diff --git a/composer.json b/composer.json index 43c3b97..048baa6 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,8 @@ "jeremykendall/slim-auth": "dev-slim-3.x", "phpmailer/phpmailer": "^5.2", "illuminate/pagination": "^5.5", - "par0noid/ts3admin": "^1.0" + "par0noid/ts3admin": "^1.0", + "planetteamspeak/ts3-php-framework": "^1.1" }, "config": { "bin-dir": "bin/" diff --git a/public/index.php b/public/index.php index 29bfb8f..e677f92 100644 --- a/public/index.php +++ b/public/index.php @@ -60,8 +60,10 @@ $container['logger'] = function () { }; // teamspeak -$container['ts'] = function () { - return new TSInstance(); +$ts = new TSInstance(); +$_SESSION['_TS3'] = serialize($ts); +$container['ts'] = function () use ($ts) { + return $ts; }; // auth @@ -138,7 +140,7 @@ $container['view'] = function ($container) use ($app) { $view['flash'] = $container['flash']; // currentUser, currentRole, ACL.isPermitted - $view['currentUser'] = ($container['authenticator']->hasIdentity() ? $container['authenticator']->getIdentity() : NULL); // currentUser in Twig + $view['currentUser'] = ($container['authenticator']->hasIdentity() ? $container['authenticator']->getIdentity() : NULL); // currentUser in twig $view['currentRole'] = (!empty($user) ? $role = $user->role : $role = ACL::ACL_DEFAULT_ROLE_GUEST); $view->getEnvironment()->addFunction(new Twig_SimpleFunction('isPermitted', function ($currentRole, $targetRole) use ($container) { diff --git a/public/theme/material/css/custom.css b/public/theme/material/css/custom.css index 2c52897..467347d 100644 --- a/public/theme/material/css/custom.css +++ b/public/theme/material/css/custom.css @@ -1,6 +1,5 @@ /* START: for rendering within block you should keep the following */ img { - display: block; max-width: 100%; height: auto; } diff --git a/src/Control/Actions/OnlineAction.php b/src/Control/Actions/OnlineAction.php index ba40220..d2eb886 100644 --- a/src/Control/Actions/OnlineAction.php +++ b/src/Control/Actions/OnlineAction.php @@ -16,10 +16,22 @@ final class OnlineAction extends AbstractAction $dataResult = $this->ts->getInstance()->clientList(); $this->ts->checkCommandResult($dataResult); + $instance = TeamSpeak3::factory(sprintf("serverquery://%s:%s@%s:%s/?server_id=%s", + $this->auth->getIdentity()['user'], + $this->auth->getIdentity()['password'], + $this->ts->getHost(), + $this->ts->getQueryPort(), + $sid) + ); + + $treeView = new TeamSpeak3_Viewer_Html("/images/viewer/", "/images/flags/", "data:image"); + $tree = $instance->getViewer($treeView); + // render GET $this->view->render($response, 'online.twig', [ 'title' => $this->translator->trans('online.title'), 'data' => $this->ts->getInstance()->getElement('data', $dataResult), + 'tree' => $tree, 'sid' => $sid ]); } diff --git a/src/Util/MailHelper.php b/src/Util/MailHelper.php deleted file mode 100644 index 1becb86..0000000 --- a/src/Util/MailHelper.php +++ /dev/null @@ -1,35 +0,0 @@ -CharSet = 'UTF-8'; - $mailer->ContentType = 'text/plain'; - $mailer->isSMTP(); - $mailer->SMTPSecure = getenv('mail_secure'); - $mailer->SMTPAuth = getenv('mail_auth'); - $mailer->Host = getenv('mail_host'); - $mailer->Port = getenv('mail_port'); - $mailer->Username = getenv('mail_username'); - $mailer->Password = getenv('mail_password'); - $mailer->From = getenv('mail_from'); - $mailer->FromName = getenv('mail_from_name'); - $mailer->addAddress($receiverMail); - $mailer->Subject = $subject; - $mailer->Body = $body; - return $mailer->send(); - } else { - return false; - } - } -} \ No newline at end of file diff --git a/src/Util/Pagination.php b/src/Util/Pagination.php deleted file mode 100644 index 6bc6299..0000000 --- a/src/Util/Pagination.php +++ /dev/null @@ -1,82 +0,0 @@ -request = $request; - $this->view = $view; - $this->pageName = $pageName; - $this->pageNameAfter = $pageNameAfter; - } - - /** - * Get current page from pageName parameter - * @return int|mixed - */ - public function resolveCurrentPage() - { - $page = $this->request->getParam($this->pageName, 1); - - if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) { - return $page; - } - - return 1; - } - - /** - * Fetches required information for rendering, used Eloquent Paginator. The array keys should match your view - * @param \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator - * @return array - */ - public function fetchPaginationDetails(\Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator) - { - return [ - 'currentPage' => $paginator->currentPage(), - 'lastPage' => ceil($paginator->total()/$paginator->perPage()), - 'paginationPath' => $this->request->getUri()->getPath() . '?' . $this->pageName . '=', - 'pageName' => $this->pageName, - 'pageNameAfter' => $this->pageNameAfter - ]; - } - - /** - * @return string - */ - public function getPageName() - { - return $this->pageName; - } - - /** - * Generate links with the help of the given $view - * @param \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator - * @param string $template - * @return string (html) - */ - public function links(\Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator, $template = self::RENDER_TEMPLATE) - { - return $this->view->fetch($template, $this->fetchPaginationDetails($paginator)); - } -} \ No newline at end of file diff --git a/src/View/material/online.twig b/src/View/material/online.twig index 51877e8..71bead1 100644 --- a/src/View/material/online.twig +++ b/src/View/material/online.twig @@ -2,15 +2,24 @@ {% block content %}