script can not find some members

Joined
Oct 1, 2017
Messages
128
Likes
41
Points
44
Age
20
Location
Brasil
#1
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.

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";
}
?>
 

Asphyxia

Server Monkey
Administrator
Joined
Apr 25, 2015
Messages
937
Likes
1,401
Points
217
Age
25
Location
North America
#2
@Celso could you kindly provide more information to us? Like do you notice this happens specifically with users containing a (, or maybe a comma, and even perhaps other wild special characters? The more information you could provide us, the easier to troubleshoot.

I skimmed the code quickly, but without knowing for example the variable name I need to look at, (I would assume client or nickname).. I would be playing a guessing game.

So if you could certainly offer up a little more info I will happily help you ;)

P.S. maybe some of your groups have special characters too? Do not overlook any details, the more information - the easier to help!
 

kalle

high minded
Contributor
Joined
Oct 28, 2015
Messages
295
Likes
146
Points
103
Age
22
Location
Bosnia and Herzegovina
#3
Like always users can fake in input almost everything. If you check user IP on TS I think that user can hide IP adress with TS3 Hook. So check users IP or what else you are using (didnt looked at the code).
 

Top