1// Function to get the client IP address
2function get_client_ip() {
3 $ipaddress = '';
4 if (getenv('HTTP_CLIENT_IP'))
5 $ipaddress = getenv('HTTP_CLIENT_IP');
6 else if(getenv('HTTP_X_FORWARDED_FOR'))
7 $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
8 else if(getenv('HTTP_X_FORWARDED'))
9 $ipaddress = getenv('HTTP_X_FORWARDED');
10 else if(getenv('HTTP_FORWARDED_FOR'))
11 $ipaddress = getenv('HTTP_FORWARDED_FOR');
12 else if(getenv('HTTP_FORWARDED'))
13 $ipaddress = getenv('HTTP_FORWARDED');
14 else if(getenv('REMOTE_ADDR'))
15 $ipaddress = getenv('REMOTE_ADDR');
16 else
17 $ipaddress = 'UNKNOWN';
18 return $ipaddress;
19}