From: paca70 Date: Sat, 4 Sep 2004 10:54:54 +0000 (+0000) Subject: New function to get client address X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f97ab1ec36adfcb7989b960828673603035b17fc;p=moodle.git New function to get client address --- diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 2345deaa7d..701e79c634 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2945,6 +2945,14 @@ function mtrace($string, $eol="\n") { flush(); } +function getremoteaddr() { +//Returns most reliable client address + if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP"); + else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR"); + else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR"); + else $ip = false; //just in case + return $ip; +} // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140: ?>