示例#1
0
 public static function info_command($nick, $ircdata = array())
 {
     $unick = core::get_nick(&$ircdata, 0);
     // get the nickname.
     if ($unick == '') {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_SYNTAX_RE, array('help' => 'INFO'));
         // wrong syntax
         return false;
     }
     // make sure they've entered a channel
     if (!($user = services::user_exists($unick, false, array('display', 'suspended', 'suspend_reason', 'last_hostmask', 'timestamp', 'last_timestamp')))) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ISNT_REGISTERED, array('nick' => $unick));
         return false;
     }
     // make sure the user exists
     if ($user->suspended == 1) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INFO_SUSPENDED_1, array('nick' => $user->display));
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INFO_SUSPENDED_2, array('reason' => $user->suspend_reason));
     } else {
         $hostmask = explode('!', $user->last_hostmask);
         $hostmask = $hostmask[1];
         // get the hostmask
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INFO_1, array('nick' => $user->display));
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INFO_2, array('time' => date("F j, Y, g:i a", $user->timestamp)));
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INFO_3, array('time' => date("F j, Y, g:i a", $user->last_timestamp != 0 ? $user->last_timestamp : core::$network_time)));
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INFO_4, array('host' => $hostmask));
         // standard messages
         if (core::$nicks[$nick]['ircop'] && services::user_exists($nick, true, array('display', 'identified')) !== false || $unick == $nick && services::user_exists($nick, true, array('display', 'identified')) !== false) {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INFO_5, array('email' => nickserv::get_flags($nick, 'e')));
         }
         // if the person doing /ns info has staff powers we show the email
         // or if someone is doing /ns info on themselves we show it.
         $url = nickserv::get_flags($unick, 'u');
         if ($url != null) {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INFO_6, array('url' => $url));
         }
         // url
         $list = '';
         if (nickserv::check_flags($unick, array('S'))) {
             $list .= 'Secure, ';
         }
         if (nickserv::check_flags($unick, array('P'))) {
             $list .= 'Private Message';
         }
         if (substr($list, -2, 2) == ', ') {
             $list = substr($list, 0, -2);
         }
         // compile our list of options
         if ($list != '') {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INFO_7, array('options' => $list));
         }
         // if our list doesn't equal '', eg. empty show the info.
         if (core::$nicks[$nick]['ircop'] && services::user_exists($nick, true, array('display', 'identified')) !== false && core::$config->nickserv->expire != 0) {
             $expiry_time = core::$config->nickserv->expire * 86400;
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INFO_8, array('time' => date("F j, Y, g:i a", $user->last_timestamp != 0 ? $user->last_timestamp : core::$network_time + $expiry_time)));
         }
         // if the nick in question has staff powers, we show the expiry times.
     }
 }
示例#2
0
 public static function _registered_nick($nick, $user)
 {
     database::update('users', array('identified' => 0), array('display', '=', $nick));
     // set them to identified 0, this might fix that long term bug.
     ircd::on_user_logout($nick);
     // they shouldn't really have registered mode
     if (is_array(nickserv::$help->NS_REGISTERED_NICK)) {
         foreach (nickserv::$help->NS_REGISTERED_NICK as $line) {
             services::communicate(core::$config->nickserv->nick, $nick, $line);
         }
     } else {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_REGISTERED_NICK);
     }
     // this is just a crappy function, basically just parses the NS_REGISTERED thing
     // we check for arrays and single lines, even though the default is array
     // someone might have changed it.
     if (nickserv::check_flags($nick, array('S')) && isset(modules::$list['ns_flags'])) {
         timer::add(array('ns_identify', 'secured_callback', array($nick)), core::$config->nickserv->secure_time, 1);
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_SECURED_NICK, array('seconds' => core::$config->nickserv->secure_time));
     }
     // if the nickname has secure enabled, we let them know that we're watching them :o
 }
示例#3
0
 public static function communicate($from, $to, $template, $data = '')
 {
     $ntemplate = $template;
     if ($data != '' && is_array($data)) {
         foreach ($data as $var => $value) {
             $ntemplate = str_replace('{' . $var . '}', $value, $ntemplate);
         }
         // loop through the array replacing each variable.
     }
     // IF there is a $data defined, we do some replacing
     // otherwise leave it alone
     if (nickserv::check_flags($to, array('P'))) {
         ircd::msg($from, $to, $ntemplate);
     } else {
         ircd::notice($from, $to, $ntemplate);
     }
     // if they are registered, we check their means of contact
 }
示例#4
0
 public static function set_flag($nick, $target, $flag, $param)
 {
     $mode = $flag[0];
     $r_flag = $flag[1];
     // get the real flag, eg. V, v and mode
     if (in_array($r_flag, str_split(self::$p_flags)) && $param == '' && $mode == '+') {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_FLAGS_NEEDS_PARAM, array('flag' => $flag));
         return false;
     }
     // are they issuing a flag, that HAS to have a parameter?
     // only if mode is + and parameter is empty.
     if ($r_flag == 'e') {
         $param_field = 'email';
     }
     if ($r_flag == 'u') {
         $param_field = 'url';
     }
     if ($r_flag == 'm') {
         $param_field = 'msn';
     }
     // translate. some craq.
     if ($r_flag == 'e' && $mode == '-') {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_FLAGS_CANT_UNSET, array('flag' => $flag));
         return false;
     }
     // we're not allowed to let +e be unset
     if (in_array($r_flag, str_split(self::$p_flags)) && $mode == '+') {
         $check_e = database::select('users_flags', array('id', 'email'), array('email', '=', $param));
         if ($r_flag == 'e' && database::num_rows($check_e) > 0) {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_EMAIL_IN_USE);
             return false;
         }
         // check if the email is in use.
         if ($r_flag == 'e' && services::valid_email($param) === false) {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_FLAGS_INVALID_E, array('flag' => $flag));
             return false;
         }
         // is the email invalid?
         if ($r_flag == 'm' && services::valid_email($param) === false) {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_FLAGS_INVALID_E, array('flag' => $flag));
             return false;
         }
         // is the email invalid?
     }
     // check for invalid values
     if (nickserv::check_flags($target, array($r_flag))) {
         $nick_flag_q = database::select('users_flags', array('id', 'nickname', 'flags'), array('nickname', '=', $target));
         if ($mode == '-') {
             if (strpos(self::$set[$target], '-') === false) {
                 self::$set[$target] .= '-';
             }
             // ok, no - ?
             $nick_flag = database::fetch($nick_flag_q);
             // get the flag record
             $new_nick_flags = str_replace($r_flag, '', $nick_flag->flags);
             if (in_array($r_flag, str_split(self::$p_flags))) {
                 database::update('users_flags', array('flags' => $new_nick_flags, $param_field => $param), array('nickname', '=', $target));
                 // update the row with the new flags.
             } else {
                 database::update('users_flags', array('flags' => $new_nick_flags), array('nickname', '=', $target));
                 // update the row with the new flags.
             }
             self::$set[$target] .= $r_flag;
             // some magic :O
             return true;
         }
         if ($mode == '+') {
             if (!in_array($r_flag, str_split(self::$p_flags))) {
                 self::$already_set[$target] .= $r_flag;
                 // some magic :O
                 return false;
             }
             if (strpos(self::$set[$target], '+') === false) {
                 self::$set[$target] .= '+';
             }
             // ok, no + ?
             $nick_flag = database::fetch($nick_flag_q);
             // get the flag record
             database::update('user_flags', array($param_field => $param), array('nickname', '=', $target));
             // update the row with the new flags.
             self::$set[$target] .= $r_flag;
             // some magic :O
             return true;
         }
         // the flag IS set, so now we check whether they are trying to -, or + it
         // if they are trying to - it, go ahead, error if they are trying to + it.
     } else {
         $nick_flag_q = database::select('users_flags', array('id', 'nickname', 'flags'), array('nickname', '=', $target));
         if ($mode == '+') {
             if (strpos(self::$set[$target], '+') === false) {
                 self::$set[$target] .= '+';
             }
             // ok, no + ?
             $nick_flag = database::fetch($nick_flag_q);
             // get the flag record
             $new_nick_flags = $nick_flag->flags . $r_flag;
             if (!in_array($r_flag, str_split(self::$p_flags))) {
                 database::update('users_flags', array('flags' => $new_nick_flags), array('nickname', '=', $target));
                 // update the row with the new flags.
                 self::$set[$target] .= $r_flag;
                 // some magic :O
                 return true;
             } else {
                 database::update('users_flags', array('flags' => $new_nick_flags, $param_field => $param), array('nickname', '=', $target));
                 // update the row with the new flags.
                 self::$set[$target] .= $r_flag;
                 // some magic :O
                 return true;
             }
         }
         // the flag ISNT set, so now we check whether they are trying to -, or + it
         // if they are trying to + it, go ahead, error if they are trying to _ it.
         if ($mode == '-') {
             self::$not_set[$target] .= $r_flag;
             // some magic :O
             return false;
         }
     }
     // check if the flag is already set?
 }