function _httpbl_ip_address in http:BL 5
Backport of Drupal 6's ip_address() function.
4 calls to _httpbl_ip_address()
- httpbl_blacklisted in ./
httpbl.module - Check if an IP should be banned
- httpbl_request_whitelist_submit in ./
httpbl.module - httpbl_request_whitelist_validate in ./
httpbl.module - _httpbl_check in ./
httpbl.module - The actual checking function.
File
- ./
httpbl.module, line 724 - Implementation of http:BL for Drupal. It provides IP-based blacklisting through http:BL and allows linking to a honeypot.
Code
function _httpbl_ip_address() {
static $ip_address = NULL;
if (!isset($ip_address)) {
$ip_address = $_SERVER['REMOTE_ADDR'];
if (variable_get('reverse_proxy', 0) && array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
// If an array of known reverse proxy IPs is provided, then trust
// the XFF header if request really comes from one of them.
$reverse_proxy_addresses = variable_get('reverse_proxy_addresses', array());
if (!empty($reverse_proxy_addresses) && in_array($ip_address, $reverse_proxy_addresses, TRUE)) {
// If there are several arguments, we need to check the most
// recently added one, i.e. the last one.
$ip_address = array_pop(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']));
}
}
}
return $ip_address;
}