[Help]

Celso

Well-Known Member
Oct 1, 2017
142
47
119
Wrong Thread Title
I wanted to change a script only that I do not understand much of php. the script creates a channel and creates a token with the channel administrator key, he wanted to be able to change it to move the channel creator direct to the channel with the channel administrator. Can someone help me with this change?
 

Celso

Well-Known Member
Oct 1, 2017
142
47
119
how does it work=>
PHP:
try {

            $ts3_VirtualServer = TeamSpeak3::factory("serverquery://$ts3_username:$ts3_password@$ts3_host:$ts3_q_port/?server_port=$ts3_s_port");
            $ts3_VirtualServer->selfUpdate(array('client_nickname'=> $ts3_nick));

            $client = $ts3_VirtualServer->clientGetByUid($request->uuid);
            $groups = $client["client_servergroups"];
            $group_matches = 0;

            foreach($allowed_groups as $g)
            {
                if(in_array($g, $allowed_groups))
                {
                    $group_matches++;
                }
            }

            if($group_matches <= 0)
            {
                Response(403, "Não Autorizado "," Não é permitido usar esta ferramenta, você não está em um grupo permitido.");
            }

            $cid = $ts3_VirtualServer->channelCreate(array(
            "channel_name" => $request->channelname,
            "channel_password" => $request->password,
            "channel_topic" => $channel_topic,
            "channel_codec" => TS3_CODEC,
            "channel_codec_quality" => $request->quality,
            "channel_flag_permanent" => FALSE,
            "cpid"                  => $cpid,
            "channel_description" => $channel_description,
            "channel_flag_semi_permanent" => TRUE
            ));

            //log cid with IP (abuse)
            $usr_ip = $_SERVER['REMOTE_ADDR'];
            $ts3_VirtualServer->logAdd("Channel $cid created from IP:$usr_ip", TeamSpeak3::LOGLEVEL_INFO);

     
            $token = $ts3_VirtualServer->privilegeKeyCreate(0x01, "$chadmin_group_id"  ,"$cid", "TOKEN created from CHADD.");

            $chadd->SetCookie();


            $resp = array(
                    "code" => 1,
                    "header" => "Tudo bem! :)",
                    "token" => (string)$token,
                    "url" => "$server_conn_url?port=$ts3_s_port&cid=$cid&channelpassword=$request->password&token=$token",
            );


            $json = json_encode($resp);
            echo $json;
            exit;

            }
work like this=>
PHP:
{
            $cid1 = $ts3->channelCreate(array(
            "channel_name" => "$channelname",
            "channel_password" => "$password",
            "channel_flag_permanent" => "1",
            "channel_description" => '[center][b][u]'.$channelname.'[/u][/b][/center][hr][b][list][*]Data e hora que foi criado: '.$realTime.'[*]Criador: ' . $client_nickname . '[/list][/b]',
            "channel_order" => "$order"));
           
            $ts3->clientGetByUid($clientuid)->setChannelGroup($cid1, $channel_admin_group);
            $ts3->clientMove($client_clid, $cid1);
           
        }
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
you can append
PHP:
$client->move($cid);
$client->setChannelGroup($cid, $chadmin_group_id);
behind "$ts3_VirtualServer->logAdd("Channel $cid created from IP:$usr_ip", TeamSpeak3::LOGLEVEL_INFO);" and then remove this line as it is redundant.
 

Celso

Well-Known Member
Oct 1, 2017
142
47
119
you can append
PHP:
$client->move($cid);
$client->setChannelGroup($cid, $chadmin_group_id);
behind "$ts3_VirtualServer->logAdd("Channel $cid created from IP:$usr_ip", TeamSpeak3::LOGLEVEL_INFO);" and then remove this line as it is redundant.

I will try, ty
 

Celso

Well-Known Member
Oct 1, 2017
142
47
119
It was like this, but it gave an error
PHP:
//log cid with IP (abuse)
            $usr_ip = $_SERVER['REMOTE_ADDR'];
            $ts3_VirtualServer->logAdd("Channel $cid created from IP:$usr_ip";
            $client->move($cid);
            $client->setChannelGroup($cid, $chadmin_group_id);

        
            $token = $ts3_VirtualServer->privilegeKeyCreate(0x01, "$chadmin_group_id"  ,"$cid", "TOKEN created from CHADD.");

            $chadd->SetCookie();

P33xkQz.png




( Oops o_O The server does not respond with the right path. Please try again in a few minutes or contact an administrator.)
 

Celso

Well-Known Member
Oct 1, 2017
142
47
119
PHP:
            //log cid with IP (abuse)
            $usr_ip = $_SERVER['REMOTE_ADDR'];
            $ts3_VirtualServer->logAdd("Channel $cid created from IP:$usr_ip", TeamSpeak3::LOGLEVEL_INFO);

        
            $token = $ts3_VirtualServer->privilegeKeyCreate(0x01, "$chadmin_group_id"  ,"$cid", "TOKEN created from CHADD.");
            $client->move($cid);
            $client->setChannelGroup($cid, $chadmin_group_id);


that worked!
 
Top