Forum Moderators: coopster
The below code isnt full version but my question is this..
as it should grab an weather image from another site ,how can i built in a security (or IF statement) that when there's something wrong with the connection that it shows a standerd image..
Because if its waiting for the connectiuon and fails it messes up the place..
Any solution..?
if ( ($difference < $q) AND ($filesize!= 0) )
{ }
elseif ( ($difference > $q) OR ($filesize == 0) )
{
$fc = fopen("cache/latest_radar.png", "wb");
$file = fopen ("http://www.test.com/test.png", "rb");
if (!$file) {
$info = "E";
exit;
}
else
{
while (!feof ($file)) {
$line = fread ($file, 4096);
fwrite($fc,$line);
}
}
fclose($fc);
fclose($file);
$info = "F"; }
If you need fopen() on a URL to timeout, you can do like:
<?php
$timeout = 3;
$old = ini_set('default_socket_timeout', $timeout);
$file = fopen('http://example.com', 'r');
ini_set('default_socket_timeout', $old);
stream_set_timeout($file, $timeout);
stream_set_blocking($file, 0);
//the rest is standard
?>
Hope this helps you
Regards
Michal
When safe_mode is on, PHP checks to see if the owner of the current script matches the owner of the file to be operated on by a file function or its directory.
So the fopen will not work.
More here:
[pl2.php.net...]
Michal