Celso
Well-Known Member
- Oct 1, 2017
- 142
- 47
- 119
Hello, I use this script on my site for members to assign tags.
some members the script can not find it on teamspeak. wanted to know if this is a bug or a bug in the script or something in the pc / network configuration of the members.
some members the script can not find it on teamspeak. wanted to know if this is a bug or a bug in the script or something in the pc / network configuration of the members.
PHP:
try {
$tsAdmin = getTeamspeakConnection("#no_query_clients");
$tsAdmin->selfUpdate(["client_nickname" => $botname]);
$userip = $_SERVER["REMOTE_ADDR"];
if($userip === "::1")
$userip = "127.0.0.1";
$clients = $tsAdmin->clientList(["connection_client_ip" => $userip]);
$servergroups = $tsAdmin->serverGroupList();
if(!empty($clients)) {
$client = array_values($clients)[0];
$clientgroups = explode(",", $client["client_servergroups"]);
}
if(isset($client)) {
$cacheutils = new CacheUtils('logincodes-' . $client["client_database_id"]);
if(empty($_SESSION["loggedin"])) {
if($cacheutils->isExpired()) {
$logincode = mt_rand(100, 999);
$client->poke(translate($lang["groupassigner"]["codepoke"], [$logincode]));
$cacheutils->setValue($logincode, 120);
} else {
$logincode = $cacheutils->getValue();
}
if(!empty($_POST["logincode"])) {
if($logincode === (int)$_POST["logincode"]) {
$cacheutils->remove();
$_SESSION["loggedin"] = true;
} else {
$failedlogin = true;
}
}
}
if(!empty($_POST["submitted"]) && !empty($_SESSION["loggedin"])) {
$allgroups = [];
foreach ($assignerconfig as $item) {
foreach ($item["sgids"] as $sgid) {
if(!in_array($sgid, $allgroups))
$allgroups[] = (int)$sgid;
}
}
$submittedgroups = [];
if(!empty($_POST["sgs"]) && is_array($_POST["sgs"])) {
foreach ($_POST["sgs"] as $sg) {
$submittedgroups[] = (int)$sg;
}
}
$groupsremove = array_diff($allgroups, $submittedgroups);
foreach ($groupsremove as $grid) {
try {
$client->remServerGroup((int)$grid);
} catch (Exception $e) {}
}
foreach ($submittedgroups as $gaid) {
try {
if(in_array($gaid, $allgroups)) {
$client->addServerGroup((int)$gaid);
}
} catch (Exception $e) {}
}
$client = $tsAdmin->clientGetByDbid($client["client_database_id"]); // refresh
$clientgroups = explode(",", $client["client_servergroups"]);
$success = true;
}
}
} catch (Exception $e) {
echo "Connection failed! $e";
}
?>