Dalexhd

autopoke.php

Oct 25th, 2017
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.60 KB | None | 0 0
  1. <?php
  2. include_once 'include/config.php';
  3. include_once 'include/ts3admin.class.php';
  4.  
  5. function autopoke()
  6. {
  7.     global $query;
  8.     global $config;
  9.     global $interval;
  10.    
  11.     $cache   = array();
  12.     $welcome = array();
  13.    
  14.     $users = $query->getElement('data', $query->clientList('-groups -voice -away -times'));
  15.    
  16.     $pokes  = array();
  17.     $admins = array();
  18.    
  19.     foreach ($users as $client)
  20.     {
  21.         if ($client['client_nickname'] != $config['bot']['name'])
  22.         {
  23.             $user_groups = explode(',', $client['client_servergroups']);
  24.            
  25.             if (isInGroup($user_groups, $config['autopoke']['admins_groups']) && !in_array($client['clid'], $cache))
  26.             {
  27.                 $admins[$client['clid']] = $user_groups;
  28.             }
  29.            
  30.             if (array_key_exists($client['cid'], $config['autopoke']['messages']) && !isInGroup($user_groups, $config['autopoke']['admins_groups']) && !$client['client_is_talker'])
  31.             {
  32.                
  33.                 $pokes[] = $client['cid'];
  34.                
  35.                 //priv dla usera
  36.                 if (!in_array($client['clid'], $cache))
  37.                 {
  38.                     $msg = file_get_contents($config['autopoke']['user_poke_path'], "r");
  39.                     $query->sendMessage(1, $client['clid'], $msg);
  40.                     $cache[time() - 1] = $client['clid'];
  41.                 }
  42.             }
  43.         }
  44.     }
  45.    
  46.     $counter = 0;
  47.     foreach ($pokes as $poke)
  48.     {
  49.         foreach ($admins as $clid => $admin)
  50.         {
  51.             if (isInGroup($admin, $config['autopoke']['messages'][$poke]['groups']))
  52.             {
  53.                 if (!in_array($clid, $cache))
  54.                 {
  55.                     $cache[time() + $counter] = $clid;
  56.                     $msg2 = file_get_contents($config['autopoke']['admin_poke_path'], "r");
  57.                     $query->clientPoke($clid, $msg2);
  58.                     $counter++;
  59.                 }
  60.             }
  61.         }
  62.     }
  63.    
  64.     foreach ($cache as $time => $user)
  65.     {
  66.         if (time() - $time > $interval)
  67.         {
  68.             unset($cache[$time]);
  69.         }
  70.     }
  71.    
  72.     if (date('H') == '23')
  73.     {
  74.         foreach ($welcome as $time => $user)
  75.         {
  76.             if (time() - $time > 60 * 60 * 24)
  77.             {
  78.                 unset($welcome[$time]);
  79.             }
  80.         }
  81.     }
  82.    
  83.     unset($query);
  84.     unset($config);
  85.     unset($interval);
  86.    
  87.     unset($cache);
  88.     unset($welcome);
  89.    
  90.     unset($users);
  91.    
  92.     unset($pokes);
  93.     unset($admins);
  94. }
  95.  
  96. ?>
Advertisement
Add Comment
Please, Sign In to add comment