Show banlist on you website

freets3.ovh

Active Member
Sep 19, 2015
150
105
85
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>';
  }


?>
 

FarisDev

L oryh brx
Contributor
Jun 9, 2016
277
111
107
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>';
  }


?>
nice but can u add. cliient list! Display his own Nickname - Uid ?
 

p0tassium

Member
Jun 13, 2015
68
48
53
error.log?
Code:
Stack trace:
#0 /var/www/enju.sandwii.ch/libraries/TeamSpeak3/Adapter/ServerQuery/Reply.php(91): TeamSpeak3_Adapter_ServerQuery_Reply->fetchError(Object(TeamSpeak3_Helper_String))
#1 /var/www/enju.sandwii.ch/libraries/TeamSpeak3/Adapter/ServerQuery.php(141): TeamSpeak3_Adapter_ServerQuery_Reply->__construct(Array, 'banlist', Object(TeamSpeak3_Node_Host), true)
#2 /var/www/enju.sandwii.ch/libraries/TeamSpeak3/Node/Abstract.php(73): TeamSpeak3_Adapter_ServerQuery->request('banlist', true)
#3 /var/www/enju.sandwii.ch/libraries/TeamSpeak3/Node/Server.php(90): TeamSpeak3_Node_Abstract->request('banlist', true)
#4 /var/www/enju.sandwii.ch/libraries/TeamSpeak3/Node/Server.php(2076): TeamSpeak3_Node_Server->request('banlist')
#5 /var/www/enju.sandwii.ch/index.php(4): TeamSpeak3_Node_Server->banList()" while reading response header from upstream, client: 162.158.27.134, server: enju.sandwii.ch, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "enju.sandwii.ch"
2016/09/18 04:16:46 [error] 17153#0: *5 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught exception 'TeamSpeak3_Adapter_ServerQuery_Exception' with message 'database empty result set' in /var/www/enju.sandwii.ch/libraries/TeamSpeak3/Adapter/ServerQuery/Reply.php:319
 

Qraktzyl

Retired Staff
Contributor
Nov 2, 2015
997
723
161
Code:
Stack trace:
#0 /var/www/enju.sandwii.ch/libraries/TeamSpeak3/Adapter/ServerQuery/Reply.php(91): TeamSpeak3_Adapter_ServerQuery_Reply->fetchError(Object(TeamSpeak3_Helper_String))
#1 /var/www/enju.sandwii.ch/libraries/TeamSpeak3/Adapter/ServerQuery.php(141): TeamSpeak3_Adapter_ServerQuery_Reply->__construct(Array, 'banlist', Object(TeamSpeak3_Node_Host), true)
#2 /var/www/enju.sandwii.ch/libraries/TeamSpeak3/Node/Abstract.php(73): TeamSpeak3_Adapter_ServerQuery->request('banlist', true)
#3 /var/www/enju.sandwii.ch/libraries/TeamSpeak3/Node/Server.php(90): TeamSpeak3_Node_Abstract->request('banlist', true)
#4 /var/www/enju.sandwii.ch/libraries/TeamSpeak3/Node/Server.php(2076): TeamSpeak3_Node_Server->request('banlist')
#5 /var/www/enju.sandwii.ch/index.php(4): TeamSpeak3_Node_Server->banList()" while reading response header from upstream, client: 162.158.27.134, server: enju.sandwii.ch, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "enju.sandwii.ch"
2016/09/18 04:16:46 [error] 17153#0: *5 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught exception 'TeamSpeak3_Adapter_ServerQuery_Exception' with message 'database empty result set' in /var/www/enju.sandwii.ch/libraries/TeamSpeak3/Adapter/ServerQuery/Reply.php:319
Issue with your database. That's all I can say, I have no idea what it is.
 

Qraktzyl

Retired Staff
Contributor
Nov 2, 2015
997
723
161
;)Where do i put my Teamspeak 3 IP and Username and password so it can work?
$ts3 = TeamSpeak3::factory("serverquery://user:p[email protected]:xxxx/?server_port=yyyy");
user is serveradmin
pass is serveradmin pass
z.z.z.z is the ip
xxxx is the serverquery port
yyyy is the teamspeak server port
 

p0tassium

Member
Jun 13, 2015
68
48
53
That's odd. I tried this code on a test server with fresh installed TS3 using Dedmen's 3.0.13.4 crack. Still getting the same 500 Internal Server Error. I'll try on a different web server now and see if that works.

EDIT: Nope doesn't work as well.
 
Last edited:

Qraktzyl

Retired Staff
Contributor
Nov 2, 2015
997
723
161
That's odd. I tried this code on a test server with fresh installed TS3 using Dedmen's 3.0.13.4 crack. Still getting the same 500 Internal Server Error. I'll try on a different web server now and see if that works.

EDIT: Nope doesn't work as well.
surround with try / catch maybe so it catches it and might work?
I have no idea what the problem could be.
 

DifferentUser

Member
Feb 19, 2016
53
23
58
surround with try / catch maybe so it catches it and might work?
I have no idea what the problem could be.

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
 

DifferentUser

Member
Feb 19, 2016
53
23
58
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
 
Top