Podałem już to w sekcji dla początkujących - może tutaj ktoś odpowie.
"Znalazlem cos takiego i dziala. Jeszcze tylko jedna sprawa - jak wyciagnac date takiego sprawdzanego pliku"
<?php
echo \"<table align=\"center\\"> <tr><td><br><b>http://10.<font style=\"color: red\">\";
echo \"</font>.0.25/dbindex.cpt</b><br></td></tr> </table>\";
echo \"<table width=\"100%\\" border=1><tr><td>\";
function remote_file_exists($url)
{
$head = '';
if (isset ($url_p['host'])) { $host = $url_p['host']; }
else
{
return '1 Invalid URL host';
}
if (isset ($url_p['path'])) { $path = $url_p['path']; }
else
{ $path = ''; }
$fp = fsockopen ($host, 81
, $errno, $errstr, 20
); if (!$fp)
{
return '2 Unable to connect to remote host';
}
else
{
$host = $parse['host'];
fputs($fp, 'HEAD '.$url.\" HTTP/1.1rn\"); fputs($fp, 'HOST: '.$host.\"rn\"); fputs($fp, \"Connection: closernrn\"); $headers = '';
{ $headers .= fgets ($fp, 128
); } }
// for debug
//echo nl2br($headers);
$arr_headers = explode(\"n\", $headers); if (isset ($arr_headers[0
])) { if(strpos ($arr_headers[0], '200') !== false) { return true; }
if( (strpos ($arr_headers[0], '404') !== false) || (strpos ($arr_headers[0], '410') !== false)) { return false; }
if( (strpos ($arr_headers[0], '301') !== false) || (strpos ($arr_headers[0], '302') !== false)) {
preg_match(\"/Location:s*(.+)r/i\", $headers, $matches); return false;
$nextloc = $matches[1];
return remote_file_exists($nextloc);
}
}
preg_match('/HTTP.*(ddd.*)r/i', $headers, $matches); return '3 Status Code not supported'.
(isset($matches[1])?
\": $matches[1]\":''); }
// sample code
$urls[] = \"http://10.1.0.25/dbindex.cpt\";
$urls[] = \"http://10.2.0.25/dbindex.cpt\";
foreach($urls as $url) {
echo \"<table width=\"100%\\" border=1 style=\"font-size:11px; font-family: verdana; border-collapse: collapse;border: 0px solid red;\"><tr><td width=\"250\"></b><b>$url</b> - </td>\"; $ret = remote_file_exists($url);
$filename = '$url';
if ($ret===true)
{
//$filemod = filemtime($urls);
//$filemodtime = date(\"d m y\", $filemod);
//$tTime=$urls[0];
//$tTime=date(\"d m y\", $tTime);
// echo \" $tTime<BR>\";
//echo \"<td>\". $filemodtime.\"</td>\";
//echo $filename . ': ' . filesize($filename) . ' bytes';
echo \"<td>plik istnieje!</td>\"; } elseif ($ret===false)
{ echo \"<td><font color=\"#FF0000\">plik nie istnieje!</font></td>\"; } else
{
echo \"<td>error code: \".$ret.\"</td><td></td></tr></table>\";
}
}
echo \"</td></tr></table>\"; ?>
Please helpnijcie cosik!!!