Dalexhd

commander.php

Oct 25th, 2017
387
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.87 KB | None | 0 0
  1. <?php
  2. include_once 'include/config.php';
  3. include_once 'include/ts3admin.class.php';
  4.  
  5. function commander()
  6. {
  7.     global $query;
  8.     global $config;
  9.  
  10.     $channels = $query->getElement('data', $query->channelList("-topic"));
  11.     foreach($channels as $channel)
  12.     {
  13.         if($channel['channel_topic'] == 'commander')
  14.         {
  15.             $wiadomosci = $query->readChatMessage('textchannel', false, $channel['cid']);
  16.             if(isset($wiadomosci['success']) && strlen($wiadomosci['data']['msg']) > 2)
  17.             {
  18.                 if($wiadomosci['success'] == 1)
  19.                 {
  20.                     if($wiadomosci['data']['msg']{0} == '!')
  21.                     {
  22.                         $wpisana_komenda = substr($wiadomosci['data']['msg'], 1);
  23.                         $command_arguments = explode(" ", $wpisana_komenda);
  24.  
  25.                         $user = $query->getElement('data', $query->clientInfo($wiadomosci['data']['invokerid']));
  26.                         $groups = explode(",", $user['client_servergroups']);
  27.  
  28.                         $client['client_nickname'] = $wiadomosci['data']['invokername'];
  29.                         $client['client_uid'] = $wiadomosci['data']['invokeruid'];
  30.                         $client['client_clid'] = $wiadomosci['data']['invokerid'];
  31.                         $client['client_cmd'] = $command_arguments[0];
  32.                         $client['client_params'] = $wpisana_komenda;
  33.  
  34.                         for($i=0; $i<count($config['commander']['commands_list']); $i++)
  35.                         {
  36.                             if($client['client_cmd'] == $config['commander']['commands_list'][$i])
  37.                             {
  38.                                 if(isInGroup($groups, $config['commander']['commands'][$config['commander']['commands_list'][$i]]['allowed_groups']))
  39.                                 {
  40.                                     echo 'Użytkownik '.$client['client_nickname'].' (clid: '.$client['client_clid'].') wywołał komendę: '.$client['client_cmd'].'' . PHP_EOL;
  41.                                     $funkcja = $wpisana_komenda;
  42.                                     $funkcja($client['client_clid'], $client['client_uid'], $client['client_nickname'], $client['client_params']);
  43.                                     break;
  44.                                 }
  45.                             }
  46.                         }
  47.                     }
  48.                 }
  49.             }
  50.         }
  51.     }
  52.  
  53.     unset($query);
  54.     unset($config);
  55. }
  56. ?>
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment