示例#1
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
 }
示例#2
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.
     }
 }