From 5bd99dc358b3bb182a303527d3254648ce3919b3 Mon Sep 17 00:00:00 2001 From: blackcoder87 Date: Fri, 20 Jul 2018 06:21:04 +0200 Subject: [PATCH 1/6] Update for Ilch 2 final - update for ilch 2 final - added a cache to cache server responses - fixed various errors --- .gitignore | 3 +- .../voiceserver/classes/cache.class.php | 324 ++++++++++++++++++ .../modules/voiceserver/classes/license.txt | 10 + .../modules/voiceserver/classes/mumble.php | 38 +- .../modules/voiceserver/classes/ts3.php | 51 ++- .../modules/voiceserver/classes/ventrilo.php | 16 +- .../modules/voiceserver/config/config.php | 37 +- .../voiceserver/controllers/admin/Index.php | 7 +- .../voiceserver/static/css/voiceserver.css | 7 +- .../modules/voiceserver/translations/de.php | 15 +- .../modules/voiceserver/translations/en.php | 29 +- .../voiceserver/views/admin/index/index.php | 4 +- .../modules/voiceserver/views/index/index.php | 9 +- 13 files changed, 469 insertions(+), 81 deletions(-) create mode 100644 application/modules/voiceserver/classes/cache.class.php create mode 100644 application/modules/voiceserver/classes/license.txt diff --git a/.gitignore b/.gitignore index 29f2040..7fdb73b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ application/modules/voiceserver/static/img/ts3/server/ -nbproject/ \ No newline at end of file +nbproject/ +application/modules/voiceserver/cache/ \ No newline at end of file diff --git a/application/modules/voiceserver/classes/cache.class.php b/application/modules/voiceserver/classes/cache.class.php new file mode 100644 index 0000000..c083643 --- /dev/null +++ b/application/modules/voiceserver/classes/cache.class.php @@ -0,0 +1,324 @@ +setCache($config); + } else if (is_array($config)) { + $this->setCache($config['name']); + $this->setCachePath($config['path']); + $this->setExtension($config['extension']); + } + } + } + + /** + * Check whether data accociated with a key + * + * @param string $key + * @return boolean + * @throws Exception + */ + public function isCached($key) { + if (false != $this->_loadCache()) { + $cachedData = $this->_loadCache(); + return isset($cachedData[$key]['data']); + } + } + + /** + * Store data in the cache + * + * @param string $key + * @param mixed $data + * @param integer [optional] $expiration + * @return object + * @throws Exception + */ + public function store($key, $data, $expiration = 0) { + $storeData = array( + 'time' => time(), + 'expire' => $expiration, + 'data' => serialize($data) + ); + $dataArray = $this->_loadCache(); + if (true === is_array($dataArray)) { + $dataArray[$key] = $storeData; + } else { + $dataArray = array($key => $storeData); + } + $cacheData = json_encode($dataArray); + file_put_contents($this->getCacheDir(), $cacheData); + return $this; + } + + /** + * Retrieve cached data by its key + * + * @param string $key + * @param boolean [optional] $timestamp + * @return string + * @throws Exception + */ + public function retrieve($key, $timestamp = false) { + $cachedData = $this->_loadCache(); + (false === $timestamp) ? $type = 'data' : $type = 'time'; + if (!isset($cachedData[$key][$type])) return null; + return unserialize($cachedData[$key][$type]); + } + + /** + * Retrieve all cached data + * + * @param boolean [optional] $meta + * @return array + * @throws Exception + */ + public function retrieveAll($meta = false) { + if ($meta === false) { + $results = array(); + $cachedData = $this->_loadCache(); + if ($cachedData) { + foreach ($cachedData as $k => $v) { + $results[$k] = unserialize($v['data']); + } + } + return $results; + } else { + return $this->_loadCache(); + } + } + + /** + * Erase cached entry by its key + * + * @param string $key + * @return object + * @throws Exception + */ + public function erase($key) { + $cacheData = $this->_loadCache(); + if (true === is_array($cacheData)) { + if (true === isset($cacheData[$key])) { + unset($cacheData[$key]); + $cacheData = json_encode($cacheData); + file_put_contents($this->getCacheDir(), $cacheData); + } else { + throw new Exception("Error: erase() - Key '{$key}' not found."); + } + } + return $this; + } + + /** + * Erase all expired entries + * + * @return integer + * @throws Exception + */ + public function eraseExpired() { + $cacheData = $this->_loadCache(); + if (true === is_array($cacheData)) { + $counter = 0; + foreach ($cacheData as $key => $entry) { + if (true === $this->_checkExpired($entry['time'], $entry['expire'])) { + unset($cacheData[$key]); + $counter++; + } + } + if ($counter > 0) { + $cacheData = json_encode($cacheData); + file_put_contents($this->getCacheDir(), $cacheData); + } + return $counter; + } + } + + /** + * Erase all cached entries + * + * @return object + * @throws Exception + */ + public function eraseAll() { + $cacheDir = $this->getCacheDir(); + if (true === file_exists($cacheDir)) { + $cacheFile = fopen($cacheDir, 'w'); + fclose($cacheFile); + } + return $this; + } + + /** + * Load appointed cache + * + * @return mixed + * @throws Exception + */ + private function _loadCache() { + if (true === file_exists($this->getCacheDir())) { + $file = file_get_contents($this->getCacheDir()); + return json_decode($file, true); + } else { + return false; + } + } + + /** + * Get the cache directory path + * + * @return string + * @throws Exception + */ + public function getCacheDir() { + if (true === $this->_checkCacheDir()) { + $filename = $this->getCache(); + $filename = preg_replace('/[^0-9a-z\.\_\-]/i', '', strtolower($filename)); + return $this->getCachePath() . $this->_getHash($filename) . $this->getExtension(); + } + } + + /** + * Get the filename hash + * + * @param $filename + * @return string + */ + private function _getHash($filename) { + return sha1($filename); + } + + /** + * Check whether a timestamp is still in the duration + * + * @param integer $timestamp + * @param integer $expiration + * @return boolean + */ + private function _checkExpired($timestamp, $expiration) { + $result = false; + if ($expiration !== 0) { + $timeDiff = time() - $timestamp; + ($timeDiff > $expiration) ? $result = true : $result = false; + } + return $result; + } + + /** + * Check if a writable cache directory exists and if not create a new one + * + * @return boolean + * @throws Exception + */ + private function _checkCacheDir() { + if (!is_dir($this->getCachePath()) && !mkdir($this->getCachePath(), 0775, true)) { + throw new Exception('Unable to create cache directory ' . $this->getCachePath()); + } elseif (!is_readable($this->getCachePath()) || !is_writable($this->getCachePath())) { + if (!chmod($this->getCachePath(), 0775)) { + throw new Exception($this->getCachePath() . ' must be readable and writeable'); + } + } + return true; + } + + /** + * Cache path Setter + * + * @param string $path + * @return object + */ + public function setCachePath($path) { + $this->_cachepath = $path; + return $this; + } + + /** + * Cache path Getter + * + * @return string + */ + public function getCachePath() { + return $this->_cachepath; + } + + /** + * Cache name Setter + * + * @param string $name + * @return object + */ + public function setCache($name) { + $this->_cachename = $name; + return $this; + } + + /** + * Cache name Getter + * + * @return string + */ + public function getCache() { + return $this->_cachename; + } + + /** + * Cache file extension Setter + * + * @param string $ext + * @return object + */ + public function setExtension($ext) { + $this->_extension = $ext; + return $this; + } + + /** + * Cache file extension Getter + * + * @return string + */ + public function getExtension() { + return $this->_extension; + } + +} diff --git a/application/modules/voiceserver/classes/license.txt b/application/modules/voiceserver/classes/license.txt new file mode 100644 index 0000000..df6181b --- /dev/null +++ b/application/modules/voiceserver/classes/license.txt @@ -0,0 +1,10 @@ +Copyright (c) 2012, Christian Metz +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of the organisation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/application/modules/voiceserver/classes/mumble.php b/application/modules/voiceserver/classes/mumble.php index ee8a0d3..21bd8e5 100644 --- a/application/modules/voiceserver/classes/mumble.php +++ b/application/modules/voiceserver/classes/mumble.php @@ -18,25 +18,30 @@ class Mumble { public static $useNewAPI; - + private $id; private $_serverDatas; private $_channelDatas; private $_userDatas; private $_userList; private $_channelList; - + private $_host; + private $_port; + private $ice; + public $imagePath; public $hideEmptyChannels; public $hideParentChannels; - - public function Mumble($host, $port) + + + + public function __construct($host, $port) { $this->_host = $host; $this->_port = $port; - - $this->ice = $this->init_ICE(); - + + $this->ice = $this->init_ICE(); + $this->id = 1; $this->_serverDatas = []; $this->_channelDatas = []; @@ -47,7 +52,7 @@ public function Mumble($host, $port) $this->hideEmptyChannels = false; $this->hideParentChannels = false; } - + /** * Create's a ICE object * @return ice object @@ -152,7 +157,7 @@ private function update() $defaultconf = $this->ice->getDefaultConf(); $serverconf = $server->getAllConf(); $this->_serverDatas = array_merge($defaultconf, $serverconf); - + $this->ice->getVersion($major, $minor, $patch, $text); $this->_serverDatas['version'] = $major . '.' . $minor . '.' . $patch; @@ -232,10 +237,11 @@ private function prepareUsers($channelId) } return $users; } - + /** * prepare Channel Data * @param int $channelId + * @param array $cnames * @return array */ private function prepareChannelTree($channelId, $cnames = []) @@ -278,7 +284,7 @@ private function prepareChannelTree($channelId, $cnames = []) * @return array */ public function getChannelTree() - { + { try { $this->update(); @@ -295,23 +301,22 @@ public function getChannelTree() 'icon' => $this->renderImages(["mumble.png"]), ]; $channels = $this->prepareChannelTree(0); - } catch (Exception $e) { - + } return ['root' => $root, 'tree' => $channels]; } - + /** * get the full ServerInformations * @return array + * @throws Exception */ public function getFullServerInfo() { - $tree = $this->getChannelTree(); - $content = [ + $content = [ 'name' => $this->toHTML($this->_serverDatas['registername']), 'uptime' => $this->time_convert($this->ice->getUptime()), 'channelson' => count($this->_channelDatas) - 1, @@ -323,6 +328,7 @@ public function getFullServerInfo() 'root' => $tree['root'], 'tree' => $tree['tree'], ]; + return $content; } } diff --git a/application/modules/voiceserver/classes/ts3.php b/application/modules/voiceserver/classes/ts3.php index de67cc8..4e35109 100755 --- a/application/modules/voiceserver/classes/ts3.php +++ b/application/modules/voiceserver/classes/ts3.php @@ -34,7 +34,7 @@ class TS3 public $hideParentChannels; public $showIcons; - public function TS3($host, $queryPort) + public function __construct($host, $queryPort) { $this->_host = $host; $this->_queryPort = $queryPort; @@ -153,19 +153,21 @@ private function setShowFlag($channelIds) private function renderImages($images) { $content = ""; - foreach ($images as $image) + foreach ($images as $image) { if (file_exists(realpath('') . $this->imagePath . $image)) { $content .= '' . $image . ''; } else { $content .= $this->renderIcon($image); } + } return $content; } - + /** * download and render icon * @param string $id * @return string + * @throws Exception */ private function renderIcon($id) { @@ -174,7 +176,7 @@ private function renderIcon($id) if ($id == "100" || $id == "200" || $id == "300" || $id == "500" || $id == "600") { $image = "group_" . $id . ".png"; $content = '' . $image . ''; - } else { + } else { if (!file_exists(realpath('') . $this->imagePath . 'server/') && !is_dir(realpath('') . $this->imagePath . 'server/') && !is_writable(realpath('') . $this->imagePath . 'server/')) { @@ -219,9 +221,9 @@ private function time_convert($time, $ms = false) if ($day>0) { $time = $day."d ".$hours."h ".$minutes."m ".$seconds."s"; - } elseif ($hours>0) { + } elseif ($hours > 0) { $time = $hours."h ".$minutes."m ".$seconds."s"; - } elseif ($minutes>0) { + } elseif ($minutes > 0) { $time = $minutes."m ".$seconds."s"; } else { $time = $seconds."s"; @@ -249,8 +251,10 @@ private function queryServer() if ($this->_socket) { @socket_set_timeout($this->_socket, $this->timeout); $isTs3 = trim(fgets($this->_socket)) == "TS3"; - if (!$isTs3) + + if (!$isTs3) { throw new Exception("Not a Teamspeak 3 server/bad query port"); + } if ($this->_login !== false) { $this->sendCommand("login client_login_name=" . $this->_login . " client_login_password=" . $this->_password); @@ -263,7 +267,7 @@ private function queryServer() $response .= $this->sendCommand("clientlist -uid -times -away -voice -groups -info -icon"); $response .= $this->sendCommand("servergrouplist"); $response .= $this->sendCommand("channelgrouplist"); - + return $response; } else { throw new Exception("Socket error: $errstr [$errno]"); @@ -272,13 +276,28 @@ private function queryServer() private function disconnect() { - @fputs($this->_socket, "quit\n"); - @fclose($this->_socket); + if ($this->_socket) { + @fputs($this->_socket, "quit\n"); + @fclose($this->_socket); + } } private function update() { - $response = $this->queryServer(); + require_once 'cache.class.php'; + $cacheKey = 'ts3'; + $cache = new Cache(['name' => $cacheKey, 'path' => APPLICATION_PATH.'/modules/voiceserver/cache/', 'extension' => '.cache']); + + // Delete expired cache and try to retrieve it after that. + $cache->eraseExpired(); + $result = $cache->retrieve($cacheKey); + + if (!empty($result)) { + $response = $result; + } else { + $response = $this->queryServer(); + } + $lines = explode("error id=0 msg=ok\n\r", $response); if (count($lines) == 7) { $this->_serverDatas = $this->parseLine($lines[1]); @@ -310,6 +329,9 @@ private function update() foreach ($channelGroups as $cg) if ($cg["iconid"] > 0) $this->setChannelGroupFlag($cg["cgid"], 'group_' . $cg["iconid"] . '.png'); + + // Store content in cache. + $cache->store($cacheKey, $response, 30); } else { throw new Exception("Invalid server response"); } @@ -432,7 +454,7 @@ private function prepareChannelTree($channelId) /** * get the Servertree - * @return array + * @return array|string */ public function getChannelTree() { @@ -452,18 +474,20 @@ public function getChannelTree() 'icon' => $this->renderImages(["ts3.png"]), ]; $channels = $this->prepareChannelTree(0); - + $this->disconnect(); } catch (Exception $e) { $this->disconnect(); return 'offline'; } + return ['root' => $root, 'tree' => $channels]; } /** * get the full ServerInformations * @return array + * @throws Exception */ public function getFullServerInfo() { @@ -487,6 +511,7 @@ public function getFullServerInfo() } else { $content = 'offline'; } + return $content; } } diff --git a/application/modules/voiceserver/classes/ventrilo.php b/application/modules/voiceserver/classes/ventrilo.php index 0470922..7df481c 100755 --- a/application/modules/voiceserver/classes/ventrilo.php +++ b/application/modules/voiceserver/classes/ventrilo.php @@ -26,7 +26,7 @@ class Ventrilo public $hideEmptyChannels; public $hideParentChannels; - public function Ventrilo($host, $port) + public function __construct($host, $port) { $this->_host = $host; $this->_port = $port; @@ -181,7 +181,7 @@ private function queryServer() private function update() { - $response = $this->queryServer(); + $this->queryServer(); $tmpChannels = $this->_channelList; $this->_channelList = []; @@ -241,10 +241,11 @@ private function prepareUsers($channelId) } return $users; } - + /** * prepare Channel Data * @param int $channelId + * @param array $cnames * @return array */ private function prepareChannelTree($channelId, $cnames = []) @@ -291,7 +292,7 @@ private function prepareChannelTree($channelId, $cnames = []) * @return array */ public function getChannelTree() - { + { try { $this->update(); @@ -308,19 +309,19 @@ public function getChannelTree() 'icon' => $this->renderImages(["ventrilo.png"]), ]; $channels = $this->prepareChannelTree(0); - } catch (Exception $e) { } return ['root' => $root, 'tree' => $channels]; } - + /** * get the full ServerInformations * @return array + * @throws Exception */ public function getFullServerInfo() - { + { $tree = $this->getChannelTree(); $content = [ @@ -336,6 +337,7 @@ public function getFullServerInfo() 'root' => $tree['root'], 'tree' => $tree['tree'], ]; + return $content; } } diff --git a/application/modules/voiceserver/config/config.php b/application/modules/voiceserver/config/config.php index 2e4a975..f31c191 100755 --- a/application/modules/voiceserver/config/config.php +++ b/application/modules/voiceserver/config/config.php @@ -8,25 +8,35 @@ class Config extends \Ilch\Config\Install { - public $config = - [ + public $config = [ 'key' => 'voiceserver', + 'version' => '1.0', 'author' => 'Rümmler, Dirk', 'icon_small' => 'voiceserver.png', - 'languages' => - [ - 'de_DE' => - [ + 'link' => 'https://github.com/drthebrain/voiceserver', + 'languages' => [ + 'de_DE' => [ 'name' => 'Voiceserver', 'description' => 'Hier kann der Voiceserver (TS3|Ventrilo|Mumble) verwaltet werden.', - ], - 'en_EN' => - [ + ], + 'en_EN' => [ 'name' => 'Voiceserver', - 'description' => 'Here you can manage Voiceserver (TS3|Ventrilo|Mumble) from your Site.', + 'description' => 'Here you can manage your voiceserver (TS3|Ventrilo|Mumble).', + ], + ], + 'boxes' => [ + 'voiceserver' => [ + 'de_DE' => [ + 'name' => 'Voiceserver' ], + 'en_EN' => [ + 'name' => 'Voiceserver' + ] ] - ]; + ], + 'ilchCore' => '2.0.0', + 'phpVersion' => '5.6' + ]; public function install() { @@ -38,4 +48,9 @@ public function uninstall() { $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'voice_server'"); } + + public function getUpdate($installedVersion) + { + + } } diff --git a/application/modules/voiceserver/controllers/admin/Index.php b/application/modules/voiceserver/controllers/admin/Index.php index ed1a017..1c620ac 100755 --- a/application/modules/voiceserver/controllers/admin/Index.php +++ b/application/modules/voiceserver/controllers/admin/Index.php @@ -32,7 +32,7 @@ public function indexAction() if ($this->getRequest()->isPost()) { $voiceserver = $this->getRequest()->getPost('voiceServer'); - + switch ($voiceserver['Type']) { case 'TS3': if (empty($voiceserver['IP'])) { @@ -60,9 +60,8 @@ public function indexAction() break; default: $message = 'Error'; - break; - } - + } + if (isset($message)) { $this->addMessage($message, 'danger'); } else { diff --git a/application/modules/voiceserver/static/css/voiceserver.css b/application/modules/voiceserver/static/css/voiceserver.css index 21d4503..8fff7a5 100755 --- a/application/modules/voiceserver/static/css/voiceserver.css +++ b/application/modules/voiceserver/static/css/voiceserver.css @@ -1,10 +1,11 @@ .voiceSrvServer { margin-left: 0; } -.voiceSrv, .voiceSrv *, .voiceSrverror { + +.voiceSrv, .voiceSrv * { background-color: #ffffff; - color: #00000; - font-family: Verdana; + color: #000000; + font-family: Verdana, serif; font-size: 12px; } diff --git a/application/modules/voiceserver/translations/de.php b/application/modules/voiceserver/translations/de.php index e04ea43..a13439b 100755 --- a/application/modules/voiceserver/translations/de.php +++ b/application/modules/voiceserver/translations/de.php @@ -4,15 +4,14 @@ * @package ilch */ -return - [ +return [ 'menuVoiceServer' => 'Voiceserver', 'voiceServerType' => 'Server Type', - 'voiceServerIP' => 'Server IP', + 'voiceServerIP' => 'Server IP-Adresse', 'voiceServerPort' => 'Server Port', 'voiceServerQPort' => 'Server Queryport', 'voiceServerCIcons' => 'Benutzerdefinierte Icons', - 'voiceServerHideEmpty' => 'verstecke leere Kanäle', + 'voiceServerHideEmpty' => 'Verstecke leere Kanäle', 'voiceServerRefresh' => 'Refreshzeit', 'missingIP' => 'Bitte IP Adresse eingeben', @@ -20,11 +19,15 @@ 'missingPort' => 'Bitte Port eingeben', 'tableName' => 'Servername', - 'tableOS' => 'Betriebsystem', + 'tableOS' => 'Betriebssystem', 'tableUptime' => 'Laufzeit', 'tableChannels' => 'Kanäle', 'tableUser' => 'Benutzer', 'tableChannel' => 'Kanal', 'tableLoggedin' => 'Eingeloggt seit', 'tableAfK' => 'AFK seit', - ]; + + 'server' => 'Server', + 'version' => 'Version', + 'welcomeMessage' => 'Willkommensnachricht', +]; diff --git a/application/modules/voiceserver/translations/en.php b/application/modules/voiceserver/translations/en.php index 14b6098..b5e258a 100755 --- a/application/modules/voiceserver/translations/en.php +++ b/application/modules/voiceserver/translations/en.php @@ -4,28 +4,31 @@ * @package ilch */ -return - [ +return [ 'menuVoiceServer' => 'Voiceserver', - 'voiceServerType' => 'Server Type', - 'voiceServerIP' => 'Server IP', - 'voiceServerPort' => 'Server Port', - 'voiceServerQPort' => 'Server Queryport', - 'voiceServerCIcons' => 'Custom Icons', - 'voiceServerHideEmpty' => 'Hidden empty channels', + 'voiceServerType' => 'Server type', + 'voiceServerIP' => 'Server IP address', + 'voiceServerPort' => 'Server port', + 'voiceServerQPort' => 'Server queryport', + 'voiceServerCIcons' => 'Custom icons', + 'voiceServerHideEmpty' => 'Hide empty channels', 'voiceServerRefresh' => 'Refreshtime', 'missingIP' => 'Please enter IP address', - 'missingQPort' => 'Please enter Queryport', - 'missingPort' => 'Please enter Port', + 'missingQPort' => 'Please enter queryport', + 'missingPort' => 'Please enter port', 'tableName' => 'Servername', - 'tableOS' => 'System', + 'tableOS' => 'Operating system', 'tableUptime' => 'Uptime', 'tableChannels' => 'Channels', 'tableUser' => 'User', 'tableChannel' => 'Channel', - 'tableLoggedin' => 'Logged since', + 'tableLoggedin' => 'Logged in since', 'tableAfK' => 'AFK since', - ]; + + 'server' => 'Server', + 'version' => 'Version', + 'welcomeMessage' => 'Welcome message', +]; diff --git a/application/modules/voiceserver/views/admin/index/index.php b/application/modules/voiceserver/views/admin/index/index.php index 3cdab0e..6e30f25 100755 --- a/application/modules/voiceserver/views/admin/index/index.php +++ b/application/modules/voiceserver/views/admin/index/index.php @@ -2,7 +2,7 @@
getTokenField() ?> - get('voiceServer'); ?> + get('voiceServer'); ?>
- + getSaveBar() ?>
diff --git a/application/modules/voiceserver/views/index/index.php b/application/modules/voiceserver/views/index/index.php index bed4241..e76df9d 100755 --- a/application/modules/voiceserver/views/index/index.php +++ b/application/modules/voiceserver/views/index/index.php @@ -63,7 +63,6 @@ $datas = $ventriloviewer->getFullServerInfo(); break; default: - break; } ?> @@ -141,19 +140,19 @@ - + - + - + @@ -164,7 +163,7 @@ - + From f50f467863738efed50833c2a1366727faa4a41f Mon Sep 17 00:00:00 2001 From: blackcoder87 Date: Fri, 20 Jul 2018 09:35:54 +0200 Subject: [PATCH 2/6] Fix some errors Fix invalid urls and "Only variables should be passed by reference" --- application/modules/voiceserver/boxes/views/voiceserver.php | 4 ++-- application/modules/voiceserver/classes/ts3.php | 6 +++--- application/modules/voiceserver/views/ajax/refreshVoice.php | 4 ++-- application/modules/voiceserver/views/index/index.php | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/application/modules/voiceserver/boxes/views/voiceserver.php b/application/modules/voiceserver/boxes/views/voiceserver.php index 354c4b0..68da6b1 100755 --- a/application/modules/voiceserver/boxes/views/voiceserver.php +++ b/application/modules/voiceserver/boxes/views/voiceserver.php @@ -1,7 +1,7 @@ get('voiceServer'); ?> - + $item): ?>
  • class="last" > @@ -12,7 +12,7 @@
      - + $user): ?>
    • class="last" > diff --git a/application/modules/voiceserver/classes/ts3.php b/application/modules/voiceserver/classes/ts3.php index 4e35109..398fc9a 100755 --- a/application/modules/voiceserver/classes/ts3.php +++ b/application/modules/voiceserver/classes/ts3.php @@ -155,7 +155,7 @@ private function renderImages($images) $content = ""; foreach ($images as $image) { if (file_exists(realpath('') . $this->imagePath . $image)) { - $content .= '' . $image . ''; + $content .= '' . $image . ''; } else { $content .= $this->renderIcon($image); } @@ -175,7 +175,7 @@ private function renderIcon($id) if ($id < 0) $id = $id+4294967296; if ($id == "100" || $id == "200" || $id == "300" || $id == "500" || $id == "600") { $image = "group_" . $id . ".png"; - $content = '' . $image . ''; + $content = '' . $image . ''; } else { if (!file_exists(realpath('') . $this->imagePath . 'server/') && !is_dir(realpath('') . $this->imagePath . 'server/') @@ -199,7 +199,7 @@ private function renderIcon($id) } } if (file_exists($pfad) && $this->showIcons) { - $content .= '' . $image . ''; + $content .= '' . $image . ''; } } return $content; diff --git a/application/modules/voiceserver/views/ajax/refreshVoice.php b/application/modules/voiceserver/views/ajax/refreshVoice.php index 58fc458..1431888 100755 --- a/application/modules/voiceserver/views/ajax/refreshVoice.php +++ b/application/modules/voiceserver/views/ajax/refreshVoice.php @@ -1,7 +1,7 @@ get('voiceServer'); ?> - + $item): ?>
    • class="last" > @@ -12,7 +12,7 @@
        - + $user): ?>
      • class="last" > diff --git a/application/modules/voiceserver/views/index/index.php b/application/modules/voiceserver/views/index/index.php index e76df9d..2f05e42 100755 --- a/application/modules/voiceserver/views/index/index.php +++ b/application/modules/voiceserver/views/index/index.php @@ -3,7 +3,7 @@ get('voiceServer'); ?> - + $item): ?>
      • class="last" > @@ -14,7 +14,7 @@
          - + $user): ?>
        • class="last" > From 84432c0d48d77bd3b45be2ec29fd0ae093acd284 Mon Sep 17 00:00:00 2001 From: blackcoder87 Date: Fri, 20 Jul 2018 14:12:36 +0200 Subject: [PATCH 3/6] Fix error introduced by using the cache --- .../modules/voiceserver/boxes/views/voiceserver.php | 2 +- application/modules/voiceserver/classes/ts3.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/application/modules/voiceserver/boxes/views/voiceserver.php b/application/modules/voiceserver/boxes/views/voiceserver.php index 68da6b1..eca6549 100755 --- a/application/modules/voiceserver/boxes/views/voiceserver.php +++ b/application/modules/voiceserver/boxes/views/voiceserver.php @@ -87,7 +87,7 @@ refreshVoice(); function refreshVoice() { $('#voiceserver').load('getUrl(['module' => 'voiceserver', 'controller' => 'ajax','action' => 'refreshVoice']); ?>'); - }; + } }, ); }); diff --git a/application/modules/voiceserver/classes/ts3.php b/application/modules/voiceserver/classes/ts3.php index 398fc9a..5ace083 100755 --- a/application/modules/voiceserver/classes/ts3.php +++ b/application/modules/voiceserver/classes/ts3.php @@ -183,7 +183,7 @@ private function renderIcon($id) @mkdir(realpath('') . $this->imagePath . 'server/', 0755, true); } $image = $id . '.png'; - $pfad = realpath('') . $this->imagePath . 'server/' . $image; + $pfad = realpath('') . $this->imagePath . 'server/' . $image; if (!file_exists($pfad) && $this->showIcons) { $dl = $this->parseLine($this->sendCommand("ftinitdownload clientftfid=".rand(1,99)." name=\/icon_".$id." cid=0 cpw= seekpos=0")); $ft = @fsockopen($this->_host, $dl[0]['port'], $errnum, $errstr, 2); @@ -292,8 +292,16 @@ private function update() $cache->eraseExpired(); $result = $cache->retrieve($cacheKey); + $costumIconsPath = realpath('') . $this->imagePath . 'server'; if (!empty($result)) { - $response = $result; + // Call queryServer() if showIcons is enabled, but the folder missing. + // This is needed to prevent an error, which occured when renderIcon() called sendCommand(), while + // the socket is null. + if ($this->showIcons && !file_exists($costumIconsPath)) { + $response = $this->queryServer(); + } else { + $response = $result; + } } else { $response = $this->queryServer(); } From c64bfa5a8ebfc26d71c5c90bc7e8dd01b3f4ddf1 Mon Sep 17 00:00:00 2001 From: blackcoder87 Date: Sat, 21 Jul 2018 07:33:53 +0200 Subject: [PATCH 4/6] alternative fix for previous issue --- application/modules/voiceserver/classes/ts3.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/application/modules/voiceserver/classes/ts3.php b/application/modules/voiceserver/classes/ts3.php index 5ace083..ea953e5 100755 --- a/application/modules/voiceserver/classes/ts3.php +++ b/application/modules/voiceserver/classes/ts3.php @@ -185,6 +185,12 @@ private function renderIcon($id) $image = $id . '.png'; $pfad = realpath('') . $this->imagePath . 'server/' . $image; if (!file_exists($pfad) && $this->showIcons) { + // This is needed to prevent an error, which occured when renderIcon() called sendCommand(), while + // the socket is null. + if (!$this->_socket) { + return $content; + } + $dl = $this->parseLine($this->sendCommand("ftinitdownload clientftfid=".rand(1,99)." name=\/icon_".$id." cid=0 cpw= seekpos=0")); $ft = @fsockopen($this->_host, $dl[0]['port'], $errnum, $errstr, 2); if ($ft) { @@ -292,16 +298,8 @@ private function update() $cache->eraseExpired(); $result = $cache->retrieve($cacheKey); - $costumIconsPath = realpath('') . $this->imagePath . 'server'; if (!empty($result)) { - // Call queryServer() if showIcons is enabled, but the folder missing. - // This is needed to prevent an error, which occured when renderIcon() called sendCommand(), while - // the socket is null. - if ($this->showIcons && !file_exists($costumIconsPath)) { - $response = $this->queryServer(); - } else { - $response = $result; - } + $response = $result; } else { $response = $this->queryServer(); } From 52335042f939be752e7ac185fc32c1d9d367fa0d Mon Sep 17 00:00:00 2001 From: Dennis Reilard Date: Fri, 9 Apr 2021 21:35:23 +0200 Subject: [PATCH 5/6] Update config.php --- application/modules/voiceserver/config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/modules/voiceserver/config/config.php b/application/modules/voiceserver/config/config.php index f31c191..1ff19a5 100755 --- a/application/modules/voiceserver/config/config.php +++ b/application/modules/voiceserver/config/config.php @@ -10,7 +10,7 @@ class Config extends \Ilch\Config\Install { public $config = [ 'key' => 'voiceserver', - 'version' => '1.0', + 'version' => '1.0.0', 'author' => 'Rümmler, Dirk', 'icon_small' => 'voiceserver.png', 'link' => 'https://github.com/drthebrain/voiceserver', From 9246c1847c0cfc0013c16cdc4b623f2121eb34ff Mon Sep 17 00:00:00 2001 From: Dennis Reilard Date: Mon, 12 Apr 2021 07:07:16 +0200 Subject: [PATCH 6/6] Fix Undefined offset --- .../voiceserver/boxes/views/voiceserver.php | 58 ++++++++++--------- .../voiceserver/views/ajax/refreshVoice.php | 58 ++++++++++--------- .../modules/voiceserver/views/index/index.php | 58 ++++++++++--------- 3 files changed, 90 insertions(+), 84 deletions(-) diff --git a/application/modules/voiceserver/boxes/views/voiceserver.php b/application/modules/voiceserver/boxes/views/voiceserver.php index eca6549..cbcff40 100755 --- a/application/modules/voiceserver/boxes/views/voiceserver.php +++ b/application/modules/voiceserver/boxes/views/voiceserver.php @@ -1,35 +1,37 @@ get('voiceServer'); ?> - - $item): ?> -
        • class="last" > - - - -
          + 0): ?> + + $item): ?> +
        • class="last" > + + + +
          + +
          + +
            + + $user): ?> +
          • class="last" > + + +
            + +
          • + +
          + + +
            + +
          - - -
            - - $user): ?> -
          • class="last" > - - -
            - -
          • - -
          - - -
            - -
          - -
        • - + + + get('voiceServer'); ?> - - $item): ?> -
        • class="last" > - - - -
          + 0): ?> + + $item): ?> +
        • class="last" > + + + +
          + +
          + +
            + + $user): ?> +
          • class="last" > + + +
            + +
          • + +
          + + +
            + +
          - - -
            - - $user): ?> -
          • class="last" > - - -
            - -
          • - -
          - - -
            - -
          - -
        • - + + + get('voiceServer'); ?> - - $item): ?> -
        • class="last" > - - - -
          + 0): ?> + + $item): ?> +
        • class="last" > + + + +
          + +
          + +
            + + $user): ?> +
          • class="last" > + + +
            + +
          • + +
          + + +
            + +
          - - -
            - - $user): ?> -
          • class="last" > - - -
            - -
          • - -
          - - -
            - -
          - -
        • - + + +
  • Server:getTrans('server') ?>:


    Server IP:getTrans('voiceServerIP') ?>:


    Version:getTrans('version') ?>:


    Welcome Message:getTrans('welcomeMessage') ?>:
    getHtmlFromBBCode($datas['welcome']) ?>