Show banlist on you website

freets3.ovh

Active Member
Joined
Sep 19, 2015
Messages
150
Reaction score
105
Points
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>';
  }


?>
 

Ch4ch4rR4t0

Active Member
Joined
Aug 19, 2016
Messages
77
Reaction score
7
Points
83
thanks bro, nice, you can to release this simple template? :}
thank you
 

FarisDev

L oryh brx
Contributor
Joined
Jun 9, 2016
Messages
277
Reaction score
111
Points
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
Joined
Jun 13, 2015
Messages
68
Reaction score
48
Points
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
Joined
Nov 2, 2015
Messages
997
Reaction score
723
Points
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.
 

DamianTs3

Member
Joined
May 3, 2016
Messages
6
Reaction score
0
Points
38
;)Where do i put my Teamspeak 3 IP and Username and password so it can work?
 

Qraktzyl

Retired Staff
Contributor
Joined
Nov 2, 2015
Messages
997
Reaction score
723
Points
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
 

Alligatoras

Administrator
Joined
Mar 31, 2016
Messages
2,570
Solutions
12
Reaction score
2,857
Points
381
$ts3 = TeamSpeak3::factory("serverquery://user:p[email protected]:xxxx/?server_port=yyyy");
Sorry for that comment, but it's seems a bit funny to me!
All these zzzz...xxxxx...yyyy...makes me fall asleep :(
Usually i see something like that:
PHP:
$ts3 = TeamSpeak3::factory("serverquery://serveradmin:[email protected]:10011/?server_port=9987")
 

DamianTs3

Member
Joined
May 3, 2016
Messages
6
Reaction score
0
Points
38
can someone please give me the full script of it?
it would be very nice!
 

Alligatoras

Administrator
Joined
Mar 31, 2016
Messages
2,570
Solutions
12
Reaction score
2,857
Points
381
This is the full script...all rest is just styling!
 

p0tassium

Member
Joined
Jun 13, 2015
Messages
68
Reaction score
48
Points
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
Joined
Nov 2, 2015
Messages
997
Reaction score
723
Points
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
Joined
Feb 19, 2016
Messages
53
Reaction score
23
Points
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
Joined
Feb 19, 2016
Messages
53
Reaction score
23
Points
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