function getIP() { if( isset($_SERVER) ) { if( isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ) { $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } elseif ( isset($_SERVER["HTTP_CLIENT_IP"]) ) { $ip = $_SERVER["HTTP_CLIENT_IP"]; } elseif ( isset($_SERVER["REMOTE_ADDR"]) ) { $ip = $_SERVER["REMOTE_ADDR"]; } else { $ip = $_SERVER["SSH_CLIENT"]; } } else { if( getenv("HTTP_X_FORWARDED_FOR") ) { $ip = getenv("HTTP_X_FORWARDED_FOR"); } elseif ( getenv("HTTP_CLIENT_IP") ) { $ip = getenv("HTTP_CLIENT_IP"); } else { $ip = getenv("REMOTE_ADDR"); } } return $ip; }