[php]代码库
<?php
header("Content-type:text/html; charset=utf-8");
echo'<link rel="Stylesheet" type="text/css" href="toolsite.css?ver=2011_11"/>';
$check_html="<center><form action='tseo.php' method='post'><font>请输入网址:</font>http://<span class=s_ipt_wr><input type=text name=ck_url class=s_ipt></span><input type=submit name=ck_tj value=查询 class=s_btn></form></center>";
class seo_Check{
public $url;
function __construct($url){
$this->url=$url;
}
function show_seo(){
$this->check_url();
$this->get_content();
}
function check_url(){
$zurl=$this->url;
if(!empty($zurl)){
$pattern="/^(http\\:\\/\\/)?(www)?\\.([0-9a-z]+)\\.(com|cn|net|com\\.cn)$/i";
if(preg_match($pattern,$zurl,$newurl)){
if(!empty($newurl[1])){
$zurl=trim($newurl[1].".".$newurl[2].".".$newurl[3].".".$newurl[4]);
//$this->url=$zurl;
}
}
else
{
die("网址不合法!");
}
}
}
//get_content()
function get_content(){
$strem="http://seo.chinaz.com/?host=".$this->url;
//echo $strem;
$contents=file_get_contents($strem); // file_get_contents获取内容
if (!preg_match("<html>",$contents)){ // 暂时这样测试匹配成功与否
die("内容失效");
}
$contents=str_replace("\\n",'',$contents);
$contents=str_replace("/template/default/images",'http://seo.chinaz.com/template/default/images',$contents);
preg_match("/\\<table (.*?)\\>(.*?)\\<\\/table\\>/i",$contents,$newcode);
$_infohtml="<center><table class='info_tab'>".$newcode[2]."</table></center>";
echo $_infohtml;
}
}
if ($_POST['ck_tj']){
if(!empty($_POST['ck_url'])){
$ck_url=$_POST['ck_url'];
$show_seo1=new seo_Check($ck_url);
$show_seo1->show_seo();
}
}else
{
$ck_url="";
echo $check_html;
}
//echo $show_seo1->cur_html;
?>
//该片段来自于http://yuncode.net