diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-11-22 15:42:37 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-11-22 15:42:37 +0100 |
commit | fd993cbaf26cea66fc72c2a744189d7c1fef843c (patch) | |
tree | 8735e78d0b8171e233821a80f933ccf5be0195a4 /phpBB/includes/functions_admin.php | |
parent | 8b711038368bc0a52d1b532a2f1b7c8c45ac2d0a (diff) | |
parent | f3ae5e4cb2cf1f3db1d2b8e2a34e234845712efe (diff) | |
download | forums-fd993cbaf26cea66fc72c2a744189d7c1fef843c.tar forums-fd993cbaf26cea66fc72c2a744189d7c1fef843c.tar.gz forums-fd993cbaf26cea66fc72c2a744189d7c1fef843c.tar.bz2 forums-fd993cbaf26cea66fc72c2a744189d7c1fef843c.tar.xz forums-fd993cbaf26cea66fc72c2a744189d7c1fef843c.zip |
Merge pull request #3157 from marc1706/ticket/13358
[ticket/13358] Add class for retrieving remote file data
Diffstat (limited to 'phpBB/includes/functions_admin.php')
-rw-r--r-- | phpBB/includes/functions_admin.php | 65 |
1 files changed, 9 insertions, 56 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 5ddaf31cf5..0b9ea23fe7 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2982,68 +2982,21 @@ function get_database_size() /** * Retrieve contents from remotely stored file +* +* @deprecated 3.1.2 Use file_downloader instead */ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port = 80, $timeout = 6) { - global $user; - - if ($fsock = @fsockopen($host, $port, $errno, $errstr, $timeout)) - { - @fputs($fsock, "GET $directory/$filename HTTP/1.0\r\n"); - @fputs($fsock, "HOST: $host\r\n"); - @fputs($fsock, "Connection: close\r\n\r\n"); + global $phpbb_container; - $timer_stop = time() + $timeout; - stream_set_timeout($fsock, $timeout); - - $file_info = ''; - $get_info = false; - - while (!@feof($fsock)) - { - if ($get_info) - { - $file_info .= @fread($fsock, 1024); - } - else - { - $line = @fgets($fsock, 1024); - if ($line == "\r\n") - { - $get_info = true; - } - else if (stripos($line, '404 not found') !== false) - { - $errstr = $user->lang('FILE_NOT_FOUND', $filename); - return false; - } - } + // Get file downloader and assign $errstr and $errno + $file_downloader = $phpbb_container->get('file_downloader'); - $stream_meta_data = stream_get_meta_data($fsock); - - if (!empty($stream_meta_data['timed_out']) || time() >= $timer_stop) - { - $errstr = $user->lang['FSOCK_TIMEOUT']; - return false; - } - } - @fclose($fsock); - } - else - { - if ($errstr) - { - $errstr = utf8_convert_message($errstr); - return false; - } - else - { - $errstr = $user->lang['FSOCK_DISABLED']; - return false; - } - } + $file_data = $file_downloader->get($host, $directory, $filename, $port, $timeout); + $errstr = $file_downloader->get_error_string(); + $errno = $file_downloader->get_error_number(); - return $file_info; + return $file_data; } /* |