diff --git a/bans.php b/bans.php index 2d7e0bd..02cb00e 100644 --- a/bans.php +++ b/bans.php @@ -64,20 +64,28 @@ function getBanlist() { try { $tsAdmin = TeamSpeak3::factory(getTeamspeakURI() . "#no_query_clients"); - $bany = $tsAdmin->banList(); + $bans = $tsAdmin->banList(); $output = ""; - foreach ($bany as $ban) { + foreach ($bans as $ban) { - if (!isset($ban['lastnickname'])) - continue; + $user = null; - $lastnickname = $ban['lastnickname']->toString(); - $reason = $ban['reason']; - $invokername = $ban['invokername']->toString(); - $created = date('d-m-Y H:i:s', $ban['created']); - $duration = $ban['duration']; + if (!empty($ban['ip'])) + $user = censorIP($ban['ip']->toString()); + + if (!empty($ban['lastnickname'])) + $user = $ban['lastnickname']->toString(); + + if (empty($user)) + $user = "Unknown"; + + + $reason = $ban['reason']; + $invokername = $ban['invokername']->toString(); + $created = date('d-m-Y H:i:s', $ban['created']); + $duration = $ban['duration']; if (empty($reason)) $reason = "" . translate($lang["banlist"]["table"]["emptyreason"]) . ""; @@ -87,7 +95,7 @@ function getBanlist() { else $expires = date('d-m-Y H:i:s', $ban['created'] + $duration); - $output .= "$lastnickname$reason$invokername$created$expires"; + $output .= "$user$reason$invokername$created$expires"; } return $output; @@ -101,6 +109,9 @@ function getBanlist() { } +function censorIP($ip) { + return preg_replace("/(\d+\.\d+\.)\d+\.\d+/", "$1*.*", $ip); +} require_once __DIR__ . "/include/footer.php"; ?> diff --git a/include/footer.php b/include/footer.php index 9763c53..e04910a 100644 --- a/include/footer.php +++ b/include/footer.php @@ -12,7 +12,7 @@