PHP interesse |
|
het is eerdee 5 minuten dan 5 seconden(-:
maar dit is mijn code nu:
function remote_file_exists ($domein, $path, $port = 80, $get = false)
{
$path = (substr($path, 0, 1) != '/') ? '/'.$path : $path; $sock = fsockopen($domein, $port, $errno, $errstr, 5); //5s timeout
if (!$sock)
return false;
$cmd = ($get === true) ? "GET ".$path." HTTP/1.1\r\n" : "HEAD ".$path." HTTP/1.1\r\n"; $cmd .= "Host: ".$domein."\r\n"; $cmd .= "Connection: Close\r\n\r\n"; fwrite($sock, $cmd);
$output = NULL; while (!feof($sock))
$output .= fgets($sock, 128);
fclose($sock);
if(preg_match('#200#', $output))
return true;
else
return false;
}
echo remote_file_exists('sitemasters.be', 'forum/1/25110')
?>
function remote_file_exists ($domein, $path, $port = 80, $get = false) { $path = (substr($path, 0, 1) != '/') ? '/'.$path : $path; $sock = fsockopen($domein, $port, $errno, $errstr, 5); //5s timeout if (!$sock) return false; $cmd = ($get === true) ? "GET ".$path." HTTP/1.1\r\n" : "HEAD ".$path." HTTP/1.1\r\n"; $cmd .= "Host: ".$domein."\r\n"; $cmd .= "Connection: Close\r\n\r\n"; fwrite($sock, $cmd); $output = NULL; while (!feof($sock)) $output .= fgets($sock, 128); return true; else return false; } echo remote_file_exists ('sitemasters.be', 'forum/1/25110') ?>
|