Beispiel #1
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..
     }
 }
 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..
 }
Beispiel #3
0
 public static function identify_command($nick, $ircdata = array())
 {
     $password = $ircdata[0];
     if (trim($password) == '') {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_SYNTAX_RE, array('help' => 'IDENTIFY'));
         return false;
     }
     // wrong syntax damit!
     if ($user = services::user_exists($nick, false, array('display', 'pass', 'identified', 'validated', 'salt', 'vhost'))) {
         if ($user->validated == 0) {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_AWAITING_VALIDATION);
             return false;
         } elseif ($user->identified == 1) {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ALREADY_IDENTIFIED);
             return false;
         } else {
             if ($user->pass == sha1($password . $user->salt)) {
                 timer::remove(array('ns_identify', 'secured_callback', array($nick)));
                 // remove the secured timer. if there is one
                 ircd::on_user_login($nick);
                 // registered mode
                 database::update('users', array('identified' => 1, 'last_hostmask' => core::get_full_hostname($nick), 'last_timestamp' => 0), array('display', '=', $nick));
                 services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_IDENTIFIED);
                 // right, standard identify crap
                 core::alog(core::$config->nickserv->nick . ': ' . core::get_full_hostname($nick) . ' identified for nick ' . core::$nicks[$nick]['nick']);
                 // logchan
                 if ($user->vhost != '' && isset(modules::$list['os_vhost'])) {
                     if (substr_count($user->vhost, '@') == 1) {
                         $new_host = explode('@', $user->vhost);
                         $ident = $new_host[0];
                         $host = $new_host[1];
                         ircd::setident(core::$config->operserv->nick, $user->display, $ident);
                         ircd::sethost(core::$config->operserv->nick, $user->display, $host);
                     } else {
                         ircd::sethost(core::$config->operserv->nick, $user->display, $user->vhost);
                     }
                 }
                 // first thing we do, check if they have a vhost, if they do, apply it.
                 $failed_attempts = database::select('failed_attempts', array('nick', 'mask', 'time'), array('nick', '=', $nick));
                 if (database::num_rows($failed_attempts) > 0) {
                     services::communicate(core::$config->nickserv->nick, $nick, '' . database::num_rows($failed_attempts) . ' failed login(s) since last login.');
                     while ($row = database::fetch($failed_attempts)) {
                         services::communicate(core::$config->nickserv->nick, $nick, 'Failed login from: ' . $row->mask . ' on ' . date("F j, Y, g:i a", $row->time) . '');
                     }
                     // loop through the failed attempts messaging them to the user
                     database::delete('failed_attempts', array('nick', '=', $nick));
                     // clear them now that they've been seen
                 }
                 // we got any failed attempts? HUMM
                 $hostname = core::get_full_hostname($nick);
                 // generate a hostname.
                 if (core::$config->settings->mode_on_id == 'yes' && isset(modules::$list['cs_levels'])) {
                     foreach (core::$chans as $chan => $cdata) {
                         $access_array = cs_levels::get_access($chan);
                         // get the access array
                         if ($nick == core::$config->chanserv->nick) {
                             continue;
                         }
                         // skip us :D
                         $hostname = core::get_full_hostname($nick);
                         // get the hostname ready.
                         foreach ($access_array as $target => $access) {
                             if ($target == $nick) {
                                 $remove_access = false;
                                 // don't remove access
                                 cs_levels::give_access($chan, $nick, $access, chanserv::check_flags($chan, array('S')));
                                 // give them access
                                 continue 2;
                                 // continue to next loop cause we've found a match
                             } elseif (strpos($target, '@') !== false && services::match($hostname, $target)) {
                                 $remove_access = false;
                                 // don't remove access
                                 cs_levels::give_access($chan, $nick, $access, chanserv::check_flags($chan, array('S')));
                                 // give them access
                                 continue 2;
                                 // continue to next loop cause we've found a match
                             } elseif (strpos(core::$chans[$chan]['users'][$nick], 'o') !== false) {
                                 $remove_access = true;
                                 // set remove access to true
                                 continue 1;
                                 // continue to next loop to check other access records
                             } else {
                                 continue 1;
                                 // continue to next loop to check other access records
                             }
                             // we check if the user has access, if they do break;
                             // we also check if they dont have access and have op, if they do remove it.
                         }
                         // loop through the access records
                     }
                     // loop through channels, check if they are in any
                 }
                 // check if mode_on_id is set, also cs_access is enabled, and lets do a remote access gain :D
             } else {
                 services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_PASSWORD);
                 core::alog(core::$config->nickserv->nick . ': Invalid password from ' . core::get_full_hostname($nick));
                 // some logging stuff
                 database::insert('failed_attempts', array('nick' => $nick, 'mask' => core::get_full_hostname($nick), 'time' => core::$network_time));
                 core::$nicks[$nick]['failed_attempts']++;
                 // ooh, we have something to log :)
                 if (core::$nicks[$nick]['failed_attempts'] == 5) {
                     ircd::kill(core::$config->nickserv->nick, $nick, 'Maxmium FAILED login attempts reached.');
                 }
                 // have they reached the failed attempts limit? we gonna f*****g KILL mwhaha
             }
             // invalid password? HAX!!
         }
         // are they already identifed?
     } else {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_UNREGISTERED);
         return false;
         // doesn't even exist..
     }
     // right now we need to check if the user exists, and password matches
 }