Auth
[ class tree: Auth ] [ index: Auth ] [ all elements ]

Source for file Container.php

Documentation is available at Container.php

  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Martin Jansen <mj@php.net>                                  |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Container.php,v 1.17 2004/03/28 23:19:50 yavo Exp $
  20. //
  21.  
  22. define("AUTH_METHOD_NOT_SUPPORTED"-4);
  23.  
  24. /**
  25.  * Storage class for fetching login data
  26.  *
  27.  * @author   Martin Jansen <mj@php.net>
  28.  * @package  Auth
  29.  */
  30. {
  31.  
  32.     /**
  33.      * User that is currently selected from the storage container.
  34.      *
  35.      * @access public
  36.      */
  37.     var $activeUser = "";
  38.  
  39.     // {{{ Constructor
  40.  
  41.     /**
  42.      * Constructor
  43.      *
  44.      * Has to be overwritten by each storage class
  45.      *
  46.      * @access public
  47.      */
  48.     function Auth_Container()
  49.     {
  50.     }
  51.  
  52.     // }}}
  53.     // {{{ fetchData()
  54.  
  55.     /**
  56.      * Fetch data from storage container
  57.      *
  58.      * Has to be overwritten by each storage class
  59.      *
  60.      * @access public
  61.      */
  62.     function fetchData(
  63.     {
  64.     }
  65.  
  66.     // }}}
  67.     // {{{ verifyPassword()
  68.  
  69.     /**
  70.      * Crypt and verfiy the entered password
  71.      *
  72.      * @param  string Entered password
  73.      * @param  string Password from the data container (usually this password
  74.      *                 is already encrypted.
  75.      * @param  string Type of algorithm with which the password from
  76.      *                 the container has been crypted. (md5, crypt etc.)
  77.      *                 Defaults to "md5".
  78.      * @return bool   True, if the passwords match
  79.      */
  80.     function verifyPassword($password1$password2$cryptType "md5")
  81.     {
  82.         switch ($cryptType{
  83.             case "crypt" :
  84.                 return crypt($password1$password2== $password2 );
  85.                 break;
  86.     
  87.             case "none" :
  88.                 return ($password1 == $password2);
  89.                 break;
  90.     
  91.             case "md5" :
  92.                 return (md5($password1== $password2);
  93.                 break;
  94.     
  95.             default :
  96.                 if (function_exists($cryptType)) {
  97.                     return ($cryptType($password1== $password2);
  98.                 elseif (method_exists($this,$cryptType)) 
  99.                     return ($this->$cryptType($password1== $password2);
  100.                 else {
  101.                     return false;
  102.                 }
  103.                 break;
  104.         }
  105.     }
  106.  
  107.     // }}}
  108.     // {{{ listUsers()
  109.  
  110.     /**
  111.      * List all users that are available from the storage container
  112.      */
  113.     function listUsers()
  114.     {
  115.         return AUTH_METHOD_NOT_SUPPORTED;
  116.     }
  117.  
  118.     /**
  119.      * Returns a user assoc array
  120.      *
  121.      * Containers which want should overide this
  122.      *
  123.      * @param string The username
  124.      */
  125.     function getUser($username)
  126.     {
  127.         $users $this->listUsers();
  128.         if ($users === AUTH_METHOD_NOT_SUPPORTED{
  129.             return AUTH_METHOD_NOT_SUPPORTED;
  130.         }
  131.         for ($i=0; $c count($users)$i<$c$i++{
  132.             if ($users[$i]['username'== $username{
  133.                 return $users[$i];
  134.             }
  135.         }
  136.         return false;
  137.         
  138.     }
  139.  
  140.     // }}}
  141.     // {{{ addUser()
  142.  
  143.     /**
  144.      * Add a new user to the storage container
  145.      *
  146.      * @param string Username
  147.      * @param string Password
  148.      * @param array  Additional information
  149.      *
  150.      * @return boolean 
  151.      */
  152.     function addUser($username$password$additional=null)
  153.     {
  154.         return AUTH_METHOD_NOT_SUPPORTED;
  155.     }
  156.  
  157.     // }}}
  158.     // {{{ removeUser()
  159.  
  160.     /**
  161.      * Remove user from the storage container
  162.      *
  163.      * @param string Username
  164.      */
  165.     function removeUser($username)
  166.     {
  167.         return AUTH_METHOD_NOT_SUPPORTED;
  168.     }
  169.  
  170.     // }}}
  171.  
  172.  
  173.     // {{{ changePassword()
  174.  
  175.     /**
  176.      * Change password for user in the storage container
  177.      *
  178.      * @param string Username
  179.      * @param string The new password
  180.      */
  181.     function changePassword($username$password)
  182.     {
  183.         return AUTH_METHOD_NOT_SUPPORTED;
  184.     }
  185.  
  186.     // }}}
  187.  
  188. }
  189. ?>

Documentation generated on Mon, 11 Mar 2019 10:17:23 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.