Exemple #1
0
 public static function rehash_command($nick, $ircdata = array())
 {
     $parser = new parser(CONFPATH . 'services.conf');
     // load the parser
     $total_modules_exceptions = array();
     $mod_info = array('cs' => 'chanserv', 'ns' => 'nickserv', 'os' => 'operserv', 'core' => 'core');
     foreach ($mod_info as $short => $full) {
         $category_name = $full . '_modules';
         foreach (core::$config->{$category_name} as $id => $module) {
             $total_modules[$short . '_' . $module] = array('type' => $short, 'file' => $module . '.' . $short . '.php');
         }
     }
     // merge all the arrays to check that the loaded and excluded modules are all correct
     foreach (modules::$list as $name => $details) {
         if (!isset($total_modules[$name]) && $details['extra'] != 'static') {
             if (is_callable(array($name, 'modunload'), true) && method_exists($name, 'modunload')) {
                 modules::$list[$name]['class']->modunload();
             }
             // if the module has an unload method, call it now before we destroy the class.
             unset(modules::$list[$name]);
             modules::_unset_docs($name);
             // destory relevant data to the module
             core::alog(core::$config->operserv->nick . ': unloaded module ' . $name);
             ircd::globops(core::$config->operserv->nick, 'unloaded module ' . $name);
             // unset the module
             core::alog('rehash_command(): ' . $name . ' unloaded from rehash', 'BASIC');
             // log what we need to log.
         }
         // the module is loaded and should be unloaded
     }
     // go through each set module and unset the now exempt modules
     foreach ($total_modules as $name => $details) {
         if (!isset(modules::$list[$name])) {
             if (!class_exists($name)) {
                 modules::load_module($name, $details['file']);
                 // load the module
             } else {
                 if (!(modules::$list[$name]['class'] = new $name())) {
                     core::alog('load_module(): unable to start: ' . $name . ' (boot error)', 'BASIC');
                     return false;
                 }
             }
             core::alog(core::$config->operserv->nick . ': loaded module ' . $name);
             ircd::globops(core::$config->operserv->nick, 'loaded module ' . $name);
             // load it up
             core::alog('rehash_command(): ' . $name . ' loaded from rehash', 'BASIC');
             // log what we need to log.
             modules::$list[$name]['class']->modload();
             // onload handler.
         }
     }
     // go through every module
     // load the ones that are new.
     core::alog(core::$config->operserv->nick . ': Successfully reloaded configuration.');
     ircd::globops(core::$config->operserv->nick, $nick . ' performed a REHASH');
     core::alog('rehash_command(): sucessful rehash', 'BASIC');
     // log what we need to log.
 }
Exemple #2
0
 public function modunload_command($nick, $ircdata = array())
 {
     $module = $ircdata[0];
     // get the module thats been requested.
     if (services::is_root($nick)) {
         if (trim($module) == '') {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX_RE, array('help' => 'MODUNLOAD'));
             // wrong syntax
             return false;
         }
         if (!isset(modules::$list[$module])) {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_MODUNLOAD_1, array('name' => $module));
             return false;
         }
         if (modules::$list[$module]['extra'] == 'static') {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_MODUNLOAD_2, array('name' => $module));
             core::alog(core::$config->operserv->nick . ': unable to unload static module ' . $module);
             core::alog('modunload_command(): unable to unload static module ' . $module . ' (cannot be unloaded)', 'BASIC');
             // log what we need to log.
             return false;
         }
         if (!class_exists($module)) {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_MODUNLOAD_2, array('name' => $module));
             core::alog(core::$config->operserv->nick . ': unable to unload module ' . $module);
             core::alog('modunload_command(): unable to unload module ' . $module . ' (not booted)', 'BASIC');
             // log what we need to log.
             return false;
         }
         if (is_callable(array($module, 'modunload'), true) && method_exists($module, 'modunload')) {
             modules::$list[$module]['class']->modunload();
         }
         // if the module has an unload method, call it now before we destroy the class.
         unset(modules::$list[$module]);
         // unset the module
         modules::_unset_docs($module);
         // unset the modules help docs etc.
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_MODUNLOAD_3, array('name' => $module));
         core::alog(core::$config->operserv->nick . ': unloaded module ' . $module);
         ircd::globops(core::$config->operserv->nick, $nick . ' unloaded module ' . $module);
         // let everyone know :D
     } else {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_ACCESS_DENIED);
     }
 }