1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[feature/request-class] Add server(), header() and is_ajax() to request

Extend the request class with helpers for reading server vars (server())
and HTTP request headers (header()). Refactor the existing code base
to make use of these helpers, make $_SERVER a deactivated super global.

Also introduce an is_ajax() method, which checks the X-Requested-With
header for the value 'XMLHttpRequest', which is sent by JavaScript
libraries, such as jQuery.

PHPBB3-9716
This commit is contained in:
Igor Wiedler
2011-07-13 19:20:16 +02:00
parent 09e0460e5b
commit 0bf6966c52
23 changed files with 318 additions and 152 deletions

View File

@@ -27,8 +27,12 @@ class phpbb_security_extract_current_page_test extends phpbb_security_test_base
*/
public function test_query_string_php_self($url, $query_string, $expected)
{
$_SERVER['PHP_SELF'] = $url;
$_SERVER['QUERY_STRING'] = $query_string;
global $request;
$request->merge(phpbb_request_interface::SERVER, array(
'PHP_SELF' => $url,
'QUERY_STRING' => $query_string,
));
$result = session::extract_current_page('./');
@@ -41,8 +45,12 @@ class phpbb_security_extract_current_page_test extends phpbb_security_test_base
*/
public function test_query_string_request_uri($url, $query_string, $expected)
{
$_SERVER['REQUEST_URI'] = $url . '?' . $query_string;
$_SERVER['QUERY_STRING'] = $query_string;
global $request;
$request->merge(phpbb_request_interface::SERVER, array(
'PHP_SELF' => $url,
'QUERY_STRING' => $query_string,
));
$result = session::extract_current_page('./');