1) $useragent_msie_version = $ua_matches[1]; else $useragent_msie_version = null; // yepp, we will use UTF-8 mb_internal_encoding('UTF-8'); mb_regex_encoding('UTF-8'); // if magic_quotes is enabled, fix it fix_magic_quotes_gpc(); // set options require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/config2/settings-dist.inc.php'); require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/config2/settings.inc.php'); require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/config2/verify-settings.inc.php'); foreach ($opt['page']['banned_user_agents'] as $ua) if (strpos($useragent, $ua) !== false) die(); set_domain(); if (!(isset($_REQUEST['sqldebug']) && $_REQUEST['sqldebug']=='1')) $opt['debug'] = $opt['debug'] & ~DEBUG_SQLDEBUGGER; if (($opt['debug'] & DEBUG_FORCE_TRANSLATE) != DEBUG_FORCE_TRANSLATE) { if (($opt['debug'] & DEBUG_TRANSLATE) == DEBUG_TRANSLATE && isset($_REQUEST['trans']) && $_REQUEST['trans']=='1') $opt['debug'] = $opt['debug'] | DEBUG_TEMPLATES; else $opt['debug'] = $opt['debug'] & ~DEBUG_TRANSLATE; } require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/errorhandler.inc.php'); configure_php(); normalize_settings(); set_language(); set_usercountry(); set_timezone(); // set stylepath and langpath if (isset($opt['template']['style'])) { if (strpos($opt['template']['style'], '.') !== false || strpos($opt['template']['style'], '/') !== false) $opt['template']['style'] = $opt['template']['default']['style']; if (!is_dir($opt['rootpath'] . 'templates2/' . $opt['template']['style'])) $opt['template']['style'] = $opt['template']['default']['style']; } else $opt['template']['style'] = $opt['template']['default']['style']; $opt['stylepath'] = $GLOBALS['container']->get('ocde.config')->getBaseDir() . '/templates2/' . $opt['template']['style'] . '/'; check_useragent(); /* setup smarty * */ require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/OcSmarty.class.php'); $tpl = new OcSmarty(); // include all we need require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/logic/const.inc.php'); require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/error.inc.php'); require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/util.inc.php'); require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/db.inc.php'); require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/menu.class.php'); require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/logic/labels.inc.php'); // apply post configuration if (function_exists('post_config')) post_config(); // check for email address problems // use direct database access instead of user class for performance reasons - need not // to include user.class.php in any script if (!isset($disable_verifyemail) && $GLOBALS['container']->get('ocde.login')->getUserId() > 0 && sql_value("SELECT `email_problems` FROM `user` WHERE `user_id`='&1'", 0, $GLOBALS['container']->get('ocde.login')->getUserId()) != 0) { header("Location: verifyemail.php?page=" . basename($_SERVER['REQUEST_URI'])); exit; } // normalize important settings function normalize_settings() { global $opt; $opt['charset']['iconv'] = strtoupper($opt['charset']['iconv']); if (substr($opt['page']['absolute_url'], -1, 1) != '/') $opt['page']['absolute_url'] .= '/'; if (substr($opt['logic']['pictures']['url'], -1, 1) != '/') $opt['logic']['pictures']['url'] .= '/'; if (substr($opt['logic']['pictures']['dir'], -1, 1) != '/') $opt['logic']['pictures']['dir'] .= '/'; if (substr($opt['logic']['podcasts']['url'], -1, 1) != '/') $opt['logic']['podcasts']['url'] .= '/'; if (substr($opt['logic']['podcasts']['dir'], -1, 1) != '/') $opt['logic']['podcasts']['dir'] .= '/'; } function configure_php() { global $opt; if ($opt['php']['debug'] == PHP_DEBUG_SKIP) { } if ($opt['php']['debug'] == PHP_DEBUG_ON) { ini_set('display_errors', true); ini_set('error_reporting', E_ALL); ini_set('mysql.trace_mode', true); // SQL_CALC_FOUND_ROWS will not work with trace_mode on! // Use the next two functions below as workaround. // not for production use yet (has to be tested thoroughly) register_errorhandlers(); } else { ini_set('display_errors', false); ini_set('error_reporting', E_ALL & ~E_NOTICE); ini_set('mysql.trace_mode', false); } } function sql_enable_foundrows() { ini_set('mysql.trace_mode', false); } function sql_foundrows_done() { global $opt; if ($opt['php']['debug'] == PHP_DEBUG_ON) ini_set('mysql.trace_mode', true); } function set_domain() { global $opt; $domain = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : ''; $opt['page']['domain'] = $domain; if (!isset($opt['domain']) || $domain == '') return; if (isset($opt['domain'][$domain])) { if (isset($opt['domain'][$domain]['url'])) $opt['page']['absolute_url'] = $opt['domain'][$domain]['url']; if (isset($opt['domain'][$domain]['locale'])) $opt['template']['default']['locale'] = $opt['domain'][$domain]['locale']; if (isset($opt['domain'][$domain]['country'])) $opt['template']['default']['country'] = $opt['domain'][$domain]['country']; if (isset($opt['domain'][$domain]['style'])) $opt['template']['default']['style'] = $opt['domain'][$domain]['style']; if (isset($opt['domain'][$domain]['cookiedomain'])) $opt['session']['domain'] = $opt['domain'][$domain]['cookiedomain']; } } function set_language() { global $opt; if (isset($_REQUEST['locale'])) $opt['template']['locale'] = strtoupper($_REQUEST['locale']); else $opt['template']['locale'] = strtoupper($GLOBALS['container']->get('ocde.cookie')->get('locale', $opt['template']['default']['locale'])); if (isset($opt['template']['locale']) && $opt['template']['locale'] != '') { if (strpos($opt['template']['locale'], '.') !== false || strpos($opt['template']['locale'], '/') !== false) $opt['template']['locale'] = $opt['template']['default']['locale']; if (!isset($opt['locale'][$opt['template']['locale']])) $opt['template']['locale'] = $opt['template']['default']['locale']; } else $opt['template']['locale'] = $opt['template']['default']['locale']; $GLOBALS['container']->get('ocde.cookie')->set('locale', $opt['template']['locale'], $opt['template']['default']['locale']); bindtextdomain('messages', $GLOBALS['container']->get('ocde.config')->getBaseDir() . '/cache2/translate'); // setup the PHP locale setlocale(LC_MONETARY, $opt['locale'][$opt['template']['locale']]['locales']); setlocale(LC_TIME, $opt['locale'][$opt['template']['locale']]['locales']); if (defined('LC_MESSAGES')) setlocale(LC_MESSAGES, $opt['locale'][$opt['template']['locale']]['locales']); // no localisation! setlocale(LC_COLLATE, $opt['locale']['EN']['locales']); setlocale(LC_CTYPE, $opt['locale']['EN']['locales']); setlocale(LC_NUMERIC, $opt['locale']['EN']['locales']); // important for mysql-queries! textdomain('messages'); } function set_usercountry() { if (isset($_REQUEST['usercountry'])) { $GLOBALS['container']->get('ocde.cookie')->set('usercountry', $_REQUEST['usercountry']); } } function set_timezone() { global $opt; date_default_timezone_set($opt['php']['timezone']); } function check_useragent() { global $_SERVER, $ocpropping; // are we Ocprop? $ocpropping = isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],"Ocprop/"); } function fix_magic_quotes_gpc() { // Disable magic_quotes_runtime @set_magic_quotes_runtime(0); if (get_magic_quotes_gpc()) { if (is_array($_GET)) { while (list($k, $v) = each($_GET)) { if (is_array($_GET[$k])) { while (list($k2, $v2) = each($_GET[$k])) { $_GET[$k][$k2] = stripslashes($v2); } @reset($_GET[$k]); } else { $_GET[$k] = stripslashes($v); } } @reset($_GET); } if (is_array($_POST)) { while (list($k, $v) = each($_POST)) { if (is_array($_POST[$k])) { while (list($k2, $v2) = each($_POST[$k])) { $_POST[$k][$k2] = stripslashes($v2); } @reset($_POST[$k]); } else { $_POST[$k] = stripslashes($v); } } @reset($_POST); } if (is_array($_REQUEST)) { while (list($k, $v) = each($_REQUEST)) { if (is_array($_REQUEST[$k])) { while (list($k2, $v2) = each($_REQUEST[$k])) { $_REQUEST[$k][$k2] = stripslashes($v2); } @reset($_REQUEST[$k]); } else { $_REQUEST[$k] = stripslashes($v); } } @reset($_REQUEST); } if (is_array($_COOKIE)) { while (list($k, $v) = each($_COOKIE)) { if (is_array($_COOKIE[$k])) { while (list($k2, $v2) = each($_COOKIE[$k])) { $_COOKIE[$k][$k2] = stripslashes($v2); } @reset($_COOKIE[$k]); } else { $_COOKIE[$k] = stripslashes($v); } } @reset($_COOKIE); } } } // external help embedding // pay attention to use only ' quotes in $text (escape other ') // // see corresponding function in lib/common.inc.php function helppagelink($ocpage, $title='Instructions') { global $opt, $translate; if ($translate === null) { require_once($GLOBALS['container']->get('ocde.config')->getBaseDir() . '/lib2/translate.inc.php'); $translate = createTranslate(); } $helppage = sql_value("SELECT `helppage` FROM `helppages` WHERE `ocpage`='&1' AND `language`='&2'", "", $ocpage, $opt['template']['locale']); if ($helppage == "") $helppage = sql_value("SELECT `helppage` FROM `helppages` WHERE `ocpage`='&1' AND `language`='*'", "", $ocpage); if ($helppage == "" && isset($opt['locale'][$opt['template']['locale']]['help'][$ocpage])) $helppage = $opt['locale'][$opt['template']['locale']]['help'][$ocpage]; $imgtitle = $translate->t($title, '', basename(__FILE__), __LINE__); $imgtitle = "alt='" . $imgtitle . "' title='" . $imgtitle . "'"; if (substr($helppage,0,1) == "!") return ""; else if ($helppage != "" && isset($opt['locale'][$opt['template']['locale']]['helpwiki'])) return ""; return ""; } // format number with 1000er dots function number1000($n) { global $opt; if (isset($opt['locale'][$opt['template']['locale']]['format']['dot1000']) && $opt['locale'][$opt['template']['locale']]['format']['dot1000'] == ',') return number_format($n); else return str_replace(',', '.', number_format($n)); }