From ecf7d911c95935f8cfb2403f645cd12f93d8c3f5 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sun, 18 Mar 2018 18:13:51 +0000 Subject: [PATCH] Added last access handling. --- WEB-INF/lib/common.lib.php | 4 +++- WEB-INF/lib/ttUserHelper.class.php | 9 +++++++++ WEB-INF/templates/footer.tpl | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/WEB-INF/lib/common.lib.php b/WEB-INF/lib/common.lib.php index 69c38b73..3dce388f 100644 --- a/WEB-INF/lib/common.lib.php +++ b/WEB-INF/lib/common.lib.php @@ -340,8 +340,10 @@ function ttAccessAllowed($required_right) } // Check if user has the right. - if (in_array($required_right, $user->rights)) + if (in_array($required_right, $user->rights)) { + ttUserHelper::updateLastAccess(); return true; + } return false; } diff --git a/WEB-INF/lib/ttUserHelper.class.php b/WEB-INF/lib/ttUserHelper.class.php index bd4570a5..9513a721 100644 --- a/WEB-INF/lib/ttUserHelper.class.php +++ b/WEB-INF/lib/ttUserHelper.class.php @@ -474,4 +474,13 @@ class ttUserHelper { } return true; } + + // updateLastAccess - updates last access info for user in db. + static function updateLastAccess() { + global $user; + $mdb2 = getConnection(); + $accessed_ip = $mdb2->quote($_SERVER['REMOTE_ADDR']); + $sql = "update tt_users set accessed = now(), accessed_ip = $accessed_ip where id = $user->id"; + $mdb2->exec($sql); + } } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 7bfc132b..3c74775c 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.54.4102 | Copyright © Anuko | +  Anuko Time Tracker 1.17.55.4103 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1