Create channel web [help]

qeekus

Active Member
Oct 12, 2015
17
5
93
Help me please with script create channel web for teamspeak (add the token display)
PHP:
<?php
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
/* Here it checks if the User has already created a room today. */
if($_COOKIE["config623424123455"]==""){ /* If he has not created yet he goes and does the registration of the room */
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://xxx:xxx@localhost:10011/?server_port=9987");
// Channel Admin group ID goes here:
$channel_admin_group = 9;


$name_channel         = $_POST['nchannel'];
$desc_channel         = $_POST['dchannel'];
$pass_channel         = $_POST['pchannel'];

// create a top-level channel and get its ID
$top_cid = $ts3_VirtualServer->channelCreate(array(
  "channel_name"           => "$name_channel",
  "channel_description"          => "$desc_channel",
  "channel_flag_permanent" => TRUE,
  "channel_password" => "$pass_channel",
));


   setcookie('config623424123455', '1', (time() + (3 * 24 * 3600)));

   /* After he set up the room, it will add a record of 3 days,
   ie the User does not managed to create a new room for 3 days.
   Of course it will be able to circumvent it, clean up the records of the PC. */

// Searches for the client. If exists, assign channel admin
foreach($ts3_VirtualServer->clientList() as $client) {
    if($_SERVER['REMOTE_ADDR'] == $client['connection_client_ip']) {
        $ts3_VirtualServer->clientGetById($client['clid'])->setChannelGroup($top_cid, $channel_admin_group);
        break;
    }
}
header("Location: unit.php?op=1");
}
else
{  /* If the User has created a room today, the system does not let him create another. Throwing you to the site with the initial error message. */
header("Location: unit.php?op=2");
}

?>
HTML:
<div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">Create perm channel</h3>
            </div>
            <div class="panel-body">
  
                    <?php error_reporting(0); $op = $_GET['op'];

echo "<form action='xxx.php' method='POST'>

<div class='input-group'>
<span class='input-group-addon'><strong>Name channel:</strong></span><input class='form-control' name='nchannel' id='nchannel' placeholder='Name channel' type='text'></div><BR>
<div class='input-group'>
<span class='input-group-addon'><strong>Descr:</strong></span><input class='form-control' name='dchannel' id='dchannel' placeholder='Description' type='text' ></div><BR>
<div class='input-group'>
<span class='input-group-addon'><strong>PW:</strong></span><input class='form-control' name='pchannel' id='pchannel' placeholder='Password' type='text' ></div><BR>

<button type='submit' class='btn btn-primary'>Create</button><BR>

</form> <br>";
if ($op==1){ echo "<div class='bs-component'><div class='alert alert-dismissible alert-success'><button type='button' class='close' data-dismiss='alert'>×</button><strong>Nice!</strong> </a>.</div></div>";}
/* Channel created successfully! */
if ($op==2){ echo "<div class='bs-component'><div class='alert alert-dismissible alert-danger'><button type='button' class='close' data-dismiss='alert'>×</button><strong>Ooops!</strong> </a>.</div></div>";}
/* Here is the message to the User if he has already created a room on the day. */

?>

          
              
                    </div>
        </div>

need display token after create channel
 

Santiago

Active Member
May 9, 2015
19
16
81
I recommend you leave the token in Base64, to avoid problems when put in the URL. :)
To decode.
PHP:
$64decodetoken = base64_decode($_GET["token"]);
PHP:
<?php
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
/* Here it checks if the User has already created a room today. */
if($_COOKIE["config623424123455"]==""){ /* If he has not created yet he goes and does the registration of the room */
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://xxx:xxx@localhost:10011/?server_port=9987");
// Channel Admin group ID goes here:
$channel_admin_group = 9;


$name_channel         = $_POST['nchannel'];
$desc_channel         = $_POST['dchannel'];
$pass_channel         = $_POST['pchannel'];

// create a top-level channel and get its ID
$top_cid = $ts3_VirtualServer->channelCreate(array(
  "channel_name"           => "$name_channel",
  "channel_description"          => "$desc_channel",
  "channel_flag_permanent" => TRUE,
  "channel_password" => "$pass_channel",
));


   setcookie('config623424123455', '1', (time() + (3 * 24 * 3600)));

   /* After he set up the room, it will add a record of 3 days,
   ie the User does not managed to create a new room for 3 days.
   Of course it will be able to circumvent it, clean up the records of the PC. */

// Searches for the client. If exists, assign channel admin
foreach($ts3_VirtualServer->clientList() as $client) {
    if($_SERVER['REMOTE_ADDR'] == $client['connection_client_ip']) {
        $ts3_VirtualServer->clientGetById($client['clid'])->setChannelGroup($top_cid, $channel_admin_group);
        $token = $ts3_VirtualServer->channelGroupGetByName('GROUP NAME')->privilegeKeyCreate($top_cid, 'Token Auto - Desc');
        break;
    }
}
$64token = base64_encode($token);
header("Location: unit.php?op=1&token=$64token");
}
else
{  /* If the User has created a room today, the system does not let him create another. Throwing you to the site with the initial error message. */
header("Location: unit.php?op=2");
}

?>

:)
 
Last edited:

tiro

Member
Jun 6, 2016
27
4
43
PHP:
Parse error: syntax error, unexpected '64' (T_LNUMBER), expecting variable (T_VARIABLE) or '$'
 
Top