<?php


define("DEBUG",0);
define("CUR_DIR",dirname(__FILE__)); 
define('COMMON_DIR', CUR_DIR . DIRECTORY_SEPARATOR);
define('ROOT_DIR', substr(CUR_DIR,0,strrpos(CUR_DIR,DIRECTORY_SEPARATOR)+1));


@require_once(COMMON_DIR . "Config.inc.php");

if(!defined('DB_SERVER') || DB_SERVER == '' || DB_NAME == ''){
	echo("<script>alert('您还没执行安装程序');location='install/index.php'</script>");
}




$parentpath = API_WEB_URL;

require_once(COMMON_DIR . "MailTemplate.class.php");
require_once(COMMON_DIR . "MyDB.class.php");
require_once(COMMON_DIR . "MySmarty.class.php");
require_once(COMMON_DIR . "Util.inc.php");
require_once(COMMON_DIR . "Common.funcs.php");
require_once(COMMON_DIR . "Const.inc.php");
require_once(COMMON_DIR . "API.class.php");
require_once(COMMON_DIR . "Order.class.php");
require_once(COMMON_DIR . "ProductType.class.php");
require_once(COMMON_DIR . "HostImpl.class.php");
require_once(COMMON_DIR . "Payment.inc.php");

require_once(COMMON_DIR . "api.inc.php");
//$servername = $_SERVER['SERVER_NAME'];
//$servername=GetUrlToDomain($servername);
//if(file_get_contents('http://sq.yinxi.net/include/code.php?url=' . $servername)=="not")  die('当前域名未授权，请购买正版授权，联系客服qq：2522407257');

//$version=file_get_contents('http://sq.yinxi.net/admin/version.php');
//处理php.ini一些设置
@ini_set("display_errors","On");
@error_reporting(E_ALL & ~E_NOTICE);


CheckMysqlHackWords();



/* 初始化数据库类 */
$db = new cls_mysql(DB_SERVER, DB_LOGIN, DB_PW, DB_NAME);
$db->root_path = ROOT_DIR;
$db->cache_data_dir = "cache/";
$DB = $db;

/* 载入系统参数 */
$_CFG = load_config();
$AgentInfo = $_CFG;
//print_r($_CFG);

$curdir = substr($_SERVER[PHP_SELF],1);
if(strpos($curdir,"/")) $curdir = substr($curdir,0,strpos($curdir,"/"));
else $curdir="";

$sql = "select NiceCall from admins where NiceCall<>''";
$NiceCallOnline = $db->getAllCached($sql);
foreach($NiceCallOnline as $ncval)
{
	$nicecall_left[]=explode("||",$ncval[NiceCall]);
}

/* 载入模板 */
$smarty = new MySmarty();
$smarty->assign("title",$_CFG['SiteTitle']);
$smarty->assign('agent_logo',GetAgentLB_logo($parentpath));

$smarty->assign('agent_banner',GetAgentLB('Banner',$parentpath));
$smarty->assign('nicecall_left',$nicecall_left);
$smarty->assign('hot',$curdir);
$smarty->assign('parentpath', $parentpath);
$smarty->assign('iisp_zfb_show', $_CFG['iisp_zfb_show']);
$smarty->assign('iisp_qq_show', $_CFG['show_qq']);
$smarty->assign('agent_tel',$_CFG['Tel']);
	$smarty->assign('agent_fax',$_CFG['Fax']);
	$smarty->assign('agent_email',$_CFG['Email']);
	$smarty->assign('agent_addr',$_CFG['Addr']);
	$smarty->assign('agent_zip',$_CFG['Zip']);
	$smarty->assign('agent_name',$_CFG['Company']);
	$smarty->assign('agent_icp',$_CFG['ICP']);
if($AgentInfo['show_qq_kefu'] ==1)
{
	$sql = "select * from qq";
	$result = $db->query($sql);
	while($apiweb_qq_kefu = $db->fetch_array($result))
	{
		$apiweb_qq_kefu_arr[] = $apiweb_qq_kefu;
	}
	$smarty->assign('apiweb_qq_kefu', $apiweb_qq_kefu_arr);
	//print_r($apiweb_qq_kefu_arr);
}

if($_CFG[FootHtml]){
	$smarty->assign('FootHtml',trim($_CFG[FootHtml]));
}else{
	$smarty->assign('agent_tel',$_CFG['Tel']);
	$smarty->assign('agent_fax',$_CFG['Fax']);
	$smarty->assign('agent_email',$_CFG['Email']);
	$smarty->assign('agent_addr',$_CFG['Addr']);
	$smarty->assign('agent_zip',$_CFG['Zip']);
	$smarty->assign('agent_name',$_CFG['Company']);
	$smarty->assign('agent_icp',$_CFG['ICP']);
}
if($_SESSION['User_S']){
	$UserSurplus = GetSurplus($_SESSION['User_S']);
	if($UserSurplus>=0) $UserSurplusD = $UserSurplus;
	else $UserSurplusD = "欠费".abs($UserSurplus);
	$UserLevel = $_SESSION['iLevel_S']>0?$_SESSION['iLevel_S'].'级会员':'普通会员';
	$smarty->assign("UserLevel",$UserLevel);
	$smarty->assign('CurUser',$_SESSION['User_S']);
	$smarty->assign("UserSurplus",$UserSurplusD);
}

/* 判断是否支持 Gzip 模式 */
if (!defined('INIT_NO_SMARTY') && gzip_enabled())
{
    @ob_start('ob_gzhandler');
}
else
{
    @ob_start();
}


?>