|
Hi,
I have this link validation script that I got from some site. It works fine in testing enviornment i.e localhost, but when I upload it to my shared hosting account it did'nt work, here is the script,
function is_link_exist($url)
{
$host = parse_url($url, PHP_URL_HOST);
$path = parse_url($url, PHP_URL_PATH);
if (empty($path)) {
$path = "/";
}
/* build request headers
$reqh = "HEAD $path HTTP/1.1\r\n"
. "Host: $host\r\n"
. "Connection: Close\r\n\r\n";
$fp = @fsockopen($host, 80, $errno, $errmsg, 30);
if (!$fp) {
print "Sorry unable to connect.";
exit;
}
/* send request headers
fwrite($fp, $reqh);
/* read response
while(!feof($fp)) {
$resh .= fgets($fp, 4096);
}
fclose($fp);
/* get http status
$firstline = substr($resh, 0, strpos($resh, "\r\n"));
list($proto, $stat, $msg) = explode(" ", $firstline);
if ($stat == 200) {
return true;
}
else {
return false;
}
}
It prints out the "Sorry unable to connect" message, can any body help me out, or anybody has a working script?
|