X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fremote_url.inc;h=0e53dbf466eab1cc32445cd9ca935f1d8c919504;hb=f2343f51b0ed0d9abd2ec98b64f202beb9716d37;hp=fb0c1348fa48c8dbad4bbd38b26729b22615a39c;hpb=56c36285c4c0d22b978552baa0928b8eb3c64a7b;p=fa-stable.git diff --git a/includes/remote_url.inc b/includes/remote_url.inc index fb0c1348..0e53dbf4 100644 --- a/includes/remote_url.inc +++ b/includes/remote_url.inc @@ -19,6 +19,9 @@ function url_get_contents($url, $timeout=10) // get the host name and url path $parsedUrl = parse_url($url); + if (@$parsedUrl['scheme'] == 'file') + return file_get_contents($parsedUrl['path']); + $host = $parsedUrl['host']; if (isset($parsedUrl['path'])) { @@ -60,11 +63,13 @@ function url_get_contents($url, $timeout=10) "Referer: http://$host\r\n\r\n"); // retrieve the response from the remote server - $len =0; + $unblocked=0; + while ($line = fread($fp, 4096)) { $response .= $line; - if ($host=='localhost') + if ($host=='localhost' && !$unblocked++) stream_set_blocking($fp, 0); // just after connection switch to nonblocking mode + usleep(10); } fclose( $fp ); @@ -83,6 +88,8 @@ function url_get_contents($url, $timeout=10) function url_copy($from, $to, $timeout=10) { $f = fopen($to, 'wb'); - fwrite($f, url_get_contents($from, $timeout)); + if (!$f || !fwrite($f, url_get_contents($from, $timeout))) + return false; fclose($f); + return true; }