Beispiel #1
0
 /** Bans a player.
  * This command bans the player passed in first parameter, and parses the other parameters to add modifiers to the ban :
  * \li from <server(s)> : Specifies the range of the ban : servers can be defined one by one by separating them with a space,
  * and the special keyword in PluginBans::GLOBALBAN can be used to make the ban bot-wide (if a server is named like that, you can use
  * server:<PluginBans::GLOBALBAN> to bypass that).
  * \li for <duration> : Specifies the duration of the ban. You can use numbers and modifiers to specify the duration (valid modifiers : 
  * second(s), minute(s), hour(s), day(s), week(s), month(s), year(s)).
  * \li forever : Makes the ban permanent. Can't be used with the "for" parameter.
  * 
  * If none parameter specified, the defaults from config file are taken. If a default duration or range is not specified in the config, 
  * the default applied are 1 day and the current server from which the command has been emitted.
  * 
  * Examples : 
  * \li Simple ban : !ban linkboss
  * \li Ban from only one server : !ban linkboss from myserver
  * \li Ban from multiple servers, including one server name <PluginBans::GLOBALBAN> : !ban linkboss from myserver, otherserver,
  * 		server:<PluginBans::GLOBALBAN>
  * \li Ban from all servers : !ban linkboss from <PluginBans::GLOBALBAN>
  * \li Ban for 1 month and a half : !ban linkboss for 1 month 2 weeks
  * \li Ban from one server during 1 day : !ban linkboss from myserver for 1 day
  * \li Permanent ban : !ban linkboss forever
  * 
  * \note
  * When you specify the ban duration, if you use 2 numbers one after another, their values will be additionned. For example :
  * \li !ban linkboss for 1 2 months
  * Will result of a 3 months ban. Also, if you use a non-recognized keyword between durations, only the last before a recognized keyword
  * will be used. For example :
  * \li !ban linkboss for 1 and 2 months
  * Will result of a 2 months ban. If you do not use any modifier at all, the default modifier applied is the day.
  * 
  * \param $id The player ID who used the command.
  * \param $command The command parameters.
  * 
  * \return Nothing.
  */
 public function CommandBan($id, $command)
 {
     $ban = $this->_parseBanCommand($command);
     $error = FALSE;
     if ($ban['duration'] != 'forever' && $ban['duration'] <= 0) {
         $error = 'Cannot ban for this duration.';
     }
     if (empty($ban['servers'])) {
         $error = 'Cannot ban from zero servers.';
     }
     if (empty($ban['banned'])) {
         $error = 'There is nobody to ban.';
     }
     if ($error !== FALSE) {
         RCon::tell($id, $error);
         return;
     }
     $banned = array();
     foreach ($ban['banned'] as $player) {
         $pid = Server::searchPlayer($player);
         if (is_array($pid)) {
             RCon::tell('Multiple results found for search $0 : $1', array($player, Server::getPlayerNames($pid)));
             continue;
         } elseif ($pid === FALSE) {
             RCon::tell('No player found for search $0.', array($player));
             continue;
         }
         //Adding the entry to the banlist
         $player = Server::getPlayer($pid);
         $banID = Leelabot::UUID();
         if ($ban['duration'] !== 'forever' && $ban['duration'] < $this->_durations['day'] && count($ban['servers']) == 1) {
             //GUID save
             $this->_banlist[$banID] = array('GUIDList' => array($player->guid), 'IP' => FALSE, 'Aliases' => array($player->name), 'Duration' => $ban['duration'], 'Begin' => time(), 'Realm' => join(',', $ban['servers']), 'Identifier' => $player->name, 'Description' => '');
         } elseif ($ban['duration'] !== 'forever' && $ban['duration'] < $this->_durations['month']) {
             $this->_banlist[$banID] = array('GUIDList' => array($player->guid), 'IP' => $player->ip, 'Aliases' => array($player->name), 'Duration' => $ban['duration'], 'Begin' => time(), 'Realm' => join(',', $ban['servers']), 'Identifier' => $player->name, 'Description' => '');
             if (!isset($this->_bannedIP[$player->ip])) {
                 $this->_bannedIP[$player->ip] = array();
             }
             $this->_bannedIP[$player->ip][] = $banID;
         } else {
             $ip = explode('.', $player->ip);
             array_pop($ip);
             $ip = join('.', $ip) . '.0';
             $this->_banlist[$banID] = array('GUIDList' => array($player->guid), 'IP' => $ip, 'Aliases' => array($player->name), 'Duration' => $ban['duration'], 'Begin' => time(), 'Realm' => join(',', $ban['servers']), 'Identifier' => $player->name, 'Description' => '');
             if (!isset($this->_bannedIP[$player->ip])) {
                 $this->_bannedIP[$player->ip] = array();
             }
             $this->_bannedIP[$ip] = $banID;
         }
         //Adding the alias for better GUID search
         if (!isset($this->_bannedGUID[$player->guid])) {
             $this->_bannedGUID[$player->guid] = array();
         }
         $this->_bannedGUID[$player->guid][] = $banID;
         //We save the banlist and we kick the player
         $this->saveBanlist();
         //We call the event
         $this->_plugins->callEventSimple('bans', 'new', $player->id, $banID);
         if (in_array(Server::getName(), $ban['servers']) || $ban['servers'][0] == self::GLOBALBAN) {
             //NEED TEST, CALL APERTURE SCIENCE
             RCon::kick($player->id);
         }
     }
 }
Beispiel #2
0
 public function WSMethodKickAll($server, $mask)
 {
     if (!ServerList::serverEnabled($server)) {
         throw new WebserviceException('Server not found');
     }
     $server = ServerList::getServer($server);
     $target = $server->searchPlayer($mask);
     if ($target === FALSE) {
         throw new WebserviceException('No player found.');
     } elseif (is_array($target)) {
         $players = array();
         $kick = true;
         foreach ($target as $p) {
             $kick = $kick && RCon::kick($p);
         }
         return $target;
     } else {
         return Leelabot::boolString(RCon::kick($target));
     }
 }