From 45c75614853f9efc21cb5d8598a4d4a0863e37e4 Mon Sep 17 00:00:00 2001 From: darthgandalf Date: Sat, 11 Sep 2010 18:52:51 +0000 Subject: [PATCH] Lastseen module embeds info about last login time to webadmin user page. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2130 726aef4b-f618-498e-8847-2d620e286838 --- modules/lastseen.cpp | 18 ++++++++++++++++++ modules/lastseen/tmpl/WebadminUser.tmpl | 9 +++++++++ 2 files changed, 27 insertions(+) create mode 100644 modules/lastseen/tmpl/WebadminUser.tmpl diff --git a/modules/lastseen.cpp b/modules/lastseen.cpp index 15182457..8efcf5eb 100644 --- a/modules/lastseen.cpp +++ b/modules/lastseen.cpp @@ -150,6 +150,24 @@ public: return false; } + + virtual bool OnEmbeddedWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) { + if (sPageName == "webadmin/user" && WebSock.GetSession()->IsAdmin()) { + CUser* pUser = CZNC::Get().FindUser(Tmpl["Username"]); + if (pUser) { + time_t last = GetTime(pUser); + if (last) { + char buf[1024] = {0}; + strftime(buf, sizeof(buf), "%c", localtime(&last)); + Tmpl["LastSeen"] = buf; + } + } + return true; + } + + return false; + } + }; GLOBALMODULEDEFS(CLastSeenMod, "Collects data about when a user last logged in") diff --git a/modules/lastseen/tmpl/WebadminUser.tmpl b/modules/lastseen/tmpl/WebadminUser.tmpl new file mode 100644 index 00000000..6efe21a6 --- /dev/null +++ b/modules/lastseen/tmpl/WebadminUser.tmpl @@ -0,0 +1,9 @@ +
+
+
+
Last login time:
+
" class="half" />
+
+
+
+