<?php
error_reporting(0);

define('IN_HANFOX', true);

/** 设置默认编码 */
header('Content-type: text/html; charset=utf-8');

/** 设置时区 */
if (function_exists('date_default_timezone_set')) {
	date_default_timezone_set('PRC');
}

/** PHP错误日志 */
ini_set('error_log', ROOT_PATH.'data/log/debug.log');
ini_set('log_errors', '1');

/** SESSION */
@session_cache_limiter('private, must-revalidate');
@session_start();
@session_save_path(ROOT_PATH.'data/session');


/** 加载配置文件 */
if (file_exists(ROOT_PATH.'config.php')) {
	require(ROOT_PATH.'config.php');
} else {
	exit('config.php file is missing!');
}

require(APP_PATH.'include/mysql.php');
require(APP_PATH.'include/smarty.php');
require(APP_PATH.'include/cache.php');
require(APP_PATH.'include/function.php');
require(APP_PATH.'include/validate.php');
require(APP_PATH.'version.php');

/** 对传入的变量进行转义 */
if (phpversion() < '5.3.0') {
	set_magic_quotes_runtime(0);
	@ini_set('magic_quotes_sybase', 0);
}

if (get_magic_quotes_gpc()) {
	$_GET = stripslashes_deep($_GET);
	$_POST = stripslashes_deep($_POST);
	$_COOKIE = stripslashes_deep($_COOKIE);
} else {
	$_GET = add_magic_quotes($_GET);
	$_POST = add_magic_quotes($_POST);
	$_COOKIE = add_magic_quotes($_COOKIE);
	$_SERVER = add_magic_quotes($_SERVER);
	$_REQUEST = array_merge($_GET, $_POST);
}

/** 初始化数据库信息 */
$DB = new MySQL(DB_HOST, DB_USER, DB_PASS, DB_NAME, DB_CHARSET, TABLE_PREFIX, DB_PCONNECT);

/** 初始化变量 */
$php_self = htmlspecialchars($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']);
$base_name = basename($php_self);
$site_root = substr($php_self, 0, -strlen($base_name));
$site_url = htmlspecialchars('http://'.$_SERVER['HTTP_HOST'].preg_replace("/\/+(api)?\/*$/i", '', substr($php_self, 0, strrpos($php_self, '/'))).'/');
$timescope = array('0' => '所有时间内', '1' => '24小时内', '3' => '三天内', '7' => '一周内', '30' => '一月内', '365' => '一年内');

define('SITE_ROOT', $site_root);
define('SITE_URL', $site_url);
?>