PHP home link query link check code

  • 2020-03-31 20:16:47
  • OfStack


<?php 
 

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

$domain=$_POST['domain']; 

//The domain name form item is empty, gets the address bar parameter
if($domain==""){ 
$domain=$_GET['domain']; 
} 

//The url
$url="http://".$domain; 

//Read the web page and return the contents of the web page source file
function read_url($str){ 

$file=fopen($str,"r") or die($str.'-> Remote url reading failed ! <a href="?next='.($_GET['next']+1).'&action=check&domain='.$_GET['domain'].'"> Click continue </a><br>'); 
while(!feof($file)){ 
$result.=fgets($file,9999); 
} 
fclose($file); 
return $result; 

} 

//Open the session
session_start(); 

//Set $_SESSION['matches'] if it is not assigned;
if(!isset($_SESSION['matches'])){ 
$result=read_url($url); 

preg_match_all('/<a(.*?)href="(http://.*?)"(.*?)>(.*?)</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]; 
} 
//Extract the array of urls directly from 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].' <font color=green>true</font><br>'; 
}else{ 
$value=$matches[2][$next].' <font color=red>false</font><br>'; 
} 
$values=$_COOKIE['check_result'].$value; 
setcookie("check_result",$values,time()+3600); 
echo $values; 

if($next==$n){ 
echo " The scan !"; 
}else{ 
echo '<meta http-equiv="refresh" content="1;URL=?next='.($next+1).'&action=check&domain='.$domain.'" />'; 
} 


}else{ 
//Delete the cookies
setcookie("check_result","",time()-3600); 
echo '<form name="form1" method="post" action="?action=check"> 
<input type="text" name="domain"> 
<input type="submit" name="Submit" value=" submit "> 
<font color="red">*</font> Enter the domain name   Such as :jb51.net 
</form>'; 
} 
?> 

Related articles: