TeamSpeak 3 PHP Framework  1.1.16
Copyright © Planet TeamSpeak. All rights reserved.
 All Classes Namespaces Files Functions Variables Pages
TeamSpeak3.php
Go to the documentation of this file.
1 <?php
2 
3 /**
4  * @file
5  * TeamSpeak 3 PHP Framework
6  *
7  * $Id: TeamSpeak3.php 8/31/2012 11:06:09 scp@orilla $
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  *
22  * @package TeamSpeak3
23  * @version 1.1.16
24  * @author Sven 'ScP' Paulsen
25  * @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
26  */
27 
28 /**
29  * @class TeamSpeak3
30  * @brief Factory class all for TeamSpeak 3 PHP Framework objects.
31  */
33 {
34  /**
35  * TeamSpeak 3 protocol welcome message.
36  */
37  const READY = "TS3";
38 
39  /**
40  * TeamSpeak 3 protocol greeting message prefix.
41  */
42  const GREET = "Welcome";
43 
44  /**
45  * TeamSpeak 3 protocol error message prefix.
46  */
47  const ERROR = "error";
48 
49  /**
50  * TeamSpeak 3 protocol event message prefix.
51  */
52  const EVENT = "notify";
53 
54  /**
55  * TeamSpeak 3 protocol server connection handler ID prefix.
56  */
57  const SCHID = "selected";
58 
59  /**
60  * TeamSpeak 3 PHP Framework version.
61  */
62  const LIB_VERSION = "1.1.16";
63 
64  /*@
65  * TeamSpeak 3 protocol separators.
66  */
67  const SEPARATOR_LINE = "\n"; //!< protocol line separator
68  const SEPARATOR_LIST = "|"; //!< protocol list separator
69  const SEPARATOR_CELL = " "; //!< protocol cell separator
70  const SEPARATOR_PAIR = "="; //!< protocol pair separator
71 
72  /*@
73  * TeamSpeak 3 log levels.
74  */
75  const LOGLEVEL_CRITICAL = 0x00; //!< 0: these messages stop the program
76  const LOGLEVEL_ERROR = 0x01; //!< 1: everything that is really bad
77  const LOGLEVEL_WARNING = 0x02; //!< 2: everything that might be bad
78  const LOGLEVEL_DEBUG = 0x03; //!< 3: output that might help find a problem
79  const LOGLEVEL_INFO = 0x04; //!< 4: informational output
80  const LOGLEVEL_DEVEL = 0x05; //!< 5: development output
81 
82  /*@
83  * TeamSpeak 3 token types.
84  */
85  const TOKEN_SERVERGROUP = 0x00; //!< 0: server group token (id1={groupID} id2=0)
86  const TOKEN_CHANNELGROUP = 0x01; //!< 1: channel group token (id1={groupID} id2={channelID})
87 
88  /*@
89  * TeamSpeak 3 codec identifiers.
90  */
91  const CODEC_SPEEX_NARROWBAND = 0x00; //!< 0: speex narrowband (mono, 16bit, 8kHz)
92  const CODEC_SPEEX_WIDEBAND = 0x01; //!< 1: speex wideband (mono, 16bit, 16kHz)
93  const CODEC_SPEEX_ULTRAWIDEBAND = 0x02; //!< 2: speex ultra-wideband (mono, 16bit, 32kHz)
94  const CODEC_CELT_MONO = 0x03; //!< 3: celt mono (mono, 16bit, 48kHz)
95 
96  /*@
97  * TeamSpeak 3 codec encryption modes.
98  */
99  const CODEC_CRYPT_INDIVIDUAL = 0x00; //!< 0: configure per channel
100  const CODEC_CRYPT_DISABLED = 0x01; //!< 1: globally disabled
101  const CODEC_CRYPT_ENABLED = 0x02; //!< 2: globally enabled
102 
103  /*@
104  * TeamSpeak 3 kick reason types.
105  */
106  const KICK_CHANNEL = 0x04; //!< 4: kick client from channel
107  const KICK_SERVER = 0x05; //!< 5: kick client from server
108 
109  /*@
110  * TeamSpeak 3 text message target modes.
111  */
112  const TEXTMSG_CLIENT = 0x01; //!< 1: target is a client
113  const TEXTMSG_CHANNEL = 0x02; //!< 2: target is a channel
114  const TEXTMSG_SERVER = 0x03; //!< 3: target is a virtual server
115 
116  /*@
117  * TeamSpeak 3 host message modes.
118  */
119  const HOSTMSG_NONE = 0x00; //!< 0: display no message
120  const HOSTMSG_LOG = 0x01; //!< 1: display message in chatlog
121  const HOSTMSG_MODAL = 0x02; //!< 2: display message in modal dialog
122  const HOSTMSG_MODALQUIT = 0x03; //!< 3: display message in modal dialog and close connection
123 
124  /*@
125  * TeamSpeak 3 host banner modes.
126  */
127  const HOSTBANNER_NO_ADJUST = 0x00; //!< 0: do not adjust
128  const HOSTBANNER_IGNORE_ASPECT = 0x01; //!< 1: adjust but ignore aspect ratio
129  const HOSTBANNER_KEEP_ASPECT = 0x02; //!< 2: adjust and keep aspect ratio
130 
131  /*@
132  * TeamSpeak 3 client identification types.
133  */
134  const CLIENT_TYPE_REGULAR = 0x00; //!< 0: regular client
135  const CLIENT_TYPE_SERVERQUERY = 0x01; //!< 1: query client
136 
137  /*@
138  * TeamSpeak 3 permission group database types.
139  */
140  const GROUP_DBTYPE_TEMPLATE = 0x00; //!< 0: template group (used for new virtual servers)
141  const GROUP_DBTYPE_REGULAR = 0x01; //!< 1: regular group (used for regular clients)
142  const GROUP_DBTYPE_SERVERQUERY = 0x02; //!< 2: global query group (used for ServerQuery clients)
143 
144  /*@
145  * TeamSpeak 3 permission group name modes.
146  */
147  const GROUP_NAMEMODE_HIDDEN = 0x00; //!< 0: display no name
148  const GROUP_NAMEMODE_BEFORE = 0x01; //!< 1: display name before client nickname
149  const GROUP_NAMEMODE_BEHIND = 0x02; //!< 2: display name after client nickname
150 
151  /*@
152  * TeamSpeak 3 permission group identification types.
153  */
154  const GROUP_IDENTIFIY_STRONGEST = 0x01; //!< 1: identify most powerful group
155  const GROUP_IDENTIFIY_WEAKEST = 0x02; //!< 2: identify weakest group
156 
157  /*@
158  * TeamSpeak 3 permission types.
159  */
160  const PERM_TYPE_SERVERGROUP = 0x00; //!< 0: server group permission
161  const PERM_TYPE_CLIENT = 0x01; //!< 1: client specific permission
162  const PERM_TYPE_CHANNEL = 0x02; //!< 2: channel specific permission
163  const PERM_TYPE_CHANNELGROUP = 0x03; //!< 3: channel group permission
164  const PERM_TYPE_CHANNELCLIENT = 0x04; //!< 4: channel-client specific permission
165 
166  /*@
167  * TeamSpeak 3 permission categories.
168  */
169  const PERM_CAT_GLOBAL = 0x10; //!< 00010000: global permissions
170  const PERM_CAT_GLOBAL_INFORMATION = 0x11; //!< 00010001: global permissions -> global information
171  const PERM_CAT_GLOBAL_SERVER_MGMT = 0x12; //!< 00010010: global permissions -> virtual server management
172  const PERM_CAT_GLOBAL_ADM_ACTIONS = 0x13; //!< 00010011: global permissions -> global administrative actions
173  const PERM_CAT_GLOBAL_SETTINGS = 0x14; //!< 00010100: global permissions -> global settings
174  const PERM_CAT_SERVER = 0x20; //!< 00100000: virtual server permissions
175  const PERM_CAT_SERVER_INFORMATION = 0x21; //!< 00100001: virtual server permissions -> virtual server information
176  const PERM_CAT_SERVER_ADM_ACTIONS = 0x22; //!< 00100010: virtual server permissions -> virtual server administrative actions
177  const PERM_CAT_SERVER_SETTINGS = 0x23; //!< 00100011: virtual server permissions -> virtual server settings
178  const PERM_CAT_CHANNEL = 0x30; //!< 00110000: channel permissions
179  const PERM_CAT_CHANNEL_INFORMATION = 0x31; //!< 00110001: channel permissions -> channel information
180  const PERM_CAT_CHANNEL_CREATE = 0x32; //!< 00110010: channel permissions -> create channels
181  const PERM_CAT_CHANNEL_MODIFY = 0x33; //!< 00110011: channel permissions -> edit channels
182  const PERM_CAT_CHANNEL_DELETE = 0x34; //!< 00110100: channel permissions -> delete channels
183  const PERM_CAT_CHANNEL_ACCESS = 0x35; //!< 00110101: channel permissions -> access channels
184  const PERM_CAT_GROUP = 0x40; //!< 01000000: group permissions
185  const PERM_CAT_GROUP_INFORMATION = 0x41; //!< 01000001: group permissions -> group information
186  const PERM_CAT_GROUP_CREATE = 0x42; //!< 01000010: group permissions -> create groups
187  const PERM_CAT_GROUP_MODIFY = 0x43; //!< 01000011: group permissions -> edit groups
188  const PERM_CAT_GROUP_DELETE = 0x44; //!< 01000100: group permissions -> delete groups
189  const PERM_CAT_CLIENT = 0x50; //!< 01010000: client permissions
190  const PERM_CAT_CLIENT_INFORMATION = 0x51; //!< 01010001: client permissions -> client information
191  const PERM_CAT_CLIENT_ADM_ACTIONS = 0x52; //!< 01010010: client permissions -> client administrative actions
192  const PERM_CAT_CLIENT_BASICS = 0x53; //!< 01010011: client permissions -> client basic communication
193  const PERM_CAT_CLIENT_MODIFY = 0x54; //!< 01010100: client permissions -> edit clients
194  const PERM_CAT_FILETRANSFER = 0x60; //!< 01100000: file transfer permissions
195  const PERM_CAT_NEEDED_MODIFY_POWER = 0xFF; //!< 11111111: needed permission modify power (grant) permissions
196 
197  /*@
198  * TeamSpeak 3 file types.
199  */
200  const FILE_TYPE_DIRECTORY = 0x00; //!< 0: file is directory
201  const FILE_TYPE_REGULAR = 0x01; //!< 1: file is regular
202 
203  /*@
204  * TeamSpeak 3 server snapshot types.
205  */
206  const SNAPSHOT_STRING = 0x00; //!< 0: default string
207  const SNAPSHOT_BASE64 = 0x01; //!< 1: base64 string
208  const SNAPSHOT_HEXDEC = 0x02; //!< 2: hexadecimal string
209 
210  /*@
211  * TeamSpeak 3 channel spacer types.
212  */
213  const SPACER_SOLIDLINE = 0x00; //!< 0: solid line
214  const SPACER_DASHLINE = 0x01; //!< 1: dash line
215  const SPACER_DOTLINE = 0x02; //!< 2: dot line
216  const SPACER_DASHDOTLINE = 0x03; //!< 3: dash dot line
217  const SPACER_DASHDOTDOTLINE = 0x04; //!< 4: dash dot dot line
218  const SPACER_CUSTOM = 0x05; //!< 5: custom format
219 
220  /*@
221  * TeamSpeak 3 channel spacer alignments.
222  */
223  const SPACER_ALIGN_LEFT = 0x00; //!< 0: alignment left
224  const SPACER_ALIGN_RIGHT = 0x01; //!< 1: alignment right
225  const SPACER_ALIGN_CENTER = 0x02; //!< 2: alignment center
226  const SPACER_ALIGN_REPEAT = 0x03; //!< 3: repeat until the whole line is filled
227 
228  /*@
229  * TeamSpeak 3 reason identifiers.
230  */
231  const REASON_NONE = 0x00; //!< 0: no reason
232  const REASON_MOVE = 0x01; //!< 1: channel switched or moved
233  const REASON_SUBSCRIPTION = 0x02; //!< 2: subscription added or removed
234  const REASON_TIMEOUT = 0x03; //!< 3: client connection timed out
235  const REASON_CHANNEL_KICK = 0x04; //!< 4: client kicked from channel
236  const REASON_SERVER_KICK = 0x05; //!< 5: client kicked from server
237  const REASON_SERVER_BAN = 0x06; //!< 6: client banned from server
238  const REASON_SERVER_STOP = 0x07; //!< 7: server stopped
239  const REASON_DISCONNECT = 0x08; //!< 8: client disconnected
240  const REASON_CHANNEL_UPDATE = 0x09; //!< 9: channel information updated
241  const REASON_CHANNEL_EDIT = 0x0A; //!< 10: channel information edited
242  const REASON_DISCONNECT_SHUTDOWN = 0x0B; //!< 11: client disconnected on server shutdown
243 
244  /**
245  * Stores an array containing various chars which need to be escaped while communicating
246  * with a TeamSpeak 3 Server.
247  *
248  * @var array
249  */
250  protected static $escape_patterns = array(
251  "\\" => "\\\\", // backslash
252  "/" => "\\/", // slash
253  " " => "\\s", // whitespace
254  "|" => "\\p", // pipe
255  ";" => "\\;", // semicolon
256  "\a" => "\\a", // bell
257  "\b" => "\\b", // backspace
258  "\f" => "\\f", // formfeed
259  "\n" => "\\n", // newline
260  "\r" => "\\r", // carriage return
261  "\t" => "\\t", // horizontal tab
262  "\v" => "\\v" // vertical tab
263  );
264 
265  /**
266  * Factory for TeamSpeak3_Adapter_Abstract classes. $uri must be formatted as
267  * "<adapter>://<user>:<pass>@<host>:<port>/<options>#<flags>". All parameters
268  * except adapter, host and port are optional.
269  *
270  * === Supported Options ===
271  * - timeout
272  * - blocking
273  * - nickname
274  * - no_query_clients
275  * - use_offline_as_virtual
276  * - clients_before_channels
277  * - server_id|server_uid|server_port|server_name|server_tsdns
278  * - channel_id|channel_name
279  * - client_id|client_uid|client_name
280  *
281  * === Supported Flags (only one per $uri) ===
282  * - no_query_clients
283  * - use_offline_as_virtual
284  * - clients_before_channels
285  *
286  * === URI Examples ===
287  * - serverquery://127.0.0.1:10011/
288  * - serverquery://127.0.0.1:10011/?server_port=9987&channel_id=1
289  * - serverquery://127.0.0.1:10011/?server_port=9987&channel_id=1#no_query_clients
290  * - serverquery://127.0.0.1:10011/?server_port=9987&client_name=ScP
291  * - filetransfer://127.0.0.1:30011/
292  * - blacklist
293  * - update
294  *
295  * @param string $uri
296  * @return TeamSpeak3_Adapter_Abstract
297  * @return TeamSpeak3_Node_Abstract
298  */
299  public static function factory($uri)
300  {
301  self::init();
302 
303  $uri = new TeamSpeak3_Helper_Uri($uri);
304 
305  $adapter = self::getAdapterName($uri->getScheme());
306  $options = array("host" => $uri->getHost(), "port" => $uri->getPort(), "timeout" => intval($uri->getQueryVar("timeout", 10)), "blocking" => intval($uri->getQueryVar("blocking", 1)));
307 
308  self::loadClass($adapter);
309 
310  $object = new $adapter($options);
311 
312  if($object instanceof TeamSpeak3_Adapter_ServerQuery)
313  {
314  $node = $object->getHost();
315 
316  if($uri->hasUser() && $uri->hasPass())
317  {
318  $node->login($uri->getUser(), $uri->getPass());
319  }
320 
321  /* option to pre-define nickname */
322  if($uri->hasQueryVar("nickname"))
323  {
324  $node->setPredefinedQueryName($uri->getQueryVar("nickname"));
325  }
326 
327  /* flag to use offline servers in virtual mode */
328  if($uri->getFragment() == "use_offline_as_virtual")
329  {
330  $node->setUseOfflineAsVirtual(TRUE);
331  }
332  elseif($uri->hasQueryVar("use_offline_as_virtual"))
333  {
334  $node->setUseOfflineAsVirtual($uri->getQueryVar("use_offline_as_virtual") ? TRUE : FALSE);
335  }
336 
337  /* flag to fetch clients before sub-channels */
338  if($uri->getFragment() == "clients_before_channels")
339  {
340  $node->setLoadClientlistFirst(TRUE);
341  }
342  elseif($uri->hasQueryVar("clients_before_channels"))
343  {
344  $node->setLoadClientlistFirst($uri->getQueryVar("clients_before_channels") ? TRUE : FALSE);
345  }
346 
347  /* flag to hide ServerQuery clients */
348  if($uri->getFragment() == "no_query_clients")
349  {
350  $node->setExcludeQueryClients(TRUE);
351  }
352  elseif($uri->hasQueryVar("no_query_clients"))
353  {
354  $node->setExcludeQueryClients($uri->getQueryVar("no_query_clients") ? TRUE : FALSE);
355  }
356 
357  /* access server node object */
358  if($uri->hasQueryVar("server_id"))
359  {
360  $node = $node->serverGetById($uri->getQueryVar("server_id"));
361  }
362  elseif($uri->hasQueryVar("server_uid"))
363  {
364  $node = $node->serverGetByUid($uri->getQueryVar("server_uid"));
365  }
366  elseif($uri->hasQueryVar("server_port"))
367  {
368  $node = $node->serverGetByPort($uri->getQueryVar("server_port"));
369  }
370  elseif($uri->hasQueryVar("server_name"))
371  {
372  $node = $node->serverGetByName($uri->getQueryVar("server_name"));
373  }
374  elseif($uri->hasQueryVar("server_tsdns"))
375  {
376  $node = $node->serverGetByTSDNS($uri->getQueryVar("server_tsdns"));
377  }
378 
379  /* direct access to node objects */
380  if($node instanceof TeamSpeak3_Node_Server)
381  {
382  /* access channel node object */
383  if($uri->hasQueryVar("channel_id"))
384  {
385  $node = $node->channelGetById($uri->getQueryVar("channel_id"));
386  }
387  elseif($uri->hasQueryVar("channel_name"))
388  {
389  $node = $node->channelGetByName($uri->getQueryVar("channel_name"));
390  }
391 
392  /* access client node object */
393  if($uri->hasQueryVar("client_id"))
394  {
395  $node = $node->clientGetById($uri->getQueryVar("client_id"));
396  }
397  if($uri->hasQueryVar("client_uid"))
398  {
399  $node = $node->clientGetByUid($uri->getQueryVar("client_uid"));
400  }
401  elseif($uri->hasQueryVar("client_name"))
402  {
403  $node = $node->clientGetByName($uri->getQueryVar("client_name"));
404  }
405  }
406 
407  return $node;
408  }
409 
410  return $object;
411  }
412 
413  /**
414  * Loads a class from a PHP file. The filename must be formatted as "$class.php".
415  *
416  * include() is not prefixed with the @ operator because if the file is loaded and
417  * contains a parse error, execution will halt silently and this is difficult to debug.
418  *
419  * @param string $class
420  * @throws LogicException
421  * @return boolean
422  */
423  protected static function loadClass($class)
424  {
425  if(class_exists($class, FALSE) || interface_exists($class, FALSE))
426  {
427  return;
428  }
429 
430  if(preg_match("/[^a-z0-9\\/\\\\_.-]/i", $class))
431  {
432  throw new LogicException("illegal characters in classname '" . $class . "'");
433  }
434 
435  $file = self::getFilePath($class) . ".php";
436 
437  if(!file_exists($file) || !is_readable($file))
438  {
439  throw new LogicException("file '" . $file . "' does not exist or is not readable");
440  }
441 
442  if(class_exists($class, FALSE) || interface_exists($class, FALSE))
443  {
444  throw new LogicException("class '" . $class . "' does not exist");
445  }
446 
447  return include_once($file);
448  }
449 
450  /**
451  * Generates a possible file path for $name.
452  *
453  * @param string $name
454  * @return string
455  */
456  protected static function getFilePath($name)
457  {
458  $path = str_replace("_", DIRECTORY_SEPARATOR, $name);
459  $path = str_replace(__CLASS__, dirname(__FILE__), $path);
460 
461  return $path;
462  }
463 
464  /**
465  * Returns the name of an adapter class by $name.
466  *
467  * @param string $name
468  * @param string $namespace
469  * @throws TeamSpeak3_Adapter_Exception
470  * @return string
471  */
472  protected static function getAdapterName($name, $namespace = "TeamSpeak3_Adapter_")
473  {
474  $path = self::getFilePath($namespace);
475  $scan = scandir($path);
476 
477  foreach($scan as $node)
478  {
479  $file = TeamSpeak3_Helper_String::factory($node)->toLower();
480 
481  if($file->startsWith($name) && $file->endsWith(".php"))
482  {
483  return $namespace . str_replace(".php", "", $node);
484  }
485  }
486 
487  throw new TeamSpeak3_Adapter_Exception("adapter '" . $name . "' does not exist");
488  }
489 
490  /**
491  * spl_autoload() suitable implementation for supporting class autoloading.
492  *
493  * @param string $class
494  * @return boolean
495  */
496  public static function autoload($class)
497  {
498  if(substr($class, 0, strlen(__CLASS__)) != __CLASS__) return;
499 
500  try
501  {
502  self::loadClass($class);
503 
504  return TRUE;
505  }
506  catch(Exception $e)
507  {
508  return FALSE;
509  }
510  }
511 
512  /**
513  * Checks for required PHP features, enables autoloading and starts a default profiler.
514  *
515  * @throws LogicException
516  * @return void
517  */
518  public static function init()
519  {
520  if(version_compare(phpversion(), "5.2.1") == -1)
521  {
522  throw new LogicException("this particular software cannot be used with the installed version of PHP");
523  }
524 
525  if(!function_exists("stream_socket_client"))
526  {
527  throw new LogicException("network functions are not available in this PHP installation");
528  }
529 
530  if(!function_exists("spl_autoload_register"))
531  {
532  throw new LogicException("autoload functions are not available in this PHP installation");
533  }
534 
535  if(!class_exists("TeamSpeak3_Helper_Profiler"))
536  {
537  spl_autoload_register(array(__CLASS__, "autoload"));
538  }
539 
541  }
542 
543  /**
544  * Returns an assoc array containing all escape patterns available on a TeamSpeak 3
545  * Server.
546  *
547  * @return array
548  */
549  public static function getEscapePatterns()
550  {
551  return self::$escape_patterns;
552  }
553 
554  /**
555  * Debug helper function. This is a wrapper for var_dump() that adds the pre-format tags,
556  * cleans up newlines and indents, and runs htmlentities() before output.
557  *
558  * @param mixed $var
559  * @param bool $echo
560  * @return string
561  */
562  public static function dump($var, $echo = TRUE)
563  {
564  ob_start();
565  var_dump($var);
566 
567  $output = ob_get_clean();
568  $output = preg_replace("/\]\=>\n(\s+)/m", "] => ", $output);
569 
570  if(PHP_SAPI == "cli")
571  {
572  $output = PHP_EOL . PHP_EOL . $output . PHP_EOL;
573  }
574  else
575  {
576  $output = "<pre>" . htmlspecialchars($output, ENT_QUOTES) . "</pre>";
577  }
578 
579  if($echo) echo($output);
580 
581  return $output;
582  }
583 }
584 
585 /*!
586  * \mainpage API Documentation
587  *
588  * \section welcome_sec Introduction
589  *
590  * \subsection welcome1 What is the TS3 PHP Framework?
591  * Initially released in January 2010, the TS3 PHP Framework is a powerful, open source, object-oriented framework
592  * implemented in PHP 5 and licensed under the GNU General Public License. It's based on simplicity and a rigorously
593  * tested agile codebase. Extend the functionality of your servers with scripts or create powerful web applications
594  * to manage all features of your TeamSpeak 3 Server instances.
595  *
596  * Tested. Thoroughly. Enterprise-ready and built with agile methods, the TS3 PHP Framework has been unit-tested from
597  * the start to ensure that all code remains stable and easy for you to extend, re-test with your extensions, and
598  * further maintain.
599  *
600  * \subsection welcome2 Why should I use the TS3 PHP Framework rather than other PHP libraries?
601  * The TS3 PHP Framework is a is a modern use-at-will framework that provides individual components to communicate
602  * with the TeamSpeak 3 Server.
603  *
604  * There are lots of arguments for the TS3 PHP Framework in comparison with other PHP based libraries. It is the most
605  * dynamic and feature-rich piece of software in its class. In addition, it's the only PHP library that parses the data
606  * spit out of the ServerQuery interface correctly.
607  *
608  * \section sysreqs_sec Requirements
609  * The TS3 PHP Framework currently supports PHP 5.2.1 or later, but we strongly recommend the most current release of
610  * PHP for critical security and performance enhancements. If you want to create a web application using the TS3 PHP
611  * Framework, you need a PHP 5 interpreter with a web server configured to handle PHP scripts correctly.
612  *
613  * Note that the majority of TS3 PHP Framework development and deployment is done on Apache, so there is more community
614  * experience and testing performed on Apache than on other web servers.
615  *
616  * \section feature_sec Features
617  * Features of the TS3 PHP Framework include:
618  *
619  * - Fully object-oriented PHP 5 and E_STRICT compliant components
620  * - Access to all TeamSpeak 3 Server features via ServerQuery
621  * - Integrated full featured and customizable TSViewer interfaces
622  * - Full support for file transfers to up- and /or download custom icons and other stuff
623  * - Powerful error handling capablities using exceptions and customizable error messages
624  * - Query mechanisms for several official services such as the blacklist and auto-update servers
625  * - Dynamic signal slots for event based scripting
626  * - ...
627  *
628  * \section example_sec Usage Examples
629  *
630  * \subsection example1 1. Kick all Clients from a Virtual Server
631  * @code
632  * // connect to local server, authenticate and quickly spawn an object for the virtual server on port 9987
633  * $ts3_VirtualServer = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/?server_port=9987");
634  *
635  * // query clientlist from virtual server
636  * $arr_ClientList = $ts3_VirtualServer->clientList();
637  *
638  * // kick all clients online with a single command
639  * $ts3_VirtualServer->clientKick($arr_ClientList, TeamSpeak3::KICK_SERVER, "evil kick XD");
640  * @endcode
641  *
642  * \subsection example2 2. Modify the Settings of each Virtual Server
643  * @code
644  * // connect to local server, authenticate and quickly spawn an object for the server instance
645  * $ts3_ServerInstance = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/?use_offline_as_virtual=1");
646  *
647  * // walk through list of virtual servers
648  * foreach($ts3_ServerInstance as $ts3_VirtualServer)
649  * {
650  * // modify the virtual servers hostbanner URL only
651  * $ts3_VirtualServer["virtualserver_hostbanner_gfx_url"] = "http://www.example.com/banners/banner01_468x60.jpg";
652  *
653  * // modify multiple virtual server properties at once
654  * $ts3_VirtualServer->modify(
655  * "virtualserver_hostbutton_tooltip" => "My Company",
656  * "virtualserver_hostbutton_url" => "http://www.example.com",
657  * "virtualserver_hostbutton_gfx_url" => "http://www.example.com/buttons/button01_24x24.jpg",
658  * );
659  * }
660  * @endcode
661  *
662  * \subsection example3 3. Modify the Permissions of Admins on each Virtual Server
663  * @code
664  * // connect to local server, authenticate and quickly spawn an object for the server instance
665  * $ts3_ServerInstance = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/?use_offline_as_virtual=1");
666  *
667  * // walk through list of virtual servers
668  * foreach($ts3_ServerInstance as $ts3_VirtualServer)
669  * {
670  * // identify the most powerful group on the virtual server
671  * $ts3_ServerGroup = $ts3_VirtualServer->serverGroupIdentify();
672  *
673  * // assign a new permission
674  * $ts3_ServerGroup->permAssign("b_virtualserver_modify_hostbanner", TRUE);
675  *
676  * // revoke an existing permission
677  * $ts3_ServerGroup->permRemove("b_virtualserver_modify_maxclients");
678  * }
679  * @endcode
680  *
681  * \subsection example4 4. Create a new Virtual Server
682  * @code
683  * // connect to local server and authenticate
684  * $ts3_ServerInstance = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/");
685  *
686  * // create a virtual server and get its ID
687  * $new_sid = $ts3_ServerInstance->serverCreate(
688  * "virtualserver_name" => "My TeamSpeak 3 Server",
689  * "virtualserver_maxclients" => 64,
690  * "virtualserver_hostbutton_tooltip" => "My Company",
691  * "virtualserver_hostbutton_url" => "http://www.example.com",
692  * "virtualserver_hostbutton_gfx_url" => "http://www.example.com/buttons/button01_24x24.jpg",
693  * );
694  * @endcode
695  *
696  * \subsection example5 5. Create a hierarchical Channel Stucture
697  * @code
698  * // connect to local server, authenticate and quickly spawn an object for the virtual server on port 9987
699  * $ts3_VirtualServer = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/?server_port=9987");
700  *
701  * // create a top-level channel and get its ID
702  * $top_cid = $ts3_VirtualServer->channelCreate(
703  * "channel_name" => "My Channel",
704  * "channel_topic" => "This is a top-level channel",
705  * "channel_codec" => TeamSpeak3::CODEC_SPEEX_WIDEBAND,
706  * "channel_flag_permanent" => TRUE,
707  * );
708  *
709  * // create a sub-level channel and get its ID
710  * $sub_cid = $ts3_VirtualServer->channelCreate(
711  * "channel_name" => "My Sub-Channel",
712  * "channel_topic" => "This is a sub-level channel",
713  * "channel_codec" => TeamSpeak3::CODEC_SPEEX_NARROWBAND,
714  * "channel_flag_permanent" => TRUE,
715  * "cpid" => $top_cid,
716  * );
717  * @endcode
718  *
719  * \subsection example6 6. Send a Text Message to outdated Clients
720  * @code
721  * // connect to local server, authenticate and quickly spawn an object for the virtual server on port 9987
722  * $ts3_VirtualServer = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/?server_port=9987");
723  *
724  * // connect to default update server
725  * $ts3_UpdateServer = TeamSpeak3::factory("update");
726  *
727  * // walk through list of clients on virtual server
728  * foreach($ts3_VirtualServer->clientList() as $ts3_Client)
729  * {
730  * // skip query clients
731  * if($ts3_Client["client_type"]) continue;
732  *
733  * // send test message if client build is outdated
734  * if($ts3_Client->getRev() < $ts3_UpdateServer->getClientRev())
735  * {
736  * $ts3_Client->message("[COLOR=red]your client is [B]outdated[/B]... update to [U]" . $ts3_UpdateServer->getClientVersion() . "[/U] now![/COLOR]");
737  * }
738  * }
739  * @endcode
740  *
741  * \subsection example7 7. Check if the Server Instance is Outdated or Blacklisted
742  * @code
743  * // connect to local server and authenticate
744  * $ts3_ServerInstance = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/");
745  *
746  * // connect to default update server
747  * $ts3_UpdateServer = TeamSpeak3::factory("update");
748  *
749  * // send global text message if the server is outdated
750  * if($ts3_ServerInstance->version("build") < $ts3_UpdateServer->getServerRev())
751  * {
752  * $ts3_ServerInstance->message("[COLOR=red]your server is [B]outdated[/B]... update to [U]" . $ts3_UpdateServer->getServerVersion() . "[/U] now![/COLOR]");
753  * }
754  *
755  * // connect to default blacklist server
756  * $ts3_BlacklistServer = TeamSpeak3::factory("blacklist");
757  *
758  * // send global text message if the server is blacklisted
759  * if($ts3_BlacklistServer->isBlacklisted($ts3_ServerInstance))
760  * {
761  * $ts3_ServerInstance->message("[COLOR=red]your server is [B]blacklisted[/B]... disconnect now![/COLOR]");
762  * }
763  * @endcode
764  *
765  * Speed up new development and reduce maintenance costs by using the TS3 PHP Framework!
766  */