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

Source for file Session.php

Documentation is available at Session.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3.  
  4. /**
  5.  * A framework for authentication and authorization in PHP applications
  6.  *
  7.  * LiveUser is an authentication/permission framework designed
  8.  * to be flexible and easily extendable.
  9.  *
  10.  * Since it is impossible to have a
  11.  * "one size fits all" it takes a container
  12.  * approach which should enable it to
  13.  * be versatile enough to meet most needs.
  14.  *
  15.  * PHP version 4 and 5
  16.  *
  17.  * LICENSE: This library is free software; you can redistribute it and/or
  18.  * modify it under the terms of the GNU Lesser General Public
  19.  * License as published by the Free Software Foundation; either
  20.  * version 2.1 of the License, or (at your option) any later version.
  21.  *
  22.  * This library is distributed in the hope that it will be useful,
  23.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  25.  * Lesser General Public License for more details.
  26.  *
  27.  * You should have received a copy of the GNU Lesser General Public
  28.  * License along with this library; if not, write to the Free Software
  29.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  30.  * MA  02111-1307  USA
  31.  *
  32.  *
  33.  * @category authentication
  34.  * @package LiveUser
  35.  * @author  Markus Wolff <wolff@21st.de>
  36.  * @author  Helgi Þormar Þorbjörnsson <dufuz@php.net>
  37.  * @author  Lukas Smith <smith@pooteeweet.org>
  38.  * @author  Arnaud Limbourg <arnaud@php.net>
  39.  * @author  Pierre-Alain Joye <pajoye@php.net>
  40.  * @author  Bjoern Kraus <krausbn@php.net>
  41.  * @copyright 2002-2006 Markus Wolff
  42.  * @license http://www.gnu.org/licenses/lgpl.txt
  43.  * @version CVS: $Id: Session.php,v 1.29 2006/03/14 13:03:32 lsmith Exp $
  44.  * @link http://pear.php.net/LiveUser
  45.  */
  46.  
  47. require_once 'LiveUser/Auth/Common.php';
  48.  
  49. /**
  50.  * Session based container for Authentication
  51.  *
  52.  * This is a backend driver for a simple session based anonymous LiveUser class.
  53.  *
  54.  * Requirements:
  55.  * - File "LiveUser.php" (contains the parent class "LiveUser")
  56.  *
  57.  * @category authentication
  58.  * @package LiveUser
  59.  * @author  Lukas Smith <smith@pooteeweet.org>
  60.  * @copyright 2002-2006 Markus Wolff
  61.  * @license http://www.gnu.org/licenses/lgpl.txt
  62.  * @version Release: @package_version@
  63.  * @link http://pear.php.net/LiveUser
  64.  */
  65. {
  66.     /**
  67.      * name of the key containing the Session phrase inside the auth session array
  68.      *
  69.      * @var    string 
  70.      * @access public
  71.      */
  72.     var $sessionKey = 'password';
  73.  
  74.     /**
  75.      * Load the storage container
  76.      *
  77.      * @param   array  array containing the configuration.
  78.      * @param string  name of the container that should be used
  79.      * @return bool true on success or false on failure
  80.      *
  81.      * @access public
  82.      */
  83.     function init(&$conf$containerName)
  84.     {
  85.         parent::init($conf$containerName);
  86.  
  87.         return true;
  88.     }
  89.  
  90.     /**
  91.      * Does nothing
  92.      *
  93.      * @return bool true on success or false on failure
  94.      *
  95.      * @access private
  96.      */
  97.     function _updateUserData()
  98.     {
  99.         return true;
  100.     }
  101.  
  102.     /**
  103.      * Reads user data from the given data source
  104.      * Compares $passwd with a string inside the $_SESSION array
  105.      *
  106.      * @param  string user handle
  107.      * @param  string user password
  108.      * @param  bool|intif the user data should be read using the auth user id
  109.      * @return bool true on success or false on failure
  110.      *
  111.      * @access public
  112.      */
  113.     function readUserData($handle ''$passwd ''$auth_user_id = false)
  114.     {
  115.         if (!$auth_user_id{
  116.             if (!is_null($this->tables['users']['fields']['passwd'])) {
  117.                 if (!array_key_exists($this->alias['passwd']$_SESSION)
  118.                     || $_SESSION[$this->alias['passwd']] !== $passwd
  119.                 {
  120.                     return false;
  121.                 }
  122.             }
  123.             $this->propertyValues = $this->tables['users']['fields'];
  124.             $this->propertyValues['handle']    $handle;
  125.             $this->propertyValues['passwd']    $passwd;
  126.             $this->propertyValues['is_active'= true;
  127.             $this->propertyValues['lastlogin'time();
  128.         }
  129.  
  130.         return true;
  131.     }
  132. }
  133. ?>

Documentation generated on Mon, 28 Jan 2008 03:30:31 -0500 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.