note 51843 deleted from function.fopen by nlopess

From: Date: Wed, 13 Apr 2005 18:23:52 +0000
Subject: note 51843 deleted from function.fopen by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-87964@lists.php.net to get a copy of this message
Note Submitter: theo at oracle dot 2question dot com Reason: useless ---- here a suggestion for a time out when using a url. in stead of using fopen en fread with pcntl (if compiled within your php), it is easier to use the curl function available on linux distributions. example: function saveURL2Disk($url, $filename) { // the microtime_float function is defined on the php website $start=microtime_float(); // the timeout in seconds $timeout=10; // a system call to the curl function (see man curl) $res=system("curl -m $timeout $url > $filename", $retVal); $end=microtime_float(); $duration=$end-$start; if ($duration < $timeout) $filesize=filesize($filename); else $filesize=0; // the returning filesize could be used as an identifier for succesful download return $filesize; } $filesize=saveURL2Disk('http://www.2question.com/index.html', '/tmp/out.html') kind regards, theo theunissen

« previous php.notes (#87964) next »