cvs: pear /Auth/Auth Anonymous.php
| From: | Yavor Shahpasov | Date: | Thu, 08 Jul 2004 11:22:23 +0000 |
| Subject: | cvs: pear /Auth/Auth Anonymous.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-21640@lists.php.net to get a copy of this message | ||
yavo Thu Jul 8 07:22:23 2004 EDT
Added files:
/pear/Auth/Auth Anonymous.php
Log:
A class to allow anonymous authenthication
http://cvs.php.net/co.php/pear/Auth/Auth/Anonymous.php?r=1.1&p=1
Index: pear/Auth/Auth/Anonymous.php
+++ pear/Auth/Auth/Anonymous.php
<?php
include_once 'Auth.php';
/**
* This class provides anonymous authenthication
* if username and password were not supplied
*
*/
class Auth_Anonymous extends Auth {
var $allow_anonymous = true;
var $anonymous_username = 'anonymous';
/**
* Pass all parameters to Parent Auth class
*/
function Auth_Anonymous($storageDriver, $options = '', $loginFunction = '',
$showLogin = true) {
parent::Auth($storageDriver, $options, $loginFunction, $showLogin);
}
/**
* If no username & password is passed
* then login the user as anonymous
*/
function login() {
if ( $this->allow_anonymous && empty($this->username) &&
empty($this->password) ) {
$this->setAuth($this->anonymous_username);
if (is_callable($this->loginCallback)) {
call_user_func_array($this->loginCallback, array($this->username, &$this)
);
}
} else {
print "Real Login";
parent::login();
}
}
/**
* Force the user to login
*
*/
function forceLogin() {
$this->allow_anonymous = false;
if( !empty($this->session['username']) &&
$this->session['username'] == $this->anonymous_username ) {
$this->logout();
}
}
}
?>