Show banlist on you website

p0tassium

Member
Jun 13, 2015
68
48
53
Definitly, if you do not have any bans on the teamspeak Server then you will get a Error with "Empty Result set" and this is nothing to worry about, but easy catchable
I tried banning my friend just to make sure empty banlist wasn't the problem but I'm still getting the same error
 
U

User_2970

Hello,
i have edit the script,Please use this for the last API an Server Version:
Code:
<?php
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
try {
$ts3 = TeamSpeak3::factory("serverquery://serveradmin:password@ip:10011/?server_port=9987");
$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['lastnickname']))
  $name = "No name given";
  else
  $name = $row['lastnickname'];

  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();
   }
 }


?>
</table>
 

XARON

get over here!
Restricted
Nov 24, 2016
162
161
118
Small php script to display the list of banned users on your TeamSpeak server, on your site.

KtaS0S6.png
============================================================

PHP:
<?php
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$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>';
  }


?>
You can use useful if/else;
echo ((empty($row['reason'])) ? 'No reason given' : $row['reason']);
 

ptR

Member
Nov 15, 2015
47
0
38
Thanks my table, but how can i delete it pressing by red cross (in my table by trash icon)?
xDGPBE9.png
 

skreww

New Member
Aug 28, 2017
28
1
20
Hi ! Thanks alote for this script ! Now can you share the same code to show the servers logs ? I try to creat one but i didn't resolve it :/
 

InVaDeR359

Active Member
May 29, 2017
160
121
72
@Cepkin , Please replace $name by $lastnickname in the following line :

PHP:
  $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>';  // This One
  echo '<td>' . $expires . '</td>';
  echo '<td>' . $row['invokername'] . '</td>';
  echo '<td>' . $reason . '</td>';
  echo '</tr>';
  }
 
Top