NetVision-Technik

NetVision-Technik (http://www.netvision-technik.de/forum/index.php)
-   Webserver (http://www.netvision-technik.de/forum/forumdisplay.php?f=9)
-   -   TS3 Fehler ?! (http://www.netvision-technik.de/forum/showthread.php?t=5940)

Stifler 08.03.2011 18:09

Welchen ts3viewer verwendest du?

dienr2 08.03.2011 18:16

TSStatus: Teamspeak 3 viewer for php5

Changelog
---------

23/12/09:

- work with BETA 5 servers
- added a decodeUTF8 method for specials chars

26/12/09
- tested with severs BETA 3,5,6,7,8
- first release of the TSStatus generator script
- added a new property, showNicknameBox, to show/hide the nickname box
- improved error messages. sockets and Teamspeak servers errors are now displayed with the error message and error number
- added a timeout property for connect, read, write operations
- properly disconnect from server and send the quit message
- code cleanup

steht in der README

Stifler 08.03.2011 18:24

Da gibt es eine 2010er Version .. Die Aktuelle TS3 Beta hat die Zahl 30, und bei den versch. Betas wurde viel rumexperimentiert so dass ich glaube dass diese Version des TS3Viewers nicht mehr mit der deines Servers kompatibel ist.

Bei mir hatte ich mit der 2009er auch eine riesen CPU Auslastung und mit der 2010er keine mehr!

wagaman 08.03.2011 18:26

kann dir nur empfehlen einen anderen zu nehmen und den auch entweder mit klappe versehen oder als popup zu machen,

oder deinen jetzigen ma so ausprobieren,also klappe oder popup

dienr2 10.03.2011 20:04

möschte mir einer mal seinen geben ; ) weil bei allen die ich jetzt ausprobiert habe ist der selbe fehler.

Sponge 10.03.2011 20:46

Aber du weisst schon das bei jedem der das installiert nen individueller SA-Schlüssel erstellt wird ne?
Also nix mit von anderen den nehmen!
Neu installen und gut....

dienr2 12.03.2011 04:21

joa hab ich schon par mal ; )

so wenn ich den ts3 server starte funzt es die seite läuft auch flüssig.

Aber sobald ich den Viewer reinbaue aufm tracker lädt der tracker nicht mehr. wie bekomme ich das weg ? hab schon mehrere viewer ausprobiert

Stifler 12.03.2011 09:20

Kuck mal im viewer nach was er für cmds schickt (serverinfo, channellist) ect und das musst du bei deinem teamspeakserver einstellen.

was ich festgestellt habe ist das manche ts3 viewer ein falsches Errorhandling haben.

in der funktion sendCommand z.B gehört korrekterweise

PHP-Code:

    if(!strpos($response"error id=0")) {
        
$this->error "TS3 Server returned the following error: " $this->unescape(trim($response));
        return 
false;
        } 

und bei update()

PHP-Code:

$lines explode("\n\rerror id=0 msg=ok\n\r"$response); 

queryserver()

PHP-Code:

        $this->_socket = @fsockopen($this->_host$this->_qport$errno$errstr1); 

und


PHP-Code:

@socket_set_timeout($this->_socket1);

            if(
trim(@fgets($this->_socket)) != "TS3") {
            
$this->error "Not a Teamspeak 3 Server - Bad Query Port";
            return 
false;
            } 

stell mal deinen tsviewer hier rein und wir schauen uns das an!

dienr2 12.03.2011 17:56

Also in meiner block_ts3_ansicht.php (die links im menü angezeigt wird da ich es mit blöcken hab )

hab ich stehn

PHP-Code:

<?
////////////////////////////////////////
//      Blocks vom Linken Menü       //
//////////////////////////////////////
//      TS 3 Ansicht               //
////////////////////////////////////
?>

<html>
<head>
<title>TSStatus</title>
<link rel="stylesheet" type="text/css" href="/tsstatus/tsstatus.css" />
<script type="text/javascript" src="/tsstatus/tsstatus.js"></script>
</head>
<body>

<?php
require_once("/dt/trackerv2/xyz/tsstatus/tsstatus.php");
$tsstatus = new TSStatus("URLBZW.IP"100111);
$tsstatus->imagePath "/tsstatus/img/";
$tsstatus->showNicknameBox true;
$tsstatus->decodeUTF8 true;
$tsstatus->timeout 2;
echo 
$tsstatus->render();
?>

</body>
</html>

und die tsstatus.php

PHP-Code:

<?php 


class TSStatus
{
    private 
$_host;
    private 
$_qport;
    private 
$_sid;
    private 
$_socket;
    private 
$_updated;
    private 
$_serverDatas;
    private 
$_channelDatas;
    private 
$_userDatas;
    private 
$_serverGroupFlags;
    private 
$_channelGroupFlags;
    
    public 
$imagePath;
    public 
$decodeUTF8;
    public 
$showNicknameBox;
    public 
$timeout;
    
    public function 
TSStatus($host$queryPort$serverId)
    {
        
$this->_host $host;
        
$this->_qport $queryPort;
        
$this->_sid $serverId;
        
        
$this->_socket null;    
        
$this->_updated false;
        
$this->_serverDatas = array();
        
$this->_channelDatas = array();
        
$this->_userDatas = array();
        
$this->_serverGroupFlags = array();
        
$this->_channelGroupFlags = array();
        
        
$this->imagePath "img/";
        
$this->decodeUTF8 false;
        
$this->showNicknameBox true;
        
$this->timeout 2;
        
        
$this->setServerGroupFlag(6'servergroup_300.png');
        
$this->setChannelGroupFlag(5'changroup_100.png');
        
$this->setChannelGroupFlag(6'changroup_200.png');
    }
    
    private function 
unescape($str)
    {
        
$find = array('\\\\',     "\/",         "\s",         "\p",         "\a",     "\b",     "\f",         "\n",         "\r",     "\t",     "\v");
        
$rplc = array(chr(92),    chr(47),    chr(32),    chr(124),    chr(7),    chr(8),    chr(12),    chr(10),    chr(3),    chr(9),    chr(11));
        
        return 
str_replace($find$rplc$str);
    }
    
    private function 
parseLine($rawLine)
    {
        
$datas = array();
        
$rawItems explode("|"$rawLine);
        foreach (
$rawItems as $rawItem)
        {
            
$rawDatas explode(" "$rawItem);
            
$tempDatas = array();
            foreach(
$rawDatas as $rawData)
            {
                
$ar explode("="$rawData2);
                
$tempDatas[$ar[0]] = isset($ar[1]) ? $this->unescape($ar[1]) : "";
            }
            
$datas[] = $tempDatas;
        }
        return 
$datas;
    }
    
    private function 
sendCommand($cmd)
    {
        
fputs($this->_socket"$cmd\n");
        
$response "";
        do
        {
            
$response .= fread($this->_socket8096);
        }while(
strpos($response'error id=') === false);
        
        if(
strpos($response"error id=0") === false)
        {
            throw new 
Exception("TS3 Server returned the following error: " $this->unescape(trim($response)));
        }
        
        return 
$response;
    }
    
    private function 
queryServer()
    {
        
$this->_socket = @fsockopen($this->_host$this->_qport$errno$errstr$this->timeout);
        if(
$this->_socket)
        {
            @
socket_set_timeout($this->_socket$this->timeout);
            
$isTs3 trim(fgets($this->_socket)) == "TS3";
            if(!
$isTs3) throw new Exception("Not a Teamspeak 3 server/bad query port");

            
$response "";
            
$response .= $this->sendCommand("use sid=" $this->_sid);
            
$response .= $this->sendCommand("serverinfo");
            
$response .= $this->sendCommand("channellist -topic -flags -voice -limits");
            
$response .= $this->sendCommand("clientlist -uid -away -voice -groups");

            
$this->disconnect();
            
            if(
$this->decodeUTF8$response utf8_decode($response);
            
            return 
$response;
        }
        else throw new 
Exception("Socket error: $errstr [$errno]");
    }
    
    private function 
disconnect()
    {
        @
fputs($this->_socket"quit\n");
        @
fclose($this->_socket);
    }
    
    private function 
sortUsers($a$b)
    {
        return 
strcasecmp($a["client_nickname"], $b["client_nickname"]);
    }
    
    private function 
update()
    {
        
$response $this->queryServer();
        
        
$lines explode("error id=0 msg=ok\n\r"$response);
        if(
count($lines) == 5)
        {
            
$this->_serverDatas $this->parseLine($lines[1]);
            
$this->_serverDatas $this->_serverDatas[0];

            
$this->_channelDatas $this->parseLine($lines[2]);
            
$this->_userDatas $this->parseLine($lines[3]);
            
usort($this->_userDatas, array($this"sortUsers"));

            
$this->_updated true;
        }
        else 
$this->error "Invalid server response";
        
    }
    
    private function 
renderFlags($flags)
    {
        
$out "";
        foreach (
$flags as $flag$out .= '<img src="' $this->imagePath $flag '" />';
        return 
$out;
    }

    private function 
renderUsers($parentId)
    {
        
$out "";
        foreach(
$this->_userDatas as $user)
        {
            if(
$user["client_type"] == && $user["cid"] == $parentId)
            {
                
$icon "16x16_player_off.png";
                if(
$user["client_away"] == 1$icon "16x16_away.png";
                else if(
$user["client_flag_talking"] == 1$icon "16x16_player_on.png";
                else if(
$user["client_output_hardware"] == 0$icon "16x16_hardware_output_muted.png";
                else if(
$user["client_output_muted"] == 1$icon "16x16_output_muted.png";
                else if(
$user["client_input_hardware"] == 0$icon "16x16_hardware_input_muted.png";
                else if(
$user["client_input_muted"] == 1$icon "16x16_input_muted.png";
                
                
$flags = array();
                if(isset(
$this->_channelGroupFlags[$user["client_channel_group_id"]])) $flags[] = $this->_channelGroupFlags[$user["client_channel_group_id"]];
                
$serverGroups explode(","$user["client_servergroups"]);
                foreach (
$serverGroups as $serverGroup) if(isset($this->_serverGroupFlags[$serverGroup])) $flags[] = $this->_serverGroupFlags[$serverGroup];
                
                
$out .= '
                <div class="tsstatusItem">
                    <div class="tsstatusLabel">
                        <img src="' 
$this->imagePath $icon '" />' $user["client_nickname"] . '
                    </div>
                    <div class="tsstatusFlags">
                        ' 
$this->renderFlags($flags) . '
                    </div>
                </div>'
;
            }
        }
        return 
$out;
    }
    
    private function 
renderChannels($parentId)
    {
        
$out "";
        foreach (
$this->_channelDatas as $channel)
        {
            if(
$channel["pid"] == $parentId)
            {
                
$icon "16x16_channel_green.png";
                if( 
$channel["channel_maxclients"] > -&& ($channel["total_clients"] >= $channel["channel_maxclients"])) $icon "16x16_channel_red.png";
                else if( 
$channel["channel_maxfamilyclients"] > -&& ($channel["total_clients_family"] >= $channel["channel_maxfamilyclients"])) $icon "16x16_channel_red.png";
                else if(
$channel["channel_flag_password"] == 1$icon "16x16_channel_yellow.png";
                
                
$flags = array();
                if(
$channel["channel_flag_default"] == 1$flags[] = '16x16_default.png';
                if(
$channel["channel_needed_talk_power"] > 0$flags[] = '16x16_moderated.png';
                if(
$channel["channel_flag_password"] == 1$flags[] = '16x16_register.png';

                
$link "javascript:tsstatusconnect('" $this->_host "','" $this->_serverDatas["virtualserver_port"] . "','" htmlentities($channel["channel_name"]) . "')";
                
                
$out .= '
                <div class="tsstatusItem">
                    <div class="tsstatusLabel">
                        <a href="' 
$link '">
                            <img src="' 
$this->imagePath $icon '" />' $channel["channel_name"] . '
                        </a>
                    </div>
                    <div class="tsstatusFlags">
                        ' 
$this->renderFlags($flags) . '
                    </div>
                    ' 
. (count($this->_userDatas) > $this->renderUsers($channel["cid"]) : '') . $this->renderChannels($channel["cid"]) . '
                </div>'
;
            }
        }
        return 
$out;
    }
    
    private function 
renderNickNameBox()
    {
        
$cookieName "tsstatus_" str_replace(".""_"$this->_host);
        
$nickname = isset($_COOKIE[$cookieName]) ? $_COOKIE[$cookieName] : "";
        
$out '<div class="tsstatusNickname">Nickname: <input type="text" id="tsstatusNick" value="' $nickname '" /></div>';
        return 
$out;
    }
    
    public function 
clearServerGroupFlags()
    {
        
$this->_serverGroupFlags = array();
    }
    
    public function 
setServerGroupFlag($serverGroupId$image)
    {
        
$this->_serverGroupFlags[$serverGroupId] = $image;
    }
    
    public function 
clearChannelGroupFlags()
    {
        
$this->_channelGroupFlags = array();
    }
    
    public function 
setChannelGroupFlag($channelGroupId$image)
    {
        
$this->_channelGroupFlags[$channelGroupId] = $image;
    }
    
    public function 
render()
    {
        try
        {
            
$out '<div class="tsstatus">' "\n";
            
$this->update();
        
            if (
$this->showNicknameBox$out .= $this->renderNickNameBox();
            
$out .= '<div class="tsstatusServerName"><a href="javascript:tsstatusconnect(\'' $this->_host "','" $this->_serverDatas["virtualserver_port"] . '\')"><img src="' $this->imagePath '16x16_server_green.png" />' $this->_serverDatas["virtualserver_name"] . "</a></div>\n";
            if(
count($this->_channelDatas) > 0$out .= $this->renderChannels(0);
            
$out .= "</div>\n";
        }
        catch (
Exception $ex)
        {
            
$this->disconnect();
            
$out '<div class="tsstatuserror">' $ex->getMessage() . '</div>';
        }
        return 
$out;        
    }
}

?>


Stifler 12.03.2011 18:26

So:

PHP-Code:

<?php 


class TSStatus
{
    private 
$_host;
    private 
$_qport;
    private 
$_sid;
    private 
$_socket;
    private 
$_updated;
    private 
$_serverDatas;
    private 
$_channelDatas;
    private 
$_userDatas;
    private 
$_serverGroupFlags;
    private 
$_channelGroupFlags;
    
    public 
$imagePath;
    public 
$decodeUTF8;
    public 
$showNicknameBox;
    public 
$timeout;
    
    public function 
TSStatus($host$queryPort$serverId)
    {
        
$this->_host $host;
        
$this->_qport $queryPort;
        
$this->_sid $serverId;
        
        
$this->_socket null;    
        
$this->_updated false;
        
$this->_serverDatas = array();
        
$this->_channelDatas = array();
        
$this->_userDatas = array();
        
$this->_serverGroupFlags = array();
        
$this->_channelGroupFlags = array();
        
        
$this->imagePath "img/";
        
$this->decodeUTF8 false;
        
$this->showNicknameBox true;
        
$this->timeout 2;
        
        
$this->setServerGroupFlag(6'servergroup_300.png');
        
$this->setChannelGroupFlag(5'changroup_100.png');
        
$this->setChannelGroupFlag(6'changroup_200.png');
    }
    
    private function 
unescape($str)
    {
        
$find = array('\\',     "\/",         "\s",         "\p",         "\a",     "\b",     "\f",         "\n",         "\r",     "\t",     "\v");
        
$rplc = array(chr(92),    chr(47),    chr(32),    chr(124),    chr(7),    chr(8),    chr(12),    chr(10),    chr(3),    chr(9),    chr(11));
        
        return 
str_replace($find$rplc$str);
    }
    
    private function 
parseLine($rawLine)
    {
        
$datas = array();
        
$rawItems explode("|"$rawLine);
        foreach (
$rawItems as $rawItem)
        {
            
$rawDatas explode(" "$rawItem);
            
$tempDatas = array();
            foreach(
$rawDatas as $rawData)
            {
                
$ar explode("="$rawData2);
                
$tempDatas[$ar[0]] = isset($ar[1]) ? $this->unescape($ar[1]) : "";
            }
            
$datas[] = $tempDatas;
        }
        return 
$datas;
    }
    
    private function 
sendCommand($cmd)
    {
        
fputs($this->_socket"$cmd\n");
        
$response "";
        
        while(
strpos($response"error id=") === false) {
        
$response .= @fread($this->_socket8096);
        }
        
        if(
strpos($response"error id=0") === false)
        {
            throw new 
Exception("TS3 Server returned the following error: " $this->unescape(trim($response)));
        }
        
        return 
$response;
    }
    
    private function 
queryServer()
    {
        
$this->_socket = @fsockopen($this->_host$this->_qport$errno$errstr$this->timeout);
        if(
$this->_socket)
        {
            @
socket_set_timeout($this->_socket$this->timeout);
            
$isTs3 trim(fgets($this->_socket)) == "TS3";
            if(!
$isTs3) throw new Exception("Not a Teamspeak 3 server/bad query port");

            
$response "";
            
$response .= $this->sendCommand("use sid=" $this->_sid);
            
$response .= $this->sendCommand("serverinfo");
            
$response .= $this->sendCommand("channellist -topic -flags -voice -limits");
            
$response .= $this->sendCommand("clientlist -uid -away -voice -groups");

            
$this->disconnect();
            
            if(
$this->decodeUTF8$response utf8_decode($response);
            
            return 
$response;
        }
        else throw new 
Exception("Socket error: $errstr [$errno]");
    }
    
    private function 
disconnect()
    {
        @
fputs($this->_socket"quit\n");
        @
fclose($this->_socket);
    }
    
    private function 
sortUsers($a$b)
    {
        return 
strcasecmp($a["client_nickname"], $b["client_nickname"]);
    }
    
    private function 
update()
    {
        
$response $this->queryServer();
        
    
$lines explode("\n\rerror id=0 msg=ok\n\r"$response);
        if(
count($lines) == 5)
        {
            
$this->_serverDatas $this->parseLine($lines[1]);
            
$this->_serverDatas $this->_serverDatas[0];

            
$this->_channelDatas $this->parseLine($lines[2]);
            
$this->_userDatas $this->parseLine($lines[3]);
            
usort($this->_userDatas, array($this"sortUsers"));

            
$this->_updated true;
        }
        else 
$this->error "Invalid server response";
        
    }
    
    private function 
renderFlags($flags)
    {
        
$out "";
        foreach (
$flags as $flag$out .= '<img src="' $this->imagePath $flag '" />';
        return 
$out;
    }

    private function 
renderUsers($parentId)
    {
        
$out "";
        foreach(
$this->_userDatas as $user)
        {
            if(
$user["client_type"] == && $user["cid"] == $parentId)
            {
                
$icon "16x16_player_off.png";
                if(
$user["client_away"] == 1$icon "16x16_away.png";
                else if(
$user["client_flag_talking"] == 1$icon "16x16_player_on.png";
                else if(
$user["client_output_hardware"] == 0$icon "16x16_hardware_output_muted.png";
                else if(
$user["client_output_muted"] == 1$icon "16x16_output_muted.png";
                else if(
$user["client_input_hardware"] == 0$icon "16x16_hardware_input_muted.png";
                else if(
$user["client_input_muted"] == 1$icon "16x16_input_muted.png";
                
                
$flags = array();
                if(isset(
$this->_channelGroupFlags[$user["client_channel_group_id"]])) $flags[] = $this->_channelGroupFlags[$user["client_channel_group_id"]];
                
$serverGroups explode(","$user["client_servergroups"]);
                foreach (
$serverGroups as $serverGroup) if(isset($this->_serverGroupFlags[$serverGroup])) $flags[] = $this->_serverGroupFlags[$serverGroup];
                
                
$out .= '
                <div class="tsstatusItem">
                    <div class="tsstatusLabel">
                        <img src="' 
$this->imagePath $icon '" />' $user["client_nickname"] . '
                    </div>
                    <div class="tsstatusFlags">
                        ' 
$this->renderFlags($flags) . '
                    </div>
                </div>'
;
            }
        }
        return 
$out;
    }
    
    private function 
renderChannels($parentId)
    {
        
$out "";
        foreach (
$this->_channelDatas as $channel)
        {
            if(
$channel["pid"] == $parentId)
            {
                
$icon "16x16_channel_green.png";
                if( 
$channel["channel_maxclients"] > -&& ($channel["total_clients"] >= $channel["channel_maxclients"])) $icon "16x16_channel_red.png";
                else if( 
$channel["channel_maxfamilyclients"] > -&& ($channel["total_clients_family"] >= $channel["channel_maxfamilyclients"])) $icon "16x16_channel_red.png";
                else if(
$channel["channel_flag_password"] == 1$icon "16x16_channel_yellow.png";
                
                
$flags = array();
                if(
$channel["channel_flag_default"] == 1$flags[] = '16x16_default.png';
                if(
$channel["channel_needed_talk_power"] > 0$flags[] = '16x16_moderated.png';
                if(
$channel["channel_flag_password"] == 1$flags[] = '16x16_register.png';

                
$link "javascript:tsstatusconnect('" $this->_host "','" $this->_serverDatas["virtualserver_port"] . "','" htmlentities($channel["channel_name"]) . "')";
                
                
$out .= '
                <div class="tsstatusItem">
                    <div class="tsstatusLabel">
                        <a href="' 
$link '">
                            <img src="' 
$this->imagePath $icon '" />' $channel["channel_name"] . '
                        </a>
                    </div>
                    <div class="tsstatusFlags">
                        ' 
$this->renderFlags($flags) . '
                    </div>
                    ' 
. (count($this->_userDatas) > $this->renderUsers($channel["cid"]) : '') . $this->renderChannels($channel["cid"]) . '
                </div>'
;
            }
        }
        return 
$out;
    }
    
    private function 
renderNickNameBox()
    {
        
$cookieName "tsstatus_" str_replace(".""_"$this->_host);
        
$nickname = isset($_COOKIE[$cookieName]) ? $_COOKIE[$cookieName] : "";
        
$out '<div class="tsstatusNickname">Nickname: <input type="text" id="tsstatusNick" value="' $nickname '" /></div>';
        return 
$out;
    }
    
    public function 
clearServerGroupFlags()
    {
        
$this->_serverGroupFlags = array();
    }
    
    public function 
setServerGroupFlag($serverGroupId$image)
    {
        
$this->_serverGroupFlags[$serverGroupId] = $image;
    }
    
    public function 
clearChannelGroupFlags()
    {
        
$this->_channelGroupFlags = array();
    }
    
    public function 
setChannelGroupFlag($channelGroupId$image)
    {
        
$this->_channelGroupFlags[$channelGroupId] = $image;
    }
    
    public function 
render()
    {
        try
        {
            
$out '<div class="tsstatus">' "\n";
            
$this->update();
        
            if (
$this->showNicknameBox$out .= $this->renderNickNameBox();
            
$out .= '<div class="tsstatusServerName"><a href="javascript:tsstatusconnect(\'' $this->_host "','" $this->_serverDatas["virtualserver_port"] . '\')"><img src="' $this->imagePath '16x16_server_green.png" />' $this->_serverDatas["virtualserver_name"] . "</a></div>\n";
            if(
count($this->_channelDatas) > 0$out .= $this->renderChannels(0);
            
$out .= "</div>\n";
        }
        catch (
Exception $ex)
        {
            
$this->disconnect();
            
$out '<div class="tsstatuserror">' $ex->getMessage() . '</div>';
        }
        return 
$out;        
    }
}

?>



Alle Zeitangaben in WEZ +1. Es ist jetzt 14:40 Uhr.

Powered by vBulletin® Version 3.8.9 (Deutsch)
Copyright ©2000 - 2025, vBulletin Solutions, Inc.