Link Check PHP implementation Home link query links check the code

Source: Internet
Author: User
Tags setcookie
Copy CodeThe code is as follows:


/*
* Website Home hyperlink Reverse Search links query outside the chain
* Web technology Enthusiasts lost63.com original qq:35501547
* Reprint please indicate the source
*/
if ($_get[' action ']== "check") {
$domain =$_post[' domain ';
If the Domain Name table item is empty, get the address bar parameter
if ($domain = = "") {
$domain =$_get[' domain ';
}
Url
$url = "http://". $domain;
Read Web page, return page source file content
function Read_url ($STR) {
$file =fopen ($str, "R") or Die ($str. ' Remote URL read failed! Click Continue Query
');
while (!feof ($file)) {
$result. =fgets ($file, 9999);
}
Fclose ($file);
return $result;
}
Open session
Session_Start ();
If $_session[' matches ' is not assigned, set it;
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];
}
Remove the included URL array directly from the 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 "Scan over!";
}else{
Echo ' ';
}
}else{
Delete Cookies
Setcookie ("Check_result", "", Time ()-3600);
Echo ';
}
?>

The above describes the link check PHP implementation of the homepage link query links Check the code, including links to check the content, I hope that the PHP tutorial interested friends have helped.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.