mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 13:30:25 +02:00
Merge remote-tracking branch 'upstream/develop' into ticket/11015
* upstream/develop: (196 commits) [ticket/11219] Coding guidelines and naming consistency changes [ticket/10841] Revert more whitespace changes. [ticket/10841] Revert whitespace changes. [ticket/10841] adding space after if [ticket/10841] removing unnecessary spacing [ticket/10841] changing affectedrows check to COUNT in sql [ticket/10841] Modifying style and language selectors in UCP [ticket/11247] Fix wrong property reference in flock class. [ticket/10602] Avoid a race condition. [ticket/10602] Use last_queue_run for its intended purpose. [ticket/10716] Collect standard error from executed php process. [ticket/10716] Skip test if php is not in PATH. [ticket/10716] Exclude our dependencies from linting. [ticket/10103] New and improved wording. [ticket/10716] Only lint on php 5.3+. [ticket/10103] Assert with messages. [ticket/10103] assertLessThan/assertGreaterThan. [ticket/10103] Inline assignment is bad? [ticket/10103] $rv had too few characters. [ticket/10103] Correct flock class documentation. ... Conflicts: phpBB/includes/functions.php tests/cache/cache_test.php
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
@@ -229,7 +231,8 @@ function phpbb_gmgetdate($time = false)
|
||||
/**
|
||||
* Return formatted string for filesizes
|
||||
*
|
||||
* @param int $value filesize in bytes
|
||||
* @param mixed $value filesize in bytes
|
||||
* (non-negative number; int, float or string)
|
||||
* @param bool $string_only true if language string should be returned
|
||||
* @param array $allowed_units only allow these units (data array indexes)
|
||||
*
|
||||
@@ -241,6 +244,12 @@ function get_formatted_filesize($value, $string_only = true, $allowed_units = fa
|
||||
global $user;
|
||||
|
||||
$available_units = array(
|
||||
'tb' => array(
|
||||
'min' => 1099511627776, // pow(2, 40)
|
||||
'index' => 4,
|
||||
'si_unit' => 'TB',
|
||||
'iec_unit' => 'TIB',
|
||||
),
|
||||
'gb' => array(
|
||||
'min' => 1073741824, // pow(2, 30)
|
||||
'index' => 3,
|
||||
@@ -2847,12 +2856,10 @@ function meta_refresh($time, $url, $disable_cd_check = false)
|
||||
*
|
||||
* @param int $code HTTP status code
|
||||
* @param string $message Message for the status code
|
||||
* @return void
|
||||
* @return null
|
||||
*/
|
||||
function send_status_line($code, $message)
|
||||
{
|
||||
global $request;
|
||||
|
||||
if (substr(strtolower(@php_sapi_name()), 0, 3) === 'cgi')
|
||||
{
|
||||
// in theory, we shouldn't need that due to php doing it. Reality offers a differing opinion, though
|
||||
@@ -2860,18 +2867,35 @@ function send_status_line($code, $message)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($request->server('SERVER_PROTOCOL'))
|
||||
{
|
||||
$version = $request->server('SERVER_PROTOCOL');
|
||||
}
|
||||
else
|
||||
{
|
||||
$version = 'HTTP/1.0';
|
||||
}
|
||||
$version = phpbb_request_http_version();
|
||||
header("$version $code $message", true, $code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTTP version used in the current request.
|
||||
*
|
||||
* Handles the case of being called before $request is present,
|
||||
* in which case it falls back to the $_SERVER superglobal.
|
||||
*
|
||||
* @return string HTTP version
|
||||
*/
|
||||
function phpbb_request_http_version()
|
||||
{
|
||||
global $request;
|
||||
|
||||
if ($request && $request->server('SERVER_PROTOCOL'))
|
||||
{
|
||||
return $request->server('SERVER_PROTOCOL');
|
||||
}
|
||||
else if (isset($_SERVER['SERVER_PROTOCOL']))
|
||||
{
|
||||
return $_SERVER['SERVER_PROTOCOL'];
|
||||
}
|
||||
|
||||
return 'HTTP/1.0';
|
||||
}
|
||||
|
||||
//Form validation
|
||||
|
||||
|
||||
@@ -4771,7 +4795,7 @@ function phpbb_get_plural_form($rule, $number)
|
||||
*
|
||||
* @param array $param Parameter array, see $param_defaults array.
|
||||
*
|
||||
* @return void
|
||||
* @return null
|
||||
*/
|
||||
function phpbb_http_login($param)
|
||||
{
|
||||
@@ -5209,8 +5233,12 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
|
||||
|
||||
/**
|
||||
* Generate page footer
|
||||
*
|
||||
* @param bool $run_cron Whether or not to run the cron
|
||||
* @param bool $display_template Whether or not to display the template
|
||||
* @param bool $exit_handler Whether or not to run the exit_handler()
|
||||
*/
|
||||
function page_footer($run_cron = true)
|
||||
function page_footer($run_cron = true, $display_template = true, $exit_handler = true)
|
||||
{
|
||||
global $db, $config, $template, $user, $auth, $cache, $starttime, $phpbb_root_path, $phpEx;
|
||||
global $request, $phpbb_dispatcher;
|
||||
@@ -5305,10 +5333,17 @@ function page_footer($run_cron = true)
|
||||
}
|
||||
}
|
||||
|
||||
$template->display('body');
|
||||
if ($display_template)
|
||||
{
|
||||
$template->display('body');
|
||||
}
|
||||
|
||||
garbage_collection();
|
||||
exit_handler();
|
||||
|
||||
if ($exit_handler)
|
||||
{
|
||||
exit_handler();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5326,7 +5361,10 @@ function garbage_collection()
|
||||
* @event core.garbage_collection
|
||||
* @since 3.1-A1
|
||||
*/
|
||||
$phpbb_dispatcher->dispatch('core.garbage_collection');
|
||||
if (!empty($phpbb_dispatcher))
|
||||
{
|
||||
$phpbb_dispatcher->dispatch('core.garbage_collection');
|
||||
}
|
||||
|
||||
// Unload cache, must be done before the DB connection if closed
|
||||
if (!empty($cache))
|
||||
@@ -5433,3 +5471,49 @@ function phpbb_convert_30_dbms_to_31($dbms)
|
||||
|
||||
throw new \RuntimeException("You have specified an invalid dbms driver: $dbms");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Symfony Request object from phpbb_request object
|
||||
*
|
||||
* @param phpbb_request $request Request object
|
||||
* @return Request A Symfony Request object
|
||||
*/
|
||||
function phpbb_create_symfony_request(phpbb_request $request)
|
||||
{
|
||||
// This function is meant to sanitize the global input arrays
|
||||
$sanitizer = function(&$value, $key) {
|
||||
$type_cast_helper = new phpbb_request_type_cast_helper();
|
||||
$type_cast_helper->set_var($value, $value, gettype($value), true);
|
||||
};
|
||||
|
||||
// We need to re-enable the super globals so we can access them here
|
||||
$request->enable_super_globals();
|
||||
$get_parameters = $_GET;
|
||||
$post_parameters = $_POST;
|
||||
$server_parameters = $_SERVER;
|
||||
$files_parameters = $_FILES;
|
||||
$cookie_parameters = $_COOKIE;
|
||||
// And now disable them again for security
|
||||
$request->disable_super_globals();
|
||||
|
||||
array_walk_recursive($get_parameters, $sanitizer);
|
||||
array_walk_recursive($post_parameters, $sanitizer);
|
||||
|
||||
// Until we fix the issue with relative paths, we have to fake path info
|
||||
// to allow urls like app.php?controller=foo/bar
|
||||
$controller = $request->variable('controller', '');
|
||||
$path_info = '/' . $controller;
|
||||
$request_uri = $server_parameters['REQUEST_URI'];
|
||||
|
||||
// Remove the query string from REQUEST_URI
|
||||
if ($pos = strpos($request_uri, '?'))
|
||||
{
|
||||
$request_uri = substr($request_uri, 0, $pos);
|
||||
}
|
||||
|
||||
// Add the path info (i.e. controller route) to the REQUEST_URI
|
||||
$server_parameters['REQUEST_URI'] = $request_uri . $path_info;
|
||||
$server_parameters['SCRIPT_NAME'] = '';
|
||||
|
||||
return new Request($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters);
|
||||
}
|
||||
|
Reference in New Issue
Block a user