diff options
| author | Nathan Guse <nathaniel.guse@gmail.com> | 2014-02-19 16:11:40 -0600 |
|---|---|---|
| committer | Nathan Guse <nathaniel.guse@gmail.com> | 2014-02-19 16:13:23 -0600 |
| commit | 6c8589775b8df2b6fbeffbe594d9279ae90e85ba (patch) | |
| tree | 170b26bd86dce0eeb7d6c447115f6810ced34bc2 /phpBB/includes/functions_compatibility.php | |
| parent | bd8951cfbec799f685eb89f14a83933cee647112 (diff) | |
| download | forums-6c8589775b8df2b6fbeffbe594d9279ae90e85ba.tar forums-6c8589775b8df2b6fbeffbe594d9279ae90e85ba.tar.gz forums-6c8589775b8df2b6fbeffbe594d9279ae90e85ba.tar.bz2 forums-6c8589775b8df2b6fbeffbe594d9279ae90e85ba.tar.xz forums-6c8589775b8df2b6fbeffbe594d9279ae90e85ba.zip | |
[ticket/9871] Update version check file to use json format
PHPBB3-9871
Diffstat (limited to 'phpBB/includes/functions_compatibility.php')
| -rw-r--r-- | phpBB/includes/functions_compatibility.php | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/phpBB/includes/functions_compatibility.php b/phpBB/includes/functions_compatibility.php index 2197815087..2bd812efe0 100644 --- a/phpBB/includes/functions_compatibility.php +++ b/phpBB/includes/functions_compatibility.php @@ -48,3 +48,71 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $ return phpbb_get_avatar($row, $alt, $ignore_config); } + +/** + * Retrieve contents from remotely stored file + * + * @deprecated 3.1.0-a4 (To be removed: 3.3.0) + */ +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"); + + $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; + } + } + + $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; + } + } + + return $file_info; +} |
