Automatic channel creator

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
Hello,
few days ago I made this handy script to automate creating channels. (From temporary to permanent). But this only works when you dont have any rooms where you are channel admin (to prevent flooding server with rooms)

Just copy it, edit needed things in CONFIG part and upload it on web server.
Create spacer and set it's name to "[cspacerα]↓ - Sector α - ↓".

PHP:
<?php
echo "<title>Room Creator by Nicer</title>";
$nickname = $client = '';
require_once("libraries/TeamSpeak3/TeamSpeak3.php");

function string_ends_with($string, $ending)
{
    $len = strlen($ending);
    $string_end = substr($string, strlen($string) - $len);
    return $string_end == $ending;
}
//CONFIG
//channel admin group id
$groupid = 5;
//number of channels in spacer
$chinspacer = 25;
//connection details
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://name:[email protected]:10011/?server_port=9987");

$ts3_VirtualServer->selfUpdate(array('client_nickname'=>"Permanent room"));
//DO NOT EDIT THIS UNLESS YOU KNOW WHAT YOU ARE DOING
$greekalphabet = array("α","β","γ","δ","ε","ζ","η","θ","ι","κ","λ","μ","ν","ξ","ο","π","ρ","ς","τ","υ","φ","χ","ψ","ω");
$isonts = false;
foreach($ts3_VirtualServer->clientList() as $client)
{
    if($client->client_type) continue;
    if($client->getProperty('connection_client_ip') == $_SERVER['REMOTE_ADDR'])
    {
        $client = $client;
        $nickname = $client->getProperty('client_nickname');
        $uid = $client->getProperty('client_unique_identifier');
        $dbid = $client->getProperty('client_database_id');
        $isonts = true;
    }
}
if($isonts == true)
{
try{
$grouplist = $ts3_VirtualServer->channelGroupClientList($groupid,null,$dbid);
foreach($grouplist as $group)
{
    $g = $group['cid'];
    break;
}
$ts3_VirtualServer->channelListReset();
if($ts3_VirtualServer->channelGetById($g)->getProperty('channel_flag_permanent') == 0 && $ts3_VirtualServer->channelGetById($g)->getProperty('channel_flag_semi_permanent') == 0)
{
    $greek = 0;
    foreach($ts3_VirtualServer->channelList() as $channel)
    {
        if(!$channel->isSpacer()) {continue;}
        if(string_ends_with($channel,"↓")) { $greek = $greek + 1; $spacer = $channel;}
    }
    $count=0;
    foreach($spacer->subChannelList() as $subchannel)
    {
        $count = $count + 1;
        $cid = $subchannel->getProperty('cid');
    }
    if($count >= $chinspacer)
    {
        $ts3_VirtualServer->channelCreate(array("channel_name=[cspacer".$greekalphabet[$greek]."]↓ - Sector ".$greekalphabet[$greek]." - ↓","channel_order=".$spacer->getProperty('cid'),"channel_flag_permanent=1","channel_flag_maxfamilyclients_unlimited=1"));
        $ts3_VirtualServer->channelListReset();
        foreach($ts3_VirtualServer->channelList() as $channel)
        {
        if(!$channel->isSpacer()) {continue;}
        if(string_ends_with($channel,"↓")) {$spacer = $channel;}
        }
        $ts3_VirtualServer->channelMove($channel->getProperty('cid'),$spacer->getProperty('cid'));
        $channel->modify(array("channel_flag_permanent=1"));
        $client = $ts3_VirtualServer->clientGetByDbid($group['cldbid']);
        $client->move($g);
        $client->setChannelGroup($channel->getProperty('cid'),$groupid);
    }
    else
    {
        $ts3_VirtualServer->channelMove($channel->getProperty('cid'),$spacer->getProperty('cid'),$cid);
        $channel->modify(array("channel_flag_permanent=1","channel_flag_maxfamilyclients_unlimited=1"));
    }
    header('Location: index.php');
}
else { echo "You are not in temporary room!!";}
}
catch (exception $e) {echo "Something went wrong: " . $e->getMessage();}

}
else {echo "You are not ocnnected!";}

?>
 
Last edited:

Sempz

Member
May 14, 2016
23
2
35
I think that is ussles... you have this:
I allready shared the script with him lol , I was talking with him on his own teamspeak... i shared but his hoster can't support the script cuz i think the script is only for linux. Sorry for my bad english :) but if some one need the code of this: https://r4p3.net/threads/create-channel-web-help.1039/ with subchannels i can give you
Here is the code:
Code:
<?php session_start(); ?>
<?php

    date_default_timezone_set('Portugal'); //Change Here!
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");
    include 'data/config.php';


    function getClientIp() {
        if (!empty($_SERVER['HTTP_CLIENT_IP']))
            return $_SERVER['HTTP_CLIENT_IP'];
        else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
            return $_SERVER['HTTP_X_FORWARDED_FOR'];
        else if(!empty($_SERVER['HTTP_X_FORWARDED']))
            return $_SERVER['HTTP_X_FORWARDED'];
        else if(!empty($_SERVER['HTTP_FORWARDED_FOR']))
            return $_SERVER['HTTP_FORWARDED_FOR'];
        else if(!empty($_SERVER['HTTP_FORWARDED']))
            return $_SERVER['HTTP_FORWARDED'];
        else if(!empty($_SERVER['REMOTE_ADDR']))
            return $_SERVER['REMOTE_ADDR'];
        else
            return false;
    }

    $connect = "serverquery://".$USER_QUERY.":".$PASS_QUERY."@".$HOST_QUERY.":".$PORT_QUERY."/?server_port=".$SERVER_PORT."";
    $ts3 = TeamSpeak3::factory($connect);
    $ts3->execute("clientupdate", array("client_nickname" => $NICK_QUERY));
    $FLAG = false;

    foreach ($ts3->clientList(array('client_type' => '0', 'connection_client_ip' => getClientIp())) as $client) {
        $clientuid = $client->client_unique_identifier;
        $client_nickname = $client->client_nickname;
        $client_clid = $client->clid;
        $FLAG = true;
        break;
    }
    if (!$FLAG){
        echo "<p><b>".$lang['f_connectts'].".</b></p><br/>";
        header("refresh: 10; url = ./");
        die;
    }

    if (isset($_POST["create"])) {

        $channelname = $_POST['channelname'];
        $password = $_POST['password'];
        $unixTime = time();
        $realTime = date('[Y-m-d]-[H:i]',$unixTime);
        $channel_admin_group = 5;
        $random = mt_rand(0,10000);

        try
        {
       $cid1 = $ts3->channelCreate(array(
       "channel_name" => "[*spacer$random]▃",
       "channel_password" => "$password",
       "channel_flag_permanent" => "1",
       "channel_description" => '[center][b][u]'.$channelname.'[/u][/b][/center][hr][b][list][*]Data: '.$realTime.'[*]Dono da sala: ' . $client_nickname . '[/list][/b]',
       "channel_order" => "$order"
        ));
            $cid = $ts3->channelCreate(array(
            "channel_name" => "[cspacer$random]★ $channelname ★",
            "channel_password" => "$password",
            "channel_flag_permanent" => "1",
            "channel_description" => '[center][b][u][color=red]'.$channelname.'[/color][/u][/b][/center][hr][b][list][*]Data: '.$realTime.'[*]Dono da sala: ' . $client_nickname . '[/list][/b]',
       "channel_order" => "$order"
    ));
            $cid1 = $ts3->channelCreate(array(
            "channel_name" => "Convivio #1",
            "channel_password" => "$password",
            "channel_flag_permanent" => "1",
            "channel_description" => '[center][b][u]'.$channelname.'[/u][/b][/center][hr][b][list][*]Data: '.$realTime.'[*]Dono da sala: ' . $client_nickname . '[/list][/b]',

       "cpid" => $cid,
    ));
            $cid1 = $ts3->channelCreate(array(
            "channel_name" => "Convivio #2",
            "channel_password" => "$password",
            "channel_flag_permanent" => "1",
            "channel_description" => '[center][b][u]'.$channelname.'[/u][/b][/center][hr][b][list][*]Data: '.$realTime.'[*]Dono da sala: ' . $client_nickname . '[/list][/b]',

       "cpid" => $cid,
    ));
            $cid1 = $ts3->channelCreate(array(
            "channel_name" => "A Jogar",
            "channel_password" => "$password",
            "channel_flag_permanent" => "1",
            "channel_description" => '[center][b][u]'.$channelname.'[/u][/b][/center][hr][b][list][*]Data: '.$realTime.'[*]Dono da sala: ' . $client_nickname . '[/list][/b]',

       "cpid" => $cid,
    ));
            $ts3->clientGetByUid($clientuid)->setChannelGroup($cid1, $channel_admin_group);
            $ts3->clientMove($client_clid, $cid1);

        }
        catch(Exception $e)
        {
            echo "Error (ID " . $e->getCode() . ") <b>" . $e->getMessage() . "</b>";
        }
    }
?>
<!DOCTYPE html>
<html lang="en" class="no-js">
    <head>
        <meta charset="UTF-8" />
        <title>NEW-SENSE</title>
        <link rel="stylesheet" type="text/css" href="css/demo.css" />
        <link rel="stylesheet" type="text/css" href="css/style.css" />
        <link rel="stylesheet" type="text/css" href="css/animate-custom.css" />
    </head>
    <body>
        <div class="container">
            <header>
                <h1>Cria a tua sala<span> Permanente</span></h1>
            </header>
            <section> 
                <div id="container_demo" >
                    <div id="wrapper">
                        <div id="login" class="animate form">
                            <form  method="post" autocomplete="on">
                                <h1>Settings</h1>
                                <p>
                                    <label  class="uname" data-icon="u" > Ola, <?php echo $client_nickname; ?></label>
                                    <input  readonly type="text" value="<?php echo $clientuid; ?>"/>
                                </p>
                                <p>
                                    <label  class="uname" data-icon="u" > Nome do Canal </label>
                                    <input  name="channelname" required="required" type="text" placeholder="My Super Channel."/>
                                </p>
                                <p>
                                    <label class="youpasswd" data-icon="p"> Passwords dos canais</label>
                                    <input name="password" required="required" type="text" placeholder="eg. X8df!90EO" />
                                </p>
                                <p class="login button">
                                    <input type="submit" name="create" value="Criar Canais!" />
                                </p>
                            </form>
                        </div>
          
                    </div>
                </div>
            </section>
        </div>
    </body>
</html>
My ts: *REMOVED*
the site if you wan't to test the script: *REMOVED* YOU NEED TO BE CONNECTED TO THE TEAMSPEAK SERVER
This script was been created by
EscuderoKevin ( THANK YOU FOR YOUR HELP )
i just add more channels :)
https://r4p3.net/threads/web-script-copy-the-function-of-this-channel-creator.2713/
 

Sempz

Member
May 14, 2016
23
2
35
Ho ok , didn't saw the code , i though the user need to create a temporary channel and than with that channel it will became permanent with subchannels added to.
 

LIFE

Member
Oct 1, 2016
19
1
38
can we make this when some one go to the channel auto create channel for him ? with a password ?
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
It is, you just need to launch the script when someone joins the channel (event).
 

MadKill

Active Member
Sep 1, 2015
190
47
66
i have channel creator works very fine.
cf5b565b6cca4ae0ad10e92be7a54362.png


effc280209aa48bdb3a3baee12f36250.png


if already have channel on teamspeak3 .
02d99bab54db420abc385f7e8383a780.png


else show the form to create.

Version 4.1 unfinished

Sorry for link.
 
Last edited:

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
Well it is set that you can't havy any channel admin group on the server in order to allow room creation so that may be the issue.
 

pwn3r

Member
Jan 1, 2018
143
63
64
database empty result set
Well it is set that you can't havy any channel admin group on the server in order to allow room creation so that may be the issue.
I have the same problem on my script, this is coming from this function:
PHP:
$grouplist = $ts3_VirtualServer->channelGroupClientList($groupid,null,$dbid);
How do you think I can check whether the person has an already owned channel without getting that database empty result set error.
Check out my post here: https://r4p3.net/threads/channelgroupclientlist-problem.6112/post-53960
 
Top