php實現首頁連結查詢 友情連結檢查的代碼_PHP教程

來源:互聯網
上載者:User
複製代碼 代碼如下:
/*
* 網站首頁超連結反查 友情連結查詢 外鏈查詢
* web技術愛好者 lost63.com原創 QQ:35501547
* 轉載請註明出處
*/

if($_GET['action']=="check"){

$domain=$_POST['domain'];

//網域名稱表單項為空白,則擷取地址欄參數
if($domain==""){
$domain=$_GET['domain'];
}

//網址
$url="http://".$domain;

//讀取網頁,返回網頁源檔案內容
function read_url($str){

$file=fopen($str,"r") or die($str.'->遠程網址讀取失敗! 點擊繼續查詢
');
while(!feof($file)){
$result.=fgets($file,9999);
}
fclose($file);
return $result;

}

//開啟session
session_start();

//如果$_SESSION['matches']沒有賦值就設定它;
if(!isset($_SESSION['matches'])){
$result=read_url($url);

preg_match_all('/(.*?)<\/a>/i',$result,$matches);
$num=count($matches[2]);
for($i=0;$i<$num;$i++){
if(strpos($matches[2][$i],$domain)>0){
unset($matches[2][$i]);
}
}

$_SESSION['matches']=$matches[2];
}
//直接從session中取出包含網址數組;
$matches[2]=$_SESSION['matches'];

$n=count($matches[2]);

$next=0;
$next+=$_GET['next'];

$result=read_url($matches[2][$next]);

if(strpos($result,$domain)>0){
$value=$matches[2][$next].' true
';
}else{
$value=$matches[2][$next].' false
';
}
$values=$_COOKIE['check_result'].$value;
setcookie("check_result",$values,time()+3600);
echo $values;

if($next==$n){
echo "掃描結束!";
}else{
echo '';
}


}else{
//刪除cookies
setcookie("check_result","",time()-3600);
echo '';
}
?>

http://www.bkjia.com/PHPjc/321019.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/321019.htmlTechArticle複製代碼 代碼如下: ?php /* * 網站首頁超連結反查 友情連結查詢 外鏈查詢 * web技術愛好者 lost63.com原創 QQ:35501547 * 轉載請註明出處 */ if($_G...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.