da der Viewer von teamspeakviewer.com des Öfteren etwas länger zum laden braucht bzw. auch mal eine Fehlermeldung anzeigt, habe ich einen Ersatz gesucht und bin auch fündig geworden. Leider werden die Sonderzeichen nicht korrekt angezeigt. Umlaute gehen, aber keine, ich glaube, kyrillische Schriftarten.
Der Teamspeakviewer ist von tsstatus.sebastien.me/
Der TS3-Viewer sollte so aussehen (teamspeakviewer.com):

Die Ausgabe für den Viewer tsstatus erfolgt über die teamspeak.php
1 2 3 4 5 6 7 8 9 10 | <div style= "width:160px; height:100%; overflow:auto; border:0px solid #840; margin:1em;" > <?php require_once ( "/www/tsstatus/tsstatus.php" ); $tsstatus = new TSStatus( "85.114.150.101" , 10011, 3); $tsstatus ->imagePath = "/tsstatus/img/" ; $tsstatus ->showNicknameBox = true; $tsstatus ->decodeUTF8 = true; $tsstatus ->timeout = 2; echo $tsstatus ->render(); ?> |
Als ich es das erste mal gestartet hatte, stand folgender Wert noch auf "false"
1 | $tsstatus->decodeUTF8 = true; |
Da sah der Viewer so aus:

Jetzt, wo dieser Wert auf "true" steht, ist die Darstellung nicht mehr ganz so heftig, aber leider sind da, wo Sonderzeichen sein sollten, jetzt Fragezeichen.

Bisher habe ich herausgefunden, dass es an der Kodierung ISO-8859-1 und dessen Umwandlung zu utf-8 liegt bzw. an dem Befehl $decodeUTF8. Also liegt das Problem in der Abfrage, die über die Datei tsstatus.php läuft. Hier der Inhalt:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | <?php /** * TSStatus: Teamspeak 3 viewer for php5 * @author Sebastien Gerard <sebeuu@gmail.com> * **/ 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 ( "=" , $rawData , 2); $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 ->_socket, 8096); } 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" ] == 0 && $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" ] > -1 && ( $channel [ "total_clients" ] >= $channel [ "channel_maxclients" ])) $icon = "16x16_channel_red.png" ; else if ( $channel [ "channel_maxfamilyclients" ] > -1 && ( $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) > 0 ? $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 ; } } ?> |
Also der Inhalt dieser Datei übersteigt mein Wissen um einiges und ich konnte keine Lösung dafür im Netz finden, deswegen versuche ich es jetzt erstmal hier.
Kann mir jemand sagen, was zu tun ist, damit die Sonderzeichen, wie oben in der teamspeakviewer.com-Box, angezeigt werden?
Weiß jemand, warum der Text mittig steht und nicht linkbündig und viel wichtiger, warum ist bei einigen Channelnamen und beim Servernamen ein Zeilenumbruch drin? Im Viewer von teamspeak.com ist doch auch alles einzeilig.
Vielen Dank im Voraus für die Bemühungen...
MfG
Nick
verwendete ilchClan Version: 1.1 N
betroffene Homepage: externer Link