<?php
include('common.php');
//联盟首页
$user_name=$_GET['u'];
$ip = pe_ip();
$now = strtotime(date('Y-m-d'));
$s_now = $now+24*3600;
$click = $db->pe_select('click', array('ip'=>$ip));
$s = mysql_query("SELECT COUNT(id) as total FROM `cps_click` WHERE `username`='$user_name' and `time` >= '$now' and `time` < '$s_now'");
$arr = mysql_fetch_assoc($s);

 if(empty($click)){
$user = $db->pe_select('user', array('user_name'=>$user_name));



if($user){
$info['time'] = time();
$info['ip'] = $ip;
$info['username'] = $user_name;
$info['uid'] = $user['user_id'];
$db->pe_insert('click', $info);
$money = $user['user_money'] + 0.01;
$db->pe_update('user', array('user_id'=>$user['user_id']), array('user_money'=>$money));
}
}

if($user_name){
$_COOKIE['user_name']=$user_name;
setcookie("user_name", "$user_name");  
}
   
if (stripos($pe['host_root'], $pe['domain_cps']) !== false) {
	$notice_list = $db->pe_selectall('notice', array('order by'=>'`notice_state` desc,`notice_id` desc'), '*', array(10));
	
	$notice_list[1] = $db->pe_selectall('notice', array('noticeclass_id'=>1, 'order by'=>'`notice_state` desc,`notice_id` desc'), '*', array(5));
	$notice_list[2] = $db->pe_selectall('notice', array('noticeclass_id'=>2, 'order by'=>'`notice_state` desc,`notice_id` desc'), '*', array(5));
	$faq_list = $db->pe_selectall('faq', array('order by'=>'`faq_id` desc'), '*', array(5));
	//登录首页信息
	$_s_user_id && $user = $db->pe_select('user', array('user_id'=>$_s_user_id));
	if (in_array($mod, array('faq','notice','page','product', 'comment','order'))) {
		include("{$pe['path_root']}module/{$module}/cps_{$mod}.php");
	}
	else {
		include("{$pe['path_root']}module/{$module}/cps_index.php");
	}
}
//套餐首页
else {
     $product = $db->pe_select('package', array('package_domainmark'=>$_SERVER['HTTP_HOST']));
    if($product){
	    if (in_array($mod, array('page', 'comment','order','product'))) {
			include("{$pe['path_root']}module/{$module}/{$mod}.php");
		}
		else {
			include("{$pe['path_root']}module/{$module}/index.php");
		}
	}else{
	echo "<script>alert('你的访问不存在！');window.location.href='http://1tuitui.viicms.com/';</script>";
	}
	
}
pe_result();
?>