<?php
/*
**U2自动链 自动采集程序
**index.php
**By 冬筠 qq 4  2 6 4 2 0
*/
error_reporting(0);
ini_set('html_errors',false);
ini_set('display_errors',false);
@ini_set('memory_limit', '-1');
@set_time_limit(0);
require_once "./inc/common.inc.php";
$time=time()+8*3600;
$ltime=date("Y-m-d");
$url=$_SERVER["QUERY_STRING"];
if(!$url) exit('');
$url=urldecode($url);
$filename=l_path.'./_Cache/key/'.md5($url).'';
if(!is_dir(l_path.'./_Cache/key/')) {
mkpaths('/_Cache/key/');
}
if(!gethchtml($filename,$cjsjsz*60)){
writetofile($filename,'ok');
$url="http://www.baidu.com/s?wd=".urlencode($url)."&pn=1&rn=20";
$html=get_url_content($url);
if($html) {
//$html=get_encoding($html,$charset);
$uurls_array = array();
preg_match_all("/(href|HREF)=[\"|'| ]{0,}(http:\/\/(.*))[\"|'| |>]/isU",$html,$uurls_array);
if(count($uurls_array[2])) {
$uurls = array_unique($uurls_array[2]);
foreach($uurls as $key => $lurl){
$uurl=$lurl;
$urlok = strstr($uurl, 'baidu.com');
if(!$urlok){
$query = $db -> query("SELECT id FROM {$tablepre}link WHERE url='$uurl'");
if($db -> num_rows($query)){
} else {
$urlhtml=get_url_content($uurl);
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="";
//写入数据
$shok="2";
if($shenhe) $shok="0";
if($title){
$db -> query("INSERT INTO {$tablepre}link (title, url, keywords, description, about, lurl, result, addtime, uptime, classid) VALUES ('$title', '$uurl', '$keywords', '$description', '$wzhtml', '$lurl', '$shok', '$time', '$time', '$daoid') ");
//$keywords=GetKeywords($keywords);
Gettags();
}
}
}
}
}
}
}
}
$db -> close();
?>