Advertisement
Guest User

Channel Register by Codex R4P3.NET

a guest
Mar 16th, 2017
733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.59 KB | None | 0 0
  1. <?php
  2.  
  3. require_once("libraries/TeamSpeak3/TeamSpeak3.php");
  4.  
  5. function connection() {
  6.    
  7.     global $ts3_VirtualServer;
  8.     global $config;
  9.     $ts3_VirtualServer = TeamSpeak3::factory("serverquery://{$config['serveradmin']}:{$config['password']}@{$config['address']}:{$config['queryport']}/?server_port={$config['port']}&nickname={$config['nickname']}");
  10.    
  11. }
  12.  
  13. //Connection
  14. $config = array(
  15.     "address" => "localhost",
  16.     "queryport" => "10011",
  17.     "serveradmin" => "serveradmin",
  18.     "password" => "qwerty",
  19.     "port" => "9987",
  20.     "nickname" => "CodexBOT"
  21. );
  22.  
  23. //Channels order
  24. $channels = array(  
  25.     "A" => 5, //CID
  26.     "B" => 6,
  27.     "-" => 50
  28.     //... insert other
  29. );
  30. try {
  31.    
  32.     while (1) {
  33.        
  34.         connection();
  35.        
  36.         foreach ($ts3_VirtualServer->channelList() as $channelList) {
  37.            
  38.             if (preg_match('/\[PERMANENT\]/', $channelList['channel_name'])) {
  39.                
  40.                 $ChannelName = preg_replace('/\[PERMANENT\]/', "", $channelList['channel_name']);
  41.                
  42.                
  43.                 foreach ($channels as $channel => $cid) {
  44.                    
  45.                     $subChannels = $ts3_VirtualServer->channelGetById($cid)->subChannelList();
  46.                    
  47.                     if(!empty($subChannels))
  48.                         $lastId = end($subChannels)->getId();
  49.                     else
  50.                         $lastId = null;
  51.                    
  52.                     if (preg_match('/^\s/', $ChannelName))
  53.                        $ChannelName = preg_replace('/^\s/', "", $ChannelName);
  54.                    
  55.                     foreach ($subChannels as $subChannel) {
  56.                        
  57.                         if ($ChannelName == $subChannel['channel_name']) {
  58.                            
  59.                             if (strlen($ChannelName) > 11) {
  60.                                
  61.                                 $channelList->modify(array(
  62.                                     "channel_description" => '[COLOR=#ffaa00][B]it s not possible  to make this channel permanent because there  is already one channel with this name. Rename this channel in different way (Adding always the tag [COLOR=#000000][PERMANENT][/COLOR]) for getting your channel.[/B][/COLOR]'            
  63.                                 ));
  64.                             }
  65.                            
  66.                             if (strlen($ChannelName) < 12) {
  67.                                
  68.                                 $channelList->modify(array(
  69.                                     "channel_name" => '[READ DESCRIPTION] ' . $ChannelName,
  70.                                     "channel_description" => '[COLOR=#ffaa00][B]it s not possible  to make this channel permanent because there  is already one channel with this name. Rename this channel in different way (Adding always the tag [COLOR=#000000][PERMANENT][/COLOR]) for getting your channel.[/B][/COLOR]'            
  71.                                 ));
  72.                             }
  73.                         }
  74.                     }
  75.                    
  76.                     if ($ChannelName != $subChannel['channel_name'] || empty($subChannel)) {
  77.                        
  78.                         if ($ChannelName[0] === $channel || $ChannelName[0] === strtolower($channel)) {
  79.                            
  80.                             $ts3_VirtualServer->channelMove($channelList['cid'], $cid , $lastId);
  81.                             $channelList->modify(array("channel_name" => $ChannelName,
  82.                                                        "channel_flag_permanent" => 1
  83.                                                       ));        
  84.                         }
  85.                        
  86.                         if (preg_match('/[^A-Za-z]/', $channel)) {
  87.                        
  88.                             if (!ctype_alpha($ChannelName[0])) {
  89.                            
  90.                                 $ts3_VirtualServer->channelMove($channelList['cid'], $cid , $lastId);
  91.                                 $channelList->modify(array("channel_name" => $ChannelName,
  92.                                                            "channel_flag_permanent" => 1
  93.                                                           ));
  94.                             }
  95.                         }
  96.                     }
  97.                 }
  98.             }
  99.         }
  100.        
  101.         $ts3_VirtualServer->logout();
  102.         sleep(3);
  103.        
  104.     }
  105.    
  106. } catch(TeamSpeak3_Exception $e) {
  107.    
  108.     echo "Error " . $e->getCode() . ": " . $e->getMessage();
  109.    
  110. }
  111.  
  112.  
  113. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement