function visitors_get_ip in Visitors 7.0
Same name and namespace in other branches
- 8 visitors.exit.inc \visitors_get_ip()
- 7.2 visitors.exit.inc \visitors_get_ip()
- 7 visitors.exit.inc \visitors_get_ip()
Get visitors ip address.
Return value
A string containing an ip address ('0.0.0.0' on failure).
2 calls to visitors_get_ip()
- visitors_block_user_ip in ./
visitors.block.inc - Display user ip to visitors block.
- visitors_get_ip_str in ./
visitors.exit.inc - Converts a string containing an visitors (IPv4) Internet Protocol dotted address into a proper address.
File
- ./
visitors.exit.inc, line 40 - Implements of hook_exit().
Code
function visitors_get_ip() {
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip_array = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$ip = trim(reset($ip_array));
}
else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return visitors_is_ip_valid($ip) ? $ip : '0.0.0.0';
}