TeamSpeak 3 PHP Framework
Modern use-at-will framework that provides individual components to manage TeamSpeak 3 Server instances
TeamSpeak3_Node_Host Class Reference

Class describing a TeamSpeak 3 server instance and all it's parameters. More...

+ Inheritance diagram for TeamSpeak3_Node_Host:

Public Member Functions

 __construct (TeamSpeak3_Adapter_ServerQuery $squery)
 The TeamSpeak3_Node_Host constructor. More...
 
 __toString ()
 Returns a string representation of this node. More...
 
 __wakeup ()
 Re-authenticates with the TeamSpeak 3 Server instance using given ServerQuery login credentials and re-selects a previously selected virtual server. More...
 
 bindingList ($subsystem="voice")
 Returns a list of IP addresses used by the server instance on multi-homed machines. More...
 
 getAdapter ()
 Returns the underlying TeamSpeak3_Adapter_ServerQuery object. More...
 
 getAdapterHost ()
 Returns the hostname or IPv4 address the adapter is connected to. More...
 
 getAdapterPort ()
 Returns the network port the adapter is connected to. More...
 
 getExcludeQueryClients ()
 Returns the option to decide whether ServerQuery clients should be excluded from node lists or not. More...
 
 getIcon ()
 Returns the name of a possible icon to display the node object. More...
 
 getLoadClientlistFirst ()
 Returns the option to decide whether offline servers will be started in virtual mode by default or not. More...
 
 getPredefinedQueryName ()
 Returns the pre-defined nickname for ServerQuery clients which will be used automatically after selecting a virtual server. More...
 
 getSymbol ()
 Returns a symbol representing the node. More...
 
 getUniqueId ()
 Returns a unique identifier for the node which can be used as a HTML property. More...
 
 getUseOfflineAsVirtual ()
 Returns the option to decide whether offline servers will be started in virtual mode by default or not. More...
 
 logAdd ($logmsg, $loglevel=TeamSpeak3::LOGLEVEL_INFO)
 Writes a custom entry into the server instance log. More...
 
 login ($username, $password)
 Authenticates with the TeamSpeak 3 Server instance using given ServerQuery login credentials. More...
 
 logout ()
 Deselects the active virtual server and logs out from the server instance. More...
 
 logView ($lines=30, $begin_pos=null, $reverse=null, $instance=TRUE)
 Displays a specified number of entries (1-100) from the servers log. More...
 
 message ($msg)
 Sends a text message to all clients on all virtual servers in the TeamSpeak 3 Server instance. More...
 
 modify (array $properties)
 Changes the server instance configuration using given properties. More...
 
 permissionCats ()
 Returns a list of permission categories available on the server instance. More...
 
 permissionEnds ()
 Returns a list of permission category endings available on the server instance. More...
 
 permissionFind ($permid)
 Returns the IDs of all clients, channels or groups using the permission with the specified ID. More...
 
 permissionGetCategoryById ($permid)
 Returns the internal category of the permission matching the given ID. More...
 
 permissionGetGrantById ($permid)
 Returns the internal ID of the i_needed_modify_power_* or grant permission. More...
 
 permissionGetIdByName ($name)
 Returns the ID of the permission matching the given name. More...
 
 permissionGetNameById ($permid)
 Returns the name of the permission matching the given ID. More...
 
 permissionList ()
 Returns a list of permissions available on the server instance. More...
 
 permissionTree ()
 Returns an array filled with all permission categories known to the server including their ID, name and parent. More...
 
 selfPermCheck ($permid)
 Returns an array containing the value of a specified permission for your own client. More...
 
 serverCreate (array $properties=array())
 Creates a new virtual server using given properties and returns an assoc array containing the new ID and initial admin token. More...
 
 serverDelete ($sid)
 Deletes the virtual server specified by ID. More...
 
 serverDeselect ()
 Deselects the active virtual server. More...
 
 serverGetById ($sid)
 Returns the TeamSpeak3_Node_Server object matching the given ID. More...
 
 serverGetByName ($name)
 Returns the first TeamSpeak3_Node_Server object matching the given name. More...
 
 serverGetByPort ($port)
 Returns the TeamSpeak3_Node_Server object matching the given port number. More...
 
 serverGetByUid ($uid)
 Returns the first TeamSpeak3_Node_Server object matching the given unique identifier. More...
 
 serverGetPortById ($sid)
 Returns the port of a virtual server matching the given ID. More...
 
 serverGetSelected ()
 Returns the TeamSpeak3_Node_Server object matching the currently selected ID. More...
 
 serverGroupPermAutoAssign ($sgtype, $permid, $permvalue, $permnegated=FALSE, $permskip=FALSE)
 Adds a set of specified permissions to all regular server groups on all virtual servers. More...
 
 serverGroupPermAutoRemove ($sgtype, $permid)
 Removes a set of specified permissions from all regular server groups on all virtual servers. More...
 
 serverIdGetByPort ($port)
 Returns the ID of a virtual server matching the given port. More...
 
 serverList (array $filter=array())
 Returns an array filled with TeamSpeak3_Node_Server objects. More...
 
 serverListReset ()
 Resets the list of virtual servers. More...
 
 serverSelect ($sid, $virtual =null)
 Selects a virtual server by ID to allow further interaction. More...
 
 serverSelectById ($sid, $virtual =null)
 Alias for serverSelect(). More...
 
 serverSelectByPort ($port, $virtual =null)
 Selects a virtual server by UDP port to allow further interaction. More...
 
 serverSelectedId ()
 Returns the primary ID of the selected virtual server. More...
 
 serverSelectedPort ()
 Returns the primary UDP port of the selected virtual server. More...
 
 serverStart ($sid)
 Starts the virtual server specified by ID. More...
 
 serverStop ($sid)
 Stops the virtual server specified by ID. More...
 
 serverStopProcess ()
 Stops the entire TeamSpeak 3 Server instance by shutting down the process. More...
 
 setExcludeQueryClients ($exclude=FALSE)
 Sets the option to decide whether ServerQuery clients should be excluded from node lists or not. More...
 
 setLoadClientlistFirst ($first=FALSE)
 Sets the option to decide whether clients should be sorted before sub-channels to support the new TeamSpeak 3 Client display mode or not. More...
 
 setPredefinedQueryName ($name=null)
 Sets a pre-defined nickname for ServerQuery clients which will be used automatically after selecting a virtual server. More...
 
 setUseOfflineAsVirtual ($virtual =FALSE)
 Sets the option to decide whether offline servers will be started in virtual mode by default or not. More...
 
 version ($ident=null)
 Returns the servers version information including platform and build number. More...
 
 whoami ()
 Returns information about your current ServerQuery connection. More...
 
 whoamiGet ($ident, $default=null)
 Returns a single value from the current ServerQuery connection info. More...
 
 whoamiReset ()
 Resets the current ServerQuery connection info. More...
 
 whoamiSet ($ident, $value=null)
 Sets a single value in the current ServerQuery connection info. More...
 
- Public Member Functions inherited from TeamSpeak3_Node_Abstract
 __call ($name, array $args)
 Called whenever we're using an unknown method. More...
 
 __get ($offset)
 
 __set ($offset, $value)
 
 __sleep ()
 Commit pending data. More...
 
 __toString ()
 Returns a string representation of this node. More...
 
 count ()
 
 current ()
 
 execute ($cmd, array $params=array())
 Prepares and executes a ServerQuery command and returns the result. More...
 
 getChildren ()
 
 getClass ($prefix="ts3_")
 Returns a possible classname for the node which can be used as a HTML property. More...
 
 getIcon ()
 Returns the name of a possible icon to display the node object. More...
 
 getId ()
 Returns the primary ID of the current node. More...
 
 getInfo ($extend=TRUE, $convert=FALSE)
 Returns all information available on this node. More...
 
 getParent ()
 Returns the parent object of the current node. More...
 
 getProperty ($property, $default=null)
 Returns the specified property or a pre-defined default value from the node info array. More...
 
 getSymbol ()
 Returns a symbol representing the node. More...
 
 getUniqueId ()
 Returns a unique identifier for the node which can be used as a HTML property. More...
 
 getViewer (TeamSpeak3_Viewer_Interface $viewer)
 Returns the HTML code to display a TeamSpeak 3 viewer. More...
 
 hasChildren ()
 
 hasNext ()
 
 iconGetName ($key)
 Returns the internal path of the node icon. More...
 
 iconIsLocal ($key)
 Returns TRUE if the node icon has a local source. More...
 
 key ()
 
 next ()
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 prepare ($cmd, array $params=array())
 Uses given parameters and returns a prepared ServerQuery command. More...
 
 request ($cmd, $throw=TRUE)
 Sends a prepared command to the server and returns the result. More...
 
 rewind ()
 
 toArray ()
 Returns an assoc array filled with current node info properties. More...
 
 toString ()
 Returns a string representation of this node. More...
 
 valid ()
 

Protected Member Functions

 fetchNodeInfo ()
 
 fetchNodeList ()
 
 fetchPermissionCats ()
 
 fetchPermissionList ()
 
- Protected Member Functions inherited from TeamSpeak3_Node_Abstract
 delStorage ($key)
 Deletes data from the internal storage array. More...
 
 fetchNodeInfo ()
 
 fetchNodeList ()
 
 filterList (array $nodes=array(), array $rules=array())
 Filters given node list array using specified filter rules. More...
 
 getStorage ($key, $default=null)
 Returns data from the internal storage array. More...
 
 resetNodeInfo ()
 
 resetNodeList ()
 
 setStorage ($key, $val)
 Writes data to the internal storage array. More...
 
 verifyNodeList ()
 

Protected Attributes

 $exclude_query_clients = FALSE
 
 $permissionCats = null
 
 $permissionEnds = null
 
 $permissionList = null
 
 $predefined_query_name = null
 
 $serverList = null
 
 $sort_clients_channels = FALSE
 
 $start_offline_virtual = FALSE
 
 $version = null
 
 $whoami = null
 
- Protected Attributes inherited from TeamSpeak3_Node_Abstract
 $nodeId = 0x00
 
 $nodeInfo = array()
 
 $nodeList = null
 
 $parent = null
 
 $server = null
 
 $storage = array()
 

Detailed Description

Class describing a TeamSpeak 3 server instance and all it's parameters.

Constructor & Destructor Documentation

◆ __construct()

__construct ( TeamSpeak3_Adapter_ServerQuery  $squery)

The TeamSpeak3_Node_Host constructor.

Parameters
TeamSpeak3_Adapter_ServerQuery$squery
Returns
TeamSpeak3_Node_Host
88  {
89  $this->parent = $squery;
90  }

Member Function Documentation

◆ __toString()

__toString ( )

Returns a string representation of this node.

Returns
string
1161  {
1162  return (string) $this->getAdapterHost();
1163  }
getAdapterHost()
Returns the hostname or IPv4 address the adapter is connected to.
Definition: Host.php:890

◆ __wakeup()

__wakeup ( )

Re-authenticates with the TeamSpeak 3 Server instance using given ServerQuery login credentials and re-selects a previously selected virtual server.

Returns
void
1121  {
1122  $username = $this->getStorage("_login_user");
1123  $password = $this->getStorage("_login_pass");
1124 
1125  if($username && $password)
1126  {
1127  $crypt = new TeamSpeak3_Helper_Crypt($username);
1128 
1129  $this->login($username, $crypt->decrypt($password));
1130  }
1131 
1132  $this->predefined_query_name = $this->getStorage("_query_nick");
1133  $this->exclude_query_clients = $this->getStorage("_query_hide", FALSE);
1134  $this->start_offline_virtual = $this->getStorage("_do_virtual", FALSE);
1135  $this->sort_clients_channels = $this->getStorage("_client_top", FALSE);
1136 
1137  if($server = $this->getStorage("_server_use"))
1138  {
1139  $func = array_shift($server);
1140  $args = array_shift($server);
1141 
1142  try
1143  {
1144  call_user_func_array(array($this, $func), $args);
1145  }
1146  catch(Exception $e)
1147  {
1148  $class = get_class($e);
1149 
1150  throw new $class($e->getMessage(), $e->getCode());
1151  }
1152  }
1153  }
getStorage($key, $default=null)
Returns data from the internal storage array.
Definition: Abstract.php:400
$server
Definition: Abstract.php:39
login($username, $password)
Authenticates with the TeamSpeak 3 Server instance using given ServerQuery login credentials.
Definition: Host.php:800
Helper class for data encryption.
Definition: Crypt.php:29

◆ bindingList()

bindingList (   $subsystem = "voice")

Returns a list of IP addresses used by the server instance on multi-homed machines.

Returns
array
434  {
435  return $this->execute("bindinglist", array("subsystem" => $subsystem))->toArray();
436  }
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ getAdapter()

getAdapter ( )

Returns the underlying TeamSpeak3_Adapter_ServerQuery object.

Returns
TeamSpeak3_Adapter_ServerQuery
1080  {
1081  return $this->getParent();
1082  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103

◆ getAdapterHost()

getAdapterHost ( )

Returns the hostname or IPv4 address the adapter is connected to.

Returns
string
891  {
892  return $this->getParent()->getTransportHost();
893  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103

◆ getAdapterPort()

getAdapterPort ( )

Returns the network port the adapter is connected to.

Returns
string
901  {
902  return $this->getParent()->getTransportPort();
903  }
getParent()
Returns the parent object of the current node.
Definition: Abstract.php:103

◆ getExcludeQueryClients()

getExcludeQueryClients ( )

Returns the option to decide whether ServerQuery clients should be excluded from node lists or not.

Returns
boolean
1020  {
1022  }
$exclude_query_clients
Definition: Host.php:69

◆ getIcon()

getIcon ( )

Returns the name of a possible icon to display the node object.

Returns
string
1100  {
1101  return "host";
1102  }

◆ getLoadClientlistFirst()

getLoadClientlistFirst ( )

Returns the option to decide whether offline servers will be started in virtual mode by default or not.

Returns
boolean
1070  {
1072  }
$sort_clients_channels
Definition: Host.php:79

◆ getPredefinedQueryName()

getPredefinedQueryName ( )

Returns the pre-defined nickname for ServerQuery clients which will be used automatically after selecting a virtual server.

Returns
string
995  {
997  }
$predefined_query_name
Definition: Host.php:64

◆ getSymbol()

getSymbol ( )

Returns a symbol representing the node.

Returns
string
1110  {
1111  return "+";
1112  }

◆ getUniqueId()

getUniqueId ( )

Returns a unique identifier for the node which can be used as a HTML property.

Returns
string
1090  {
1091  return "ts3_h";
1092  }

◆ getUseOfflineAsVirtual()

getUseOfflineAsVirtual ( )

Returns the option to decide whether offline servers will be started in virtual mode by default or not.

Returns
boolean
1045  {
1047  }
$start_offline_virtual
Definition: Host.php:74

◆ logAdd()

logAdd (   $logmsg,
  $loglevel = TeamSpeak3::LOGLEVEL_INFO 
)

Writes a custom entry into the server instance log.

Parameters
string$logmsg
integer$loglevel
Returns
void
785  {
786  $sid = $this->serverSelectedId();
787 
788  $this->serverDeselect();
789  $this->execute("logadd", array("logmsg" => $logmsg, "loglevel" => $loglevel));
790  $this->serverSelect($sid);
791  }
serverSelect($sid, $virtual =null)
Selects a virtual server by ID to allow further interaction.
Definition: Host.php:135
serverSelectedId()
Returns the primary ID of the selected virtual server.
Definition: Host.php:97
serverDeselect()
Deselects the active virtual server.
Definition: Host.php:201
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ login()

login (   $username,
  $password 
)

Authenticates with the TeamSpeak 3 Server instance using given ServerQuery login credentials.

Parameters
string$username
string$password
Returns
void
801  {
802  $this->execute("login", array("client_login_name" => $username, "client_login_password" => $password));
803  $this->whoamiReset();
804 
805  $crypt = new TeamSpeak3_Helper_Crypt($username);
806 
807  $this->setStorage("_login_user", $username);
808  $this->setStorage("_login_pass", $crypt->encrypt($password));
809 
810  TeamSpeak3_Helper_Signal::getInstance()->emit("notifyLogin", $this);
811  }
whoamiReset()
Resets the current ServerQuery connection info.
Definition: Host.php:880
Helper class for data encryption.
Definition: Crypt.php:29
setStorage($key, $val)
Writes data to the internal storage array.
Definition: Abstract.php:388
static getInstance()
Returns a singleton instance of TeamSpeak3_Helper_Signal.
Definition: Signal.php:201
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ logout()

logout ( )

Deselects the active virtual server and logs out from the server instance.

Returns
void
819  {
820  $this->request("logout");
821  $this->whoamiReset();
822 
823  $this->delStorage("_login_user");
824  $this->delStorage("_login_pass");
825 
826  TeamSpeak3_Helper_Signal::getInstance()->emit("notifyLogout", $this);
827  }
request($cmd, $throw=TRUE)
Sends a prepared command to the server and returns the result.
Definition: Abstract.php:68
whoamiReset()
Resets the current ServerQuery connection info.
Definition: Host.php:880
delStorage($key)
Deletes data from the internal storage array.
Definition: Abstract.php:411
static getInstance()
Returns a singleton instance of TeamSpeak3_Helper_Signal.
Definition: Signal.php:201

◆ logView()

logView (   $lines = 30,
  $begin_pos = null,
  $reverse = null,
  $instance = TRUE 
)

Displays a specified number of entries (1-100) from the servers log.

Parameters
integer$lines
integer$begin_pos
boolean$reverse
boolean$instance
Returns
array
773  {
774  return $this->execute("logview", array("lines" => $lines, "begin_pos" => $begin_pos, "instance" => $instance, "reverse" => $reverse))->toArray();
775  }
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ message()

message (   $msg)

Sends a text message to all clients on all virtual servers in the TeamSpeak 3 Server instance.

Parameters
string$msg
Returns
void
759  {
760  $this->execute("gm", array("msg" => $msg));
761  }
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ modify()

modify ( array  $properties)

Changes the server instance configuration using given properties.

Parameters
array$properties
Returns
void
747  {
748  $this->execute("instanceedit", $properties);
749  $this->resetNodeInfo();
750  }
resetNodeInfo()
Definition: Abstract.php:445
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ permissionCats()

permissionCats ( )

Returns a list of permission categories available on the server instance.

Returns
array
481  {
482  if($this->permissionCats === null)
483  {
484  $this->fetchPermissionCats();
485  }
486 
487  return $this->permissionCats;
488  }
permissionCats()
Returns a list of permission categories available on the server instance.
Definition: Host.php:480
fetchPermissionCats()
Definition: Host.php:956
$permissionCats
Definition: Host.php:59

◆ permissionEnds()

permissionEnds ( )

Returns a list of permission category endings available on the server instance.

Returns
array
496  {
497  if($this->permissionEnds === null)
498  {
499  $this->fetchPermissionList();
500  }
501 
502  return $this->permissionCats;
503  }
fetchPermissionList()
Definition: Host.php:932
$permissionCats
Definition: Host.php:59
permissionEnds()
Returns a list of permission category endings available on the server instance.
Definition: Host.php:495

◆ permissionFind()

permissionFind (   $permid)

Returns the IDs of all clients, channels or groups using the permission with the specified ID.

Parameters
integer$permid
Returns
array
554  {
555  if(!is_array($permid))
556  {
557  $permident = (is_numeric($permid)) ? "permid" : "permsid";
558  }
559  else
560  {
561  $permident = (is_numeric(current($permid))) ? "permid" : "permsid";
562  }
563 
564  return $this->execute("permfind", array($permident => $permid))->toArray();
565  }
current()
Definition: Abstract.php:482
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ permissionGetCategoryById()

permissionGetCategoryById (   $permid)

Returns the internal category of the permission matching the given ID.

All pre-3.0.7 permission IDs are are 2 bytes wide. The first byte identifies the category while the second byte is the permission count within that group.

Parameters
integer$permid
Returns
integer
611  {
612  if(!is_numeric($permid))
613  {
614  $permid = $this->permissionGetIdByName($permid);
615  }
616 
617  if($permid < 0x1000)
618  {
619  if($this->permissionEnds === null)
620  {
621  $this->fetchPermissionList();
622  }
623 
624  if($this->permissionCats === null)
625  {
626  $this->fetchPermissionCats();
627  }
628 
629  $catids = array_values($this->permissionCats());
630 
631  foreach($this->permissionEnds as $key => $val)
632  {
633  if($val >= $permid && isset($catids[$key]))
634  {
635  return $catids[$key];
636  }
637  }
638 
639  return 0;
640  }
641  else
642  {
643  return (int) $permid >> 8;
644  }
645  }
permissionCats()
Returns a list of permission categories available on the server instance.
Definition: Host.php:480
permissionGetIdByName($name)
Returns the ID of the permission matching the given name.
Definition: Host.php:574
fetchPermissionList()
Definition: Host.php:932
fetchPermissionCats()
Definition: Host.php:956
permissionEnds()
Returns a list of permission category endings available on the server instance.
Definition: Host.php:495

◆ permissionGetGrantById()

permissionGetGrantById (   $permid)

Returns the internal ID of the i_needed_modify_power_* or grant permission.

Every permission has an associated i_needed_modify_power_* permission, for example b_client_ban_create has an associated permission called i_needed_modify_power_client_ban_create.

Parameters
integer$permid
Returns
integer
657  {
658  if(!is_numeric($permid))
659  {
660  $permid = $this->permissionGetIdByName($permid);
661  }
662 
663  if($permid < 0x1000)
664  {
665  return (int) $permid+0x8000;
666  }
667  else
668  {
669  return (int) bindec(substr(decbin($permid), -8))+0xFF00;
670  }
671  }
permissionGetIdByName($name)
Returns the ID of the permission matching the given name.
Definition: Host.php:574

◆ permissionGetIdByName()

permissionGetIdByName (   $name)

Returns the ID of the permission matching the given name.

Parameters
string$name
Exceptions
TeamSpeak3_Adapter_ServerQuery_Exception
Returns
integer
575  {
576  if(!array_key_exists((string) $name, $this->permissionList()))
577  {
578  throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid permission ID", 0xA02);
579  }
580 
581  return $this->permissionList[(string) $name]["permid"];
582  }
permissionList()
Returns a list of permissions available on the server instance.
Definition: Host.php:443
Enhanced exception class for TeamSpeak3_Adapter_ServerQuery objects.
Definition: Exception.php:29

◆ permissionGetNameById()

permissionGetNameById (   $permid)

Returns the name of the permission matching the given ID.

Parameters
integer$permid
Exceptions
TeamSpeak3_Adapter_ServerQuery_Exception
Returns
TeamSpeak3_Helper_String
592  {
593  foreach($this->permissionList() as $name => $perm)
594  {
595  if($perm["permid"] == $permid) return new TeamSpeak3_Helper_String($name);
596  }
597 
598  throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid permission ID", 0xA02);
599  }
Helper class for string handling.
Definition: String.php:29
permissionList()
Returns a list of permissions available on the server instance.
Definition: Host.php:443
Enhanced exception class for TeamSpeak3_Adapter_ServerQuery objects.
Definition: Exception.php:29

◆ permissionList()

permissionList ( )

Returns a list of permissions available on the server instance.

Returns
array
444  {
445  if($this->permissionList === null)
446  {
447  $this->fetchPermissionList();
448  }
449 
450  foreach($this->permissionList as $permname => $permdata)
451  {
452  if(isset($permdata["permcatid"]) && $permdata["permgrant"])
453  {
454  continue;
455  }
456 
457  $this->permissionList[$permname]["permcatid"] = $this->permissionGetCategoryById($permdata["permid"]);
458  $this->permissionList[$permname]["permgrant"] = $this->permissionGetGrantById($permdata["permid"]);
459 
460  $grantsid = "i_needed_modify_power_" . substr($permname, 2);
461 
462  if(!$permdata["permname"]->startsWith("i_needed_modify_power_") && !isset($this->permissionList[$grantsid]))
463  {
464  $this->permissionList[$grantsid]["permid"] = $this->permissionList[$permname]["permgrant"];
465  $this->permissionList[$grantsid]["permname"] = TeamSpeak3_Helper_String::factory($grantsid);
466  $this->permissionList[$grantsid]["permdesc"] = null;
467  $this->permissionList[$grantsid]["permcatid"] = 0xFF;
468  $this->permissionList[$grantsid]["permgrant"] = $this->permissionList[$permname]["permgrant"];
469  }
470  }
471 
472  return $this->permissionList;
473  }
$permissionList
Definition: Host.php:54
permissionList()
Returns a list of permissions available on the server instance.
Definition: Host.php:443
fetchPermissionList()
Definition: Host.php:932
permissionGetGrantById($permid)
Returns the internal ID of the i_needed_modify_power_* or grant permission.
Definition: Host.php:656
static factory($string)
Returns a TeamSpeak3_Helper_String object for thegiven string.
Definition: String.php:60
permissionGetCategoryById($permid)
Returns the internal category of the permission matching the given ID.
Definition: Host.php:610

◆ permissionTree()

permissionTree ( )

Returns an array filled with all permission categories known to the server including their ID, name and parent.

Returns
array
512  {
513  $permtree = array();
514 
515  foreach($this->permissionCats() as $key => $val)
516  {
517  $permtree[$val]["permcatid"] = $val;
518  $permtree[$val]["permcathex"] = "0x" . dechex($val);
520  $permtree[$val]["permcatparent"] = $permtree[$val]["permcathex"]{3} == 0 ? 0 : hexdec($permtree[$val]["permcathex"]{2} . 0);
521  $permtree[$val]["permcatchilren"] = 0;
522  $permtree[$val]["permcatcount"] = 0;
523 
524  if(isset($permtree[$permtree[$val]["permcatparent"]]))
525  {
526  $permtree[$permtree[$val]["permcatparent"]]["permcatchilren"]++;
527  }
528 
529  if($permtree[$val]["permcatname"]->contains("/"))
530  {
531  $permtree[$val]["permcatname"] = $permtree[$val]["permcatname"]->section("/", 1)->trim();
532  }
533 
534  foreach($this->permissionList() as $permission)
535  {
536  if($permission["permid"]["permcatid"] == $val)
537  {
538  $permtree[$val]["permcatcount"]++;
539  }
540  }
541  }
542 
543  return $permtree;
544  }
permissionCats()
Returns a list of permission categories available on the server instance.
Definition: Host.php:480
permissionList()
Returns a list of permissions available on the server instance.
Definition: Host.php:443
static permissionCategory($pcat)
Converts a given permission category value to a human readable name.
Definition: Convert.php:141
static factory($string)
Returns a TeamSpeak3_Helper_String object for thegiven string.
Definition: String.php:60

◆ selfPermCheck()

selfPermCheck (   $permid)

Returns an array containing the value of a specified permission for your own client.

Parameters
integer$permid
Returns
array
727  {
728  if(!is_array($permid))
729  {
730  $permident = (is_numeric($permid)) ? "permid" : "permsid";
731  }
732  else
733  {
734  $permident = (is_numeric(current($permid))) ? "permid" : "permsid";
735  }
736 
737  return $this->execute("permget", array($permident => $permid))->toAssocArray("permsid");
738  }
current()
Definition: Abstract.php:482
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ serverCreate()

serverCreate ( array  $properties = array())

Creates a new virtual server using given properties and returns an assoc array containing the new ID and initial admin token.

Parameters
array$properties
Returns
array
315  {
316  $this->serverListReset();
317 
318  $detail = $this->execute("servercreate", $properties)->toList();
319  $server = new TeamSpeak3_Node_Server($this, array("virtualserver_id" => intval($detail["sid"])));
320 
321  TeamSpeak3_Helper_Signal::getInstance()->emit("notifyServercreated", $this, $detail["sid"]);
322  TeamSpeak3_Helper_Signal::getInstance()->emit("notifyTokencreated", $server, $detail["token"]);
323 
324  return $detail;
325  }
$server
Definition: Abstract.php:39
serverListReset()
Resets the list of virtual servers.
Definition: Host.php:422
static getInstance()
Returns a singleton instance of TeamSpeak3_Helper_Signal.
Definition: Signal.php:201
Class describing a TeamSpeak 3 virtual server and all it&#39;s parameters.
Definition: Server.php:29
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ serverDelete()

serverDelete (   $sid)

Deletes the virtual server specified by ID.

Parameters
integer$sid
Returns
void
334  {
335  $this->serverListReset();
336 
337  $this->execute("serverdelete", array("sid" => $sid));
338 
339  TeamSpeak3_Helper_Signal::getInstance()->emit("notifyServerdeleted", $this, $sid);
340  }
serverListReset()
Resets the list of virtual servers.
Definition: Host.php:422
static getInstance()
Returns a singleton instance of TeamSpeak3_Helper_Signal.
Definition: Signal.php:201
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ serverDeselect()

serverDeselect ( )

Deselects the active virtual server.

Returns
void
202  {
203  $this->serverSelect(0);
204 
205  $this->delStorage("_server_use");
206  }
serverSelect($sid, $virtual =null)
Selects a virtual server by ID to allow further interaction.
Definition: Host.php:135
delStorage($key)
Deletes data from the internal storage array.
Definition: Abstract.php:411

◆ serverGetById()

serverGetById (   $sid)

Returns the TeamSpeak3_Node_Server object matching the given ID.

Parameters
integer$sid
Returns
TeamSpeak3_Node_Server
254  {
255  $this->serverSelectById($sid);
256 
257  return new TeamSpeak3_Node_Server($this, array("virtualserver_id" => intval($sid)));
258  }
serverSelectById($sid, $virtual =null)
Alias for serverSelect().
Definition: Host.php:163
Class describing a TeamSpeak 3 virtual server and all it&#39;s parameters.
Definition: Server.php:29

◆ serverGetByName()

serverGetByName (   $name)

Returns the first TeamSpeak3_Node_Server object matching the given name.

Parameters
string$name
Exceptions
TeamSpeak3_Adapter_ServerQuery_Exception
Returns
TeamSpeak3_Node_Server
281  {
282  foreach($this->serverList() as $server)
283  {
284  if($server["virtualserver_name"] == $name) return $server;
285  }
286 
287  throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid serverID", 0x400);
288  }
serverList(array $filter=array())
Returns an array filled with TeamSpeak3_Node_Server objects.
Definition: Host.php:398
$server
Definition: Abstract.php:39
Enhanced exception class for TeamSpeak3_Adapter_ServerQuery objects.
Definition: Exception.php:29

◆ serverGetByPort()

serverGetByPort (   $port)

Returns the TeamSpeak3_Node_Server object matching the given port number.

Parameters
integer$port
Returns
TeamSpeak3_Node_Server
267  {
268  $this->serverSelectByPort($port);
269 
270  return new TeamSpeak3_Node_Server($this, array("virtualserver_id" => $this->serverSelectedId()));
271  }
serverSelectByPort($port, $virtual =null)
Selects a virtual server by UDP port to allow further interaction.
Definition: Host.php:175
serverSelectedId()
Returns the primary ID of the selected virtual server.
Definition: Host.php:97
Class describing a TeamSpeak 3 virtual server and all it&#39;s parameters.
Definition: Server.php:29

◆ serverGetByUid()

serverGetByUid (   $uid)

Returns the first TeamSpeak3_Node_Server object matching the given unique identifier.

Parameters
string$uid
Exceptions
TeamSpeak3_Adapter_ServerQuery_Exception
Returns
TeamSpeak3_Node_Server
298  {
299  foreach($this->serverList() as $server)
300  {
301  if($server["virtualserver_unique_identifier"] == $uid) return $server;
302  }
303 
304  throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid serverID", 0x400);
305  }
serverList(array $filter=array())
Returns an array filled with TeamSpeak3_Node_Server objects.
Definition: Host.php:398
$server
Definition: Abstract.php:39
Enhanced exception class for TeamSpeak3_Adapter_ServerQuery objects.
Definition: Exception.php:29

◆ serverGetPortById()

serverGetPortById (   $sid)

Returns the port of a virtual server matching the given ID.

Parameters
integer$sid
Returns
integer
228  {
229  if(!array_key_exists((string) $sid, $this->serverList()))
230  {
231  throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid serverID", 0x400);
232  }
233 
234  return $this->serverList[intval((string) $sid)]["virtualserver_port"];
235  }
serverList(array $filter=array())
Returns an array filled with TeamSpeak3_Node_Server objects.
Definition: Host.php:398
Enhanced exception class for TeamSpeak3_Adapter_ServerQuery objects.
Definition: Exception.php:29

◆ serverGetSelected()

serverGetSelected ( )

Returns the TeamSpeak3_Node_Server object matching the currently selected ID.

Returns
TeamSpeak3_Node_Server
243  {
244  return $this->serverGetById($this->serverSelectedId());
245  }
serverSelectedId()
Returns the primary ID of the selected virtual server.
Definition: Host.php:97
serverGetById($sid)
Returns the TeamSpeak3_Node_Server object matching the given ID.
Definition: Host.php:253

◆ serverGroupPermAutoAssign()

serverGroupPermAutoAssign (   $sgtype,
  $permid,
  $permvalue,
  $permnegated = FALSE,
  $permskip = FALSE 
)

Adds a set of specified permissions to all regular server groups on all virtual servers.

The target groups will be identified by the value of their i_group_auto_update_type permission specified with $sgtype.

Parameters
integer$sgtype
integer$permid
integer$permvalue
integer$permnegated
integer$permskip
Returns
void
685  {
686  if(!is_array($permid))
687  {
688  $permident = (is_numeric($permid)) ? "permid" : "permsid";
689  }
690  else
691  {
692  $permident = (is_numeric(current($permid))) ? "permid" : "permsid";
693  }
694 
695  $this->execute("servergroupautoaddperm", array("sgtype" => $sgtype, $permident => $permid, "permvalue" => $permvalue, "permnegated" => $permnegated, "permskip" => $permskip));
696  }
current()
Definition: Abstract.php:482
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ serverGroupPermAutoRemove()

serverGroupPermAutoRemove (   $sgtype,
  $permid 
)

Removes a set of specified permissions from all regular server groups on all virtual servers.

The target groups will be identified by the value of their i_group_auto_update_type permission specified with $sgtype.

Parameters
integer$sgtype
integer$permid
Returns
void
707  {
708  if(!is_array($permid))
709  {
710  $permident = (is_numeric($permid)) ? "permid" : "permsid";
711  }
712  else
713  {
714  $permident = (is_numeric(current($permid))) ? "permid" : "permsid";
715  }
716 
717  $this->execute("servergroupautodelperm", array("sgtype" => $sgtype, $permident => $permid));
718  }
current()
Definition: Abstract.php:482
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ serverIdGetByPort()

serverIdGetByPort (   $port)

Returns the ID of a virtual server matching the given port.

Parameters
integer$port
Returns
integer
215  {
216  $sid = $this->execute("serveridgetbyport", array("virtualserver_port" => $port))->toList();
217 
218  return $sid["server_id"];
219  }
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ serverList()

serverList ( array  $filter = array())

Returns an array filled with TeamSpeak3_Node_Server objects.

Parameters
array$filter
Returns
array
399  {
400  if($this->serverList === null)
401  {
402  $servers = $this->request("serverlist -uid")->toAssocArray("virtualserver_id");
403 
404  $this->serverList = array();
405 
406  foreach($servers as $sid => $server)
407  {
408  $this->serverList[$sid] = new TeamSpeak3_Node_Server($this, $server);
409  }
410 
411  $this->resetNodeList();
412  }
413 
414  return $this->filterList($this->serverList, $filter);
415  }
serverList(array $filter=array())
Returns an array filled with TeamSpeak3_Node_Server objects.
Definition: Host.php:398
filterList(array $nodes=array(), array $rules=array())
Filters given node list array using specified filter rules.
Definition: Abstract.php:219
request($cmd, $throw=TRUE)
Sends a prepared command to the server and returns the result.
Definition: Abstract.php:68
$server
Definition: Abstract.php:39
Class describing a TeamSpeak 3 virtual server and all it&#39;s parameters.
Definition: Server.php:29
resetNodeList()
Definition: Abstract.php:464

◆ serverListReset()

serverListReset ( )

Resets the list of virtual servers.

Returns
void
423  {
424  $this->resetNodeList();
425  $this->serverList = null;
426  }
serverList(array $filter=array())
Returns an array filled with TeamSpeak3_Node_Server objects.
Definition: Host.php:398
resetNodeList()
Definition: Abstract.php:464

◆ serverSelect()

serverSelect (   $sid,
  $virtual = null 
)

Selects a virtual server by ID to allow further interaction.

Parameters
integer$sid
boolean$virtual
Returns
void
136  {
137  if($this->whoami !== null && $this->serverSelectedId() == $sid) return;
138 
139  $virtual = ($virtual !== null) ? $virtual : $this->start_offline_virtual;
140  $getargs = func_get_args();
141 
142  $this->execute("use", array("sid" => $sid, $virtual ? "-virtual" : null));
143 
144  if($sid != 0 && $this->predefined_query_name !== null)
145  {
146  $this->execute("clientupdate", array("client_nickname" => (string) $this->predefined_query_name));
147  }
148 
149  $this->whoamiReset();
150 
151  $this->setStorage("_server_use", array(__FUNCTION__, $getargs));
152 
153  TeamSpeak3_Helper_Signal::getInstance()->emit("notifyServerselected", $this);
154  }
serverSelectedId()
Returns the primary ID of the selected virtual server.
Definition: Host.php:97
whoamiReset()
Resets the current ServerQuery connection info.
Definition: Host.php:880
whoami()
Returns information about your current ServerQuery connection.
Definition: Host.php:834
setStorage($key, $val)
Writes data to the internal storage array.
Definition: Abstract.php:388
static getInstance()
Returns a singleton instance of TeamSpeak3_Helper_Signal.
Definition: Signal.php:201
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ serverSelectById()

serverSelectById (   $sid,
  $virtual = null 
)

Alias for serverSelect().

Parameters
integer$sid
boolean$virtual
Returns
void
164  {
165  $this->serverSelect($sid, $virtual);
166  }
serverSelect($sid, $virtual =null)
Selects a virtual server by ID to allow further interaction.
Definition: Host.php:135

◆ serverSelectByPort()

serverSelectByPort (   $port,
  $virtual = null 
)

Selects a virtual server by UDP port to allow further interaction.

Parameters
integer$port
boolean$virtual
Returns
void
176  {
177  if($this->whoami !== null && $this->serverSelectedPort() == $port) return;
178 
179  $virtual = ($virtual !== null) ? $virtual : $this->start_offline_virtual;
180  $getargs = func_get_args();
181 
182  $this->execute("use", array("port" => $port, $virtual ? "-virtual" : null));
183 
184  if($port != 0 && $this->predefined_query_name !== null)
185  {
186  $this->execute("clientupdate", array("client_nickname" => (string) $this->predefined_query_name));
187  }
188 
189  $this->whoamiReset();
190 
191  $this->setStorage("_server_use", array(__FUNCTION__, $getargs));
192 
193  TeamSpeak3_Helper_Signal::getInstance()->emit("notifyServerselected", $this);
194  }
whoamiReset()
Resets the current ServerQuery connection info.
Definition: Host.php:880
whoami()
Returns information about your current ServerQuery connection.
Definition: Host.php:834
setStorage($key, $val)
Writes data to the internal storage array.
Definition: Abstract.php:388
static getInstance()
Returns a singleton instance of TeamSpeak3_Helper_Signal.
Definition: Signal.php:201
serverSelectedPort()
Returns the primary UDP port of the selected virtual server.
Definition: Host.php:107
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ serverSelectedId()

serverSelectedId ( )

Returns the primary ID of the selected virtual server.

Returns
integer
98  {
99  return $this->whoamiGet("virtualserver_id", 0);
100  }
whoamiGet($ident, $default=null)
Returns a single value from the current ServerQuery connection info.
Definition: Host.php:851

◆ serverSelectedPort()

serverSelectedPort ( )

Returns the primary UDP port of the selected virtual server.

Returns
integer
108  {
109  return $this->whoamiGet("virtualserver_port", 0);
110  }
whoamiGet($ident, $default=null)
Returns a single value from the current ServerQuery connection info.
Definition: Host.php:851

◆ serverStart()

serverStart (   $sid)

Starts the virtual server specified by ID.

Parameters
integer$sid
Returns
void
349  {
350  if($sid == $this->serverSelectedId())
351  {
352  $this->serverDeselect();
353  }
354 
355  $this->execute("serverstart", array("sid" => $sid));
356  $this->serverListReset();
357 
358  TeamSpeak3_Helper_Signal::getInstance()->emit("notifyServerstarted", $this, $sid);
359  }
serverSelectedId()
Returns the primary ID of the selected virtual server.
Definition: Host.php:97
serverListReset()
Resets the list of virtual servers.
Definition: Host.php:422
static getInstance()
Returns a singleton instance of TeamSpeak3_Helper_Signal.
Definition: Signal.php:201
serverDeselect()
Deselects the active virtual server.
Definition: Host.php:201
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ serverStop()

serverStop (   $sid)

Stops the virtual server specified by ID.

Parameters
integer$sid
Returns
void
368  {
369  if($sid == $this->serverSelectedId())
370  {
371  $this->serverDeselect();
372  }
373 
374  $this->execute("serverstop", array("sid" => $sid));
375  $this->serverListReset();
376 
377  TeamSpeak3_Helper_Signal::getInstance()->emit("notifyServerstopped", $this, $sid);
378  }
serverSelectedId()
Returns the primary ID of the selected virtual server.
Definition: Host.php:97
serverListReset()
Resets the list of virtual servers.
Definition: Host.php:422
static getInstance()
Returns a singleton instance of TeamSpeak3_Helper_Signal.
Definition: Signal.php:201
serverDeselect()
Deselects the active virtual server.
Definition: Host.php:201
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ serverStopProcess()

serverStopProcess ( )

Stops the entire TeamSpeak 3 Server instance by shutting down the process.

Returns
void
386  {
387  TeamSpeak3_Helper_Signal::getInstance()->emit("notifyServershutdown", $this);
388 
389  $this->execute("serverprocessstop");
390  }
static getInstance()
Returns a singleton instance of TeamSpeak3_Helper_Signal.
Definition: Signal.php:201
execute($cmd, array $params=array())
Prepares and executes a ServerQuery command and returns the result.
Definition: Abstract.php:92

◆ setExcludeQueryClients()

setExcludeQueryClients (   $exclude = FALSE)

Sets the option to decide whether ServerQuery clients should be excluded from node lists or not.

Parameters
boolean$exclude
Returns
void
1007  {
1008  $this->setStorage("_query_hide", $exclude);
1009 
1010  $this->exclude_query_clients = $exclude;
1011  }
setStorage($key, $val)
Writes data to the internal storage array.
Definition: Abstract.php:388

◆ setLoadClientlistFirst()

setLoadClientlistFirst (   $first = FALSE)

Sets the option to decide whether clients should be sorted before sub-channels to support the new TeamSpeak 3 Client display mode or not.

Parameters
boolean$first
Returns
void
1057  {
1058  $this->setStorage("_client_top", $first);
1059 
1060  $this->sort_clients_channels = $first;
1061  }
setStorage($key, $val)
Writes data to the internal storage array.
Definition: Abstract.php:388

◆ setPredefinedQueryName()

setPredefinedQueryName (   $name = null)

Sets a pre-defined nickname for ServerQuery clients which will be used automatically after selecting a virtual server.

Parameters
string$name
Returns
void
982  {
983  $this->setStorage("_query_nick", $name);
984 
985  $this->predefined_query_name = $name;
986  }
setStorage($key, $val)
Writes data to the internal storage array.
Definition: Abstract.php:388

◆ setUseOfflineAsVirtual()

setUseOfflineAsVirtual (   $virtual = FALSE)

Sets the option to decide whether offline servers will be started in virtual mode by default or not.

Parameters
boolean$virtual
Returns
void
1032  {
1033  $this->setStorage("_do_virtual", $virtual);
1034 
1035  $this->start_offline_virtual = $virtual;
1036  }
setStorage($key, $val)
Writes data to the internal storage array.
Definition: Abstract.php:388

◆ version()

version (   $ident = null)

Returns the servers version information including platform and build number.

Parameters
string$ident
Returns
mixed
119  {
120  if($this->version === null)
121  {
122  $this->version = $this->request("version")->toList();
123  }
124 
125  return ($ident && isset($this->version[$ident])) ? $this->version[$ident] : $this->version;
126  }
$version
Definition: Host.php:39
request($cmd, $throw=TRUE)
Sends a prepared command to the server and returns the result.
Definition: Abstract.php:68
version($ident=null)
Returns the servers version information including platform and build number.
Definition: Host.php:118

◆ whoami()

whoami ( )

Returns information about your current ServerQuery connection.

Returns
array
835  {
836  if($this->whoami === null)
837  {
838  $this->whoami = $this->request("whoami")->toList();
839  }
840 
841  return $this->whoami;
842  }
request($cmd, $throw=TRUE)
Sends a prepared command to the server and returns the result.
Definition: Abstract.php:68
whoami()
Returns information about your current ServerQuery connection.
Definition: Host.php:834
$whoami
Definition: Host.php:34

◆ whoamiGet()

whoamiGet (   $ident,
  $default = null 
)

Returns a single value from the current ServerQuery connection info.

Parameters
string$ident
mixed$default
Returns
mixed
852  {
853  if(array_key_exists($ident, $this->whoami()))
854  {
855  return $this->whoami[$ident];
856  }
857 
858  return $default;
859  }
whoami()
Returns information about your current ServerQuery connection.
Definition: Host.php:834

◆ whoamiReset()

whoamiReset ( )

Resets the current ServerQuery connection info.

Returns
void
881  {
882  $this->whoami = null;
883  }
whoami()
Returns information about your current ServerQuery connection.
Definition: Host.php:834

◆ whoamiSet()

whoamiSet (   $ident,
  $value = null 
)

Sets a single value in the current ServerQuery connection info.

Parameters
string$ident
mixed$value
Returns
mixed
869  {
870  $this->whoami();
871 
872  $this->whoami[$ident] = (is_numeric($value)) ? (int) $value : TeamSpeak3_Helper_String::factory($value);
873  }
whoami()
Returns information about your current ServerQuery connection.
Definition: Host.php:834
static factory($string)
Returns a TeamSpeak3_Helper_String object for thegiven string.
Definition: String.php:60

The documentation for this class was generated from the following file: