Updated formatting in getremoteaddr, and made add_to_log use it
This commit is contained in:
+3
-1
@@ -2627,7 +2627,7 @@ function instance_is_visible($moduletype, $module) {
|
||||
*/
|
||||
function add_to_log($courseid, $module, $action, $url='', $info='', $cm=0, $user=0) {
|
||||
|
||||
global $db, $CFG, $USER, $REMOTE_ADDR;
|
||||
global $db, $CFG, $USER;
|
||||
|
||||
if ($cm === '') { // postgres won't translate empty string to its default
|
||||
$cm = 0;
|
||||
@@ -2642,6 +2642,8 @@ function add_to_log($courseid, $module, $action, $url='', $info='', $cm=0, $user
|
||||
$userid = empty($USER->id) ? '0' : $USER->id;
|
||||
}
|
||||
|
||||
$REMOTE_ADDR = getremoteaddr();
|
||||
|
||||
$timenow = time();
|
||||
$info = addslashes($info);
|
||||
$url = html_entity_decode($url); // for php < 4.3.0 this is defined in moodlelib.php
|
||||
|
||||
+10
-5
@@ -5535,11 +5535,16 @@ function unzip_show_status ($list,$removepath) {
|
||||
* @return string The remote IP address
|
||||
*/
|
||||
function getremoteaddr() {
|
||||
if (!empty($_SERVER['HTTP_CLIENT_IP'])) $ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
else if(!empty($_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR'];
|
||||
else $ip = false; //just in case
|
||||
return $ip;
|
||||
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
||||
return $_SERVER['HTTP_CLIENT_IP'];
|
||||
}
|
||||
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
return $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
}
|
||||
if (!empty($_SERVER['REMOTE_ADDR'])) {
|
||||
return $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user