It might work perfect for you in a browser, but not for me.
My guess is that you have a cookie your browser passes which allows entry. When you use "socket/fopen" you don't pass the cookie, thus you get the 403.
Here's a slightly modified (port-checking changed and moved and response echo added, plus reformatting) version of a function posted by "jack" to this page. You could probably add a cookie header to the "fwrite()" line.
function url_validate($link)
{
$url_parts = @parse_url($link);
if (empty($url_parts['host'])) {
return(false);
}
if (!empty($url_parts['path'])) {
$documentpath = $url_parts['path'];
} else {
$documentpath = '/';
}
if (!empty($url_parts['query'])) {
$documentpath .= '?' . $url_parts['query'];
}
$host = $url_parts['host'];
if (isset($url_parts['port'])) {
$port = $url_parts['port'];
} else {
$port = '80';
}
// Now (HTTP-)GET $documentpath at $host';
/**
if (empty($port)) {
$port = '80';
}
**/
$socket = @fsockopen($host, $port, $errno, $errstr, 30);
if (!$socket) {
return(false);
} else {
fwrite ($socket, 'HEAD ' . $documentpath . ' HTTP/1.0' . "\r\n" .
'Host: ' . $host . "\r\n\r\n");
$http_response = fgets($socket, 22);
echo '<pre>';
echo nl2br(htmlentities($http_response)) . '<br />';
echo '</pre>';
if (ereg('200 OK', $http_response, $regs)) {
return(true);
fclose($socket);
} else {
//echo "HTTP-Response: $http_response<br>";
return(false);
}
}
}