function getRealIp() { if (isset($_SERVER["HTTP_X_REAL_IP"])) { return $_SERVER["HTTP_X_REAL_IP"]; } elseif (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { return preg_replace('/^.+,\s*/', '', $_SERVER["HTTP_X_FORWARDED_FOR"]); } else { return $_SERVER["REMOTE_ADDR"]; } }