aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_admin.php
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2014-03-05 19:07:39 -0600
committerNathan Guse <nathaniel.guse@gmail.com>2014-03-05 19:07:39 -0600
commit8748032866293129b881f9b7f3f0173c1e3a646b (patch)
tree090debb833759376796b060b7c9c29415921f52a /phpBB/includes/functions_admin.php
parent6a8f110b5a28338ac4e48e75c763ea7435192cc7 (diff)
downloadforums-8748032866293129b881f9b7f3f0173c1e3a646b.tar
forums-8748032866293129b881f9b7f3f0173c1e3a646b.tar.gz
forums-8748032866293129b881f9b7f3f0173c1e3a646b.tar.bz2
forums-8748032866293129b881f9b7f3f0173c1e3a646b.tar.xz
forums-8748032866293129b881f9b7f3f0173c1e3a646b.zip
[ticket/9871] Restore get_remote_file
PHPBB3-9871
Diffstat (limited to 'phpBB/includes/functions_admin.php')
-rw-r--r--phpBB/includes/functions_admin.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 7c4f589700..a422d38f67 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -2925,6 +2925,72 @@ function get_database_size()
}
/**
+ * Retrieve contents from remotely stored file
+ */
+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;
+}
+
+/*
* Tidy Warnings
* Remove all warnings which have now expired from the database
* The duration of a warning can be defined by the administrator