3namespace PlanetTeamSpeak\TeamSpeak3Framework\Node;
5use PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery\Reply;
6use PlanetTeamSpeak\TeamSpeak3Framework\Exception\AdapterException;
7use PlanetTeamSpeak\TeamSpeak3Framework\Exception\HelperException;
8use PlanetTeamSpeak\TeamSpeak3Framework\Exception\NodeException;
9use PlanetTeamSpeak\TeamSpeak3Framework\Exception\ServerQueryException;
10use PlanetTeamSpeak\TeamSpeak3Framework\Helper\Signal;
11use PlanetTeamSpeak\TeamSpeak3Framework\Helper\StringHelper;
12use PlanetTeamSpeak\TeamSpeak3Framework\TeamSpeak3;
50 public function __construct(
Host $host, array $info,
string $index =
"virtualserver_id")
52 $this->parent = $host;
53 $this->nodeInfo = $info;
55 if (!array_key_exists($index, $this->nodeInfo)) {
59 $this->nodeId = $this->nodeInfo[$index];
77 return $this->
getParent()->request($cmd, $throw);
91 $channels = $this->
request(
"channellist -topic -flags -voice -limits -icon")->toAssocArray(
"cid");
95 foreach ($channels as $cid => $channel) {
126 if ($channel[
"channel_flag_default"]) {
144 $cid = $this->
execute(
"channelcreate", $properties)->toList();
147 if (!isset($properties[
"channel_flag_permanent"]) && !isset($properties[
"channel_flag_semi_permanent"])) {
148 $this->
getParent()->whoamiSet(
"client_channel_id", $cid[
"cid"]);
165 $this->
execute(
"channeldelete", [
"cid" => $cid,
"force" => $force]);
168 if (($cid instanceof
Node ? $cid->
getId() : $cid) == $this->whoamiGet(
"client_channel_id")) {
183 public function channelMove(
int $cid,
int $pid,
int $order =
null): void
185 $this->
execute(
"channelmove", [
"cid" => $cid,
"cpid" => $pid,
"order" => $order]);
197 return preg_match(
"/\[[^]]*spacer[^]]*]/", $channel) && $channel[
"channel_flag_permanent"] && !$channel[
"pid"];
221 "channel_name_phonetic" =>
"channel spacer",
222 "channel_codec" =>
TeamSpeak3::CODEC_OPUS_VOICE,
223 "channel_codec_quality" => 0x00,
224 "channel_flag_permanent" => true,
225 "channel_flag_maxclients_unlimited" => false,
226 "channel_flag_maxfamilyclients_unlimited" => false,
227 "channel_flag_maxfamilyclients_inherited" => false,
228 "channel_maxclients" => $maxclients,
229 "channel_order" => $order,
232 $properties[
"channel_name"] = match ($align) {
240 $properties[
"channel_name"] .= match ($type) {
246 default => strval($type),
268 return match ($channel[
"channel_name"]->section(
"]", 1)) {
290 if (!$this->
channelIsSpacer($channel) || !preg_match(
"/\[(.*)spacer.*]/", $channel, $matches) || !isset($matches[1])) {
294 return match ($matches[1]) {
313 return $this->
execute(
"channelpermlist", [
"cid" => $cid, $permsid ?
"-permsid" :
null])
314 ->toAssocArray($permsid ?
"permsid" :
"permid");
330 if (!is_array($permid)) {
331 $permident = (is_numeric($permid)) ?
"permid" :
"permsid";
333 $permident = (is_numeric(
current($permid))) ?
"permid" :
"permsid";
336 $this->
execute(
"channeladdperm", [
"cid" => $cid, $permident => $permid,
"permvalue" => $permvalue]);
350 if (!is_array($permid)) {
351 $permident = (is_numeric($permid)) ?
"permid" :
"permsid";
353 $permident = (is_numeric(
current($permid))) ?
"permid" :
"permsid";
356 $this->
execute(
"channeldelperm", [
"cid" => $cid, $permident => $permid]);
371 return $this->
execute(
"channelclientpermlist", [
"cid" => $cid,
"cldbid" => $cldbid, $permsid ?
"-permsid" :
null])
372 ->toAssocArray($permsid ?
"permsid" :
"permid");
389 if (!is_array($permid)) {
390 $permident = (is_numeric($permid)) ?
"permid" :
"permsid";
392 $permident = (is_numeric(
current($permid))) ?
"permid" :
"permsid";
395 $this->
execute(
"channelclientaddperm", [
"cid" => $cid,
"cldbid" => $cldbid, $permident => $permid,
"permvalue" => $permvalue]);
410 if (!is_array($permid)) {
411 $permident = (is_numeric($permid)) ?
"permid" :
"permsid";
413 $permident = (is_numeric(
current($permid))) ?
"permid" :
"permsid";
416 $this->
execute(
"channelclientdelperm", [
"cid" => $cid,
"cldbid" => $cldbid, $permident => $permid]);
430 public function channelFileList(
int $cid,
string $cpw =
"",
string $path =
"/",
bool $recursive =
false): array
432 $files = $this->
execute(
"ftgetfilelist", [
"cid" => $cid,
"cpw" => $cpw,
"path" => $path])->toArray();
433 $count =
count($files);
435 for ($i = 0; $i < $count; $i++) {
436 $files[$i][
"sid"] = $this->
getId();
437 $files[$i][
"cid"] = $files[0][
"cid"];
438 $files[$i][
"path"] = $files[0][
"path"];
439 $files[$i][
"src"] =
new StringHelper($cid ? $files[$i][
"path"] :
"/");
441 if (!$files[$i][
"src"]->endsWith(
"/")) {
442 $files[$i][
"src"]->append(
"/");
445 $files[$i][
"src"]->append($files[$i][
"name"]);
448 $files = array_merge($files, $this->
channelFileList($cid, $cpw, $path . $files[$i][
"name"], $recursive));
452 uasort($files, [__CLASS__,
"sortFileList"]);
467 public function channelFileInfo(
int $cid,
string $cpw =
"",
string $name =
"/"): array
469 $info = $this->
execute(
"ftgetfileinfo", [
"cid" => $cid,
"cpw" => $cpw,
"name" => $name])->toArray();
471 return array_pop($info);
488 public function channelFileRename(
int $cid,
string $cpw =
"",
string $oldname =
"/",
string $newname =
"/",
int $tcid =
null,
string $tcpw =
null): void
490 $this->
execute(
"ftrenamefile", [
"cid" => $cid,
"cpw" => $cpw,
"oldname" => $oldname,
"newname" => $newname,
"tcid" => $tcid,
"tcpw" => $tcpw]);
505 $this->
execute(
"ftdeletefile", [
"cid" => $cid,
"cpw" => $cpw,
"name" => $name]);
520 $this->
execute(
"ftcreatedir", [
"cid" => $cid,
"cpw" => $cpw,
"dirname" => $dirname]);
536 if ($channel[
"pid"]) {
554 $pathway = $channel[
"channel_name"];
556 if ($channel[
"pid"]) {
557 $pathway = $this->
channelGetPathway($channel[
"pid"]) .
"/" . $channel[
"channel_name"];
573 if (!array_key_exists((
string)$cid, $this->
channelList())) {
591 if ($channel[
"channel_name"] == $name) {
610 $clients = $this->
request(
"clientlist -uid -away -badges -voice -info -times -groups -icon -country -ip")
611 ->toAssocArray(
"clid");
615 foreach ($clients as $clid => $client) {
616 if ($this->
getParent()->getExcludeQueryClients() && $client[
"client_type"]) {
623 uasort($this->
clientList, [__CLASS__,
"sortClientList"]);
652 return $this->
execute(
"clientfind", [
"pattern" => $pattern])->toAssocArray(
"clid");
665 public function clientListDb(
int $offset =
null,
int $limit =
null): array
667 return $this->
execute(
"clientdblist -count", [
"start" => $offset,
"duration" => $limit])
668 ->toAssocArray(
"cldbid");
680 return current($this->
execute(
"clientdblist -count", [
"duration" => 1])->toList(
"count"));
693 return $this->
execute(
"clientdbinfo", [
"cldbid" => $cldbid])->toList();
706 public function clientFindDb(
string $pattern,
bool $uid =
false): array
708 return array_keys($this->
execute(
"clientdbfind", [
"pattern" => $pattern, ($uid) ?
"-uid" :
null,
"-details"])
709 ->toAssocArray(
"cldbid"));
723 return $this[
"virtualserver_clientsonline"] - $this[
"virtualserver_queryclientsonline"];
736 if (!array_key_exists((
string)$clid, $this->
clientList())) {
740 return $this->
clientList[intval((
string)$clid)];
754 if ($client[
"client_nickname"] == $name) {
773 if ($client[
"client_unique_identifier"] == $uid) {
792 if ($client[
"client_database_id"] == $dbid) {
811 return $this->
execute(
"clientgetnamefromuid", [
"cluid" => $cluid])->toList();
825 return $this->
execute(
"clientgetids", [
"cluid" => $cluid])->toAssocArray(
"clid");
839 return $this->
execute(
"clientgetnamefromdbid", [
"cldbid" => $cldbid])->toList();
853 return $this->
execute(
"servergroupsbyclientid", [
"cldbid" => $cldbid])->toAssocArray(
"sgid");
870 $this->
execute(
"clientmove", [
"clid" => $clid,
"cid" => $cid,
"cpw" => $cpw]);
872 if ($clid instanceof
Node) {
873 $clid = $clid->
getId();
876 if ($cid instanceof
Node) {
877 $cid = $cid->
getId();
880 if (!is_array($clid) && $clid == $this->whoamiGet(
"client_id")) {
881 $this->
getParent()->whoamiSet(
"client_channel_id", $cid);
899 $this->
execute(
"clientkick", [
"clid" => $clid,
"reasonid" => $reasonid,
"reasonmsg" => $reasonmsg]);
913 $this->
execute(
"clientpoke", [
"clid" => $clid,
"msg" => $msg]);
927 public function clientBan(
int $clid,
int $timeseconds =
null,
string $reason =
null): array
931 $bans = $this->
execute(
"banclient", [
"clid" => $clid,
"time" => $timeseconds,
"banreason" => $reason])
932 ->toAssocArray(
"banid");
934 return array_keys($bans);
948 $properties[
"cldbid"] = $cldbid;
950 $this->
execute(
"clientdbedit", $properties);
963 $this->
execute(
"clientdbdelete", [
"cldbid" => $cldbid]);
978 $this->
execute(
"setclientchannelgroup", [
"cldbid" => $cldbid,
"cid" => $cid,
"cgid" => $cgid]);
994 return $this->
execute(
"clientpermlist", [
"cldbid" => $cldbid, $permsid ?
"-permsid" :
null])
995 ->toAssocArray($permsid ?
"permsid" :
"permid");
1010 public function clientPermAssign(
int $cldbid,
int|array $permid,
int|array $permvalue,
bool|array $permskip =
false): void
1012 if (!is_array($permid)) {
1013 $permident = (is_numeric($permid)) ?
"permid" :
"permsid";
1015 $permident = (is_numeric(
current($permid))) ?
"permid" :
"permsid";
1018 $this->
execute(
"clientaddperm -continueonerror", [
"cldbid" => $cldbid, $permident => $permid,
"permvalue" => $permvalue,
"permskip" => $permskip]);
1032 if (!is_array($permid)) {
1033 $permident = (is_numeric($permid)) ?
"permid" :
"permsid";
1035 $permident = (is_numeric(
current($permid))) ?
"permid" :
"permsid";
1038 $this->
execute(
"clientdelperm", [
"cldbid" => $cldbid, $permident => $permid]);
1052 if ($this->sgroupList ===
null) {
1053 $this->sgroupList = $this->
request(
"servergrouplist")->toAssocArray(
"sgid");
1055 foreach ($this->sgroupList as $sgid => $group) {
1056 $this->sgroupList[$sgid] =
new ServerGroup($this, $group);
1059 uasort($this->sgroupList, [__CLASS__,
"sortGroupList"]);
1062 return $this->
filterList($this->sgroupList, $filter);
1072 $this->sgroupList =
null;
1088 $sgid = $this->
execute(
"servergroupadd", [
"name" => $name,
"type" => $type])->toList();
1090 return $sgid[
"sgid"];
1108 $sgid = $this->
execute(
"servergroupcopy", [
"ssgid" => $ssgid,
"tsgid" => $tsgid,
"name" => $name,
"type" => $type])
1111 if ($tsgid && $name) {
1115 return count($sgid) ? $sgid[
"sgid"] : $tsgid;
1131 $this->
execute(
"servergrouprename", [
"sgid" => $sgid,
"name" => $name]);
1148 $this->
execute(
"servergroupdel", [
"sgid" => $sgid,
"force" => $force]);
1166 return $this->sgroupList[intval((
string)$sgid)];
1182 if ($group[
"name"] == $name && $group[
"type"] == $type) {
1201 return $this->
execute(
"servergrouppermlist", [
"sgid" => $sgid, $permsid ?
"-permsid" :
null])
1202 ->toAssocArray($permsid ?
"permsid" :
"permid");
1218 public function serverGroupPermAssign(
int $sgid,
int|array $permid,
int|array $permvalue,
int|array $permnegated = 0,
bool|array $permskip =
false): void
1220 if (!is_array($permid)) {
1221 $permident = (is_numeric($permid)) ?
"permid" :
"permsid";
1223 $permident = (is_numeric(
current($permid))) ?
"permid" :
"permsid";
1226 $this->
execute(
"servergroupaddperm", [
"sgid" => $sgid, $permident => $permid,
"permvalue" => $permvalue,
"permnegated" => $permnegated,
"permskip" => $permskip]);
1241 if (!is_array($permid)) {
1242 $permident = (is_numeric($permid)) ?
"permid" :
"permsid";
1244 $permident = (is_numeric(
current($permid))) ?
"permid" :
"permsid";
1247 $this->
execute(
"servergroupdelperm", [
"sgid" => $sgid, $permident => $permid]);
1260 if ($this[
"virtualserver_default_server_group"] == $sgid) {
1264 return $this->
execute(
"servergroupclientlist", [
"sgid" => $sgid,
"-names"])->toAssocArray(
"cldbid");
1281 $this->
execute(
"servergroupaddclient", [
"sgid" => $sgid,
"cldbid" => $cldbid]);
1295 $this->
execute(
"servergroupdelclient", [
"sgid" => $sgid,
"cldbid" => $cldbid]);
1313 if ($sgroup[
"type"] != $type) {
1317 $profiles[$sgid] = [
1318 "b_permission_modify_power_ignore" => 0,
1319 "i_group_member_add_power" => 0,
1320 "i_group_member_remove_power" => 0,
1321 "i_needed_modify_power_count" => 0,
1322 "i_needed_modify_power_total" => 0,
1323 "i_permission_modify_power" => 0,
1324 "i_group_modify_power" => 0,
1325 "i_client_modify_power" => 0,
1326 "b_virtualserver_servergroup_create" => 0,
1327 "b_virtualserver_servergroup_delete" => 0,
1328 "b_client_ignore_bans" => 0,
1329 "b_client_ignore_antiflood" => 0,
1330 "b_group_is_permanent" => 0,
1331 "i_client_needed_ban_power" => 0,
1332 "i_client_needed_kick_power" => 0,
1333 "i_client_needed_move_power" => 0,
1334 "i_client_talk_power" => 0,
1336 "__name" => $sgroup->toString(),
1337 "__node" => $sgroup,
1342 $grant = isset($perms[
"i_permission_modify_power"]) ? $perms[
"i_permission_modify_power"][
"permvalue"] :
null;
1345 if ($e->getCode() != 0x501) {
1353 foreach ($perms as $permsid => $perm) {
1354 if (in_array($permsid, array_keys($profiles[$sgid]))) {
1355 $profiles[$sgid][$permsid] = $perm[
"permvalue"];
1356 } elseif (StringHelper::factory($permsid)->startsWith(
"i_needed_modify_power_")) {
1357 if (!$grant || $perm[
"permvalue"] > $grant) {
1361 $profiles[$sgid][
"i_needed_modify_power_total"] = $profiles[$sgid][
"i_needed_modify_power_total"] + $perm[
"permvalue"];
1362 $profiles[$sgid][
"i_needed_modify_power_count"]++;
1367 array_multisort($profiles, SORT_DESC);
1404 if ($this->cgroupList ===
null) {
1405 $this->cgroupList = $this->
request(
"channelgrouplist")->toAssocArray(
"cgid");
1407 foreach ($this->cgroupList as $cgid => $group) {
1408 $this->cgroupList[$cgid] =
new ChannelGroup($this, $group);
1411 uasort($this->cgroupList, [__CLASS__,
"sortGroupList"]);
1414 return $this->
filterList($this->cgroupList, $filter);
1424 $this->cgroupList =
null;
1440 $cgid = $this->
execute(
"channelgroupadd", [
"name" => $name,
"type" => $type])->toList();
1442 return $cgid[
"cgid"];
1460 $cgid = $this->
execute(
"channelgroupcopy", [
"scgid" => $scgid,
"tcgid" => $tcgid,
"name" => $name,
"type" => $type])
1463 if ($tcgid && $name) {
1467 return count($cgid) ? $cgid[
"cgid"] : $tcgid;
1483 $this->
execute(
"channelgrouprename", [
"cgid" => $cgid,
"name" => $name]);
1500 $this->
execute(
"channelgroupdel", [
"cgid" => $cgid,
"force" => $force]);
1517 return $this->cgroupList[intval((
string)$cgid)];
1532 if ($group[
"name"] == $name && $group[
"type"] == $type) {
1551 return $this->
execute(
"channelgrouppermlist", [
"cgid" => $cgid, $permsid ?
"-permsid" :
null])
1552 ->toAssocArray($permsid ?
"permsid" :
"permid");
1568 if (!is_array($permid)) {
1569 $permident = (is_numeric($permid)) ?
"permid" :
"permsid";
1571 $permident = (is_numeric(
current($permid))) ?
"permid" :
"permsid";
1574 $this->
execute(
"channelgroupaddperm", [
"cgid" => $cgid, $permident => $permid,
"permvalue" => $permvalue]);
1589 if (!is_array($permid)) {
1590 $permident = (is_numeric($permid)) ?
"permid" :
"permsid";
1592 $permident = (is_numeric(
current($permid))) ?
"permid" :
"permsid";
1595 $this->
execute(
"channelgroupdelperm", [
"cgid" => $cgid, $permident => $permid]);
1613 if ($this[
"virtualserver_default_channel_group"] == $cgid) {
1618 $result = $this->
execute(
"channelgroupclientlist", [
"cgid" => $cgid,
"cid" => $cid,
"cldbid" => $cldbid])
1622 if ($e->getCode() != 0x501) {
1630 foreach ($result as $k => $v) {
1631 $result[$k] = array_merge($v, $this->
clientInfoDb($v[
"cldbid"]));
1648 $token = $this->
request(
"permreset")->toList();
1650 Signal::getInstance()->emit(
"notifyTokencreated", $this, $token[
"token"]);
1652 return $token[
"token"];
1666 $assignments = $this->permissionFind($permid);
1668 foreach ($assignments as $assignment) {
1669 switch ($assignment[
"t"]) {
1695 return count($assignments);
1718 bool $overwrite =
false,
1719 bool $resume =
false
1721 $upload = $this->
execute(
"ftinitupload", [
"clientftfid" => $clientftfid,
"cid" => $cid,
"name" => $name,
"cpw" => $cpw,
"size" => $size,
"overwrite" => $overwrite,
"resume" => $resume])
1724 if (array_key_exists(
"status", $upload) && $upload[
"status"] != 0x00) {
1728 $upload[
"cid"] = $cid;
1729 $upload[
"file"] = $name;
1731 if (!array_key_exists(
"ip", $upload) || $upload[
"ip"]->startsWith(
"0.0.0.0")) {
1732 $upload[
"ip"] = $this->getParent()->getAdapterHost();
1734 $upload[
"ip"] = $upload[
"ip"]->section(
",");
1736 $upload[
"host"] = $upload[
"ip"];
1738 Signal::getInstance()->emit(
"filetransferUploadInit", $upload[
"ftkey"], $upload);
1755 public function transferInitDownload(
int $clientftfid,
int $cid,
string $name,
string $cpw =
"",
int $seekpos = 0): array
1757 $download = $this->
execute(
"ftinitdownload", [
"clientftfid" => $clientftfid,
"cid" => $cid,
"name" => $name,
"cpw" => $cpw,
"seekpos" => $seekpos])
1760 if (array_key_exists(
"status", $download) && $download[
"status"] != 0x00) {
1764 $download[
"cid"] = $cid;
1765 $download[
"file"] = $name;
1767 if (!array_key_exists(
"ip", $download) || $download[
"ip"]->startsWith(
"0.0.0.0")) {
1768 $download[
"ip"] = $this->
getParent()->getAdapterHost();
1770 $download[
"ip"] = $download[
"ip"]->section(
",");
1772 $download[
"host"] = $download[
"ip"];
1774 Signal::getInstance()->emit(
"filetransferDownloadInit", $download[
"ftkey"], $download);
1789 return $this->
request(
"ftlist")->toAssocArray(
"serverftfid");
1803 $this->
execute(
"ftstop", [
"serverftfid" => $serverftfid,
"delete" => $delete]);
1820 $iconid = $this[
'virtualserver_icon_id'];
1821 if (!is_int($iconid)) {
1822 $iconid = $iconid->toInt();
1825 if ($this->
iconIsLocal(
"virtualserver_icon_id") || $iconid == 0) {
1828 $name = $this->
iconGetName(
"virtualserver_icon_id");
1832 $transfer =
TeamSpeak3::factory(
"filetransfer://" . (str_contains($download[
"host"],
":") ?
"[" . $download[
"host"] .
"]" : $download[
"host"]) .
":" . $download[
"port"]);
1834 return $transfer->download($download[
"ftkey"], $download[
"size"]);
1848 $crc = crc32($data);
1849 $size = strlen($data);
1851 $upload = $this->
transferInitUpload(rand(0x0000, 0xFFFF), 0,
"/icon_" . $crc, $size);
1852 $transfer =
TeamSpeak3::factory(
"filetransfer://" . (str_contains($upload[
"host"],
":") ?
"[" . $upload[
"host"] .
"]" : $upload[
"host"]) .
":" . $upload[
"port"]);
1854 $transfer->upload($upload[
"ftkey"], $upload[
"seekpos"], $data);
1867 public function modify(array $properties): void
1869 $this->
execute(
"serveredit", $properties);
1896 return $this->
request(
"messagelist")->toAssocArray(
"msgid");
1909 public function messageCreate(
string $cluid,
string $subject,
string $message): void
1911 $this->
execute(
"messageadd", [
"cluid" => $cluid,
"subject" => $subject,
"message" => $message]);
1924 $this->
execute(
"messagedel", [
"msgid" => $msgid]);
1936 public function messageRead(
int $msgid,
bool $flag_read =
true): array
1938 $msg = $this->
execute(
"messageget", [
"msgid" => $msgid])->toList();
1941 $this->
execute(
"messageget", [
"msgid" => $msgid,
"flag" => $flag_read]);
1957 $snapshot = $this->
request(
"serversnapshotcreate")->toString(
false);
1959 return match ($mode) {
1962 default => (string)$snapshot,
1979 $data = match ($mode) {
1982 default => StringHelper::factory($data),
1985 $detail = $this->
request(
"serversnapshotdeploy -mapping " . $data)->toList();
1987 if (isset($detail[0][
"sid"])) {
1988 Signal::getInstance()->emit(
"notifyServercreated", $this->
getParent(), $detail[0][
"sid"]);
1990 $server = array_shift($detail);
2013 $this->
execute(
"servernotifyregister", [
"event" => $event,
"id" => $id]);
2026 $this->
request(
"servernotifyunregister");
2057 $tokens = $this->
request(
"privilegekeylist")->toAssocArray(
"token");
2060 foreach ($tokens as $token => $array) {
2061 $func = $array[
"token_type"] ?
"channelGroupGetById" :
"serverGroupGetById";
2064 $tokens[$token][
"token_id1"] = $this->$func($array[
"token_id1"])->name;
2067 if ($e->getCode() != 0xA00) {
2072 if ($array[
"token_type"]) {
2073 $tokens[$token][
"token_id2"] = $this->
channelGetById($array[
"token_id2"])->getPathway();
2098 string $description =
null,
2099 array $customset =
null
2119 string $description =
null,
2120 string $customset =
null
2122 $token = $this->
execute(
"privilegekeyadd", [
"tokentype" => $type,
"tokenid1" => $id1,
"tokenid2" => $id2,
"tokendescription" => $description,
"tokencustomset" => $customset])
2125 Signal::getInstance()->emit(
"notifyTokencreated", $this, $token[
"token"]);
2127 return $token[
"token"];
2153 $this->
execute(
"privilegekeydelete", [
"token" => $token]);
2180 $this->
execute(
"privilegekeyuse", [
"token" => $token]);
2194 return $this->
execute(
"customsearch", [
"ident" => $ident,
"pattern" => $pattern])->toArray();
2207 return $this->
execute(
"custominfo", [
"cldbid" => $cldbid])->toArray();
2220 public function customSet(
int $cldbid,
string $ident,
string $value): void
2222 $this->
execute(
"customset", [
"cldbid" => $cldbid,
"ident" => $ident,
"value" => $value]);
2236 $this->
execute(
"customdelete", [
"cldbid" => $cldbid,
"ident" => $ident]);
2248 public function banList($offset =
null, $limit =
null): array
2250 return $this->
execute(
"banlist -count", [
"start" => $offset,
"duration" => $limit])->toAssocArray(
"banid");
2262 return current($this->
execute(
"banlist -count", [
"duration" => 1])->toList(
"count"));
2288 public function banCreate(array $rules,
int $timeseconds =
null,
string $reason =
null): int
2290 $rules[
"time"] = $timeseconds;
2291 $rules[
"banreason"] = $reason;
2293 $banid = $this->
execute(
"banadd", $rules)->toList();
2295 return $banid[
"banid"];
2308 $this->
execute(
"bandel", [
"banid" => $banid]);
2322 return $this->
execute(
"complainlist", [
"tcldbid" => $tcldbid])->toArray();
2335 $this->
execute(
"complaindelall", [
"tcldbid" => $tcldbid]);
2349 $this->
execute(
"complainadd", [
"tcldbid" => $tcldbid,
"message" => $message]);
2363 $this->
execute(
"complaindel", [
"tcldbid" => $tcldbid,
"fcldbid" => $fcldbid]);
2376 $passwords = $this->
request(
"servertemppasswordlist")->toAssocArray(
"pw_clear");
2379 foreach ($passwords as $password => $array) {
2382 $passwords[$password][
"tcname"] = $channel->toString();
2383 $passwords[$password][
"tcpath"] = $channel->getPathway();
2405 public function tempPasswordCreate(
string $pw,
int $duration,
int $tcid = 0,
string $tcpw =
"",
string $desc =
""): void
2407 $this->
execute(
"servertemppasswordadd", [
"pw" => $pw,
"duration" => $duration,
"tcid" => $tcid,
"tcpw" => $tcpw,
"desc" => $desc]);
2420 $this->
execute(
"servertemppassworddel", [
"pw" => $pw]);
2434 public function logView(
int $lines = 30,
int $begin_pos =
null,
bool $reverse =
null,
bool $instance =
null): array
2436 return $this->
execute(
"logview", [
"lines" => $lines,
"begin_pos" => $begin_pos,
"instance" => $instance,
"reverse" => $reverse])
2451 $this->
execute(
"logadd", [
"logmsg" => $logmsg,
"loglevel" => $loglevel]);
2463 return $this->
request(
"serverrequestconnectioninfo")->toList();
2471 public function delete(): void
2492 public function stop(
string $msg =
null): void
2521 $this->
execute(
"clientupdate", $properties);
2523 foreach ($properties as $ident => $value) {
2524 $this->whoamiSet($ident, $value);
2539 $password = $this->
execute(
"clientsetserverquerylogin", [
"client_login_name" => $username])->toList();
2541 return $password[
"client_login_password"];
2553 return $this->
execute(
"permoverview", [
"cldbid" => $this->whoamiGet(
"client_database_id"),
"cid" => $this->whoamiGet(
"client_channel_id"),
"permid" => 0])
2564 $this->nodeList = [];
2567 if ($channel[
"pid"] == 0) {
2568 $this->nodeList[] = $channel;
2580 $this->nodeInfo = array_merge($this->nodeInfo, $this->
request(
"serverinfo")->toList());
2592 if (get_class($a) != get_class($b)) {
2604 return strcmp(strtolower($a[
"client_nickname"]), strtolower($b[
"client_nickname"]));
2616 if (get_class($a) != get_class($b)) {
2640 if (!array_key_exists(
"src", $a) || !array_key_exists(
"src", $b) || !array_key_exists(
"type", $a) || !array_key_exists(
"type", $b)) {
2644 if ($a[
"type"] != $b[
"type"]) {
2645 return ($a[
"type"] < $b[
"type"]) ? -1 : 1;
2648 return strcmp(strtolower($a[
"src"]), strtolower($b[
"src"]));
2658 return $this[
"virtualserver_status"] ==
"online";
2668 return $this[
"virtualserver_status"] ==
"offline";
2678 return $this->
getParent()->getUniqueId() .
"_s" . $this->
getId();
2688 if ($this[
"virtualserver_clientsonline"] - $this[
"virtualserver_queryclientsonline"] >= $this[
"virtualserver_maxclients"]) {
2689 return "server_full";
2690 } elseif ($this[
"virtualserver_flag_password"]) {
2691 return "server_pass";
2693 return "server_open";
2714 return (
string)$this[
"virtualserver_name"];
Provides methods to analyze and format a ServerQuery reply.
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Node\Node objects.
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Adapter\ServerQuery objects.
Helper class for string handling.
Class describing a TeamSpeak 3 channel group and all it's parameters.
Class describing a TeamSpeak 3 channel and all it's parameters.
Class describing a TeamSpeak 3 client and all it's parameters.
Class describing a TeamSpeak 3 server instance and all it's parameters.
filterList(array $nodes=[], array $rules=[])
execute($cmd, array $params=[])
getProperty(string $property, mixed $default=null)
Class describing a TeamSpeak 3 virtual server and all it's parameters.
clientSetChannelGroup(int $cldbid, int $cid, int $cgid)
complaintDelete(int $tcldbid, int $fcldbid)
channelGroupDelete(int $cgid, bool $force=false)
complaintList(int $tcldbid=null)
channelGroupList(array $filter=[])
privilegeKeyUse(string $token)
channelCreate(array $properties)
channelSpacerCreate(string $ident, int $type=TeamSpeak3::SPACER_SOLIDLINE, int $align=TeamSpeak3::SPACER_ALIGN_REPEAT, int $order=null, int $maxclients=0)
serverGroupGetProfiles(int $type=TeamSpeak3::GROUP_DBTYPE_REGULAR)
channelSpacerGetType(int $cid)
complaintCreate(int $tcldbid, string $message)
privilegeKeyDelete(string $token)
clientGetNameByUid(string $cluid)
clientListDb(int $offset=null, int $limit=null)
clientPermAssign(int $cldbid, int|array $permid, int|array $permvalue, bool|array $permskip=false)
channelGroupCreate(string $name, int $type=TeamSpeak3::GROUP_DBTYPE_REGULAR)
snapshotCreate(int $mode=TeamSpeak3::SNAPSHOT_STRING)
customSet(int $cldbid, string $ident, string $value)
channelIsSpacer(Channel $channel)
clientPermRemove(int $cldbid, int|array $permid)
clientInfoDb(int $cldbid)
customDelete(int $cldbid, string $ident)
clientGetByUid(string $uid)
modify(array $properties)
static sortGroupList(Node $a, Node $b)
logAdd(string $logmsg, int $loglevel=TeamSpeak3::LOGLEVEL_INFO)
serverGroupPermList(int $sgid, bool $permsid=false)
clientGetByName(string $name)
channelClientPermList(int $cid, int $cldbid, bool $permsid=false)
selfUpdate(array $properties)
tempPasswordDelete(string $pw)
serverGroupIdentify(int $mode=TeamSpeak3::GROUP_IDENTIFIY_STRONGEST, int $type=TeamSpeak3::GROUP_DBTYPE_REGULAR)
channelPermAssign(int $cid, int|array $permid, int|array $permvalue)
static sortFileList(array $a, array $b)
clientDeleteDb(string $cldbid)
iconDownload(string $iconname=null)
clientModifyDb(string $cldbid, array $properties)
serverGroupClientList(int $sgid)
logView(int $lines=30, int $begin_pos=null, bool $reverse=null, bool $instance=null)
channelDirCreate(int $cid, string $cpw="", string $dirname="/")
tokenList(bool $translate=false)
clientList(array $filter=[])
clientFindDb(string $pattern, bool $uid=false)
tempPasswordList(bool $resolve=false)
channelClientPermAssign(int $cid, int $cldbid, int|array $permid, int|array $permvalue)
clientBan(int $clid, int $timeseconds=null, string $reason=null)
serverGroupList(array $filter=[])
channelPermRemove(int $cid, int|array $permid)
serverGroupPermAssign(int $sgid, int|array $permid, int|array $permvalue, int|array $permnegated=0, bool|array $permskip=false)
channelGetByName(string $name)
privilegeKeyList(bool $resolve=false)
tempPasswordCreate(string $pw, int $duration, int $tcid=0, string $tcpw="", string $desc="")
permRemoveAny(int $permid)
channelMove(int $cid, int $pid, int $order=null)
channelGroupGetByName(string $name, int $type=TeamSpeak3::GROUP_DBTYPE_REGULAR)
channelClientPermRemove(int $cid, int $cldbid, int|array $permid)
serverGroupDelete(int $sgid, bool $force=false)
transferInitDownload(int $clientftfid, int $cid, string $name, string $cpw="", int $seekpos=0)
sendPluginCmd(string $plugin, string $data)
clientGetByDbid(int $dbid)
clientPoke(int $clid, string $msg)
complaintListClear(int $tcldbid)
request(string $cmd, bool $throw=true)
clientGetServerGroupsByDbid(string $cldbid)
channelGroupClientList(int $cgid=null, int $cid=null, int $cldbid=null, bool $resolve=false)
serverGroupGetByName(string $name, int $type=TeamSpeak3::GROUP_DBTYPE_REGULAR)
channelGroupPermRemove(int $cgid, int|array $permid)
channelGetPathway(int $cid)
banList($offset=null, $limit=null)
serverGroupGetById(int $sgid)
__construct(Host $host, array $info, string $index="virtualserver_id")
messageRead(int $msgid, bool $flag_read=true)
clientPermList(int $cldbid, bool $permsid=false)
serverGroupCreate(string $name, int $type=TeamSpeak3::GROUP_DBTYPE_REGULAR)
clientGetIdsByUid(string $cluid)
clientGetNameByDbid(string $cldbid)
channelFileDelete(int $cid, string $cpw="", string $name="/")
channelGetLevel(int $cid)
channelList(array $filter=[])
channelPermList(int $cid, bool $permsid=false)
channelDelete(int|Node $cid, bool $force=false)
clientKick(int $clid, int $reasonid=TeamSpeak3::KICK_CHANNEL, $reasonmsg=null)
privilegeKeyCreate(int $id1, int $id2=0, int $type=TeamSpeak3::TOKEN_SERVERGROUP, string $description=null, string $customset=null)
selfUpdateLogin(string $username)
channelFileInfo(int $cid, string $cpw="", string $name="/")
clientMove(int|Node $clid, int|Node $cid, $cpw=null)
static sortClientList(Client $a, Client $b)
channelSpacerGetAlign(int $cid)
messageDelete(int $msgid)
channelFileList(int $cid, string $cpw="", string $path="/", bool $recursive=false)
clientFind(string $pattern)
serverGroupRename(int $sgid, string $name)
channelGroupCopy(int $scgid, string $name=null, int $tcgid=0, int $type=TeamSpeak3::GROUP_DBTYPE_REGULAR)
transferInitUpload(int $clientftfid, int $cid, string $name, int $size, string $cpw="", bool $overwrite=false, bool $resume=false)
serverGroupPermRemove(int $sgid, int|array $permid)
notifyRegister(string $event, int $id=0)
serverGroupClientDel(int $sgid, int $cldbid)
channelGroupPermList(int $cgid, bool $permsid=false)
transferStop(int $serverftfid, bool $delete=false)
channelGroupGetById(int $cgid)
banCreate(array $rules, int $timeseconds=null, string $reason=null)
messageCreate(string $cluid, string $subject, string $message)
customSearch(string $ident, string $pattern="%")
serverGroupClientAdd(int $sgid, int $cldbid)
snapshotDeploy(string $data, int $mode=TeamSpeak3::SNAPSHOT_STRING)
serverGroupCopy(int $ssgid, string $name=null, int $tsgid=0, int $type=TeamSpeak3::GROUP_DBTYPE_REGULAR)
channelGroupPermAssign(int $cgid, int|array $permid, int|array $permvalue)
channelFileRename(int $cid, string $cpw="", string $oldname="/", string $newname="/", int $tcid=null, string $tcpw=null)
channelGroupRename(int $cgid, string $name)
tokenCreate(int $id1, int $id2=0, int $type=TeamSpeak3::TOKEN_SERVERGROUP, string $description=null, array $customset=null)
const SPACER_ALIGN_LEFT
0: alignment left
const SPACER_DASHLINE
1: dash line
const SNAPSHOT_HEXDEC
2: hexadecimal string
const PERM_TYPE_CHANNELGROUP
3: channel group permission
const SPACER_DASHDOTLINE
3: dash dot line
const SPACER_SOLIDLINE
0: solid line
const LOGLEVEL_INFO
4: informational output
const PLUGINCMD_SERVER
2: send plugincmd to all clients on server
const SPACER_ALIGN_RIGHT
1: alignment right
const SPACER_ALIGN_CENTER
2: alignment center
const PERM_TYPE_CHANNELCLIENT
4: channel-client specific permission
const TOKEN_SERVERGROUP
0: server group token (id1={groupID} id2=0)
const GROUP_IDENTIFIY_STRONGEST
1: identify most powerful group
const FILE_TYPE_DIRECTORY
0: file is directory
const KICK_CHANNEL
4: kick client from channel
const SNAPSHOT_BASE64
1: base64 string
const SPACER_DOTLINE
2: dot line
static factory(string $uri)
const SPACER_ALIGN_REPEAT
3: repeat until the whole line is filled
const PERM_TYPE_CHANNEL
2: channel specific permission
const SPACER_CUSTOM
5: custom format
const SPACER_DASHDOTDOTLINE
4: dash dot dot line
const TEXTMSG_SERVER
3: target is a virtual server
const SNAPSHOT_STRING
0: default string
const GROUP_DBTYPE_REGULAR
1: regular group (used for regular clients)
const PERM_TYPE_CLIENT
1: client specific permission
const PERM_TYPE_SERVERGROUP
0: server group permission