Change the way commands to the ts3 server are issued
This commit is contained in:
parent
ca5e677b2d
commit
a4a0202859
46 changed files with 112 additions and 140 deletions
|
@ -10,10 +10,9 @@
|
||||||
"symfony/yaml": "*",
|
"symfony/yaml": "*",
|
||||||
"vlucas/phpdotenv": "^2.3",
|
"vlucas/phpdotenv": "^2.3",
|
||||||
"jeremykendall/slim-auth": "dev-slim-3.x",
|
"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"
|
"planetteamspeak/ts3-php-framework": "^1.1",
|
||||||
|
"nesbot/carbon": "^1.25"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"bin-dir": "bin/"
|
"bin-dir": "bin/"
|
||||||
|
|
|
@ -15,5 +15,5 @@ teamspeak_default_query_port=10011
|
||||||
teamspeak_default_user="serveradmin"
|
teamspeak_default_user="serveradmin"
|
||||||
|
|
||||||
# log
|
# log
|
||||||
log_name="app" # values: all strings
|
log_name="ts3web" # values: all strings
|
||||||
log_level="INFO" # values: DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY
|
log_level="INFO" # values: DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY
|
|
@ -52,16 +52,22 @@ $container['translator'] = function () use ($translator) {
|
||||||
|
|
||||||
// date
|
// date
|
||||||
Carbon::setLocale(getenv('site_language'));
|
Carbon::setLocale(getenv('site_language'));
|
||||||
|
Carbon::setToStringFormat(getenv('site_date_format'));
|
||||||
|
|
||||||
// logger
|
// logger
|
||||||
$container['logger'] = function () {
|
try {
|
||||||
$logger = BootstrapHelper::bootLogger();
|
$logger = BootstrapHelper::bootLogger();
|
||||||
return $logger;
|
|
||||||
};
|
$container['logger'] = function () use ($logger) {
|
||||||
|
return $logger;
|
||||||
|
};
|
||||||
|
} catch (Exception $e) {
|
||||||
|
die('Error bootstrapping logger: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
// teamspeak
|
// teamspeak
|
||||||
$container['ts'] = function () {
|
$container['ts'] = function () use ($logger) {
|
||||||
return new TSInstance();
|
return new TSInstance($logger);
|
||||||
};
|
};
|
||||||
|
|
||||||
// auth
|
// auth
|
||||||
|
@ -125,9 +131,6 @@ $container['view'] = function ($container) use ($app) {
|
||||||
$view->addExtension(new \Symfony\Bridge\Twig\Extension\TranslationExtension($container['translator']));
|
$view->addExtension(new \Symfony\Bridge\Twig\Extension\TranslationExtension($container['translator']));
|
||||||
$view->getEnvironment()->getExtension('Twig_Extension_Core')->setDateFormat(getenv('site_date_format'));
|
$view->getEnvironment()->getExtension('Twig_Extension_Core')->setDateFormat(getenv('site_date_format'));
|
||||||
|
|
||||||
// date
|
|
||||||
Carbon::setToStringFormat(getenv('site_date_format'));
|
|
||||||
|
|
||||||
// env
|
// env
|
||||||
$view->getEnvironment()->addFunction(new Twig_SimpleFunction('getenv', function($value) {
|
$view->getEnvironment()->addFunction(new Twig_SimpleFunction('getenv', function($value) {
|
||||||
$res = getenv($value);
|
$res = getenv($value);
|
||||||
|
|
|
@ -12,10 +12,8 @@ final class BanDeleteAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$banDeleteResult = $this->ts->getInstance()->banDelete($banId);
|
$banDeleteResult = $this->ts->getInstance()->banDelete($banId);
|
||||||
$this->ts->checkCommandResult($banDeleteResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('done'));
|
$this->flash->addMessage('success', $this->translator->trans('done'));
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,8 @@ final class BansAction extends AbstractAction
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
|
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$banListResult = $this->ts->getInstance()->banList();
|
$banListResult = $this->ts->getInstance()->banList();
|
||||||
$this->ts->checkCommandResult($banListResult);
|
|
||||||
|
|
||||||
// render GET
|
// render GET
|
||||||
$this->view->render($response, 'bans.twig', [
|
$this->view->render($response, 'bans.twig', [
|
||||||
|
|
|
@ -12,10 +12,8 @@ final class ChannelDeleteAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$channelDeleteResult = $this->ts->getInstance()->channelDelete($cid);
|
$channelDeleteResult = $this->ts->getInstance()->channelDelete($cid);
|
||||||
$this->ts->checkCommandResult($channelDeleteResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('done'));
|
$this->flash->addMessage('success', $this->translator->trans('done'));
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,8 @@ final class ChannelGroupDeleteAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$groupDeleteResult = $this->ts->getInstance()->channelGroupDelete($cgid);
|
$groupDeleteResult = $this->ts->getInstance()->channelGroupDelete($cgid);
|
||||||
$this->ts->checkCommandResult($groupDeleteResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('done'));
|
$this->flash->addMessage('success', $this->translator->trans('done'));
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,10 @@ final class ChannelGroupInfoAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$clientsResult = $this->ts->getInstance()->channelGroupClientList(null, null, $cgid);
|
$clientsResult = $this->ts->getInstance()->channelGroupClientList(null, null, $cgid);
|
||||||
$this->ts->checkCommandResult($clientsResult);
|
|
||||||
|
|
||||||
$permissionsResult = $this->ts->getInstance()->channelGroupPermList($cgid, true);
|
$permissionsResult = $this->ts->getInstance()->channelGroupPermList($cgid, true);
|
||||||
$this->ts->checkCommandResult($permissionsResult);
|
|
||||||
|
|
||||||
// render GET
|
// render GET
|
||||||
$this->view->render($response, 'channelgroup_info.twig', [
|
$this->view->render($response, 'channelgroup_info.twig', [
|
||||||
|
|
|
@ -12,13 +12,10 @@ final class ChannelInfoAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$channelResult = $this->ts->getInstance()->channelInfo($cid);
|
$channelResult = $this->ts->getInstance()->channelInfo($cid);
|
||||||
$this->ts->checkCommandResult($channelResult);
|
|
||||||
|
|
||||||
$clientsResult = $this->ts->getInstance()->channelClientList($cid);
|
$clientsResult = $this->ts->getInstance()->channelClientList($cid);
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$files = [];
|
$files = [];
|
||||||
$files['data'] = $this->getAllFilesIn($sid, $cid, '/');
|
$files['data'] = $this->getAllFilesIn($sid, $cid, '/');
|
||||||
|
@ -38,10 +35,8 @@ final class ChannelInfoAction extends AbstractAction
|
||||||
{
|
{
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$fileResult = $this->ts->getInstance()->ftGetFileList($cid, '', $path);
|
$fileResult = $this->ts->getInstance()->ftGetFileList($cid, '', $path);
|
||||||
$this->ts->checkCommandResult($fileResult);
|
|
||||||
|
|
||||||
$foundFiles = $fileResult['data'];
|
$foundFiles = $fileResult['data'];
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,8 @@ final class ChannelSendAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$dataResult = $this->ts->getInstance()->sendMessage(2, $cid, $body['message']);
|
$dataResult = $this->ts->getInstance()->sendMessage(2, $cid, $body['message']);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('done'));
|
$this->flash->addMessage('success', $this->translator->trans('done'));
|
||||||
return $response->withRedirect('/channels/' . $sid . '/' . $cid);
|
return $response->withRedirect('/channels/' . $sid . '/' . $cid);
|
||||||
|
|
|
@ -11,10 +11,8 @@ final class ChannelsAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$dataResult = $this->ts->getInstance()->channelList();
|
$dataResult = $this->ts->getInstance()->channelList();
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
// render GET
|
// render GET
|
||||||
$this->view->render($response, 'channels.twig', [
|
$this->view->render($response, 'channels.twig', [
|
||||||
|
|
|
@ -14,17 +14,14 @@ final class ClientBanAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$getResult = $this->ts->getInstance()->clientGetNameFromDbid($cldbid);
|
$getResult = $this->ts->getInstance()->clientGetNameFromDbid($cldbid);
|
||||||
$this->ts->checkCommandResult($getResult);
|
|
||||||
|
|
||||||
$dataResult = $this->ts->getInstance()->banAddByUid(
|
$dataResult = $this->ts->getInstance()->banAddByUid(
|
||||||
$this->ts->getInstance()->getElement('data', $getResult)['cluid'],
|
$this->ts->getInstance()->getElement('data', $getResult)['cluid'],
|
||||||
(!empty($body['time']) ? $body['time'] : 0),
|
(!empty($body['time']) ? $body['time'] : 0),
|
||||||
$body['reason']
|
$body['reason']
|
||||||
);
|
);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('client_info.banned.success', ['%cldbid%' => $cldbid]));
|
$this->flash->addMessage('success', $this->translator->trans('client_info.banned.success', ['%cldbid%' => $cldbid]));
|
||||||
return $response->withRedirect('/clients/' . $sid . '/' . $cldbid);
|
return $response->withRedirect('/clients/' . $sid . '/' . $cldbid);
|
||||||
|
|
|
@ -12,10 +12,8 @@ final class ClientDeleteAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$clientDeleteResult = $this->ts->getInstance()->clientDbDelete($cldbid);
|
$clientDeleteResult = $this->ts->getInstance()->clientDbDelete($cldbid);
|
||||||
$this->ts->checkCommandResult($clientDeleteResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('done'));
|
$this->flash->addMessage('success', $this->translator->trans('done'));
|
||||||
|
|
||||||
|
|
|
@ -12,19 +12,14 @@ final class ClientInfoAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$detailsResult = $this->ts->getInstance()->clientDbInfo($cldbid);
|
$detailsResult = $this->ts->getInstance()->clientDbInfo($cldbid);
|
||||||
$this->ts->checkCommandResult($detailsResult);
|
|
||||||
|
|
||||||
$serverGroupsResult = $this->ts->getInstance()->serverGroupsByClientID($cldbid);
|
$serverGroupsResult = $this->ts->getInstance()->serverGroupsByClientID($cldbid);
|
||||||
$this->ts->checkCommandResult($serverGroupsResult);
|
|
||||||
|
|
||||||
$channelGroupsResult = $this->ts->getInstance()->channelGroupClientList(null, $cldbid, null);
|
$channelGroupsResult = $this->ts->getInstance()->channelGroupClientList(null, $cldbid, null);
|
||||||
$this->ts->checkCommandResult($channelGroupsResult);
|
|
||||||
|
|
||||||
$permissionsResult = $this->ts->getInstance()->clientPermList($cldbid, true);
|
$permissionsResult = $this->ts->getInstance()->clientPermList($cldbid, true);
|
||||||
$this->ts->checkCommandResult($permissionsResult);
|
|
||||||
|
|
||||||
// render GET
|
// render GET
|
||||||
$this->view->render($response, 'client_info.twig', [
|
$this->view->render($response, 'client_info.twig', [
|
||||||
|
|
|
@ -14,17 +14,14 @@ final class ClientSendAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$getResult = $this->ts->getInstance()->clientGetNameFromDbid($cldbid);
|
$getResult = $this->ts->getInstance()->clientGetNameFromDbid($cldbid);
|
||||||
$this->ts->checkCommandResult($getResult);
|
|
||||||
|
|
||||||
$dataResult = $this->ts->getInstance()->messageAdd(
|
$dataResult = $this->ts->getInstance()->messageAdd(
|
||||||
$this->ts->getInstance()->getElement('data', $getResult)['cluid'],
|
$this->ts->getInstance()->getElement('data', $getResult)['cluid'],
|
||||||
$body['subject'],
|
$body['subject'],
|
||||||
$body['message']
|
$body['message']
|
||||||
);
|
);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('client_info.sent.success', ['%cldbid%' => $cldbid]));
|
$this->flash->addMessage('success', $this->translator->trans('client_info.sent.success', ['%cldbid%' => $cldbid]));
|
||||||
return $response->withRedirect('/clients/' . $sid . '/' . $cldbid);
|
return $response->withRedirect('/clients/' . $sid . '/' . $cldbid);
|
||||||
|
|
|
@ -11,10 +11,8 @@ final class ClientsAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$dataResult = $this->ts->getInstance()->clientDbList();
|
$dataResult = $this->ts->getInstance()->clientDbList();
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
// render GET
|
// render GET
|
||||||
$this->view->render($response, 'clients.twig', [
|
$this->view->render($response, 'clients.twig', [
|
||||||
|
|
|
@ -12,13 +12,11 @@ final class ComplainDeleteAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
// search fcldbid
|
// search fcldbid
|
||||||
$fcldbid = null;
|
$fcldbid = null;
|
||||||
|
|
||||||
$searchResult = $this->ts->getInstance()->complainList();
|
$searchResult = $this->ts->getInstance()->complainList();
|
||||||
$this->ts->checkCommandResult($searchResult);
|
|
||||||
|
|
||||||
foreach ($this->ts->getInstance()->getElement('data', $searchResult) as $complain) {
|
foreach ($this->ts->getInstance()->getElement('data', $searchResult) as $complain) {
|
||||||
if ($complain['tcldbid'] === $tcldbid) {
|
if ($complain['tcldbid'] === $tcldbid) {
|
||||||
|
@ -29,7 +27,6 @@ final class ComplainDeleteAction extends AbstractAction
|
||||||
|
|
||||||
if (!empty($fcldbid)) {
|
if (!empty($fcldbid)) {
|
||||||
$complainDeleteResult = $this->ts->getInstance()->complainDelete($tcldbid, $fcldbid);
|
$complainDeleteResult = $this->ts->getInstance()->complainDelete($tcldbid, $fcldbid);
|
||||||
$this->ts->checkCommandResult($complainDeleteResult);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('done'));
|
$this->flash->addMessage('success', $this->translator->trans('done'));
|
||||||
|
|
|
@ -11,10 +11,8 @@ final class ComplainsAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$dataResult = $this->ts->getInstance()->complainList();
|
$dataResult = $this->ts->getInstance()->complainList();
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
// render GET
|
// render GET
|
||||||
$this->view->render($response, 'complains.twig', [
|
$this->view->render($response, 'complains.twig', [
|
||||||
|
|
|
@ -15,10 +15,8 @@ final class GroupAddAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$groupAddResult = $this->ts->getInstance()->serverGroupAddClient($sgid, $cldbid);
|
$groupAddResult = $this->ts->getInstance()->serverGroupAddClient($sgid, $cldbid);
|
||||||
$this->ts->checkCommandResult($groupAddResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('added'));
|
$this->flash->addMessage('success', $this->translator->trans('added'));
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,8 @@ final class GroupDeleteAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$groupDeleteResult = $this->ts->getInstance()->serverGroupDelete($sgid);
|
$groupDeleteResult = $this->ts->getInstance()->serverGroupDelete($sgid);
|
||||||
$this->ts->checkCommandResult($groupDeleteResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('done'));
|
$this->flash->addMessage('success', $this->translator->trans('done'));
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,10 @@ final class GroupInfoAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$clientsResult = $this->ts->getInstance()->serverGroupClientList($sgid, true);
|
$clientsResult = $this->ts->getInstance()->serverGroupClientList($sgid, true);
|
||||||
$this->ts->checkCommandResult($clientsResult);
|
|
||||||
|
|
||||||
$permissionsResult = $this->ts->getInstance()->serverGroupPermList($sgid, true);
|
$permissionsResult = $this->ts->getInstance()->serverGroupPermList($sgid, true);
|
||||||
$this->ts->checkCommandResult($permissionsResult);
|
|
||||||
|
|
||||||
// render GET
|
// render GET
|
||||||
$this->view->render($response, 'group_info.twig', [
|
$this->view->render($response, 'group_info.twig', [
|
||||||
|
|
|
@ -13,10 +13,8 @@ final class GroupRemoveAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$groupRemoveResult = $this->ts->getInstance()->serverGroupDeleteClient($sgid, $cldbid);
|
$groupRemoveResult = $this->ts->getInstance()->serverGroupDeleteClient($sgid, $cldbid);
|
||||||
$this->ts->checkCommandResult($groupRemoveResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('removed'));
|
$this->flash->addMessage('success', $this->translator->trans('removed'));
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,10 @@ final class GroupsAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$serverGroupsResult = $this->ts->getInstance()->serverGroupList();
|
$serverGroupsResult = $this->ts->getInstance()->serverGroupList();
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$channelGroupsResult = $this->ts->getInstance()->channelGroupList();
|
$channelGroupsResult = $this->ts->getInstance()->channelGroupList();
|
||||||
$this->ts->checkCommandResult($channelGroupsResult);
|
|
||||||
|
|
||||||
// render GET
|
// render GET
|
||||||
$this->view->render($response, 'groups.twig', [
|
$this->view->render($response, 'groups.twig', [
|
||||||
|
|
|
@ -9,9 +9,7 @@ final class InstanceAction extends AbstractAction
|
||||||
{
|
{
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$hostResult = $this->ts->getInstance()->hostInfo();
|
$hostResult = $this->ts->getInstance()->hostInfo();
|
||||||
$this->ts->checkCommandResult($hostResult);
|
|
||||||
$instanceResult = $this->ts->getInstance()->instanceInfo();
|
$instanceResult = $this->ts->getInstance()->instanceInfo();
|
||||||
$this->ts->checkCommandResult($instanceResult);
|
|
||||||
|
|
||||||
$data['data'] = array_merge($hostResult['data'], $instanceResult['data']);
|
$data['data'] = array_merge($hostResult['data'], $instanceResult['data']);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ final class InstanceEditAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$dataResult = $this->ts->getInstance()->instanceEdit($body);
|
$dataResult = $this->ts->getInstance()->instanceEdit($body);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('instance_edit.edited.success'));
|
$this->flash->addMessage('success', $this->translator->trans('instance_edit.edited.success'));
|
||||||
return $response->withRedirect('/instance');
|
return $response->withRedirect('/instance');
|
||||||
|
|
|
@ -10,7 +10,6 @@ final class LogsAction extends AbstractAction
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
|
|
||||||
$dataResult = $this->ts->getInstance()->logView(100, 1, 1);
|
$dataResult = $this->ts->getInstance()->logView(100, 1, 1);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
// render GET
|
// render GET
|
||||||
$this->view->render($response, 'logs.twig', [
|
$this->view->render($response, 'logs.twig', [
|
||||||
|
|
|
@ -11,10 +11,9 @@ final class OnlineAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$dataResult = $this->ts->getInstance()->clientList();
|
$dataResult = $this->ts->getInstance()->clientList('-ip -times -info');
|
||||||
$this->ts->checkCommandResult($dataResult);
|
$this->ts->getInstance()->logout(); // avoid showing currently used user twice
|
||||||
|
|
||||||
$instance = TeamSpeak3::factory(sprintf("serverquery://%s:%s@%s:%s/?server_id=%s",
|
$instance = TeamSpeak3::factory(sprintf("serverquery://%s:%s@%s:%s/?server_id=%s",
|
||||||
$this->auth->getIdentity()['user'],
|
$this->auth->getIdentity()['user'],
|
||||||
|
@ -26,6 +25,7 @@ final class OnlineAction extends AbstractAction
|
||||||
|
|
||||||
$treeView = new TeamSpeak3_Viewer_Html("/images/viewer/", "/images/flags/", "data:image");
|
$treeView = new TeamSpeak3_Viewer_Html("/images/viewer/", "/images/flags/", "data:image");
|
||||||
$tree = $instance->getViewer($treeView);
|
$tree = $instance->getViewer($treeView);
|
||||||
|
$instance->logout();
|
||||||
|
|
||||||
// render GET
|
// render GET
|
||||||
$this->view->render($response, 'online.twig', [
|
$this->view->render($response, 'online.twig', [
|
||||||
|
|
|
@ -14,10 +14,8 @@ final class OnlineBanAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$dataResult = $this->ts->getInstance()->banClient($clid, (!empty($body['time']) ? $body['time'] : 0), $body['reason']);
|
$dataResult = $this->ts->getInstance()->banClient($clid, (!empty($body['time']) ? $body['time'] : 0), $body['reason']);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('online.banned.success', ['%clid%' => $clid]));
|
$this->flash->addMessage('success', $this->translator->trans('online.banned.success', ['%clid%' => $clid]));
|
||||||
return $response->withRedirect('/online/' . $sid . '/' . $clid);
|
return $response->withRedirect('/online/' . $sid . '/' . $clid);
|
||||||
|
|
|
@ -12,10 +12,8 @@ final class OnlineInfoAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$dataResult = $this->ts->getInstance()->clientInfo($clid);
|
$dataResult = $this->ts->getInstance()->clientInfo($clid);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
// render GET
|
// render GET
|
||||||
$this->view->render($response, 'online_info.twig', [
|
$this->view->render($response, 'online_info.twig', [
|
||||||
|
|
|
@ -14,10 +14,8 @@ final class OnlineKickAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$dataResult = $this->ts->getInstance()->clientKick($clid, 'server', $body['reason']);
|
$dataResult = $this->ts->getInstance()->clientKick($clid, 'server', $body['reason']);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('online.kicked.success', ['%clid%' => $clid]));
|
$this->flash->addMessage('success', $this->translator->trans('online.kicked.success', ['%clid%' => $clid]));
|
||||||
return $response->withRedirect('/online/' . $sid);
|
return $response->withRedirect('/online/' . $sid);
|
||||||
|
|
|
@ -14,10 +14,8 @@ final class OnlinePokeAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$dataResult = $this->ts->getInstance()->clientPoke($clid, $body['message']);
|
$dataResult = $this->ts->getInstance()->clientPoke($clid, $body['message']);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('online.poked.success', ['%clid%' => $clid]));
|
$this->flash->addMessage('success', $this->translator->trans('online.poked.success', ['%clid%' => $clid]));
|
||||||
return $response->withRedirect('/online/' . $sid . '/' . $clid);
|
return $response->withRedirect('/online/' . $sid . '/' . $clid);
|
||||||
|
|
|
@ -14,10 +14,8 @@ final class OnlineSendAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$dataResult = $this->ts->getInstance()->sendMessage(1, $clid, $body['message']);
|
$dataResult = $this->ts->getInstance()->sendMessage(1, $clid, $body['message']);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('done'));
|
$this->flash->addMessage('success', $this->translator->trans('done'));
|
||||||
return $response->withRedirect('/online/' . $sid . '/' . $clid);
|
return $response->withRedirect('/online/' . $sid . '/' . $clid);
|
||||||
|
|
|
@ -9,7 +9,6 @@ final class ProfileAction extends AbstractAction
|
||||||
{
|
{
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$whoisResult = $this->ts->getInstance()->whoAmI();
|
$whoisResult = $this->ts->getInstance()->whoAmI();
|
||||||
$this->ts->checkCommandResult($whoisResult);
|
|
||||||
|
|
||||||
// render GET
|
// render GET
|
||||||
$this->view->render($response, 'profile.twig', [
|
$this->view->render($response, 'profile.twig', [
|
||||||
|
|
|
@ -9,7 +9,6 @@ final class ProfileCredentialsChangeAction extends AbstractAction
|
||||||
{
|
{
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$dataResult = $this->ts->getInstance()->clientSetServerQueryLogin($this->auth->getIdentity()['user']);
|
$dataResult = $this->ts->getInstance()->clientSetServerQueryLogin($this->auth->getIdentity()['user']);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('profile_credentials.changed.success', ['%password%' => $dataResult['data']['client_login_password']]));
|
$this->flash->addMessage('success', $this->translator->trans('profile_credentials.changed.success', ['%password%' => $dataResult['data']['client_login_password']]));
|
||||||
$this->auth->logout();
|
$this->auth->logout();
|
||||||
|
|
|
@ -11,7 +11,6 @@ final class ServerCreateAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$dataResult = $this->ts->getInstance()->serverCreate($body);
|
$dataResult = $this->ts->getInstance()->serverCreate($body);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('server_create.created.success', ['%token%' => $dataResult['data']['token']]));
|
$this->flash->addMessage('success', $this->translator->trans('server_create.created.success', ['%token%' => $dataResult['data']['token']]));
|
||||||
return $response->withRedirect('/servers');
|
return $response->withRedirect('/servers');
|
||||||
|
|
|
@ -11,10 +11,8 @@ final class ServerDeleteAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$dataResult = $this->ts->getInstance()->serverDelete($sid);
|
$dataResult = $this->ts->getInstance()->serverDelete($sid);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('done'));
|
$this->flash->addMessage('success', $this->translator->trans('done'));
|
||||||
return $response->withRedirect('/servers');
|
return $response->withRedirect('/servers');
|
||||||
|
|
|
@ -12,10 +12,8 @@ final class ServerEditAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$dataResult = $this->ts->getInstance()->serverEdit($body);
|
$dataResult = $this->ts->getInstance()->serverEdit($body);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('server_edit.edited.success', ['%sid%' => $sid]));
|
$this->flash->addMessage('success', $this->translator->trans('server_edit.edited.success', ['%sid%' => $sid]));
|
||||||
return $response->withRedirect('/servers/' . $sid);
|
return $response->withRedirect('/servers/' . $sid);
|
||||||
|
|
|
@ -11,13 +11,10 @@ final class ServerInfoAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$infoResult = $this->ts->getInstance()->serverInfo();
|
$infoResult = $this->ts->getInstance()->serverInfo();
|
||||||
$this->ts->checkCommandResult($infoResult);
|
|
||||||
|
|
||||||
$uploadsResult = $this->ts->getInstance()->ftList();
|
$uploadsResult = $this->ts->getInstance()->ftList();
|
||||||
$this->ts->checkCommandResult($uploadsResult);
|
|
||||||
|
|
||||||
// render GET
|
// render GET
|
||||||
$this->view->render($response, 'server_info.twig', [
|
$this->view->render($response, 'server_info.twig', [
|
||||||
|
|
|
@ -12,10 +12,8 @@ final class ServerSendAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
$selectResult = $this->ts->getInstance()->selectServer($sid, 'serverId');
|
||||||
$this->ts->checkCommandResult($selectResult);
|
|
||||||
|
|
||||||
$dataResult = $this->ts->getInstance()->sendMessage(3, $sid, $body['message']);
|
$dataResult = $this->ts->getInstance()->sendMessage(3, $sid, $body['message']);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('done'));
|
$this->flash->addMessage('success', $this->translator->trans('done'));
|
||||||
return $response->withRedirect('/servers/' . $sid);
|
return $response->withRedirect('/servers/' . $sid);
|
||||||
|
|
|
@ -11,7 +11,6 @@ final class ServerStartAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$dataResult = $this->ts->getInstance()->serverStart($sid);
|
$dataResult = $this->ts->getInstance()->serverStart($sid);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('servers.started.success', ['%sid%' => $sid]));
|
$this->flash->addMessage('success', $this->translator->trans('servers.started.success', ['%sid%' => $sid]));
|
||||||
return $response->withRedirect('/servers');
|
return $response->withRedirect('/servers');
|
||||||
|
|
|
@ -11,7 +11,6 @@ final class ServerStopAction extends AbstractAction
|
||||||
|
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$dataResult = $this->ts->getInstance()->serverStop($sid);
|
$dataResult = $this->ts->getInstance()->serverStop($sid);
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
$this->flash->addMessage('success', $this->translator->trans('servers.stopped.success', ['%sid%' => $sid]));
|
$this->flash->addMessage('success', $this->translator->trans('servers.stopped.success', ['%sid%' => $sid]));
|
||||||
return $response->withRedirect('/servers');
|
return $response->withRedirect('/servers');
|
||||||
|
|
|
@ -9,7 +9,6 @@ final class ServersAction extends AbstractAction
|
||||||
{
|
{
|
||||||
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
$this->ts->login($this->auth->getIdentity()['user'], $this->auth->getIdentity()['password']);
|
||||||
$dataResult = $this->ts->getInstance()->serverList();
|
$dataResult = $this->ts->getInstance()->serverList();
|
||||||
$this->ts->checkCommandResult($dataResult);
|
|
||||||
|
|
||||||
// render GET
|
// render GET
|
||||||
$this->view->render($response, 'servers.twig', [
|
$this->view->render($response, 'servers.twig', [
|
||||||
|
|
|
@ -25,7 +25,7 @@ class TSAuthAdapter extends \Zend\Authentication\Adapter\AbstractAdapter
|
||||||
*/
|
*/
|
||||||
private $ts;
|
private $ts;
|
||||||
|
|
||||||
public function __construct($host, $queryPort, LoggerInterface $logger, $ts)
|
public function __construct($host, $queryPort, LoggerInterface $logger, TSInstance $ts)
|
||||||
{
|
{
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
$this->queryPort = $queryPort;
|
$this->queryPort = $queryPort;
|
||||||
|
@ -45,7 +45,7 @@ class TSAuthAdapter extends \Zend\Authentication\Adapter\AbstractAdapter
|
||||||
$password = $this->getCredential();
|
$password = $this->getCredential();
|
||||||
|
|
||||||
if ($this->ts->login($user, $password)) {
|
if ($this->ts->login($user, $password)) {
|
||||||
$this->logger->info(sprintf('%s authenticated with teamspeak instance %s:%s', $user, $this->ts->getHost(), $this->ts->getQueryPort()));
|
$this->logger->info(sprintf('Authenticated as %s', $user));
|
||||||
|
|
||||||
$user = ['identity' => $user, 'user' => $user, 'password'=> $password, 'role' => ACL::ACL_DEFAULT_ROLE_ADMIN];
|
$user = ['identity' => $user, 'user' => $user, 'password'=> $password, 'role' => ACL::ACL_DEFAULT_ROLE_ADMIN];
|
||||||
return new Result(Result::SUCCESS, $user, array());
|
return new Result(Result::SUCCESS, $user, array());
|
||||||
|
|
68
src/Util/TS3AdminProxy.php
Normal file
68
src/Util/TS3AdminProxy.php
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class TS3AdminProxy
|
||||||
|
{
|
||||||
|
private $object;
|
||||||
|
private $logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TS3AdminProxy constructor.
|
||||||
|
* @param ts3admin $object
|
||||||
|
* @param $logger \Psr\Log\LoggerInterface
|
||||||
|
*/
|
||||||
|
public function __construct(ts3admin $object, $logger) {
|
||||||
|
$this->object = $object;
|
||||||
|
$this->logger = $logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __call($method, $args) {
|
||||||
|
|
||||||
|
// hide sensitive args
|
||||||
|
if (in_array($method, ['login'])) {
|
||||||
|
$this->logger->debug(sprintf('Calling %s', $method));
|
||||||
|
} else {
|
||||||
|
$this->logger->debug(sprintf('Calling %s', $method), $args);
|
||||||
|
}
|
||||||
|
|
||||||
|
// invoke original method
|
||||||
|
$result = call_user_func_array(array($this->object, $method), $args);
|
||||||
|
|
||||||
|
// check result
|
||||||
|
if (is_array($result)) {
|
||||||
|
$this->logger->debug('Received', $result);
|
||||||
|
|
||||||
|
if (array_key_exists('success', $result)) {
|
||||||
|
$success = call_user_func_array(array($this->object, 'getElement'), ['success', $result]);
|
||||||
|
|
||||||
|
if (!$success) {
|
||||||
|
if (array_key_exists('errors', $result)) {
|
||||||
|
$errors = call_user_func_array(array($this->object, 'getElement'), ['errors', $result]);
|
||||||
|
$errorsAsString = implode('. ', $errors);
|
||||||
|
|
||||||
|
if (count($errors) === 1) {
|
||||||
|
|
||||||
|
// catch this
|
||||||
|
if (strpos($errorsAsString, 'ErrorID: 1281 | Message: database empty result set') !== false) {
|
||||||
|
$throw = false;
|
||||||
|
} else {
|
||||||
|
$throw = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$throw = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($throw) {
|
||||||
|
throw new TSException($errorsAsString);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new TSException('An unknown error occurred.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->logger->debug('Received ' . $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,21 +18,31 @@ class TSInstance
|
||||||
private $queryPort;
|
private $queryPort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TeamSpeakWrapper constructor.
|
* @var \Psr\Log\LoggerInterface
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
private $logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TeamSpeakWrapper constructor.
|
||||||
|
* @param $logger
|
||||||
|
*/
|
||||||
|
public function __construct($logger)
|
||||||
{
|
{
|
||||||
|
$this->logger = $logger;
|
||||||
|
|
||||||
$this->host = getenv('teamspeak_default_host');
|
$this->host = getenv('teamspeak_default_host');
|
||||||
$this->queryPort = getenv('teamspeak_default_query_port');
|
$this->queryPort = getenv('teamspeak_default_query_port');
|
||||||
|
|
||||||
$ts = new ts3admin($this->host, $this->queryPort);
|
$ts = new ts3admin($this->host, $this->queryPort);
|
||||||
|
$ts = new TS3AdminProxy($ts, $logger);
|
||||||
|
|
||||||
if($ts->getElement('success', $ts->connect())) {
|
try {
|
||||||
} else {
|
$ts->connect();
|
||||||
die('An unknown error occurred. A connection to the teamspeak server could not be established. Check settings.');
|
$this->ts = $ts;
|
||||||
|
$this->logger->debug(sprintf('Connected to %s:%s', $this->host, $this->queryPort));
|
||||||
|
} catch (TSException $e) {
|
||||||
|
die($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->ts = $ts;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,8 +55,8 @@ class TSInstance
|
||||||
public function login($user, $password)
|
public function login($user, $password)
|
||||||
{
|
{
|
||||||
if (!empty($user) && !empty($password)) {
|
if (!empty($user) && !empty($password)) {
|
||||||
$res = $this->ts->login($user, $password);
|
$this->ts->login($user, $password);
|
||||||
$this->checkCommandResult($res);
|
$this->logger->debug(sprintf('Logged in as %s', $user));
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidArgumentException('User and password not provided');
|
throw new InvalidArgumentException('User and password not provided');
|
||||||
}
|
}
|
||||||
|
@ -54,39 +64,6 @@ class TSInstance
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if any error occurred
|
|
||||||
*
|
|
||||||
* @param $result
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function checkCommandResult($result)
|
|
||||||
{
|
|
||||||
if (!$this->ts->getElement('success', $result)) {
|
|
||||||
|
|
||||||
$errors = $this->ts->getElement('errors', $result);
|
|
||||||
$errorsAsString = implode('. ', $errors);
|
|
||||||
|
|
||||||
if (count($errors) === 1) {
|
|
||||||
|
|
||||||
// catch this
|
|
||||||
if (strpos($errorsAsString, 'ErrorID: 1281 | Message: database empty result set') !== false) {
|
|
||||||
$throw = false;
|
|
||||||
} else {
|
|
||||||
$throw = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$throw = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($throw) {
|
|
||||||
throw new TSException($errorsAsString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -11,6 +11,12 @@
|
||||||
{% if data|length >0 %}
|
{% if data|length >0 %}
|
||||||
{% include 'table.twig' with {'data': data,
|
{% include 'table.twig' with {'data': data,
|
||||||
'hide': [{'key': 'client_type', 'values': ['1']}],
|
'hide': [{'key': 'client_type', 'values': ['1']}],
|
||||||
|
'filters': [
|
||||||
|
{'key': 'client_idle_time', 'apply': 'timeInSeconds'},
|
||||||
|
{'key': 'connection_connected_time', 'apply': 'timeInSeconds'},
|
||||||
|
{'key': 'client_created', 'apply': 'timestamp'},
|
||||||
|
{'key': 'client_lastconnected', 'apply': 'timestamp'}
|
||||||
|
],
|
||||||
'links': [
|
'links': [
|
||||||
{'key': 'clid', 'uri': '/online/' ~ sid},
|
{'key': 'clid', 'uri': '/online/' ~ sid},
|
||||||
{'key': 'cid', 'uri': '/channels/' ~ sid, 'uri_param': 'cid'},
|
{'key': 'cid', 'uri': '/channels/' ~ sid, 'uri_param': 'cid'},
|
||||||
|
|
Reference in a new issue