Show banlist on you website

Qraktzyl

Retired Staff
Contributor
Joined
Nov 2, 2015
Messages
997
Reaction score
723
Points
161
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
Makes sense, because @freets3.ovh probably has around 111111111 bans
 

p0tassium

Member
Joined
Jun 13, 2015
Messages
68
Reaction score
48
Points
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
Joined
Nov 24, 2016
Messages
162
Reaction score
161
Points
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']);
 

anonz

Member
Joined
Sep 24, 2016
Messages
19
Reaction score
0
Points
38
0rysa5A.jpg

Thanks man, this is my table.
 
Last edited:

ptR

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

strux1

Member
Joined
Mar 19, 2016
Messages
30
Reaction score
1
Points
43
Any tutorial how to set it up iam a noob :D
 

skreww

New Member
Joined
Aug 28, 2017
Messages
28
Reaction score
1
Points
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
Joined
May 29, 2017
Messages
160
Reaction score
121
Points
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