From d13ef2fbdcd0e22749598d65f3b1c88965a2798f Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Tue, 18 Apr 2006 22:40:56 +0000 Subject: [PATCH] mod/chat - cope with missing $USER->lastIP $USER->lastIP is sometimes not set properly during login, fetch it if we can or error out clearly -- we won't be able to login the user to the chat if we don't have an IP address to match him/her against. --- mod/chat/lib.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mod/chat/lib.php b/mod/chat/lib.php index 30d7f2d785..12c4c5a51b 100644 --- a/mod/chat/lib.php +++ b/mod/chat/lib.php @@ -385,6 +385,16 @@ function chat_login_user($chatid, $version, $groupid, $course) { $chatuser->lastping = time(); $chatuser->lang = current_language(); + // Sometimes $USER->lastIP is not setup properly + // during login. Update with current value if possible + // or error out clearly. + if (empty($chatuser->ip)) { + $chatuser->ip = getremoteaddr(); + if (empty($chatuser->ip)) { + error("Cannot determine the IP address of the user!"); + } + } + if (($chatuser->course != $course->id) or ($chatuser->userid != $USER->id)) { return false; -- 2.39.5