diff options
author | Marc Alexander <admin@m-a-styles.de> | 2014-06-24 11:53:32 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2014-06-24 11:53:32 +0200 |
commit | 5ee1e07e1731cfa58e815c4a805fb188b0986640 (patch) | |
tree | 692b339af30758b82bb5ced926febfadb988a398 | |
parent | 8817b5937747f0b82e180bd3ce7d38b8aa68577e (diff) | |
download | forums-5ee1e07e1731cfa58e815c4a805fb188b0986640.tar forums-5ee1e07e1731cfa58e815c4a805fb188b0986640.tar.gz forums-5ee1e07e1731cfa58e815c4a805fb188b0986640.tar.bz2 forums-5ee1e07e1731cfa58e815c4a805fb188b0986640.tar.xz forums-5ee1e07e1731cfa58e815c4a805fb188b0986640.zip |
[ticket/12755] Change upload in remote_upload() method to fit get_remote_file
PHPBB3-12755
-rw-r--r-- | phpBB/includes/functions_upload.php | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index f4b9262d19..c6e2dddf3d 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -467,7 +467,7 @@ class fileupload var $error_prefix = ''; /** @var int Timeout for remote upload */ - var $upload_timeout = 5; + var $upload_timeout = 6; /** * Init file upload class. @@ -788,9 +788,6 @@ class fileupload return $file; } - // Set a proper timeout for the socket - socket_set_timeout($fsock, $this->upload_timeout); - // Make sure $path not beginning with / if (strpos($path, '/') === 0) { @@ -801,9 +798,12 @@ class fileupload fputs($fsock, "HOST: " . $host . "\r\n"); fputs($fsock, "Connection: close\r\n\r\n"); + // Set a proper timeout for the socket + socket_set_timeout($fsock, $this->upload_timeout); + $get_info = false; $data = ''; - $upload_start = time(); + $timer_stop = time() + $this->upload_timeout; while (!@feof($fsock)) { @@ -821,13 +821,6 @@ class fileupload } $data .= $block; - - // Cancel upload if we exceed timeout - if ((time() - $upload_start) >= $this->upload_timeout) - { - $file = new fileerror($user->lang[$this->error_prefix . 'REMOTE_UPLOAD_TIMEOUT']); - return $file; - } } else { @@ -862,6 +855,15 @@ class fileupload } } } + + $stream_meta_data = stream_get_meta_data($fsock); + + // Cancel upload if we exceed timeout + if (!empty($stream_meta_data['timed_out']) || time() >= $timer_stop) + { + $file = new fileerror($user->lang[$this->error_prefix . 'REMOTE_UPLOAD_TIMEOUT']); + return $file; + } } @fclose($fsock); |