PHP+Ajax 网站SEO查询工具 提供代码

前端之家收集整理的这篇文章主要介绍了PHP+Ajax 网站SEO查询工具 提供代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Name:PHP+Ajax网站seo查询工具
#Author:年华nianhua.liu@gmail.com[Q:4908220]
#Homepage:http://master8.net
使用说明:
1.服务器必须至少支持allow_url_fopen,curl,fsockopen中的一种,具体请咨询服务器管理员
2.请尊重别人的劳动成果!你可以任意修改并使用此程序,但不允许修改后公开发布!传播此程序亦应保持此压缩包完整性!
3.如果在使用中遇到任何问题,请访问<A href="http://master8.net/bbs/"&gt;http://master8.net/bbs/提出以便得到解决。

ajax.js

<div class="codetitle"><a style="CURSOR: pointer" data="5950" class="copybut" id="copybut5950" onclick="doCopy('code5950')"> 代码如下:
<div class="codebody" id="code5950">
//Name:PHP+Ajax网站seo查询工具
//Author:年华nianhua.liu@gmail.com[Q:4908220]
//Notice:UseItAfterREADreadme.txt
//(c)2007www.master8.net
varxmlHttp;
functionmakeRequest(queryString){
varmsXml=newArray();
msXml[0]="Microsoft.XMLHTTP";
msXml[1]="MSXML2.XMLHTTP.5.0";
msXml[2]="MSXML2.XMLHTTP.4.0";
msXml[3]="MSXML2.XMLHTTP.3.0";
msXml[4]="MSXML2.XMLHTTP";
if(window.xmlHttpRequest){
xmlHttp=newXMLHttpRequest();
}else{
for(vari=0;i<msXml.length;i++){
try{
xmlHttp=newActiveXObject(msXml[i]);
break;
}catch(e){
xmlHttp=newxmlHttpRequest();
}
}
}
xmlHttp.onreadystatechange=getRequest;
xmlHttp.open('post','SEO.PHP',true);
xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlHttp.send(queryString);
}
functiongetRequest(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
$('SEO_result').innerHTML=xmlHttp.responseText;
}
}
}

SEO.PHP


<div class="codetitle"><a style="CURSOR: pointer" data="97664" class="copybut" id="copybut97664" onclick="doCopy('code97664')"> 代码如下:
<div class="codebody" id="code97664">
<?PHP
#Name:PHP+Ajax网站seo查询工具
#Author:年华nianhua.liu@gmail.com[Q:4908220]
#Notice:UseItAfterREADreadme.txt
#(c)2007www.master8.net
define('IN_SEO',TRUE);
error_reporting(E_ERROR);
set_time_limit(0);
isset($_SERVER['HTTP_REFERER'])orexit('InvalidRequest');
preg_match("/".$_SERVER['HTTP_HOST']."/i",$_SERVER['HTTP_REFERER'])orexit('AccessDenied');
header("Content-Type:text/html;charset=gb2312");
include'./robot.PHP';
require'./function.PHP';
@extract($_POST);
isset($job)&&isset($domain)orexit('InvalidRequest');
$domain=strtolower($domain);
is_domain($domain)orexit('InvalidDomain');
$jobs=array('google','baidu','yahoo','msn','sogou','iask','so163','zhongsou','vnet');
$result='';
if(inarray($job,$jobs))
{
$result=get
SEO_info($domain,$job);
}
elseif($job=='alexa')
{
$result=Alexa($domain);
}
elseif($job=='chinarank')
{
$result=ChinaRank($domain);
}
elseif($job=='pagerank')
{
$result='<imgsrc="./images/pagerank'.PageRank($domain).'.gif"align="absmiddle"/>'.$domain;
if(substr($domain,4)=='www.')
{
$domain=substr($domain,4);
$result.='<imgsrc="./images/pagerank'.PageRank($domain).'.gif"align="absmiddle"/>'.$domain;
}
}
elseif($job=='sogourank')
{
$result=sogouRank($domain).''.$domain;
if(substr($domain,4)=='www.')
{
$domain=str_replace("www.",'',$domain);
$result=$result.''.sogouRank($domain).''.$domain;
}
}
!empty($result)orexit('InvalidRequest');
echo'<imgsrc="./images/yes.gif"align="absmiddle"/>'.$result;
?>

function.PHP

<div class="codetitle"><a style="CURSOR: pointer" data="75638" class="copybut" id="copybut75638" onclick="doCopy('code75638')"> 代码如下:
<div class="codebody" id="code75638">
<?PHP
#Name:PHP+Ajax网站seo查询工具
#Author:年华nianhua.liu@gmail.com[Q:4908220]
#Notice:UseItAfterREADreadme.txt
#(c)2007www.master8.net
defined('INSEO')orexit('AccessDenied');
functionget
SEO_info($domain,$bot)
{
global$ROBOT;
if(!array_key_exists($bot,$ROBOT))return'InvalidRobot';
$content='';
$site_info='';
$link_info='';
$content=get_content($ROBOT[$bot]['site_url'].$domain);
if(empty($content))return'UnkownError...';
if(preg_match($ROBOT[$bot]['site_pattern'],$content,$matches))$site_info=$matches[1];
$content=get_content($ROBOT[$bot]['link_url'].$domain);
if(preg_match($ROBOT[$bot]['link_pattern'],$matches))$link_info=$matches[1];
return$ROBOT[$bot]['name'].'收录:<ahref="'.$ROBOT[$bot]['site_url'].$domain.'"target="_blank">'.$site_info.'反向链接:<ahref="'.$ROBOT[$bot]['link_url'].$domain.'"target="_blank">'.$link_info.'';
}
functionsogouRank($domain)
{
$rank='';
$pr=0;
$content=get_content('http://www.sogou.com/web?query='.$domain);
if(preg_match("/<\/span>([0-9]{1,})<\/dd>/",$matches))
{
$pr=intval($matches[1]);
$width=ceil(65$pr/100);
$rank='<imgsrc="./images/sg_left.gif"width="2"height="11"/><imgsrc="./images/sg_left_img.gif"width="'.$width.'"height="11"/><imgsrc="./images/sg_right_img.gif"width="'.(65-$width).'"height="11"/><imgsrc="./images/sg_right.gif"width="2"height="11"/>';
}
$rank='<ahref="http://www.sogou.com/web?query=link%3A'.$domain.'"target="_blank"title="搜狗Rank:'.$pr.'"&gt;'.$rank.''.$pr;
return$rank;
} functionChinaRank($domain)
{
$rank='';
$content=get_content('http://www.chinarank.org.cn/detail/Info.do?url='.$domain);
if(preg_match("/

排名<\/h3>(.)<\/tr>/",$matches))
{
$p=trim(str_replace('</td>',$matches[1]));
$p=explode("<td>",$p);
if(isset($p[1]))$rank.='今日:'.$p[1];
if(isset($p[2]))$rank.='本周:'.$p[2];
if(isset($p[3]))$rank.='三月:'.$p[3];
}
$rank='<ahref="http://www.chinarank.org.cn/detail/Info.do?url='.$domain.'"target="_blank"&gt;'.$rank.'';
return$rank;
}
functionAlexa($domain)
{
$alexa='';
$content=get_content('http://www.alexa.com/data/details/traffic_details?url='.$domain);
if(preg_match("/3mos.Change([\s\S]?)<\/table>/",$matches))
{
$change=strpos($matches[1],'down_arrow.gif')?'下降':'上升';
$p=strip_tags($matches[1],'<td>');
$p=trim(str_replace(array("","\n","</td>"),array('',''),$p));
$p=explode("<td>",$p);
if(isset($p[1]))$alexa.='今日:'.$p[1];
if(isset($p[2]))$alexa.='本周:'.$p[2];
if(isset($p[3]))$alexa.='本月:'.$p[3];
if(isset($p[4]))$alexa.=''.$change.':'.$p[4];
}
if(preg_match("/Reviewfor$domain:<\/span>(.
)
/",$matches))
{
$alexa=$alexa.'等级:'.$matches[1];
}
$alexa='<ahref="http://www.alexa.com/data/details/traffic_details?url='.$domain.'"target="_blank"&gt;'.$alexa.'';
return$alexa;
} functionis_domain($domain)
{
if(preg_match("/^([0-9a-z-]{1,}.)?[0-9a-z-]{2,}.([0-9a-z-]{2,}.)?[a-z]{2,}$/i",$domain))
{
returntrue;
}
else
{
returnfalse;
}
}
functionget_content($url)
{
if(!strpos($url,'://'))return'InvalidURI';
$content='';
if(ini_get('allow_url_fopen'))
{
$content=file_get_contents($url);
}
elseif(function_exists('curl_init'))
{
$handle=curl_init();
curl_setopt($handle,CURLOPT_URL,$url);
curl_setopt($handle,CURLOPT_CONNECTTIMEOUT,5);
curl_setopt($handle,CURLOPT_RETURNTRANSFER,1);
curl_setopt($handle,CURLOPT_FOLLOWLOCATION,0);
$content=curl_exec($handle);
curl_close($handle);
}
elseif(function_exists('fsockopen'))
{
$urlinfo=parse_url($url);
$host=$urlinfo['host'];
$str=explode($host,$url);
$uri=$str[1];
unset($urlinfo,$str);
$content='';
$fp=fsockopen($host,80,$errno,$errstr,30);
if(!$fp)
{
$content='CanNotOpenSocket...';
}
else
{
$out="GET$uriHTTP/1.1\r\n";
$out.="Host:$host\r\n";
$out.="Accept:/\r\n";
$out.="User-Agent:$_SERVER[HTTP_USER_AGENT]\r\n";
$out.="Connection:Close\r\n\r\n";
fputs($fp,$out);
while(!feof($fp))
{
$content.=fgets($fp,4069);
}
fclose($fp);
}
}
if(empty($content))$content='CanNotOpenUrl,PleaseCheckYouServer...
ForMoreInformation,PleaseVisitwww.master8.net';
return$content;
}
functionPageRank($domain)
{
$result=get_content('http://www.google.com/search?client=navclient-auto&ch=6'.GCH(strord('info:'.$domain)).'&ie=UTF-8&oe=UTF-8&features=Rank&q=info:'.urlencode($domain));
if(preg_match('/\d+:\d+:(\d+)/',$result,$matches))
{
returnintval($matches[1]);
}
else
{
return0;
}
} functionstrord($string)
{
$strlen=strlen($string);
for($i=0;$i<$strlen;$i++)
{
$result[$i]=ord($string{$i});
}
return$result;
} functionGCH($url,$length=null)
{
$length=sizeof($url);
$a=$b=0x9E3779B9;
$c=0xE6359A60;
$k=0;
$len=$length;
while($len>=12)
{
$a+=($url[$k+0]+($url[$k+1]<<8)+($url[$k+2]<<16)+($url[$k+3]<<24));
$b+=($url[$k+4]+($url[$k+5]<<8)+($url[$k+6]<<16)+($url[$k+7]<<24));
$c+=($url[$k+8]+($url[$k+9]<<8)+($url[$k+10]<<16)+($url[$k+11]<<24));
$mix=mix($a,$b,$c);
$a=$mix[0];
$b=$mix[1];
$c=$mix[2];
$k+=12;
$len-=12;
}
$c+=$length;
switch($len){
case11:$c+=($url[$k+10]<<24);
case10:$c+=($url[$k+9]<<16);
case9:$c+=($url[$k+8]<<8);
case8:$b+=($url[$k+7]<<24);
case7:$b+=($url[$k+6]<<16);
case6:$b+=($url[$k+5]<<8);
case5:$b+=($url[$k+4]);
case4:$a+=($url[$k+3]<<24);
case3:$a+=($url[$k+2]<<16);
case2:$a+=($url[$k+1]<<8);
case1:$a+=($url[$k+0]);
}
$mix=mix($a,$c);
return$mix[2];
} functionmix($a,$c)
{
$a-=$b;
$a-=$c;
$a^=(zeroFill($c,13));
$b-=$c;
$b-=$a;
$b^=($a<<8);
$c-=$a;
$c-=$b;
$c^=(zeroFill($b,13));
$a-=$b;
$a-=$c;
$a^=(zeroFill($c,12));
$b-=$c;
$b-=$a;
$b^=($a<<16);
$c-=$a;
$c-=$b;
$c^=(zeroFill($b,5));
$a-=$b;
$a-=$c;
$a^=(zeroFill($c,3));
$b-=$c;
$b-=$a;
$b^=($a<<10);
$c-=$a;
$c-=$b;
$c^=(zeroFill($b,15));
returnarray($a,$c);
} functionzeroFill($a,$b)
{
$z=hexdec(80000000);
if($z&$a)
{
$a=($a>>1);
$a&=(~$z);
$a|=0x40000000;
$a=($a>>($b-1));
}
else
{
$a=($a>>$b);
}
return$a;
}
?>


robot.php

<div class="codetitle"><a style="CURSOR: pointer" data="15159" class="copybut" id="copybut15159" onclick="doCopy('code15159')"> 代码如下:
<div class="codebody" id="code15159">
<?PHP
#Name:PHP+Ajax网站seo查询工具
#Author:年华nianhua.liu@gmail.com[Q:4908220]
#Notice:UseItAfterREADreadme.txt
#(c)2007www.master8.net
defined('IN_SEO')orexit('AccessDenied');
$ROBOT['google']['name']='Google';
$ROBOT['google']['site_url']='http://www.google.com/search?hl=zh-CN&q=site%3A';
$ROBOT['google']['site_pattern']="/上约有(.)<\/b>项符合/";
$ROBOT['google']['link_url']='http://www.google.com/search?hl=zh-CN&q=link%3A';
$ROBOT['google']['link_pattern']="/约有(.
)<\/b>项链接到/"; $ROBOT['baidu']['name']='百度';
$ROBOT['baidu']['site_url']='http://www.baidu.com/s?wd=site%3A';
$ROBOT['baidu']['site_pattern']="/找到相关网页约(.)篇/";
$ROBOT['baidu']['link_url']='http://www.baidu.com/s?wd=domain%3A';
$ROBOT['baidu']['link_pattern']="/找到相关网页约(.
)篇/"; $ROBOT['yahoo']['name']='Yahoo';
$ROBOT['yahoo']['site_url']='http://search.cn.yahoo.com/search?p=site%3A';
$ROBOT['yahoo']['site_pattern']="/共返回约

(.)<\/h3>项/";
$ROBOT['yahoo']['link_url']='http://search.cn.yahoo.com/search?p=linkdomain%3A';
$ROBOT['yahoo']['link_pattern']="/共返回约

(.)<\/h3>项/"; $ROBOT['sogou']['name']='搜狗';
$ROBOT['sogou']['site_url']='http://www.sogou.com/web?query=site%3A';
$ROBOT['sogou']['site_pattern']="/找到(.)个网页/";
$ROBOT['sogou']['link_url']='http://www.sogou.com/web?query=link%3A';
$ROBOT['sogou']['link_pattern']="/找到(.
)个网页/"; $ROBOT['iask']['name']='新浪';
$ROBOT['iask']['site_url']='http://www.iask.com/w?k=site%3A';
$ROBOT['iask']['site_pattern']="/找到<spanclass=\"ar\">(.)<\/span>篇网页/";
$ROBOT['iask']['link_url']='http://www.iask.com/w?k=domain%3A';
$ROBOT['iask']['link_pattern']="/找到<spanclass=\"ar\">(.
)<\/span>篇网页/"; $ROBOT['msn']['name']='MSN';
$ROBOT['msn']['site_url']='http://search.msn.com/results.aspx?q=site%3A';
$ROBOT['msn']['site_pattern']="/

Page1of(.)results<\/h5>/";
$ROBOT['msn']['link_url']='http://search.msn.com/results.aspx?q=link%3A';
$ROBOT['msn']['link_pattern']="/
Page1of(.)results<\/h5>/"; $ROBOT['so163']['name']='网易';
$ROBOT['so163']['site_url']='http://cha.so.163.com/so.PHP?q=site%3A';
$ROBOT['so163']['site_pattern']="/共<\/span><SPANclass=black5>(.)<\/span>/";
$ROBOT['so163']['link_url']='http://cha.so.163.com/so.PHP?q=link%3A';
$ROBOT['so163']['link_pattern']="/共<\/span><SPANclass=black5>(.
)<\/span>/"; $ROBOT['zhongsou']['name']='中搜';
$ROBOT['zhongsou']['site_url']='http://p.zhongsou.com/p?w=site%3A';
$ROBOT['zhongsou']['site_pattern']="/找到(.)条结果/";
$ROBOT['zhongsou']['link_url']='http://p.zhongsou.com/p?w=link%3A';
$ROBOT['zhongsou']['link_pattern']="/找到(.
)条结果/"; $ROBOT['vnet']['name']='电信114';
$ROBOT['vnet']['site_url']='http://search.114.vnet.cn/search_web.html?kw=site%3A';
$ROBOT['vnet']['site_pattern']="/共搜到约(.)个网页/";
$ROBOT['vnet']['link_url']='http://search.114.vnet.cn/search_web.html?kw=link%3A';
$ROBOT['vnet']['link_pattern']="/共搜到约(.
)个网页/";
?>

index.html

<div class="codetitle"><a style="CURSOR: pointer" data="96596" class="copybut" id="copybut96596" onclick="doCopy('code96596')"> 代码如下:<div class="codebody" id="code96596">
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<htmlxmlns="http://www.w3.org/1999/xhtml"&gt;

<Metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
<a href="/tag/PHP/" target="_blank" class="keywords">PHP</a>+Ajax<a href="/tag/wangzhanseo/" target="_blank" class="keywords">网站seo</a><a href="/tag/chaxun/" target="_blank" class="keywords">查询</a>工具PoweredByMaster8.NET
<Metaname="author"content="站长吧Master8.NET"/>
<Metaname="description"content="PHP+Ajax网站seo查询工具"/>
<Metaname="keywords"content="PHP,Ajax,网站seo,查询,工具"/>

<scripttype="text/javascript"src="./ajax.js">
<scripttype="text/javascript">
functiondoSEO(){
if(!$('domain').value.match(/^([a-z0-9-]{1,}.)?[a-z0-9-]{2,}.([a-z0-9-]{1,}.)?[a-z0-9]{2,}$/i)){
alert('哈罗~~~首先,请输入正确的域名:P');
$('domain').value='';
$('domain').focus();
return;
}
$('SEO_result').innerHTML='<imgsrc="./images/loading.gif"width="94"height="15"align="absmiddle"alt="正在加载,请稍候... 如果长时间未响应,请尝试重新查询"/>Loading...';
$('SEO_result').style.display='';
varjobs=newArray();
jobs[0]="alexa";
jobs[1]="pagerank";
jobs[2]="google";
jobs[3]="baidu";
jobs[4]="chinarank";
jobs[5]="sogourank";
jobs[6]="yahoo";
jobs[7]="msn";
jobs[8]="sogou";
jobs[9]="iask";
jobs[10]="so163";
jobs[11]="zhongsou";
jobs[12]="vnet";
for(vari=0;i<jobs.length;i++){
if($(jobs[i]+'_check').checked==false)continue;
makeRequest('job='+jobs[i]+'&domain='+$('domain').value);break;
}
} function$(ID){
returndocument.getElementById(ID);
}



<divclass="divline">
<inputtype="input"size="18"name="domain"id="domain"value="www.master8.net"style="height:12px;"onmouSEOver="this.select()"ondblclick="this.value='';"title="请输入您的网站域名 双击鼠标清空输入框"/>
<inputtype="radio"name="type"value="alexa"id="alexa_check"/>Alexa排名
<inputtype="radio"name="type"value="pagerank"id="pagerank_check"checked/>PageRank
<inputtype="radio"name="type"value="google"id="google_check"/>Google收录
<inputtype="radio"name="type"value="baidu"id="baidu_check"/>Baidu收录
<imgsrc="./images/doSEO.gif"width="52"height="18"align="absmiddle"onclick="doSEO();"style="cursor:pointer"alt="网站seo查询"/>
<imgsrc="./images/moreSEO.gif"width="52"height="18"align="absmiddle"onclick="$('SEO_more').style.display=$('SEO_more').style.display=='none'?'':'none';"style="cursor:pointer"alt="更多SEO查询"/>

<divclass="divline"style="display:none"id="SEO_more">
<inputtype="radio"name="type"value="chinarank"id="chinarank_check"/>ChinaRank排名
<inputtype="radio"name="type"value="sogourank"id="sogourank_check"/>搜狗Rank
<inputtype="radio"name="type"value="yahoo"id="yahoo_check"/>Yahoo
<inputtype="radio"name="type"value="msn"id="msn_check"/>MSN
<inputtype="radio"name="type"value="sogou"id="sogou_check"/>搜狗
<inputtype="radio"name="type"value="iask"id="iask_check"/>新浪
<inputtype="radio"name="type"value="so163"id="so163_check"/>网易
<inputtype="radio"name="type"value="zhongsou"id="zhongsou_check"/>中搜
<inputtype="radio"name="type"value="vnet"id="vnet_check"/>电信114

<divclass="divline"style="display:none"id="SEO_result">

<divclass="div"style="font-size:9px;text-align:right;">
<ahref="http://www.master8.net"target="_blank"&gt;PoweredByMaster8.NET



本地下载

猜你在找的Ajax相关文章