<?php
error_reporting(0);
set_time_limit(1800);
header("Content-type: text/html;charset=utf8");
session_start();
setcookie(session_name(), session_id(), time() + 24*3600*7, "/"); 
date_default_timezone_set("PRC"); 
function getmtime()
{
	list($a,$b) = explode(" ",microtime());
	return ((float)$a+(float)$b); 
} 
define("START_TIME",getmtime()); 
define("root_path", dirname(__FILE__)); 
include root_path . "/config.php"; 
require root_path . "/include/conn.mysql.php"; 
include root_path . "/include/fun/functions.php";
include root_path . "/include/fun/online.fun.php";
include root_path . "/include/fun/html.fun.php";
include root_path . "/include/fun/ubb.fun.php";
include root_path . "/include/fun/salefty.fun.php";
include root_path . "/include/class/list.class.php";
include root_path . "/include/class/app.class.php";
include root_path . "/include/class/mysql.class.php";
include root_path . "/include/class/CfgValue.class.php";
include root_path . "/include/class/Dir.class.php";
include root_path . "/DdTpl/dd_tpl.class.php";
define("INCLUDE_TIME",getmtime());
/*
+----------------------------------------
  域名处理获取对应的网站ID
+----------------------------------------  
*@$cfg[URL] str 当前授权域名
*/

$APP = new APP;
$wapid = $APP->run();
define("WAPID",$wapid);
/*
+----------------------------------------
* 网站字符过滤
+----------------------------------------
*/

$cfgValue = new CfgValue('safety');
salefty($cfgValue);
/*
+------------------------------------------
* 获取网站配置文件
+------------------------------------------
*/

$mysql = new D('config');
$cfginfo = $mysql->where(array('user'=>WAPID))->find();
if ($cfginfo) {
    $sitevip = site_vip(WAPID);
    if ($sitevip == 'vip')
	{
        $wap_top = $cfg['SYS_TOP'] . $cfg['SYS_TOP_VIP'] . $cfginfo['wap_top'];
        $wap_bottom = $cfginfo['wap_bottom'] . $cfg['SYS_TOP_VIP'] . $cfg['SYS_TOP'];
    } else {
        $wap_top = $cfg['SYS_TOP'] . $cfg['SYS_TOP_P'] . $cfginfo['wap_top'];
        $wap_bottom = $cfginfo['wap_bottom'] . $cfg['SYS_TOP_P'] . $cfg['SYS_TOP'];
    }
}
$userinfo = array();
$userinfo = userinfo('get');
if($userinfo == NULL){
	$userinfo['sid'] = NULL;
	$userinfo['ver'] = $cfginfo['ver'];
	$userinfo['css'] = '0';
}
if ($userinfo['ver'] == 0 || $userinfo['ver'] == '0') {
    if (isMobile()) {
        $userinfo['ver'] = 3;
    } else {
        $userinfo['ver'] = 4;
    }
}
$login = 2;
if($userinfo['sid'] != NULL && $userinfo['sid'] != '')
{	
	$sql = new D('user');
	$res = $sql -> where(
		array(
				'sid' => $userinfo['sid'],
				'site_u' => WAPID
				)
			)->find();
	if ($res)
	{
		$id       =  $res['id'];
		$name     =  $res['name'];
		$nc       =  $res['nc'];
		$pass     =  $res['pass'];
		$sex      =  $res['sex'];
		$qianm    =  $res['qianm'];
		$head     =  $res['head'];
		$email    =  $res['email'];
		$admin    =  $res['admin'];
		$vip      =  $res['vip'];
		$sids     =  $res['sid'];
		$xid      =  $res['xid'];
		$crevalue =  $res['crevalue'];
		$login = 1;
    }
} 
$sid1 = $sids;
userinfo('set',$sids.'-'.$userinfo['ver'].'-'.$userinfo['css']);
//ini_set("display_errors", "off");
if ($cfg['ReadHtml'] == TRUE) 
{
    if ($_POST = null)
	{
        ReadHtml();
    }
}
/*
+-------------------------------------------
*      引入常量定义文件
+-------------------------------------------
*/
include root_path . "/include/cfg/defines.php";
define("SYSTEM_TIME",getmtime());