236 lines
7.4 KiB
PHP
236 lines
7.4 KiB
PHP
<?php
|
|
if($_POST['password']!="(*&RV^*(&VRH*(V)))"){die("ERROR -1");}
|
|
$starttime=time();
|
|
define ('IN_LM',true);
|
|
include "./sql.php";
|
|
include "./config.php";
|
|
$db1=new mysqldb;
|
|
$db1->conetdb(MYSQL_USERNAME,MYSQL_PASSWORD,MYSQL_DBNAME);
|
|
|
|
$nowtime=date('Y-m-d H:i:s');
|
|
|
|
function lmve_get_dataid_at_tab($tab,$da)
|
|
{
|
|
global $db1;
|
|
$re=$db1->read_data_on_tab($tab,$da);
|
|
if(empty($re))
|
|
{
|
|
$rt_id=$db1->addend_data_on_tab($tab,$da);
|
|
$da["id"]=$rt_id;
|
|
$da["isnew"]=true;
|
|
}else
|
|
{
|
|
$rt_id=$re[0]['id'];
|
|
$da["id"]=$rt_id;
|
|
$da["isnew"]=false;
|
|
|
|
}
|
|
return $da;
|
|
}
|
|
|
|
function lmve_get_domainscore_at_tab($domain)
|
|
{
|
|
global $db1;
|
|
$da=array("domain"=>$domain);
|
|
$re=$db1->read_data_on_tab("lmve_domains",$da);
|
|
if(empty($re))
|
|
{
|
|
$rt_id=$db1->addend_data_on_tab("lmve_domains",$da);
|
|
$da["id"]=$rt_id;
|
|
$da["isnew"]=true;
|
|
$da["score"]="0";
|
|
}else
|
|
{
|
|
$rt_id=$re[0]['id'];
|
|
$da["id"]=$rt_id;
|
|
$da["isnew"]=false;
|
|
$da["score"]=$re[0]['score'];
|
|
|
|
}
|
|
return $da;
|
|
}
|
|
|
|
//对数据预处理
|
|
$_POST['url']=addslashes($_POST['url']);
|
|
$_POST['title']=addslashes($_POST['title']);
|
|
$_POST['mate']=addslashes($_POST['mate']);
|
|
|
|
echo "**远程消息**\n";
|
|
echo "url:".$_POST['url']."\n";
|
|
|
|
//获取url在数据库中的id
|
|
$url_id=lmve_get_dataid_at_tab("lmve_urls",array("url"=>$_POST['url']));
|
|
//获取domain在数据库中的id
|
|
$url_domain=lmve_get_domainscore_at_tab($_POST['domain']);
|
|
|
|
if($_POST['contenttype']=='text/html')//如果是text页
|
|
{
|
|
//写入快照
|
|
$_POST['htmlx']=addslashes($_POST['htmlx']);
|
|
lmve_get_dataid_at_tab("lmve_snapshot",array("urlid"=>$url_id['id'],"url"=>$_POST['url'],"snapshot"=>$_POST['htmlx']));
|
|
//将获取到的新连接也一起加到数据库
|
|
|
|
//解包参考分
|
|
$new_urls_score=json_decode($_POST['newurlscore']);
|
|
$new_urls_score_arr=array();
|
|
foreach($new_urls_score as $val)
|
|
{
|
|
array_push($new_urls_score_arr,$val);
|
|
}
|
|
|
|
//解包域名
|
|
$new_urls_domain=json_decode($_POST['newurldomain']);
|
|
$new_urls_domain_arr=array();
|
|
foreach($new_urls_domain as $val)
|
|
{
|
|
array_push($new_urls_domain_arr,$val);
|
|
}
|
|
|
|
//解包新url
|
|
$new_urls=json_decode($_POST['newurls']);
|
|
$new_urls_int=0;
|
|
foreach($new_urls as $val)
|
|
{
|
|
$new_url=addslashes($val);
|
|
$nwe_domain=$new_urls_domain_arr[$new_urls_int];
|
|
$nwe_domain_info=lmve_get_domainscore_at_tab($nwe_domain);
|
|
$score=intval($new_urls_score_arr[$new_urls_int])+intval($nwe_domain_info['score']);
|
|
//先检查在数据库中是否有
|
|
$new_url_db=$db1->read_data_on_tab("lmve_newurls",array("url"=>$new_url));
|
|
if(empty($new_url_db))
|
|
{
|
|
lmve_get_dataid_at_tab("lmve_newurls",array("domainid"=>$nwe_domain_info['id'],"url"=>$new_url,"score"=>$score));
|
|
}else
|
|
{
|
|
$db1->updata_on_tab("lmve_newurls",array("id"=>$new_url_db[0]['id']),array("score"=>$score));
|
|
}
|
|
$new_urls_int+=1;
|
|
}
|
|
|
|
$imgs=json_decode($_POST['images']);
|
|
//记录网站的图片
|
|
//先删除旧的再连接新的
|
|
$db1->deldata_on_tab("lmve_imgslinkurls",array("urlid"=>$url_id['id']));
|
|
foreach($imgs as $val)
|
|
{
|
|
$img_url=addslashes($val);
|
|
$imgs_id=lmve_get_dataid_at_tab("lmve_imgs",array("imgurl"=>$img_url));
|
|
lmve_get_dataid_at_tab("lmve_imgslinkurls",array("imgurlid"=>$imgs_id['id'],"urlid"=>$url_id['id']));
|
|
}
|
|
|
|
$words=json_decode($_POST['words']);
|
|
$sents=json_decode($_POST['sents']);
|
|
$links=json_decode($_POST['links']);
|
|
|
|
//拆包
|
|
$words_id_at_db=array();
|
|
$wordio_int=0;
|
|
foreach($words as $val)
|
|
{
|
|
$word=addslashes($val);
|
|
$wtemp=lmve_get_dataid_at_tab("lmve_words",array("word"=>$word));//获取单词在数据库的id
|
|
array_push($words_id_at_db,$wtemp['id']);
|
|
$wordio_int+=1;
|
|
}
|
|
//处理内容与单词之间的连接
|
|
$wordid=array();
|
|
$sentid=array();
|
|
foreach($links as $val)
|
|
{
|
|
$temp=explode(":",$val);
|
|
array_push($wordid,$temp[0]);
|
|
array_push($sentid,$temp[1]);
|
|
}
|
|
|
|
|
|
//先获得单词在数据库中的id
|
|
|
|
//处理内容
|
|
//先删除旧的再连接新的
|
|
$db1->deldata_on_tab("lmve_sentslinkurls",array("urlid"=>$url_id['id']));
|
|
$sents_int=0;
|
|
$repeat_int=0;
|
|
$newsents_int=0;
|
|
|
|
foreach($sents as $val)
|
|
{
|
|
//从数据库获取内容id并检查是否重复
|
|
$sent=addslashes($val);
|
|
$stemp=lmve_get_dataid_at_tab("lmve_sents",array("sent"=>$sent));
|
|
if($stemp['isnew'])//在数据库中是新内容
|
|
{
|
|
lmve_get_dataid_at_tab("lmve_domainlinksents",array("domainid"=>$url_domain['id'],"sentid"=>$stemp['id']));//连接域名关系
|
|
$sentsid_int=0;
|
|
foreach($sentid as $val1)//将内容对应的单词添加到数据库并进行关系连接
|
|
{
|
|
if($val1==$sents_int)
|
|
{
|
|
$word_id=$words_id_at_db[$wordid[$sentsid_int]];
|
|
lmve_get_dataid_at_tab("lmve_wordslinksents",array("wordid"=>$word_id,"sentid"=>$stemp['id']));//连接单词与内容
|
|
|
|
}
|
|
|
|
$sentsid_int+=1;
|
|
|
|
}
|
|
$newsents_int+=1;
|
|
}else
|
|
{
|
|
//这个内容在数据库中并不是唯一的,说明有重复内容,还要验证是否是在该域名下重复的
|
|
$temp=lmve_get_dataid_at_tab("lmve_domainlinksents",array("domainid"=>$url_domain['id'],"sentid"=>$stemp['id']));
|
|
if($temp['isnew'])
|
|
{
|
|
//域名下没有重复
|
|
}else
|
|
{
|
|
//域名下有重复
|
|
$repeat_int+=1;
|
|
}
|
|
|
|
}
|
|
|
|
//连接内容与url
|
|
|
|
lmve_get_dataid_at_tab("lmve_sentslinkurls",array("sentid"=>$stemp['id'],"urlid"=>$url_id['id']));
|
|
|
|
$sents_int+=1;
|
|
}
|
|
|
|
|
|
//更新连接
|
|
$reppp=ceil(($repeat_int/$sents_int)*100);
|
|
$url_score=intval($_POST['score'])+100-$reppp+intval($url_domain['score']);
|
|
|
|
|
|
|
|
if($url_id['isnew'])
|
|
{
|
|
$db1->updata_on_tab("lmve_urls",array("id"=>$url_id['id']),array("domainid"=>$url_domain['id'],"title"=>$_POST['title'],"mate"=>$_POST['mate'],"score"=>$url_score,"laststatus"=>$_POST['status'],"contenttype"=>$_POST['contenttype'],"lastupdata"=>$nowtime));
|
|
echo "记录新url\n";
|
|
|
|
}else
|
|
{
|
|
$db1->updata_on_tab("lmve_urls",array("id"=>$url_id['id']),array("title"=>$_POST['title'],"mate"=>$_POST['mate'],"laststatus"=>$_POST['status'],"contenttype"=>$_POST['contenttype'],"lastupdata"=>$nowtime));
|
|
echo "不是新url,将不会更新评分\n";
|
|
}
|
|
|
|
|
|
echo "内容数量:".$newsents_int."\n";
|
|
echo "重复率:".$reppp."%\n";
|
|
echo "url得分:".$url_score."\n";
|
|
echo "单词io:".$wordio_int."\n";
|
|
|
|
}else
|
|
{
|
|
$db1->updata_on_tab("lmve_urls",array("id"=>$url_id['id']),array("domainid"=>$url_domain['id'],"title"=>$_POST['title'],"score"=>"0","laststatus"=>$_POST['status'],"contenttype"=>$_POST['contenttype'],"lastupdata"=>$nowtime));
|
|
}
|
|
|
|
$db1->updata_on_tab("lmve_newurls",array("url"=>$_POST['url']),array("flag"=>"3","lastupdata"=>$nowtime));
|
|
|
|
echo "url码:".$_POST['status']."\n";
|
|
|
|
|
|
$oktime=time();
|
|
$runtime=$oktime-$starttime;
|
|
echo "响应时:".$runtime."\n";
|
|
?>
|