From f970ef346f6eaafa60f13697f2f93406ab318958 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 14 Jul 2006 18:05:58 +0000 Subject: [PATCH] send the redirect to login,if the session can not be verified, via xajax --- xajax.php | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/xajax.php b/xajax.php index dc7d96fcac..6ecb949cf5 100644 --- a/xajax.php +++ b/xajax.php @@ -10,10 +10,25 @@ \**************************************************************************/ /* $Id$ */ - /* $Source$ */ require_once('./phpgwapi/inc/xajax.inc.php'); + /** + * callback if the session-check fails, redirects via xajax to login.php + * + * @param array &$anon_account anon account_info with keys 'login', 'passwd' and optional 'passwd_type' + * @return boolean/string true if we allow anon access and anon_account is set, a sessionid or false otherwise + */ + function xajax_redirect(&$anon_account) + { + $response =& new xajaxResponse(); + $response->addScript("location.href='".$GLOBALS['egw_info']['server']['webserver_url'].'/login.php?cd=10'."';"); + + header('Content-type: text/xml; charset='.$GLOBALS['egw']->translation->charset()); + echo $response->getXML(); + $GLOBALS['egw']->common->egw_exit(); + } + function doXMLHTTP() { $numargs = func_num_args(); @@ -28,26 +43,26 @@ if(substr($className,0,4) != 'ajax' && $arg0 != 'etemplate.etemplate.process_exec' && substr($functionName,0,4) != 'ajax') { // stopped for security reasons - error_log($_SERVER["PHP_SELF"]. ' stopped for security reason. className '.$className.' is not valid. className must start with ajax!!!'); + error_log($_SERVER['PHP_SELF']. ' stopped for security reason. '.$arg0.' is not valid. class- or function-name must start with ajax!!!'); exit; } - $GLOBALS['egw_info'] = array(); - $GLOBALS['egw_info']['flags'] = array( - 'currentapp' => $appName, - 'noheader' => True, - 'disable_Template_class' => True, + $GLOBALS['egw_info'] = array( + 'flags' => array( + 'currentapp' => $appName, + 'noheader' => True, + 'disable_Template_class' => True, + 'autocreate_session_callback' => 'xajax_redirect', + ) ); - include('./header.inc.php'); - - $ajaxClass = CreateObject("$appName.$className"); + + $ajaxClass =& CreateObject($appName.'.'.$className); $argList = $GLOBALS['egw']->translation->convert($argList, 'utf-8'); - return call_user_func_array(array(&$ajaxClass, $functionName), $argList ); - + + return call_user_func_array(array(&$ajaxClass, $functionName), $argList ); } - $xajax = new xajax($_SERVER["PHP_SELF"]); - $xajax->registerFunction("doXMLHTTP"); + $xajax = new xajax($_SERVER['PHP_SELF']); + $xajax->registerFunction('doXMLHTTP'); $xajax->processRequests(); -?>