<?php

//The directory in which your application specific resources are located.
//加载配置文件
require(TMAC_BASE_PATH . 'Tmac.config.php');

$TmacConfig['Common']['errorreport'] ? error_reporting(E_ALL) : error_reporting(0);

define('ROOTINC', WEB_ROOT . '/inc/');

function filter(&$array)
{
    if (is_array($array)) {
        foreach ($array as $key => $value) {
            is_array($value) ? filter($value) : $array[$key] = addslashes($value);
        }
    }
}

if (!get_magic_quotes_gpc()) {
    filter($_GET);
    filter($_POST);
    filter($_COOKIE);
    filter($_FILES);
}

date_default_timezone_set("PRC"); //设定为中华人民共和国 时间戳
//定义php通用属性
if (PHP_VERSION < '4.1.0') {
    $_GET = &$HTTP_GET_VARS;
    $_POST = &$HTTP_POST_VARS;
    $_COOKIE = &$HTTP_COOKIE_VARS;
    $_SERVER = &$HTTP_SERVER_VARS;
    $_ENV = &$HTTP_ENV_VARS;
    $_FILES = &$HTTP_POST_FILES;
}

//global防注入
if (isset($_REQUEST['GLOBALS']) OR isset($_FILES['GLOBALS'])) {
    exit('Request tainting attempted.');
}

require_once(ROOTINC . 'function.inc.php'); //包含通用函数库
//外部引入的(包括数据库或者文件)数据中关闭字符串自动转义
//不进行魔术过滤 php5.3废除了 set_magic_quotes_runtime(0);
ini_set("magic_quotes_runtime", 0);

require_once(ROOTINC . 'db.class.php'); //包含数据库操作类
require_once(ROOTINC . 'template.class.php');

$dbinfo = $db[$TmacConfig['Common']['Database']];
?>