示例#1
0
 public function unloadPlugin($data)
 {
     $this->_dispatcher->disableDesign();
     //We disable the design, because of AJAX
     $this->_dispatcher->disableCache();
     //Disabling cache, to be sure to re-execute the request the next time
     //Returning the the bot's root, since we're in the webadmin root
     $cwd = getcwd();
     chdir(Leelabot::$instance->root);
     //Saving the loaded plugins before loading, so we can get the loaded plugins during operation
     $pluginsBefore = Leelabot::$instance->plugins->getLoadedPlugins();
     //Loading the plugin, and processing the result
     if (Leelabot::$instance->plugins->unloadPlugin($data['matches'][1])) {
         $ret = 'success:' . join('/', array_diff($pluginsBefore, Leelabot::$instance->plugins->getLoadedPlugins()));
     } else {
         $ret = 'error:' . Leelabot::lastError();
     }
     chdir($cwd);
     //Returning to the webadmin root.
     return $ret;
 }
示例#2
0
文件: bans.php 项目: Geolim4/Leelabot
 /** Loads the banlist.
  * This function takes the file pointed by Banlist parameter from the config and loads the banlist from it. It also indexes IPs
  * for a more efficient and less time-eating search for bans.
  * 
  * \return TRUE if the banlist loaded correctly, FALSE otherwise.
  */
 public function loadBanlist()
 {
     $contents = file_get_contents($this->_banlistLocation);
     if ($contents === FALSE) {
         Leelabot::message('Can\'t load banlist : $0', array(Leelabot::lastError()), E_WARNING);
         return FALSE;
     }
     $this->_banlist = Leelabot::parseINIStringRecursive($contents);
     if (!$this->_banlist) {
         $this->_banlist = array();
     }
     $this->_bannedIP = array();
     foreach ($this->_banlist as $banID => $ban) {
         if (isset($ban['IP'])) {
             if (!isset($this->_bannedIP[$ban['IP']])) {
                 $this->_bannedIP[$ban['IP']] = array();
             }
             $this->_bannedIP[$ban['IP']][] = $banID;
         }
     }
     $this->_bannedGUID = array();
     foreach ($this->_banlist as $banID => $ban) {
         foreach ($ban['GUIDList'] as $guid) {
             if (!isset($this->_bannedGUID[$guid])) {
                 $this->_bannedGUID[$guid] = array();
             }
             $this->_bannedGUID[$guid][] = $banID;
         }
     }
     return TRUE;
 }