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.15 2003/10/19 14:03:19 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 (($password2 == "**" $password1||
  85.                     (crypt($password1$password2== $password2)
  86.                     );
  87.             break;
  88.  
  89.         case "none" :
  90.             return ($password1 == $password2);
  91.             break;
  92.  
  93.         case "md5" :
  94.             return (md5($password1== $password2);
  95.             break;
  96.  
  97.         default :
  98.             if (function_exists($cryptType)) {
  99.                 return ($cryptType($password1== $password2);
  100.             }
  101.             else if (method_exists($this,$cryptType)) 
  102.                 return ($this->$cryptType($password1== $password2);
  103.             else {
  104.                 return false;
  105.             }
  106.             break;
  107.         }
  108.     }
  109.  
  110.     // }}}
  111.     // {{{ listUsers()
  112.  
  113.     /**
  114.      * List all users that are available from the storage container
  115.      */
  116.     function listUsers()
  117.     {
  118.         return AUTH_METHOD_NOT_SUPPORTED;
  119.     }
  120.  
  121.     /**
  122.      * Returns a user assoc array
  123.      *
  124.      * Containers which want should overide this
  125.      *
  126.      * @param string The username
  127.      */
  128.     function getUser($username)
  129.     {
  130.         $users $this->listUsers();
  131.         if($users === AUTH_METHOD_NOT_SUPPORTED){
  132.             return(AUTH_METHOD_NOT_SUPPORTED);
  133.         }
  134.         for($i=0;$c count($users),$i<$c;$i++){
  135.             if($users[$i]['username'== $username){
  136.                 return($users[$i]);
  137.             }
  138.         }
  139.         return(false);
  140.         
  141.     }
  142.  
  143.     // }}}
  144.     // {{{ addUser()
  145.  
  146.     /**
  147.      * Add a new user to the storage container
  148.      *
  149.      * @param string Username
  150.      * @param string Password
  151.      * @param array  Additional information
  152.      *
  153.      * @return boolean 
  154.      */
  155.     function addUser($username$password$additional=null)
  156.     {
  157.         return AUTH_METHOD_NOT_SUPPORTED;
  158.     }
  159.  
  160.     // }}}
  161.     // {{{ removeUser()
  162.  
  163.     /**
  164.      * Remove user from the storage container
  165.      *
  166.      * @param string Username
  167.      */
  168.     function removeUser($username)
  169.     {
  170.         return AUTH_METHOD_NOT_SUPPORTED;
  171.     }
  172.  
  173.     // }}}
  174.  
  175. }
  176. ?>

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