Show the user’s last IP on profile
Signed-off-by: Euan Torano <euantorano@gmail.com>
This commit is contained in:
parent
c722234594
commit
9200165c42
1 changed files with 11 additions and 0 deletions
11
forum.nim
11
forum.nim
|
|
@ -69,6 +69,7 @@ type
|
||||||
email: string
|
email: string
|
||||||
ban: string
|
ban: string
|
||||||
rank: Rank
|
rank: Rank
|
||||||
|
lastIp: string
|
||||||
|
|
||||||
ForumError = object of Exception
|
ForumError = object of Exception
|
||||||
|
|
||||||
|
|
@ -900,6 +901,10 @@ proc gatherUserInfo(c: var TForumData, nick: string, ui: var TUserInfo): bool =
|
||||||
ui.ban = row[2]
|
ui.ban = row[2]
|
||||||
ui.rank = parseEnum[Rank](row[3])
|
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 "forms.tmpl"
|
||||||
include "main.tmpl"
|
include "main.tmpl"
|
||||||
|
|
||||||
|
|
@ -944,6 +949,12 @@ proc genProfile(c: var TForumData, ui: TUserInfo): string =
|
||||||
th("Status"),
|
th("Status"),
|
||||||
td($ui.rank)
|
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(
|
tr(
|
||||||
th(""),
|
th(""),
|
||||||
td(if c.rank >= Moderator and c.rank > ui.rank:
|
td(if c.rank >= Moderator and c.rank > ui.rank:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue