mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Merge remote-tracking branch 'github-bantu/ticket/10278' into develop-olympus
* github-bantu/ticket/10278: [ticket/10278] Show VERSIONCHECK_FAIL instead of FSOCK_TIMEOUT. [ticket/10278] Also timeout when receiving data over a slow connection. [ticket/10278] Decrease default timeout of get_remote_file() to 6 seconds. [ticket/10278] Return with a timeout error when fread() or fgets() time out. [ticket/10278] Also set timeout on stream in get_remote_file().
This commit is contained in:
commit
dda1e13126
3 changed files with 14 additions and 2 deletions
|
@ -37,7 +37,7 @@ class acp_update
|
||||||
$errstr = '';
|
$errstr = '';
|
||||||
$errno = 0;
|
$errno = 0;
|
||||||
|
|
||||||
$info = obtain_latest_version_info(request_var('versioncheck_force', false), true);
|
$info = obtain_latest_version_info(request_var('versioncheck_force', false));
|
||||||
|
|
||||||
if ($info === false)
|
if ($info === false)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3130,7 +3130,7 @@ function get_database_size()
|
||||||
/**
|
/**
|
||||||
* Retrieve contents from remotely stored file
|
* Retrieve contents from remotely stored file
|
||||||
*/
|
*/
|
||||||
function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port = 80, $timeout = 10)
|
function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port = 80, $timeout = 6)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
@ -3140,6 +3140,9 @@ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port
|
||||||
@fputs($fsock, "HOST: $host\r\n");
|
@fputs($fsock, "HOST: $host\r\n");
|
||||||
@fputs($fsock, "Connection: close\r\n\r\n");
|
@fputs($fsock, "Connection: close\r\n\r\n");
|
||||||
|
|
||||||
|
$timer_stop = time() + $timeout;
|
||||||
|
stream_set_timeout($fsock, $timeout);
|
||||||
|
|
||||||
$file_info = '';
|
$file_info = '';
|
||||||
$get_info = false;
|
$get_info = false;
|
||||||
|
|
||||||
|
@ -3162,6 +3165,14 @@ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port
|
||||||
return false;
|
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);
|
@fclose($fsock);
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,6 +200,7 @@ $lang = array_merge($lang, array(
|
||||||
'FORUM_RULES_LINK' => 'Please click here to view the forum rules',
|
'FORUM_RULES_LINK' => 'Please click here to view the forum rules',
|
||||||
'FROM' => 'from',
|
'FROM' => 'from',
|
||||||
'FSOCK_DISABLED' => 'The operation could not be completed because the <var>fsockopen</var> function has been disabled or the server being queried could not be found.',
|
'FSOCK_DISABLED' => 'The operation could not be completed because the <var>fsockopen</var> function has been disabled or the server being queried could not be found.',
|
||||||
|
'FSOCK_TIMEOUT' => 'A timeout occurred while reading from the network stream.',
|
||||||
|
|
||||||
'FTP_FSOCK_HOST' => 'FTP host',
|
'FTP_FSOCK_HOST' => 'FTP host',
|
||||||
'FTP_FSOCK_HOST_EXPLAIN' => 'FTP server used to connect your site.',
|
'FTP_FSOCK_HOST_EXPLAIN' => 'FTP server used to connect your site.',
|
||||||
|
|
Loading…
Add table
Reference in a new issue