From 0f3892d8a732d965c58a4816ee7253ffda517ac3 Mon Sep 17 00:00:00 2001 From: marcus Date: Thu, 20 Nov 2008 19:05:00 +0000 Subject: Fixes #548: Introducing set_last_login($user_guid). Called from login(), but call from any authentication code where appropriate. git-svn-id: https://code.elgg.org/elgg/trunk@2481 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/sessions.php | 5 ++++- engine/lib/users.php | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'engine/lib') diff --git a/engine/lib/sessions.php b/engine/lib/sessions.php index dda4e960a..7ea650434 100644 --- a/engine/lib/sessions.php +++ b/engine/lib/sessions.php @@ -241,7 +241,10 @@ // Users privilege has been elevated, so change the session id (help prevent session hijacking) session_regenerate_id(); - + + // Update statistics + set_last_login($_SESSION['guid']); + return true; } diff --git a/engine/lib/users.php b/engine/lib/users.php index ee47bf078..e920472c9 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -1256,6 +1256,21 @@ } + /** + * Sets the last logon time of the given user to right now. + * + * @param int $user_guid The user GUID + */ + function set_last_login($user_guid) { + + $user_guid = (int) $user_guid; + global $CONFIG; + $time = time(); + + execute_delayed_write_query("UPDATE {$CONFIG->dbprefix}users_entity set prev_last_login = last_login, last_login = {$time} where guid = {$user_guid}"); + + } + /** * A permissions plugin hook that grants access to users if they are newly created - allows * for email activation. -- cgit v1.2.3