teox99 ha scritto:sono costretto perche non c'è modo di aprire una pagine web senza incorrere in un permesso negato da parte del server, poi essendo su aruba non posso nè usare bash (wget ecc...) e ne impostare un cron che mi scarichi il file ogni tot...
che ne pensi?
Cioè fopen ti da errore?
perché, ora non ricordo se conviene in termini di download, ma una cosa tipo
$file = fopen("url_del_file", "r" );
e poi usare filemtime() sullo stream potrebbe essere vantaggioso in termini di prestazioni, ma dovresti provare
sul manuale php trovi anche esempi di classi
- Codice: Seleziona tutto
<?php
function filemtime_remote($uri)
{
$uri = parse_url($uri);
$handle = @fsockopen($uri['host'],80);
if(!$handle)
return 0;
fputs($handle,"GET $uri[path] HTTP/1.1\r\nHost: $uri[host]\r\n\r\n");
$result = 0;
while(!feof($handle))
{
$line = fgets($handle,1024);
if(!trim($line))
break;
$col = strpos($line,':');
if($col !== false)
{
$header = trim(substr($line,0,$col));
$value = trim(substr($line,$col+1));
if(strtolower($header) == 'last-modified')
{
$result = strtotime($value);
break;
}
}
}
fclose($handle);
return $result;
}
// echo filemtime_remote('http://www.somesite.com/someimage.jpg');
?>
- Codice: Seleziona tutto
<?php
// get remote file last modification date (returns unix timestamp)
function GetRemoteLastModified( $uri )
{
// default
$unixtime = 0;
$fp = fopen( $uri, "r" );
if( !$fp ) {return;}
$MetaData = stream_get_meta_data( $fp );
foreach( $MetaData['wrapper_data'] as $response )
{
// case: redirection
if( substr( strtolower($response), 0, 10 ) == 'location: ' )
{
$newUri = substr( $response, 10 );
fclose( $fp );
return GetRemoteLastModified( $newUri );
}
// case: last-modified
elseif( substr( strtolower($response), 0, 15 ) == 'last-modified: ' )
{
$unixtime = strtotime( substr($response, 15) );
break;
}
}
fclose( $fp );
return $unixtime;
}
?>