Show banlist on you website

skreww

New Member
Aug 28, 2017
28
1
20
Code:
<?php
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
try {
$ts3 = TeamSpeak3::factory("serverquery://user:[email protected]:xxxx/?server_port=yyyy");
$banlist = $ts3 -> banlist();


  echo '<table class="table table-striped table-bordered table-hover" border="1">';
echo '
<tr>
<th>Ban ID</th>
<th>Ban IP</th>
<th>Ban Name</th>
<th>Ban Duration</th>
<th>Banned By</th>
<th>Ban reason</th>
</tr>';

  foreach ($banlist as $row)
  {

  if(empty($row['reason']))
  $reason = "No raison given";
  else
  $reason = $row['reason'];

  if(empty($row['name']))
  $name = "No name given";
  else
  $name = $row['name'];

  if(empty($row['ip']))
  $ip = "No IP given";
  else
  $ip = $row['ip'];

  if($row['duration'] == 0)
  $expires = "Ban permanent";
  else
  $expires = date('d-m-Y H:i:s', $row['created'] + $row['duration']);

  echo '<td>' . $row['banid'] . '</td>';
  echo '<td>' . $ip . '</td>';
  echo '<td>' . $name . '</td>';
  echo '<td>' . $expires . '</td>';
  echo '<td>' . $row['invokername'] . '</td>';
  echo '<td>' . $reason . '</td>';
  echo '</tr>';
  }
 } catch (TeamSpeak3_Exception $e) {
   if ($e->getCode() == 1281) { //I hope its code ID 1281 otherwise correct me
    echo "No Bans on this Server";
   } else {
    echo "Error: ".$e->getMessage();
   }
 }


?>


like this, havent tested it

didn't work for me :s
 

skreww

New Member
Aug 28, 2017
28
1
20
@Marie Hi ! Thanks for your answer, i found the problem its solved for me, it come from this line
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
i don't have the same adress on my FTP, that's all ^^
Did you know how to show the logs from a Virtual Server ? Thanks a lot !
 

XARON

get over here!
Restricted
Nov 24, 2016
162
161
118
@Marie Hi ! Thanks for your answer, i found the problem its solved for me, it come from this line
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
i don't have the same adress on my FTP, that's all ^^
Did you know how to show the logs from a Virtual Server ? Thanks a lot !
get the last 100 lines from virtual server log
$server->logView(100);
 

itsmejay

New Member
Jan 10, 2018
1
0
3
it works, but the script dont show me the names of the banend clients.. :(

i replaced $name with $lastnickname - it doesnt work.. why? even if I banne someone currently, no name is displayed.
 

InVaDeR359

Active Member
May 29, 2017
160
121
72
it works, but the script dont show me the names of the banend clients..:(

i replaced $name with $lastnickname - it doesnt work.. why? even if I banne someone currently, no name is displayed.
Do not replace $name with $lastnickname, only change this :
PHP:
 if(empty($row['name']))
$name = "No name given";
else
$name = $row['name'];
to :
PHP:
 if(empty($row['lastnickname']))
$name = "No name given";
else
$name = $row['lastnickname'];
 

getBrainError

Member
Nov 6, 2016
3
3
38
You should use htmlspecialchars() for the nicknames and reason... if not somebody could inject external javascript on your website.
 

InVaDeR359

Active Member
May 29, 2017
160
121
72
You should use htmlspecialchars() for the nicknames and reason... if not somebody could inject external javascript on your website.
I don't think so. You don't have enough space in the nickname and ban reason to really inject anything.
 

getBrainError

Member
Nov 6, 2016
3
3
38
Its possible if you have a short domain... like j.mp or something else like that. Beside that fact every nickname with chars like <> wouldnt get displayed (Which happens with my name <Ole/>).
As Example something like should be enough to get code running
Code:
<script src="j.mp/s.js"
 

paul78

Active Member
Jan 23, 2016
12
0
76
Think it is feasible, incorporate such a script with the Whmcs module of Ts3?
 

kalle

high minded
Contributor
Oct 28, 2015
411
253
178
Idk if there is option like that, but you could check server by server and collect bans. If there is better way, please post it.
 
Top