Esempio n. 1
0
 /**
  * Returns the HTML code needed to display this node in a TeamSpeak 3 viewer.
  *
  * @param  TeamSpeak3_Node_Abstract $node
  * @return string
  */
 public function fetchObject(TeamSpeak3_Node_Abstract $node, array $siblings = array())
 {
     $prefix = "";
     $suffix = "";
     $detail = "";
     if (count($siblings)) {
         $last = array_pop($siblings);
         foreach ($siblings as $level) {
             $prefix .= $level ? $this->getImage("16x16_tree_line.gif") : $this->getImage("16x16_tree_blank.png");
         }
         $prefix .= $last ? $this->getImage("16x16_tree_end.gif") : $this->getImage("16x16_tree_mid.gif");
     }
     if ($node instanceof TeamSpeak3_Node_Server) {
         $detail .= "ID: " . $node->getId() . " | Clients: " . $node->clientCount() . "/" . $node["virtualserver_maxclients"] . " | Uptime: " . TeamSpeak3_Helper_Convert::seconds($node["virtualserver_uptime"]);
     } elseif ($node instanceof TeamSpeak3_Node_Channel) {
         $suffix .= $this->fetchSuffixChannel($node);
         $detail .= "ID: " . $node->getId() . " | Codec: " . TeamSpeak3_Helper_Convert::codec($node["channel_codec"]) . " | Quality: " . $node["channel_codec_quality"];
     } elseif ($node instanceof TeamSpeak3_Node_Client) {
         $suffix .= $this->fetchSuffixClient($node);
         $detail .= "ID: " . $node->getId() . " | Version: " . $node["client_version"] . " | Platform: " . $node["client_platform"];
     }
     return "<div id='" . $node->getUniqueId() . "'>" . $prefix . $this->getImage("16x16_" . $node->getIcon() . ".png") . " <span title='" . $detail . "'>" . htmlspecialchars($node) . " " . $suffix . "</span></div>\n";
 }
Esempio n. 2
0
 /**
  * Returns the HTML img tags which can be used to display the various icons for a
  * TeamSpeak_Node_Client object.
  *
  * @return string
  */
 protected function getSuffixIconClient()
 {
     $html = "";
     if ($this->currObj["client_is_priority_speaker"]) {
         $html .= $this->getImage("client_priority.png", "Priority Speaker");
     }
     if ($this->currObj["client_is_channel_commander"]) {
         $html .= $this->getImage("client_cc.png", "Channel Commander");
     }
     if ($this->currObj["client_is_talker"]) {
         $html .= $this->getImage("client_talker.png", "Talk Power granted");
     } elseif ($cntp = $this->currObj->getParent()->channelGetById($this->currObj["cid"])->channel_needed_talk_power) {
         if ($cntp > $this->currObj["client_talk_power"]) {
             $html .= $this->getImage("client_mic_muted.png", "Insufficient Talk Power");
         }
     }
     foreach ($this->currObj->memberOf() as $group) {
         if (!$group["iconid"]) {
             continue;
         }
         $type = $group instanceof TeamSpeak3_Node_Servergroup ? "Server Group" : "Channel Group";
         if (!$group->iconIsLocal("iconid") && $this->ftclient) {
             if (!isset($this->cacheIcon[$group["iconid"]])) {
                 $download = $group->getParent()->transferInitDownload(rand(0x0, 0xffff), 0, $group->iconGetName("iconid"));
                 if ($this->ftclient == "data:image") {
                     $download = TeamSpeak3::factory("filetransfer://" . $download["host"] . ":" . $download["port"])->download($download["ftkey"], $download["size"]);
                 }
                 $this->cacheIcon[$group["iconid"]] = $download;
             } else {
                 $download = $this->cacheIcon[$group["iconid"]];
             }
             if ($this->ftclient == "data:image") {
                 $html .= $this->getImage("data:" . TeamSpeak3_Helper_Convert::imageMimeType($download) . ";base64," . base64_encode($download), $group . " [" . $type . "]", null, FALSE);
             } else {
                 $html .= $this->getImage($this->ftclient . "?ftdata=" . base64_encode(serialize($download)), $group . " [" . $type . "]", null, FALSE);
             }
         } elseif (in_array($group["iconid"], $this->cachedIcons)) {
             $html .= $this->getImage("group_icon_" . $group["iconid"] . ".png", $group . " [" . $type . "]");
         }
     }
     if ($this->currObj["client_icon_id"]) {
         if (!$this->currObj->iconIsLocal("client_icon_id") && $this->ftclient) {
             if (!isset($this->cacheIcon[$this->currObj["client_icon_id"]])) {
                 $download = $this->currObj->getParent()->transferInitDownload(rand(0x0, 0xffff), 0, $this->currObj->iconGetName("client_icon_id"));
                 if ($this->ftclient == "data:image") {
                     $download = TeamSpeak3::factory("filetransfer://" . $download["host"] . ":" . $download["port"])->download($download["ftkey"], $download["size"]);
                 }
                 $this->cacheIcon[$this->currObj["client_icon_id"]] = $download;
             } else {
                 $download = $this->cacheIcon[$this->currObj["client_icon_id"]];
             }
             if ($this->ftclient == "data:image") {
                 $html .= $this->getImage("data:" . TeamSpeak3_Helper_Convert::imageMimeType($download) . ";base64," . base64_encode($download), "Client Icon", null, FALSE);
             } else {
                 $html .= $this->getImage($this->ftclient . "?ftdata=" . base64_encode(serialize($download)), "Client Icon", null, FALSE);
             }
         } elseif (in_array($this->currObj["client_icon_id"], $this->cachedIcons)) {
             $html .= $this->getImage("group_icon_" . $this->currObj["client_icon_id"] . ".png", "Client Icon");
         }
     }
     return $html;
 }
Esempio n. 3
0
 /**
  * Returns all information available on this node. If $convert is enabled, some property
  * values will be converted to human-readable values.
  *
  * @param  boolean $extend
  * @param  boolean $convert
  * @return array
  */
 public function getInfo($extend = TRUE, $convert = FALSE)
 {
     if ($extend) {
         $this->fetchNodeInfo();
     }
     if ($convert) {
         $info = $this->nodeInfo;
         foreach ($info as $key => $val) {
             $key = TeamSpeak3_Helper_String::factory($key);
             if ($key->contains("_bytes_")) {
                 $info[$key->toString()] = TeamSpeak3_Helper_Convert::bytes($val);
             } elseif ($key->contains("_bandwidth_")) {
                 $info[$key->toString()] = TeamSpeak3_Helper_Convert::bytes($val) . "/s";
             } elseif ($key->contains("_packets_")) {
                 $info[$key->toString()] = number_format($val, null, null, ".");
             } elseif ($key->contains("_packetloss_")) {
                 $info[$key->toString()] = sprintf("%01.2f", floatval($val->toString()) * 100) . "%";
             } elseif ($key->endsWith("_uptime")) {
                 $info[$key->toString()] = TeamSpeak3_Helper_Convert::seconds($val);
             } elseif ($key->endsWith("_icon_id")) {
                 $info[$key->toString()] = $this->iconGetName($key)->filterDigits();
             }
         }
         return $info;
     }
     return $this->nodeInfo;
 }
Esempio n. 4
0
 /**
  * Returns the HTML img tags which can be used to display the various icons for a
  * TeamSpeak_Node_Abstract object.
  *
  * @return string
  */
 protected function getCorpusTitle()
 {
     if ($this->currObj instanceof TeamSpeak3_Node_Server) {
         return "ID: " . $this->currObj->getId() . " | Clients: " . $this->currObj->clientCount() . "/" . $this->currObj["virtualserver_maxclients"] . " | Uptime: " . TeamSpeak3_Helper_Convert::seconds($this->currObj["virtualserver_uptime"]);
     } elseif ($this->currObj instanceof TeamSpeak3_Node_Channel && !$this->currObj->isSpacer()) {
         return "ID: " . $this->currObj->getId() . " | Codec: " . TeamSpeak3_Helper_Convert::codec($this->currObj["channel_codec"]) . " | Quality: " . $this->currObj["channel_codec_quality"];
     } elseif ($this->currObj instanceof TeamSpeak3_Node_Client) {
         return "ID: " . $this->currObj->getId() . " | Version: " . $this->currObj["client_version"] . " | Platform: " . $this->currObj["client_platform"];
     } elseif ($this->currObj instanceof TeamSpeak3_Node_Servergroup || $this->currObj instanceof TeamSpeak3_Node_Channelgroup) {
         return "ID: " . $this->currObj->getId() . " | Type: " . TeamSpeak3_Helper_Convert::groupType($this->currObj["type"]) . " (" . ($this->currObj["savedb"] ? "Permanent" : "Temporary") . ")";
     }
 }
Esempio n. 5
0
 /**
  * Returns an array filled with all permission categories known to the server including
  * their ID, name and parent.
  *
  * @return array
  */
 public function permissionTree()
 {
     $permtree = array();
     foreach ($this->permissionCats() as $key => $val) {
         $permtree[$val]["permcatid"] = $val;
         $permtree[$val]["permcathex"] = "0x" . dechex($val);
         $permtree[$val]["permcatname"] = TeamSpeak3_Helper_String::factory(TeamSpeak3_Helper_Convert::permissionCategory($val));
         $permtree[$val]["permcatparent"] = $permtree[$val]["permcathex"][3] == 0 ? 0 : hexdec($permtree[$val]["permcathex"][2] . 0);
         $permtree[$val]["permcatchilren"] = 0;
         $permtree[$val]["permcatcount"] = 0;
         if (isset($permtree[$permtree[$val]["permcatparent"]])) {
             $permtree[$permtree[$val]["permcatparent"]]["permcatchilren"]++;
         }
         if ($permtree[$val]["permcatname"]->contains("/")) {
             $permtree[$val]["permcatname"] = $permtree[$val]["permcatname"]->section("/", 1)->trim();
         }
         foreach ($this->permissionList() as $permission) {
             if ($permission["permid"]["permcatid"] == $val) {
                 $permtree[$val]["permcatcount"]++;
             }
         }
     }
     return $permtree;
 }