92 $this->parent = $squery;
102 return $this->
whoamiGet(
"virtualserver_id", 0);
112 return $this->
whoamiGet(
"virtualserver_port", 0);
142 $virtual = ($virtual !== null) ? $virtual : $this->start_offline_virtual;
143 $getargs = func_get_args();
145 $this->
execute(
"use", array(
"sid" => $sid, $virtual ?
"-virtual" : null));
147 if($sid != 0 && $this->predefined_query_name !== null)
149 $this->
execute(
"clientupdate", array(
"client_nickname" => (
string) $this->predefined_query_name));
154 $this->
setStorage(
"_server_use", array(__FUNCTION__, $getargs));
182 $virtual = ($virtual !== null) ? $virtual : $this->start_offline_virtual;
183 $getargs = func_get_args();
185 $this->
execute(
"use", array(
"port" => $port, $virtual ?
"-virtual" : null));
187 if($port != 0 && $this->predefined_query_name !== null)
189 $this->
execute(
"clientupdate", array(
"client_nickname" => (
string) $this->predefined_query_name));
194 $this->
setStorage(
"_server_use", array(__FUNCTION__, $getargs));
219 $sid = $this->
execute(
"serveridgetbyport", array(
"virtualserver_port" => $port))->toList();
221 return $sid[
"server_id"];
232 if(!array_key_exists((
string) $sid, $this->
serverList()))
237 return $this->
serverList[intval((
string) $sid)][
"virtualserver_port"];
287 if($server[
"virtualserver_name"] == $name)
return $server;
304 if($server[
"virtualserver_unique_identifier"] == $uid)
return $server;
324 while($part = array_shift($parts))
326 $query->prepend($part);
330 $port =
TeamSpeak3::factory(
"tsdns://" . $query .
"/?timeout=3")->resolve($tsdns)->section(
":", 1);
337 if($e->getCode() != 10060 && $e->getCode() != 10061)
throw $e;
355 $detail = $this->
execute(
"servercreate", $properties)->toList();
374 $this->
execute(
"serverdelete", array(
"sid" => $sid));
392 $this->
execute(
"serverstart", array(
"sid" => $sid));
411 $this->
execute(
"serverstop", array(
"sid" => $sid));
426 $this->
execute(
"serverprocessstop");
439 $servers = $this->
request(
"serverlist -uid")->toAssocArray(
"virtualserver_id");
443 foreach($servers as $sid =>
$server)
472 return $this->
request(
"bindinglist")->toArray();
489 if(isset($permdata[
"permcatid"]) && $permdata[
"permgrant"])
497 $grantsid =
"i_needed_modify_power_" . substr($permname, 2);
499 if(!$permdata[
"permname"]->startsWith(
"i_needed_modify_power_") && !isset($this->
permissionList[$grantsid]))
554 $permtree[$val][
"permcatid"] = $val;
555 $permtree[$val][
"permcathex"] =
"0x" . dechex($val);
557 $permtree[$val][
"permcatparent"] = $permtree[$val][
"permcathex"]{3} == 0 ? 0 : hexdec($permtree[$val][
"permcathex"]{2} . 0);
558 $permtree[$val][
"permcatchilren"] = 0;
559 $permtree[$val][
"permcatcount"] = 0;
561 if(isset($permtree[$permtree[$val][
"permcatparent"]]))
563 $permtree[$permtree[$val][
"permcatparent"]][
"permcatchilren"]++;
566 if($permtree[$val][
"permcatname"]->contains(
"/"))
568 $permtree[$val][
"permcatname"] = $permtree[$val][
"permcatname"]->section(
"/", 1)->trim();
573 if($permission[
"permid"][
"permcatid"] == $val)
575 $permtree[$val][
"permcatcount"]++;
592 if(!is_array($permid))
594 $permident = (is_numeric($permid)) ?
"permid" :
"permsid";
598 $permident = (is_numeric(
current($permid))) ?
"permid" :
"permsid";
601 return $this->
execute(
"permfind", array($permident => $permid))->toArray();
649 if(!is_numeric($permid))
670 if($val >= $permid && isset($catids[$key]))
672 return $catids[$key];
680 return (
int) $permid >> 8;
695 if(!is_numeric($permid))
702 return (
int) $permid+0x8000;
706 return (
int) bindec(substr(decbin($permid), -8))+0xFF00;
723 if(!is_array($permid))
725 $permident = (is_numeric($permid)) ?
"permid" :
"permsid";
729 $permident = (is_numeric(
current($permid))) ?
"permid" :
"permsid";
732 $this->
execute(
"servergroupautoaddperm", array(
"sgtype" => $sgtype, $permident => $permid,
"permvalue" => $permvalue,
"permnegated" => $permnegated,
"permskip" => $permskip));
745 if(!is_array($permid))
747 $permident = (is_numeric($permid)) ?
"permid" :
"permsid";
751 $permident = (is_numeric(
current($permid))) ?
"permid" :
"permsid";
754 $this->
execute(
"servergroupautodelperm", array(
"sgtype" => $sgtype, $permident => $permid));
765 if(!is_array($permid))
767 $permident = (is_numeric($permid)) ?
"permid" :
"permsid";
771 $permident = (is_numeric(
current($permid))) ?
"permid" :
"permsid";
774 return $this->
execute(
"permget", array($permident => $permid))->toAssocArray(
"permsid");
783 public function modify(array $properties)
785 $this->
execute(
"instanceedit", $properties);
797 $this->
execute(
"gm", array(
"msg" => $msg));
809 public function logView($lines = 30, $begin_pos = null, $reverse = null, $instance = TRUE)
811 return $this->
execute(
"logview", array(
"lines" => $lines,
"begin_pos" => $begin_pos,
"instance" => $instance,
"reverse" => $reverse))->toArray();
826 $this->
execute(
"logadd", array(
"logmsg" => $logmsg,
"loglevel" => $loglevel));
837 public function login($username, $password)
839 $this->
execute(
"login", array(
"client_login_name" => $username,
"client_login_password" => $password));
845 $this->
setStorage(
"_login_pass", $crypt->encrypt($password));
873 if($this->
whoami === null)
890 if(array_key_exists($ident, $this->
whoami()))
892 return $this->
whoami[$ident];
929 return $this->
getParent()->getTransportHost();
939 return $this->
getParent()->getTransportPort();
960 $info1 = $this->
request(
"hostinfo")->toList();
961 $info2 = $this->
request(
"instanceinfo")->toList();
963 $this->nodeInfo = array_merge($this->nodeInfo, $info1, $info2);
971 $reply = $this->
request(
"permissionlist -new")->toArray();
977 foreach($reply as $line)
979 if(array_key_exists(
"group_id_end", $line))
985 $this->
permissionList[$line[
"permname"]->toString()] = array_merge(array(
"permid" => $start++), $line);
996 $reflects =
new ReflectionClass(
"TeamSpeak3");
998 foreach($reflects->getConstants() as $key => $val)
1005 $permcats[$key] = $val;
1022 $this->predefined_query_name = $name;
1047 $this->exclude_query_clients = $exclude;
1072 $this->start_offline_virtual = $virtual;
1097 $this->sort_clients_channels = $first;
1159 $username = $this->
getStorage(
"_login_user");
1160 $password = $this->
getStorage(
"_login_pass");
1162 if($username && $password)
1166 $this->
login($username, $crypt->decrypt($password));
1169 $this->predefined_query_name = $this->
getStorage(
"_query_nick");
1170 $this->exclude_query_clients = $this->
getStorage(
"_query_hide", FALSE);
1171 $this->start_offline_virtual = $this->
getStorage(
"_do_virtual", FALSE);
1172 $this->sort_clients_channels = $this->
getStorage(
"_client_top", FALSE);
1179 call_user_func_array(array($this, $func), $args);