function CleantalkGetIP in Anti Spam by CleanTalk 7.2
1 call to CleantalkGetIP()
- cleantalk_boot in ./
cleantalk.module - Implements hook_boot()
File
- ./
cleantalk.module, line 2560 - Main CleanTalk integration module functions.
Code
function CleantalkGetIP() {
$result = array();
if (function_exists('apache_request_headers')) {
$headers = apache_request_headers();
}
else {
$headers = $_SERVER;
}
if (array_key_exists('X-Forwarded-For', $headers)) {
$the_ip = explode(",", trim($headers['X-Forwarded-For']));
$result[] = trim($the_ip[0]);
}
if (array_key_exists('HTTP_X_FORWARDED_FOR', $headers)) {
$the_ip = explode(",", trim($headers['HTTP_X_FORWARDED_FOR']));
$result[] = trim($the_ip[0]);
}
$result[] = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
if (isset($_GET['sfw_test_ip'])) {
$result[] = $_GET['sfw_test_ip'];
}
return $result;
}