2018-12-27 17:59:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Latte\Runtime\Html;
|
|
|
|
use Wruczek\TSWebsite\CacheManager;
|
|
|
|
use Wruczek\TSWebsite\Utils\TemplateUtils;
|
|
|
|
use Wruczek\TSWebsite\Utils\Utils;
|
|
|
|
|
|
|
|
require_once __DIR__ . "/private/php/load.php";
|
|
|
|
|
|
|
|
$banlist = CacheManager::i()->getBanList();
|
|
|
|
$data = null;
|
|
|
|
$ipbanned = false;
|
|
|
|
|
|
|
|
if ($banlist !== null) {
|
|
|
|
$data = [];
|
|
|
|
|
|
|
|
foreach ($banlist as $ban) {
|
2019-01-09 10:22:36 +00:00
|
|
|
// 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
|
2018-12-27 17:59:49 +00:00
|
|
|
|
2019-01-09 10:22:36 +00:00
|
|
|
$target = "(unknown)";
|
2020-10-06 02:26:04 +00:00
|
|
|
$lastNickname = null;
|
2019-01-09 10:22:36 +00:00
|
|
|
$filter = "";
|
|
|
|
$abbreviation = null;
|
2018-12-27 17:59:49 +00:00
|
|
|
|
2020-10-06 02:26:04 +00:00
|
|
|
if ($ban["lastnickname"] !== null) {
|
|
|
|
$lastNickname = Utils::escape($ban["lastnickname"]);
|
|
|
|
}
|
|
|
|
|
2019-01-09 10:22:36 +00:00
|
|
|
if ($ban["ip"]) {
|
2020-10-06 02:26:04 +00:00
|
|
|
$ip = str_replace("\\", "", (string) $ban["ip"]);
|
2018-12-27 17:59:49 +00:00
|
|
|
|
|
|
|
try {
|
2019-01-09 10:22:36 +00:00
|
|
|
$ip = Utils::censorIpAddress($ip);
|
2018-12-27 17:59:49 +00:00
|
|
|
} catch (\Exception $e) {}
|
|
|
|
|
2020-10-06 02:26:04 +00:00
|
|
|
if ($lastNickname !== null) {
|
2019-01-09 10:22:36 +00:00
|
|
|
$abbreviation = [$ip, "IP"];
|
|
|
|
} else {
|
|
|
|
$target = $ip;
|
|
|
|
}
|
|
|
|
|
2018-12-27 17:59:49 +00:00
|
|
|
if ($ip === Utils::getClientIp()) {
|
|
|
|
$ipbanned = [
|
2020-10-06 02:26:04 +00:00
|
|
|
"invoker" => (string) $ban["invokername"],
|
|
|
|
"reason" => (string) $ban["reason"]
|
2018-12-27 17:59:49 +00:00
|
|
|
];
|
|
|
|
}
|
2019-01-09 10:22:36 +00:00
|
|
|
} else if ($ban["uid"]) {
|
2020-10-06 02:26:04 +00:00
|
|
|
if ($lastNickname !== null) {
|
2019-01-09 10:22:36 +00:00
|
|
|
$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
|
2020-10-06 02:26:04 +00:00
|
|
|
if ($lastNickname !== null) {
|
2019-01-09 10:22:36 +00:00
|
|
|
$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";
|
2018-12-27 17:59:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$data[] = [
|
2019-01-09 10:22:36 +00:00
|
|
|
"filter" => $filter,
|
|
|
|
"target" => $target,
|
2020-10-06 02:26:04 +00:00
|
|
|
"reason" => (string) $ban["reason"],
|
|
|
|
"invoker" => (string) $ban["invokername"],
|
2018-12-27 17:59:49 +00:00
|
|
|
"created" => $ban["created"],
|
|
|
|
"duration" => $ban["duration"]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TemplateUtils::i()->renderTemplate("bans", [
|
|
|
|
"banlist" => $data,
|
|
|
|
"ipbanned" => $ipbanned
|
|
|
|
]);
|