if (getenv(HTTP_X_FORWARDED_FOR)) { $ipaddress = getenv(HTTP_X_FORWARDED_FOR); } else { $ipaddress = getenv(REMOTE_ADDR); }