Posted By
mladoux on 09/22/10
Tagged
php security utility ip proxy
Versions (? )
12/25/10 10:54am 10/11/10 04:24pm 10/11/10 04:18pm 09/22/10 12:25am
Who likes this? 1 person have marked this snippet as a favorite
roli000
get_ip
URL: http://mark.haktstudios.com/
A simple IP address utility that first attempts to get the users IP via X_FORWARDED_FOR headers, and if they are not available, then resorts to the TCP/IP stack.
Copy this code and paste it in your HTML
/**
* get_ip()
*
* Attempts to retrieve the most accurate IP address possible.
*
* @return string - best IP address guess.
*/
function get_ip( )
{
if ( isset ( $_SERVER [ 'X_FORWARDED_FOR' ] ) ) // fixed typo
else return $_SERVER [ 'REMOTE_ADDR' ] ;
}
Report this snippet