fix bugs found in initial testing

git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@582 a1433add-5e2c-0410-b055-b7f2511e0802
postfixadmin-2.3
David Goodwin 16 years ago
parent 9ee45c69c8
commit 3ed6989c23

@ -27,28 +27,37 @@
* } * }
* *
* Note, the requirement that your XmlRpc client provides cookies with each request. * Note, the requirement that your XmlRpc client provides cookies with each request.
* If it does not do this, then your authentication details will not persist across requests. * If it does not do this, then your authentication details will not persist across requests, and
* this XMLRPC interface will not work.
*/ */
require_once(dirname(__FILE__) . '/common.php');
require_once('Zend/XmlRpc/Server.php'); require_once('Zend/XmlRpc/Server.php');
$server = new Zend_XmlRpc_Server(); $server = new Zend_XmlRpc_Server();
session_start(); session_start();
/**
* @param string $username
* @param string $password
* @return boolean true on success, else false.
*/
function login($username, $password) { function login($username, $password) {
if(UserHandler::login($username, $password)) { if(UserHandler::login($username, $password)) {
session_regenerate_id(); session_regenerate_id();
$_SESSION['authenticated'] = true; $_SESSION['authenticated'] = true;
$_SESSION['username'] = $username; $_SESSION['username'] = $username;
return true;
} }
return false;
} }
if(!isset($_SESSION['authenticated'])) { if(!isset($_SESSION['authenticated'])) {
$server->addFunction('login', 'login'); $server->addFunction('login', 'login');
} }
else { else {
$server->addClass('user', 'UserProxy'); $server->setClass('UserProxy', 'user');
$server->addClass('vacation', 'VacationProxy'); $server->setClass('VacationProxy', 'vacation');
$server->addClass('alias', 'AliasProxy'); $server->setClass('AliasProxy', 'alias');
} }
echo $server->handle(); echo $server->handle();

Loading…
Cancel
Save