85 public const SCHID =
"selected";
354 $uri =
new Uri($uri);
357 $options = [
"host" => $uri->getHost(),
"port" => $uri->getPort(),
"timeout" => (int)$uri->getQueryVar(
"timeout", 10),
"blocking" => (int)$uri->getQueryVar(
"blocking", 1),
"tls" => (int)$uri->getQueryVar(
"tls", 0),
"ssh" => (int)$uri->getQueryVar(
"ssh", 0)];
361 if ($options[
"ssh"]) {
362 $options[
"username"] = $uri->getUser();
363 $options[
"password"] = $uri->getPass();
366 $adapterClass =
"PlanetTeamSpeak\\TeamSpeak3Framework\\" . str_replace(DIRECTORY_SEPARATOR,
"\\", $adapter);
368 $object =
new $adapterClass($options);
372 $node = $object->getHost();
374 if ($uri->hasUser() && $uri->hasPass()) {
375 $node->login($uri->getUser(), $uri->getPass());
378 if ($uri->hasQueryVar(
"nickname")) {
379 $node->setPredefinedQueryName($uri->getQueryVar(
"nickname"));
382 if ($uri->getFragment() ==
"use_offline_as_virtual") {
383 $node->setUseOfflineAsVirtual(
true);
384 } elseif ($uri->hasQueryVar(
"use_offline_as_virtual")) {
385 $node->setUseOfflineAsVirtual((
bool)$uri->getQueryVar(
"use_offline_as_virtual"));
388 if ($uri->getFragment() ==
"clients_before_channels") {
389 $node->setLoadClientlistFirst(
true);
390 } elseif ($uri->hasQueryVar(
"clients_before_channels")) {
391 $node->setLoadClientlistFirst((
bool)$uri->getQueryVar(
"clients_before_channels"));
394 if ($uri->getFragment() ==
"no_query_clients") {
395 $node->setExcludeQueryClients(
true);
396 } elseif ($uri->hasQueryVar(
"no_query_clients")) {
397 $node->setExcludeQueryClients((
bool)$uri->getQueryVar(
"no_query_clients"));
400 if ($uri->hasQueryVar(
"server_id")) {
401 $node = $node->serverGetById($uri->getQueryVar(
"server_id"));
402 } elseif ($uri->hasQueryVar(
"server_uid")) {
403 $node = $node->serverGetByUid($uri->getQueryVar(
"server_uid"));
404 } elseif ($uri->hasQueryVar(
"server_port")) {
405 $node = $node->serverGetByPort($uri->getQueryVar(
"server_port"));
406 } elseif ($uri->hasQueryVar(
"server_name")) {
407 $node = $node->serverGetByName($uri->getQueryVar(
"server_name"));
410 if ($node instanceof
Server) {
411 if ($uri->hasQueryVar(
"channel_id")) {
412 $node = $node->channelGetById($uri->getQueryVar(
"channel_id"));
413 } elseif ($uri->hasQueryVar(
"channel_name")) {
414 $node = $node->channelGetByName($uri->getQueryVar(
"channel_name"));
417 if ($uri->hasQueryVar(
"client_id")) {
418 $node = $node->clientGetById($uri->getQueryVar(
"client_id"));
420 if ($uri->hasQueryVar(
"client_uid")) {
421 $node = $node->clientGetByUid($uri->getQueryVar(
"client_uid"));
422 } elseif ($uri->hasQueryVar(
"client_name")) {
423 $node = $node->clientGetByName($uri->getQueryVar(
"client_name"));
430 $object->__destruct();
445 protected static function getAdapterName(
string $name,
string $namespace =
"Adapter_"): string
448 $scan = scandir(__DIR__ . DIRECTORY_SEPARATOR . $path);
450 foreach ($scan as $node) {
451 $file = StringHelper::factory($node)->toLower();
453 if ($file->startsWith($name) && $file->endsWith(
".php")) {
454 return $path . str_replace(
".php",
"", $node);
471 protected static function loadClass(
string $class): bool
473 if (class_exists($class,
false) || interface_exists($class,
false)) {
477 if (preg_match(
"/[^a-z0-9\\/\\\\_.-]/i", $class)) {
478 throw new Exception(
"illegal characters in classname '" . $class .
"'");
483 if (!file_exists($file) || !is_readable($file)) {
484 throw new Exception(
"file '" . $file .
"' does not exist or is not readable");
487 if (class_exists($class,
false) || interface_exists($class,
false)) {
488 throw new Exception(
"class '" . $class .
"' does not exist");
491 return include_once($file);
502 $path = str_replace(
"_", DIRECTORY_SEPARATOR, $name);
503 return str_replace(__CLASS__, dirname(__FILE__), $path);
512 public static function init(): void
514 if (version_compare(phpversion(),
"5.2.1") == -1) {
515 throw new Exception(
"this particular software cannot be used with the installed version of PHP");
518 if (!function_exists(
"stream_socket_client")) {
519 throw new Exception(
"network functions are not available in this PHP installation");
522 if (!function_exists(
"spl_autoload_register")) {
523 throw new Exception(
"autoload functions are not available in this PHP installation");
537 return self::$escape_patterns;
548 public static function dump(mixed $var,
bool $echo =
true): string
553 $output = preg_replace(
"/]=>\n(\s+)/m",
"] => ", ob_get_clean());
555 if (PHP_SAPI ==
"cli") {
556 $output = PHP_EOL . PHP_EOL . $output . PHP_EOL;
558 $output =
"<pre>" . htmlspecialchars($output, ENT_QUOTES,
"utf-8") .
"</pre>";
Provides low-level methods for file transfer communication with a TeamSpeak 3 Server.
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Adapter\Adapter objects.
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Helper* objects.
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery objects.
Helper class for string handling.
Helper class for URI handling.
Class describing a TeamSpeak 3 server instance and all it's parameters.
Class describing a TeamSpeak 3 virtual server and all it's parameters.
const SPACER_ALIGN_LEFT
0: alignment left
const SEPARATOR_CELL
protocol cell separator
const PERM_CAT_SERVER_INFORMATION
00100001: virtual server permissions -> virtual server information
const GROUP_DBTYPE_SERVERQUERY
2: global query group (used for ServerQuery clients)
const SPACER_DASHLINE
1: dash line
const CODEC_SPEEX_WIDEBAND
1: speex wideband (mono, 16bit, 16kHz)
const PERM_CAT_CLIENT_ADM_ACTIONS
01010010: client permissions -> client administrative actions
const REASON_SERVER_BAN
6: client banned from server
const REASON_SERVER_KICK
5: client kicked from server
const HOSTBANNER_IGNORE_ASPECT
1: adjust but ignore aspect ratio
const REASON_SUBSCRIPTION
2: subscription added or removed
const SNAPSHOT_HEXDEC
2: hexadecimal string
const SEPARATOR_PAIR
protocol pair separator
const LOGLEVEL_DEBUG
3: output that might help find a problem
const TEXTMSG_CLIENT
1: target is a client
const PERM_CAT_NEEDED_MODIFY_POWER
11111111: needed permission modify power (grant) permissions
const PERM_CAT_GLOBAL
00010000: global permissions
const PERM_CAT_GLOBAL_SERVER_MGMT
00010010: global permissions -> virtual server management
const KICK_SERVER
5: kick client from server
const GROUP_NAMEMODE_BEHIND
2: display name after client nickname
const CLIENT_TYPE_REGULAR
0: regular client
const REASON_TIMEOUT
3: client connection timed out
const CODEC_CRYPT_ENABLED
2: globally enabled
const HOSTBANNER_KEEP_ASPECT
2: adjust and keep aspect ratio
const PERM_TYPE_CHANNELGROUP
3: channel group permission
const APIKEY_WRITE
allow access to read and write calls
const PERM_CAT_CLIENT
01010000: client permissions
const HOSTMSG_MODALQUIT
3: display message in modal dialog and close connection
const SPACER_DASHDOTLINE
3: dash dot line
const PERM_CAT_GLOBAL_INFORMATION
00010001: global permissions -> global information
const CODEC_CELT_MONO
3: celt mono (mono, 16bit, 48kHz)
const APIKEY_MANAGE
allow access to administrative calls
const SPACER_SOLIDLINE
0: solid line
const PERM_CAT_GROUP
01000000: group permissions
const GROUP_DBTYPE_TEMPLATE
0: template group (used for new virtual servers)
const CODEC_CRYPT_INDIVIDUAL
0: configure per channel
const PERM_CAT_CLIENT_INFORMATION
01010001: client permissions -> client information
const CODEC_OPUS_VOICE
3: opus voice (interactive)
const TOKEN_CHANNELGROUP
1: channel group token (id1={groupID} id2={channelID})
const LOGLEVEL_INFO
4: informational output
const GROUP_NAMEMODE_BEFORE
1: display name before client nickname
const PLUGINCMD_SERVER
2: send plugincmd to all clients on server
const REASON_MOVE
1: channel switched or moved
const PLUGINCMD_CHANNEL
1: send plugincmd to all clients in current channel
const FILE_TYPE_REGULAR
1: file is regular
const PERM_CAT_CHANNEL
00110000: channel permissions
const PERM_CAT_GROUP_MODIFY
01000011: group permissions -> edit groups
const PLUGINCMD_CLIENT
3: send plugincmd to all given client ids
const CODEC_CRYPT_DISABLED
1: globally disabled
const SPACER_ALIGN_RIGHT
1: alignment right
const REASON_CHANNEL_EDIT
10: channel information edited
const SPACER_ALIGN_CENTER
2: alignment center
const PERM_TYPE_CHANNELCLIENT
4: channel-client specific permission
const REASON_CHANNEL_KICK
4: client kicked from channel
const PERM_CAT_GROUP_INFORMATION
01000001: group permissions -> group information
const TOKEN_SERVERGROUP
0: server group token (id1={groupID} id2=0)
const PERM_CAT_CHANNEL_ACCESS
00110101: channel permissions -> access channels
const HOSTMSG_LOG
1: display message in chatlog
const HOSTBANNER_NO_ADJUST
0: do not adjust
const CLIENT_TYPE_SERVERQUERY
1: query client
const GROUP_IDENTIFIY_STRONGEST
1: identify most powerful group
static loadClass(string $class)
const HOSTMSG_NONE
0: display no message
const HOSTMSG_MODAL
2: display message in modal dialog
const FILE_TYPE_DIRECTORY
0: file is directory
const SEPARATOR_LINE
protocol line separator
const CODEC_OPUS_MUSIC
3: opus music (interactive)
const PERM_CAT_CLIENT_BASICS
01010011: client permissions -> client basic communication
const LOGLEVEL_ERROR
1: everything that is awful
const PERM_CAT_GLOBAL_ADM_ACTIONS
00010011: global permissions -> global administrative actions
const REASON_DISCONNECT_SHUTDOWN
11: client disconnected on server shutdown
const PERM_CAT_GLOBAL_SETTINGS
00010100: global permissions -> global settings
const PERM_CAT_GROUP_DELETE
01000100: group permissions -> delete groups
const KICK_CHANNEL
4: kick client from channel
const SNAPSHOT_BASE64
1: base64 string
const SPACER_DOTLINE
2: dot line
const CODEC_SPEEX_NARROWBAND
0: speex narrowband (mono, 16bit, 8kHz)
const SEPARATOR_LIST
protocol list separator
static factory(string $uri)
const PERM_CAT_GROUP_CREATE
01000010: group permissions -> create groups
const PERM_CAT_CHANNEL_CREATE
00110010: channel permissions -> create channels
const SPACER_ALIGN_REPEAT
3: repeat until the whole line is filled
const LOGLEVEL_CRITICAL
0: these messages stop the program
static getEscapePatterns()
const PERM_CAT_CLIENT_MODIFY
01010100: client permissions -> edit clients
const PERM_CAT_CHANNEL_MODIFY
00110011: channel permissions -> edit channels
const GROUP_IDENTIFIY_WEAKEST
2: identify weakest group
const PERM_CAT_SERVER_ADM_ACTIONS
00100010: virtual server permissions -> virtual server administrative actions
const PERM_CAT_SERVER
00100000: virtual server permissions
const PERM_TYPE_CHANNEL
2: channel specific permission
const SPACER_CUSTOM
5: custom format
const PLUGINCMD_CHANNEL_SUBSCRIBED
4: send plugincmd to all subscribed clients in current channel
const REASON_SERVER_STOP
7: server stopped
const PERM_CAT_SERVER_SETTINGS
00100011: virtual server permissions -> virtual server settings
const SPACER_DASHDOTDOTLINE
4: dash dot dot line
const CODEC_SPEEX_ULTRAWIDEBAND
2: speex ultra-wideband (mono, 16bit, 32kHz)
const TEXTMSG_SERVER
3: target is a virtual server
const GROUP_NAMEMODE_HIDDEN
0: display no name
const LOGLEVEL_DEVEL
5: development output
const PERM_CAT_CHANNEL_INFORMATION
00110001: channel permissions -> channel information
const SNAPSHOT_STRING
0: default string
const GROUP_DBTYPE_REGULAR
1: regular group (used for regular clients)
const REASON_NONE
0: no reason
const APIKEY_READ
allow access to read-only calls
const PERM_TYPE_CLIENT
1: client specific permission
const REASON_CHANNEL_UPDATE
9: channel information updated
static getAdapterName(string $name, string $namespace="Adapter_")
const LOGLEVEL_WARNING
2: everything that might be bad
const PERM_CAT_CHANNEL_DELETE
00110100: channel permissions -> delete channels
static getFilePath(string $name)
const REASON_DISCONNECT
8: client disconnected
const PERM_CAT_FILETRANSFER
01100000: file transfer permissions
const TEXTMSG_CHANNEL
2: target is a channel
static dump(mixed $var, bool $echo=true)
const PERM_TYPE_SERVERGROUP
0: server group permission
static array $escape_patterns