From a4a0264df6b3ec40a0bc52c7fabc9b9cd4a88975 Mon Sep 17 00:00:00 2001 From: Martin Dougiamas Date: Thu, 20 May 2010 02:42:18 +0000 Subject: [PATCH] MDL-19628 Store 0.0.0.0 in user table and log tables if IP address can't be found. I didn't change getremoteaddr in 1.9. --- lib/datalib.php | 3 +++ lib/moodlelib.php | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/lib/datalib.php b/lib/datalib.php index dd562022429..af096d4baf3 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -1992,6 +1992,9 @@ function user_accesstime_log($courseid=0) { if (defined('MDL_PERFDB')) { global $PERF ; $PERF->dbqueries++;}; $remoteaddr = getremoteaddr(); + if (empty($remoteaddr)) { + $remoteaddr = '0.0.0.0'; + } if ($db->Execute("UPDATE {$CFG->prefix}user SET lastip = '$remoteaddr', lastaccess = $timenow WHERE id = $USER->id")) { diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 69a6d5b5545..b86ef8cca76 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2968,6 +2968,9 @@ function create_user_record($username, $password, $auth='manual') { } $newuser->confirmed = 1; $newuser->lastip = getremoteaddr(); + if (empty($newuser->lastip)) { + $newuser->lastip = '0.0.0.0'; + } $newuser->timemodified = time(); $newuser->mnethostid = $CFG->mnet_localhost_id; @@ -3137,6 +3140,9 @@ function guest_user() { $newuser->confirmed = 1; $newuser->lang = $CFG->lang; $newuser->lastip = getremoteaddr(); + if (empty($newuser->lastip)) { + $newuser->lastip = '0.0.0.0'; + } } return $newuser;