]> git.mjollnir.org Git - moodle.git/commitdiff
New function to get client address
authorpaca70 <paca70>
Sat, 4 Sep 2004 10:54:54 +0000 (10:54 +0000)
committerpaca70 <paca70>
Sat, 4 Sep 2004 10:54:54 +0000 (10:54 +0000)
lib/moodlelib.php

index 2345deaa7d8d772883d7b9e205c70b4f30991dea..701e79c634181ca8afd06833469f2e4c48999a0d 100644 (file)
@@ -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:
 ?>