From 9200165c42c6fc4fab7d5f8fee9c87b7e4378327 Mon Sep 17 00:00:00 2001 From: Euan Torano Date: Wed, 1 Mar 2017 18:55:58 +0000 Subject: [PATCH] =?UTF-8?q?Show=20the=20user=E2=80=99s=20last=20IP=20on=20?= =?UTF-8?q?profile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Euan Torano --- forum.nim | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/forum.nim b/forum.nim index e006d7a..7414144 100644 --- a/forum.nim +++ b/forum.nim @@ -69,6 +69,7 @@ type email: string ban: string rank: Rank + lastIp: string ForumError = object of Exception @@ -900,6 +901,10 @@ proc gatherUserInfo(c: var TForumData, nick: string, ui: var TUserInfo): bool = ui.ban = row[2] ui.rank = parseEnum[Rank](row[3]) + const lastIpQuery = sql"select `ip` from `session` where `userid` = ? order by `id` desc limit 1;" + let ipRow = db.getRow(lastIpQuery, $uid) + ui.lastIp = ipRow[0] + include "forms.tmpl" include "main.tmpl" @@ -944,6 +949,12 @@ proc genProfile(c: var TForumData, ui: TUserInfo): string = th("Status"), td($ui.rank) ), + tr( + th(if c.rank >= Moderator: "Last IP" else: ""), + td(if c.rank >= Moderator: + htmlgen.a(href="http://whatismyipaddress.com/ip/" & encodeUrl(ui.lastIp), ui.lastIp) + else: "") + ), tr( th(""), td(if c.rank >= Moderator and c.rank > ui.rank: