cvs: pear /Perm_LiveUser LiveUser.php /Perm_LiveUser/Admin/Auth Common.php /Perm_LiveUser/Admin/Auth/Container DB.php MDB.php
/Perm_LiveUser/Auth/Container DB.php MDB.php /Perm_LiveUser/examples/example4 main.inc.php
| From: | Lukas Smith | Date: | Fri, 26 Sep 2003 14:32:17 +0000 |
| Subject: | cvs: pear /Perm_LiveUser LiveUser.php /Perm_LiveUser/Admin/Auth Common.php /Perm_LiveUser/Admin/Auth/Container DB.php MDB.php /Perm_LiveUser/Auth/Container DB.php MDB.php /Perm_LiveUser/examples/example4 main.inc.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-13107@lists.php.net to get a copy of this message | ||
lsmith Fri Sep 26 10:32:17 2003 EDT
Modified files:
/pear/Perm_LiveUser LiveUser.php
/pear/Perm_LiveUser/Admin/Auth Common.php
/pear/Perm_LiveUser/Admin/Auth/Container DB.php MDB.php
/pear/Perm_LiveUser/Auth/Container DB.php MDB.php
/pear/Perm_LiveUser/examples/example4 main.inc.php
Log:
- renamed password field in the database containers to passwd to prevent conflicts with certain
RDBMS
- lowercased all column fields to prevent issues with certain RDBMS
- phpdoc
Index: pear/Perm_LiveUser/LiveUser.php diff -u pear/Perm_LiveUser/LiveUser.php:1.41 pear/Perm_LiveUser/LiveUser.php:1.42 --- pear/Perm_LiveUser/LiveUser.php:1.41 Thu Sep 25 15:13:36 2003 +++ pear/Perm_LiveUser/LiveUser.php Fri Sep 26 10:32:14 2003 @@ -91,7 +91,7 @@ * @author Lukas Smith <smith@backendmedia.com> * @author Pierre-Alain Joye <pajoye@php.net> * @author Arnaud Limbourg <arnaud@php.net> - * @version $Id: LiveUser.php,v 1.41 2003/09/25 19:13:36 arnaud Exp $ + * @version $Id: LiveUser.php,v 1.42 2003/09/26 14:32:14 lsmith Exp $ * @package LiveUser */ class LiveUser @@ -141,10 +141,10 @@ * 'idleTime' => 1800, * 'allowDuplicateHandles' => 0, * 'authTable' => 'liveuser_users', - * 'authTableCols' => array('userId' => 'auth_user_id', + * 'authTableCols' => array('user_id' => 'auth_user_id', * 'handle' => 'handle', - * 'password' => 'password', - * 'lastLogin' => 'lastlogin' + * 'passwd' => 'passwd', + * 'lastlogin' => 'lastlogin' * ) * ) * ), @@ -519,14 +519,14 @@ return false; } + // Determine if user wanted to log out + $this->processLogout($logout); + // Set the name of the current session session_name($this->_options['session']['name']); // If there's no session yet, start it now session_start(); - // Determine if user wanted to log out - $this->processLogout($logout); - // Include needed permission container class if (is_array($this->permContainer)) { include_once 'LiveUser/Perm/Container/' . $this->permContainer['type'] . '.php'; @@ -882,6 +882,11 @@ if ($this->_error) { return false; } + + // Set the name of the current session + session_name($this->_options['session']['name']); + // If there's no session yet, start it now + session_start(); // If a callback function is set, call it if (!empty($this->_options['logout']['function']) && Index: pear/Perm_LiveUser/Admin/Auth/Common.php diff -u pear/Perm_LiveUser/Admin/Auth/Common.php:1.8 pear/Perm_LiveUser/Admin/Auth/Common.php:1.9 --- pear/Perm_LiveUser/Admin/Auth/Common.php:1.8 Thu Sep 25 15:33:44 2003 +++ pear/Perm_LiveUser/Admin/Auth/Common.php Fri Sep 26 10:32:14 2003 @@ -20,7 +20,7 @@ * Base class for authentication backends. * * @author Lukas Smith <smith@backendmedia.com> - * @version $Id: Common.php,v 1.8 2003/09/25 19:33:44 arnaud Exp $ + * @version $Id: Common.php,v 1.9 2003/09/26 14:32:14 lsmith Exp $ * @package LiveUser * @category authentication */ @@ -48,7 +48,7 @@ 'PLAIN' => 'PLAIN'); /** - * Defines the algorhythm used for encrypting/decrypting + * Defines the algorithm used for encrypting/decrypting * passwords. Default: "MD5". * * @access private @@ -68,7 +68,7 @@ /** * Decrypts a password so that it can be compared with the user - * input. Uses the algorhythm defined in the passwordEncryptionMode + * input. Uses the algorithm defined in the passwordEncryptionMode * property. * * @access public @@ -94,7 +94,7 @@ /** * Encrypts a password for storage in a backend container. - * Uses the algorhythm defined in the passwordEncryptionMode + * Uses the algorithm defined in the passwordEncryptionMode * property. * * @access public @@ -179,17 +179,16 @@ } /** - * Gets all users with handle, password, authId, permId, currentLogin, - * lastLogin, isActive and individual rights. + * Gets all users with handle, passwd, authId, + * lastlogin, is_active and individual rights. * * The array will look like this: * <code> - * $userData[0]['authId'] = 'wujha433gawefawfwfiuj2ou9823r98h'; + * $userData[0]['auth_user_id'] = 'wujha433gawefawfwfiuj2ou9823r98h'; * ['handle'] = 'myLogin'; - * ['password'] = 'd346gs2gwaeiuhaeiuuweijfjuwaefhj'; - * ['currentLogin'] = 1254801292; (Unix timestamp) - * ['lastLogin'] = 1254801292; (Unix timestamp) - * ['isActive'] = 1; (1 = yes, 0 = no) + * ['passwd'] = 'd346gs2gwaeiuhaeiuuweijfjuwaefhj'; + * ['lastlogin'] = 1254801292; (Unix timestamp) + * ['is_active'] = 1; (1 = yes, 0 = no) * </code> * * @access public Index: pear/Perm_LiveUser/Admin/Auth/Container/DB.php diff -u pear/Perm_LiveUser/Admin/Auth/Container/DB.php:1.14 pear/Perm_LiveUser/Admin/Auth/Container/DB.php:1.15 --- pear/Perm_LiveUser/Admin/Auth/Container/DB.php:1.14 Thu Sep 25 15:33:45 2003 +++ pear/Perm_LiveUser/Admin/Auth/Container/DB.php Fri Sep 26 10:32:15 2003 @@ -48,7 +48,7 @@ * This class is only experimental. API may change. Use it at your own risk. * * @author Bj?rn Kraus <krausbn@php.net> - * @version $Id: DB.php,v 1.14 2003/09/25 19:33:45 arnaud Exp $ + * @version $Id: DB.php,v 1.15 2003/09/26 14:32:15 lsmith Exp $ * @package LiveUser * @category authentication */ @@ -83,19 +83,19 @@ /** * Columns of the auth table. * Associative array with the names of the auth table columns. - * The 'userId', 'handle' and 'password' fields have to be set. - * 'lastLogin' and 'isActive' are optional. + * The 'user_id', 'handle' and 'passwd' fields have to be set. + * 'lastlogin' and 'is_active' are optional. * It doesn't make sense to set only one of the time columns without the * other. * * @access public * @var array */ - var $authTableCols = array('userId' => 'auth_user_id', + var $authTableCols = array('user_id' => 'auth_user_id', 'handle' => 'handle', - 'password' => 'password', - 'lastLogin' => 'lastlogin', - 'isActive' => 'is_active'); + 'passwd' => 'passwd', + 'lastlogin' => 'lastlogin', + 'is_active' => 'is_active'); /** * Indicates if backend module initialized correctly. If yes, @@ -126,11 +126,11 @@ * 'allowDuplicateHandles' => 0, * 'authTable' => 'users', * 'authTableCols' => array( - * 'userId' => 'auth_user_id', + * 'user_id' => 'auth_user_id', * 'handle' => 'handle', - * 'password' => 'password', - * 'lastLogin' => 'lastlogin', - * 'isActive' => 'is_active' + * 'passwd' => 'passwd', + * 'lastlogin' => 'lastlogin', + * 'is_active' => 'is_active' * ) * ) * ), @@ -152,11 +152,11 @@ * 'allowDuplicateHandles' => 0, * 'authTable' => 'users', * 'authTableCols' => array( - * 'userId' => 'auth_user_id', + * 'user_id' => 'auth_user_id', * 'handle' => 'handle', - * 'password' => 'password', - * 'lastLogin' => 'lastlogin', - * 'isActive' => 'is_active' + * 'passwd' => 'passwd', + * 'lastlogin' => 'lastlogin', + * 'is_active' => 'is_active' * ) * ); * @@ -229,10 +229,10 @@ INSERT INTO ' . $this->authTable . ' ( - ' . $this->authTableCols['userId'] . ', + ' . $this->authTableCols['user_id'] . ', ' . $this->authTableCols['handle'] . ', - ' . $this->authTableCols['password'] . ', - ' . $this->authTableCols['isActive'] . ' + ' . $this->authTableCols['passwd'] . ', + ' . $this->authTableCols['is_active'] . ' ) VALUES ( @@ -309,7 +309,7 @@ if (!empty($password)) { $updateValues[] = - $this->authTableCols['password'] . ' = ' + $this->authTableCols['passwd'] . ' = ' . $this->dbc->quote($this->encryptPW($password)); } @@ -320,7 +320,7 @@ $active = 'N'; } $updateValues[] = - $this->authTableCols['isActive'] . ' = ' . $this->dbc->quote($active); + $this->authTableCols['is_active'] . ' = ' . $this->dbc->quote($active); } if (count($updateValues) >= 1) { @@ -330,7 +330,7 @@ } $query .= ' WHERE - ' . $this->authTableCols['userId'] . '=' . $this->dbc->quote($authId); + ' . $this->authTableCols['user_id'] . '=' . $this->dbc->quote($authId); $result = $this->dbc->query($query); @@ -342,16 +342,16 @@ } // end func changeUser /** - * Gets all users with handle, password, authId, permId - * lastLogin, isActive and individual rights. + * Gets all users with handle, passwd, auth_user_id + * lastlogin, is_active and individual rights. * * The array will look like this: * <code> - * $userData[0]['authId'] = 'wujha433gawefawfwfiuj2ou9823r98h'; + * $userData[0]['auth_user_id'] = 'wujha433gawefawfwfiuj2ou9823r98h'; * ['handle'] = 'myLogin'; - * ['password'] = 'd346gs2gwaeiuhaeiuuweijfjuwaefhj'; - * ['lastLogin'] = 1254801292; (Unix timestamp) - * ['isActive'] = 1; (1 = yes, 0 = no) + * ['passwd'] = 'd346gs2gwaeiuhaeiuuweijfjuwaefhj'; + * ['lastlogin'] = 1254801292; (Unix timestamp) + * ['is_active'] = 1; (1 = yes, 0 = no) * </code> * * @access public @@ -366,11 +366,11 @@ // First: Get all data from auth table. $query = ' SELECT - ' . $this->authTableCols['userId'] . ' AS authId, + ' . $this->authTableCols['user_id'] . ' AS auth_user_id, ' . $this->authTableCols['handle'] . ' AS handle, - ' . $this->authTableCols['password'] . ' AS password, - ' . $this->authTableCols['lastLogin'] . ' AS lastLogin, - ' . $this->authTableCols['isActive'] . ' AS isActive + ' . $this->authTableCols['passwd'] . ' AS passwd, + ' . $this->authTableCols['lastlogin'] . ' AS lastlogin, + ' . $this->authTableCols['is_active'] . ' AS is_active FROM ' . $this->authTable; @@ -384,10 +384,10 @@ // with MDB admin container reset($userData); while (list($key, $value) = each($userData)) { - if ($value['isActive'] == 'Y') { - $userData[$key]['isActive'] == 1; + if ($value['is_active'] == 'Y') { + $userData[$key]['is_active'] == 1; } else { - $userData[$key]['isActive'] == 0; + $userData[$key]['is_active'] == 0; } } Index: pear/Perm_LiveUser/Admin/Auth/Container/MDB.php diff -u pear/Perm_LiveUser/Admin/Auth/Container/MDB.php:1.16 pear/Perm_LiveUser/Admin/Auth/Container/MDB.php:1.17 --- pear/Perm_LiveUser/Admin/Auth/Container/MDB.php:1.16 Thu Sep 25 15:33:45 2003 +++ pear/Perm_LiveUser/Admin/Auth/Container/MDB.php Fri Sep 26 10:32:15 2003 @@ -47,7 +47,7 @@ * This class is only experimental. API may change. Use it at your own risk. * * @author Bj?rn Kraus <krausbn@php.net> - * @version $Id: MDB.php,v 1.16 2003/09/25 19:33:45 arnaud Exp $ + * @version $Id: MDB.php,v 1.17 2003/09/26 14:32:15 lsmith Exp $ * @package LiveUser */ class LiveUser_Admin_Auth_Container_MDB extends LiveUser_Admin_Auth_Common @@ -81,19 +81,19 @@ /** * Columns of the auth table. * Associative array with the names of the auth table columns. - * The 'userId', 'handle' and 'password' fields have to be set. - * 'lastLogin' and 'isActive' are optional. + * The 'user_id', 'handle' and 'passwd' fields have to be set. + * 'lastlogin' and 'is_active' are optional. * It doesn't make sense to set only one of the time columns without the * other. * * @access public * @var array */ - var $authTableCols = array('userId' => 'auth_user_id', + var $authTableCols = array('user_id' => 'auth_user_id', 'handle' => 'handle', - 'password' => 'password', - 'lastLogin' => 'lastlogin', - 'isActive' => 'is_active'); + 'passwd' => 'passwd', + 'lastlogin' => 'lastlogin', + 'is_active' => 'is_active'); /** * Indicates if backend module initialized correctly. If yes, @@ -124,11 +124,11 @@ * 'allowDuplicateHandles' => 0, * 'authTable' => 'users', * 'authTableCols' => array( - * 'userId' => 'auth_user_id', + * 'user_id' => 'auth_user_id', * 'handle' => 'handle', - * 'password' => 'password', - * 'lastLogin' => 'lastlogin', - * 'isActive' => 'is_active' + * 'passwd' => 'passwd', + * 'lastlogin' => 'lastlogin', + * 'is_active' => 'is_active' * ) * ) * ), @@ -150,11 +150,11 @@ * 'allowDuplicateHandles' => 0, * 'authTable' => 'users', * 'authTableCols' => array( - * 'userId' => 'auth_user_id', + * 'user_id' => 'auth_user_id', * 'handle' => 'handle', - * 'password' => 'password', - * 'lastLogin' => 'lastlogin', - * 'isActive' => 'is_active' + * 'passwd' => 'passwd', + * 'lastlogin' => 'lastlogin', + * 'is_active' => 'is_active' * ) * ); * @@ -221,10 +221,10 @@ ' . $this->authTable . ' ( - ' . $this->authTableCols['userId'] . ', + ' . $this->authTableCols['user_id'] . ', ' . $this->authTableCols['handle'] . ', - ' . $this->authTableCols['password'] . ', - ' . $this->authTableCols['isActive'] . ' + ' . $this->authTableCols['passwd'] . ', + ' . $this->authTableCols['is_active'] . ' ) VALUES @@ -301,11 +301,11 @@ } if (!empty($password)) { $updateValues[] = - $this->authTableCols['password'] . ' = ' . $this->dbc->getTextValue($this->encryptPW($password)); + $this->authTableCols['passwd'] . ' = ' . $this->dbc->getTextValue($this->encryptPW($password)); } if (isset($active)) { $updateValues[] = - $this->authTableCols['isActive'] . ' = ' . $this->dbc->getBooleanValue($active); + $this->authTableCols['is_active'] . ' = ' . $this->dbc->getBooleanValue($active); } if (count($updateValues) >= 1) { @@ -315,7 +315,7 @@ } $query .= 'WHERE - ' . $this->authTableCols['userId'] . '=' . $this->dbc->getTextValue($authId); + ' . $this->authTableCols['user_id'] . '=' . $this->dbc->getTextValue($authId); $result = $this->dbc->query($query); @@ -327,16 +327,16 @@ } // end func changeUser /** - * Gets all users with handle, password, authId, permId, currentLogin, - * lastLogin, isActive and individual rights. + * Gets all users with handle, passwd, auth_user_id, + * lastlogin, is_active and individual rights. * * The array will look like this: * <code> - * $userData[0]['authId'] = 'wujha433gawefawfwfiuj2ou9823r98h'; + * $userData[0]['auth_user_id'] = 'wujha433gawefawfwfiuj2ou9823r98h'; * ['handle'] = 'myLogin'; - * ['password'] = 'd346gs2gwaeiuhaeiuuweijfjuwaefhj'; - * ['lastLogin'] = 1254801292; (Unix timestamp) - * ['isActive'] = 1; (1 = yes, 0 = no) + * ['passwd'] = 'd346gs2gwaeiuhaeiuuweijfjuwaefhj'; + * ['lastlogin'] = 1254801292; (Unix timestamp) + * ['is_active'] = 1; (1 = yes, 0 = no) * </code> * * @access public @@ -351,11 +351,11 @@ // First: Get all data from auth table. $query = ' SELECT - ' . $this->authTableCols['userId'] . ' AS authId, + ' . $this->authTableCols['user_id'] . ' AS auth_user_id, ' . $this->authTableCols['handle'] . ' AS handle, - ' . $this->authTableCols['password'] . ' AS password, - ' . $this->authTableCols['lastLogin'] . ' AS lastLogin, - ' . $this->authTableCols['isActive'] . ' AS isActive + ' . $this->authTableCols['passwd'] . ' AS passwd, + ' . $this->authTableCols['lastlogin'] . ' AS lastlogin, + ' . $this->authTableCols['is_active'] . ' AS is_active FROM ' . $this->authTable; Index: pear/Perm_LiveUser/Auth/Container/DB.php diff -u pear/Perm_LiveUser/Auth/Container/DB.php:1.30 pear/Perm_LiveUser/Auth/Container/DB.php:1.31 --- pear/Perm_LiveUser/Auth/Container/DB.php:1.30 Thu Sep 25 15:11:48 2003 +++ pear/Perm_LiveUser/Auth/Container/DB.php Fri Sep 26 10:32:16 2003 @@ -47,7 +47,7 @@ * 'allowDuplicateHandles' => 1); * * @author Markus Wolff <wolff@21st.de> - * @version $Id: DB.php,v 1.30 2003/09/25 19:11:48 arnaud Exp $ + * @version $Id: DB.php,v 1.31 2003/09/26 14:32:16 lsmith Exp $ * @package LiveUser * @category authentication */ @@ -79,19 +79,19 @@ /** * Columns of the auth table. * Associative array with the names of the auth table columns. - * The 'userId', 'handle' and 'password' fields have to be set. - * 'lastLogin' and 'isActive' are optional. + * The 'user_id', 'handle' and 'passwd' fields have to be set. + * 'lastlogin' and 'is_active' are optional. * It doesn't make sense to set only one of the time columns without the * other. * * @var array * @access public */ - var $authTableCols = array('userId' => 'auth_user_id', + var $authTableCols = array('user_id' => 'auth_user_id', 'handle' => 'handle', - 'password' => 'passwd', - 'lastLogin' => 'lastlogin', - 'isActive' => 'is_active'); + 'passwd' => 'passwd', + 'lastlogin' => 'lastlogin', + 'is_active' => 'is_active'); /** * Indicates if backend module initialized correctly. If yes, @@ -181,10 +181,10 @@ return false; } - if (isset($this->authTableCols['lastLogin'])) { + if (isset($this->authTableCols['lastlogin'])) { $sql = 'UPDATE '.$this->authTable.' - SET '.$this->authTableCols['lastLogin'].'='.$this->dbc->quote(date('Y.m.d H:i:s', $this->currentLogin)).' - WHERE '.$this->authTableCols['userId'].'='.$this->dbc->quote($this->authUserId); + SET '.$this->authTableCols['lastlogin'].'='.$this->dbc->quote(date('Y.m.d H:i:s', $this->currentLogin)).' + WHERE '.$this->authTableCols['user_id'].'='.$this->dbc->quote($this->authUserId); $res = $this->dbc->query($sql); return $res; } else { @@ -195,8 +195,8 @@ /** * LiveUser_Auth_Container_DB::readUserData() * - * Reads auth_user_id, password, validity flag, current - * and last login timestamp from the database + * Reads auth_user_id, passwd, is_active flag + * lastlogin timestamp from the database * If only $handle is given, it will read the data * from the first user with that handle and return * true on success. @@ -229,7 +229,7 @@ $sql = 'SELECT '.implode(',', $fields).' FROM '.$this->authTable.' WHERE '.$this->authTableCols['handle'].'='.$this->dbc->quote($handle).' - AND '.$this->authTableCols['password'].'='.$this->dbc->quote($this->encryptPW($passwd)); + AND '.$this->authTableCols['passwd'].'='.$this->dbc->quote($this->encryptPW($passwd)); } else { // If only $handle is set, try to find the first matching user $sql = 'SELECT '.implode(',', $fields).' @@ -246,11 +246,11 @@ $udata = $result; $this->handle = $udata['handle']; - $this->passwd = $this->decryptPW($udata['password']); - $this->isActive = ((!isset($udata['isActive']) OR $udata['isActive']=='Y') ? true : false); - $this->authUserId = $udata['userId']; - $this->lastLogin = !empty($udata['lastLogin'])? - strtotime($udata['lastLogin']):''; + $this->passwd = $this->decryptPW($udata['passwd']); + $this->isActive = ((!isset($udata['is_active']) || $udata['is_active']=='Y') ? true : false); + $this->authUserId = $udata['user_id']; + $this->lastLogin = !empty($udata['lastlogin'])? + strtotime($udata['lastlogin']):''; $success = true; } @@ -294,20 +294,20 @@ } if ($checkHandle !== false && $checkPW === false) { // only search for the first user with the given handle - $sql = 'SELECT '.$this->authTableCols['userId'].' + $sql = 'SELECT '.$this->authTableCols['user_id'].' FROM '.$this->authTable.' WHERE '.$this->authTableCols['handle'].'='.$this->dbc->quote($checkHandle); } elseif ($checkHandle === false && $checkPW !== false) { // only search for the first user with the given password - $sql = 'SELECT '.$this->authTableCols['userId'].' + $sql = 'SELECT '.$this->authTableCols['user_id'].' FROM '.$this->authTable.' - WHERE '.$this->authTableCols['password'].'='.$this->dbc->quote($this->encryptPW($checkPW)); + WHERE '.$this->authTableCols['passwd'].'='.$this->dbc->quote($this->encryptPW($checkPW)); } else { // check for a user with both handle and password matching - $sql = 'SELECT '.$this->authTableCols['userId'].' + $sql = 'SELECT '.$this->authTableCols['user_id'].' FROM '.$this->authTable.' WHERE '.$this->authTableCols['handle'].'='.$this->dbc->quote($checkHandle).' - AND '.$this->authTableCols['password'].'='.$this->dbc->quote($this->encryptPW($checkPW)); + AND '.$this->authTableCols['passwd'].'='.$this->dbc->quote($this->encryptPW($checkPW)); } $result = $this->dbc->getOne($sql); if (!DB::isError($result) && $result) { Index: pear/Perm_LiveUser/Auth/Container/MDB.php diff -u pear/Perm_LiveUser/Auth/Container/MDB.php:1.14 pear/Perm_LiveUser/Auth/Container/MDB.php:1.15 --- pear/Perm_LiveUser/Auth/Container/MDB.php:1.14 Thu Sep 25 15:11:48 2003 +++ pear/Perm_LiveUser/Auth/Container/MDB.php Fri Sep 26 10:32:16 2003 @@ -48,7 +48,7 @@ * 'allowDuplicateHandles' => 1); * * @author Markus Wolff <wolff@21st.de> - * @version $Id: MDB.php,v 1.14 2003/09/25 19:11:48 arnaud Exp $ + * @version $Id: MDB.php,v 1.15 2003/09/26 14:32:16 lsmith Exp $ * @package LiveUser * @category authentication */ @@ -60,7 +60,7 @@ * @var string * @access private */ - var $dsn = NULL; + var $dsn = null; /** * PEAR::MDB connection object @@ -80,19 +80,19 @@ /** * Columns of the auth table. * Associative array with the names of the auth table columns. - * The 'userId', 'handle' and 'password' fields have to be set. - * 'currentLogin', 'lastLogin' and 'isActive' are optional. + * The 'user_id', 'handle' and 'passwd' fields have to be set. + * 'lastlogin' and 'is_active' are optional. * It doesn't make sense to set only one of the time columns without the * other. * * @var array * @access public */ - var $authTableCols = array('userId' => array('name' => 'auth_user_id', 'type' => 'text'), + var $authTableCols = array('user_id' => array('name' => 'auth_user_id', 'type' => 'text'), 'handle' => array('name' => 'handle', 'type' => 'text'), - 'password' => array('name' => 'passwd', 'type' => 'text'), - 'lastLogin' => array('name' => 'lastlogin', 'type' => 'timestamp'), - 'isActive' => array('name' => 'is_active', 'type' => 'boolean')); + 'passwd' => array('name' => 'passwd', 'type' => 'text'), + 'lastlogin' => array('name' => 'lastlogin', 'type' => 'timestamp'), + 'is_active' => array('name' => 'is_active', 'type' => 'boolean')); /** * Indicates if backend module initialized correctly. If yes, @@ -183,14 +183,14 @@ } $fields = array(); - if (isset($this->authTableCols['lastLogin'])) { + if (isset($this->authTableCols['lastlogin'])) { $lastLogin = ($this->currentLogin >= 0) ? MDB_Date::unix2Mdbstamp($this->currentLogin) : null; - $fields[] = $this->authTableCols['lastLogin']['name'].'='.$this->dbc->getValue($this->authTableCols['lastLogin']['type'], $lastLogin); + $fields[] = $this->authTableCols['lastlogin']['name'].'='.$this->dbc->getValue($this->authTableCols['lastlogin']['type'], $lastLogin); } if (count($fields) > 0) { $sql = 'UPDATE '.$this->authTable.' SET '.implode(',', $fields).' - WHERE '.$this->authTableCols['userId']['name'].'='.$this->dbc->getValue($this->authTableCols['userId']['type'], $this->authUserId); + WHERE '.$this->authTableCols['user_id']['name'].'='.$this->dbc->getValue($this->authTableCols['user_id']['type'], $this->authUserId); $res = $this->dbc->query($sql); return $res; } else { @@ -201,8 +201,8 @@ /** * LiveUser_Auth_Container_MDB::readUserData() * - * Reads auth_user_id, password, validity flag, current - * and last login timestamp from the database + * Reads auth_user_id, passwd, is_active flag + * lastlogin timestamp from the database * If only $handle is given, it will read the data * from the first user with that handle and return * true on success. @@ -236,7 +236,7 @@ $sql = 'SELECT '.implode(',', $fields).' FROM '.$this->authTable.' WHERE '.$this->authTableCols['handle']['name'].'='.$this->dbc->getValue($this->authTableCols['handle']['type'], $handle).' - AND '.$this->authTableCols['password']['name'].'='.$this->dbc->getValue($this->authTableCols['password']['type'], $this->encryptPW($passwd)); + AND '.$this->authTableCols['passwd']['name'].'='.$this->dbc->getValue($this->authTableCols['passwd']['type'], $this->encryptPW($passwd)); } else { // If only $handle is set, try to find the first matching user $sql = 'SELECT '.implode(',', $fields).' @@ -253,11 +253,11 @@ $udata = $result; $this->handle = $udata['handle']; - $this->passwd = $this->decryptPW($udata['password']); - $this->isActive = $udata['isActive']; - $this->authUserId = $udata['userId']; - $this->lastLogin = !empty($udata['lastLogin'])? - MDB_Date::mdbstamp2Unix($udata['lastLogin']):''; + $this->passwd = $this->decryptPW($udata['passwd']); + $this->isActive = ((!isset($udata['is_active']) || $udata['is_active']) ? true : false); + $this->authUserId = $udata['user_id']; + $this->lastLogin = !empty($udata['lastlogin'])? + MDB_Date::mdbstamp2Unix($udata['lastlogin']):''; $success = true; } @@ -301,23 +301,23 @@ } if ($checkHandle !== false && $checkPW === false) { // only search for the first user with the given handle - $sql = 'SELECT '.$this->authTableCols['userId']['name'].' + $sql = 'SELECT '.$this->authTableCols['user_id']['name'].' FROM '.$this->authTable.' WHERE handle='.$this->dbc->getValue($this->authTableCols['handle']['type'], $checkHandle); } elseif ($checkHandle === false && $checkPW !== false) { // only search for the first user with the given password - $sql = 'SELECT '.$this->authTableCols['userId']['name'].' + $sql = 'SELECT '.$this->authTableCols['user_id']['name'].' FROM '.$this->authTable.' - WHERE password='.$this->dbc->getValue('text', $this->encryptPW($checkPW)); + WHERE passwd='.$this->dbc->getValue('text', $this->encryptPW($checkPW)); } else { // check for a user with both handle and password matching - $sql = 'SELECT '.$this->authTableCols['userId']['name'].' + $sql = 'SELECT '.$this->authTableCols['user_id']['name'].' FROM '.$this->authTable.' WHERE handle='.$this->dbc->getValue($this->authTableCols['handle']['type'], $checkHandle).' - AND password='.$this->dbc->getValue($this->authTableCols['password']['type'], $this->encryptPW($checkPW)); + AND passwd='.$this->dbc->getValue($this->authTableCols['passwd']['type'], $this->encryptPW($checkPW)); } - $result = $this->dbc->queryOne($sql, $this->authTableCols['userId']['type']); + $result = $this->dbc->queryOne($sql, $this->authTableCols['user_id']['type']); if (!MDB::isError($result) && $result) { return $result; Index: pear/Perm_LiveUser/examples/example4/main.inc.php diff -u pear/Perm_LiveUser/examples/example4/main.inc.php:1.8 pear/Perm_LiveUser/examples/example4/main.inc.php:1.9 --- pear/Perm_LiveUser/examples/example4/main.inc.php:1.8 Fri Sep 12 08:57:11 2003 +++ pear/Perm_LiveUser/examples/example4/main.inc.php Fri Sep 26 10:32:17 2003 @@ -101,10 +101,10 @@ 'idleTime' => 1800, 'allowDuplicateHandles' => 0, 'authTable' => 'liveuser_users', - 'authTableCols' => array('userId' => 'auth_user_id', + 'authTableCols' => array('user_id' => 'auth_user_id', 'handle' => 'handle', - 'password' => 'password', - 'lastLogin' => 'lastlogin' + 'passwd' => 'passwd', + 'lastlogin' => 'lastlogin' ) ) ),
Index: pear/Perm_LiveUser/LiveUser.php diff -u pear/Perm_LiveUser/LiveUser.php:1.41 pear/Perm_LiveUser/LiveUser.php:1.42 --- pear/Perm_LiveUser/LiveUser.php:1.41 Thu Sep 25 15:13:36 2003 +++ pear/Perm_LiveUser/LiveUser.php Fri Sep 26 10:32:14 2003 @@ -91,7 +91,7 @@ * @author Lukas Smith <smith@backendmedia.com> * @author Pierre-Alain Joye <pajoye@php.net> * @author Arnaud Limbourg <arnaud@php.net> - * @version $Id: LiveUser.php,v 1.41 2003/09/25 19:13:36 arnaud Exp $ + * @version $Id: LiveUser.php,v 1.42 2003/09/26 14:32:14 lsmith Exp $ * @package LiveUser */ class LiveUser @@ -141,10 +141,10 @@ * 'idleTime' => 1800, * 'allowDuplicateHandles' => 0, * 'authTable' => 'liveuser_users', - * 'authTableCols' => array('userId' => 'auth_user_id', + * 'authTableCols' => array('user_id' => 'auth_user_id', * 'handle' => 'handle', - * 'password' => 'password', - * 'lastLogin' => 'lastlogin' + * 'passwd' => 'passwd', + * 'lastlogin' => 'lastlogin' * ) * ) * ), @@ -519,14 +519,14 @@ return false; } + // Determine if user wanted to log out + $this->processLogout($logout); + // Set the name of the current session session_name($this->_options['session']['name']); // If there's no session yet, start it now session_start(); - // Determine if user wanted to log out - $this->processLogout($logout); - // Include needed permission container class if (is_array($this->permContainer)) { include_once 'LiveUser/Perm/Container/' . $this->permContainer['type'] . '.php'; @@ -882,6 +882,11 @@ if ($this->_error) { return false; } + + // Set the name of the current session + session_name($this->_options['session']['name']); + // If there's no session yet, start it now + session_start(); // If a callback function is set, call it if (!empty($this->_options['logout']['function']) && Index: pear/Perm_LiveUser/Admin/Auth/Common.php diff -u pear/Perm_LiveUser/Admin/Auth/Common.php:1.8 pear/Perm_LiveUser/Admin/Auth/Common.php:1.9 --- pear/Perm_LiveUser/Admin/Auth/Common.php:1.8 Thu Sep 25 15:33:44 2003 +++ pear/Perm_LiveUser/Admin/Auth/Common.php Fri Sep 26 10:32:14 2003 @@ -20,7 +20,7 @@ * Base class for authentication backends. * * @author Lukas Smith <smith@backendmedia.com> - * @version $Id: Common.php,v 1.8 2003/09/25 19:33:44 arnaud Exp $ + * @version $Id: Common.php,v 1.9 2003/09/26 14:32:14 lsmith Exp $ * @package LiveUser * @category authentication */ @@ -48,7 +48,7 @@ 'PLAIN' => 'PLAIN'); /** - * Defines the algorhythm used for encrypting/decrypting + * Defines the algorithm used for encrypting/decrypting * passwords. Default: "MD5". * * @access private @@ -68,7 +68,7 @@ /** * Decrypts a password so that it can be compared with the user - * input. Uses the algorhythm defined in the passwordEncryptionMode + * input. Uses the algorithm defined in the passwordEncryptionMode * property. * * @access public @@ -94,7 +94,7 @@ /** * Encrypts a password for storage in a backend container. - * Uses the algorhythm defined in the passwordEncryptionMode + * Uses the algorithm defined in the passwordEncryptionMode * property. * * @access public @@ -179,17 +179,16 @@ } /** - * Gets all users with handle, password, authId, permId, currentLogin, - * lastLogin, isActive and individual rights. + * Gets all users with handle, passwd, authId, + * lastlogin, is_active and individual rights. * * The array will look like this: * <code> - * $userData[0]['authId'] = 'wujha433gawefawfwfiuj2ou9823r98h'; + * $userData[0]['auth_user_id'] = 'wujha433gawefawfwfiuj2ou9823r98h'; * ['handle'] = 'myLogin'; - * ['password'] = 'd346gs2gwaeiuhaeiuuweijfjuwaefhj'; - * ['currentLogin'] = 1254801292; (Unix timestamp) - * ['lastLogin'] = 1254801292; (Unix timestamp) - * ['isActive'] = 1; (1 = yes, 0 = no) + * ['passwd'] = 'd346gs2gwaeiuhaeiuuweijfjuwaefhj'; + * ['lastlogin'] = 1254801292; (Unix timestamp) + * ['is_active'] = 1; (1 = yes, 0 = no) * </code> * * @access public Index: pear/Perm_LiveUser/Admin/Auth/Container/DB.php diff -u pear/Perm_LiveUser/Admin/Auth/Container/DB.php:1.14 pear/Perm_LiveUser/Admin/Auth/Container/DB.php:1.15 --- pear/Perm_LiveUser/Admin/Auth/Container/DB.php:1.14 Thu Sep 25 15:33:45 2003 +++ pear/Perm_LiveUser/Admin/Auth/Container/DB.php Fri Sep 26 10:32:15 2003 @@ -48,7 +48,7 @@ * This class is only experimental. API may change. Use it at your own risk. * * @author Bj?rn Kraus <krausbn@php.net> - * @version $Id: DB.php,v 1.14 2003/09/25 19:33:45 arnaud Exp $ + * @version $Id: DB.php,v 1.15 2003/09/26 14:32:15 lsmith Exp $ * @package LiveUser * @category authentication */ @@ -83,19 +83,19 @@ /** * Columns of the auth table. * Associative array with the names of the auth table columns. - * The 'userId', 'handle' and 'password' fields have to be set. - * 'lastLogin' and 'isActive' are optional. + * The 'user_id', 'handle' and 'passwd' fields have to be set. + * 'lastlogin' and 'is_active' are optional. * It doesn't make sense to set only one of the time columns without the * other. * * @access public * @var array */ - var $authTableCols = array('userId' => 'auth_user_id', + var $authTableCols = array('user_id' => 'auth_user_id', 'handle' => 'handle', - 'password' => 'password', - 'lastLogin' => 'lastlogin', - 'isActive' => 'is_active'); + 'passwd' => 'passwd', + 'lastlogin' => 'lastlogin', + 'is_active' => 'is_active'); /** * Indicates if backend module initialized correctly. If yes, @@ -126,11 +126,11 @@ * 'allowDuplicateHandles' => 0, * 'authTable' => 'users', * 'authTableCols' => array( - * 'userId' => 'auth_user_id', + * 'user_id' => 'auth_user_id', * 'handle' => 'handle', - * 'password' => 'password', - * 'lastLogin' => 'lastlogin', - * 'isActive' => 'is_active' + * 'passwd' => 'passwd', + * 'lastlogin' => 'lastlogin', + * 'is_active' => 'is_active' * ) * ) * ), @@ -152,11 +152,11 @@ * 'allowDuplicateHandles' => 0, * 'authTable' => 'users', * 'authTableCols' => array( - * 'userId' => 'auth_user_id', + * 'user_id' => 'auth_user_id', * 'handle' => 'handle', - * 'password' => 'password', - * 'lastLogin' => 'lastlogin', - * 'isActive' => 'is_active' + * 'passwd' => 'passwd', + * 'lastlogin' => 'lastlogin', + * 'is_active' => 'is_active' * ) * ); * @@ -229,10 +229,10 @@ INSERT INTO ' . $this->authTable . ' ( - ' . $this->authTableCols['userId'] . ', + ' . $this->authTableCols['user_id'] . ', ' . $this->authTableCols['handle'] . ', - ' . $this->authTableCols['password'] . ', - ' . $this->authTableCols['isActive'] . ' + ' . $this->authTableCols['passwd'] . ', + ' . $this->authTableCols['is_active'] . ' ) VALUES ( @@ -309,7 +309,7 @@ if (!empty($password)) { $updateValues[] = - $this->authTableCols['password'] . ' = ' + $this->authTableCols['passwd'] . ' = ' . $this->dbc->quote($this->encryptPW($password)); } @@ -320,7 +320,7 @@ $active = 'N'; } $updateValues[] = - $this->authTableCols['isActive'] . ' = ' . $this->dbc->quote($active); + $this->authTableCols['is_active'] . ' = ' . $this->dbc->quote($active); } if (count($updateValues) >= 1) { @@ -330,7 +330,7 @@ } $query .= ' WHERE - ' . $this->authTableCols['userId'] . '=' . $this->dbc->quote($authId); + ' . $this->authTableCols['user_id'] . '=' . $this->dbc->quote($authId); $result = $this->dbc->query($query); @@ -342,16 +342,16 @@ } // end func changeUser /** - * Gets all users with handle, password, authId, permId - * lastLogin, isActive and individual rights. + * Gets all users with handle, passwd, auth_user_id + * lastlogin, is_active and individual rights. * * The array will look like this: * <code> - * $userData[0]['authId'] = 'wujha433gawefawfwfiuj2ou9823r98h'; + * $userData[0]['auth_user_id'] = 'wujha433gawefawfwfiuj2ou9823r98h'; * ['handle'] = 'myLogin'; - * ['password'] = 'd346gs2gwaeiuhaeiuuweijfjuwaefhj'; - * ['lastLogin'] = 1254801292; (Unix timestamp) - * ['isActive'] = 1; (1 = yes, 0 = no) + * ['passwd'] = 'd346gs2gwaeiuhaeiuuweijfjuwaefhj'; + * ['lastlogin'] = 1254801292; (Unix timestamp) + * ['is_active'] = 1; (1 = yes, 0 = no) * </code> * * @access public @@ -366,11 +366,11 @@ // First: Get all data from auth table. $query = ' SELECT - ' . $this->authTableCols['userId'] . ' AS authId, + ' . $this->authTableCols['user_id'] . ' AS auth_user_id, ' . $this->authTableCols['handle'] . ' AS handle, - ' . $this->authTableCols['password'] . ' AS password, - ' . $this->authTableCols['lastLogin'] . ' AS lastLogin, - ' . $this->authTableCols['isActive'] . ' AS isActive + ' . $this->authTableCols['passwd'] . ' AS passwd, + ' . $this->authTableCols['lastlogin'] . ' AS lastlogin, + ' . $this->authTableCols['is_active'] . ' AS is_active FROM ' . $this->authTable; @@ -384,10 +384,10 @@ // with MDB admin container reset($userData); while (list($key, $value) = each($userData)) { - if ($value['isActive'] == 'Y') { - $userData[$key]['isActive'] == 1; + if ($value['is_active'] == 'Y') { + $userData[$key]['is_active'] == 1; } else { - $userData[$key]['isActive'] == 0; + $userData[$key]['is_active'] == 0; } } Index: pear/Perm_LiveUser/Admin/Auth/Container/MDB.php diff -u pear/Perm_LiveUser/Admin/Auth/Container/MDB.php:1.16 pear/Perm_LiveUser/Admin/Auth/Container/MDB.php:1.17 --- pear/Perm_LiveUser/Admin/Auth/Container/MDB.php:1.16 Thu Sep 25 15:33:45 2003 +++ pear/Perm_LiveUser/Admin/Auth/Container/MDB.php Fri Sep 26 10:32:15 2003 @@ -47,7 +47,7 @@ * This class is only experimental. API may change. Use it at your own risk. * * @author Bj?rn Kraus <krausbn@php.net> - * @version $Id: MDB.php,v 1.16 2003/09/25 19:33:45 arnaud Exp $ + * @version $Id: MDB.php,v 1.17 2003/09/26 14:32:15 lsmith Exp $ * @package LiveUser */ class LiveUser_Admin_Auth_Container_MDB extends LiveUser_Admin_Auth_Common @@ -81,19 +81,19 @@ /** * Columns of the auth table. * Associative array with the names of the auth table columns. - * The 'userId', 'handle' and 'password' fields have to be set. - * 'lastLogin' and 'isActive' are optional. + * The 'user_id', 'handle' and 'passwd' fields have to be set. + * 'lastlogin' and 'is_active' are optional. * It doesn't make sense to set only one of the time columns without the * other. * * @access public * @var array */ - var $authTableCols = array('userId' => 'auth_user_id', + var $authTableCols = array('user_id' => 'auth_user_id', 'handle' => 'handle', - 'password' => 'password', - 'lastLogin' => 'lastlogin', - 'isActive' => 'is_active'); + 'passwd' => 'passwd', + 'lastlogin' => 'lastlogin', + 'is_active' => 'is_active'); /** * Indicates if backend module initialized correctly. If yes, @@ -124,11 +124,11 @@ * 'allowDuplicateHandles' => 0, * 'authTable' => 'users', * 'authTableCols' => array( - * 'userId' => 'auth_user_id', + * 'user_id' => 'auth_user_id', * 'handle' => 'handle', - * 'password' => 'password', - * 'lastLogin' => 'lastlogin', - * 'isActive' => 'is_active' + * 'passwd' => 'passwd', + * 'lastlogin' => 'lastlogin', + * 'is_active' => 'is_active' * ) * ) * ), @@ -150,11 +150,11 @@ * 'allowDuplicateHandles' => 0, * 'authTable' => 'users', * 'authTableCols' => array( - * 'userId' => 'auth_user_id', + * 'user_id' => 'auth_user_id', * 'handle' => 'handle', - * 'password' => 'password', - * 'lastLogin' => 'lastlogin', - * 'isActive' => 'is_active' + * 'passwd' => 'passwd', + * 'lastlogin' => 'lastlogin', + * 'is_active' => 'is_active' * ) * ); * @@ -221,10 +221,10 @@ ' . $this->authTable . ' ( - ' . $this->authTableCols['userId'] . ', + ' . $this->authTableCols['user_id'] . ', ' . $this->authTableCols['handle'] . ', - ' . $this->authTableCols['password'] . ', - ' . $this->authTableCols['isActive'] . ' + ' . $this->authTableCols['passwd'] . ', + ' . $this->authTableCols['is_active'] . ' ) VALUES @@ -301,11 +301,11 @@ } if (!empty($password)) { $updateValues[] = - $this->authTableCols['password'] . ' = ' . $this->dbc->getTextValue($this->encryptPW($password)); + $this->authTableCols['passwd'] . ' = ' . $this->dbc->getTextValue($this->encryptPW($password)); } if (isset($active)) { $updateValues[] = - $this->authTableCols['isActive'] . ' = ' . $this->dbc->getBooleanValue($active); + $this->authTableCols['is_active'] . ' = ' . $this->dbc->getBooleanValue($active); } if (count($updateValues) >= 1) { @@ -315,7 +315,7 @@ } $query .= 'WHERE - ' . $this->authTableCols['userId'] . '=' . $this->dbc->getTextValue($authId); + ' . $this->authTableCols['user_id'] . '=' . $this->dbc->getTextValue($authId); $result = $this->dbc->query($query); @@ -327,16 +327,16 @@ } // end func changeUser /** - * Gets all users with handle, password, authId, permId, currentLogin, - * lastLogin, isActive and individual rights. + * Gets all users with handle, passwd, auth_user_id, + * lastlogin, is_active and individual rights. * * The array will look like this: * <code> - * $userData[0]['authId'] = 'wujha433gawefawfwfiuj2ou9823r98h'; + * $userData[0]['auth_user_id'] = 'wujha433gawefawfwfiuj2ou9823r98h'; * ['handle'] = 'myLogin'; - * ['password'] = 'd346gs2gwaeiuhaeiuuweijfjuwaefhj'; - * ['lastLogin'] = 1254801292; (Unix timestamp) - * ['isActive'] = 1; (1 = yes, 0 = no) + * ['passwd'] = 'd346gs2gwaeiuhaeiuuweijfjuwaefhj'; + * ['lastlogin'] = 1254801292; (Unix timestamp) + * ['is_active'] = 1; (1 = yes, 0 = no) * </code> * * @access public @@ -351,11 +351,11 @@ // First: Get all data from auth table. $query = ' SELECT - ' . $this->authTableCols['userId'] . ' AS authId, + ' . $this->authTableCols['user_id'] . ' AS auth_user_id, ' . $this->authTableCols['handle'] . ' AS handle, - ' . $this->authTableCols['password'] . ' AS password, - ' . $this->authTableCols['lastLogin'] . ' AS lastLogin, - ' . $this->authTableCols['isActive'] . ' AS isActive + ' . $this->authTableCols['passwd'] . ' AS passwd, + ' . $this->authTableCols['lastlogin'] . ' AS lastlogin, + ' . $this->authTableCols['is_active'] . ' AS is_active FROM ' . $this->authTable; Index: pear/Perm_LiveUser/Auth/Container/DB.php diff -u pear/Perm_LiveUser/Auth/Container/DB.php:1.30 pear/Perm_LiveUser/Auth/Container/DB.php:1.31 --- pear/Perm_LiveUser/Auth/Container/DB.php:1.30 Thu Sep 25 15:11:48 2003 +++ pear/Perm_LiveUser/Auth/Container/DB.php Fri Sep 26 10:32:16 2003 @@ -47,7 +47,7 @@ * 'allowDuplicateHandles' => 1); * * @author Markus Wolff <wolff@21st.de> - * @version $Id: DB.php,v 1.30 2003/09/25 19:11:48 arnaud Exp $ + * @version $Id: DB.php,v 1.31 2003/09/26 14:32:16 lsmith Exp $ * @package LiveUser * @category authentication */ @@ -79,19 +79,19 @@ /** * Columns of the auth table. * Associative array with the names of the auth table columns. - * The 'userId', 'handle' and 'password' fields have to be set. - * 'lastLogin' and 'isActive' are optional. + * The 'user_id', 'handle' and 'passwd' fields have to be set. + * 'lastlogin' and 'is_active' are optional. * It doesn't make sense to set only one of the time columns without the * other. * * @var array * @access public */ - var $authTableCols = array('userId' => 'auth_user_id', + var $authTableCols = array('user_id' => 'auth_user_id', 'handle' => 'handle', - 'password' => 'passwd', - 'lastLogin' => 'lastlogin', - 'isActive' => 'is_active'); + 'passwd' => 'passwd', + 'lastlogin' => 'lastlogin', + 'is_active' => 'is_active'); /** * Indicates if backend module initialized correctly. If yes, @@ -181,10 +181,10 @@ return false; } - if (isset($this->authTableCols['lastLogin'])) { + if (isset($this->authTableCols['lastlogin'])) { $sql = 'UPDATE '.$this->authTable.' - SET '.$this->authTableCols['lastLogin'].'='.$this->dbc->quote(date('Y.m.d H:i:s', $this->currentLogin)).' - WHERE '.$this->authTableCols['userId'].'='.$this->dbc->quote($this->authUserId); + SET '.$this->authTableCols['lastlogin'].'='.$this->dbc->quote(date('Y.m.d H:i:s', $this->currentLogin)).' + WHERE '.$this->authTableCols['user_id'].'='.$this->dbc->quote($this->authUserId); $res = $this->dbc->query($sql); return $res; } else { @@ -195,8 +195,8 @@ /** * LiveUser_Auth_Container_DB::readUserData() * - * Reads auth_user_id, password, validity flag, current - * and last login timestamp from the database + * Reads auth_user_id, passwd, is_active flag + * lastlogin timestamp from the database * If only $handle is given, it will read the data * from the first user with that handle and return * true on success. @@ -229,7 +229,7 @@ $sql = 'SELECT '.implode(',', $fields).' FROM '.$this->authTable.' WHERE '.$this->authTableCols['handle'].'='.$this->dbc->quote($handle).' - AND '.$this->authTableCols['password'].'='.$this->dbc->quote($this->encryptPW($passwd)); + AND '.$this->authTableCols['passwd'].'='.$this->dbc->quote($this->encryptPW($passwd)); } else { // If only $handle is set, try to find the first matching user $sql = 'SELECT '.implode(',', $fields).' @@ -246,11 +246,11 @@ $udata = $result; $this->handle = $udata['handle']; - $this->passwd = $this->decryptPW($udata['password']); - $this->isActive = ((!isset($udata['isActive']) OR $udata['isActive']=='Y') ? true : false); - $this->authUserId = $udata['userId']; - $this->lastLogin = !empty($udata['lastLogin'])? - strtotime($udata['lastLogin']):''; + $this->passwd = $this->decryptPW($udata['passwd']); + $this->isActive = ((!isset($udata['is_active']) || $udata['is_active']=='Y') ? true : false); + $this->authUserId = $udata['user_id']; + $this->lastLogin = !empty($udata['lastlogin'])? + strtotime($udata['lastlogin']):''; $success = true; } @@ -294,20 +294,20 @@ } if ($checkHandle !== false && $checkPW === false) { // only search for the first user with the given handle - $sql = 'SELECT '.$this->authTableCols['userId'].' + $sql = 'SELECT '.$this->authTableCols['user_id'].' FROM '.$this->authTable.' WHERE '.$this->authTableCols['handle'].'='.$this->dbc->quote($checkHandle); } elseif ($checkHandle === false && $checkPW !== false) { // only search for the first user with the given password - $sql = 'SELECT '.$this->authTableCols['userId'].' + $sql = 'SELECT '.$this->authTableCols['user_id'].' FROM '.$this->authTable.' - WHERE '.$this->authTableCols['password'].'='.$this->dbc->quote($this->encryptPW($checkPW)); + WHERE '.$this->authTableCols['passwd'].'='.$this->dbc->quote($this->encryptPW($checkPW)); } else { // check for a user with both handle and password matching - $sql = 'SELECT '.$this->authTableCols['userId'].' + $sql = 'SELECT '.$this->authTableCols['user_id'].' FROM '.$this->authTable.' WHERE '.$this->authTableCols['handle'].'='.$this->dbc->quote($checkHandle).' - AND '.$this->authTableCols['password'].'='.$this->dbc->quote($this->encryptPW($checkPW)); + AND '.$this->authTableCols['passwd'].'='.$this->dbc->quote($this->encryptPW($checkPW)); } $result = $this->dbc->getOne($sql); if (!DB::isError($result) && $result) { Index: pear/Perm_LiveUser/Auth/Container/MDB.php diff -u pear/Perm_LiveUser/Auth/Container/MDB.php:1.14 pear/Perm_LiveUser/Auth/Container/MDB.php:1.15 --- pear/Perm_LiveUser/Auth/Container/MDB.php:1.14 Thu Sep 25 15:11:48 2003 +++ pear/Perm_LiveUser/Auth/Container/MDB.php Fri Sep 26 10:32:16 2003 @@ -48,7 +48,7 @@ * 'allowDuplicateHandles' => 1); * * @author Markus Wolff <wolff@21st.de> - * @version $Id: MDB.php,v 1.14 2003/09/25 19:11:48 arnaud Exp $ + * @version $Id: MDB.php,v 1.15 2003/09/26 14:32:16 lsmith Exp $ * @package LiveUser * @category authentication */ @@ -60,7 +60,7 @@ * @var string * @access private */ - var $dsn = NULL; + var $dsn = null; /** * PEAR::MDB connection object @@ -80,19 +80,19 @@ /** * Columns of the auth table. * Associative array with the names of the auth table columns. - * The 'userId', 'handle' and 'password' fields have to be set. - * 'currentLogin', 'lastLogin' and 'isActive' are optional. + * The 'user_id', 'handle' and 'passwd' fields have to be set. + * 'lastlogin' and 'is_active' are optional. * It doesn't make sense to set only one of the time columns without the * other. * * @var array * @access public */ - var $authTableCols = array('userId' => array('name' => 'auth_user_id', 'type' => 'text'), + var $authTableCols = array('user_id' => array('name' => 'auth_user_id', 'type' => 'text'), 'handle' => array('name' => 'handle', 'type' => 'text'), - 'password' => array('name' => 'passwd', 'type' => 'text'), - 'lastLogin' => array('name' => 'lastlogin', 'type' => 'timestamp'), - 'isActive' => array('name' => 'is_active', 'type' => 'boolean')); + 'passwd' => array('name' => 'passwd', 'type' => 'text'), + 'lastlogin' => array('name' => 'lastlogin', 'type' => 'timestamp'), + 'is_active' => array('name' => 'is_active', 'type' => 'boolean')); /** * Indicates if backend module initialized correctly. If yes, @@ -183,14 +183,14 @@ } $fields = array(); - if (isset($this->authTableCols['lastLogin'])) { + if (isset($this->authTableCols['lastlogin'])) { $lastLogin = ($this->currentLogin >= 0) ? MDB_Date::unix2Mdbstamp($this->currentLogin) : null; - $fields[] = $this->authTableCols['lastLogin']['name'].'='.$this->dbc->getValue($this->authTableCols['lastLogin']['type'], $lastLogin); + $fields[] = $this->authTableCols['lastlogin']['name'].'='.$this->dbc->getValue($this->authTableCols['lastlogin']['type'], $lastLogin); } if (count($fields) > 0) { $sql = 'UPDATE '.$this->authTable.' SET '.implode(',', $fields).' - WHERE '.$this->authTableCols['userId']['name'].'='.$this->dbc->getValue($this->authTableCols['userId']['type'], $this->authUserId); + WHERE '.$this->authTableCols['user_id']['name'].'='.$this->dbc->getValue($this->authTableCols['user_id']['type'], $this->authUserId); $res = $this->dbc->query($sql); return $res; } else { @@ -201,8 +201,8 @@ /** * LiveUser_Auth_Container_MDB::readUserData() * - * Reads auth_user_id, password, validity flag, current - * and last login timestamp from the database + * Reads auth_user_id, passwd, is_active flag + * lastlogin timestamp from the database * If only $handle is given, it will read the data * from the first user with that handle and return * true on success. @@ -236,7 +236,7 @@ $sql = 'SELECT '.implode(',', $fields).' FROM '.$this->authTable.' WHERE '.$this->authTableCols['handle']['name'].'='.$this->dbc->getValue($this->authTableCols['handle']['type'], $handle).' - AND '.$this->authTableCols['password']['name'].'='.$this->dbc->getValue($this->authTableCols['password']['type'], $this->encryptPW($passwd)); + AND '.$this->authTableCols['passwd']['name'].'='.$this->dbc->getValue($this->authTableCols['passwd']['type'], $this->encryptPW($passwd)); } else { // If only $handle is set, try to find the first matching user $sql = 'SELECT '.implode(',', $fields).' @@ -253,11 +253,11 @@ $udata = $result; $this->handle = $udata['handle']; - $this->passwd = $this->decryptPW($udata['password']); - $this->isActive = $udata['isActive']; - $this->authUserId = $udata['userId']; - $this->lastLogin = !empty($udata['lastLogin'])? - MDB_Date::mdbstamp2Unix($udata['lastLogin']):''; + $this->passwd = $this->decryptPW($udata['passwd']); + $this->isActive = ((!isset($udata['is_active']) || $udata['is_active']) ? true : false); + $this->authUserId = $udata['user_id']; + $this->lastLogin = !empty($udata['lastlogin'])? + MDB_Date::mdbstamp2Unix($udata['lastlogin']):''; $success = true; } @@ -301,23 +301,23 @@ } if ($checkHandle !== false && $checkPW === false) { // only search for the first user with the given handle - $sql = 'SELECT '.$this->authTableCols['userId']['name'].' + $sql = 'SELECT '.$this->authTableCols['user_id']['name'].' FROM '.$this->authTable.' WHERE handle='.$this->dbc->getValue($this->authTableCols['handle']['type'], $checkHandle); } elseif ($checkHandle === false && $checkPW !== false) { // only search for the first user with the given password - $sql = 'SELECT '.$this->authTableCols['userId']['name'].' + $sql = 'SELECT '.$this->authTableCols['user_id']['name'].' FROM '.$this->authTable.' - WHERE password='.$this->dbc->getValue('text', $this->encryptPW($checkPW)); + WHERE passwd='.$this->dbc->getValue('text', $this->encryptPW($checkPW)); } else { // check for a user with both handle and password matching - $sql = 'SELECT '.$this->authTableCols['userId']['name'].' + $sql = 'SELECT '.$this->authTableCols['user_id']['name'].' FROM '.$this->authTable.' WHERE handle='.$this->dbc->getValue($this->authTableCols['handle']['type'], $checkHandle).' - AND password='.$this->dbc->getValue($this->authTableCols['password']['type'], $this->encryptPW($checkPW)); + AND passwd='.$this->dbc->getValue($this->authTableCols['passwd']['type'], $this->encryptPW($checkPW)); } - $result = $this->dbc->queryOne($sql, $this->authTableCols['userId']['type']); + $result = $this->dbc->queryOne($sql, $this->authTableCols['user_id']['type']); if (!MDB::isError($result) && $result) { return $result; Index: pear/Perm_LiveUser/examples/example4/main.inc.php diff -u pear/Perm_LiveUser/examples/example4/main.inc.php:1.8 pear/Perm_LiveUser/examples/example4/main.inc.php:1.9 --- pear/Perm_LiveUser/examples/example4/main.inc.php:1.8 Fri Sep 12 08:57:11 2003 +++ pear/Perm_LiveUser/examples/example4/main.inc.php Fri Sep 26 10:32:17 2003 @@ -101,10 +101,10 @@ 'idleTime' => 1800, 'allowDuplicateHandles' => 0, 'authTable' => 'liveuser_users', - 'authTableCols' => array('userId' => 'auth_user_id', + 'authTableCols' => array('user_id' => 'auth_user_id', 'handle' => 'handle', - 'password' => 'password', - 'lastLogin' => 'lastlogin' + 'passwd' => 'passwd', + 'lastlogin' => 'lastlogin' ) ) ),