ikibooru/reportuser.html.l
2024-06-01 17:40:11 +03:00

46 lines
1.5 KiB
Plaintext

{%
local reportee
local reported = nil
if verified and verified.privs >= DB.USER_PRIVS_APPROVED then
local reporteeid = tonumber(request:path():match"/reportuser/(%d+)")
reportee = reporteeid and DB.getuserbyid(reporteeid)
if reportee then
title = "Report user " .. Escapes.htmlescape(reportee.displayname)
if request:post() and request:post().csrf and DB.csrfverify(verified.id, Escapes.urlunescape(request:post().csrf)) and request:post().wtf and not request:post().wtf:match"^%s*$" and #request:post().wtf <= BigGlobe.MAX_COMMENT_SIZE then
reported = DB.addreport(verified.id, reporteeid, Escapes.urlspunescape(request:post().wtf))
end
else
title = "User not found"
end
else
title = "Unverified"
end
%}
{% function content() %}
{% if reported == nil then %}
{% if verified and verified.privs >= DB.USER_PRIVS_APPROVED then %}
<form action="#" method="POST">
<input type="hidden" name="csrf" value="{{ DB.csrf(verified.id) }}" />
<h2>Reporting user &quot;{{ Escapes.htmlescape(reportee.displayname) }}&quot;</h2>
<div style="margin-top:1em;margin-bottom:1em;">{{ BigGlobe.cfg.ruleset }}</div>
<textarea class="uf" name="wtf" placeholder="Max {{ BigGlobe.MAX_COMMENT_SIZE }}..."></textarea>
<button>Submit</button>
</form>
{% else %}
<p>You must be an approved member to report users.</p>
{% end %}
{% elseif reported then %}
<p>Reported.</p>
{% else %}
<p>Failed to report.</p>
{% end %}
{% end %}
{# base.inc