示例#1
0
 public static function get_information(&$ircdata)
 {
     if (isset($ircdata[0]) && $ircdata[0] == 'CAPAB' && $ircdata[1] == 'MODULES') {
         if (strpos($ircdata[2], 'm_services_account.so') === false) {
             timer::add(array('core', 'check_services', array()), 1, 1);
         } else {
             core::$services_account = true;
         }
         // we have services_account
         if (strpos($ircdata[2], 'm_globops.so') !== false) {
             self::$globops = true;
         }
         // we have globops!
         if (strpos($ircdata[2], 'm_chghost.so') !== false) {
             self::$chghost = true;
         }
         // we have chghost
         if (strpos($ircdata[2], 'm_chgident.so') !== false) {
             self::$chgident = true;
         }
         // and chgident
     }
     // only trigger when our modules info is coming through
     if (isset($ircdata[0]) && $ircdata[0] == 'CAPAB' && $ircdata[1] == 'CAPABILITIES') {
         $data = explode('=', $ircdata[16]);
         $data = $data[1];
         $new_mdata = isset($mdata) ? explode('=', $mdata) : '';
         $rmodes = '';
         if (strpos($data, 'q') !== false) {
             self::$owner = true;
             self::$status_modes[] .= 'q';
             $rmodes .= 'q';
         }
         // check if +q is there
         if (strpos($data, 'a') !== false) {
             self::$protect = true;
             self::$status_modes[] .= 'a';
             $rmodes .= 'a';
         }
         // and +a
         $hdata = implode(' ', $ircdata);
         if (strpos($hdata, 'HALFOP=1') !== false) {
             self::$halfop = true;
             self::$status_modes[] .= 'h';
             $rmodes .= 'h';
         }
         // we check halfop differently
         self::$status_modes[] .= 'o';
         self::$status_modes[] .= 'v';
         $modes = str_replace(',', '', $data);
         self::$modes = $rmodes . $modes . 'ov';
     }
     // only trigger when the capab capabilities is coming through
     return true;
 }
示例#2
0
 public static function unsuspend_command($nick, $ircdata = array())
 {
     $unick = core::get_nick(&$ircdata, 0);
     // get the nick etc.
     if (!core::$nicks[$nick]['ircop'] || services::user_exists($nick, true, array('display', 'identified')) === false) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ACCESS_DENIED);
         return false;
     }
     // they've gotta be identified and opered..
     if ($user = services::user_exists($unick, false, array('display', 'suspended', 'real_user'))) {
         if ($user->suspended == 0) {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_SUSPEND_4, array('nick' => $unick));
             return false;
         }
         // nick isn't suspended
         database::update('users', array('suspended' => 0, 'suspend_reason' => null), array('display', '=', $unick));
         if ($user->real_user == 0) {
             database::delete('users', array('display', '=', $unick));
         }
         // nick wasen't registered by a real person, drop it
     } else {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_SUSPEND_4, array('nick' => $unick));
         return false;
     }
     // nick isn't even registered.
     services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_SUSPEND_5, array('nick' => $unick));
     core::alog(core::$config->nickserv->nick . ': ' . $nick . ' UNSUSPENDED ' . $unick);
     ircd::globops(core::$config->nickserv->nick, $nick . ' UNSUSPENDED ' . $unick);
     // oh well, was fun while it lasted eh?
     // unsuspend it :P
 }
示例#3
0
 public static function _drop_check($nick, $chan)
 {
     if ($chan == '' || $chan[0] != '#') {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INVALID_SYNTAX_RE, array('help' => 'DROP'));
         return false;
         // wrong syntax
     }
     // make sure they've entered a channel
     if (services::chan_exists($chan, array('channel')) === false) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_UNREGISTERED_CHAN, array('chan' => $chan));
         return false;
     }
     // make sure the channel exists.
     if (chanserv::_is_founder($nick, $chan)) {
         return true;
     } elseif (core::$nicks[$nick]['ircop'] && services::user_exists($nick, true, array('display', 'identified'))) {
         ircd::globops(core::$config->chanserv->nick, $nick . ' used DROP on ' . $chan);
         return true;
     }
     services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
     return false;
     // do they have access?
 }
示例#4
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.
 }
示例#5
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);
     }
 }
示例#6
0
 public static function override_command($nick, $ircdata = array())
 {
     $mode = strtolower($ircdata[0]);
     if (services::is_root($nick)) {
         if (trim($mode) == '' || !in_array($mode, array('on', 'off'))) {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX_RE, array('help' => 'OVERRIDE'));
             return false;
         }
         // is the format correct?
         if ($mode == 'on') {
             if (core::$nicks[$nick]['override']) {
                 services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_OVERRIDE_IS_ON);
                 return false;
             }
             // override is already on..
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_OVERRIDE_ON);
             core::alog('override_command(): ' . $nick . ' is now using override mode.', 'BASIC');
             ircd::globops(core::$config->operserv->nick, $nick . ' is now using override mode.');
             // log and stuff
             core::$nicks[$nick]['override'] = true;
             return false;
         }
         // set override on
         if ($mode == 'off') {
             if (!core::$nicks[$nick]['override']) {
                 services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_OVERRIDE_IS_OFF);
                 return false;
             }
             // override isnt even on..
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_OVERRIDE_OFF);
             core::alog('override_command(): ' . $nick . ' has turned override mode off.', 'BASIC');
             ircd::globops(core::$config->operserv->nick, $nick . ' has turned override mode off.');
             // log and stuff
             core::$nicks[$nick]['override'] = false;
             return false;
         }
         // set override off
     } else {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_ACCESS_DENIED);
     }
     // are they root?
 }
示例#7
0
 public static function global_command($nick, $ircdata = array())
 {
     $mask = $ircdata[0];
     $message = core::get_data_after(&$ircdata, 1);
     if (trim($mask) == '' || trim($message) == '') {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX);
         return false;
     }
     // are they sending a message?
     if (strpos($mask, '@') === false) {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_GLOBAL_INVALID);
         return false;
     } else {
         if (strpos($mask, '!') === false) {
             $mask = '*!' . $mask;
         }
         // prepend the *! to the mask
     }
     // is the mask valid?
     if (core::$config->global->nick_on_global) {
         ircd::global_notice(core::$config->global->nick, $mask, '[' . $nick . '] ' . $message);
     } else {
         ircd::global_notice(core::$config->global->nick, $mask, $message);
     }
     // send the message!!
     ircd::globops(core::$config->operserv->nick, $nick . ' just used GLOBAL command.');
     // we globop the command being used.
 }
示例#8
0
 public static function mode_command($nick, $ircdata = array())
 {
     $channel = core::get_chan(&$ircdata, 0);
     $modes = core::get_data_after(&$ircdata, 1);
     // grab the parameters: nick; channel; reason (optional)
     if (trim($channel) == '') {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX_RE, array('help' => 'MODE'));
         return false;
     }
     // are we missing channel? invalid syntax if so.
     if (!isset(core::$chans[$channel])) {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_CHAN_INVALID, array('chan' => $channel));
         return false;
     }
     // does the channel exist?
     ircd::mode(core::$config->operserv->nick, $channel, $modes);
     ircd::globops(core::$config->operserv->nick, $nick . ' used MODE ' . $modes . ' on ' . $channel);
     // set the mode, globops it.
 }
示例#9
0
 public static function unsuspend_command($nick, $ircdata = array())
 {
     $chan = core::get_chan(&$ircdata, 0);
     // get the channel.
     if (!core::$nicks[$nick]['ircop'] || services::user_exists($nick, true, array('display', 'identified')) === false) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
         return false;
     }
     // they've gotta be identified.
     if ($chan == '' || $chan[0] != '#') {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INVALID_SYNTAX_RE, array('help' => 'UNSUSPEND'));
         return false;
         // wrong syntax
     }
     // make sure they've entered a channel
     if ($channel = services::chan_exists($chan, array('channel', 'suspended'))) {
         if ($channel->suspended == 0) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_SUSPEND_4, array('chan' => $chan));
             return false;
         }
         // channel isn't even suspended
         $check_row = database::select('chans_levels', array('channel'), array('channel', '=', $chan));
         if (database::num_rows($check_row) == 0) {
             database::delete('chans', array('channel', '=', $chan));
             database::delete('chans_flags', array('channel', '=', $chan));
         }
         // the channel has no access records, drop it.
     } else {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_SUSPEND_4, array('chan' => $chan));
         return false;
     }
     services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_SUSPEND_5, array('chan' => $chan));
     core::alog(core::$config->chanserv->nick . ': ' . $nick . ' UNSUSPENDED ' . $chan);
     ircd::globops(core::$config->chanserv->nick, $nick . ' UNSUSPENDED ' . $chan);
     // oh well, was fun while it lasted eh?
     // unsuspend it :P
 }