Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 1712 → Rev 1713

/trunk/api/pear/Pager.php
New file
0,0 → 1,193
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
 
/**
* Contains the Pager class
*
* PHP versions 4 and 5
*
* LICENSE: Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category HTML
* @package Pager
* @author Lorenzo Alberton <l dot alberton at quipo dot it>
* @author Richard Heyes <richard@phpguru.org>
* @copyright 2003-2006 Lorenzo Alberton, Richard Heyes
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
* @version CVS: $Id: Pager.php,v 1.2 2007-11-19 15:10:59 jp_milcent Exp $
* @link http://pear.php.net/package/Pager
*/
 
/**
* Pager - Wrapper class for [Sliding|Jumping]-window Pager
* Usage examples can be found in the PEAR manual
*
* @category HTML
* @package Pager
* @author Lorenzo Alberton <l dot alberton at quipo dot it>
* @author Richard Heyes <richard@phpguru.org>,
* @copyright 2003-2005 Lorenzo Alberton, Richard Heyes
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @link http://pear.php.net/package/Pager
*/
class Pager
{
// {{{ Pager()
 
/**
* Constructor
*
* -------------------------------------------------------------------------
* VALID options are (default values are set some lines before):
* - mode (string): "Jumping" or "Sliding" -window - It determines
* pager behaviour. See the manual for more details
* - totalItems (int): # of items to page.
* - perPage (int): # of items per page.
* - delta (int): # of page #s to show before and after the current
* one
* - linkClass (string): name of CSS class used for link styling.
* - append (bool): if true pageID is appended as GET value to the
* URL - if false it is embedded in the URL
* according to "fileName" specs
* - httpMethod (string): Specifies the HTTP method to use. Valid values
* are 'GET' or 'POST'
* according to "fileName" specs
* - importQuery (bool): if true (default behaviour), variables and
* values are imported from the submitted data
* (query string) and used in the generated links
* otherwise they're ignored completely
* - path (string): complete path to the page (without the page name)
* - fileName (string): name of the page, with a %d if append=true
* - urlVar (string): name of pageNumber URL var, for example "pageID"
* - altPrev (string): alt text to display for prev page, on prev link.
* - altNext (string): alt text to display for next page, on next link.
* - altPage (string): alt text to display before the page number.
* - prevImg (string): sth (it can be text such as "<< PREV" or an
* <img/> as well...) to display instead of "<<".
* - nextImg (string): same as prevImg, used for NEXT link, instead of
* the default value, which is ">>".
* - separator (string): what to use to separate numbers (can be an
* <img/>, a comma, an hyphen, or whatever.
* - spacesBeforeSeparator
* (int): number of spaces before the separator.
* - firstPagePre (string):
* string used before first page number (can be an
* <img/>, a "{", an empty string, or whatever.
* - firstPageText (string):
* string used in place of first page number
* - firstPagePost (string):
* string used after first page number (can be an
* <img/>, a "}", an empty string, or whatever.
* - lastPagePre (string):
* similar to firstPagePre.
* - lastPageText (string):
* similar to firstPageText.
* - lastPagePost (string):
* similar to firstPagePost.
* - spacesAfterSeparator
* (int): number of spaces after the separator.
* - firstLinkTitle (string):
* string used as title in <link rel="first"> tag
* - lastLinkTitle (string):
* string used as title in <link rel="last"> tag
* - prevLinkTitle (string):
* string used as title in <link rel="prev"> tag
* - nextLinkTitle (string):
* string used as title in <link rel="next"> tag
* - curPageLinkClassName
* (string): name of CSS class used for current page link.
* - clearIfVoid(bool): if there's only one page, don't display pager.
* - extraVars (array): additional URL vars to be added to the querystring
* - excludeVars (array): URL vars to be excluded in the querystring
* - itemData (array): array of items to page.
* - useSessions (bool): if true, number of items to display per page is
* stored in the $_SESSION[$_sessionVar] var.
* - closeSession (bool): if true, the session is closed just after R/W.
* - sessionVar (string): name of the session var for perPage value.
* A value != from default can be useful when
* using more than one Pager istance in the page.
* - pearErrorMode (constant):
* PEAR_ERROR mode for raiseError().
* Default is PEAR_ERROR_RETURN.
* -------------------------------------------------------------------------
* REQUIRED options are:
* - fileName IF append==false (default is true)
* - itemData OR totalItems (if itemData is set, totalItems is overwritten)
* -------------------------------------------------------------------------
*
* @param mixed $options An associative array of option names and
* their values.
* @access public
*/
function Pager($options = array())
{
//this check evaluates to true on 5.0.0RC-dev,
//so i'm using another one, for now...
//if (version_compare(phpversion(), '5.0.0') == -1) {
if (get_class($this) == 'pager') { //php4 lowers class names
// assign factoried method to this for PHP 4
eval('$this = Pager::factory($options);');
} else { //php5 is case sensitive
$msg = 'Pager constructor is deprecated.'
.' You must use the "Pager::factory($params)" method'
.' instead of "new Pager($params)"';
trigger_error($msg, E_USER_ERROR);
}
}
 
// }}}
// {{{ factory()
 
/**
* Return a pager based on $mode and $options
*
* @param array $options Optional parameters for the storage class
* @return object Object Storage object
* @static
* @access public
*/
static function &factory($options = array())
{
$mode = (isset($options['mode']) ? ucfirst($options['mode']) : 'Jumping');
$classname = 'Pager_' . $mode;
$classfile = 'Pager' . DIRECTORY_SEPARATOR . $mode . '.php';
 
// Attempt to include a custom version of the named class, but don't treat
// a failure as fatal. The caller may have already included their own
// version of the named class.
if (!class_exists($classname)) {
include_once $classfile;
}
 
// If the class exists, return a new instance of it.
if (class_exists($classname)) {
$pager =& new $classname($options);
return $pager;
}
 
$null = null;
return $null;
}
 
// }}}
}
?>
/trunk/api/pear/Auth.php
18,7 → 18,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 CVS: $Id: Auth.php,v 1.2 2006-12-14 15:04:29 jp_milcent Exp $
* @version CVS: $Id: Auth.php,v 1.3 2007-11-19 15:10:59 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
*/
 
30,7 → 30,7
* Returned if session has expired
*/
define('AUTH_EXPIRED', -2);
/**
/**
* Returned if container is unable to authenticate user/password pair
*/
define('AUTH_WRONG_LOGIN', -3);
48,6 → 48,16
define('AUTH_CALLBACK_ABORT', -6);
 
/**
* Auth Log level - INFO
*/
define('AUTH_LOG_INFO', 6);
/**
* Auth Log level - DEBUG
*/
define('AUTH_LOG_DEBUG', 7);
 
 
/**
* PEAR::Auth
*
* The PEAR::Auth class provides methods for creating an
59,7 → 69,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.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
*/
class Auth {
126,7 → 136,7
* @see setShowlogin()
*/
var $showLogin = true;
 
/**
* Is Login Allowed from this page
*
204,12 → 214,12
 
/**
* Flag to use advanced security
* When set extra checks will be made to see if the
* user's IP or useragent have changed across requests.
* When set extra checks will be made to see if the
* user's IP or useragent have changed across requests.
* Turned off by default to preserve BC.
*
* @var boolean
*/
*/
var $advancedsecurity = false;
 
/**
255,13 → 265,34
* @var array
*/
var $authdata;
 
/**
* How many times has checkAuth been called
* var int
* @var int
*/
var $authChecks = 0;
 
/**
* PEAR::Log object
*
* @var object Log
*/
var $logger = null;
 
/**
* Whether to enable logging of behaviour
*
* @var boolean
*/
var $enableLogging = false;
 
/**
* Whether to regenerate session id everytime start is called
*
* @var boolean
*/
var $regenerateSessionId = false;
 
// }}}
// {{{ Auth() [constructor]
 
321,7 → 352,7
$this->storage->_auth_obj =& $this;
} else {
// $this->storage = $this->_factory($storageDriver, $options);
//
//
$this->storage_driver = $storageDriver;
$this->storage_options =& $options;
}
331,11 → 362,11
// {{{ applyAuthOptions()
 
/**
* Set the Auth options
* Set the Auth options
*
* Some options which are Auth specific will be applied
* the rest will be left for usage by the container
*
*
* @param array An array of Auth options
* @return array The options which were not applied
* @access private
363,6 → 394,13
$this->advancedsecurity = $options['advancedsecurity'];
unset($options['advancedsecurity']);
}
if (isset($options['enableLogging'])) {
$this->enableLogging = $options['enableLogging'];
unset($options['enableLogging']);
}
if (isset($options['regenerateSessionId']) && is_bool($options['regenerateSessionId'])) {
$this->regenerateSessionId = $options['regenerateSessionId'];
}
}
return($options);
}
369,11 → 407,11
 
// }}}
// {{{ _loadStorage()
 
/**
* Load Storage Driver if not already loaded
*
* Suspend storage instantiation to make Auth lighter to use
* Suspend storage instantiation to make Auth lighter to use
* for calls which do not require login
*
* @return bool True if the conainer is loaded, false if the container
383,9 → 421,10
function _loadStorage()
{
if(!is_object($this->storage)) {
$this->storage =& $this->_factory($this->storage_driver,
$this->storage =& $this->_factory($this->storage_driver,
$this->storage_options);
$this->storage->_auth_obj =& $this;
$this->log('Loaded storage container ('.$this->storage_driver.')', AUTH_LOG_DEBUG);
return(true);
}
return(false);
429,16 → 468,18
*/
function assignData()
{
if ( isset($this->post[$this->_postUsername])
$this->log('Auth::assignData() called.', AUTH_LOG_DEBUG);
 
if ( isset($this->post[$this->_postUsername])
&& $this->post[$this->_postUsername] != '') {
$this->username = (get_magic_quotes_gpc() == 1
? stripslashes($this->post[$this->_postUsername])
$this->username = (get_magic_quotes_gpc() == 1
? stripslashes($this->post[$this->_postUsername])
: $this->post[$this->_postUsername]);
}
if ( isset($this->post[$this->_postPassword])
if ( isset($this->post[$this->_postPassword])
&& $this->post[$this->_postPassword] != '') {
$this->password = (get_magic_quotes_gpc() == 1
? stripslashes($this->post[$this->_postPassword])
$this->password = (get_magic_quotes_gpc() == 1
? stripslashes($this->post[$this->_postPassword])
: $this->post[$this->_postPassword] );
}
}
454,6 → 495,14
*/
function start()
{
$this->log('Auth::start() called.', AUTH_LOG_DEBUG);
 
// #10729 - Regenerate session id here if we are generating it on every
// page load.
if ($this->regenerateSessionId) {
session_regenerate_id(true);
}
 
$this->assignData();
if (!$this->checkAuth() && $this->allowLogin) {
$this->login();
471,20 → 520,23
*/
function login()
{
$this->log('Auth::login() called.', AUTH_LOG_DEBUG);
 
$login_ok = false;
$this->_loadStorage();
 
// Check if using challenge response
(isset($this->post['authsecret']) && $this->post['authsecret'] == 1)
? $usingChap = true
(isset($this->post['authsecret']) && $this->post['authsecret'] == 1)
? $usingChap = true
: $usingChap = false;
 
 
// When the user has already entered a username, we have to validate it.
if (!empty($this->username)) {
if (true === $this->storage->fetchData($this->username, $this->password, $usingChap)) {
$this->session['challengekey'] = md5($this->username.$this->password);
$login_ok = true;
$this->log('Successful login.', AUTH_LOG_INFO);
}
}
 
491,29 → 543,37
if (!empty($this->username) && $login_ok) {
$this->setAuth($this->username);
if (is_callable($this->loginCallback)) {
$this->log('Calling loginCallback ('.$this->loginCallback.').', AUTH_LOG_DEBUG);
call_user_func_array($this->loginCallback, array($this->username, &$this));
}
}
 
// If the login failed or the user entered no username,
// If the login failed or the user entered no username,
// output the login screen again.
if (!empty($this->username) && !$login_ok) {
$this->log('Incorrect login.', AUTH_LOG_INFO);
$this->status = AUTH_WRONG_LOGIN;
if (is_callable($this->loginFailedCallback)) {
$this->log('Calling loginFailedCallback ('.$this->loginFailedCallback.').', AUTH_LOG_DEBUG);
call_user_func_array($this->loginFailedCallback, array($this->username, &$this));
}
}
 
if ((empty($this->username) || !$login_ok) && $this->showLogin) {
$this->log('Rendering Login Form.', AUTH_LOG_INFO);
if (is_callable($this->loginFunction)) {
$this->log('Calling loginFunction ('.$this->loginFunction.').', AUTH_LOG_DEBUG);
call_user_func_array($this->loginFunction, array($this->username, $this->status, &$this));
} else {
// BC fix Auth used to use drawLogin for this
// call is sub classes implement this
if (is_callable(array($this, 'drawLogin'))) {
$this->log('Calling Auth::drawLogin()', AUTH_LOG_DEBUG);
return $this->drawLogin($this->username, $this);
}
 
$this->log('Using default Auth_Frontend_Html', AUTH_LOG_DEBUG);
 
// New Login form
include_once 'Auth/Frontend/Html.php';
return Auth_Frontend_Html::render($this, $this->username);
564,7 → 624,7
* If you are using multiple instances of PEAR::Auth
* on the same domain, you can change the name of
* session per application via this function.
* This will chnage the name of the session variable
* This will chnage the name of the session variable
* auth uses to store it's data in the session
*
* @param string New name for the session
574,6 → 634,10
function setSessionName($name = 'session')
{
$this->_sessionName = '_auth_'.$name;
// Make Sure Auth session variable is there
if(!isset($_SESSION[$this->_sessionName])) {
$_SESSION[$this->_sessionName] = array();
}
$this->session =& $_SESSION[$this->_sessionName];
}
 
626,7 → 690,7
 
// }}}
// {{{ setLoginCallback()
 
/**
* Register a callback function to be called on user login.
* The function will receive two parameters, the username and a reference to the auth object.
713,7 → 777,7
{
if (!isset($this->session['data'])) {
return null;
}
}
if(!isset($name)) {
return $this->session['data'];
}
720,7 → 784,7
if (isset($name) && isset($this->session['data'][$name])) {
return $this->session['data'][$name];
}
return null;
return null;
}
 
// }}}
736,10 → 800,16
*/
function setAuth($username)
{
// #2021 - Change the session id to avoid session fixation attacks php 4.3.3 >
session_regenerate_id(true);
$this->log('Auth::setAuth() called.', AUTH_LOG_DEBUG);
 
// #10729 - Regenerate session id here only if generating at login only
// Don't do it if we are regenerating on every request so we don't
// regenerate it twice in one request.
if (!$this->regenerateSessionId) {
// #2021 - Change the session id to avoid session fixation attacks php 4.3.3 >
session_regenerate_id(true);
}
 
if (!isset($this->session) || !is_array($this->session)) {
$this->session = array();
}
748,12 → 818,15
$this->session['data'] = array();
}
 
$this->session['sessionip'] = isset($this->server['REMOTE_ADDR'])
? $this->server['REMOTE_ADDR']
$this->session['sessionip'] = isset($this->server['REMOTE_ADDR'])
? $this->server['REMOTE_ADDR']
: '';
$this->session['sessionuseragent'] = isset($this->server['HTTP_USER_AGENT'])
? $this->server['HTTP_USER_AGENT']
$this->session['sessionuseragent'] = isset($this->server['HTTP_USER_AGENT'])
? $this->server['HTTP_USER_AGENT']
: '';
$this->session['sessionforwardedfor'] = isset($this->server['HTTP_X_FORWARDED_FOR'])
? $this->server['HTTP_X_FORWARDED_FOR']
: '';
 
// This should be set by the container to something more safe
// Like md5(passwd.microtime)
772,13 → 845,13
 
// }}}
// {{{ setAdvancedSecurity()
 
/**
* Enables advanced security checks
*
* Currently only ip change and useragent change
* Currently only ip change and useragent change
* are detected
* @todo Add challenge cookies - Create a cookie which changes every time
* @todo Add challenge cookies - Create a cookie which changes every time
* and contains some challenge key which the server can verify with
* a session var cookie might need to be crypted (user pass)
* @param bool Enable or disable
801,6 → 874,7
*/
function checkAuth()
{
$this->log('Auth::checkAuth() called.', AUTH_LOG_DEBUG);
$this->authChecks++;
if (isset($this->session)) {
// Check if authentication session is expired
807,6 → 881,7
if ( $this->expire > 0
&& isset($this->session['timestamp'])
&& ($this->session['timestamp'] + $this->expire) < time()) {
$this->log('Session Expired', AUTH_LOG_INFO);
$this->expired = true;
$this->status = AUTH_EXPIRED;
$this->logout();
815,8 → 890,9
 
// Check if maximum idle time is reached
if ( $this->idle > 0
&& isset($this->session['idle'])
&& isset($this->session['idle'])
&& ($this->session['idle'] + $this->idle) < time()) {
$this->log('Session Idle Time Reached', AUTH_LOG_INFO);
$this->idled = true;
$this->status = AUTH_IDLED;
$this->logout();
823,25 → 899,28
return false;
}
 
if ( isset($this->session['registered'])
&& isset($this->session['username'])
&& $this->session['registered'] == true
if ( isset($this->session['registered'])
&& isset($this->session['username'])
&& $this->session['registered'] == true
&& $this->session['username'] != '') {
Auth::updateIdle();
 
if ($this->advancedsecurity) {
$this->log('Advanced Security Mode Enabled.', AUTH_LOG_DEBUG);
 
// Only Generate the challenge once
if($this->authChecks == 1) {
$this->log('Generating new Challenge Cookie.', AUTH_LOG_DEBUG);
$this->session['challengecookieold'] = $this->session['challengecookie'];
$this->session['challengecookie'] = md5($this->session['challengekey'].microtime());
setcookie('authchallenge', $this->session['challengecookie']);
}
 
// Check for ip change
if ( isset($this->server['REMOTE_ADDR'])
if ( isset($this->server['REMOTE_ADDR'])
&& $this->session['sessionip'] != $this->server['REMOTE_ADDR']) {
// Check if the IP of the user has changed, if so we
$this->log('Security Breach. Remote IP Address changed.', AUTH_LOG_INFO);
// Check if the IP of the user has changed, if so we
// assume a man in the middle attack and log him out
$this->expired = true;
$this->status = AUTH_SECURITY_BREACH;
848,11 → 927,25
$this->logout();
return false;
}
 
// Check for ip change (if connected via proxy)
if ( isset($this->server['HTTP_X_FORWARDED_FOR'])
&& $this->session['sessionforwardedfor'] != $this->server['HTTP_X_FORWARDED_FOR']) {
$this->log('Security Breach. Forwarded For IP Address changed.', AUTH_LOG_INFO);
// Check if the IP of the user connecting via proxy has
// changed, if so we assume a man in the middle attack
// and log him out.
$this->expired = true;
$this->status = AUTH_SECURITY_BREACH;
$this->logout();
return false;
}
 
// Check for useragent change
if ( isset($this->server['HTTP_USER_AGENT'])
if ( isset($this->server['HTTP_USER_AGENT'])
&& $this->session['sessionuseragent'] != $this->server['HTTP_USER_AGENT']) {
// Check if the User-Agent of the user has changed, if
$this->log('Security Breach. User Agent changed.', AUTH_LOG_INFO);
// Check if the User-Agent of the user has changed, if
// so we assume a man in the middle attack and log him out
$this->expired = true;
$this->status = AUTH_SECURITY_BREACH;
859,13 → 952,14
$this->logout();
return false;
}
// Check challenge cookie here, if challengecookieold is not set
 
// Check challenge cookie here, if challengecookieold is not set
// this is the first time and check is skipped
// TODO when user open two pages similtaneuly (open in new window,open
// TODO when user open two pages similtaneuly (open in new window,open
// in tab) auth breach is caused find out a way around that if possible
if ( isset($this->session['challengecookieold'])
if ( isset($this->session['challengecookieold'])
&& $this->session['challengecookieold'] != $this->cookie['authchallenge']) {
$this->log('Security Breach. Challenge Cookie mismatch.', AUTH_LOG_INFO);
$this->expired = true;
$this->status = AUTH_SECURITY_BREACH;
$this->logout();
875,8 → 969,10
}
 
if (is_callable($this->checkAuthCallback)) {
$this->log('Calling checkAuthCallback ('.$this->checkAuthCallback.').', AUTH_LOG_DEBUG);
$checkCallback = call_user_func_array($this->checkAuthCallback, array($this->username, &$this));
if ($checkCallback == false) {
$this->log('checkAuthCallback failed.', AUTH_LOG_INFO);
$this->expired = true;
$this->status = AUTH_CALLBACK_ABORT;
$this->logout();
884,9 → 980,11
}
}
 
$this->log('Session OK.', AUTH_LOG_INFO);
return true;
}
}
$this->log('Unable to locate session storage.', AUTH_LOG_DEBUG);
return false;
}
 
907,6 → 1005,7
if(!isset($staticAuth)) {
$staticAuth = new Auth('null', $options);
}
$staticAuth->log('Auth::staticCheckAuth() called', AUTH_LOG_DEBUG);
return $staticAuth->checkAuth();
}
 
921,6 → 1020,7
*/
function getAuth()
{
$this->log('Auth::getAuth() called.', AUTH_LOG_DEBUG);
return $this->checkAuth();
}
 
939,13 → 1039,16
*/
function logout()
{
if (is_callable($this->logoutCallback)) {
$this->log('Auth::logout() called.', AUTH_LOG_DEBUG);
 
if (is_callable($this->logoutCallback) && isset($this->session['username'])) {
$this->log('Calling logoutCallback ('.$this->logoutCallback.').', AUTH_LOG_DEBUG);
call_user_func_array($this->logoutCallback, array($this->session['username'], &$this));
}
 
$this->username = '';
$this->password = '';
 
$this->session = null;
}
 
996,10 → 1099,10
 
// }}}
// {{{ getPostUsernameField()
 
/**
* Gets the post varible used for the username
*
*
* @return string
* @access public
*/
1013,7 → 1116,7
 
/**
* Gets the post varible used for the username
*
*
* @return string
* @access public
*/
1054,6 → 1157,7
*/
function listUsers()
{
$this->log('Auth::listUsers() called.', AUTH_LOG_DEBUG);
$this->_loadStorage();
return $this->storage->listUsers();
}
1073,6 → 1177,7
*/
function addUser($username, $password, $additional = '')
{
$this->log('Auth::addUser() called.', AUTH_LOG_DEBUG);
$this->_loadStorage();
return $this->storage->addUser($username, $password, $additional);
}
1090,6 → 1195,7
*/
function removeUser($username)
{
$this->log('Auth::removeUser() called.', AUTH_LOG_DEBUG);
$this->_loadStorage();
return $this->storage->removeUser($username);
}
1102,17 → 1208,84
*
* @access public
* @param string Username
* @param string The new password
* @param string The new password
* @return mixed True on success, PEAR error object on error
* and AUTH_METHOD_NOT_SUPPORTED otherwise.
*/
function changePassword($username, $password)
{
$this->log('Auth::changePassword() called', AUTH_LOG_DEBUG);
$this->_loadStorage();
return $this->storage->changePassword($username, $password);
}
 
// }}}
// {{{ log()
 
/**
* Log a message from the Auth system
*
* @access public
* @param string The message to log
* @param string The log level to log the message under. See the Log documentation for more info.
* @return boolean
*/
function log($message, $level = AUTH_LOG_DEBUG)
{
if (!$this->enableLogging) return false;
 
$this->_loadLogger();
 
$this->logger->log('AUTH: '.$message, $level);
}
 
// }}}
// {{{ _loadLogger()
 
/**
* Load Log object if not already loaded
*
* Suspend logger instantiation to make Auth lighter to use
* for calls which do not require logging
*
* @return bool True if the logger is loaded, false if the logger
* is already loaded
* @access private
*/
function _loadLogger()
{
if(is_null($this->logger)) {
if (!class_exists('Log')) {
include_once 'Log.php';
}
$this->logger =& Log::singleton('null',
null,
'auth['.getmypid().']',
array(),
AUTH_LOG_DEBUG);
return(true);
}
return(false);
}
 
// }}}
// {{{ attachLogObserver()
 
/**
* Attach an Observer to the Auth Log Source
*
* @param object Log_Observer A Log Observer instance
* @return boolean
*/
function attachLogObserver(&$observer) {
 
$this->_loadLogger();
 
return $this->logger->attach($observer);
 
}
 
// }}}
 
}
?>
/trunk/api/pear/Pager/tests/pager_jumping_noData_test.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/pager_tests.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/multibyte_post.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/pager_noData_test.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/pager_post_tests.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/pager_jumping_test.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/pager_sliding_tests.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/pager_test_xss.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/all_tests.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/pager_sliding_noData_test.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/simple_include.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/pager_test.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/pager_wrapper_test.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/pager_sliding_notExpanded_test.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/pager_include.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/pager_wrapper_include.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/pager_post_test.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/pager_sliding_test.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/tests/README
File deleted
/trunk/api/pear/Pager/tests/pager_jumping_tests.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/examples/example.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/examples/Pager_Wrapper.php
File deleted
\ No newline at end of file
/trunk/api/pear/Pager/Common.php
42,8 → 42,9
* when the user doesn't set any other value
*/
if (substr($_SERVER['PHP_SELF'], -1) == '/') {
$http = !empty($_SERVER['HTTPS']) ? 'https://' : 'http://';
define('CURRENT_FILENAME', '');
define('CURRENT_PATHNAME', 'http://'.$_SERVER['HTTP_HOST'].str_replace('\\', '/', $_SERVER['PHP_SELF']));
define('CURRENT_PATHNAME', $http.$_SERVER['HTTP_HOST'].str_replace('\\', '/', $_SERVER['PHP_SELF']));
} else {
define('CURRENT_FILENAME', preg_replace('/(.*)\?.*/', '\\1', basename($_SERVER['PHP_SELF'])));
define('CURRENT_PATHNAME', str_replace('\\', '/', dirname($_SERVER['PHP_SELF'])));
199,6 → 200,12
* @access private
*/
var $_attributes = '';
/**
* @var string onclick
* @access private
*/
var $_onclick = '';
 
/**
* @var string alt text for "first page" (use "%d" placeholder for page number)
445,6 → 452,7
'expanded',
'accesskey',
'attributes',
'onclick',
'separator',
'spacesBeforeSeparator',
'spacesAfterSeparator',
475,7 → 483,7
 
// }}}
// {{{ build()
 
/**
* Generate or refresh the links and paged data after a call to setOptions()
*
483,9 → 491,29
*/
function build()
{
$msg = '<b>PEAR::Pager Error:</b>'
.' function "build()" not implemented.';
return $this->raiseError($msg, ERROR_PAGER_NOT_IMPLEMENTED);
//reset
$this->_pageData = array();
$this->links = '';
 
$this->_generatePageData();
$this->_setFirstLastText();
 
if ($this->_totalPages > (2 * $this->_delta + 1)) {
$this->links .= $this->_printFirstPage();
}
 
$this->links .= $this->_getBackLink();
$this->links .= $this->_getPageLinks();
$this->links .= $this->_getNextLink();
 
$this->linkTags .= $this->_getFirstLinkTag();
$this->linkTags .= $this->_getPrevLinkTag();
$this->linkTags .= $this->_getNextLinkTag();
$this->linkTags .= $this->_getLastLinkTag();
 
if ($this->_totalPages > (2 * $this->_delta + 1)) {
$this->links .= $this->_printLastPage();
}
}
 
// }}}
752,11 → 780,16
} else {
$href = str_replace('%d', $this->_linkData[$this->_urlVar], $this->_fileName);
}
return sprintf('<a href="%s"%s%s%s title="%s">%s</a>',
$onclick = '';
if (array_key_exists($this->_urlVar, $this->_linkData)) {
$onclick = str_replace('%d', $this->_linkData[$this->_urlVar], $this->_onclick);
}
return sprintf('<a href="%s"%s%s%s%s title="%s">%s</a>',
htmlentities($this->_url . $href),
empty($this->_classString) ? '' : ' '.$this->_classString,
empty($this->_attributes) ? '' : ' '.$this->_attributes,
empty($this->_accesskey) ? '' : ' accesskey="'.$this->_linkData[$this->_urlVar].'"',
empty($onclick) ? '' : ' onclick="'.$onclick.'"',
$altText,
$linkText
);
894,15 → 927,15
$qs = $_GET;
}
}
if (count($this->_extraVars)){
$this->_recursive_urldecode($this->_extraVars);
}
$qs = array_merge($qs, $this->_extraVars);
foreach ($this->_excludeVars as $exclude) {
if (array_key_exists($exclude, $qs)) {
unset($qs[$exclude]);
}
}
if (count($this->_extraVars)){
$this->_recursive_urldecode($this->_extraVars);
$qs = array_merge($qs, $this->_extraVars);
}
if (count($qs) && get_magic_quotes_gpc()){
$this->_recursive_stripslashes($qs);
}
1293,6 → 1326,10
function __http_build_query($array, $name)
{
$tmp = array ();
$separator = ini_get('arg_separator.output');
if ($separator == '&amp;') {
$separator = '&'; //the string is escaped by htmlentities anyway...
}
foreach ($array as $key => $value) {
if (is_array($value)) {
//array_push($tmp, $this->__http_build_query($value, sprintf('%s[%s]', $name, $key)));
1305,7 → 1342,7
array_push($tmp, $this->__http_build_query(get_object_vars($value), $name.'%5B'.$key.'%5D'));
}
}
return implode(ini_get('arg_separator.output'), $tmp);
return implode($separator, $tmp);
}
 
// }}}
1386,7 → 1423,7
if (strncasecmp($this->_fileName, 'javascript', 10) != 0) {
$this->_url .= '/';
}
if (!strstr($this->_fileName, '%d')) {
if (strpos($this->_fileName, '%d') === false) {
trigger_error($this->errorMessage(ERROR_PAGER_INVALID_USAGE), E_USER_WARNING);
}
}
/trunk/api/pear/Pager/Jumping.php
75,33 → 75,6
}
 
// }}}
// {{{ build()
 
/**
* Generate or refresh the links and paged data after a call to setOptions()
*
* @access public
*/
function build()
{
//reset
$this->_pageData = array();
$this->links = '';
 
$this->_generatePageData();
$this->_setFirstLastText();
 
$this->links .= $this->_getBackLink();
$this->links .= $this->_getPageLinks();
$this->links .= $this->_getNextLink();
 
$this->linkTags .= $this->_getFirstLinkTag();
$this->linkTags .= $this->_getPrevLinkTag();
$this->linkTags .= $this->_getNextLinkTag();
$this->linkTags .= $this->_getLastLinkTag();
}
 
// }}}
// {{{ getPageIdByOffset()
 
/**
188,13 → 161,14
}
 
if (!is_null($pageID)) {
$_sav = $this->_currentPage;
$this->_currentPage = $pageID;
 
$this->links = '';
if ($this->_totalPages > $this->_delta) {
$this->links .= $this->_printFirstPage();
}
 
$_sav = $this->_currentPage;
$this->_currentPage = $pageID;
 
$this->links .= $this->_getBackLink('', $back_html);
$this->links .= $this->_getPageLinks();
$this->links .= $this->_getNextLink('', $next_html);
/trunk/api/pear/Pager/Sliding.php
84,41 → 84,6
}
 
// }}}
// {{{ build()
 
/**
* Generate or refresh the links and paged data after a call to setOptions()
*
* @access public
*/
function build()
{
//reset
$this->_pageData = array();
$this->links = '';
 
$this->_generatePageData();
$this->_setFirstLastText();
 
if ($this->_totalPages > (2 * $this->_delta + 1)) {
$this->links .= $this->_printFirstPage();
}
 
$this->links .= $this->_getBackLink();
$this->links .= $this->_getPageLinks();
$this->links .= $this->_getNextLink();
 
$this->linkTags .= $this->_getFirstLinkTag();
$this->linkTags .= $this->_getPrevLinkTag();
$this->linkTags .= $this->_getNextLinkTag();
$this->linkTags .= $this->_getLastLinkTag();
 
if ($this->_totalPages > (2 * $this->_delta + 1)) {
$this->links .= $this->_printLastPage();
}
}
 
// }}}
// {{{ getPageIdByOffset()
 
/**
/trunk/api/pear/Pager/HtmlWidgets.php
71,6 → 71,8
* - 'attributes': (html attributes) Tag attributes or
* HTML attributes (id="foo" pairs), will be inserted in the
* <select> tag
* - 'checkMaxLimit': if true, Pager checks if $end is bigger
* than $totalItems, and doesn't show the extra select options
* @return string xhtml select box
* @access public
*/
79,6 → 81,7
// FIXME: needs POST support
$optionText = '%d';
$attributes = '';
$checkMaxLimit = false;
if (is_string($extraParams)) {
//old behavior, BC maintained
$optionText = $extraParams;
89,6 → 92,9
if (array_key_exists('attributes', $extraParams)) {
$attributes = $extraParams['attributes'];
}
if (array_key_exists('checkMaxLimit', $extraParams)) {
$checkMaxLimit = $extraParams['checkMaxLimit'];
}
}
 
if (!strstr($optionText, '%d')) {
105,6 → 111,10
} else {
$selected = $this->pager->_perPage;
}
if ($checkMaxLimit && $this->pager->_totalItems > 0 && $this->pager->_totalItems < $end) {
$end = $this->pager->_totalItems;
}
 
$tmp = '<select name="'.$this->pager->_sessionVar.'"';
if (!empty($attributes)) {
111,7 → 121,9
$tmp .= ' '.$attributes;
}
$tmp .= '>';
$last = $start;
for ($i=$start; $i<=$end; $i+=$step) {
$last = $i;
$tmp .= '<option value="'.$i.'"';
if ($i == $selected) {
$tmp .= ' selected="selected"';
118,7 → 130,7
}
$tmp .= '>'.sprintf($optionText, $i).'</option>';
}
if ($showAllData && $end < $this->pager->_totalItems) {
if ($showAllData && $last != $this->pager->_totalItems) {
$tmp .= '<option value="'.$this->pager->_totalItems.'"';
if ($this->pager->_totalItems == $selected) {
$tmp .= ' selected="selected"';
/trunk/api/pear/Pager/Pager.php
165,7 → 165,7
* @static
* @access public
*/
function &factory($options = array())
static function &factory($options = array())
{
$mode = (isset($options['mode']) ? ucfirst($options['mode']) : 'Jumping');
$classname = 'Pager_' . $mode;
/trunk/api/pear/Pager/Pager_savebc.php
New file
0,0 → 1,3
<?php
require_once 'Pager.php';
?>
/trunk/api/pear/XML/Parser.php
New file
0,0 → 1,690
<?php
//
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Stig Bakken <ssb@fast.no> |
// | Tomas V.V.Cox <cox@idecnet.com> |
// | Stephan Schmidt <schst@php-tools.net> |
// +----------------------------------------------------------------------+
//
// $Id: Parser.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
 
/**
* XML Parser class.
*
* This is an XML parser based on PHP's "xml" extension,
* based on the bundled expat library.
*
* @category XML
* @package XML_Parser
* @author Stig Bakken <ssb@fast.no>
* @author Tomas V.V.Cox <cox@idecnet.com>
* @author Stephan Schmidt <schst@php-tools.net>
*/
 
/**
* uses PEAR's error handling
*/
require_once 'PEAR.php';
 
/**
* resource could not be created
*/
define('XML_PARSER_ERROR_NO_RESOURCE', 200);
 
/**
* unsupported mode
*/
define('XML_PARSER_ERROR_UNSUPPORTED_MODE', 201);
 
/**
* invalid encoding was given
*/
define('XML_PARSER_ERROR_INVALID_ENCODING', 202);
 
/**
* specified file could not be read
*/
define('XML_PARSER_ERROR_FILE_NOT_READABLE', 203);
 
/**
* invalid input
*/
define('XML_PARSER_ERROR_INVALID_INPUT', 204);
 
/**
* remote file cannot be retrieved in safe mode
*/
define('XML_PARSER_ERROR_REMOTE', 205);
 
/**
* XML Parser class.
*
* This is an XML parser based on PHP's "xml" extension,
* based on the bundled expat library.
*
* Notes:
* - It requires PHP 4.0.4pl1 or greater
* - From revision 1.17, the function names used by the 'func' mode
* are in the format "xmltag_$elem", for example: use "xmltag_name"
* to handle the <name></name> tags of your xml file.
*
* @category XML
* @package XML_Parser
* @author Stig Bakken <ssb@fast.no>
* @author Tomas V.V.Cox <cox@idecnet.com>
* @author Stephan Schmidt <schst@php-tools.net>
* @todo create XML_Parser_Namespace to parse documents with namespaces
* @todo create XML_Parser_Pull
* @todo Tests that need to be made:
* - mixing character encodings
* - a test using all expat handlers
* - options (folding, output charset)
* - different parsing modes
*/
class XML_Parser extends PEAR
{
// {{{ properties
 
/**
* XML parser handle
*
* @var resource
* @see xml_parser_create()
*/
var $parser;
 
/**
* File handle if parsing from a file
*
* @var resource
*/
var $fp;
 
/**
* Whether to do case folding
*
* If set to true, all tag and attribute names will
* be converted to UPPER CASE.
*
* @var boolean
*/
var $folding = true;
 
/**
* Mode of operation, one of "event" or "func"
*
* @var string
*/
var $mode;
 
/**
* Mapping from expat handler function to class method.
*
* @var array
*/
var $handler = array(
'character_data_handler' => 'cdataHandler',
'default_handler' => 'defaultHandler',
'processing_instruction_handler' => 'piHandler',
'unparsed_entity_decl_handler' => 'unparsedHandler',
'notation_decl_handler' => 'notationHandler',
'external_entity_ref_handler' => 'entityrefHandler'
);
 
/**
* source encoding
*
* @var string
*/
var $srcenc;
 
/**
* target encoding
*
* @var string
*/
var $tgtenc;
 
/**
* handler object
*
* @var object
*/
var $_handlerObj;
 
/**
* valid encodings
*
* @var array
*/
var $_validEncodings = array('ISO-8859-1', 'UTF-8', 'US-ASCII');
 
// }}}
// {{{ constructor
 
/**
* Creates an XML parser.
*
* This is needed for PHP4 compatibility, it will
* call the constructor, when a new instance is created.
*
* @param string $srcenc source charset encoding, use NULL (default) to use
* whatever the document specifies
* @param string $mode how this parser object should work, "event" for
* startelement/endelement-type events, "func"
* to have it call functions named after elements
* @param string $tgenc a valid target encoding
*/
function XML_Parser($srcenc = null, $mode = 'event', $tgtenc = null)
{
XML_Parser::__construct($srcenc, $mode, $tgtenc);
}
// }}}
 
/**
* PHP5 constructor
*
* @param string $srcenc source charset encoding, use NULL (default) to use
* whatever the document specifies
* @param string $mode how this parser object should work, "event" for
* startelement/endelement-type events, "func"
* to have it call functions named after elements
* @param string $tgenc a valid target encoding
*/
function __construct($srcenc = null, $mode = 'event', $tgtenc = null)
{
$this->PEAR('XML_Parser_Error');
 
$this->mode = $mode;
$this->srcenc = $srcenc;
$this->tgtenc = $tgtenc;
}
// }}}
 
/**
* Sets the mode of the parser.
*
* Possible modes are:
* - func
* - event
*
* You can set the mode using the second parameter
* in the constructor.
*
* This method is only needed, when switching to a new
* mode at a later point.
*
* @access public
* @param string mode, either 'func' or 'event'
* @return boolean|object true on success, PEAR_Error otherwise
*/
function setMode($mode)
{
if ($mode != 'func' && $mode != 'event') {
$this->raiseError('Unsupported mode given', XML_PARSER_ERROR_UNSUPPORTED_MODE);
}
 
$this->mode = $mode;
return true;
}
 
/**
* Sets the object, that will handle the XML events
*
* This allows you to create a handler object independent of the
* parser object that you are using and easily switch the underlying
* parser.
*
* If no object will be set, XML_Parser assumes that you
* extend this class and handle the events in $this.
*
* @access public
* @param object object to handle the events
* @return boolean will always return true
* @since v1.2.0beta3
*/
function setHandlerObj(&$obj)
{
$this->_handlerObj = &$obj;
return true;
}
 
/**
* Init the element handlers
*
* @access private
*/
function _initHandlers()
{
if (!is_resource($this->parser)) {
return false;
}
 
if (!is_object($this->_handlerObj)) {
$this->_handlerObj = &$this;
}
switch ($this->mode) {
 
case 'func':
xml_set_object($this->parser, $this->_handlerObj);
xml_set_element_handler($this->parser, array(&$this, 'funcStartHandler'), array(&$this, 'funcEndHandler'));
break;
 
case 'event':
xml_set_object($this->parser, $this->_handlerObj);
xml_set_element_handler($this->parser, 'startHandler', 'endHandler');
break;
default:
return $this->raiseError('Unsupported mode given', XML_PARSER_ERROR_UNSUPPORTED_MODE);
break;
}
 
 
/**
* set additional handlers for character data, entities, etc.
*/
foreach ($this->handler as $xml_func => $method) {
if (method_exists($this->_handlerObj, $method)) {
$xml_func = 'xml_set_' . $xml_func;
$xml_func($this->parser, $method);
}
}
}
 
// {{{ _create()
 
/**
* create the XML parser resource
*
* Has been moved from the constructor to avoid
* problems with object references.
*
* Furthermore it allows us returning an error
* if something fails.
*
* @access private
* @return boolean|object true on success, PEAR_Error otherwise
*
* @see xml_parser_create
*/
function _create()
{
if ($this->srcenc === null) {
$xp = @xml_parser_create();
} else {
$xp = @xml_parser_create($this->srcenc);
}
if (is_resource($xp)) {
if ($this->tgtenc !== null) {
if (!@xml_parser_set_option($xp, XML_OPTION_TARGET_ENCODING,
$this->tgtenc)) {
return $this->raiseError('invalid target encoding', XML_PARSER_ERROR_INVALID_ENCODING);
}
}
$this->parser = $xp;
$result = $this->_initHandlers($this->mode);
if ($this->isError($result)) {
return $result;
}
xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, $this->folding);
return true;
}
if (!in_array(strtoupper($this->srcenc), $this->_validEncodings)) {
return $this->raiseError('invalid source encoding', XML_PARSER_ERROR_INVALID_ENCODING);
}
return $this->raiseError('Unable to create XML parser resource.', XML_PARSER_ERROR_NO_RESOURCE);
}
 
// }}}
// {{{ reset()
 
/**
* Reset the parser.
*
* This allows you to use one parser instance
* to parse multiple XML documents.
*
* @access public
* @return boolean|object true on success, PEAR_Error otherwise
*/
function reset()
{
$result = $this->_create();
if ($this->isError( $result )) {
return $result;
}
return true;
}
 
// }}}
// {{{ setInputFile()
 
/**
* Sets the input xml file to be parsed
*
* @param string Filename (full path)
* @return resource fopen handle of the given file
* @throws XML_Parser_Error
* @see setInput(), setInputString(), parse()
* @access public
*/
function setInputFile($file)
{
/**
* check, if file is a remote file
*/
if (eregi('^(http|ftp)://', substr($file, 0, 10))) {
if (!ini_get('allow_url_fopen')) {
return $this->raiseError('Remote files cannot be parsed, as safe mode is enabled.', XML_PARSER_ERROR_REMOTE);
}
}
 
$fp = @fopen($file, 'rb');
if (is_resource($fp)) {
$this->fp = $fp;
return $fp;
}
return $this->raiseError('File could not be opened.', XML_PARSER_ERROR_FILE_NOT_READABLE);
}
 
// }}}
// {{{ setInputString()
 
/**
* XML_Parser::setInputString()
*
* Sets the xml input from a string
*
* @param string $data a string containing the XML document
* @return null
**/
function setInputString($data)
{
$this->fp = $data;
return null;
}
 
// }}}
// {{{ setInput()
 
/**
* Sets the file handle to use with parse().
*
* You should use setInputFile() or setInputString() if you
* pass a string
*
* @param mixed $fp Can be either a resource returned from fopen(),
* a URL, a local filename or a string.
* @access public
* @see parse()
* @uses setInputString(), setInputFile()
*/
function setInput($fp)
{
if (is_resource($fp)) {
$this->fp = $fp;
return true;
}
// see if it's an absolute URL (has a scheme at the beginning)
elseif (eregi('^[a-z]+://', substr($fp, 0, 10))) {
return $this->setInputFile($fp);
}
// see if it's a local file
elseif (file_exists($fp)) {
return $this->setInputFile($fp);
}
// it must be a string
else {
$this->fp = $fp;
return true;
}
 
return $this->raiseError('Illegal input format', XML_PARSER_ERROR_INVALID_INPUT);
}
 
// }}}
// {{{ parse()
 
/**
* Central parsing function.
*
* @return true|object PEAR error returns true on success, or a PEAR_Error otherwise
* @access public
*/
function parse()
{
/**
* reset the parser
*/
$result = $this->reset();
if ($this->isError($result)) {
return $result;
}
// if $this->fp was fopened previously
if (is_resource($this->fp)) {
 
while ($data = fread($this->fp, 4096)) {
if (!$this->_parseString($data, feof($this->fp))) {
$error = &$this->raiseError();
$this->free();
return $error;
}
}
// otherwise, $this->fp must be a string
} else {
if (!$this->_parseString($this->fp, true)) {
$error = &$this->raiseError();
$this->free();
return $error;
}
}
$this->free();
 
return true;
}
 
/**
* XML_Parser::_parseString()
*
* @param string $data
* @param boolean $eof
* @return bool
* @access private
* @see parseString()
**/
function _parseString($data, $eof = false)
{
return xml_parse($this->parser, $data, $eof);
}
 
// }}}
// {{{ parseString()
 
/**
* XML_Parser::parseString()
*
* Parses a string.
*
* @param string $data XML data
* @param boolean $eof If set and TRUE, data is the last piece of data sent in this parser
* @throws XML_Parser_Error
* @return Pear Error|true true on success or a PEAR Error
* @see _parseString()
*/
function parseString($data, $eof = false)
{
if (!isset($this->parser) || !is_resource($this->parser)) {
$this->reset();
}
 
if (!$this->_parseString($data, $eof)) {
$error = &$this->raiseError();
$this->free();
return $error;
}
 
if ($eof === true) {
$this->free();
}
return true;
}
 
/**
* XML_Parser::free()
*
* Free the internal resources associated with the parser
*
* @return null
**/
function free()
{
if (isset($this->parser) && is_resource($this->parser)) {
xml_parser_free($this->parser);
unset( $this->parser );
}
if (isset($this->fp) && is_resource($this->fp)) {
fclose($this->fp);
}
unset($this->fp);
return null;
}
 
/**
* XML_Parser::raiseError()
*
* Throws a XML_Parser_Error
*
* @param string $msg the error message
* @param integer $ecode the error message code
* @return XML_Parser_Error
**/
function raiseError($msg = null, $ecode = 0)
{
$msg = !is_null($msg) ? $msg : $this->parser;
$err = &new XML_Parser_Error($msg, $ecode);
return parent::raiseError($err);
}
 
// }}}
// {{{ funcStartHandler()
 
function funcStartHandler($xp, $elem, $attribs)
{
$func = 'xmltag_' . $elem;
$func = str_replace(array('.', '-', ':'), '_', $func);
if (method_exists($this->_handlerObj, $func)) {
call_user_func(array(&$this->_handlerObj, $func), $xp, $elem, $attribs);
} elseif (method_exists($this->_handlerObj, 'xmltag')) {
call_user_func(array(&$this->_handlerObj, 'xmltag'), $xp, $elem, $attribs);
}
}
 
// }}}
// {{{ funcEndHandler()
 
function funcEndHandler($xp, $elem)
{
$func = 'xmltag_' . $elem . '_';
$func = str_replace(array('.', '-', ':'), '_', $func);
if (method_exists($this->_handlerObj, $func)) {
call_user_func(array(&$this->_handlerObj, $func), $xp, $elem);
} elseif (method_exists($this->_handlerObj, 'xmltag_')) {
call_user_func(array(&$this->_handlerObj, 'xmltag_'), $xp, $elem);
}
}
 
// }}}
// {{{ startHandler()
 
/**
*
* @abstract
*/
function startHandler($xp, $elem, &$attribs)
{
return NULL;
}
 
// }}}
// {{{ endHandler()
 
/**
*
* @abstract
*/
function endHandler($xp, $elem)
{
return NULL;
}
 
 
// }}}me
}
 
/**
* error class, replaces PEAR_Error
*
* An instance of this class will be returned
* if an error occurs inside XML_Parser.
*
* There are three advantages over using the standard PEAR_Error:
* - All messages will be prefixed
* - check for XML_Parser error, using is_a( $error, 'XML_Parser_Error' )
* - messages can be generated from the xml_parser resource
*
* @package XML_Parser
* @access public
* @see PEAR_Error
*/
class XML_Parser_Error extends PEAR_Error
{
// {{{ properties
 
/**
* prefix for all messages
*
* @var string
*/
var $error_message_prefix = 'XML_Parser: ';
 
// }}}
// {{{ constructor()
/**
* construct a new error instance
*
* You may either pass a message or an xml_parser resource as first
* parameter. If a resource has been passed, the last error that
* happened will be retrieved and returned.
*
* @access public
* @param string|resource message or parser resource
* @param integer error code
* @param integer error handling
* @param integer error level
*/
function XML_Parser_Error($msgorparser = 'unknown error', $code = 0, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE)
{
if (is_resource($msgorparser)) {
$code = xml_get_error_code($msgorparser);
$msgorparser = sprintf('%s at XML input line %d:%d',
xml_error_string($code),
xml_get_current_line_number($msgorparser),
xml_get_current_column_number($msgorparser));
}
$this->PEAR_Error($msgorparser, $code, $mode, $level);
}
// }}}
}
?>
/trunk/api/pear/Auth/SASL/Plain.php
File deleted
/trunk/api/pear/Auth/SASL/DigestMD5.php
File deleted
/trunk/api/pear/Auth/SASL/Anonymous.php
File deleted
\ No newline at end of file
/trunk/api/pear/Auth/SASL/Common.php
File deleted
/trunk/api/pear/Auth/SASL/CramMD5.php
File deleted
\ No newline at end of file
/trunk/api/pear/Auth/SASL/Login.php
File deleted
\ No newline at end of file
/trunk/api/pear/Auth/HTTP.php
File deleted
/trunk/api/pear/Auth/SASL.php
File deleted
\ No newline at end of file
/trunk/api/pear/Auth/PrefManager.php
File deleted
/trunk/api/pear/Auth/RADIUS.php
File deleted
/trunk/api/pear/Auth/Anonymous.php
18,7 → 18,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 CVS: $Id: Anonymous.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: Anonymous.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
*/
30,8 → 30,8
 
/**
* Anonymous Authentication
*
* This class provides anonymous authentication if username and password
*
* This class provides anonymous authentication if username and password
* were not supplied
*
* @category Authentication
40,11 → 40,11
* @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
*/
class Auth_Anonymous extends Auth
class Auth_Anonymous extends Auth
{
 
// {{{ properties
65,10 → 65,10
 
// }}}
// {{{ Auth_Anonymous() [constructor]
 
/**
* Pass all parameters to Parent Auth class
*
*
* Set up the storage driver.
*
* @param string Type of the storage driver
87,10 → 87,10
 
// }}}
// {{{ login()
 
/**
* Login function
*
*
* If no username & password is passed then login as the username
* provided in $this->anonymous_username else call standard login()
* function.
100,8 → 100,8
* @see Auth::login()
*/
function login() {
if ( $this->allow_anonymous
&& empty($this->username)
if ( $this->allow_anonymous
&& empty($this->username)
&& empty($this->password) ) {
$this->setAuth($this->anonymous_username);
if (is_callable($this->loginCallback)) {
115,7 → 115,7
 
// }}}
// {{{ forceLogin()
 
/**
* Force the user to login
*
/trunk/api/pear/Auth/Frontend/Html.php
18,7 → 18,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 CVS: $Id: Html.php,v 1.1 2006-12-14 15:04:29 jp_milcent Exp $
* @version CVS: $Id: Html.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
*/
25,7 → 25,7
 
/**
* Standard Html Login form
*
*
* @category Authentication
* @package Auth
* @author Yavor Shahpasov <yavo@netsmart.com.cy>
32,12 → 32,12
* @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
*/
class Auth_Frontend_Html {
 
// {{{ render()
 
/**
49,7 → 49,7
*/
function render(&$caller, $username = '') {
$loginOnClick = 'return true;';
 
// Try To Use Challene response
// TODO javascript might need some improvement for work on other browsers
if($caller->advancedsecurity && $caller->storage->supportsChallengeResponse() ) {
68,7 → 68,7
print ' var secret = document.getElementById(\'authsecret\')'."\n";
//print ' alert(pass);alert(secret); '."\n";
 
// If using md5 for password storage md5 the password before
// If using md5 for password storage md5 the password before
// we hash it with the secret
// print ' alert(pass.value);';
if ($caller->storage->getCryptType() == 'md5' ) {
101,7 → 101,7
} else if (!empty ($caller->status) && $caller->status == AUTH_SECURITY_BREACH) {
$status = '<i>Security problem detected. </i>'."\n";
}
 
print '<form method="post" action="'.$caller->server['PHP_SELF'].'" '
.'onSubmit="'.$loginOnClick.'">'."\n";
print '<table border="0" cellpadding="2" cellspacing="0" '
113,7 → 113,7
print '<tr>'."\n";
print ' <td>Username:</td>'."\n";
print ' <td><input type="text" id="'.$caller->getPostUsernameField()
.'" name="'.$caller->getPostUsernameField().'" value="' . $username
.'" name="'.$caller->getPostUsernameField().'" value="' . $username
.'" /></td>'."\n";
print '</tr>'."\n";
print '<tr>'."\n";
122,7 → 122,7
.'" name="'.$caller->getPostPasswordField().'" /></td>'."\n";
print '</tr>'."\n";
print '<tr>'."\n";
 
//onClick=" '.$loginOnClick.' "
print ' <td colspan="2" bgcolor="#eeeeee"><input value="Login" '
.'id="doLogin" name="doLogin" type="submit" /></td>'."\n";
129,7 → 129,7
print '</tr>'."\n";
print '</table>'."\n";
 
// Might be a good idea to make the variable name variable
// Might be a good idea to make the variable name variable
print '<input type="hidden" id="authsecret" name="authsecret" value="" />';
print '</form>'."\n";
print '</center>'."\n";
136,7 → 136,7
}
 
// }}}
 
}
 
?>
/trunk/api/pear/Auth/Container/Array.php
18,7 → 18,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 CVS: $Id: Array.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: Array.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $
* @since File available since Release 1.4.0
*/
 
64,7 → 64,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 $
* @since File available since Release 1.4.0
*/
 
99,16 → 99,16
{
if (!is_array($data)) {
PEAR::raiseError('The options for Auth_Container_Array must be an array');
}
}
if (isset($data['users']) && is_array($data['users'])) {
$this->users = $data['users'];
} else {
$this->users = array();
PEAR::raiseError('Auth_Container_Array: no user data found inoptions array');
}
PEAR::raiseError('Auth_Container_Array: no user data found in options array');
}
if (isset($data['cryptType'])) {
$this->cryptType = $data['cryptType'];
}
}
}
 
// }}}
128,12 → 128,13
*/
function fetchData($user, $pass)
{
$this->log('Auth_Container_Array::fetchData() called.', AUTH_LOG_DEBUG);
if ( isset($this->users[$user])
&& $this->verifyPassword($pass, $this->users[$user], $this->cryptType)) {
return true;
}
return false;
}
}
 
// }}}
// {{{ listUsers()
145,15 → 146,16
*/
function listUsers()
{
$this->log('Auth_Container_Array::listUsers() called.', AUTH_LOG_DEBUG);
$ret = array();
foreach ($this->users as $username => $password) {
$ret[]['username'] = $username;
}
}
return $ret;
}
}
 
// }}}
 
}
}
 
?>
/trunk/api/pear/Auth/Container/File.php
14,14 → 14,14
*
* @category Authentication
* @package Auth
* @author Stefan Ekman <stekman@sedata.org>
* @author Stefan Ekman <stekman@sedata.org>
* @author Martin Jansen <mj@php.net>
* @author Mika Tuupola <tuupola@appelsiini.net>
* @author Mika Tuupola <tuupola@appelsiini.net>
* @author Michael Wallner <mike@php.net>
* @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: File.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: File.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
*/
 
45,14 → 45,14
*
* @category Authentication
* @package Auth
* @author Stefan Ekman <stekman@sedata.org>
* @author Stefan Ekman <stekman@sedata.org>
* @author Martin Jansen <mj@php.net>
* @author Mika Tuupola <tuupola@appelsiini.net>
* @author Mika Tuupola <tuupola@appelsiini.net>
* @author Michael Wallner <mike@php.net>
* @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.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
*/
class Auth_Container_File extends Auth_Container
62,7 → 62,7
 
/**
* Path to passwd file
*
*
* @var string
*/
var $pwfile = '';
85,7 → 85,7
*/
function Auth_Container_File($filename) {
$this->_setDefaults();
 
// Only file is a valid option here
if(is_array($filename)) {
$this->pwfile = $filename['file'];
107,19 → 107,22
*/
function fetchData($user, $pass)
{
$this->log('Auth_Container_File::fetchData() called.', AUTH_LOG_DEBUG);
return File_Passwd::staticAuth($this->options['type'], $this->pwfile, $user, $pass);
}
 
// }}}
// {{{ listUsers()
 
/**
* List all available users
*
*
* @return array
*/
function listUsers()
{
$this->log('Auth_Container_File::listUsers() called.', AUTH_LOG_DEBUG);
 
$pw_obj = &$this->_load();
if (PEAR::isError($pw_obj)) {
return array();
131,11 → 134,13
}
 
foreach ($users as $key => $value) {
$retVal[] = array("username" => $key,
$retVal[] = array("username" => $key,
"password" => $value['passwd'],
"cvsuser" => $value['system']);
}
 
$this->log('Found '.count($retVal).' users.', AUTH_LOG_DEBUG);
 
return $retVal;
}
 
153,6 → 158,7
*/
function addUser($user, $pass, $additional='')
{
$this->log('Auth_Container_File::addUser() called.', AUTH_LOG_DEBUG);
$params = array($user, $pass);
if (is_array($additional)) {
foreach ($additional as $item) {
166,17 → 172,17
if (PEAR::isError($pw_obj)) {
return false;
}
 
$res = call_user_func_array(array(&$pw_obj, 'addUser'), $params);
if (PEAR::isError($res)) {
return false;
}
 
$res = $pw_obj->save();
if (PEAR::isError($res)) {
return false;
}
 
return true;
}
 
191,21 → 197,22
*/
function removeUser($user)
{
$this->log('Auth_Container_File::removeUser() called.', AUTH_LOG_DEBUG);
$pw_obj = &$this->_load();
if (PEAR::isError($pw_obj)) {
return false;
}
 
$res = $pw_obj->delUser($user);
if (PEAR::isError($res)) {
return false;
}
 
$res = $pw_obj->save();
if (PEAR::isError($res)) {
return false;
}
 
return true;
}
 
216,54 → 223,56
* Change password for user in the storage container
*
* @param string Username
* @param string The new password
* @param string The new password
*/
function changePassword($username, $password)
{
$this->log('Auth_Container_File::changePassword() called.', AUTH_LOG_DEBUG);
$pw_obj = &$this->_load();
if (PEAR::isError($pw_obj)) {
return false;
}
 
$res = $pw_obj->changePasswd($username, $password);
if (PEAR::isError($res)) {
return false;
}
 
$res = $pw_obj->save();
if (PEAR::isError($res)) {
return false;
}
 
return true;
}
 
// }}}
// {{{ _load()
 
/**
* Load and initialize the File_Passwd object
*
*
* @return object File_Passwd_Cvs|PEAR_Error
*/
function &_load()
{
static $pw_obj;
 
if (!isset($pw_obj)) {
$this->log('Instanciating File_Password object of type '.$this->options['type'], AUTH_LOG_DEBUG);
$pw_obj = File_Passwd::factory($this->options['type']);
if (PEAR::isError($pw_obj)) {
return $pw_obj;
}
 
$pw_obj->setFile($this->pwfile);
 
$res = $pw_obj->load();
if (PEAR::isError($res)) {
return $res;
}
}
 
return $pw_obj;
}
 
/trunk/api/pear/Auth/Container/LDAP.php
14,12 → 14,12
*
* @category Authentication
* @package Auth
* @author Jan Wagner <wagner@netsols.de>
* @author Jan Wagner <wagner@netsols.de>
* @author Adam Ashley <aashley@php.net>
* @author Hugues Peeters <hugues.peeters@claroline.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: LDAP.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: LDAP.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
*/
 
103,7 → 103,7
* or the value of userattr (usually uid)
* group: the name of group to search for
* groupscope: Scope for group searching: one, sub (default), or base
* start_tls: enable/disable the use of START_TLS encrypted connection
* start_tls: enable/disable the use of START_TLS encrypted connection
* (default: false)
* debug: Enable/Disable debugging output (default: false)
* try_all: Whether to try all user accounts returned from the search
177,14 → 177,14
* It seems that binding anonymously to an Active Directory
* is not allowed, so you have to set binddn and bindpw for
* user searching.
*
*
* LDAP Referrals need to be set to false for AD to work sometimes.
*
* Example a3 shows a full blown and tested example for connection to
* Example a3 shows a full blown and tested example for connection to
* Windows 2000 Active Directory with group mebership checking
*
* Note also that if you want an encrypted connection to an MS LDAP
* server, then, on your webserver, you must specify
* Note also that if you want an encrypted connection to an MS LDAP
* server, then, on your webserver, you must specify
* TLS_REQCERT never
* in /etc/ldap/ldap.conf or in the webserver user's ~/.ldaprc (which
* may or may not be read depending on your configuration).
197,7 → 197,7
* @author Hugues Peeters <hugues.peeters@claroline.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.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
*/
class Auth_Container_LDAP extends Auth_Container
275,29 → 275,34
*/
function _connect()
{
$this->log('Auth_Container_LDAP::_connect() called.', AUTH_LOG_DEBUG);
// connect
if (isset($this->options['url']) && $this->options['url'] != '') {
$this->_debug('Connecting with URL', __LINE__);
$this->log('Connecting with URL', AUTH_LOG_DEBUG);
$conn_params = array($this->options['url']);
} else {
$this->_debug('Connecting with host:port', __LINE__);
$this->log('Connecting with host:port', AUTH_LOG_DEBUG);
$conn_params = array($this->options['host'], $this->options['port']);
}
 
if (($this->conn_id = @call_user_func_array('ldap_connect', $conn_params)) === false) {
$this->log('Connection to server failed.', AUTH_LOG_DEBUG);
$this->log('LDAP ERROR: '.ldap_errno($this->conn_id).': '.ldap_error($this->conn_id), AUTH_LOG_DEBUG);
return PEAR::raiseError('Auth_Container_LDAP: Could not connect to server.', 41);
}
$this->_debug('Successfully connected to server', __LINE__);
$this->log('Successfully connected to server', AUTH_LOG_DEBUG);
 
// switch LDAP version
if (is_numeric($this->options['version']) && $this->options['version'] > 2) {
$this->_debug("Switching to LDAP version {$this->options['version']}", __LINE__);
$this->log("Switching to LDAP version {$this->options['version']}", AUTH_LOG_DEBUG);
@ldap_set_option($this->conn_id, LDAP_OPT_PROTOCOL_VERSION, $this->options['version']);
 
// start TLS if available
if (isset($this->options['start_tls']) && $this->options['start_tls']) {
$this->_debug("Starting TLS session", __LINE__);
if (isset($this->options['start_tls']) && $this->options['start_tls']) {
$this->log("Starting TLS session", AUTH_LOG_DEBUG);
if (@ldap_start_tls($this->conn_id) === false) {
$this->log('Could not start TLS session', AUTH_LOG_DEBUG);
$this->log('LDAP ERROR: '.ldap_errno($this->conn_id).': '.ldap_error($this->conn_id), AUTH_LOG_DEBUG);
return PEAR::raiseError('Auth_Container_LDAP: Could not start tls.', 41);
}
}
305,26 → 310,30
 
// switch LDAP referrals
if (is_bool($this->options['referrals'])) {
$this->_debug("Switching LDAP referrals to " . (($this->options['referrals']) ? 'true' : 'false'), __LINE__);
@ldap_set_option($this->conn_id, LDAP_OPT_REFERRALS, $this->options['referrals']);
$this->log("Switching LDAP referrals to " . (($this->options['referrals']) ? 'true' : 'false'), AUTH_LOG_DEBUG);
if (@ldap_set_option($this->conn_id, LDAP_OPT_REFERRALS, $this->options['referrals']) === false) {
$this->log('Could not change LDAP referrals options', AUTH_LOG_DEBUG);
$this->log('LDAP ERROR: '.ldap_errno($this->conn_id).': '.ldap_error($this->conn_id), AUTH_LOG_DEBUG);
}
}
 
// bind with credentials or anonymously
if (strlen($this->options['binddn']) && strlen($this->options['bindpw'])) {
$this->_debug('Binding with credentials', __LINE__);
$this->log('Binding with credentials', AUTH_LOG_DEBUG);
$bind_params = array($this->conn_id, $this->options['binddn'], $this->options['bindpw']);
} else {
$this->_debug('Binding anonymously', __LINE__);
$this->log('Binding anonymously', AUTH_LOG_DEBUG);
$bind_params = array($this->conn_id);
}
 
// bind for searching
if ((@call_user_func_array('ldap_bind', $bind_params)) === false) {
$this->_debug();
$this->log('Bind failed', AUTH_LOG_DEBUG);
$this->log('LDAP ERROR: '.ldap_errno($this->conn_id).': '.ldap_error($this->conn_id), AUTH_LOG_DEBUG);
$this->_disconnect();
return PEAR::raiseError("Auth_Container_LDAP: Could not bind to LDAP server.", 41);
}
$this->_debug('Binding was successful', __LINE__);
$this->log('Binding was successful', AUTH_LOG_DEBUG);
 
return true;
}
339,8 → 348,9
*/
function _disconnect()
{
$this->log('Auth_Container_LDAP::_disconnect() called.', AUTH_LOG_DEBUG);
if ($this->_isValidLink()) {
$this->_debug('disconnecting from server');
$this->log('disconnecting from server');
@ldap_unbind($this->conn_id);
}
}
355,6 → 365,7
*/
function _getBaseDN()
{
$this->log('Auth_Container_LDAP::_getBaseDN() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
361,13 → 372,13
}
 
if ($this->options['basedn'] == "" && $this->_isValidLink()) {
$this->_debug("basedn not set, searching via namingContexts.", __LINE__);
$this->log("basedn not set, searching via namingContexts.", AUTH_LOG_DEBUG);
 
$result_id = @ldap_read($this->conn_id, "", "(objectclass=*)", array("namingContexts"));
 
if (@ldap_count_entries($this->conn_id, $result_id) == 1) {
 
$this->_debug("got result for namingContexts", __LINE__);
$this->log("got result for namingContexts", AUTH_LOG_DEBUG);
 
$entry_id = @ldap_first_entry($this->conn_id, $result_id);
$attrs = @ldap_get_attributes($this->conn_id, $entry_id);
374,7 → 385,7
$basedn = $attrs['namingContexts'][0];
 
if ($basedn != "") {
$this->_debug("result for namingContexts was $basedn", __LINE__);
$this->log("result for namingContexts was $basedn", AUTH_LOG_DEBUG);
$this->options['basedn'] = $basedn;
}
}
430,7 → 441,6
$this->options['userattr'] = 'uid';
$this->options['userfilter'] = '(objectClass=posixAccount)';
$this->options['attributes'] = array(''); // no attributes
// $this->options['attrformat'] = 'LDAP'; // returns attribute array as PHP LDAP functions return it
$this->options['attrformat'] = 'AUTH'; // returns attribute like other Auth containers
$this->options['group'] = '';
$this->options['groupdn'] = '';
477,7 → 487,7
 
/**
* Adapt deprecated options from Auth 1.2 LDAP to Auth 1.3 LDAP
*
*
* @author Hugues Peeters <hugues.peeters@claroline.net>
* @access private
* @param array
536,6 → 546,7
*/
function fetchData($username, $password)
{
$this->log('Auth_Container_LDAP::fetchData() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
548,7 → 559,7
 
// UTF8 Encode username for LDAPv3
if (@ldap_get_option($this->conn_id, LDAP_OPT_PROTOCOL_VERSION, $ver) && $ver == 3) {
$this->_debug('UTF8 encoding username for LDAPv3', __LINE__);
$this->log('UTF8 encoding username for LDAPv3', AUTH_LOG_DEBUG);
$username = utf8_encode($username);
}
 
566,28 → 577,28
$search_basedn .= $this->options['basedn'];
 
// attributes
$attributes = $this->options['attributes'];
$searchAttributes = $this->options['attributes'];
 
// make functions params array
$func_params = array($this->conn_id, $search_basedn, $filter, $attributes);
$func_params = array($this->conn_id, $search_basedn, $filter, $searchAttributes);
 
// search function to use
$func_name = $this->_scope2function($this->options['userscope']);
 
$this->_debug("Searching with $func_name and filter $filter in $search_basedn", __LINE__);
$this->log("Searching with $func_name and filter $filter in $search_basedn", AUTH_LOG_DEBUG);
 
// search
if (($result_id = @call_user_func_array($func_name, $func_params)) === false) {
$this->_debug('User not found', __LINE__);
$this->log('User not found', AUTH_LOG_DEBUG);
} elseif (@ldap_count_entries($this->conn_id, $result_id) >= 1) { // did we get some possible results?
 
$this->_debug('User(s) found', __LINE__);
$this->log('User(s) found', AUTH_LOG_DEBUG);
 
$first = true;
$entry_id = null;
 
do {
 
// then get the user dn
if ($first) {
$entry_id = @ldap_first_entry($this->conn_id, $result_id);
600,11 → 611,11
$user_dn = @ldap_get_dn($this->conn_id, $entry_id);
 
// as the dn is not fetched as an attribute, we save it anyway
if (is_array($attributes) && in_array('dn', $attributes)) {
$this->_debug('Saving DN to AuthData', __LINE__);
if (is_array($searchAttributes) && in_array('dn', $searchAttributes)) {
$this->log('Saving DN to AuthData', AUTH_LOG_DEBUG);
$this->_auth_obj->setAuthData('dn', $user_dn);
}
 
// fetch attributes
if ($attributes = @ldap_get_attributes($this->conn_id, $entry_id)) {
 
625,7 → 636,7
// eg. $this->options['attrformat'] = 'AUTH'
 
if ( strtoupper($this->options['attrformat']) == 'AUTH' ) {
$this->_debug('Saving attributes to Auth data in AUTH format', __LINE__);
$this->log('Saving attributes to Auth data in AUTH format', AUTH_LOG_DEBUG);
unset ($attributes['count']);
foreach ($attributes as $attributeName => $attributeValue ) {
if (is_int($attributeName)) continue;
633,12 → 644,13
unset ($attributeValue['count']);
}
if (count($attributeValue)<=1) $attributeValue = $attributeValue[0];
$this->log('Storing additional field: '.$attributeName, AUTH_LOG_DEBUG);
$this->_auth_obj->setAuthData($attributeName, $attributeValue);
}
}
else
{
$this->_debug('Saving attributes to Auth data in LDAP format', __LINE__);
$this->log('Saving attributes to Auth data in LDAP format', AUTH_LOG_DEBUG);
$this->_auth_obj->setAuthData('attributes', $attributes);
}
}
648,21 → 660,21
// need to catch an empty password as openldap seems to return TRUE
// if anonymous binding is allowed
if ($password != "") {
$this->_debug("Bind as $user_dn", __LINE__);
$this->log("Bind as $user_dn", AUTH_LOG_DEBUG);
 
// try binding as this user with the supplied password
if (@ldap_bind($this->conn_id, $user_dn, $password)) {
$this->_debug('Bind successful', __LINE__);
$this->log('Bind successful', AUTH_LOG_DEBUG);
 
// check group if appropiate
if (strlen($this->options['group'])) {
// decide whether memberattr value is a dn or the username
$this->_debug('Checking group membership', __LINE__);
$this->log('Checking group membership', AUTH_LOG_DEBUG);
$return = $this->checkGroup(($this->options['memberisdn']) ? $user_dn : $username);
$this->_disconnect();
return $return;
} else {
$this->_debug('Authenticated', __LINE__);
$this->log('Authenticated', AUTH_LOG_DEBUG);
$this->_disconnect();
return true; // user authenticated
} // checkGroup
671,7 → 683,7
} while ($this->options['try_all'] == true); // interate through entries
} // get results
// default
$this->_debug('NOT authenticated!', __LINE__);
$this->log('NOT authenticated!', AUTH_LOG_DEBUG);
$this->_disconnect();
return false;
}
691,6 → 703,7
*/
function checkGroup($user)
{
$this->log('Auth_Container_LDAP::checkGroup() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
715,42 → 728,22
array($this->options['memberattr']));
$func_name = $this->_scope2function($this->options['groupscope']);
 
$this->_debug("Searching with $func_name and filter $filter in $search_basedn", __LINE__);
$this->log("Searching with $func_name and filter $filter in $search_basedn", AUTH_LOG_DEBUG);
 
// search
if (($result_id = @call_user_func_array($func_name, $func_params)) != false) {
if (@ldap_count_entries($this->conn_id, $result_id) == 1) {
@ldap_free_result($result_id);
$this->_debug('User is member of group', __LINE__);
$this->log('User is member of group', AUTH_LOG_DEBUG);
return true;
}
}
// default
$this->_debug('User is NOT member of group', __LINE__);
$this->log('User is NOT member of group', AUTH_LOG_DEBUG);
return false;
}
 
// }}}
// {{{ _debug()
 
/**
* Outputs debugging messages
*
* @access private
* @param string Debugging Message
* @param integer Line number
*/
function _debug($msg = '', $line = 0)
{
if ($this->options['debug'] == true) {
if ($msg == '' && $this->_isValidLink()) {
$msg = 'LDAP_Error: ' . @ldap_err2str(@ldap_errno($this->_conn_id));
}
print("$line: $msg <br />");
}
}
 
// }}}
// {{{ _quoteFilterString()
 
/**
/trunk/api/pear/Auth/Container/POP3.php
14,13 → 14,13
*
* @category Authentication
* @package Auth
* @author Stefan Ekman <stekman@sedata.org>
* @author Stefan Ekman <stekman@sedata.org>
* @author Martin Jansen <mj@php.net>
* @author Mika Tuupola <tuupola@appelsiini.net>
* @author Mika Tuupola <tuupola@appelsiini.net>
* @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: POP3.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: POP3.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.2.0
*/
44,11 → 44,11
* @category Authentication
* @package Auth
* @author Martin Jansen <mj@php.net>
* @author Mika Tuupola <tuupola@appelsiini.net>
* @author Mika Tuupola <tuupola@appelsiini.net>
* @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.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.2.0
*/
77,7 → 77,7
* String 'DIGEST-MD5','CRAM-MD5','LOGIN','PLAIN','APOP','USER'
* - Attempt this authentication style first
* then fallback to autodetection.
* @var mixed
* @var mixed
*/
var $method=true;
 
127,9 → 127,11
*/
function fetchData($username, $password)
{
$this->log('Auth_Container_POP3::fetchData() called.', AUTH_LOG_DEBUG);
$pop3 =& new Net_POP3();
$res = $pop3->connect($this->server, $this->port, $this->method);
if (!$res) {
$this->log('Connection to POP3 server failed.', AUTH_LOG_DEBUG);
return $res;
}
$result = $pop3->login($username, $password);
/trunk/api/pear/Auth/Container/SAP.php
20,7 → 20,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 CVS: $Id: SAP.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: SAP.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.4.0
*/
48,13 → 48,13
* @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 $
* @since Class available since Release 1.4.0
*/
class Auth_Container_SAP extends Auth_Container {
 
// {{{ properties
 
/**
* @var array Default options
*/
116,6 → 116,7
*/
function fetchData($username, $password)
{
$this->log('Auth_Container_SAP::fetchData() called.', AUTH_LOG_DEBUG);
$connection_options = $this->options;
$connection_options['USER'] = $username;
$connection_options['PASSWD'] = $password;
130,6 → 131,7
return false;
} else {
if (!empty($this->options['GETSSO2'])) {
$this->log('Attempting to retrieve SSO2 ticket.', AUTH_LOG_DEBUG);
if ($ticket = @saprfc_get_ticket($rfc)) {
$this->options['MYSAPSSO2'] = $ticket;
unset($this->options['GETSSO2']);
141,7 → 143,7
@saprfc_close($rfc);
return true;
}
 
}
 
// }}}
/trunk/api/pear/Auth/Container/MDB2.php
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)) {
/trunk/api/pear/Auth/Container/DB.php
18,7 → 18,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 CVS: $Id: DB.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: DB.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
*/
 
43,7 → 43,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.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
*/
class Auth_Container_DB extends Auth_Container
109,6 → 109,8
*/
function _connect($dsn)
{
$this->log('Auth_Container_DB::_connect() called.', AUTH_LOG_DEBUG);
 
if (is_string($dsn) || is_array($dsn)) {
$this->db = DB::Connect($dsn, $this->options['db_options']);
} elseif (is_subclass_of($dsn, 'db_common')) {
205,6 → 207,7
$this->options['db_fields'] = '';
$this->options['cryptType'] = 'md5';
$this->options['db_options'] = array();
$this->options['db_where'] = '';
$this->options['auto_quote'] = true;
}
 
262,7 → 265,7
 
return '';
}
 
// }}}
// {{{ fetchData()
 
284,6 → 287,7
*/
function fetchData($username, $password, $isChallengeResponse=false)
{
$this->log('Auth_Container_DB::fetchData() called.', AUTH_LOG_DEBUG);
// Prepare for a database query
$err = $this->_prepare();
if ($err !== true) {
307,6 → 311,14
" FROM ".$this->options['final_table'].
" WHERE ".$this->options['final_usernamecol']." = ".$this->db->quoteSmart($username);
 
// 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 DB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->db->getRow($query, null, DB_FETCHMODE_ASSOC);
 
if (DB::isError($res)) {
326,12 → 338,12
if ($isChallengeResponse) {
$res[$this->options['passwordcol']] = md5($res[$this->options['passwordcol']]
.$this->_auth_obj->session['loginchallenege']);
 
// UGLY cannot avoid without modifying verifyPassword
if ($this->options['cryptType'] == 'md5') {
$res[$this->options['passwordcol']] = md5($res[$this->options['passwordcol']]);
}
 
//print " Hashed Password [{$res[$this->options['passwordcol']]}]<br/>\n";
}
 
344,8 → 356,11
$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
// This is because the auth session variable can change so a
// static call to setAuthData does not make sence
$this->_auth_obj->setAuthData($key, $value);
}
366,6 → 381,7
*/
function listUsers()
{
$this->log('Auth_Container_DB::listUsers() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
390,6 → 406,15
$sql_from,
$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 DB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->db->getAll($query, null, DB_FETCHMODE_ASSOC);
 
if (DB::isError($res)) {
400,6 → 425,7
$retVal[] = $user;
}
}
$this->log('Found '.count($retVal).' users.', AUTH_LOG_DEBUG);
return $retVal;
}
 
418,15 → 444,16
*/
function addUser($username, $password, $additional = "")
{
$this->log('Auth_Container_DB::addUser() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
}
 
if ( isset($this->options['cryptType'])
if ( isset($this->options['cryptType'])
&& $this->options['cryptType'] == 'none') {
$cryptFunction = 'strval';
} elseif ( isset($this->options['cryptType'])
} elseif ( isset($this->options['cryptType'])
&& function_exists($this->options['cryptType'])) {
$cryptFunction = $this->options['cryptType'];
} else {
459,6 → 486,8
$additional_value
);
 
$this->log('Running SQL against DB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->query($query);
 
if (DB::isError($res)) {
481,17 → 510,30
*/
function removeUser($username)
{
$this->log('Auth_Container_DB::removeUser() called.', AUTH_LOG_DEBUG);
 
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
}
 
$query = sprintf("DELETE FROM %s WHERE %s = %s",
// check if there is an optional parameter db_where
if ($this->options['db_where'] != '') {
// there is one, so add it to the query
$where = " AND ".$this->options['db_where'];
} else {
$where = '';
}
 
$query = sprintf("DELETE FROM %s WHERE %s = %s %s",
$this->options['final_table'],
$this->options['final_usernamecol'],
$this->db->quoteSmart($username)
$this->db->quoteSmart($username),
$where
);
 
$this->log('Running SQL against DB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->query($query);
 
if (DB::isError($res)) {
512,15 → 554,16
*/
function changePassword($username, $password)
{
$this->log('Auth_Container_DB::changePassword() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
}
 
if ( isset($this->options['cryptType'])
if ( isset($this->options['cryptType'])
&& $this->options['cryptType'] == 'none') {
$cryptFunction = 'strval';
} elseif ( isset($this->options['cryptType'])
} elseif ( isset($this->options['cryptType'])
&& function_exists($this->options['cryptType'])) {
$cryptFunction = $this->options['cryptType'];
} else {
529,14 → 572,25
 
$password = $cryptFunction($password);
 
$query = sprintf("UPDATE %s SET %s = %s WHERE %s = %s",
// check if there is an optional parameter db_where
if ($this->options['db_where'] != '') {
// there is one, so add it to the query
$where = " AND ".$this->options['db_where'];
} else {
$where = '';
}
 
$query = sprintf("UPDATE %s SET %s = %s WHERE %s = %s %s",
$this->options['final_table'],
$this->options['final_passwordcol'],
$this->db->quoteSmart($password),
$this->options['final_usernamecol'],
$this->db->quoteSmart($username)
$this->db->quoteSmart($username),
$where
);
 
$this->log('Running SQL against DB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->query($query);
 
if (DB::isError($res)) {
/trunk/api/pear/Auth/Container/IMAP.php
14,17 → 14,17
*
* @category Authentication
* @package Auth
* @author Jeroen Houben <jeroen@terena.nl>
* @author Jeroen Houben <jeroen@terena.nl>
* @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: IMAP.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: IMAP.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.2.0
*/
 
/**
* Include Auth_Container base class
* Include Auth_Container base class
*/
require_once "Auth/Container.php";
 
77,7 → 77,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.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.2.0
*/
148,6 → 148,7
* @access private
*/
function _checkServer() {
$this->log('Auth_Container_IMAP::_checkServer() called.', AUTH_LOG_DEBUG);
$fp = @fsockopen ($this->options['host'], $this->options['port'],
$errno, $errstr, $this->options['timeout']);
if (is_resource($fp)) {
188,13 → 189,16
*/
function fetchData($username, $password)
{
$this->log('Auth_Container_IMAP::fetchData() called.', AUTH_LOG_DEBUG);
$dsn = '{'.$this->options['host'].':'.$this->options['port'].$this->options['baseDSN'].'}';
$conn = @imap_open ($dsn, $username, $password, OP_HALFOPEN);
if (is_resource($conn)) {
$this->log('Successfully connected to IMAP server.', AUTH_LOG_DEBUG);
$this->activeUser = $username;
@imap_close($conn);
return true;
} else {
$this->log('Connection to IMAP server failed.', AUTH_LOG_DEBUG);
$this->activeUser = '';
return false;
}
/trunk/api/pear/Auth/Container/vpopmail.php
14,11 → 14,11
*
* @category Authentication
* @package Auth
* @author Stanislav Grozev <tacho@orbitel.bg>
* @author Stanislav Grozev <tacho@orbitel.bg>
* @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: vpopmail.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: vpopmail.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.2.0
*/
41,7 → 41,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.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.2.0
*/
74,6 → 74,7
*/
function fetchData($username, $password)
{
$this->log('Auth_Container_vpopmail::fetchData() called.', AUTH_LOG_DEBUG);
$userdata = array();
$userdata = preg_split("/@/", $username, 2);
$result = @vpopmail_auth_user($userdata[0], $userdata[1], $password);
/trunk/api/pear/Auth/Container/SOAP5.php
19,7 → 19,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 CVS: $Id: SOAP5.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: SOAP5.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $
* @since File available since Release 1.4.0
*/
 
38,7 → 38,7
* thats using the PEAR SOAP Package.
*
* This class takes one parameter (options), where
* you specify the following fields:
* you specify the following fields:
* * location and uri, or wsdl file
* * method to call on the SOAP service
* * usernamefield, the name of the parameter where the username is supplied
58,10 → 58,10
* 'wsdl' => NULL,
* 'location' => 'http://your.soap.service/endpoint',
* 'uri' => 'urn:/Your/Namespace',
* 'method' => 'checkAuth',
* 'method' => 'checkAuth',
* 'usernamefield' => 'username',
* 'passwordfield' => 'password',
* 'matchpasswords' => false,
* 'matchpasswords' => false,
* '_features' => array (
* 'extra_parameter' => 'example_value',
* 'another_parameter' => 'foobar'
79,10 → 79,10
*
* $options = array (
* 'wsdl' => 'http://your.soap.service/wsdl',
* 'method' => 'checkAuth',
* 'method' => 'checkAuth',
* 'usernamefield' => 'username',
* 'passwordfield' => 'password',
* 'matchpasswords' => false,
* 'matchpasswords' => false,
* '_features' => array (
* 'extra_parameter' => 'example_value',
* 'another_parameter' => 'foobar'
101,7 → 101,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 $
* @since Class available since Release 1.4.0
*/
class Auth_Container_SOAP5 extends Auth_Container
115,7 → 115,7
* @access private
*/
var $_requiredOptions = array(
'location',
'location',
'uri',
'method',
'usernamefield',
143,7 → 143,7
* @access public
*/
var $soapResponse = array();
 
// }}}
// {{{ Auth_Container_SOAP5()
 
164,7 → 164,7
if (!empty($this->_options['_features'])) {
$this->_features = $this->_options['_features'];
unset($this->_options['_features']);
}
}
}
 
// }}}
181,7 → 181,8
* @return mixed Returns the SOAP response or false if something went wrong
*/
function fetchData($username, $password)
{
{
$this->log('Auth_Container_SOAP5::fetchData() called.', AUTH_LOG_DEBUG);
$result = $this->_validateOptions();
if (PEAR::isError($result))
return $result;
188,8 → 189,8
 
// create a SOAP client
$soapClient = new SoapClient($this->_options["wsdl"], $this->_options);
$params = array();
 
$params = array();
// first, assign the optional features
foreach ($this->_features as $fieldName => $fieldValue) {
$params[$fieldName] = $fieldValue;
196,11 → 197,11
}
// assign username and password ...
$params[$this->_options['usernamefield']] = $username;
$params[$this->_options['passwordfield']] = $password;
$params[$this->_options['passwordfield']] = $password;
 
try {
$this->soapResponse = $soapClient->__soapCall($this->_options['method'], $params);
 
if ($this->_options['matchpasswords']) {
// check if passwords match
if ($password == $this->soapResponse[$this->_options['passwordfield']]) {
208,17 → 209,17
} else {
return false;
}
} else {
} else {
return true;
}
} catch (SoapFault $e) {
return PEAR::raiseError("Error retrieving authentication data. Received SOAP Fault: ".$e->faultstring, $e->faultcode);
}
}
}
 
// }}}
// {{{ _validateOptions()
 
/**
* Validate that the options passed to the container class are enough for us to proceed
*
225,22 → 226,22
* @access private
* @param array
*/
function _validateOptions($array)
function _validateOptions()
{
if ( ( is_null($this->options['wsdl'])
&& is_null($this->options['location'])
&& is_null($this->options['uri']))
|| ( is_null($this->options['wsdl'])
&& ( is_null($this->options['location'])
|| is_null($this->options['uri'])))) {
if ( ( is_null($this->_options['wsdl'])
&& is_null($this->_options['location'])
&& is_null($this->_options['uri']))
|| ( is_null($this->_options['wsdl'])
&& ( is_null($this->_options['location'])
|| is_null($this->_options['uri'])))) {
return PEAR::raiseError('Either a WSDL file or a location/uri pair must be specified.');
}
if (is_null($this->options['method'])) {
if (is_null($this->_options['method'])) {
return PEAR::raiseError('A method to call on the soap service must be specified.');
}
return true;
}
 
// }}}
// {{{ _setDefaults()
 
252,16 → 253,16
*/
function _setDefaults()
{
$this->options['wsdl'] = null;
$this->options['location'] = null;
$this->options['uri'] = null;
$this->options['method'] = null;
$this->options['usernamefield'] = 'username';
$this->options['passwordfield'] = 'password';
$this->options['matchpasswords'] = true;
$this->_options['wsdl'] = null;
$this->_options['location'] = null;
$this->_options['uri'] = null;
$this->_options['method'] = null;
$this->_options['usernamefield'] = 'username';
$this->_options['passwordfield'] = 'password';
$this->_options['matchpasswords'] = true;
}
 
// }}}
 
}
?>
/trunk/api/pear/Auth/Container/PEAR.php
18,19 → 18,19
* @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: PEAR.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: PEAR.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
*/
 
/**
* Include PEAR HTTP_Client.
*/
require_once 'HTTP/Client.php';
/**
* Include Auth_Container base class
*/
require_once 'Auth/Container.php';
/**
* Include PEAR XML_RPC
*/
require_once 'XML/RPC.php';
 
/**
* Storage driver for authenticating against PEAR website
42,9 → 42,10
* @package Auth
* @author Yavor Shahpasov <yavo@netsmart.com.cy>
* @author Adam Ashley <aashley@php.net>
* @copyright 2001-2006 The PHP Group
* @author Adam Harvey <aharvey@php.net>
* @copyright 2001-2007 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
*/
57,17 → 58,17
* Constructor
*
* Currently does nothing
*
*
* @return void
*/
function Auth_Container_Pear()
{
 
}
 
// }}}
// {{{ fetchData()
 
/**
* Get user information from pear.php.net
*
80,24 → 81,35
*/
function fetchData($username, $password)
{
$rpc = new XML_RPC_Client('/xmlrpc.php', 'pear.php.net');
$rpc_message = new XML_RPC_Message("user.info", array(new XML_RPC_Value($username, "string")) );
// Error Checking howto ???
$result = $rpc->send($rpc_message);
$value = $result->value();
$userinfo = xml_rpc_decode($value);
if ($userinfo['password'] == md5($password)) {
$this->activeUser = $userinfo['handle'];
foreach ($userinfo as $uk=>$uv) {
$this->_auth_obj->setAuthData($uk, $uv);
}
return true;
$this->log('Auth_Container_PEAR::fetchData() called.', AUTH_LOG_DEBUG);
 
$client = new HTTP_Client;
 
$this->log('Auth_Container_PEAR::fetchData() getting salt.', AUTH_LOG_DEBUG);
$code = $client->get('https://pear.php.net/rest-login.php/getsalt');
if ($code != 200) {
return PEAR::raiseError('Bad response to salt request.', $code);
}
return false;
$resp = $client->currentResponse();
$salt = $resp['body'];
 
$this->log('Auth_Container_PEAR::fetchData() calling validate.', AUTH_LOG_DEBUG);
$code = $client->post('https://pear.php.net/rest-login.php/validate',
array('username' => $username,
'password' => md5($salt.md5($password))));
if ($code != 200) {
return PEAR::raiseError('Bad response to validate request.', $code);
}
$resp = $client->currentResponse();
 
list($code, $message) = explode(' ', $resp['body'], 1);
if ($code != 8) {
return PEAR::raiseError($message, $code);
}
return true;
}
 
// }}}
 
}
?>
/trunk/api/pear/Auth/Container/RADIUS.php
14,11 → 14,11
*
* @category Authentication
* @package Auth
* @author Michael Bretterklieber <michael@bretterklieber.com>
* @author Michael Bretterklieber <michael@bretterklieber.com>
* @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: RADIUS.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: RADIUS.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.2.0
*/
41,7 → 41,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.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.2.0
*/
55,12 → 55,12
* @var object
*/
var $radius;
 
/**
* Contains the authentication type
* @var string
*/
var $authtype;
var $authtype;
 
// }}}
// {{{ Auth_Container_RADIUS() [constructor]
89,7 → 89,7
PEAR::raiseError("Unknown Authtype, please use one of: "
."PAP, CHAP_MD5, MSCHAPv1, MSCHAPv2!", 41, PEAR_ERROR_DIE);
}
 
$this->radius = new $classname;
 
if (isset($options['configfile'])) {
107,7 → 107,7
$this->radius->addServer($servername, $port, $sharedsecret, $timeout, $maxtries);
}
}
 
if (!$this->radius->start()) {
PEAR::raiseError($this->radius->getError(), 41, PEAR_ERROR_DIE);
}
125,38 → 125,40
*/
function fetchData($username, $password, $challenge = null)
{
$this->log('Auth_Container_RADIUS::fetchData() called.', AUTH_LOG_DEBUG);
 
switch($this->authtype) {
case 'CHAP_MD5':
case 'MSCHAPv1':
if (isset($challenge)) {
$this->radius->challenge = $challenge;
$this->radius->chapid = 1;
$this->radius->response = pack('H*', $password);
} else {
case 'CHAP_MD5':
case 'MSCHAPv1':
if (isset($challenge)) {
$this->radius->challenge = $challenge;
$this->radius->chapid = 1;
$this->radius->response = pack('H*', $password);
} else {
require_once 'Crypt/CHAP.php';
$classname = 'Crypt_' . $this->authtype;
$crpt = new $classname;
$crpt->password = $password;
$this->radius->challenge = $crpt->challenge;
$this->radius->chapid = $crpt->chapid;
$this->radius->response = $crpt->challengeResponse();
}
break;
 
case 'MSCHAPv2':
require_once 'Crypt/CHAP.php';
$classname = 'Crypt_' . $this->authtype;
$crpt = new $classname;
$crpt = new Crypt_MSCHAPv2;
$crpt->username = $username;
$crpt->password = $password;
$this->radius->challenge = $crpt->challenge;
$this->radius->chapid = $crpt->chapid;
$this->radius->response = $crpt->challengeResponse();
$this->radius->challenge = $crpt->authChallenge;
$this->radius->peerChallenge = $crpt->peerChallenge;
$this->radius->chapid = $crpt->chapid;
$this->radius->response = $crpt->challengeResponse();
break;
}
 
case 'MSCHAPv2':
require_once 'Crypt/CHAP.php';
$crpt = new Crypt_MSCHAPv2;
$crpt->username = $username;
$crpt->password = $password;
$this->radius->challenge = $crpt->authChallenge;
$this->radius->peerChallenge = $crpt->peerChallenge;
$this->radius->chapid = $crpt->chapid;
$this->radius->response = $crpt->challengeResponse();
break;
 
default:
$this->radius->password = $password;
break;
default:
$this->radius->password = $password;
break;
}
 
$this->radius->username = $username;
/trunk/api/pear/Auth/Container/Multiple.php
New file
0,0 → 1,188
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
 
/**
* Storage driver for using multiple storage drivers in a fall through fashion
*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category Authentication
* @package Auth
* @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: Multiple.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $
* @since File available since Release 1.5.0
*/
 
/**
* Include Auth_Container base class
*/
require_once "Auth/Container.php";
/**
* Include PEAR package for error handling
*/
require_once "PEAR.php";
 
/**
* Storage driver for using multiple storage drivers in a fall through fashion
*
* This storage driver provides a mechanism for working through multiple
* storage drivers until either one allows successful login or the list is
* exhausted.
*
* This container takes an array of options of the following form:
*
* array(
* array(
* 'type' => <standard container type name>,
* 'options' => <normal array of options for container>,
* ),
* );
*
* Full example:
*
* $options = array(
* array(
* 'type' => 'DB',
* 'options' => array(
* 'dsn' => "mysql://user:password@localhost/database",
* ),
* ),
* array(
* 'type' => 'Array',
* 'options' => array(
* 'cryptType' => 'md5',
* 'users' => array(
* 'admin' => md5('password'),
* ),
* ),
* ),
* );
*
* $auth = new Auth('Multiple', $options);
*
* @category Authentication
* @package Auth
* @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.5.4 File: $Revision: 1.2 $
* @since File available since Release 1.5.0
*/
 
class Auth_Container_Multiple extends Auth_Container {
 
// {{{ properties
 
/**
* The options for each container
*
* @var array $options
*/
var $options = array();
 
/**
* The instanciated containers
*
* @var array $containers
*/
var $containers = array();
 
// }}}
// {{{ Auth_Container_Multiple()
 
/**
* Constructor for Array Container
*
* @param array $data Options for the container
* @return void
*/
function Auth_Container_Multiple($options)
{
if (!is_array($options)) {
PEAR::raiseError('The options for Auth_Container_Multiple must be an array');
}
if (count($options) < 1) {
PEAR::raiseError('You must define at least one sub container to use in Auth_Container_Multiple');
}
foreach ($options as $option) {
if (!isset($option['type'])) {
PEAR::raiseError('No type defined for sub container');
}
}
$this->options = $options;
}
 
// }}}
// {{{ fetchData()
 
/**
* Get user information from array
*
* This function uses the given username to fetch the corresponding
* login data from the array. If an account that matches the passed
* username and password is found, the function returns true.
* Otherwise it returns false.
*
* @param string Username
* @param string Password
* @return boolean|PEAR_Error Error object or boolean
*/
function fetchData($user, $pass)
{
$this->log('Auth_Container_Multiple::fetchData() called.', AUTH_LOG_DEBUG);
 
foreach ($this->options as $key => $options) {
 
$this->log('Using Container '.$key.' of type '.$options['type'].'.', AUTH_LOG_DEBUG);
 
if (isset($this->containers[$key]) && is_a($this->containers[$key], 'Auth_Container')) {
 
$container = &$this->containers[$key];
 
} else {
 
$this->containers[$key] = &$this->_auth_obj->_factory($options['type'], $options['options']);
$this->containers[$key]->_auth_obj = &$this->_auth_obj;
$container = &$this->containers[$key];
 
}
 
$result = $container->fetchData($user, $pass);
 
if (PEAR::isError($result)) {
 
$this->log('Container '.$key.': '.$result->getMessage(), AUTH_LOG_ERR);
return $result;
 
} elseif ($result == true) {
 
$this->log('Container '.$key.': Authentication successful.', AUTH_LOG_DEBUG);
return true;
 
} else {
 
$this->log('Container '.$key.': Authentication failed.', AUTH_LOG_DEBUG);
 
}
 
}
 
$this->log('Auth_Container_Multiple: All containers rejected user credentials.', AUTH_LOG_DEBUG);
 
return false;
 
}
 
// }}}
 
}
 
?>
/trunk/api/pear/Auth/Container/KADM5.php
18,7 → 18,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 CVS: $Id: KADM5.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: KADM5.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.4.0
*/
48,7 → 48,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.4.0
*/
82,9 → 82,9
if (!extension_loaded('kadm5')) {
return PEAR::raiseError("Cannot use Kerberos V authentication, KADM5 extension not loaded!", 41, PEAR_ERROR_DIE);
}
 
$this->_setDefaults();
 
if (isset($options['hostname'])) {
$this->options['hostname'] = $options['hostname'];
}
97,7 → 97,7
if (isset($options['checkServer'])) {
$this->options['checkServer'] = $options['checkServer'];
}
 
if ($this->options['checkServer']) {
$this->_checkServer();
}
105,7 → 105,7
 
// }}}
// {{{ fetchData()
 
/**
* Try to login to the KADM5 server
*
114,14 → 114,15
* @return boolean
*/
function fetchData($username, $password) {
$this->log('Auth_Container_KADM5::fetchData() called.', AUTH_LOG_DEBUG);
if ( ($username == NULL) || ($password == NULL) ) {
return false;
}
 
$server = $this->options['hostname'];
$realm = $this->options['realm'];
$check = @kadm5_init_with_password($server, $realm, $username, $password);
 
if ($check == false) {
return false;
} else {
128,10 → 129,10
return true;
}
}
 
// }}}
// {{{ _setDefaults()
 
/**
* Set some default options
*
143,10 → 144,10
$this->options['timeout'] = 10;
$this->options['checkServer'] = false;
}
 
// }}}
// {{{ _checkServer()
 
/**
* Check if the given server and port are reachable
*
162,7 → 163,7
return PEAR::raiseError($message, 41, PEAR_ERROR_DIE);
}
}
 
// }}}
 
}
/trunk/api/pear/Auth/Container/MDB.php
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: MDB.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: MDB.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.2.3
*/
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.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.2.3
*/
109,6 → 109,7
*/
function _connect($dsn)
{
$this->log('Auth_Container_MDB::_connect() called.', AUTH_LOG_DEBUG);
if (is_string($dsn) || is_array($dsn)) {
$this->db =& MDB::connect($dsn, $this->options['db_options']);
} elseif (is_subclass_of($dsn, 'mdb_common')) {
179,6 → 180,7
*/
function query($query)
{
$this->log('Auth_Container_MDB::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_MDB::fetchData() called.', AUTH_LOG_DEBUG);
// Prepare for a database query
$err = $this->_prepare();
if ($err !== true) {
309,6 → 313,14
$this->db->getTextValue($username)
);
 
// 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 MDB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->db->getRow($query, null, null, null, MDB_FETCHMODE_ASSOC);
 
if (MDB::isError($res) || PEAR::isError($res)) {
322,7 → 334,7
// Perform trimming here before the hashing
$password = trim($password, "\r\n");
$res[$this->options['passwordcol']] = trim($res[$this->options['passwordcol']], "\r\n");
 
// If using Challenge Response md5 the pass with the secret
if ($isChallengeResponse) {
$res[$this->options['passwordcol']] =
332,7 → 344,7
$res[$this->options['passwordcol']] = md5($res[$this->options['passwordcol']]);
}
}
 
if ($this->verifyPassword($password,
$res[$this->options['passwordcol']],
$this->options['cryptType'])) {
342,6 → 354,8
$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
365,6 → 379,7
*/
function listUsers()
{
$this->log('Auth_Container_MDB::listUsers() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
379,7 → 394,7
} else {
$sql_from = $this->options['final_usernamecol']
.', '.$this->options['final_passwordcol'];
 
if (strlen($fields = $this->_quoteDBFields()) > 0) {
$sql_from .= ', '.$fields;
}
390,6 → 405,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 MDB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->db->getAll($query, null, null, null, MDB_FETCHMODE_ASSOC);
 
if (MDB::isError($res)) {
400,6 → 423,7
$retVal[] = $user;
}
}
$this->log('Found '.count($retVal).' users.', AUTH_LOG_DEBUG);
return $retVal;
}
 
418,6 → 442,7
*/
function addUser($username, $password, $additional = "")
{
$this->log('Auth_Container_MDB::addUser() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
457,6 → 482,8
$additional_value
);
 
$this->log('Running SQL against MDB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->query($query);
 
if (MDB::isError($res)) {
478,6 → 505,7
*/
function removeUser($username)
{
$this->log('Auth_Container_MDB::removeUser() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
489,6 → 517,14
$this->db->getTextValue($username)
);
 
// 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 MDB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->query($query);
 
if (MDB::isError($res)) {
508,6 → 544,7
*/
function changePassword($username, $password)
{
$this->log('Auth_Container_MDB::changePassword() called.', AUTH_LOG_DEBUG);
$err = $this->_prepare();
if ($err !== true) {
return PEAR::raiseError($err->getMessage(), $err->getCode());
531,6 → 568,14
$this->db->getTextValue($username)
);
 
// 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 MDB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->query($query);
 
if (MDB::isError($res)) {
/trunk/api/pear/Auth/Container/SOAP.php
14,11 → 14,11
*
* @category Authentication
* @package Auth
* @author Bruno Pedro <bpedro@co.sapo.pt>
* @author Bruno Pedro <bpedro@co.sapo.pt>
* @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: SOAP.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: SOAP.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.2.0
*/
83,7 → 83,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.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.2.0
*/
170,6 → 170,7
*/
function fetchData($username, $password)
{
$this->log('Auth_Container_SOAP::fetchData() called.', AUTH_LOG_DEBUG);
// check if all required options are set
if (array_intersect($this->_requiredOptions, array_keys($this->_options)) != $this->_requiredOptions) {
return false;
/trunk/api/pear/Auth/Container/SMBPasswd.php
14,11 → 14,11
*
* @category Authentication
* @package Auth
* @author Michael Bretterklieber <michael@bretterklieber.com>
* @author Michael Bretterklieber <michael@bretterklieber.com>
* @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: SMBPasswd.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: SMBPasswd.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @since File available since Release 1.2.3
*/
56,7 → 56,7
* @package Auth
* @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.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
* @since Class available since Release 1.2.3
*/
104,14 → 104,16
*/
function fetchData($username, $password)
{
$this->log('Auth_Container_SMBPasswd::fetchData() called.', AUTH_LOG_DEBUG);
return $this->pwfile->verifyAccount($username, $password);
}
 
// }}}
// {{{ listUsers()
 
function listUsers()
{
$this->log('Auth_Container_SMBPasswd::fetchData() called.', AUTH_LOG_DEBUG);
return $this->pwfile->getAccounts();
}
 
129,6 → 131,7
*/
function addUser($username, $password, $additional = '')
{
$this->log('Auth_Container_SMBPasswd::addUser() called.', AUTH_LOG_DEBUG);
$res = $this->pwfile->addUser($user, $additional['userid'], $pass);
if ($res === true) {
return $this->pwfile->save();
146,6 → 149,7
*/
function removeUser($username)
{
$this->log('Auth_Container_SMBPasswd::removeUser() called.', AUTH_LOG_DEBUG);
$res = $this->pwfile->delUser($username);
if ($res === true) {
return $this->pwfile->save();
160,15 → 164,16
* Change password for user in the storage container
*
* @param string Username
* @param string The new password
* @param string The new password
*/
function changePassword($username, $password)
{
$res = $this->pwfile->modUser($username, '', $password);
if ($res === true) {
return $this->pwfile->save();
}
return $res;
$this->log('Auth_Container_SMBPasswd::changePassword() called.', AUTH_LOG_DEBUG);
$res = $this->pwfile->modUser($username, '', $password);
if ($res === true) {
return $this->pwfile->save();
}
return $res;
}
 
// }}}
/trunk/api/pear/Auth/Container/DBLite.php
18,7 → 18,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 CVS: $Id: DBLite.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: DBLite.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
*/
45,7 → 45,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
*/
93,6 → 93,7
$this->options['db_fields'] = '';
$this->options['cryptType'] = 'md5';
$this->options['db_options'] = array();
$this->options['db_where'] = '';
$this->options['auto_quote'] = true;
 
if (is_array($dsn)) {
117,6 → 118,7
*/
function _connect(&$dsn)
{
$this->log('Auth_Container_DBLite::_connect() called.', AUTH_LOG_DEBUG);
if (is_string($dsn) || is_array($dsn)) {
$this->db =& DB::connect($dsn, $this->options['db_options']);
} elseif (is_subclass_of($dsn, "db_common")) {
218,7 → 220,7
 
return '';
}
 
// }}}
// {{{ fetchData()
 
237,6 → 239,7
*/
function fetchData($username, $password)
{
$this->log('Auth_Container_DBLite::fetchData() called.', AUTH_LOG_DEBUG);
// Prepare for a database query
$err = $this->_prepare();
if ($err !== true) {
255,10 → 258,19
$sql_from .= ', '.$fields;
}
}
 
$query = "SELECT ".$sql_from.
" FROM ".$this->options['final_table'].
" WHERE ".$this->options['final_usernamecol']." = ".$this->db->quoteSmart($username);
 
// 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 DB: '.$query, AUTH_LOG_DEBUG);
 
$res = $this->db->getRow($query, null, DB_FETCHMODE_ASSOC);
 
if (DB::isError($res)) {
277,6 → 289,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 sence
if (is_object($this->_auth_obj)) {
/trunk/api/pear/Auth/Auth.php
17,7 → 17,7
* @author Martin Jansen <mj@php.net>
* @copyright 2001-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: Auth.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: Auth.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
* @deprecated File deprecated since Release 1.2.0
*/
/trunk/api/pear/Auth/Container.php
18,7 → 18,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 CVS: $Id: Container.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: Container.php,v 1.3 2007-11-19 15:11:00 jp_milcent Exp $
* @link http://pear.php.net/package/Auth
*/
 
31,7 → 31,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.2 $
* @version Release: 1.5.4 File: $Revision: 1.3 $
* @link http://pear.php.net/package/Auth
*/
class Auth_Container
46,6 → 46,13
*/
var $activeUser = "";
 
/**
* The Auth object this container is attached to.
*
* @access public
*/
var $_auth_obj = null;
 
// }}}
// {{{ Auth_Container() [constructor]
 
72,6 → 79,7
*/
function fetchData($username, $password, $isChallengeResponse=false)
{
$this->log('Auth_Container::fetchData() called.', AUTH_LOG_DEBUG);
}
 
// }}}
90,6 → 98,7
*/
function verifyPassword($password1, $password2, $cryptType = "md5")
{
$this->log('Auth_Container::verifyPassword() called.', AUTH_LOG_DEBUG);
switch ($cryptType) {
case "crypt" :
return ((string)crypt($password1, $password2) === (string)$password2);
104,7 → 113,7
default :
if (function_exists($cryptType)) {
return ((string)$cryptType($password1) === (string)$password2);
} elseif (method_exists($this,$cryptType)) {
} elseif (method_exists($this,$cryptType)) {
return ((string)$this->$cryptType($password1) === (string)$password2);
} else {
return false;
115,9 → 124,9
 
// }}}
// {{{ supportsChallengeResponse()
 
/**
* Returns true if the container supports Challenge Response
* Returns true if the container supports Challenge Response
* password authentication
*/
function supportsChallengeResponse()
127,7 → 136,7
 
// }}}
// {{{ getCryptType()
 
/**
* Returns the crypt current crypt type of the container
*
146,6 → 155,7
*/
function listUsers()
{
$this->log('Auth_Container::listUsers() called.', AUTH_LOG_DEBUG);
return AUTH_METHOD_NOT_SUPPORTED;
}
 
161,6 → 171,7
*/
function getUser($username)
{
$this->log('Auth_Container::getUser() called.', AUTH_LOG_DEBUG);
$users = $this->listUsers();
if ($users === AUTH_METHOD_NOT_SUPPORTED) {
return AUTH_METHOD_NOT_SUPPORTED;
187,6 → 198,7
*/
function addUser($username, $password, $additional=null)
{
$this->log('Auth_Container::addUser() called.', AUTH_LOG_DEBUG);
return AUTH_METHOD_NOT_SUPPORTED;
}
 
200,6 → 212,7
*/
function removeUser($username)
{
$this->log('Auth_Container::removeUser() called.', AUTH_LOG_DEBUG);
return AUTH_METHOD_NOT_SUPPORTED;
}
 
214,11 → 227,36
*/
function changePassword($username, $password)
{
$this->log('Auth_Container::changePassword() called.', AUTH_LOG_DEBUG);
return AUTH_METHOD_NOT_SUPPORTED;
}
 
// }}}
// {{{ log()
 
/**
* Log a message to the Auth log
*
* @param string The message
* @param int
* @return boolean
*/
function log($message, $level = AUTH_LOG_DEBUG) {
 
if (is_null($this->_auth_obj)) {
 
return false;
 
} else {
 
return $this->_auth_obj->log($message, $level);
 
}
 
}
 
// }}}
 
}
 
?>
/trunk/api/pear/Auth/Controller.php
18,14 → 18,14
* @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: Controller.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
* @version CVS: $Id: Controller.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
*/
 
/**
* Controlls access to a group of php access
* and redirects to a predefined login page as
* Controlls access to a group of php access
* and redirects to a predefined login page as
* needed
*
* In all pages
46,7 → 46,7
* $authController->start();
* if( $authController->isAuthorised() ){
* $authController->redirectBack();
* }
* }
* </code>
*
* @category Authentication
54,7 → 54,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
*/
63,29 → 63,29
 
// {{{ properties
 
/**
/**
* The Auth instance this controller is managing
*
* @var object Auth
*/
var $auth = null;
 
/**
* The login URL
* @var string
* */
var $login = null;
 
/**
* The default index page to use when the caller page is not set
*
* @var string
* @var string
*/
var $default = null;
/**
* If this is set to true after a succesfull login the
* Auth_Controller::redirectBack() is invoked automatically
 
/**
* If this is set to true after a succesfull login the
* Auth_Controller::redirectBack() is invoked automatically
*
* @var boolean
*/
93,7 → 93,7
 
// }}}
// {{{ Auth_Controller() [constructor]
 
/**
* Constructor
*
121,10 → 121,10
 
// }}}
// {{{ setAutoRedirectBack()
/**
 
/**
* Enables auto redirection when login is done
*
*
* @param bool Sets the autoRedirectBack flag to this
* @see Auth_Controller::autoRedirectBack
* @return void
136,7 → 136,7
 
// }}}
// {{{ redirectBack()
 
/**
* Redirects Back to the calling page
*
146,12 → 146,12
{
// If redirectback go there
// else go to the default page
 
$returnUrl = $this->auth->getAuthData('returnUrl');
if(!$returnUrl) {
$returnUrl = $this->_defaultPage;
}
 
// Add some entropy to the return to make it unique
// avoind problems with cached pages and proxies
if(strpos($returnUrl, '?') === false) {
162,7 → 162,7
// Track the auth status
if($this->auth->status != '') {
$url .= '&authstatus='.$this->auth->status;
}
}
header('Location:'.$returnUrl);
print("You could not be redirected to <a href=\"$returnUrl\">$returnUrl</a>");
}
169,10 → 169,10
 
// }}}
// {{{ redirectLogin()
 
/**
* Redirects to the login Page if not authorised
*
*
* put return page on the query or in auth
*
* @return void
180,10 → 180,10
function redirectLogin()
{
// Go to the login Page
 
// For Auth, put some check to avoid infinite redirects, this should at least exclude
// the login page
 
$url = $this->_loginPage;
if(strpos($url, '?') === false) {
$url .= '?';
204,7 → 204,7
 
// }}}
// {{{ start()
 
/**
* Starts the Auth Procedure
*
226,18 → 226,18
$this->auth->start();
// Logged on and on login page
if(strstr($_SERVER['PHP_SELF'], $this->_loginPage) && $this->auth->checkAuth()){
$this->autoRedirectBack ?
$this->autoRedirectBack ?
$this->redirectBack() :
null ;
}
}
 
 
}
 
// }}}
// {{{ isAuthorised()
 
/**
* Checks is the user is logged on
* @see Auth::checkAuth()