コード例 #1
0
ファイル: plugins.class.php プロジェクト: Geolim4/Leelabot
 public function pluginList($data)
 {
     //Computing server list for each plugin
     $servers = array();
     foreach (Leelabot::$instance->plugins->getInfoFromFiles() as $plugin) {
         $servers[$plugin['name']] = array();
     }
     foreach (ServerList::getList() as $servername) {
         $server = ServerList::getServer($servername);
         $list = $server->getPlugins();
         foreach ($list as $p) {
             if (!isset($servers[$p])) {
                 $servers[$p] = array();
             }
             $servers[$p][] = $servername;
         }
     }
     foreach ($servers as &$s) {
         if (empty($s)) {
             $s = 'Not used';
         } else {
             $s = join(', ', $s);
         }
     }
     $this->_dispatcher->parser->assign('plugins', Leelabot::$instance->plugins->getInfoFromFiles());
     $this->_dispatcher->parser->assign('loaded', Leelabot::$instance->plugins->getLoadedPlugins());
     $this->_dispatcher->parser->assign('servers', $servers);
     return $this->_dispatcher->parser->draw('plugins');
 }
コード例 #2
0
 public function onReadyToReceive()
 {
     print "Something received from UDP\n";
     $datalen = @socket_recvfrom($this->_socket, $data, 1500, 0, $fromip, $fromport);
     while ($datalen > 0) {
         $srvdata = ServerList::getServer($fromip, $fromport);
         if ($srvdata === NULL) {
             print "Received UDP packet from unknown server: {$fromip}:{$fromport}\n";
         } else {
             print "Received UDP packet from {$fromip}:{$fromport}\n";
             $srvdata->touch();
         }
         $datalen = @socket_recvfrom($udpsock, $data, 1500, 0, $fromip, $fromport);
     }
 }
コード例 #3
0
ファイル: dummy.php プロジェクト: Geolim4/Leelabot
 public function CommandHold($player, $command)
 {
     if (ServerList::serverEnabled($command[0])) {
         ServerList::getServer($command[0])->hold();
     }
 }
コード例 #4
0
ファイル: messages.php プロジェクト: Geolim4/Leelabot
 private function _removeMessage($id, $serv = NULL)
 {
     if ($serv === NULL) {
         $server = Server::getInstance();
     } else {
         $server = ServerList::getServer($serv);
     }
     $_messages = $server->get('msgs');
     unset($_messages[$id]);
     $server->set('msgs', $_messages);
 }
コード例 #5
0
ファイル: stats.php プロジェクト: Geolim4/Leelabot
 /** Destroy function. Unloads the plugin properly.
  * This function cleans properly the plugin when it is unloaded.
  * 
  * \return Nothing.
  */
 public function destroy()
 {
     //We browse all servers
     $servers = ServerList::getList();
     foreach ($servers as $serv) {
         $server = ServerList::getServer($serv);
         $rcon = ServerList::getServerRCon($serv);
         $rcon->say("Stats stopped by plugin unload.");
         $server->set('stats', NULL);
         $server->set('statsConfig', NULL);
         $server->set('awards', NULL);
         $server->set('ratioList', NULL);
         $server->set('disableStatsReset', NULL);
     }
 }
コード例 #6
0
 private function handleQuitCommand($attributes)
 {
     if (!isset($attributes['port']) || $attributes['port'] < 1 || $attributes['port'] > 65535) {
         $this->sendError("Wrong port for quit");
     } else {
         $srvinfo = ServerList::getServer($this->ip, $attributes['port']);
         if (isset($srvinfo)) {
             socket_write($this->_socket, "\\final\\");
             ServerList::removeServer($this->ip, $attributes['port']);
         }
     }
     $this->removeme = true;
 }
コード例 #7
0
ファイル: adminbase.php プロジェクト: Geolim4/Leelabot
 public function WSMethodWhois($server, $id)
 {
     if (!ServerList::serverEnabled($server)) {
         throw new WebserviceException('Server not found');
     }
     if (($player = ServerList::getServer($server)->getPlayer($id)) == NULL) {
         throw new WebserviceException('No player found');
     }
     $data = array('name' => $player->name, 'addr' => $player->addr, 'level' => $player->level, 'host' => gethostbyaddr($player->addr));
     return $data;
 }
コード例 #8
0
ファイル: warns.php プロジェクト: Geolim4/Leelabot
 public function RoutineWarns()
 {
     // We browse all servers
     $servers = ServerList::getList();
     foreach ($servers as $serv) {
         $server = ServerList::getServer($serv);
         $rcon = ServerList::getServerRCon($serv);
         $_warns = $server->get('warns');
         if (count($_warns)) {
             foreach ($_warns as $player => $warns) {
                 if ($warns['num'] >= $this->config['WarnsKick'] && time() >= $warns['last'] + $this->config['SecondsBeforeKick']) {
                     $rcon->tell($player, 'You have $warns warnings. You will be kicked', array('warns' => $warns['num']));
                     $this->_clearWarn($player, $server);
                     $rcon->kick($player);
                 }
             }
         }
     }
 }