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.19 2004/07/04 16:52:20 yavo Exp $
  20. //
  21.  
  22. /**
  23.  * Storage class for fetching login data
  24.  *
  25.  * @author   Martin Jansen <mj@php.net>
  26.  * @package  Auth
  27.  */
  28. {
  29.  
  30.     /**
  31.      * User that is currently selected from the storage container.
  32.      *
  33.      * @access public
  34.      */
  35.     var $activeUser = "";
  36.  
  37.     /**
  38.      * Constructor
  39.      *
  40.      * Has to be overwritten by each storage class
  41.      *
  42.      * @access public
  43.      */
  44.     function Auth_Container({
  45.     }
  46.  
  47.     /**
  48.      * Fetch data from storage container
  49.      *
  50.      * Has to be overwritten by each storage class
  51.      *
  52.      * @access public
  53.      */
  54.     function fetchData($username$password$isChallengeResponce=false{
  55.     }
  56.  
  57.     // }}}
  58.     // {{{ verifyPassword()
  59.  
  60.     /**
  61.      * Crypt and verfiy the entered password
  62.      *
  63.      * @param  string Entered password
  64.      * @param  string Password from the data container (usually this password
  65.      *                 is already encrypted.
  66.      * @param  string Type of algorithm with which the password from
  67.      *                 the container has been crypted. (md5, crypt etc.)
  68.      *                 Defaults to "md5".
  69.      * @return bool   True, if the passwords match
  70.      */
  71.     function verifyPassword($password1$password2$cryptType "md5")
  72.     {
  73.         switch ($cryptType{
  74.             case "crypt" :
  75.                 return crypt($password1$password2== $password2 );
  76.                 break;
  77.             case "none" :
  78.             case "" :
  79.                 return ($password1 == $password2);
  80.                 break;
  81.             case "md5" :
  82.                 return (md5($password1== $password2);
  83.                 break;
  84.             default :
  85.                 if (function_exists($cryptType)) {
  86.                     return ($cryptType($password1== $password2);
  87.                 elseif (method_exists($this,$cryptType)) 
  88.                     return ($this->$cryptType($password1== $password2);
  89.                 else {
  90.                     return false;
  91.                 }
  92.                 break;
  93.         }
  94.     }
  95.     
  96.     /**
  97.       * Returns true if the container supports Challenge Responce
  98.       * password authenthication
  99.       */
  100.     function supportsChallengeResponce({
  101.         return(false);
  102.     }
  103.     
  104.     /**
  105.       * Returns the crypt current crypt type of the container
  106.       *
  107.       * @return string 
  108.       */
  109.     function getCryptType({
  110.         return('');
  111.     }
  112.  
  113.     /**
  114.      * List all users that are available from the storage container
  115.      */
  116.     function listUsers({
  117.         return AUTH_METHOD_NOT_SUPPORTED;
  118.     }
  119.  
  120.     /**
  121.      * Returns a user assoc array
  122.      *
  123.      * Containers which want should overide this
  124.      *
  125.      * @param string The username
  126.      */
  127.     function getUser($username{
  128.         $users $this->listUsers();
  129.         if ($users === AUTH_METHOD_NOT_SUPPORTED{
  130.             return AUTH_METHOD_NOT_SUPPORTED;
  131.         }
  132.         for ($i=0; $c count($users)$i<$c$i++{
  133.             if ($users[$i]['username'== $username{
  134.                 return $users[$i];
  135.             }
  136.         }
  137.         return false;
  138.     }
  139.  
  140.     /**
  141.      * Add a new user to the storage container
  142.      *
  143.      * @param string Username
  144.      * @param string Password
  145.      * @param array  Additional information
  146.      *
  147.      * @return boolean 
  148.      */
  149.     function addUser($username$password$additional=null{
  150.         return AUTH_METHOD_NOT_SUPPORTED;
  151.     }
  152.  
  153.     /**
  154.      * Remove user from the storage container
  155.      *
  156.      * @param string Username
  157.      */
  158.     function removeUser($username{
  159.         return AUTH_METHOD_NOT_SUPPORTED;
  160.     }
  161.  
  162.     /**
  163.      * Change password for user in the storage container
  164.      *
  165.      * @param string Username
  166.      * @param string The new password
  167.      */
  168.     function changePassword($username$password{
  169.         return AUTH_METHOD_NOT_SUPPORTED;
  170.     }
  171.  
  172. }
  173. ?>

Documentation generated on Mon, 11 Mar 2019 13:52:32 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.