function &default_context($make_session) { /* Argument is a boolean value that tells the function whether to make a session or not. */ $db =& get_db_connection(); /* change character set to utf8 */ $db->query("SET NAMES utf8mb4"); //$db->query("SET CHARACTER SET 'utf8'"); $user = null; $type = get_preferred_type($_GET['type'] ? $_GET['type'] : $_SERVER['HTTP_ACCEPT']); if ($type == 'text/html' && $make_session) { // get the session user if there is one session_set_cookie_params(86400 * 31, get_base_dir(), null, false, true); session_start(); $user = cookied_user($db); } // Smarty is created last because it needs $_SESSION populated $sm =& get_smarty_instance($user); $ctx = new Context($db, $sm, $user, $type); return $ctx; }
function enforce_master_on_off_switch($language = 'en') { if (defined('MASTER_ON_OFF_SWITCH') and MASTER_ON_OFF_SWITCH) { return; } $sm = get_smarty_instance(); $sm->assign('language', $language); header('Retry-After: 300'); // let's just say five minutes die_with_code(503, $sm->fetch("unavailable.html.tpl")); }
<?php ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '../lib'); require_once 'init.php'; require_once 'data.php'; require_once 'output.php'; list($response_format, $response_mime_type) = parse_format($_GET['format'], 'html'); $dbh =& get_db_connection(); if (get_request_user()) { // auth stuff here } $dbh = null; $sm = get_smarty_instance(); if (get_request_user()) { // secure template vars here } header("Content-Type: {$response_mime_type}; charset=UTF-8"); print $sm->fetch("index.{$response_format}.tpl");