Merge pull request #96 from euantorano/feature-show-last-ip-on-profile

Show the user’s last IP on profile
This commit is contained in:
Dominik Picheta 2017-03-01 19:05:50 +00:00 committed by GitHub
commit d5892db647

View file

@ -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: