<?php

$mtime = explode(' ', microtime());
$starttime = $mtime[1] + $mtime[0];

define('IN_TM', TRUE);
define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
include_once './include/common.inc.php';
include_once TM_ROOT.'./data/template.inc.php';
include_once TM_ROOT.'./data/seccode.inc.php';
define('_TPLPath_', _TPLPatha_.'/'._TPLPathb_.'/');
define("_TPLCachePath_",  'data/view/');
define('_TPLCacheLimit_', _TPLCacheLimitview_);
define("_FORMHASH_", formhash());
unset($GLOBALS, $_ENV, $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_SERVER_VARS, $HTTP_ENV_VARS);
if($SystemStatus){
	die("<script>alert('$SystemStat');window.close();</script>");
}
$_GET     = daddslashes($_GET, 1, TRUE);
$_POST    = daddslashes($_POST, 1, TRUE);
$_COOKIE  = daddslashes($_COOKIE, 1, TRUE);
$_SERVER  = daddslashes($_SERVER);
$_FILES   = daddslashes($_FILES);
$_REQUEST = daddslashes($_REQUEST, 1, TRUE);
$action = getgpc('action');
//查询导航
$menulist = $db->fetch_all("SELECT * FROM `{$tablepre}menu` ORDER BY `listid` DESC");
//查询幻灯广告
$adslist = $db->fetch_all("SELECT * FROM `{$tablepre}ads` ORDER BY `listid` ASC");
//单页列表
$aboutlist = $db->fetch_all("SELECT * FROM `{$tablepre}about`");
//新闻分类
$newsfl = $db->fetch_all("SELECT * FROM `{$tablepre}news_fl` ORDER BY `listid` DESC");
//商品分类
$shopfl = $db->fetch_all("SELECT * FROM `{$tablepre}shop_fl` ORDER BY `listid` DESC");
//友情连接
$link = $db->fetch_all("SELECT * FROM `{$tablepre}link`");
$act = @in_array($action, array(
'about',
'news', 
'shop', 
'job', 
'order', 
'guestbook', 
'upload')) ? $action : 'index';
include_once TM_ROOT.'./source/'.$act.'.php';

$mtime = explode(' ', microtime());
$endtime = $mtime[1] + $mtime[0];
echo '<script>document.getElementById(\'debug_time\').innerHTML = \''.'页面执行时间'.number_format($endtime - $starttime, 5).'毫秒'.'\'</script>'."\n";
function daddslashes($string, $force = 0, $strip = FALSE) {
	if(!MAGIC_QUOTES_GPC || $force) {
		if(is_array($string)) {
			foreach($string as $key => $val) {
				$string[$key] = daddslashes($val, $force, $strip);
			}
		} else {
			$string = addslashes($strip ? stripslashes($string) : $string);
		}
	}
	return $string;
}
function getgpc($k, $var='R') {
	switch($var) {
		case 'G': $var = &$_GET; break;
		case 'P': $var = &$_POST; break;
		case 'C': $var = &$_COOKIE; break;
		case 'R': $var = &$_REQUEST; break;
	}
	return isset($var[$k]) ? $var[$k] : NULL;
}
?>