Is it possible to bypass max time limit?
| From: | Alan McFarlane | Date: | Mon, 28 Jan 2002 02:49:17 +0000 |
| Subject: | Is it possible to bypass max time limit? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-82350@lists.php.net to get a copy of this message | ||
I've got a live script which occasional has to retrieve a file via ftp,
download to the server, post-process it then display it.
I use caching to check to see if I've already got the file, but if I don't I
have to process the ftp_get operation which occasionally times out.
So, is it possible to trap the time limit exceeded error and return a fail
code?
For example:
function GetFileViaFTP( $filename )
{
if (file_exists("cache/" . $filename))
{
return true;
}
$ftp = ftp_connect("some host");
ftp_login($ftp, "some username", "some password");
ftp_chdir($ftp, "some path");
if (ftp_get($ftp, "cache/" . $filename, $filename, FTP_BINARY)) // This
will sometimes fail
{
ftp_quit($ftp);
return true;
}
ftp_quit($ftp);
return false;
}
function GetFile( $filename )
{
if (file_exists("cache/" . $filename) || GetFileViaFTP($cache))
{
return file("cache/" . $filename);
}
return "Sorry, the file {$filename} could not be located";
}