New bans page format
- Favor showing banned user's name if available - Support for MyTSID bans - Show the ban type alongside it (is it a UID / IP / MyTSID ban?) - Fixed a bug that caused the banned-ip alerts to not display if user's last name was known
This commit is contained in:
parent
7ac6d34e7b
commit
65ae062a96
64
src/bans.php
64
src/bans.php
|
@ -18,32 +18,74 @@ if ($banlist !== null) {
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
foreach ($banlist as $ban) {
|
foreach ($banlist as $ban) {
|
||||||
|
// Bans abbreviations:
|
||||||
|
// if we see a UID, IP or MyTSID ban, and we know
|
||||||
|
// the nickname of the banned user, we will show
|
||||||
|
// the user's name and then the type of ban
|
||||||
|
// that should be enough info for most users.
|
||||||
|
// it is possible to hover over the ban type to
|
||||||
|
// view the exact ban target
|
||||||
|
//
|
||||||
|
// for example, Wruczek got banned on his UID. we know that
|
||||||
|
// his last nickname was "Wruczek", so we simply show, that
|
||||||
|
// the ban is issued for:
|
||||||
|
// Wruczek (UID)
|
||||||
|
// after hovering over the "UID", you will see the exact UID
|
||||||
|
//
|
||||||
|
// if we dont know the last name of the banned user, we
|
||||||
|
// will just show the UID, IP or MyTSID
|
||||||
|
|
||||||
$name = "(cannot determine a name)";
|
$target = "(unknown)";
|
||||||
|
$lastNickname = Utils::escape($ban["lastnickname"]);
|
||||||
|
$filter = "";
|
||||||
|
$abbreviation = null;
|
||||||
|
|
||||||
if ($ban["lastnickname"]) {
|
if ($ban["ip"]) {
|
||||||
$name = (string)$ban["lastnickname"];
|
$ip = str_replace("\\", "", (string)$ban["ip"]);
|
||||||
} else if ($ban["uid"]) {
|
|
||||||
$name = new Html("<code>" . $ban["uid"] . "</code>");
|
|
||||||
} else if ($ban["name"]) {
|
|
||||||
$name = (string)$ban["name"];
|
|
||||||
} else if ($ban["ip"]) {
|
|
||||||
$ip = str_replace("\\", "", (string) $ban["ip"]);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$name = Utils::censorIpAddress($ip);
|
$ip = Utils::censorIpAddress($ip);
|
||||||
} catch (\Exception $e) {}
|
} catch (\Exception $e) {}
|
||||||
|
|
||||||
|
if ($lastNickname) {
|
||||||
|
$abbreviation = [$ip, "IP"];
|
||||||
|
} else {
|
||||||
|
$target = $ip;
|
||||||
|
}
|
||||||
|
|
||||||
if ($ip === Utils::getClientIp()) {
|
if ($ip === Utils::getClientIp()) {
|
||||||
$ipbanned = [
|
$ipbanned = [
|
||||||
"invoker" => (string)$ban["invokername"],
|
"invoker" => (string)$ban["invokername"],
|
||||||
"reason" => (string)$ban["reason"]
|
"reason" => (string)$ban["reason"]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
} else if ($ban["uid"]) {
|
||||||
|
if ($lastNickname) {
|
||||||
|
$abbreviation = [$ban["uid"], "UID"];
|
||||||
|
} else {
|
||||||
|
$target = new Html("<code>" . $ban["uid"] . "</code>");
|
||||||
|
}
|
||||||
|
} else if ($ban["name"]) {
|
||||||
|
$target = $ban["name"];
|
||||||
|
} else if (!empty($ban["mytsid"])) { // empty, older TS servers dont have MYTS bans, so the key might not exist
|
||||||
|
if ($lastNickname) {
|
||||||
|
$abbreviation = [$ban["mytsid"], "MyTSID"];
|
||||||
|
} else {
|
||||||
|
$target = new Html("<code>" . $ban["mytsid"] . "</code>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($abbreviation) {
|
||||||
|
$html = '%s (<span class="bans-highlight" data-toggle="tooltip" title="%s">%s</span>)';
|
||||||
|
$target = new Html(sprintf($html, $lastNickname, $abbreviation[0], $abbreviation[1]));
|
||||||
|
|
||||||
|
// make sure that the "full" data is also searchable in DataTables
|
||||||
|
$filter = "{$abbreviation[0]} $lastNickname";
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[] = [
|
$data[] = [
|
||||||
"name" => $name,
|
"filter" => $filter,
|
||||||
|
"target" => $target,
|
||||||
"reason" => (string)$ban["reason"],
|
"reason" => (string)$ban["reason"],
|
||||||
"invoker" => (string)$ban["invokername"],
|
"invoker" => (string)$ban["invokername"],
|
||||||
"created" => $ban["created"],
|
"created" => $ban["created"],
|
||||||
|
|
|
@ -178,6 +178,11 @@ body {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bans-highlight {
|
||||||
|
color: #e83e8c;
|
||||||
|
font-family: var(--font-family-monospace);
|
||||||
|
}
|
||||||
|
|
||||||
/* Responsive datatables styles */
|
/* Responsive datatables styles */
|
||||||
|
|
||||||
table.dataTable>tbody>tr.child ul.dtr-details>li:first-child {
|
table.dataTable>tbody>tr.child ul.dtr-details>li:first-child {
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
<table id="banlist" class="table display dt-responsive no-wrap" width="100%">
|
<table id="banlist" class="table display dt-responsive no-wrap" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th data-priority="1">{_"BANS_HEADER_NAME"}</th>
|
<th data-priority="1">{_"BANS_HEADER_TARGET"}</th>
|
||||||
<th data-priority="3">{_"BANS_HEADER_REASON"}</th>
|
<th data-priority="3">{_"BANS_HEADER_REASON"}</th>
|
||||||
<th>{_"BANS_HEADER_INVOKER"}</th>
|
<th>{_"BANS_HEADER_INVOKER"}</th>
|
||||||
<th>{_"BANS_HEADER_BANDATE"}</th>
|
<th>{_"BANS_HEADER_BANDATE"}</th>
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
{foreach $banlist as $ban}
|
{foreach $banlist as $ban}
|
||||||
{var $expiretime = $ban["created"] + $ban["duration"]}
|
{var $expiretime = $ban["created"] + $ban["duration"]}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{$ban["name"]}</td>
|
<td data-filter="{$ban["filter"]}">{$ban["target"]}</td>
|
||||||
<td>
|
<td>
|
||||||
{if $ban["reason"]}
|
{if $ban["reason"]}
|
||||||
{$ban["reason"]}
|
{$ban["reason"]}
|
||||||
|
|
Loading…
Reference in New Issue