14,11 → 14,11 |
* |
* @category Authentication |
* @package Auth |
* @author Lorenzo Alberton <l.alberton@quipo.it> |
* @author Lorenzo Alberton <l.alberton@quipo.it> |
* @author Adam Ashley <aashley@php.net> |
* @copyright 2001-2006 The PHP Group |
* @license http://www.php.net/license/3_01.txt PHP License 3.01 |
* @version CVS: $Id: MDB2.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $ |
* @version CVS: $Id: MDB2.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $ |
* @link http://pear.php.net/package/Auth |
* @since File available since Release 1.3.0 |
*/ |
44,7 → 44,7 |
* @author Adam Ashley <aashley@php.net> |
* @copyright 2001-2006 The PHP Group |
* @license http://www.php.net/license/3_01.txt PHP License 3.01 |
* @version Release: 1.4.3 File: $Revision: 1.1 $ |
* @version Release: 1.5.4 File: $Revision: 1.2 $ |
* @link http://pear.php.net/package/Auth |
* @since Class available since Release 1.3.0 |
*/ |
109,6 → 109,7 |
*/ |
function _connect($dsn) |
{ |
$this->log('Auth_Container_MDB2::_connect() called.', AUTH_LOG_DEBUG); |
if (is_string($dsn) || is_array($dsn)) { |
$this->db =& MDB2::connect($dsn, $this->options['db_options']); |
} elseif (is_subclass_of($dsn, 'MDB2_Driver_Common')) { |
128,7 → 129,7 |
if (MDB2::isError($this->db) || PEAR::isError($this->db)) { |
return PEAR::raiseError($this->db->getMessage(), $this->db->code); |
} |
|
|
if ($this->options['auto_quote']) { |
$this->options['final_table'] = $this->db->quoteIdentifier($this->options['table'], true); |
$this->options['final_usernamecol'] = $this->db->quoteIdentifier($this->options['usernamecol'], true); |
138,7 → 139,7 |
$this->options['final_usernamecol'] = $this->options['usernamecol']; |
$this->options['final_passwordcol'] = $this->options['passwordcol']; |
} |
|
|
return true; |
} |
|
179,6 → 180,7 |
*/ |
function query($query) |
{ |
$this->log('Auth_Container_MDB2::query() called.', AUTH_LOG_DEBUG); |
$err = $this->_prepare(); |
if ($err !== true) { |
return $err; |
204,6 → 206,7 |
$this->options['db_fields'] = ''; |
$this->options['cryptType'] = 'md5'; |
$this->options['db_options'] = array(); |
$this->options['db_where'] = ''; |
$this->options['auto_quote'] = true; |
} |
|
261,7 → 264,7 |
|
return ''; |
} |
|
|
// }}} |
// {{{ fetchData() |
|
283,6 → 286,7 |
*/ |
function fetchData($username, $password, $isChallengeResponse=false) |
{ |
$this->log('Auth_Container_MDB2::fetchData() called.', AUTH_LOG_DEBUG); |
// Prepare for a database query |
$err = $this->_prepare(); |
if ($err !== true) { |
308,6 → 312,14 |
$this->db->quote($username, 'text') |
); |
|
// check if there is an optional parameter db_where |
if ($this->options['db_where'] != '') { |
// there is one, so add it to the query |
$query .= " AND ".$this->options['db_where']; |
} |
|
$this->log('Running SQL against MDB2: '.$query, AUTH_LOG_DEBUG); |
|
$res = $this->db->queryRow($query, null, MDB2_FETCHMODE_ASSOC); |
if (MDB2::isError($res) || PEAR::isError($res)) { |
return PEAR::raiseError($res->getMessage(), $res->getCode()); |
338,6 → 350,9 |
$key == $this->options['usernamecol']) { |
continue; |
} |
|
$this->log('Storing additional field: '.$key, AUTH_LOG_DEBUG); |
|
// Use reference to the auth object if exists |
// This is because the auth session variable can change so a static call to setAuthData does not make sense |
$this->_auth_obj->setAuthData($key, $value); |
360,6 → 375,7 |
*/ |
function listUsers() |
{ |
$this->log('Auth_Container_MDB2::listUsers() called.', AUTH_LOG_DEBUG); |
$err = $this->_prepare(); |
if ($err !== true) { |
return PEAR::raiseError($err->getMessage(), $err->getCode()); |
385,6 → 401,14 |
$this->options['final_table'] |
); |
|
// check if there is an optional parameter db_where |
if ($this->options['db_where'] != '') { |
// there is one, so add it to the query |
$query .= " WHERE ".$this->options['db_where']; |
} |
|
$this->log('Running SQL against MDB2: '.$query, AUTH_LOG_DEBUG); |
|
$res = $this->db->queryAll($query, null, MDB2_FETCHMODE_ASSOC); |
if (MDB2::isError($res)) { |
return PEAR::raiseError($res->getMessage(), $res->getCode()); |
394,6 → 418,7 |
$retVal[] = $user; |
} |
} |
$this->log('Found '.count($retVal).' users.', AUTH_LOG_DEBUG); |
return $retVal; |
} |
|
412,6 → 437,7 |
*/ |
function addUser($username, $password, $additional = "") |
{ |
$this->log('Auth_Container_MDB2::addUser() called.', AUTH_LOG_DEBUG); |
|
// Prepare for a database query |
$err = $this->_prepare(); |
453,6 → 479,8 |
$additional_value |
); |
|
$this->log('Running SQL against MDB2: '.$query, AUTH_LOG_DEBUG); |
|
$res = $this->query($query); |
|
if (MDB2::isError($res)) { |
474,6 → 502,7 |
*/ |
function removeUser($username) |
{ |
$this->log('Auth_Container_MDB2::removeUser() called.', AUTH_LOG_DEBUG); |
// Prepare for a database query |
$err = $this->_prepare(); |
if ($err !== true) { |
486,6 → 515,14 |
$this->db->quote($username, 'text') |
); |
|
// check if there is an optional parameter db_where |
if ($this->options['db_where'] != '') { |
// there is one, so add it to the query |
$query .= " AND ".$this->options['db_where']; |
} |
|
$this->log('Running SQL against MDB2: '.$query, AUTH_LOG_DEBUG); |
|
$res = $this->query($query); |
|
if (MDB2::isError($res)) { |
505,6 → 542,7 |
*/ |
function changePassword($username, $password) |
{ |
$this->log('Auth_Container_MDB2::changePassword() called.', AUTH_LOG_DEBUG); |
// Prepare for a database query |
$err = $this->_prepare(); |
if ($err !== true) { |
529,6 → 567,14 |
$this->db->quote($username, 'text') |
); |
|
// check if there is an optional parameter db_where |
if ($this->options['db_where'] != '') { |
// there is one, so add it to the query |
$query .= " AND ".$this->options['db_where']; |
} |
|
$this->log('Running SQL against MDB2: '.$query, AUTH_LOG_DEBUG); |
|
$res = $this->query($query); |
|
if (MDB2::isError($res)) { |