CheckCustom(); } # Set our timezone, if it is specified in config.php if ($_SESSION[APPCONFIG]->GetValue('appearance','timezone')) date_default_timezone_set($_SESSION[APPCONFIG]->GetValue('appearance','timezone')); # If we are here, $_SESSION is set - so enabled DEBUGing if it has been configured. if (($_SESSION[APPCONFIG]->GetValue('debug','syslog') || $_SESSION[APPCONFIG]->GetValue('debug','file')) && $_SESSION[APPCONFIG]->GetValue('debug','level')) define('DEBUG_ENABLED',1); else define('DEBUG_ENABLED',0); if (DEBUG_ENABLED) debug_log('Application (%s) initialised and starting with (%s).',1,__FILE__,__LINE__,__METHOD__, pla_version(),$_REQUEST); # Set our PHP timelimit. if ($_SESSION[APPCONFIG]->GetValue('session','timelimit')) set_time_limit($_SESSION[APPCONFIG]->GetValue('session','timelimit')); # If debug mode is set, increase the time_limit, since we probably need it. if (DEBUG_ENABLED && $_SESSION[APPCONFIG]->GetValue('session','timelimit')) set_time_limit($_SESSION[APPCONFIG]->GetValue('session','timelimit') * 5); /** * Language configuration. Auto or specified? * Shall we attempt to auto-determine the language? */ $language = $_SESSION[APPCONFIG]->GetValue('appearance','language'); if ($language == 'auto') { # Make sure their browser correctly reports language. If not, skip this. if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { # Get the languages which are spetcified in the HTTP header $HTTP_LANGS = preg_split ('/[;,]+/',$_SERVER['HTTP_ACCEPT_LANGUAGE']); foreach ($HTTP_LANGS as $key => $value) { if (substr($value,0,2) == 'q=') { unset($HTTP_LANGS[$key]); continue; } $value = preg_split('/[-]+/',$value); if (sizeof($value) == 2) $HTTP_LANGS[$key] = strtolower($value[0]).'_'.strtoupper($value[1]); else $HTTP_LANGS[$key] = auto_lang(strtolower($value[0])); } $HTTP_LANGS = array_unique($HTTP_LANGS); foreach ($HTTP_LANGS as $HTTP_LANG) { $language_dir = LANGDIR.$HTTP_LANG; if ((substr($HTTP_LANG,0,2) == 'en') || (file_exists($language_dir) && is_readable($language_dir))) { # Set language putenv('LANG='.$HTTP_LANG); # e.g. LANG=de_DE $HTTP_LANG .= '.UTF-8'; setlocale(LC_ALL,$HTTP_LANG); # set LC_ALL to de_DE bindtextdomain('messages',LANGDIR); bind_textdomain_codeset('messages','UTF-8'); textdomain('messages'); header('Content-type: text/html; charset=UTF-8',true); break; } } #todo: Generate an error if language doesnt exist. } } else { # Grab the language file configured in config.php #todo: Generate an error if language doesnt exist. if ($language != null) { if (strcmp($language,'english') == 0) $language = 'en_GB'; # Set language putenv('LANG='.$language); # e.g. LANG=de_DE $language .= '.UTF-8'; setlocale(LC_ALL,$language); # set LC_ALL to de_DE bindtextdomain('messages',LANGDIR); bind_textdomain_codeset('messages','UTF-8'); textdomain('messages'); header('Content-type: text/html; charset=UTF-8',true); } } /** * Strip slashes from GET, POST, and COOKIE variables if this * PHP install is configured to automatically addslashes() */ if (get_magic_quotes_gpc() && (! isset($slashes_stripped) || ! $slashes_stripped)) { array_stripslashes($_REQUEST); array_stripslashes($_GET); array_stripslashes($_POST); array_stripslashes($_COOKIE); $slashes_stripped = true; } /** * Create our application repository variable. */ if (isset($_REQUEST['server_id'])) { $ldapserver = $_SESSION[APPCONFIG]->ldapservers->Instance($_REQUEST['server_id']); } else { if (isset($_SESSION[APPCONFIG]->ldapservers) && is_object($_SESSION[APPCONFIG]->ldapservers)) $ldapserver = $_SESSION[APPCONFIG]->ldapservers->Instance(null); } /** * Look/evaluate our timeout */ if (isset($ldapserver) && is_object($ldapserver) && method_exists($ldapserver,'haveAuthInfo')) { if ($ldapserver->haveAuthInfo() && isset($ldapserver->auth_type) && $ldapserver->auth_type != 'config') { /** * If time out value has been reached: * - log out user * - put $server_id in array of recently timed out servers */ if (function_exists('session_timed_out') && session_timed_out($ldapserver)) { $app['url_timeout'] = sprintf('cmd.php?cmd=timeout&server_id=%s',$_REQUEST['server_id']); printf('', htmlspecialchars($app['url_timeout'])); die(); } } # Update $_SESSION['activity'] for timeout and automatic logout feature if ($ldapserver->haveAuthInfo() && function_exists('set_lastactivity')) set_lastactivity($ldapserver); } /** * At this point we have read all our additional function PHP files and our configuration. * If we are using hooks, run the session_init hook. */ if (function_exists('run_hook')) run_hook('post_session_init',array()); ?>