diff options
author | Igor Wiedler <igor@wiedler.ch> | 2011-07-13 19:20:16 +0200 |
---|---|---|
committer | Igor Wiedler <igor@wiedler.ch> | 2011-07-15 22:34:24 +0200 |
commit | 0bf6966c5228d446c4f0d3862619db0f619c7369 (patch) | |
tree | 3f8adfb570262a9296e7a4fdb191804bfde7a4c0 /phpBB/includes/questionnaire | |
parent | 09e0460e5b53f83f4c06703c8bd8f1cb0f22eb48 (diff) | |
download | forums-0bf6966c5228d446c4f0d3862619db0f619c7369.tar forums-0bf6966c5228d446c4f0d3862619db0f619c7369.tar.gz forums-0bf6966c5228d446c4f0d3862619db0f619c7369.tar.bz2 forums-0bf6966c5228d446c4f0d3862619db0f619c7369.tar.xz forums-0bf6966c5228d446c4f0d3862619db0f619c7369.zip |
[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
Diffstat (limited to 'phpBB/includes/questionnaire')
-rw-r--r-- | phpBB/includes/questionnaire/questionnaire.php | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php index b9231547cd..ed61cf82d0 100644 --- a/phpBB/includes/questionnaire/questionnaire.php +++ b/phpBB/includes/questionnaire/questionnaire.php @@ -148,23 +148,15 @@ class phpbb_questionnaire_system_data_provider */ function get_data() { - // Start discovering the IPV4 server address, if available - $server_address = '0.0.0.0'; - - if (!empty($_SERVER['SERVER_ADDR'])) - { - $server_address = $_SERVER['SERVER_ADDR']; - } + global $request; - // Running on IIS? - if (!empty($_SERVER['LOCAL_ADDR'])) - { - $server_address = $_SERVER['LOCAL_ADDR']; - } + // Start discovering the IPV4 server address, if available + // Try apache, IIS, fall back to 0.0.0.0 + $server_address = $request->server('SERVER_ADDR', $request->server('LOCAL_ADDR', '0.0.0.0')); return array( 'os' => PHP_OS, - 'httpd' => $_SERVER['SERVER_SOFTWARE'], + 'httpd' => $request->server('SERVER_SOFTWARE'), // we don't want the real IP address (for privacy policy reasons) but only // a network address to see whether your installation is running on a private or public network. 'private_ip' => $this->is_private_ip($server_address), @@ -482,7 +474,7 @@ class phpbb_questionnaire_phpbb_data_provider } } - global $db; + global $db, $request; $result['dbms'] = $dbms; $result['acm_type'] = $acm_type; @@ -492,7 +484,7 @@ class phpbb_questionnaire_phpbb_data_provider // Try to get user agent vendor and version $match = array(); - $user_agent = (!empty($_SERVER['HTTP_USER_AGENT'])) ? (string) $_SERVER['HTTP_USER_AGENT'] : ''; + $user_agent = $request->header('User-Agent'); $agents = array('firefox', 'msie', 'opera', 'chrome', 'safari', 'mozilla', 'seamonkey', 'konqueror', 'netscape', 'gecko', 'navigator', 'mosaic', 'lynx', 'amaya', 'omniweb', 'avant', 'camino', 'flock', 'aol'); // We check here 1 by 1 because some strings occur after others (for example Mozilla [...] Firefox/) |