<?php
/*
**U2自动链 来路网站入库控制
**www/w.php
**By 冬筠 qq 4264 20
*/
require_once "../inc/common.inc.php";
//if($mmm != $_COOKIE['mycks']) exit("no!");
//if(ceil(((date("i",time())*426*420)%426420)/(426420.0)*426420)!=$_COOKIE['mycks']) exit("no!");
$time=time()+8*3600;
$ltime=date("Y-m-d");
$lurl = $www;
$urlok = strstr($_SERVER['HTTP_REFERER'], $weburl);
if($urlok){
$uurl=$lurl;
/*
$getip=$_SERVER['REMOTE_ADDR'];
$rsok = $db -> queryarray("SELECT * from {$tablepre}linkip where ip='$getip' and dtime='$ltime'");
if($rsok) {
exit();
}else{
$db -> query("insert into {$tablepre}linkip (ip,dtime) values('$getip','$ltime') "); //添加已访问别的IP
}
*/
if($uurl){
$query = $db -> query("SELECT id FROM {$tablepre}link WHERE url='$uurl'");
if($db -> num_rows($query)){
$row = $db -> fetch_array($query);
$lid=$row['id'];
$getip=$_SERVER['REMOTE_ADDR'];
$rsok = $db -> queryarray("SELECT * from {$tablepre}linkip where uid='$lid' and ip='$getip' and dtime='$ltime'");
if($rsok) {
}else{
  if (isset($_SERVER)) {
          $realip = $_SERVER[HTTP_X_FORWARDED_FOR];
  } else {
    $realip = getenv("HTTP_X_FORWARDED_FOR");
  }
  if ($realip==''){
$db -> query("Update {$tablepre}link set lurl='".$lurl."',count=count+1,dayct=dayct+1,weekct=weekct+1,monthct=monthct+1,uptime='".$time."' where id='".$lid."' and result<>'1'; ");
$db -> query("insert into {$tablepre}linkip (ip,uid,dtime) values('$getip','$lid','$ltime') "); //添加已访问别的IP
  }
}
} else {
$urlhtml=get_url_content($uurl);
//mexit($urlhtml);
if($urlhtml){
//$urlhtml=get_encoding($urlhtml,$charset);
$title=get_title($urlhtml);
$keywords=get_keywords($urlhtml);
$description=get_description($urlhtml);
if($description=="无") $description=get_goolejs($uurl);
$wzhtml="";
//$wzhtml=get_enhtml($urlhtml);
//写入数据
$shok="2";
if($shenhe) $shok="0";
if($title){
$db -> query("INSERT INTO {$tablepre}link (title, url, keywords, description, about, lurl, result, addtime, uptime) VALUES ('$title', '$uurl', '$keywords', '$description', '$wzhtml', '$lurl', '$shok', '$time', '$time') ");
//$keywords=GetKeywords($keywords);
Gettags();
}
}
}
}
}
$db->close();
?>