Forum


Notice to all users

We are migrating towards a new forum system located at community.teamspeak.com, as such this forum will become read-only on January 29, 2020

Results 1 to 9 of 9
  1. #1
    Join Date
    March 2011
    Posts
    9

    Solved server information

    Hello,
    can you help me with one little problem?
    I have the script that shows the number of people online on each server. as there can add the sum of all the people from all servers?

    <?PHP
    /**
    * serverlist.php
    *
    * Is a small script to demonstrate how to get a serverlist via ts3admin.lib
    *
    * by par0noid solutions - ts3admin.6x.to
    *
    */

    /*-------SETTINGS-------*/
    $ts3_ip = 'x6.2xx.109.xx';
    $ts3_queryport = 10011;
    $ts3_user = 'serveradmin';
    $ts3_pass = 'XXXXX';
    /*----------------------*/

    #Include ts3admin.class.php
    require("ts3admin.class.php");

    #build a new ts3admin object
    $tsAdmin = new ts3admin($ts3_ip, $ts3_queryport);

    if($tsAdmin->getElement('success', $tsAdmin->connect())) {
    #login as serveradmin
    $tsAdmin->login($ts3_user, $ts3_pass);

    #get serverlist
    $servers = $tsAdmin->serverList();

    #set output var
    $output = '';

    #generate table codes for all servers
    foreach($servers['data'] as $server) {
    $output .= '<tr bgcolor="#ffffff" onmouseover="style.backgroundColor=\'#eeeeee\'" onmouseout="style.backgroundColor=\'#ffffff\'">';
    $output .= '<td width="300px">&nbsp;&nbsp;'.htmlspecialchars($serv er['virtualserver_name']).'</td>';
    $output .= '<td width="100px" align="center">'.$server['virtualserver_port'].'</td>';
    $output .= '<td width="300px" align="center">&nbsp;&nbsp;<b>'.htmlspecialchars($ server['virtualserver_clientsonline']).'<b></td>';
    $output .= '<td width="100px" align="center"><span style="color: #008000;"><b>'.$server['virtualservers_total_clients_online'].'</b></span></td>';
    $output .= '<td width="100px" align="center"><span style="color: #008000;"><b>'.$server['virtualserver_status'].'</b></span></td>';
    }
    }else{
    echo 'Connection could not be established.';
    }

    if(count($tsAdmin->getDebugLog()) > 0) {
    foreach($tsAdmin->getDebugLog() as $logEntry) {
    echo '<script>alert(\''.$logEntry.'\');</script>';
    }
    }

    ?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style>
    * {
    font-size:13px;
    font-family:Verdana, Geneva, sans-serif;
    }
    </style>
    </head>
    <body bgcolor="transparent">
    <table bgcolor="#000000" border="0" align="left">
    <tr bgcolor="#c0c0c0">
    <td width="300px" align="center"><b>Jmeno Serveru<b></td>
    <td width="100px" align="center"><b>Port<b></td>
    <td width="300px" align="center"><b>Pocet lidi online<b></td>
    <td width="100px" align="center"><b>Pocet lidi total<b></td>
    <td width="100px" align="center"><b>Status<b></td>
    </tr>
    <?PHP echo $output; ?>
    </table>
    </body>
    </html>
    thank you very much
    Last edited by Daviss; March 3rd, 2011 at 07:45 PM.

  2. #2
    Join Date
    March 2011
    Posts
    9
    Nobody knows why it does not work? .- (

  3. #3
    Join Date
    May 2010
    Posts
    6,310
    Hello

    If you want the total client online, you must get this information from the host info.
    With this class :

    PHP Code:
    $host $tsAdmin->hostInfo(); 

  4. #4
    Join Date
    March 2011
    Posts
    9
    I tried to rewrite the script to show only the number of people online on all servers. When I use hostinfo () always fails. Any examples that use hostinfo () with ts3admin.class?

    Thank you very much

  5. #5
    Join Date
    March 2011
    Posts
    9
    I was looking for an example here, but none I found...

  6. #6
    Join Date
    March 2011
    Posts
    9
    I used a script that I found, but also with an error ... Drop me an example of someone hostinfo? then it can handle

  7. #7
    Join Date
    May 2010
    Posts
    6,310
    Quick example here (without host info) :
    (Your script contained several syntax error)

    PHP Code:
    <?php
    /**
    * serverlist.php
    *
    * Is a small script to demonstrate how to get a serverlist via ts3admin.lib
    *
    * by par0noid solutions - ts3admin.6x.to
    *
    */

    /*-------SETTINGS-------*/
    $ts3_ip '127.0.0.1';
    $ts3_queryport 10011;
    $ts3_user 'serveradmin';
    $ts3_pass 'florian';
    /*----------------------*/

    #Include ts3admin.class.php
    include 'ts3admin.class.php';

    #build a new ts3admin object
    $tsAdmin = new ts3admin($ts3_ip$ts3_queryport);

    if(
    $tsAdmin->getElement('success'$tsAdmin->connect())) 
    {
        
    #login as serveradmin
        
    $tsAdmin->login($ts3_user$ts3_pass);

        
    #get serverlist
        
    $servers $tsAdmin->serverList();
        
        
    #set output var
        
    $output '';
        
        
    //Total user count
        
    $totalUser 0;
        
        
    #generate table codes for all servers
        
    foreach($servers['data'] as $server)
        {
            
    $output .= '<tr bgcolor="#FFFFFF" onmouseover="style.backgroundColor=\'#EEEEEE\'" onmouseout="style.backgroundColor=\'#FFFFFF\'">';
            
    $output .= '    <td width="300px">&nbsp;&nbsp;'.htmlspecialchars($server['virtualserver_name']).'</td>';
            
    $output .= '    <td width="100px" align="center">'.$server['virtualserver_port'].'</td>';
            
    $output .= '    <td width="300px" align="center">&nbsp;&nbsp;<b>'.htmlspecialchars($server['virtualserver_clientsonline']).'</b></td>';
            
    $output .= '    <td width="100px" align="center"><span style="color: #008000;"><b>'.$server['virtualservers_total_clients_online'].'</b></span></td>';
            
    $output .= '    <td width="100px" align="center"><span style="color: #008000;"><b>'.$server['virtualserver_status'].'</b></span></td>';
            
    $output .= '</tr>';
            
            
    $totalUser $totalUser $server['virtualserver_clientsonline'];
        }
    }
    else
    {
        echo 
    'Connection could not be established.';
    }

    if(
    count($tsAdmin->getDebugLog()) > 0
    {
        foreach(
    $tsAdmin->getDebugLog() as $logEntry)
        {
            echo 
    '<script>alert(\''.$logEntry.'\');</script>';
        }
    }

    ?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style>
    * {
    font-size:13px;
    font-family:Verdana, Geneva, sans-serif;
    }
    </style>
    </head>
    <body bgcolor="transparent">
    <table bgcolor="#000000" border="0">
    <tr bgcolor="#c0c0c0">
        <td width="300px" align="center"><b>Jmeno Serveru</b></td>
        <td width="100px" align="center"><b>Port</b></td>
        <td width="300px" align="center"><b>Pocet lidi online</b></td>
        <td width="100px" align="center"><b>Pocet lidi total</b></td>
        <td width="100px" align="center"><b>Status</b></td>
    </tr>
    <?php echo $output?>
    </table>
    <br>
    <div><b> Total clients online: <?php echo $totalUser?></b></div>
    </body>
    </html>

  8. #8
    Join Date
    March 2011
    Posts
    9
    Thank you for your time =)

    works correctly now...

  9. #9
    Join Date
    March 2011
    Posts
    20
    I want to use this script aswell, but i get Error in connect() on line 3350: Error: connection failed! The settings ip, poort password are good, server runs on beta-30 any ideas ?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help with some information for my virtual server
    By Pedriitop in forum General Questions
    Replies: 1
    Last Post: May 5th, 2014, 02:37 AM
  2. More information in server log ?
    By Rafter in forum Server Support
    Replies: 0
    Last Post: May 22nd, 2011, 07:19 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •