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

Class: LiveUser_Auth_Common

Source Location: /LiveUser-0.13.0/Auth/Common.php

Class Overview


This class provides a set of functions for implementing a user authorisation system on live websites. All authorisation backends/containers must be extensions of this base class.


Author(s):

Version:

  • $Id: Common.php,v 1.53 2004/09/18 19:08:48 dufuz Exp $

Variables

Methods


Child classes:

LiveUser_Auth_Container_PEAR_Auth
==================== !!! WARNING !!! ========================================
LiveUser_Auth_Container_XML
This is a XML backend driver for the LiveUser class.
LiveUser_Auth_Container_MDB2
This is a PEAR::MDB2 backend driver for the LiveUser class.
LiveUser_Auth_Container_MDB
This is a PEAR::MDB backend driver for the LiveUser class.
LiveUser_Auth_Container_DB
This is a PEAR::DB backend driver for the LiveUser class.

Inherited Variables

Inherited Methods


Class Details

[line 35]
This class provides a set of functions for implementing a user authorisation system on live websites. All authorisation backends/containers must be extensions of this base class.

Requirements:

  • When using "DB" backend: PEAR::DB database abstraction layer
  • LiveUser admin GUI for easy user administration and setup of authorisation areas and rights

  • Author: Markus Wolff <wolff@21st.de>
  • Version: $Id: Common.php,v 1.53 2004/09/18 19:08:48 dufuz Exp $


[ Top ]


Class Variables

$allowDuplicateHandles =  false

[line 140]

Allow multiple users in the database to have the same login handle. Default: false.
  • Access: protected

Type:   boolean


[ Top ]

$authUserId =  0

[line 60]

Current user's database record id
  • Access: protected

Type:   integer


[ Top ]

$backendArrayIndex =  0

[line 169]

Defines the array index number of the LoginManager?s "backends" property.
  • Access: protected

Type:   integer


[ Top ]

$currentLogin =  0

[line 100]

Timestamp of current login (last to be written)
  • Access: protected

Type:   integer


[ Top ]

$encryptionModes = array('MD5'   => 'MD5',
                                 'PLAIN' => 'PLAIN',
                                 'RC4'   => 'RC4',
                                 'SHA1'  => 'SHA1')

[line 148]

Set posible encryption modes.
  • Access: protected

Type:   array


[ Top ]

$expireTime =  0

[line 120]

Auth lifetime in seconds

If this variable is set to 0, auth never expires

  • Access: protected

Type:   integer


[ Top ]

$handle =  ''

[line 43]

The handle (username) of the current user
  • Access: protected

Type:   string


[ Top ]

$idleTime =  0

[line 131]

Maximum time of idleness in seconds

Idletime gets refreshed each time, init() is called. If this variable is set to 0, idle time is never checked.

  • Access: protected

Type:   integer


[ Top ]

$init_ok =  false

[line 181]

Indicates if backend module initialized correctly. If yes,

true, if not false. Backend module won't initialize if the init value (usually an object or resource handle that identifies the backend to be used) is not of the required type.

  • Access: protected

Type:   boolean


[ Top ]

$isActive =  null

[line 74]

Is the current user allowed to login at all? If false,

a call to login() will not set $logged_in to true, even if handle and password were submitted correctly. This is useful when you want your users to be activated by an administrator before they can actually use your application. Default: false

  • See: LiveUser_Auth_Common::loggedIn
  • Access: protected

Type:   boolean


[ Top ]

$lastLogin =  0

[line 92]

Timestamp of last login (previous to currentLogin)
  • Access: protected

Type:   integer


[ Top ]

$loggedIn =  null

[line 84]

Has the current user successfully logged in? Default: false
  • See: LiveUser_Auth_Common::isActive
  • Access: protected

Type:   boolean


[ Top ]

$loginTimeout =  12

[line 110]

Number of hours that must pass between two logins to be counted as a new login. Comes in handy in some situations. Default: 12
  • Access: protected

Type:   integer


[ Top ]

$passwd =  ''

[line 52]

The password of the current user as given to the login() method.
  • Access: protected

Type:   string


[ Top ]

$passwordEncryptionMode =  'MD5'

[line 161]

Defines the algorithm used for encrypting/decrypting passwords. Default: "MD5".
  • Access: protected

Type:   string


[ Top ]

$_stack =  null

[line 189]

Error stack
  • Access: protected

Type:   PEAR_ErrorStack


[ Top ]



Method Detail

LiveUser_Auth_Common (Constructor)   [line 198]

void LiveUser_Auth_Common( $connectOptions)

Class constructor. Feel free to override in backend subclasses.
  • Var: configuration options
  • Access: protected

Parameters:

   $connectOptions   — 

[ Top ]

decryptPW   [line 269]

string decryptPW( string $encryptedPW)

Decrypts a password so that it can be compared with the user input. Uses the algorithm defined in the passwordEncryptionMode property.
  • Return: The decrypted password

Parameters:

string   $encryptedPW   —  the encrypted password

[ Top ]

disconnect   [line 243]

void disconnect( )

properly disconnect from resources
  • Access: public

Overridden in child classes as:

LiveUser_Auth_Container_XML::disconnect()
Properly disconnect from resources
LiveUser_Auth_Container_MDB2::disconnect()
properly disconnect from database
LiveUser_Auth_Container_MDB::disconnect()
Properly disconnect from database
LiveUser_Auth_Container_DB::disconnect()
Properly disconnect from database

[ Top ]

encryptPW   [line 309]

string encryptPW( string $plainPW)

Encrypts a password for storage in a backend container.

Uses the algorithm defined in the passwordEncryptionMode property.

  • Return: The encrypted password

Parameters:

string   $plainPW   —  encryption type

[ Top ]

freeze   [line 217]

array freeze( )

store all properties in an array
  • Access: public

[ Top ]

getProperty   [line 521]

mixed getProperty( string $what)

Function returns the inquired value if it exists in the class.
  • Return: null, a value or an array.

Parameters:

string   $what   —  Name of the property to be returned.

[ Top ]

isNewLogin   [line 351]

boolean isNewLogin( )

Checks if there's enough time between lastLogin and current login (now) to count as a new login.
  • Return: true if it is a new login, false if not
  • Access: public

[ Top ]

login   [line 375]

void login( string $handle, string $passwd, [boolean $checkpw = true], [boolean $updateLastLogin = true])

Tries to make a login with the given handle and password.

If $checkpw is set to false, the password won't be validated and the user will be logged in anyway. Set this option if you want to allow your users to be authenticated by a simple cookie... however, this is NOT RECOMMENDED !!! In any case, a user can't login if he's not active.


Parameters:

string   $handle   —  user handle
string   $passwd   —  user password
boolean   $checkpw   —  check password ? useful for some backends like LDAP
boolean   $updateLastLogin   —  update the last login data ?

[ Top ]

unfreeze   [line 254]

void unfreeze( array $propertyValues)

Reinitializes properties
  • Access: public

Parameters:

array   $propertyValues   — 

[ Top ]

userExists   [line 508]

mixed userExists( [boolean $checkHandle = false], [boolean $checkPW = false])

Helper function that checks if there is a user in the database who's matching the given parameters.

If $checkHandle is given and $checkPW is set to false, it only checks if a user with that handle exists. If only $checkPW is given and $checkHandle is set to false, it will check if there exists a user with that password. If both values are set to anything but false, it will find the first user in the database with both values matching. Please note:

  • If no match was found, the return value is false
  • If a match was found, the auth_user_id from the database is being returned
Whatever is returned, please keep in mind that this function only searches for the _first_ occurence of the search values in the database. So when you have multiple users with the same handle, only the ID of the first one is returned. Same goes for passwords. Searching for both password and handle should be pretty safe, though - having more than one user with the same handle/password combination in the database would be pretty stupid anyway.

Again, this does nothing in the base class. The described functionality must be implemented in a subclass overriding this method.

  • Return: user id when there is a match, false otherwise

Overridden in child classes as:

LiveUser_Auth_Container_PEAR_Auth::userExists()
not yet implemented
LiveUser_Auth_Container_XML::userExists()
Helper function that checks if there is a user in the database who's matching the given parameters.
LiveUser_Auth_Container_MDB2::userExists()
Helper function that checks if there is a user in the database who's matching the given parameters.
LiveUser_Auth_Container_MDB::userExists()
Helper function that checks if there is a user in the database who's matching the given parameters.
LiveUser_Auth_Container_DB::userExists()
Helper function that checks if there is a user in the database who's matching the given parameters.

Parameters:

boolean   $checkHandle   —  check handle ?
boolean   $checkPW   —  check password ?

[ Top ]


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