Home >Backend Development >PHP Tutorial >Friendly link check php implements home page link query code for friendly link check
Copy the code The code is as follows:
/*
* Website homepage hyperlink check, friendly link query, external link query
* Original QQ by web technology enthusiast lost63.com: 35501547
* Reposted Please indicate the source
*/
if($_GET['action']=="check"){
$domain=$_POST['domain'];
//If the domain name form item is empty, get the address bar parameters
if($domain==""){
$domain=$_GET['domain'];
}
//Website
$url="http://".$domain;
//Read the web page, Return the content of the web page source file
function read_url($str){
$file=fopen($str,"r") or die($str.'->Remote URL reading failed! Click to continue query
');
while(!feof($file)){
$result.=fgets($file,9999);
}
fclose($file);
return $result;
}
//Open session
session_start();
//If $_SESSION['matches'] is not assigned a value, set it;
if(!isset($_SESSION['matches'])){
$result=read_url($url);
preg_match_all('/(.*?)/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];
}
//Get the 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< /font>
';
}else{
$value=$matches[2][$next].' false
';
}
$ values=$_COOKIE['check_result'].$value;
setcookie("check_result",$values,time()+3600);
echo $values;
if($next==$n){
echo "Scan End!";
}else{
echo '';
}
}else{
//Delete cookies
setcookie("check_result","",time( )-3600);
echo '';
}
?>
The above introduces the friendly link check, PHP implementation of home page link query, friendly link check code, including the content of friendly link check, I hope it will be helpful to friends who are interested in PHP tutorials.