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

Class: LiveUser

Source Location: /LiveUser-0.16.7/LiveUser.php

Class Overview


This is a manager class for a user login system using the LiveUser class. It creates a LiveUser object, takes care of the whole login process and stores the LiveUser object in a session.


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2002-2005 Markus Wolff

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 181]
This is a manager class for a user login system using the LiveUser class. It creates a LiveUser object, takes care of the whole login process and stores the LiveUser object in a session.

You can also configure this class to try to connect to more than one server that can store user information - each server requiring a different backend class.

An example would be to create a login system for a live website that first queries the local database and if the requested user is not found, it tries to find it in your company's LDAP server. It means you don't have to create several user accounts for your employees so that they can access closed sections of your website - everyone can use one account.

NOTE: No browser output may be made before using this class, because it will try to send HTTP headers such as cookies and redirects.

Requirements:

  • Should run on PHP version 4.2.0 (required for PEAR_Errorstack or higher, tested only from 4.2.1 onwards
Thanks to: Bjoern Schotte, Kristian Koehntopp, Antonio Guerra



[ Top ]


Class Variables

$dispatcher =  null

[line 319]

Stores the event dispatcher which handles notifications
  • Access: protected

Type:   object


[ Top ]

$log =  null

[line 289]

PEAR::Log object used for error logging by ErrorStack
  • Access: public

Type:   Log


[ Top ]



Method Detail

LiveUser (Constructor)   [line 330]

void LiveUser( &$debug, bool|object $debug)

Constructor
  • Access: protected

Parameters:

bool|object    $debug   —  Boolean that indicates if a log instance should be created or an instance of a class that implements the PEAR:Log interface.
   &$debug   — 

[ Top ]

arrayMergeClobber   [line 636]

array|false arrayMergeClobber( array $a1, array $a2)

Clobbers two arrays together.

Function taken from the user notes of array_merge_recursive used in LiveUser::readConfig() may be called statically

  • Return: array on success and false on error
  • Author: kc@hireability.com
  • Access: public

Parameters:

array   $a1   —  array that should be clobbered
array   $a2   —  array that should be clobbered

[ Top ]

authFactory   [line 544]

object|false &authFactory( array|file &$conf, string $containerName, [string $classprefix = 'LiveUser_'])

Creates an instance of an auth object.
  • Return: Returns an instance of an auth container class or false on error
  • Access: public

Parameters:

array|file   &$conf   —  Name of array containing the configuration.
string   $containerName   —  Name of the container we'll be using.
string   $classprefix   —  Prefix of the class that will be used.

[ Top ]

checkGroup   [line 1443]

boolean checkGroup( array|int $groups)

Wrapper method for the permission object's own checkGroup method.
  • Return: true on success or false on failure
  • Access: public

Parameters:

array|int   $groups   —  A group id or an array of groups.

[ Top ]

checkRight   [line 1385]

int|false checkRight( array|int $rights)

Wrapper method for the permission object's own checkRight method.
  • Return: level if the user has the right/rights false if not
  • Access: public

Parameters:

array|int   $rights   —  A right id or an array of rights.

[ Top ]

checkRightLevel   [line 1425]

boolean checkRightLevel( array|int $rights, array|int $owner_user_id, array|int $owner_group_id)

Wrapper method for the permission object's own checkRightLevel method.
  • Return: true on success or false on failure
  • Access: public

Parameters:

array|int   $rights   —  A right id or an array of rights.
array|int   $owner_user_id   —  Id or array of Ids of the owner of the
array|int   $owner_group_id   —  Id or array of Ids of the group of the ressource for which the right is requested.

[ Top ]

cryptRC4Factory   [line 758]

object returns &cryptRC4Factory( string $secret)

Creates an instance of the PEAR::Crypt_Rc4 class.
  • Return: an instance of the Crypt_RC4 class
  • Access: public

Parameters:

string   $secret   —  token to use to encrypt data

[ Top ]

disconnect   [line 1129]

boolean disconnect( )

Properly disconnect resources in the active container
  • Return: true on success or false on failure
  • Access: public

[ Top ]

factory   [line 442]

LiveUser|false &factory( &$conf, array $conf)

Returns an instance of the login manager class.

This array contains private options defined by the following associative keys:

  1.  array(
  2.   'debug' => false/true or an instance of a class that implements the PEAR:Log interface
  3.   'session'  => array(
  4.       'name'    => 'liveuser session name',
  5.       'varname' => 'liveuser session var name'
  6.   ),
  7.  // The session_save_handler options are optional. If they are specified,
  8.  // session_set_save_handler() will be called with the parameters
  9.   'session_save_handler' => array(
  10.       'open'    => 'name of the open function/method',
  11.       'close'   => 'name of the close function/method',
  12.       'read'    => 'name of the read function/method',
  13.       'write'   => 'name of the write function/method',
  14.       'destroy' => 'name of the destroy function/method',
  15.       'gc'      => 'name of the gc function/method',
  16.   ),
  17.  // The session_cookie_params options are optional. If they are specified,
  18.  // session_set_cookie_params() will be called with the parameters
  19.   'session_cookie_params' => array(
  20.       'lifetime' => 'Cookie lifetime in days',
  21.       'path'     => 'Cookie path',
  22.       'domain'   => 'Cookie domain',
  23.       'secure'   => 'Cookie send only over secure connections',
  24.   ),
  25.  'cache_perm' => if the permission data should be cached inside the session
  26.   'login' => array(
  27.       'force'    => 'Should the user be forced to login'
  28.       'regenid'  => 'Should the session be regenerated on login'
  29.   ),
  30.   'logout' => array(
  31.       'destroy'  => 'Whether to destroy the session on logout' false or true
  32.   ),
  33.  // The cookie options are optional. If they are specified, the Remember Me
  34.  // feature is activated.
  35.   'cookie' => array(
  36.       'name'     => 'Name of Remember Me cookie',
  37.       'lifetime' => 'Cookie lifetime in days',
  38.       'path'     => 'Cookie path',
  39.       'domain'   => 'Cookie domain',
  40.       'secret'   => 'Secret key used for cookie value encryption',
  41.       'savedir'  => '/absolute/path/to/writeable/directory' // No / at the end !
  42.       'secure'   => 'Cookie send only over secure connections',
  43.   ),
  44.   'authContainers' => array(
  45.       'name' => array(
  46.             'type'            => 'DB',
  47.             'loginTimeout'    => 0,
  48.             'expireTime'      => 3600,
  49.             'idleTime'        => 1800,
  50.             'allowDuplicateHandles' => false,
  51.             'allowEmptyPasswords'   => false,
  52.             'storage' => array(
  53.                 'connection'      => 'db connection object, use this or dsn',
  54.                 'dsn'             => 'database dsn, use this or connection',
  55.            ),
  56.            'externalValues' => array(
  57.                   'values'      => &$_SERVER,
  58.                   'keysToCheck' => array('HTTP_USER_AGENT')
  59.            ),
  60.       ),
  61.   ),
  62.   'permContainer' => array(
  63.       'type'     => 'Complex',
  64.       'storage'  => array(
  65.           'MDB2' => array(
  66.               'dsn'       => $dsn,
  67.               'prefix'    => 'liveuser_'
  68.               'tables'    => array(),
  69.               'fields'    => array(),
  70.               'alias'     => array(),
  71.               'force_seq' => true,
  72.           ),
  73.       ),
  74.   ),

Other options in the configuration file relative to the Auth and Perm containers depend on what the containers expect. Refer to the Containers documentation. The examples for containers provided are just general do not reflect all the options for all containers.

  • Return: Returns an object of either LiveUser or false on error if so use LiveUser::getErrors() to get the errors
  • See: LiveUser::getErrors
  • Access: public

Parameters:

array   $conf   —  Config array to configure.
   &$conf   — 

[ Top ]

fileExists   [line 659]

boolean fileExists( string $file)

Checks if a file exists in the include path.
  • Return: true success and false on error
  • Access: public

Parameters:

string   $file   —  filename

[ Top ]

getErrors   [line 502]

array getErrors( )

Wrapper method to get the Error Stack
  • Return: an array of the errors or false if there are no errors
  • Access: public

[ Top ]

getOption   [line 839]

mixed getOption( string $option)

Returns the value of an option
  • Return: the option value or false on failure
  • Access: public

Parameters:

string   $option   —  option name

[ Top ]

getProperty   [line 1510]

mixed getProperty( string $what, [string $container = 'auth'])

Wrapper method to access properties from the auth and permission containers.
  • Return: a value or an array.
  • Access: public

Parameters:

string   $what   —  Name of the property to be returned.
string   $container   —  'auth' or 'perm'

[ Top ]

getStatus   [line 1568]

integer getStatus( )

Get the current status.
  • See: LIVEUSER_STATUS_* constants
  • Access: public

[ Top ]

init   [line 896]

boolean init( [string $handle = ''], [string $passwd = ''], [boolean $logout = false], [boolean $remember = false])

Tries to retrieve auth object from session.

If this fails, the method attempts a login based on the parameters or cookie data

  • Return: true if init process well, false if something went wrong.
  • Access: public

Parameters:

string   $handle   —  handle of the user trying to authenticate
string   $passwd   —  password of the user trying to authenticate
boolean   $logout   —  set to true if user wants to logout
boolean   $remember   —  set if remember me is set

[ Top ]

isInactive   [line 1495]

boolean isInactive( )

Function that determines if the user exists but hasn't yet been declared "active" by an administrator.

Use this to check if this was the reason why a user was not able to login. true == user account is NOT active false == user account is active

  • Return: true if the user account is *not* active false if the user account *is* active
  • Access: public

[ Top ]

isLoggedIn   [line 1472]

boolean isLoggedIn( )

Checks if a user is logged in.
  • Return: true if user is logged in, false if not
  • Access: public

[ Top ]

loadClass   [line 518]

boolean loadClass( string $classname)

Loads a PEAR class
  • Return: true success or false on failure
  • Access: public

Parameters:

string   $classname   —  classname

[ Top ]

login   [line 963]

boolean login( [string $handle = ''], [string $passwd = ''], [boolean $remember = false])

Tries to log the user in by trying all the Auth containers defined in the configuration file until there is a success or failure.
  • Return: true on success or false on failure
  • Access: public

Parameters:

string   $handle   —  handle of the user trying to authenticate
string   $passwd   —  password of the user trying to authenticate
boolean   $remember   —  set rememberMe cookie

[ Top ]

logout   [line 1345]

void logout( [boolean $direct = true])

This destroys the session object.
  • Access: public

Parameters:

boolean   $direct   —  set to true if the logout was initiated directly

[ Top ]

PEARLogFactory   [line 726]

void &PEARLogFactory( &$log, bool|object $log)

This method lazy loads PEAR::Log.
  • Access: protected

Parameters:

bool|object    $log   —  Boolean that indicates if a log instance should be created or an instance of a class that implements the PEAR:Log interface.
   &$log   — 

[ Top ]

permFactory   [line 567]

object|false &permFactory( array|file &$conf, [string $classprefix = 'LiveUser_'])

Creates an instance of an perm object.
  • Return: Returns an instance of a perm container class or false on error
  • Access: public

Parameters:

array|file   &$conf   —  Name of array containing the configuration.
string   $classprefix   —  Prefix of the class that will be used.

[ Top ]

readConfig   [line 679]

boolean readConfig( array|file &$conf, string 1)

Reads the configuration.
  • Return: true on success or false on failure
  • Access: public

Parameters:

string   1   —  Name of array containing the configuration
array|file   &$conf   —  Conf array or file path to configuration

[ Top ]

setOption   [line 820]

boolean setOption( string $option, mixed $value)

Sets an option.
  • Return: true on success or false on failure
  • See: LiveUser::_options
  • Access: public

Parameters:

string   $option   —  option name
mixed   $value   —  value for the option

[ Top ]

singleton   [line 475]

LiveUser|false &singleton( &$conf, [array $signature = null], array $conf)

This uses the singleton pattern, making sure you have one and only instance of the class.

In PHP4 you MUST call this method with the $var = &LiveUser::singleton() syntax. Without the ampersand (&) in front of the method name, you will not get a reference, you will get a copy.

  • Return: Returns an object of either LiveUser or false on failure
  • See: LiveUser::getErrors
  • See: LiveUser::factory
  • Access: public

Parameters:

array   $conf   —  Config array to configure.
array   $signature   —  Signature by which the given instance can be referenced later
   &$conf   — 

[ Top ]

statusMessage   [line 1593]

string statusMessage( int $value)

Return a textual status message for a LiveUser status code.
  • Return: error message
  • Access: public

Parameters:

int   $value   —  status code

[ Top ]

storageFactory   [line 590]

object|false &storageFactory( array &$confArray, [string $classprefix = 'LiveUser_Perm_'])

Returns an instance of a storage Container.
  • Return: will return an instance of a Storage container or false upon error
  • Access: protected

Parameters:

array   &$confArray   —  configuration array to pass to the storage container
string   $classprefix   —  Prefix of the class that will be used.

[ Top ]

updateProperty   [line 1534]

boolean updateProperty( boolean $auth, [boolean $perm = null])

updates the properties of the containers from the original source
  • Access: public

Parameters:

boolean   $auth   —  if the auth container should be updated
boolean   $perm   —  if the perm container should be updated

[ Top ]


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