Check the response to an HTTP request to a URL
How browsers and search engine crawlers do they see your Web pages, what information is returned in response to an HTTP request?
Here is a script that performs the test, sends a request to the URL you specify and displays the code returned by the server. A form is included in the archive to enter the URL with a JavaScript script to run the PHP script on a remote or local server.
Source code
function sockAccess($server, $page)
{
$errno="";
$errstr="";
$fp=0;
$fp=fsockopen($server, 80, $errno, $errstr, 30);
if($fp===0)
{
die("Error $errstr ($errno)");
}
$out="GET /$page HTTP/1.1\r\n";
$out.="Host: $server\r\n";
$out.="Connection: Close\r\n\r\n";
fwrite($fp,$out);
$content = "";
$counter = 0;
while (!feof($fp) && $counter < 8)
{
$line = trim(fgets($fp, 128));
if($counter == 0)
{
$code=trim(substr($line,9,4));
$content = "<strong>Code retour: $code ";
$label = "";
switch(intval($code))
{
case 200: $label= " OK ";break;
case 301: $label= " Redirection permanente"; break;
case 302: $label= " Redirection temporaire"; break;
case 404: $label= " Page non trouvée"; break;
default:break;
}
$content.= $label."</strong><br><br>";
}
$content .= $line . "<br>";
$counter++;
}
fclose($fp);
return $content;
}
$url = $_POST['url'];
$parsed = parse_url($url);
$server = $parsed['host'];
$page = $parsed['path'];
$content=sockAccess($server, $page);
print_r($content);
Download
More