bans.php - dont pass null into Utils::escape

This commit is contained in:
Wruczek 2020-10-06 04:26:04 +02:00
parent d0d9c91ab2
commit 9848c096e6
1 changed files with 13 additions and 9 deletions

View File

@ -33,18 +33,22 @@ if ($banlist !== null) {
// will just show the UID, IP or MyTSID // will just show the UID, IP or MyTSID
$target = "(unknown)"; $target = "(unknown)";
$lastNickname = Utils::escape($ban["lastnickname"]); $lastNickname = null;
$filter = ""; $filter = "";
$abbreviation = null; $abbreviation = null;
if ($ban["lastnickname"] !== null) {
$lastNickname = Utils::escape($ban["lastnickname"]);
}
if ($ban["ip"]) { if ($ban["ip"]) {
$ip = str_replace("\\", "", (string)$ban["ip"]); $ip = str_replace("\\", "", (string) $ban["ip"]);
try { try {
$ip = Utils::censorIpAddress($ip); $ip = Utils::censorIpAddress($ip);
} catch (\Exception $e) {} } catch (\Exception $e) {}
if ($lastNickname) { if ($lastNickname !== null) {
$abbreviation = [$ip, "IP"]; $abbreviation = [$ip, "IP"];
} else { } else {
$target = $ip; $target = $ip;
@ -52,12 +56,12 @@ if ($banlist !== null) {
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"]) { } else if ($ban["uid"]) {
if ($lastNickname) { if ($lastNickname !== null) {
$abbreviation = [$ban["uid"], "UID"]; $abbreviation = [$ban["uid"], "UID"];
} else { } else {
$target = new Html("<code>" . $ban["uid"] . "</code>"); $target = new Html("<code>" . $ban["uid"] . "</code>");
@ -65,7 +69,7 @@ if ($banlist !== null) {
} else if ($ban["name"]) { } else if ($ban["name"]) {
$target = $ban["name"]; $target = $ban["name"];
} else if (!empty($ban["mytsid"])) { // empty, older TS servers dont have MYTS bans, so the key might not exist } else if (!empty($ban["mytsid"])) { // empty, older TS servers dont have MYTS bans, so the key might not exist
if ($lastNickname) { if ($lastNickname !== null) {
$abbreviation = [$ban["mytsid"], "MyTSID"]; $abbreviation = [$ban["mytsid"], "MyTSID"];
} else { } else {
$target = new Html("<code>" . $ban["mytsid"] . "</code>"); $target = new Html("<code>" . $ban["mytsid"] . "</code>");
@ -83,8 +87,8 @@ if ($banlist !== null) {
$data[] = [ $data[] = [
"filter" => $filter, "filter" => $filter,
"target" => $target, "target" => $target,
"reason" => (string)$ban["reason"], "reason" => (string) $ban["reason"],
"invoker" => (string)$ban["invokername"], "invoker" => (string) $ban["invokername"],
"created" => $ban["created"], "created" => $ban["created"],
"duration" => $ban["duration"] "duration" => $ban["duration"]
]; ];