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:
commit
d5892db647
1 changed files with 11 additions and 0 deletions
11
forum.nim
11
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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue