<?
	require_once("user__check.php");

	// 更新本日点入点出记录
	$sql="update ".TBL_PICK." set today=0 where dt not like '".date("Y-m-d")."%' and status>0 and uid=".$uid;
	mysql_query($sql);
	$sql="update ".TBL_POST." set today=0 where dt not like '".date("Y-m-d")."%' and status>0 and uid=".$uid;
	mysql_query($sql);
	
	// 获取用户当前数据记录
	$sql="select count(id) , sum(today) , sum(total) , sum(pages1) , sum(pages2) from ".TBL_PICK." where status>0 and uid=".$uid;
	$row=mysql_fetch_array(mysql_query($sql));
	$plan1=floor($row[0]);
	$today1=floor($row[1]);
	$total1=floor($row[2]);
	$pages1=floor($row[3]);
	$pages2=floor($row[4]);

	$sql="select count(id) , sum(today) , sum(total) from ".TBL_POST." where status>0 and uid=".$uid;
	$row=mysql_fetch_array(mysql_query($sql));
	$plan2=floor($row[0]);
	$today2=floor($row[1]);
	$total2=floor($row[2]);

	$sql="select sum(point) from ".TBL_USER_POINT." where point>0 and uid=".$uid;
	$row=mysql_fetch_array(mysql_query($sql));
	$point3_1=abs($row[0]);

	$sql="select sum(point) from ".TBL_USER_POINT." where point<0 and uid=".$uid;
	$row=mysql_fetch_array(mysql_query($sql));
	$point3_2=abs($row[0]);

	// 初始化
	if($plan1==0 and $pages1==0 and $pages2==0){
		$sql="insert into ".TBL_PICK."(name,domain,dt,status,uid) values('默认方案','".$user["domain"]."','".date("Y-m-d H:i:s")."',2,".$uid.") ";
		mysql_query($sql);
		$sql="insert into ".TBL_PAGE."(title,uri,dt,status,uid) values('".$user["site"]."','http://".$user["domain"]."/#eachgain','".date("Y-m-d H:i:s")."',2,".$uid.") ";
		mysql_query($sql);
	}

	// 数据修正：通过积分判断该用户数据库记录是否操作出错，如果出错则进行修正
	$point1=floor($user["point1"]);
	$point2=floor($user["point2"]);
	$point3=floor($user["point3"]);
	if(abs($point1-$total1)>100){
		;
	}
	if(abs($point2-$total2)>100){
		;
	}
	if(abs($point3_1+$point3_2-$point3)>100){
		;
	}
	
	// 计算交换比率
	$rate1=$total2==0?$total1:round($total1/$total2,2);
	$rate2=($total2+$point3)==0?$total1:round($total1/($total2+$point3),2);

	// 判断当前的交换比率是否远小于系统设定的比率，如果小于则提醒用户
	if($rate1>10){
		$info="请投放代码或将代码投放在流量大的页面上。";
	}	
	if($rate1<1){
		$info="您的交换比率暂时比较低，请不要着急。";
	}
	if($rate1<0.5){
		$info="您的交换比率比较低，请检查原因。";
	}
	if($rate1<0.1){
		$info="您的交换比率太低，请联系管理员。";
	}
?>
<div id="left">
	<?=$user["truename"];?> [ <font style="text-decoration:underline;cursor:hand;" title="ID=<?=$user["id"];?>"><?=$user["username"];?></font> ] ，您好！
	<span style="float:right;color:red;cursor:hand;display:<?=$info==""?"none":"block";?>;" title="<?=$info;?>">[系统提示]</span>
	<br>

	<br>

	总共登录次数：<?=$user["login_times"];?>
	<br>
	上次登录时间：<?=substr($user["login_dt"],2,14);?>
	<br>
	上次登录地址：<?=str_replace(strstr($user["login_ip"],"|"),"",$user["login_ip"]);?>
	<br>
	本次登录时间：<?=substr($user["login_dt"],22,14);?>
	<br>
	本次登录地址：<?=substr(strstr($user["login_ip"],"|"),1);?>
	<br>
	
	<br>

	数据采集方案数：<?=$plan1;?>
	<br>
	代码投放方案数：<?=$plan2;?>
	<br>
	网站页面采集数：<?=$pages1;?>
	<br>
	网站页面收录数：<?=$pages2;?>
	<br>

	<br>	

	今日/总点入：<span style="width:30px;text-align:right;"><?=$today1;?></span>&nbsp;|<span style="width:30px;text-align:right;"><?=$total1;?></span>
	<br>
	今日/总点出：<span style="width:30px;text-align:right;"><?=$today2;?></span>&nbsp;|<span style="width:30px;text-align:right;"><?=$total2;?></span>
	<br>

	<br>

	总共奖惩流量：<span style="cursor:help;" title="奖励：<?=$point3_1;?> | 惩罚：<?=$point3_2;?>"><?=$point3;?></span>
	<br>
	总共赚取流量：<span style="cursor:help;" title="总共赚取流量=总共点入流量-总共点出流量"><?=floor($total1-$total2);?></span>
	<br>

	<br>	
	
	理论交换比率：<font style="color:red;font-size:14px;cursor:help;" title="理论交换比率=总点入/总点出"><?=$rate1;?></font>
	<br>
	实际交换比率：<font style="color:red;font-size:14px;cursor:help;" title="实际交换比率=总点入/(总点出+奖惩数)"><?=$rate2;?></font>
</div>

<div id="right1">
<?
	require_once("bulletin_list.php");
?>
</div>