<?php
include("require.php");
$phpcolor->table="user";
$phpcolor->field="username,loginip";
$phpcolor->where="id = '".$_GET["id"]."'";
if($user=$phpcolor->exist(1) and $int_uspread!="0")
{
  $ip=$_SERVER['REMOTE_ADDR'];
  if(!isset($_COOKIE['spreadid']) || !isset($_COOKIE['spreadcode']))
  {
    $spreadcode = (time()+$core_time*3600).$ip.rand(1000,9999);
    $spreadcode = substr(md5($spreadcode),8,16);
    setcookie("spreadid", $_GET["id"], time()+$core_time*3600+86400);
	setcookie("spreadname", $user["username"], time()+$core_time*3600+86400);
    setcookie("spreadcode", $spreadcode, time()+$core_time*3600+86400);
  }
  else
    $spreadcode = $_COOKIE['spreadcode'];
  $macrs=new GetMacAddr(PHP_OS);
  $mac=$macrs->mac_addr;
  if($mac=="")
    $mac="无法获取";
  $phpcolor->table="spread";
  $phpcolor->field="*";
  if($int_uspread=="1")
    $phpcolor->where="uid = '".$_GET["id"]."' and ip = '".$ip."'";
  elseif($mac=="无法获取" || $int_uspread=="2")
    $phpcolor->where="uid = '".$_GET["id"]."' and (ip = '".$ip."' or spreadcode='".$spreadcode."')";
  else
	$phpcolor->where="uid = '".$_GET["id"]."' and (ip = '".$ip."' or mac = '".$mac."' or spreadcode='".$spreadcode."')";
  $userip=$phpcolor->exist(2);
  $time=date('Y-m-d H:i:s',strtotime(date('Y-m-d H:i:s'))+$core_time*3600);
  if(!$userip and $ip!=$user['loginip'])
  {
	if($int_uspreadf>0)
	  $phpcolor->upintegral($user['username'],"",$int_uspreadf,8,$time);
    $phpcolor->table="spread";
    $phpcolor->field="info ,uid, ip, mac, spreadcode, time, type";
    $phpcolor->where="'推广访问','".$_GET["id"]."','".$ip."','".$mac."','".$spreadcode."','".$time."', '1'";
    $phpcolor->write();
  }
  else
  {
    $phpcolor->table="spread";
    $phpcolor->field="info ,uid, ip, mac, spreadcode, time, type";
    $phpcolor->where="'推广访问','".$_GET["id"]."','".$ip."','".$mac."','".$spreadcode."','".$time."', '2'";
    $phpcolor->write();
  }
}
if(isset($_GET['tid']))
  jump("read.php?id=".$_GET['tid']);
if(isset($_GET['bid']))
{
  $barurl=htmlurl($core_url,"list",$_GET['bid'],0,$core_rewrite);
  jump($barurl);
}
jump("index.php");
?>