Source for file Common.php
Documentation is available at Common.php
// LiveUser: A framework for authentication and authorization in PHP applications
// Copyright (C) 2002-2003 Markus Wolff
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Base class for authentication backends.
* @author Lukas Smith <smith@backendmedia.com>
* @version $Id: Common.php,v 1.21 2004/04/22 13:18:15 lsmith Exp $
* @category authentication
* 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
* Set posible encryption modes.
var $encryptionModes = array ('MD5' => 'MD5',
* Defines the algorithm used for encrypting/decrypting
* passwords. Default: "MD5".
var $passwordEncryptionMode = 'MD5';
* The name associated with this auth container. The name is used
* when adding users from this container to the reference table
* in the permission container. This way it is possible to see
* from which auth container the user data is coming from.
* Class constructor. Feel free to override in backend subclasses.
foreach ($connectOptions as $key => $value) {
if (isset ($this->$key)) {
* Decrypts a password so that it can be compared with the user
* input. Uses the algorithm defined in the passwordEncryptionMode
* @param string password as an encrypted string
* @return string The decrypted password
$decryptedPW = 'Encryption type not supported.';
switch (strtoupper($this->passwordEncryptionMode)) {
$decryptedPW = $encryptedPW;
// MD5 can't be decoded, so return the string unmodified
$decryptedPW = $encryptedPW;
@include_once 'Crypt/Rc4.php';
'Please install Crypt_RC4 to use this feature');
$this->rc4 = & new Crypt_RC4 ('LiveUserMagicKey');
$decryptedPW = $encryptedPW;
$this->rc4->decrypt ($decryptedPW);
// SHA1 can't be decoded, so return the string unmodified
$decryptedPW = $encryptedPW;
* Encrypts a password for storage in a backend container.
* Uses the algorithm defined in the passwordEncryptionMode
* @param string password as plain text
* @return string The encrypted password
$encryptedPW = 'Encryption type not supported.';
switch (strtoupper($this->passwordEncryptionMode)) {
$encryptedPW = md5($plainPW);
@include_once 'Crypt/Rc4.php';
'Please install Crypt_RC4 to use this feature');
$this->rc4 = & new Crypt_RC4 ('LiveUserMagicKey');
$this->rc4->crypt ($encryptedPW);
'SHA1 function doesn\'t exist. Upgrade your PHP version.');
$encryptedPW = sha1($plainPW);
* Function returns the inquired value if it exists in the class.
* @param string Name of the property to be returned.
* @return mixed null, a value or an array.
if (isset ($this->$what)) {
* Adds a new user to Auth.
* @param string Handle (username).
* @param string Password (optional).
* @param boolean Sets the user active (1) or not (0) (optional).
* @param mixed If specificed no new ID will be automatically generated instead
* @param integer ID of the owning user.
* @param integer ID of the owning group.
* @param mixed If specificed no new ID will be automatically generated instead
* @param array Array of custom fields to be added
* @return mixed Users auth ID on success, PEAR error if not.
function addUser($handle, $password = '', $active = true , $owner_user_id = null ,
$owner_group_id = null , $authId = null , $customFields = array ())
'Method not supported by this container');
* Removes an existing user from Auth.
* @param string Auth user ID of the user that should be removed.
* @return mixed True on success, error object if not.
'Method not supported by this container');
* Changes user data in auth table.
* @param string Auth user ID.
* @param string Handle (username) (optional).
* @param string Password (optional).
* @param boolean Sets the user active (1) or not (0) (optional).
* @param integer ID of the owning user.
* @param integer ID of the owning group.
* @param array Array of custom fields to be updated.
* @return mixed True on success, error object if not.
function updateUser($authId, $handle = '', $password = '', $active = null ,
$owner_user_id = null , $owner_group_id = null , $customFields = array ())
'Method not supported by this container');
* Gets all users with handle, passwd, authId,
* lastlogin, is_active and individual rights.
* The array will look like this:
* $userData[0]['auth_user_id'] = 'wujha433gawefawfwfiuj2ou9823r98h';
* ['handle'] = 'myLogin';
* ['passwd'] = 'd346gs2gwaeiuhaeiuuweijfjuwaefhj';
* ['lastlogin'] = 1254801292; (Unix timestamp)
* ['is_active'] = 1; (1 = yes, 0 = no)
* @param array filters to apply to fetched data
* @param array custom fields you wane to be returned
* @return mixed Array with user data or error object.
function getUsers($filters = array (), $customFields = array ())
'Method not supported by this container');
Documentation generated on Mon, 11 Mar 2019 10:16:02 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|