/** Web admin main page for the plugin. * This functions is triggered by the web admin when accessing the bans plugin area in the webadmin. * It will show a list of the last bans, along with the current banning stats. * * \param $data The data from the browser * * \return The page body */ public function WAPageIndex($data) { $parser = Webadmin::getTemplateParser(); $banlist = array(); foreach ($this->_banlist as $guid => $ban) { $banlist[$guid] = $ban; //$banlist[$guid]['End'] = $ban['Duration'] != 'forever' ? ($ban['Begin'] + $ban['Duration']) : Locales::translate('Forever'); $banlist[$guid]['Duration'] = $ban['Duration'] != 'forever' ? $this->_getDurationHumanRepresentation($ban['Duration']) : Locales::translate('Forever'); if ($ban['Realm'] == self::GLOBALBAN) { $banlist[$guid]['Realm'] = Locales::translate('Everywhere'); } else { $banlist[$guid]['Realm'] = str_replace('server:' . self::GLOBALBAN, self::GLOBALBAN, $ban['Realm']); } if (!$ban['Description']) { $banlist[$guid]['Description'] = Locales::translate('None'); } else { $banlist[$guid]['Description'] = $ban['Description']; } } $parser->assign('banlist', $banlist); $parser->assign('lastbans', $this->_extractBanlistSlice($banlist)); return $parser->draw('plugins/bans'); }
public function IrcHelp($pseudo, $channel, $cmd, $message) { $level = LeelaBotIrc::getLevel(trim($pseudo), $this->config['MainChannel']); if (!isset($cmd[1])) { $list = array(); $events = $this->_plugins->listEvents('irc'); ksort($events); // Alphabetical order foreach ($events as $event => $lvl) { if ($level >= $lvl) { $list[] = $event; } } LeelaBotIrc::sendMessage('List : ' . join(', ', $list) . '.'); } else { $cmd[1] = str_replace('!', '', $cmd[1]); if ($this->_plugins->eventExists('irc', $cmd[1])) { LeelaBotIrc::sendMessage('!' . $cmd[1] . ' : ' . Locales::translate('help_irc_' . $cmd[1])); //TODO : check if help of $cmd[1] command exist. } else { LeelaBotIrc::sendMessage("This command doesn't exist."); } } }
/** !help command. Get help and list of commands. * This function is the command !help. It get list of commands and help. * * \param $player The player who send the command. * \param $command The command's parameters. * * \return Nothing. */ public function CommandHelp($player, $command) { $list = Plugins::getCommandList(); $player = Server::getPlayer($player); if (empty($command[0])) { foreach ($list as $cmd => $level) { unset($list[$cmd]); if ($level <= $player->level) { $list['!' . $cmd] = $level; } } $list = implode(', ', array_keys($list)); Rcon::tell($player->id, 'List of commands : $list', array('list' => $list)); } else { $cmdHelp = strtolower(str_replace('!', '', $command[0])); //need into translate files for example : #id help_nextmap #to Return next map. Rcon::tell($player->id, '$cmd: ' . Locales::translate('help_' . $cmdHelp), array('cmd' => '!' . $cmdHelp), FALSE); } }
/** Gets info from plugins head comments. * This functions reads the information available on plugins from their head comments. Could be resource-hungry, use with caution. * * \return An array containing info for each plugin. */ public function getInfoFromFiles() { $files = scandir('plugins'); if ($files != $this->_pluginFiles) { $this->_pluginsInfo = array(); //Reading the plugins' directory foreach ($files as $f) { if (pathinfo($f, PATHINFO_EXTENSION) != 'php') { continue; } $name = pathinfo($f, PATHINFO_FILENAME); $this->_pluginsInfo[$f] = array('version' => '', 'file' => $f, 'author' => Locales::translate('Anonymous'), 'description' => '', 'name' => $name, 'dname' => ucfirst($name), 'dependencies' => Locales::translate('None')); $content = file_get_contents('plugins/' . $f); if (preg_match('#\\\\version (.+)\\r?\\n#isU', $content, $version)) { $this->_pluginsInfo[$f]['version'] = $version[1]; } if (preg_match('#\\\\file (.+)\\r?\\n#isU', $content, $file)) { $this->_pluginsInfo[$f]['file'] = $file[1]; } if (preg_match('#\\\\author (.+)\\r?\\n#isU', $content, $author)) { $this->_pluginsInfo[$f]['author'] = $author[1]; } if (preg_match('#\\\\brief (.+)\\r?\\n#isU', $content, $description)) { $this->_pluginsInfo[$f]['description'] = $description[1]; } if (preg_match('#\\\\depends (.+)\\r?\\n#isU', $content, $dependencies)) { $this->_pluginsInfo[$f]['dependencies'] = $dependencies[1]; } } $this->_pluginFiles = $files; } return $this->_pluginsInfo; }