Show banlist on you website

skreww

New Member
Joined
Aug 28, 2017
Messages
28
Reaction score
1
Points
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
Joined
Aug 28, 2017
Messages
28
Reaction score
1
Points
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
Joined
Nov 24, 2016
Messages
162
Reaction score
161
Points
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
Joined
Jan 10, 2018
Messages
1
Reaction score
0
Points
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
Joined
May 29, 2017
Messages
160
Reaction score
121
Points
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
Joined
Nov 6, 2016
Messages
3
Reaction score
3
Points
38
You should use htmlspecialchars() for the nicknames and reason... if not somebody could inject external javascript on your website.
 

InVaDeR359

Active Member
Joined
May 29, 2017
Messages
160
Reaction score
121
Points
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
Joined
Nov 6, 2016
Messages
3
Reaction score
3
Points
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
Joined
Jan 23, 2016
Messages
12
Reaction score
0
Points
76
Think it is feasible, incorporate such a script with the Whmcs module of Ts3?
 

BIOS

Knowledge Seeker
VIP
Joined
Oct 10, 2015
Messages
447
Reaction score
848
Points
208
how to request the banlist from the whole instance?
 

kalle

high minded
Contributor
Joined
Oct 28, 2015
Messages
411
Reaction score
253
Points
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.
 

BIOS

Knowledge Seeker
VIP
Joined
Oct 10, 2015
Messages
447
Reaction score
848
Points
208
its not supportet by teamspeak phpframework...:(
 
Top