projects
/
fa-stable.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Release 2.4.8
[fa-stable.git]
/
includes
/
remote_url.inc
diff --git
a/includes/remote_url.inc
b/includes/remote_url.inc
index fb0c1348fa48c8dbad4bbd38b26729b22615a39c..5c6790aee3f0bc6b03779daf8eecb6cceb0a8e6c 100644
(file)
--- 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);
// 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'])) {
$host = $parsedUrl['host'];
if (isset($parsedUrl['path'])) {
@@
-40,7
+43,6
@@
function url_get_contents($url, $timeout=10)
}
$response = '';
}
$response = '';
-
// connect to the remote server
$fp = @fsockopen($host, $port, $errno, $errstr, $timeout );
if( !$fp ) {
// connect to the remote server
$fp = @fsockopen($host, $port, $errno, $errstr, $timeout );
if( !$fp ) {
@@
-55,18
+57,12
@@
function url_get_contents($url, $timeout=10)
"Accept: */*\r\n" .
"Accept-Language: en-us,en;q=0.5\r\n" .
"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" .
"Accept: */*\r\n" .
"Accept-Language: en-us,en;q=0.5\r\n" .
"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" .
- "Keep-Alive: 300\r\n" .
- "Connection: keep-alive\r\n" .
+ "Connection: close\r\n" .
"Referer: http://$host\r\n\r\n");
// retrieve the response from the remote server
"Referer: http://$host\r\n\r\n");
// retrieve the response from the remote server
- $len =0;
- while ($line = fread($fp, 4096)) {
- $response .= $line;
- if ($host=='localhost')
- stream_set_blocking($fp, 0); // just after connection switch to nonblocking mode
- }
- fclose( $fp );
+
+ $response = stream_get_contents($fp);
if (!strpos($response, "200 OK\r\n"))
return null;
if (!strpos($response, "200 OK\r\n"))
return null;
@@
-83,6
+79,8
@@
function url_get_contents($url, $timeout=10)
function url_copy($from, $to, $timeout=10)
{
$f = fopen($to, 'wb');
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);
fclose($f);
+ return true;
}
}