$smarty->compile_dir = $config['smarty']['compile_dir']; $smarty->config_dir = $config['smarty']['config_dir']; $smarty->cache_dir = $config['smarty']['cache_dir']; //database connect $pdo_db = new PDO(sprintf('mysql:host=%s;dbname=%s;charset=utf8', $config['mysql']['host'], $config['mysql']['dbname']), $config['mysql']['user'], $config['mysql']['passwd']); $pdo_db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $pdo_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo_db->query("SET NAMES utf8"); $transaction_counter = 0; $nested_transaction_counter = 0; $total_time = 0; $total_queries = 0; set_exception_handler('oc_exception_handler'); //cookie check if (!is_logged() && !isset($_SESSION['user_pending']) && isset($_COOKIE['auth'])) { if ($user_id = check_auth_cookie()) { if (user_login('', '', $user_id, $_COOKIE['auth'])) { header("Location:" . $_SERVER['REQUEST_URI']); exit; } } } //debug mode if (is_admin() && isset($_GET['debug']) && ($debug = $_GET['debug'])) { if ($debug == 'on' && !isset($_SESSION['debug_mode'])) { $_SESSION['debug_mode'] = 1; } elseif ($debug == 'off' && $_SESSION['debug_mode']) { unset($_SESSION['debug_mode']); } header("Location:" . $_SERVER['HTTP_REFERER']); exit;
exit; } if (basename($_SERVER['PHP_SELF']) == 'logout.php') { return true; } if (read_config_option('auth_method') != 0) { /* handle alternate authentication realms */ api_plugin_hook_function('auth_alternate_realms'); /* handle change password dialog */ if (isset($_SESSION['sess_change_password']) && read_config_option('webbasic_enabled') != 'on') { header('Location: ' . $config['url_path'] . 'auth_changepassword.php?ref=' . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'index.php')); exit; } /* check for remember me function ality */ if (!isset($_SESSION['sess_user_id'])) { $cookie_user = check_auth_cookie(); if ($cookie_user !== false) { $_SESSION['sess_user_id'] = $cookie_user; } } /* don't even bother with the guest code if we're already logged in */ if (isset($guest_account) && empty($_SESSION['sess_user_id'])) { $guest_user_id = db_fetch_cell_prepared('SELECT id FROM user_auth WHERE username = ? AND realm = 0 AND enabled = "on"', array(read_config_option('guest_user'))); /* cannot find guest user */ if (!empty($guest_user_id)) { $_SESSION['sess_user_id'] = $guest_user_id; return true; } } /* if we are a guest user in a non-guest area, wipe credentials */ if (!empty($_SESSION['sess_user_id'])) {