diff --git a/phpgwapi/inc/functions.inc.php b/phpgwapi/inc/functions.inc.php
index 92085806e6..1e042284cf 100644
--- a/phpgwapi/inc/functions.inc.php
+++ b/phpgwapi/inc/functions.inc.php
@@ -1,167 +1,170 @@
';
- echo 'Please contact your System Administrator';
- exit;
-}
+ if (!function_exists('version_compare'))//version_compare() is only available in PHP4.1+
+ {
+ echo 'eGroupWare requires PHP 4.1 or greater.
';
+ echo 'Please contact your System Administrator';
+ exit;
+ }
-if (!defined('EGW_API_INC')) define('EGW_API_INC',PHPGW_API_INC); // this is to support the header upgrade
+ if (!defined('EGW_API_INC')) define('EGW_API_INC',PHPGW_API_INC); // this is to support the header upgrade
-/* Make sure the header.inc.php is current. */
-if (!isset($GLOBALS['egw_domain']) || $GLOBALS['egw_info']['server']['versions']['header'] < $GLOBALS['egw_info']['server']['versions']['current_header'])
-{
- echo '
!!! YOU DO NOT HAVE YOUR \$GLOBALS['egw_info']['flags']['currentapp'] SET !!!
\n";
- echo '!!! PLEASE CORRECT THIS SITUATION !!!
!!! YOU DO NOT HAVE YOUR \$GLOBALS['egw_info']['flags']['currentapp'] SET !!!
\n";
+ echo '!!! PLEASE CORRECT THIS SITUATION !!!
about to include $file
\n"; - include_once($file); + // marking the context as restored from the session, used by session->verify to not read the date from the db again + $GLOBALS['egw_info']['flags']['restored_from_session'] = true; + + // restoring the egw_info-array + $flags = $GLOBALS['egw_info']['flags']; + $GLOBALS['egw_info'] = $_SESSION['egw_info_cache']; + $GLOBALS['egw_info']['flags'] = $flags; + unset($flags); + + // including the necessary class-definitions + foreach($_SESSION['egw_included_files'] as $file) + { + //echo "about to include $file
\n"; + include_once($file); + } + $GLOBALS['egw'] = unserialize($_SESSION['egw_object_cache']); + + $GLOBALS['egw']->wakeup2(); // adapt the restored egw-object/enviroment to this request (eg. changed current app) + + //printf("egw-enviroment restored in %d ms
\n",1000*(perfgetmicrotime()-$GLOBALS['egw_info']['flags']['page_start_time'])); + + return; // exit this file, as the rest of the file creates a new egw-object and -enviroment } - $GLOBALS['egw'] = unserialize($_SESSION['egw_object_cache']); - - $GLOBALS['egw']->wakeup2(); // adapt the restored egw-object/enviroment to this request (eg. changed current app) - - //printf("egw-enviroment restored in %d ms
\n",1000*(perfgetmicrotime()-$GLOBALS['egw_info']['flags']['page_start_time'])); - - return; // exit this file, as the rest of the file creates a new egw-object and -enviroment + //echo "could not restore egw_info and the egw-object!!!
\n"; } - //echo "could not restore egw_info and the egw-object!!!
\n"; -} -include(EGW_API_INC.'/common_functions.inc.php'); + include(EGW_API_INC.'/common_functions.inc.php'); -print_debug('sane environment','messageonly','api'); + print_debug('sane environment','messageonly','api'); -/****************************************************************************\ -* Multi-Domain support * -\****************************************************************************/ + /****************************************************************************\ + * Multi-Domain support * + \****************************************************************************/ -if (!isset($GLOBALS['egw_info']['server']['default_domain']) || // allow to overwrite the default domain + if (!isset($GLOBALS['egw_info']['server']['default_domain']) || // allow to overwrite the default domain !isset($GLOBALS['egw_domain'][$GLOBALS['egw_info']['server']['default_domain']])) -{ - reset($GLOBALS['egw_domain']); - list($GLOBALS['egw_info']['server']['default_domain']) = each($GLOBALS['egw_domain']); -} -if (isset($_POST['login'])) // on login -{ - $GLOBALS['login'] = $_POST['login']; - if (strstr($GLOBALS['login'],'@') === False || count($GLOBALS['egw_domain']) == 1) { - $GLOBALS['login'] .= '@' . get_var('logindomain',array('POST'),$GLOBALS['egw_info']['server']['default_domain']); + reset($GLOBALS['egw_domain']); + list($GLOBALS['egw_info']['server']['default_domain']) = each($GLOBALS['egw_domain']); } - $parts = explode('@',$GLOBALS['login']); - $GLOBALS['egw_info']['user']['domain'] = array_pop($parts); -} -else // on "normal" pageview -{ - $GLOBALS['egw_info']['user']['domain'] = $_REQUEST['domain']; -} - -if (@isset($GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']])) -{ - $GLOBALS['egw_info']['server']['db_host'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['db_host']; - $GLOBALS['egw_info']['server']['db_port'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['db_port']; - $GLOBALS['egw_info']['server']['db_name'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['db_name']; - $GLOBALS['egw_info']['server']['db_user'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['db_user']; - $GLOBALS['egw_info']['server']['db_pass'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['db_pass']; - $GLOBALS['egw_info']['server']['db_type'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['db_type']; -} -else -{ - $GLOBALS['egw_info']['server']['db_host'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['server']['default_domain']]['db_host']; - $GLOBALS['egw_info']['server']['db_port'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['server']['default_domain']]['db_port']; - $GLOBALS['egw_info']['server']['db_name'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['server']['default_domain']]['db_name']; - $GLOBALS['egw_info']['server']['db_user'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['server']['default_domain']]['db_user']; - $GLOBALS['egw_info']['server']['db_pass'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['server']['default_domain']]['db_pass']; - $GLOBALS['egw_info']['server']['db_type'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['server']['default_domain']]['db_type']; -} -print_debug('domain',@$GLOBALS['egw_info']['user']['domain'],'api'); - -// the egw-object instanciates all sub-classes (eg. $GLOBALS['egw']->db) and the egw_info array -$GLOBALS['egw'] =& CreateObject('phpgwapi.egw',array_keys($GLOBALS['egw_domain'])); - -if ($GLOBALS['egw_info']['flags']['currentapp'] != 'login') -{ - if (!$GLOBALS['egw_info']['server']['show_domain_selectbox']) + if (isset($_POST['login'])) // on login { - unset ($GLOBALS['egw_domain']); // we kill this for security reasons - } - //printf("egw-enviroment new created in %d ms
\n",1000*(perfgetmicrotime()-$GLOBALS['egw_info']['flags']['page_start_time'])); -} - -// saving the the egw_info array and the egw-object in the session -if (!defined('NO_RESTORE') && $GLOBALS['egw_info']['server']['sessions_type'] == 'php4' && $GLOBALS['egw_info']['flags']['currentapp'] != 'login') -{ - $_SESSION['egw_info_cache'] = $GLOBALS['egw_info']; - unset($_SESSION['egw_info_cache']['flags']); // dont save the flags, they change on each request - - // exclude 1: caller, 2: the header.inc.php, 3: phpgwapi/setup/setup.inc.php, 4: phpgwapi/inc/functions.inc.php (this file) - $_SESSION['egw_included_files'] = array(); - foreach(array_slice(get_included_files(),4) as $file) - { - if (!strstr($file,'phpgwapi')) continue; - - switch(basename($file)) + $GLOBALS['login'] = $_POST['login']; + if (strstr($GLOBALS['login'],'@') === False || count($GLOBALS['egw_domain']) == 1) { - case 'head.inc.php': // needs EGW_TEMPLATE_DIR and is included anyway by common::egw_header() - case 'functions.inc.php': // not needed/wanted at all - break; - default: - $_SESSION['egw_included_files'][] = $file; + $GLOBALS['login'] .= '@' . get_var('logindomain',array('POST'),$GLOBALS['egw_info']['server']['default_domain']); } + $parts = explode('@',$GLOBALS['login']); + $GLOBALS['egw_info']['user']['domain'] = array_pop($parts); + } + else // on "normal" pageview + { + $GLOBALS['egw_info']['user']['domain'] = $_REQUEST['domain']; + } + + if (@isset($GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']])) + { + $GLOBALS['egw_info']['server']['db_host'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['db_host']; + $GLOBALS['egw_info']['server']['db_port'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['db_port']; + $GLOBALS['egw_info']['server']['db_name'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['db_name']; + $GLOBALS['egw_info']['server']['db_user'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['db_user']; + $GLOBALS['egw_info']['server']['db_pass'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['db_pass']; + $GLOBALS['egw_info']['server']['db_type'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['user']['domain']]['db_type']; + } + else + { + $GLOBALS['egw_info']['server']['db_host'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['server']['default_domain']]['db_host']; + $GLOBALS['egw_info']['server']['db_port'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['server']['default_domain']]['db_port']; + $GLOBALS['egw_info']['server']['db_name'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['server']['default_domain']]['db_name']; + $GLOBALS['egw_info']['server']['db_user'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['server']['default_domain']]['db_user']; + $GLOBALS['egw_info']['server']['db_pass'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['server']['default_domain']]['db_pass']; + $GLOBALS['egw_info']['server']['db_type'] = $GLOBALS['egw_domain'][$GLOBALS['egw_info']['server']['default_domain']]['db_type']; + } + print_debug('domain',@$GLOBALS['egw_info']['user']['domain'],'api'); + + // the egw-object instanciates all sub-classes (eg. $GLOBALS['egw']->db) and the egw_info array + $GLOBALS['egw'] =& CreateObject('phpgwapi.egw',array_keys($GLOBALS['egw_domain'])); + + if ($GLOBALS['egw_info']['flags']['currentapp'] != 'login') + { + if (!$GLOBALS['egw_info']['server']['show_domain_selectbox']) + { + unset ($GLOBALS['egw_domain']); // we kill this for security reasons + } + //printf("egw-enviroment new created in %d ms
\n",1000*(perfgetmicrotime()-$GLOBALS['egw_info']['flags']['page_start_time'])); + } + + // saving the the egw_info array and the egw-object in the session + if (!defined('NO_RESTORE') && $GLOBALS['egw_info']['server']['sessions_type'] == 'php4' && $GLOBALS['egw_info']['flags']['currentapp'] != 'login') + { + $_SESSION['egw_info_cache'] = $GLOBALS['egw_info']; + unset($_SESSION['egw_info_cache']['flags']); // dont save the flags, they change on each request + + // exclude 1: caller, 2: the header.inc.php, 3: phpgwapi/setup/setup.inc.php, 4: phpgwapi/inc/functions.inc.php (this file) + $_SESSION['egw_included_files'] = array(); + foreach(array_slice(get_included_files(),4) as $file) + { + if (!strstr($file,'phpgwapi')) + { + continue; + } + + switch(basename($file)) + { + case 'head.inc.php': // needs EGW_TEMPLATE_DIR and is included anyway by common::egw_header() + case 'functions.inc.php': // not needed/wanted at all + break; + default: + $_SESSION['egw_included_files'][] = $file; + } + } + $_SESSION['egw_object_cache'] = serialize($GLOBALS['egw']); } - $_SESSION['egw_object_cache'] = serialize($GLOBALS['egw']); -}