Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.42 KB | None | 0 0
  1. <?PHP
  2. //header("refresh: 1;");
  3. /**
  4.   * clientkick.php
  5.   *
  6.   * Is a small script to demonstrate how to kick a client via ts3admin.class
  7.   *
  8.   * by par0noid solutions - ts3admin.info
  9.   *
  10. */
  11.  
  12. /*-------SETTINGS-------*/
  13. $ts3_ip = '127.0.0.1';
  14. $ts3_queryport = 10011;
  15. $ts3_user = 'serveradmin';
  16. $ts3_pass = 'sy5SnzRJ';
  17. $ts3_port = 9987;
  18. /*----------------------*/
  19.  
  20. #Include ts3admin.class.php
  21. require("lib/ts3admin.class.php");
  22.  
  23. #build a new ts3admin object
  24. $tsAdmin = new ts3admin($ts3_ip, $ts3_queryport);
  25.  
  26. if($tsAdmin->getElement('success', $tsAdmin->connect())) {
  27.     #login as serveradmin
  28.     $tsAdmin->login($ts3_user, $ts3_pass);
  29.    
  30.     #select teamspeakserver
  31.     $tsAdmin->selectServer($ts3_port);
  32.     global $tsAdmin;
  33.     $tsAdmin->setName("KAROL - BOT");  
  34.  
  35.    
  36.    
  37.     $clients = $tsAdmin->clientList();
  38.    
  39.     echo count($clients['data']) . ' clients on selected server<br><br>';
  40.    
  41.    
  42.     print_r($tsAdmin->clientList());
  43.     echo"<br><br>";
  44.    
  45.    
  46.     $xd = $tsAdmin->clientList();
  47.     foreach($xd['data'] as $key)
  48.     {
  49.         if($key["cid"] == 2)
  50.         {
  51.  
  52.         $file = 'text.txt';
  53.         $options = array();
  54.         $channels = array();
  55.                 //$key['cid'] = $TAMTAID; //zamieniamy na clid na tego gracza
  56.                 $client = $tsAdmin->getElement('data', $tsAdmin->clientInfo($key['clid'])); //
  57.                 $client_cdbid = $client['client_database_id'];
  58.                 $client_name = $client['client_nickname'];
  59.                
  60.                 $keywords = explode(",", $client['client_servergroups']);
  61.                         if(!is_writable($file))
  62.                 {
  63.                     $handle = fopen($file, "w+");
  64.                     fclose($handle);
  65.                     echo "Tworzymy plik!";
  66.                     $current = file_get_contents($file);
  67.  
  68.                     $array = array();
  69.                     $channel_properties = array("channel_properties" => array());
  70.                     $channel_list = array("channel_list" => array());
  71.                    
  72.                     $file_data = array("channels_cid_order_start"=>21, "channels_cid_order"=>0, "channels_count"=>0, "channels_spacer"=>0, "channels_max"=>50);
  73.                    
  74.                     //$kocham2 = array("cid"=>"1", "cdbid"=>"2");
  75.                     //array_push($channel_list["channel_list"], $kocham2);
  76.                     $channel_properties["channel_properties"] = $file_data;
  77.                     $data = $channel_properties + $channel_list;
  78.                     $result = $array + $data;
  79.            
  80.            
  81.            
  82.                     $json = json_encode(($result), true);
  83.                     if(file_put_contents($file, $json)) echo "Zapisujemy dane:)";
  84.                 }
  85.                 $json_file = json_decode(file_get_contents($file), true);
  86.                 if(in_array(6, $keywords) || in_array(7, $keywords)) // sprawdzanie czy grasz ma rangi...
  87.                 {
  88.                 $channel_have_cid = false;
  89.                 foreach($json_file['channel_list'] as $key8 => $value8)
  90.                 {
  91.                     if($client_cdbid == $value8['cdbid'])
  92.                     {
  93.                         echo "Masz już kanał bydlaku!";
  94.                         $channel_have = true;
  95.                         $channel_have_cid = $value8['cid'];
  96.                         break;
  97.                     }
  98.                 }
  99.                 if(!$channel_have)
  100.                 {
  101.                
  102.                
  103.                
  104.                 //print_r($client);
  105.                
  106.                 print_r($json_file['channel_properties']);
  107.                
  108.                 foreach($json_file['channel_properties'] as $key1 => $value1)
  109.                 {
  110.                     $options[$key1] = $value1;
  111.                     echo "<br>$key1 => $value1";
  112.                 }
  113.  
  114.                 echo "<br>";
  115.                
  116.                
  117.                
  118.                 //$kocham3 = array("id"=>"NOWE", "cdbid"=>"2");
  119.                 //array_push($json_file["channel_list"], $kocham3);
  120.                 //print_r($json_file['channel_list']);
  121.                
  122.  
  123.                 if($options['channels_cid_order'] == 0)
  124.                     $options['channels_cid_order'] = $options['channels_cid_order_start'];
  125.                 $options['channels_count']++;
  126.                 $options['channels_spacer']++; // ladowanie spacera co 10 kanalow
  127.                
  128.                
  129.                 $channel_cid = $tsAdmin->channelCreate(array("channel_name"=> $options['channels_count'].".     »  ".$client_name." Random liczba:".rand(1, 100), "channel_order"=>$options['channels_cid_order'], "channel_flag_permanent"=>TRUE));
  130.                     $tsAdmin->channelCreate(array("channel_name"=>"1.", "cpid"=>$channel_cid['data']['cid'], "channel_flag_permanent"=>TRUE));
  131.                     $tsAdmin->channelCreate(array("channel_name"=>"2.", "cpid"=>$channel_cid['data']['cid'], "channel_flag_permanent"=>TRUE));
  132.                    
  133.                 $tsAdmin->clientMove($key['clid'], $channel_cid['data']['cid']);
  134.                 $tsAdmin->clientPoke($key['clid'], "masz juz kanal elo");
  135.                
  136.                
  137.                 $tsAdmin->channelGroupAddClient(5, $channel_cid['data']['cid'], $client_cdbid);
  138.                
  139.                 $order = $channel_cid['data']['cid'];
  140.                 if($options['channels_spacer'] == 10)
  141.                 {
  142.                     $spacer_cid = $tsAdmin->channelCreate(array("channel_name"=> "[cspacer".rand(1000, 1000000)."]━━━◥◣◆◢◤━━━", "channel_order"=>$channel_cid['data']['cid'], "channel_flag_permanent"=>TRUE));
  143.                     $order = $spacer_cid['data']['cid'];
  144.                     $options['channels_spacer'] = 0;
  145.                 }
  146.            
  147.             $json_file['channel_properties']['channels_cid_order_start'] = $options['channels_cid_order_start'];
  148.             $json_file['channel_properties']['channels_cid_order'] = $order;
  149.             $json_file['channel_properties']['channels_count'] = $options['channels_count'];
  150.             $json_file['channel_properties']['channels_spacer'] = $options['channels_spacer'];
  151.             $json_file['channel_properties']['channels_max'] = $options['channels_max'];
  152.             echo "<br>";
  153.             echo "<br>";
  154.  
  155.             print_r($json_file);
  156.             file_put_contents($file, "");
  157.            
  158.            
  159.             $channel_list_add = array("cid"=>$channel_cid['data']['cid'], "cdbid"=>$client_cdbid);
  160.             array_push($json_file["channel_list"], $channel_list_add);
  161.             $jsonsss = json_encode($json_file, true);
  162.             if(file_put_contents($file, $jsonsss)) echo "<b>ZAPISUJEMY DANE!!!</b>";
  163.            
  164.             /*
  165.             $current1 = file_get_contents($file);
  166.             $current1 = array("channels_cid_order_start"=>$options['channels_cid_order_start'], "channels_cid_order"=>$order, "channels_count"=>$options['channels_count'], "channels_spacer"=>$options['channels_spacer'], "channels_max"=>50);
  167.             $json1 = json_encode($current1);
  168.             if(file_put_contents($file, $json1)) echo "<b>ZAPISUJEMY DANE!!!</b>";
  169.             */
  170.                 }else {
  171.                     //$tsAdmin->clientKick($key['clid'], $kickMode = "channel", $kickmsg = "MASZ KURWA KANAL");      //  MASZ JUŻ KANAL!!!
  172.                     // lub movamy...
  173.                     $tsAdmin->clientMove($key['clid'], $channel_have_cid);
  174.                     // lub poke
  175.                     $tsAdmin->clientPoke($key['clid'],$msg="XD");
  176.                 }
  177.             }else{ //jezeli nie ma to go wyrzuci
  178.                 echo "typek nie ma rangi";
  179.                 $tsAdmin->clientKick($key['clid'], $kickMode = "channel", $kickmsg = "NIE MASZ KURWA RANGI");        // JEZELI NIE MA RANGI KICK!!!
  180.                 $tsAdmin->sendMessage(1, $target = $key['clid'], "Nie masz odpowiednich rang żeby móc zakładać kanały!!"); // LUB WIADOMOSC
  181.        
  182.             }
  183.         }
  184.     }
  185.  
  186. }else{
  187.     echo 'Connection could not be established.';
  188. }
  189.  
  190.  
  191. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement