diff --git a/config/config.template.php b/config/config.template.php index a0f359c..8493c80 100644 --- a/config/config.template.php +++ b/config/config.template.php @@ -75,3 +75,12 @@ $config['contact']['items'][] = ["TeamSpeak", "Support channel", "ts3server://te $config['contact']['items'][] = ["Email", "contact@email.com", "mailto:contact@email.com"]; $config['contact']['items'][] = ["Telegram", "@Telegram", "https://t.me/Telegram"]; $config['contact']['items'][] = ["Twitter", "@Twitter", "https://twitter.com/Twitter"]; + +/************* Groupassigner configuration *************/ + +// Enable / Disable the GroupAssigner +$config["groupassigner"] = 1; + +// Server groups to be assigned +$config["groups"]["allowgroups"] = array("41","42"); + diff --git a/config/languages/lang.de.php b/config/languages/lang.de.php index edbfb8d..6e1966d 100644 --- a/config/languages/lang.de.php +++ b/config/languages/lang.de.php @@ -22,6 +22,8 @@ $lang["navbar"]["rules"] = "Server Regeln"; $lang["navbar"]["connect"] = "Mit Server verbinden"; $lang["navbar"]["connecttooltip"] = "Klicken um mit {0} zu verbinden"; +$lang["navbar"]["groupassigner"] = "Gruppenzuweiser"; + /************* Footer *************/ @@ -102,3 +104,16 @@ $lang["banlist"]["table"]["expires"] = "Läuft ab am"; $lang["rules"]["title"] = "Server Regeln"; $lang["rules"]["filenotfound"] = "Fehler: Die Datei config/rules.md wurde nicht gefunden!"; $lang["rules"]["readerror"] = "Fehler: Nicht genügend Rechte um auf config/rules.md zuzugreifen!"; + +/************* Groupassigner - groupassigner.php *************/ +$lang["grouppage"]["title"] = "Gruppenzuweiser"; +$lang["grouppage"]["tsuid"] = "Teamspeak-UID"; +$lang["grouppage"]["tsgroup"] = "Teamspeak Gruppe"; +$lang["grouppage"]["send"] = "Absenden"; + +$lang["grouppage"]["error"]["offline"] = "Du musst online sein zur Vergabe einer Gruppe"; +$lang["grouppage"]["error"]["notallowed"] = "Diese Servergruppe darf nicht vergeben werden."; +$lang["grouppage"]["error"]["duplicate"] = "Du besitzt die Servergruppe bereits."; + +$lang["grouppage"]["success"]["success"] = "Dir wurde die Servergruppe zugewiesen"; + diff --git a/groupassigner.php b/groupassigner.php new file mode 100644 index 0000000..da5a63c --- /dev/null +++ b/groupassigner.php @@ -0,0 +1,106 @@ +isExpired()) { + $cacheutils->setValue([getServerGroups(), date('d.m.Y H:i:s')], 300); +} + +$grouplist = $cacheutils->getValue(); +try { + $tsAdmin = getTeamspeakConnection("#no_query_clients"); +} catch (Exception $e){ + if ($e->getCode() == 1281) { + echo ''; + } else { + echo '

' . translate($lang["general"]["scripterror"], [$e->getCode(), $e->getMessage()]) . '

'; + exit; + } +} + + +if(isset($_POST["absenden"])){ + $uid = htmlspecialchars($_POST['uid']); + if(in_array(htmlspecialchars($_POST['group']), $config["groups"]["allowgroups"])){ + try { + $tsAdmin->clientGetByUid($uid)->addServerGroup(htmlspecialchars($_POST['group'])); + setCookie("tsuid", $uid); + $success = "success"; + } catch(Exception $e) { + if(strpos($e, "invalid clientID") == true){ + $error = "offline"; + }elseif(strpos($e, "duplicate entry") == true){ + $error = "duplicate"; + } + + } + }else{ + $error = "notallowed"; + } +} +?> + +
+
+

+
+
+ +
+

+
+ +
+

+
+ +
+

+ " value="" class="form-control" style="width: 70%; margin-left:15%; margin-bottom: 5%;"> +

+ +

+ +
+ + +
+
+ + + +getCode() == 1281) { + return ''; + } else { + return '

' . translate($lang["general"]["scripterror"], [$e->getCode(), $e->getMessage()]) . '

'; + } + } + +} + +require_once __DIR__ . "/include/footer.php"; +?> diff --git a/include/header.php b/include/header.php index 67ef01e..34d0c3f 100644 --- a/include/header.php +++ b/include/header.php @@ -72,7 +72,18 @@ $htalink = $config["general"]["enablehta"] ? "" : ".php";