function _antispam_api_prepare_request_data in AntiSpam 7
Same name and namespace in other branches
- 6 antispam.module \_antispam_api_prepare_request_data()
Prepare user request data for AntiSpam requests.
Return value
array Relevant information extracted from $_SERVER superglobal.
1 call to _antispam_api_prepare_request_data()
- antispam_api_cmd_comment_check in ./
antispam.module - AntiSpam API: Comment Check.
File
- ./
antispam.module, line 2292 - Primary hook implementations for the Antispam module.
Code
function _antispam_api_prepare_request_data() {
// You may add more elements here, but they are often related to internal
// server data that makes little sense to check whether a comment is spam or
// not. Be sure to not send HTTP_COOKIE as it may compromise your user's
// privacy!
static $safe_to_send = array(
'CONTENT_LENGTH',
'CONTENT_TYPE',
'HTTP_ACCEPT',
'HTTP_ACCEPT_CHARSET',
'HTTP_ACCEPT_ENCODING',
'HTTP_ACCEPT_LANGUAGE',
'HTTP_REFERER',
'HTTP_USER_AGENT',
'REMOTE_ADDR',
'REMOTE_PORT',
'SCRIPT_URI',
'SCRIPT_URL',
'SERVER_ADDR',
'SERVER_NAME',
'REQUEST_METHOD',
'REQUEST_URI',
'SCRIPT_NAME',
);
// The contents of $_SERVER doesn't change between requests, so we can have
// this cached in static storage.
static $server_data;
if (!$server_data) {
$server_data = array();
foreach ($_SERVER as $key => $value) {
if (in_array($key, $safe_to_send)) {
$server_data[$key] = $value;
}
}
}
return $server_data;
}