<?php
ini_set('display_errors','off');
 $u =$_GET['u'];
 if($u){
 $_COOKIE['user_tjid']=$u;
 setcookie("user_tjid", "$u"); 
 }
 $product = $db->pe_select('package', array('package_domainmark'=>$_SERVER['HTTP_HOST']));
 if($product){
 $package_id=$product['package_id'];
 }
//评论列表
$comment_list = $db->pe_selectall('comment', array('comment_state'=>1, 'package_id'=>$package_id, 'order by'=>'comment_id desc'), '*', array(30));
//判断注册弹框是否屏蔽
if (!$_COOKIE['regdialog_cookie']) {
	$regdialog_cookie = md5(pe_ip().time().rand(1,100));
@setcookie('regdialog_cookie', $regdialog_cookie);
}
else {
	$regdialog_cookie = $_COOKIE['regdialog_cookie'];
}
$regdialog = $db->pe_num('regdialog', " and (`regdialog_ip`= '".pe_ip()."' or `regdialog_cookie` = '{$regdialog_cookie}')");


$cache_package = cache::get('package');
if (!$package_id) {
	$package_id = intval($mod) ? intval($mod) : key($cache_package);
}


//套餐涨价相关
$sqlwhere = " and `package_zjtime` <= '".time()."' and `package_money` + `package_zjmoney` <= 498";
$sqlset = "`package_money` = `package_money` + `package_zjmoney`, `package_zjtime` = `package_zjtime` + 86400 * 7";
if ($db->pe_update('package', $sqlwhere, $sqlset)) {
	cache::write('package');
}
$remain_second = $cache_package[$package_id]['package_zjtime'] - time();

function istrue_user() {
	$result = false;
	$true_arr = array('MSIE', 'Firefox', 'Chrome', 'Safari', 'Opera');
	foreach ($true_arr as $v) {
		if (stripos($_SERVER['HTTP_USER_AGENT'], $v) !== false) {
			$result = true;
		}
	}
	return $result;
}
//更新用户的推荐点
if ($domain_sub && istrue_user()) {
	$info_user = $db->pe_select('user', array('user_subdomain'=>$domain_sub));
	if ($info_user['user_id'] && !$db->pe_num('tjlog', array('user_id'=>$info_user['user_id'], 'tjlog_ip'=>pe_ip()))) {
		$db->pe_update('user', array('user_subdomain'=>$domain_sub), "`user_tjnum` = `user_tjnum`+1");
		$db->pe_insert('tjlog', array('user_id'=>$info_user['user_id'], 'tjlog_ip'=>pe_ip()));
	}	
}
//更新套餐推广点
if ($domain_sub) {
	if (!$db->pe_num('tglog', array('package_id'=>$package_id, 'tglog_ip'=>pe_ip()))) {
		$db->pe_update('package', array('package_id'=>$package_id), "`package_tgnum` = `package_tgnum`+1");
		$db->pe_insert('tglog', array('package_id'=>$package_id, 'tglog_ip'=>pe_ip()));
	}	
}
//在线订购产品
$product = $db->pe_selectall('product', array('package_id'=>$package_id, 'order by'=>'product_id desc'), '*', array(30));
$seo = pe_seo($cache_package[$package_id]['package_name'], $cache_package[$package_id]['package_keywords'], $cache_package[$package_id]['package_description']);
include(pe_tpl($cache_package[$package_id]['package_tpl'] ? $cache_package[$package_id]['package_tpl'] : 'index.html'));
?>