//获得提交者的IP地址 function getIp() { $ip = ‘Unknown‘; if(isset($_SERVER[‘HTTP_X_FORWARDED_FOR‘])) $ip = $_SERVER [‘HTTP_X_FORWARDED_FOR‘]; else if(getenv(‘HTTP_X_FORWARDED_FOR‘)) $ip = getenv(‘HTTP_X_FORWARDED_FOR‘); if (isset($_SERVER[‘HTTP_CLIENT_IP‘])) $ip = $_SERVER[‘HTTP_CLIENT_IP‘]; else if (getenv(‘HTTP_CLIENT_IP‘)) $ip = getenv(‘HTTP_CLIENT_IP‘); if (isset ($_SERVER[‘REMOTE_ADDR‘])) $ip = $_SERVER[‘REMOTE_ADDR‘]; else if (getenv(‘REMOTE_ADDR‘)) $ip = getenv(‘REMOTE_ADDR‘); return addslashes($ip); }
时间: 2024-11-14 12:50:02