Copy codeThe Code is as follows:
<? Php
/*
* Querying external links on the homepage hyperlink Lookup
* Lost63.com original QQ: 35501547
* Indicate the source for reprinting.
*/
If ($ _ GET ['action'] = "check "){
$ Domain = $ _ POST ['domain '];
// If the domain name form item is blank, the address bar parameters are obtained.
If ($ domain = ""){
$ Domain = $ _ GET ['domain '];
}
// URL
$ Url = "http: //". $ domain;
// Read the webpage and return the webpage source file content
Function read_url ($ str ){
$ File = fopen ($ str, "r") or die ($ str. '-> An error occurred while reading the remote URL! <A href = "? Next = '. ($ _ GET ['Next'] + 1 ). '& action = check & domain = '. $ _ GET ['domain ']. '"> click to continue query </a> <br> ');
While (! Feof ($ file )){
$ Result. = fgets ($ file, 9999 );
}
Fclose ($ file );
Return $ result;
}
// Open the session
Session_start ();
// If $ _ SESSION ['matches'] is not assigned a value, set it;
If (! Isset ($ _ SESSION ['matches']) {
$ Result = read_url ($ url );
Preg_match_all ('/<(.*?) 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];
}
// Retrieve the URL array from the session directly;
$ 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 "Scan completed! ";
} Else {
Echo '<meta http-equiv = "refresh" content = "1; URL =? Next = '. ($ next + 1).' & action = check & domain = '. $ domain.' "/> ';
}
} Else {
// Delete 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 a domain name, for example, jb51.net.
</Form> ';
}
?>