Пример #1
0
 public static function join_logchan()
 {
     ircd::join_chan(core::$config->global->nick, core::$config->settings->logchan);
     // join the logchan
     core::alog('Now sending log messages to ' . core::$config->settings->logchan);
     // tell the chan we're logging shit.
 }
Пример #2
0
 public static function drop_command($nick, $ircdata = array())
 {
     $chan = core::get_chan(&$ircdata, 0);
     // get the channel.
     if (self::_drop_check($nick, $chan) === false) {
         return false;
     }
     // do nessicary checks
     if ($channel = services::chan_exists($chan, array('channel', 'suspended'))) {
         if ($channel->suspended == 1) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_SUSPEND_1, array('chan' => $chan));
             return false;
         }
     }
     // is the channel suspended?
     database::delete('chans', array('channel', '=', $chan));
     database::delete('chans_levels', array('channel', '=', $chan));
     // delete all associated records
     services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_CHAN_DROPPED, array('chan' => $chan));
     // let the user know
     if (isset(core::$chans[$chan])) {
         ircd::part_chan(core::$config->chanserv->nick, $chan);
         // now lets leave the channel if we're in it
     }
     // is the channel in existance? if so unregister mode
     // remember we DON'T unset the channel record, because the channel
     // is still there, just isnt registered, completely different things
     core::alog(core::$config->chanserv->nick . ': ' . $chan . ' has been dropped by ' . core::get_full_hostname($nick));
     // logchan it
     core::alog('drop_command(): ' . $chan . ' has been dropped by ' . core::get_full_hostname($nick), 'BASIC');
     // log what we need to log.
 }
Пример #3
0
 public static function ghost_command($nick, $ircdata = array())
 {
     $unick = $ircdata[0];
     $password = $ircdata[1];
     // get the parameters.
     if (trim($unick) == '' || trim($password) == '') {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_SYNTAX_RE, array('help' => 'GHOST'));
         return false;
     }
     // invalid syntax
     if (!isset(core::$nicks[$unick])) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_NOT_IN_USE, array('nick' => $unick));
         return false;
         // nickname isn't in use
     }
     if ($user = services::user_exists($unick, false, array('display', 'pass', 'salt'))) {
         if ($user->pass == sha1($password . $user->salt) || core::$nicks[$nick]['ircop'] && services::user_exists($nick, true, array('display', 'identified')) !== false) {
             ircd::kill(core::$config->nickserv->nick, $unick, 'GHOST command used by ' . core::get_full_hostname($nick));
             core::alog(core::$config->nickserv->nick . ': GHOST command used on ' . $unick . ' by ' . core::get_full_hostname($nick));
         } else {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_PASSWORD);
             // password isn't correct
         }
     } else {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ISNT_REGISTERED, array('nick' => $unick));
         return false;
         // doesn't even exist..
     }
 }
Пример #4
0
 public static function register_command($nick, $ircdata = array())
 {
     $chan = core::get_chan(&$ircdata, 0);
     $desc = core::get_data_after(&$ircdata, 1);
     // get the channel.
     if ($user = services::user_exists($nick, true, array('display', 'id'))) {
         if (trim($desc) == '' || $chan == '' || $chan[0] != '#' || stristr($channel, ' ')) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INVALID_SYNTAX_RE, array('help' => 'INFO'));
             // wrong syntax
             return false;
         }
         if (services::chan_exists($chan, array('channel')) !== false) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_REGISTERED_CHAN, array('chan' => $chan));
             return false;
         }
         // check if its registered?
         if (!strstr(core::$chans[$chan]['users'][$nick], 'o')) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_NEED_CHAN_OP, array('chan' => $chan));
             return false;
         }
         // we need to check if the user trying to register it has +o
         // if not we tell them to GET IT!
         $chan_info = array('channel' => $chan, 'timestamp' => core::$network_time, 'last_timestamp' => core::$network_time, 'topic' => core::$chans[$chan]['topic'], 'topic_setter' => core::$chans[$chan]['topic_setter']);
         $rflags = core::$config->chanserv->default_flags;
         $rflags = str_replace('d', '', $rflags);
         $rflags = str_replace('u', '', $rflags);
         $rflags = str_replace('e', '', $rflags);
         $rflags = str_replace('w', '', $rflags);
         $rflags = str_replace('m', '', $rflags);
         $rflags = str_replace('t', '', $rflags);
         // ignore parameter flags
         database::insert('chans', $chan_info);
         database::insert('chans_levels', array('channel' => $chan, 'target' => $user->display, 'flags' => 'Ftfrsqao'));
         database::insert('chans_flags', array('channel' => $chan, 'flags' => $rflags . 'd', 'desc' => $desc));
         // create the channel! WOOOH
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_CHAN_REGISTERED, array('chan' => $chan));
         core::alog(core::$config->chanserv->nick . ': ' . $chan . ' registered by ' . core::get_full_hostname($nick));
         // logchan
         core::alog('register_command(): ' . $chan . ' registered by ' . core::get_full_hostname($nick), 'BASIC');
         // log what we need to log.
         if ($channel = services::chan_exists($chan, array('channel', 'topic', 'suspended'))) {
             chanserv::_join_channel(&$channel);
             // join the channel
         }
         // does the channel exist?
     } else {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_UNREGISTERED);
         return false;
         // ph00s aint even registered..
     }
 }
Пример #5
0
 public static function factory($driver)
 {
     if (require BASEPATH . '/core/drivers/' . $driver . '.php') {
         core::alog('factory(): using ' . $driver . ' database driver', 'BASIC');
         self::$driver = new $driver();
         // store the instance here
     } else {
         core::alog('factory(): failed to open ' . $driver . ' database driver', 'BASIC');
         core::save_logs();
         // force a log save
     }
     // see if we can require the file
     // if so initiate the class
     // if not, bail.
 }
Пример #6
0
 public static function load_module($module_name, $module_file)
 {
     if (!(require BASEPATH . '/modules/' . $module_file)) {
         core::alog('load_module(): unable to load: ' . $module_name . ' (not found)', 'BASIC');
         return false;
     }
     // module doesn't exist, log it
     if (!(self::$list[$module_name]['class'] = new $module_name())) {
         core::alog('load_module(): unable to start: ' . $module_name . ' (boot error)', 'BASIC');
         return false;
     }
     // module failed to start
     self::$list[$module_name]['class']->modload();
     // onload handler.
 }
Пример #7
0
 public static function drop_command($nick, $ircdata = array())
 {
     $unick = core::get_nick(&$ircdata, 0);
     $password = $ircdata[1];
     // get the nick.
     if (trim($unick) == '' || trim($password) == '' && (!core::$nicks[$nick]['ircop'] || services::user_exists($nick, true, array('display', 'identified')) === false)) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_SYNTAX_RE, array('help' => 'DROP'));
         return false;
     }
     // invalid syntax
     if (services::is_root($unick) && !services::is_root($nick)) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ACCESS_DENIED);
         return false;
     }
     // is a non-root trying to drop a root?
     if ($user = services::user_exists($unick, false, array('id', 'display', 'pass', 'salt', 'suspended'))) {
         if ($user->suspended == 1) {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_SUSPEND_1, array('nick' => $user->display));
             return false;
         }
         // are they suspended?
         if ($user->pass == sha1($password . $user->salt) || core::$nicks[$nick]['ircop'] && services::user_exists($nick, true, array('display', 'identified')) !== false) {
             database::delete('users', array('display', '=', $user->display));
             database::delete('users_flags', array('nickname', '=', $user->display));
             // delete the users record
             database::delete('chans_levels', array('target', '=', $user->display));
             // also delete this users channel access.
             core::alog(core::$config->nickserv->nick . ': ' . $user->display . ' has been dropped by ' . core::get_full_hostname($nick));
             // logchan it
             core::alog('drop_command(): ' . $user->display . ' has been dropped by ' . core::get_full_hostname($nick), 'BASIC');
             // log what we need to log.
             if (isset(core::$nicks[$user->display])) {
                 ircd::on_user_logout($nick->display);
             }
             // if the nick is being used unregister it, even though it shouldn't be?
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_NICK_DROPPED, array('nick' => $user->display));
             // let the nick know the account has been dropped.
         } else {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_PASSWORD);
             // password isn't correct
         }
     } else {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ISNT_REGISTERED, array('nick' => $unick));
         return false;
         // doesn't even exist..
     }
 }
Пример #8
0
 public static function remove($execution)
 {
     // NOTE: params in $execution, should be an array
     if (!is_array($execution) || !count($execution) >= 2) {
         core::alog('add(): invalid format for first parameter, timer pushed back', 'BASIC');
         return false;
     }
     // is the format correct
     foreach (self::$timers as $tid => $data) {
         if ($data['class'] == $execution[0] && $data['method'] == $execution[1] && $data['params'] == $execution[2]) {
             unset(self::$timers[$tid]);
             core::alog('remove(): ' . $execution[0] . '::' . $execution[1] . '() overridden and removed before finish.', 'BASIC');
             break;
         }
     }
     // find a match.
 }
Пример #9
0
 public static function chanclear_command($nick, $ircdata = array())
 {
     $chan = core::get_chan(&$ircdata, 1);
     $reason = core::get_data_after(&$ircdata, 2);
     $mode = strtoupper($ircdata[0]);
     // get the data.
     if (trim($chan) == '' || trim($reason) == '' || !in_array($mode, array('KICK', 'KILL', 'GLINE'))) {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX_RE, array('help' => 'CHANCLEAR'));
         return false;
         // wrong syntax
     }
     if ($chan[0] != '#') {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX_RE, array('help' => 'CHANCLEAR'));
         return false;
         // wrong syntax
     }
     if (isset(core::$chans[$chan])) {
         foreach (core::$chans[$chan]['users'] as $user => $umode) {
             if (core::$nicks[$user]['ircop']) {
                 core::alog(core::$config->operserv->nick . ': Ignoring IRC Operator (' . $user . ')');
                 // ignore irc operator, infact, logchan it too
             } else {
                 if ($mode == 'KICK') {
                     ircd::kick(core::$config->operserv->nick, $user, $chan, 'CHANKILL by ' . $nick . ' (' . $reason . ')');
                     ircd::mode(core::$config->operserv->nick, $chan, '+b *@' . core::$nicks[$user]['host']);
                     // kick and +b them
                 } elseif ($mode == 'KILL') {
                     ircd::kill(core::$config->operserv->nick, $user, 'CHANKILL by ' . $nick . ' (' . $reason . ')');
                 } elseif ($mode == 'GLINE') {
                     ircd::gline(core::$config->operserv->nick, '*@' . core::$nicks[$user]['oldhost'], 604800, 'CHANKILL by ' . $nick . ' (' . $reason . ')');
                 }
                 // remove all other users.
             }
         }
         // loop through the people in the channel/
     } else {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_CHAN_INVALID, array('chan' => $chan));
     }
     // check if the channel is in use..
 }
Пример #10
0
 public static function logout_command($nick, $ircdata = array())
 {
     // no parameter commands ftw.
     if ($user = services::user_exists($nick, false, array('display', 'id', 'identified', 'vhost'))) {
         if ($user->identified == 1) {
             ircd::on_user_logout($nick);
             // here we set unregistered mode
             database::update('users', array('identified' => 0, 'last_timestamp' => core::$network_time), array('display', '=', $nick));
             // unidentify them
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_LOGGED_OUT);
             // let them know
             core::alog(core::$config->nickserv->nick . ': ' . core::get_full_hostname($nick) . ' logged out of ' . core::$nicks[$nick]['nick']);
             // and log it.
         } else {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_NOT_IDENTIFIED);
             // not even identified
         }
     } else {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_UNREGISTERED);
         // unregistered nick name
     }
 }
Пример #11
0
 public static function vhost_command($nick, $ircdata = array())
 {
     $mode = $ircdata[0];
     if (strtolower($mode) == 'set') {
         $host = $ircdata[2];
         $unick = $ircdata[1];
         // some variables.
         if (trim($unick) == '') {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX_RE, array('help' => 'VHOST'));
             return false;
         }
         // are we missing nick? invalid syntax if so.
         if (!($user = services::user_exists($unick, false, array('display', 'id', 'identified', 'vhost')))) {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_ISNT_REGISTERED, array('nick' => $unick));
             return false;
         }
         // is the nick registered?
         if (substr_count($host, '@') == 1) {
             $realhost = $host;
             $new_host = explode('@', $host);
             $ident = $new_host[0];
             $host = $new_host[1];
         } elseif (substr_count($host, '@') > 1) {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_HOSTNAME);
             return false;
         } else {
             $realhost = $host;
         }
         // check if there is a @
         if (services::valid_host($host) === false) {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_HOSTNAME);
             return false;
         }
         // is the hostname valid?
         database::update('users', array('vhost' => $realhost), array('display', '=', $user->display));
         core::alog(core::$config->operserv->nick . ': vHost for ' . $unick . ' set to ' . $realhost . ' by ' . $nick);
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_VHOST_SET, array('nick' => $unick, 'host' => $realhost));
         // update it and log it
         if (isset(core::$nicks[$unick]) && $user->identified == 1) {
             if (substr_count($realhost, '@') == 1) {
                 ircd::setident(core::$config->operserv->nick, $unick, $ident);
                 ircd::sethost(core::$config->operserv->nick, $unick, $host);
             } else {
                 ircd::sethost(core::$config->operserv->nick, $unick, $host);
             }
         }
         // we need to check if the user is online and identified?
     } elseif (strtolower($mode) == 'del') {
         $unick = $ircdata[1];
         // some variables.
         if (trim($unick) == '') {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX_RE, array('help' => 'VHOST'));
             return false;
         }
         // are we missing nick? invalid syntax if so.
         if (!($user = services::user_exists($unick, false, array('display', 'id', 'identified', 'vhost')))) {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_ISNT_REGISTERED, array('nick' => $unick));
             return false;
         }
         // is the nick registered?
         if ($user->vhost == '') {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_NO_VHOST, array('nick' => $unick));
             return false;
         }
         // is there a vhost?!
         database::update('users', array('vhost' => ''), array('display', '=', $user->display));
         core::alog(core::$config->operserv->nick . ': vHost for ' . $unick . ' deleted by ' . $nick);
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_VHOST_DELETED, array('nick' => $unick));
         // update and logchan
     } elseif (strtolower($mode) == 'list') {
         $limit = $ircdata[1];
         // get limit.
         if (trim($limit) == '') {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX_RE, array('help' => 'VHOST'));
             return false;
         }
         // invalid syntax
         if (!preg_match('/([0-9]+)\\-([0-9]+)/i', $limit)) {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX_RE, array('help' => 'VHOST'));
             return false;
         }
         // invalid syntax
         $total = database::select('users', array('id'), array('vhost', '!=', ''));
         $total = database::num_rows($total);
         // get the total
         $limit = database::quote($limit);
         $s_limit = explode('-', $limit);
         $offset = $s_limit[0];
         $max = $s_limit[1];
         // split up the limit and stuff ^_^
         $users_q = database::select('users', array('display', 'vhost'), array('vhost', '!=', ''), '', array($offset => $max));
         // get the vhosts
         if (database::num_rows($users_q) == 0) {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_VHOST_LIST_B, array('num' => database::num_rows($users_q), 'total' => $total));
             return false;
         }
         // no vhosts
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_VHOST_LIST_T);
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_VHOST_LIST_T2);
         // list top.
         while ($users = database::fetch($users_q)) {
             $false_nick = $users->display;
             if (!isset($users->display[18])) {
                 $y = strlen($users->display);
                 for ($i = $y; $i <= 17; $i++) {
                     $false_nick .= ' ';
                 }
             }
             // this is just a bit of fancy fancy, so everything displays neat
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_VHOST_LIST_R, array('nick' => $false_nick, 'info' => $users->vhost));
         }
         // loop through em, show the vhosts
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_VHOST_LIST_B, array('num' => database::num_rows($users_q) == 0 ? 0 : database::num_rows($users_q), 'total' => $total));
         // end of list.
     } else {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX_RE, array('help' => 'VHOST'));
         return false;
         // invalid syntax.
     }
 }
Пример #12
0
 public static function confirm_command($nick, $ircdata = array())
 {
     $code = $ircdata[0];
     if (trim($code) == '') {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_SYNTAX_RE, array('help' => 'CONFIRM'));
         return false;
     }
     // wrong syntax
     if (!($user = services::user_exists($nick, false, array('display', 'id')))) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_UNREGISTERED);
         return false;
     }
     // unregistered
     $code_array = database::select('validation_codes', array('nick', 'code'), array('nick', '=', $nick, 'AND', 'code', '=', $code));
     if (database::num_rows($code_array) == 0) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_PASSCODE);
     } else {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_VALIDATED);
         // let them know.
         database::update('users', array('validated' => 1), array('id', '=', $user->id));
         // user is now validated.
         database::delete('validation_codes', array('nick', '=', $nick, 'AND', 'code', '=', $code));
         // delete the code now that we've validated them
         core::alog(core::$config->nickserv->nick . ': ' . $nick . ' activated');
         // logchan
     }
     // no passcode found
 }
Пример #13
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);
     }
 }
Пример #14
0
 public function main(&$ircdata, $startup = false)
 {
     foreach (modules::$list as $module => $data) {
         if ($data['type'] == 'operserv') {
             modules::$list[$module]['class']->main(&$ircdata, $startup);
             // loop through the modules for operserv.
         }
     }
     if (ircd::on_msg(&$ircdata, core::$config->operserv->nick)) {
         $nick = core::get_nick(&$ircdata, 0);
         $command = substr(core::get_data_after(&$ircdata, 3), 1);
         // convert to lower case because all the tingy wags are in lowercase
         core::alog(core::$config->operserv->nick . ': ' . $nick . ': ' . $command);
         // logchan it
         if (core::$nicks[$nick]['ircop'] && services::user_exists($nick, true, array('display', 'identified') !== false)) {
             self::get_command($nick, $command);
         } else {
             services::communicate(core::$config->operserv->nick, $nick, &self::$help->OS_DENIED_ACCESS);
         }
         // theyre an oper.
     }
     // this is what we use to handle command listens
     // should be quite epic.
 }
Пример #15
0
 public static function get_command($hook, &$nick, &$command)
 {
     // this works better than i imagined
     if (services::check_mask_ignore($nick) === true) {
         return false;
     }
     // this is basically to check if we have
     // an ignored user, via their hostmask, or their nickname.
     if ($hook == 'chanserv') {
         $bot = core::$config->chanserv->nick;
     }
     if ($hook == 'nickserv') {
         $bot = core::$config->nickserv->nick;
     }
     if ($hook == 'operserv') {
         $bot = core::$config->operserv->nick;
     }
     // what we sending from?
     $command = trim($command);
     $commands = explode(' ', $command);
     $num_cmds = count($commands);
     $commands_r = $commands;
     // some vars..
     if (strtolower($commands[0]) == 'help' || $command == '' || substr($commands[0], 0, 1) == '') {
         return false;
     }
     // its a command we don't need to deal with, ignore it
     for ($i = $num_cmds; $i > -1; $i--) {
         unset($commands[$i]);
         $new_params[] = trim($commands_r[$i]);
         $new = strtolower(implode(' ', $commands));
         // i really cba explaining this..
         if (isset(self::$commands[$hook][$new])) {
             break;
         }
     }
     // just a loop to.. err can't remember what this does..
     // something interesting though
     $new_params = array_reverse($new_params);
     // house keeping
     foreach ($new_params as $ii => $pp) {
         if ($pp == '') {
             unset($new_params[$ii]);
         }
     }
     // more housekeeping
     if (!isset(self::$commands[$hook][$new])) {
         self::$unknown_cmds++;
         services::communicate($bot, $nick, 'Unknown command ' . $commands_r[0] . '.');
         return false;
     }
     // command don't exist, at all..
     $class = strtolower(self::$commands[$hook][$new]['class']);
     $function = strtolower(self::$commands[$hook][$new]['function']);
     // get the function stuff.
     if (!is_callable(array($class, $function), true) || !method_exists($class, $function)) {
         core::alog($class . '::' . $function . '() isn\'t callable, command rejected.', 'BASIC');
         return false;
     }
     // reject the command attempt. output an error
     //modules::$list[$class]['class']->$function( $nick, $new_params );
     call_user_func_array(array($class, $function), array($nick, $new_params));
     // it does! execute the callback
 }
Пример #16
0
 public static function _del_news($nick, $title)
 {
     $check = database::select('logon_news', array('title'), array('title', '=', $title));
     if (database::num_rows($check) > 0) {
         database::delete('logon_news', array('title', '=', $title));
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_LOGONNEWS_DEL, array('title' => $title));
         core::alog(core::$config->operserv->nick . ': ' . $nick . ' deleted ' . $title . ' from logonnews');
         // as simple, as.
     } else {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_LOGONNEWS_NONE);
     }
     // let's check if we can find what they are lookin phowar
 }
Пример #17
0
 public static function sapass_command($nick, $ircdata = array())
 {
     $unick = core::get_nick(&$ircdata, 0);
     $new_pass = $ircdata[1];
     $conf_pass = $ircdata[2];
     // new password.
     if (!($user = services::user_exists($unick, false, array('display', 'id', 'identified', 'salt')))) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ISNT_REGISTERED, array('nick' => $unick));
         return false;
     }
     // find out if our user is registered
     if (services::is_root($unick) && !services::is_root($nick)) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ACCESS_DENIED);
         return false;
     }
     // is a non-root trying to change a root's password?
     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;
     }
     // do we have access to do this?
     if (strtolower($new_pass) == strtolower($unick)) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_PASSWORD_NICK_U);
         return false;
     }
     // are they using a reasonable password, eg. != their nick, lol.
     if ($new_pass != $conf_pass) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_PASSWORD_DIFF);
         return false;
     }
     // the passwords are different
     database::update('users', array('pass' => sha1($new_pass . $user->salt)), array('display', '=', $unick));
     // we update the password here, with the users salt.
     services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_NEW_PASSWORD_U, array('nick' => $unick, 'pass' => $new_pass));
     // let them know
     core::alog(core::$config->nickserv->nick . ': ' . core::get_full_hostname($nick) . ' changed the password for ' . $unick);
     // logchan
 }
Пример #18
0
 public static function check_expire()
 {
     if (core::$config->chanserv->expire == 0) {
         return false;
     }
     // skip channels if config is set to no expire.
     $expiry_time = core::$config->chanserv->expire * 86400;
     $check_time = core::$network_time - $expiry_time;
     // set up our times
     $channel_q = database::select('chans', array('channel', 'last_timestamp'), array('last_timestamp', '<', $check_time));
     if (database::num_rows($channel_q) == 0) {
         return false;
     }
     // no registered channels
     while ($channel = database::fetch($channel_q)) {
         database::delete('chans', array('channel', '=', $channel->channel));
         database::delete('chans_levels', array('channel', '=', $channel->channel));
         core::alog(core::$config->chanserv->nick . ': ' . $channel->channel . ' has expired. Last used on ' . date('F j, Y, g:i a', $channel->last_timestamp));
         // logchan it
         if (isset(core::$chans[$channel->channel])) {
             ircd::part_chan(core::$config->chanserv->nick, $channel->channel);
             // now lets leave the channel if we're in it
         }
         // unset some modes, leave the channel if its in use.. i know this shouldn't
         // be even thought about.. but maybe somebody idled in it and never even did
         // anything for the whole expiry period? :P
     }
     // channel is old i'm afraid, expire it
 }
Пример #19
0
 public static function kick_command($nick, $ircdata = array())
 {
     $unick = $ircdata[0];
     $channel = core::get_chan(&$ircdata, 1);
     $reason = core::get_data_after(&$ircdata, 2);
     // grab the parameters: nick; channel; reason (optional)
     if (trim($unick) == '' || trim($channel) == '') {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX_RE, array('help' => 'KICK'));
         return false;
     }
     // are we missing nick and channel? invalid syntax if so.
     $ntemplate = $template;
     if (trim($reason) == '') {
         $reason = 'Kick command issued by ' . $nick;
     }
     // if they haven't suplied a reason let's fill it in.
     if (isset(core::$nicks[$unick]) && isset(core::$chans[$channel]) && isset(core::$chans[$channel]['users'][$unick])) {
         ircd::kick(core::$config->operserv->nick, $unick, $channel, $reason);
         core::alog(core::$config->operserv->nick . ': ' . $nick . ' used KICK to remove ' . $unick . ' from ' . $chan);
     }
     // now we check 3 things, if the user exists, if the channel exists
     // and if the user is even in that channel, if they arn't we just leave it
 }
Пример #20
0
 public static function check()
 {
     foreach (self::$required as $var => $value) {
         if (!isset(self::$config[$value])) {
             core::alog('ERROR: ' . $value . ' is REQUIRED, startup halted', 'BASIC');
             core::save_logs();
             // force a log save.
         }
     }
     // check for required vars
     if (is_array(self::$config['chanserv_exception_modules']) && !in_array('cs_fantasy', self::$config['chanserv_exception_modules'])) {
         if (!isset(self::$config['fantasy_prefix'])) {
             self::$config['fantasy_prefix'] = '!';
         }
     }
     // check for undefined vars.
     foreach (self::$config as $var => $value) {
         if ($value == 'yes' || $value == 'true' || $value == '1') {
             self::$config[$var] = true;
         }
         if ($value == 'no' || $value == 'false' || $value == '0') {
             self::$config[$var] = false;
         }
     }
     // convert 'yes', 'true', '1' and their opposites to booleans
 }
Пример #21
0
 public static function on_gecos_change(&$ircdata)
 {
     if (isset($ircdata[1]) && $ircdata[1] == 'FNAME') {
         core::alog('on_gecos_change(): ' . substr($ircdata[0], 1) . ' changed gecos to ' . $ircdata[2], 'BASIC');
         // debug info
         return true;
     }
     // return true on fname.
     return false;
 }
Пример #22
0
 public function main(&$ircdata, $startup = false)
 {
     if (ircd::on_connect(&$ircdata)) {
         $nick = core::get_nick(&$ircdata, core::$config->server->ircd == 'inspircd12' ? 4 : 3);
         // get nick
         if ($user = services::user_exists($nick, false, array('display', 'identified', 'validated', 'last_hostmask', 'suspended'))) {
             if ($user->validated == 0 && $user->suspended == 0) {
                 ircd::on_user_logout($nick);
                 // they shouldn't really have registered mode
                 services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_AWAITING_VALIDATION);
             } elseif ($user->identified == 0 && $user->suspended == 0) {
                 self::_registered_nick($nick, $user);
             } elseif ($user->identified == 1 && $user->last_hostmask == core::get_full_hostname($nick)) {
                 ircd::on_user_login($nick);
                 if (!$startup) {
                     core::alog(core::$config->nickserv->nick . ': ' . core::$nicks[$nick]['ident'] . '@' . core::$nicks[$nick]['host'] . ' automatically identified for ' . $nick);
                 }
             } else {
                 self::_registered_nick($nick, $user);
             }
         }
         // is the user existing?
     }
     // on connect let them know that they're using
     // an identified nickname
     if (ircd::on_nick_change(&$ircdata)) {
         $nick = core::get_nick($ircdata, 2);
         $old_nick = core::$nicks[$nick]['onick'];
         // get the nicknames
         timer::remove(array('ns_identify', 'secured_callback', array($old_nick)));
         // remove the secured timer. if there is one
         ircd::on_user_logout($nick);
         // we remove the registered mode
         if ($user = services::user_exists($nick, false, array('display', 'identified', 'validated', 'last_hostmask', 'suspended'))) {
             if ($user->validated == 0 && $user->suspended == 0) {
                 ircd::on_user_logout($nick);
                 // they shouldn't really have registered mode
                 services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_AWAITING_VALIDATION);
             } elseif ($user->identified == 0 && $user->suspended == 0) {
                 self::_registered_nick($nick, $user);
             } elseif ($user->identified == 1 && $user->last_hostmask == core::get_full_hostname($nick)) {
                 ircd::on_user_login($nick);
                 core::alog(core::$config->nickserv->nick . ': ' . core::$nicks[$nick]['ident'] . '@' . core::$nicks[$nick]['host'] . ' automatically identified for ' . $nick);
             } else {
                 self::_registered_nick($nick, $user);
             }
         }
         // is the new nick registered? let them know
     }
     if (ircd::on_quit(&$ircdata)) {
         $nick = core::get_nick(&$ircdata, 0);
         timer::remove(array('ns_identify', 'secured_callback', array($nick)));
         // remove the secured timer. if there is one
         database::update('users', array('identified' => 0, 'last_timestamp' => core::$network_time), array('display', '=', $nick));
         // change nick to unidentified imo
     }
 }
Пример #23
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.
 }
Пример #24
0
 public static function _del_user($nick, $who)
 {
     if (strpos($who, '@') !== false && strpos($who, '!') === false) {
         $who = '*!' . $who;
     }
     // we need to check if it's a hostmask thats been written properly.
     $check_nick_q = database::select('ignored_users', array('who'), array('who', '=', $who));
     if (database::num_rows($check_nick_q) > 0) {
         database::delete('ignored_users', array('who', '=', $who));
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_IGNORE_DEL, array('nick' => $who));
         core::alog(core::$config->operserv->nick . ': ' . $nick . ' deleted ' . $who . ' from the services ignore list');
         // as simple, as.
     } else {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_IGNORE_NONE);
         // empty list.
     }
 }
Пример #25
0
 public static function optimize()
 {
     $tablesResult = mysql_query("SHOW TABLES FROM " . core::$config->database->name);
     $tname = "Tables_in_" . core::$config->database->name;
     while ($row = database::fetch($tablesResult)) {
         mysql_query("OPTIMIZE TABLE `" . $row->{$tname} . "`");
     }
     // loop through our tables
     core::alog(core::$config->operserv->nick . ': database optimization complete');
     core::alog('optimize(): database optimization complete.', 'BASIC');
 }
Пример #26
0
 public static function check_expire()
 {
     if (core::$config->nickserv->expire == 0) {
         return false;
     }
     // skip nicknames if config is set to no expire.
     $expiry_time = core::$config->nickserv->expire * 86400;
     $check_time = core::$network_time - $expiry_time;
     // set up our times.
     $nick_q = database::select('users', array('id', 'display', 'last_timestamp'), array('last_timestamp', '!=', '0', 'AND', 'last_timestamp', '<', $check_time));
     if (database::num_rows($nick_q) == 0) {
         return false;
     }
     // no expiring nicknames
     while ($nick = database::fetch($nick_q)) {
         // Mikeh gets most of the credit for helping
         // me code this function
         database::delete('users', array('display', '=', $nick->display));
         database::delete('users_flags', array('nickname', '=', $user->display));
         // delete the users record
         database::delete('chans_levels', array('target', '=', $nick->display));
         // also delete this users channel access.
         core::alog(core::$config->nickserv->nick . ': ' . $nick->display . ' has expired. Last used on ' . date('F j, Y, g:i a', $nick->last_timestamp));
         // logchan it
         if (isset(core::$nicks[$nick->display])) {
             ircd::on_user_logout($nick->display);
         }
         // if the nick is being used unregister it, even though it shouldn't be, just to be safe.
     }
     // loop through all expiring nicks.
 }
Пример #27
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
 }
Пример #28
0
 public static function on_gecos_change(&$ircdata)
 {
     if (isset($ircdata[1]) && $ircdata[1] == 'CHGNAME') {
         core::alog('on_gecos_change(): ' . self::get_nick(&$ircdata, 2) . ' changed gecos to ' . substr($ircdata[3], 1), 'BASIC');
         // debug info
         return true;
     }
     // return true on chgname.
     if (isset($ircdata[1]) && $ircdata[1] == 'SETNAME') {
         core::alog('on_gecos_change(): ' . self::get_nick(&$ircdata, 0) . ' changed gecos to ' . substr($ircdata[2], 1), 'BASIC');
         // debug info
         return true;
     }
     // return true on chgname.
     return false;
 }
Пример #29
0
 public function remove_callback($nick)
 {
     ircd::remove_client($nick, 'Hold on ' . $nick . ' expiring');
     core::alog(core::$config->nickserv->nick . ': Hold on ' . $nick . ' expiring');
     // remove client, respectively
 }
Пример #30
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
 }