예제 #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..
     }
 }
예제 #2
0
 public static function topic_command($nick, $ircdata = array())
 {
     $chan = core::get_chan(&$ircdata, 0);
     $topic = core::get_data_after(&$ircdata, 1);
     // get the channel.
     if ($chan == '' || $chan[0] != '#') {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INVALID_SYNTAX_RE, array('help' => 'TOPIC'));
         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::check_levels($nick, $channel->channel, array('t', 'F')) === false) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
         return false;
     }
     // do they have access?
     if ($channel = services::chan_exists($chan, array('channel'))) {
         $topicmask = chanserv::get_flags($chan, 't');
         // get the topicmask
         if ($topicmask != null) {
             $topic = str_replace(' *', ' ' . $new_topic, $topicmask);
             $topic = str_replace('\\*', '*', $topic);
             ircd::topic(core::$config->chanserv->nick, $channel->channel, $topic);
             database::update('chans', array('topic' => $topic, 'topic_setter' => core::$config->chanserv->nick), array('channel', '=', $channel->channel));
         } else {
             $topic = trim($topic);
             if (trim($topic) == '') {
                 ircd::topic(core::$config->chanserv->nick, $chan, '');
                 database::update('chans', array('topic' => '', 'topic_setter' => core::$config->chanserv->nick), array('channel', '=', $chan));
                 // set us an empty topic
             } else {
                 ircd::topic(core::$config->chanserv->nick, $chan, $topic);
                 database::update('chans', array('topic' => $topic, 'topic_setter' => core::$config->chanserv->nick), array('channel', '=', $chan));
                 // change the topic
             }
         }
     }
     // we gotta get the topicmask etc
 }
예제 #3
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..
 }
예제 #4
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
     }
 }
예제 #5
0
 public static function info_command($nick, $ircdata = array())
 {
     $chan = core::get_chan(&$ircdata, 0);
     // get the channel.
     if ($chan == '' || $chan[0] != '#') {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INVALID_SYNTAX_RE, array('help' => 'INFO'));
         return false;
         // wrong syntax
     }
     // make sure they've entered a channel
     if (!($channel = services::chan_exists($chan, array('channel', 'timestamp', 'last_timestamp', 'suspended', 'suspend_reason')))) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_UNREGISTERED_CHAN, array('chan' => $chan));
         return false;
     }
     // make sure the channel exists
     if ($channel->suspended == 1) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_SUSPENDED_1, array('chan' => $channel->channel));
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_SUSPENDED_2, array('reason' => $channel->suspend_reason));
     } else {
         $founder = database::select('chans_levels', array('id', 'channel', 'target', 'flags'), array('channel', '=', $chan));
         $founders = '';
         while ($f_row = database::fetch($founder)) {
             if (strpos($f_row->flags, 'F') !== false) {
                 $founders .= $f_row->target . ', ';
             }
         }
         // get the founder(s)
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_1, array('chan' => $channel->channel));
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_2, array('nicks' => substr($founders, 0, -2)));
         $desc = chanserv::get_flags($channel->channel, 'd');
         if ($desc != null) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_3, array('desc' => $desc));
         }
         // description?
         if (core::$chans[$chan]['topic'] != '') {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_4, array('topic' => core::$chans[$chan]['topic']));
         }
         // topic
         $email = chanserv::get_flags($channel->channel, 'e');
         if ($email != null) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_5, array('email' => $email));
         }
         // is there an email?
         $url = chanserv::get_flags($channel->channel, 'u');
         if ($url != null) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_6, array('url' => $url));
         }
         // or a url?
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_7, array('time' => date("F j, Y, g:i a", $channel->timestamp)));
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_8, array('time' => date("F j, Y, g:i a", $channel->last_timestamp)));
         $modelock = chanserv::get_flags($channel->channel, 'm');
         if ($modelock != null) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_9, array('mode_lock' => $modelock));
         }
         // is there a mode lock?
         $entrymsg = chanserv::get_flags($channel->channel, 'w');
         if ($entrymsg != null) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_10, array('entrymsg' => $entrymsg));
         }
         // is there an entry msg?
         $list = '';
         if (chanserv::check_flags($channel->channel, array('T'))) {
             $list .= 'Topiclock, ';
         }
         if (chanserv::check_flags($channel->channel, array('K'))) {
             $list .= 'Keeptopic, ';
         }
         if (chanserv::check_flags($channel->channel, array('G'))) {
             $list .= 'Guard, ';
         }
         if (chanserv::check_flags($channel->channel, array('S'))) {
             $list .= 'Secure, ';
         }
         if (chanserv::check_flags($channel->channel, array('F'))) {
             $list .= 'Fantasy';
         }
         if (substr($list, -2, 2) == ', ') {
             $list = substr($list, 0, -2);
         }
         // compile our list of options
         if ($list != '') {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_11, 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->chanserv->expire != 0) {
             $expiry_time = core::$config->chanserv->expire * 86400;
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INFO_12, array('time' => date("F j, Y, g:i a", $channel->last_timestamp + $expiry_time)));
         }
         // if the nick in question has staff powers, we show the expiry times.
     }
 }
예제 #6
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
 }
예제 #7
0
 public static function set_flag($nick, $chan, $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->chanserv->nick, $nick, &chanserv::$help->CS_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 == 'd') {
         $param_field = 'desc';
     }
     if ($r_flag == 'u') {
         $param_field = 'url';
     }
     if ($r_flag == 'e') {
         $param_field = 'email';
     }
     if ($r_flag == 'w') {
         $param_field = 'welcome';
     }
     if ($r_flag == 'm') {
         $param_field = 'modelock';
     }
     if ($r_flag == 't') {
         $param_field = 'topicmask';
     }
     // translate. some craq.
     if (in_array($r_flag, str_split(self::$p_flags)) && $mode == '+') {
         if ($r_flag == 'e' && services::valid_email($param) === false) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_FLAGS_INVALID_E, array('flag' => $flag));
             return false;
         }
         // is the email invalid?
         if ($r_flag == 't' && strpos($param, '*') === false) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_FLAGS_INVALID_T, array('flag' => $flag));
             return false;
         }
         // is the topicmask invalid?
         if ($r_flag == 'm') {
             $mode_string = explode(' ', $param);
             if (strstr($mode_string[0], 'r') || strstr($mode_string[0], 'q') || strstr($mode_string[0], 'a') || strstr($mode_string[0], 'o') || strstr($mode_string[0], 'h') || strstr($mode_string[0], 'v') || strstr($mode_string[0], 'b')) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_FLAGS_INVALID_M, array('flag' => $flag));
                 return false;
             }
         }
         // is the modelock invalid?
     }
     // check for invalid values
     if (chanserv::check_flags($chan, array($r_flag))) {
         $chan_flag_q = database::select('chans_flags', array('id', 'channel', 'flags'), array('channel', '=', $chan));
         if ($mode == '-') {
             if (strpos(self::$set[$target], '+') === false) {
                 self::$set[$target] .= '+';
             }
             // ok, no + ?
             $chan_flag = database::fetch($chan_flag_q);
             // get the flag record
             $new_chan_flags = str_replace($r_flag, '', $chan_flag->flags);
             if (in_array($r_flag, str_split(self::$p_flags))) {
                 database::update('chans_flags', array('flags' => $new_chan_flags, $param_field => $param), array('channel', '=', $chan));
                 // update the row with the new flags.
             } else {
                 database::update('chans_flags', array('flags' => $new_chan_flags), array('channel', '=', $chan));
                 // update the row with the new flags.
             }
             self::$set[$chan] .= $r_flag;
             // some magic :O
             return true;
         }
         if ($mode == '+') {
             if (!in_array($r_flag, str_split(self::$p_flags))) {
                 self::$already_set[$chan] .= $r_flag;
                 // some magic :O
                 return false;
             }
             if (strpos(self::$set[$target], '+') === false) {
                 self::$set[$target] .= '+';
             }
             // ok, no + ?
             $chan_flag = database::fetch($chan_flag_q);
             // get the flag record
             database::update('chans_flags', array($param_field => $param), array('channel', '=', $chan));
             // update the row with the new flags.
             self::$set[$chan] .= $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 {
         $chan_flag_q = database::select('chans_flags', array('id', 'channel', 'flags'), array('channel', '=', $chan));
         if ($mode == '+') {
             if (strpos(self::$set[$target], '+') === false) {
                 self::$set[$target] .= '+';
             }
             // ok, no + ?
             $chan_flag = database::fetch($chan_flag_q);
             // get the flag record
             $new_chan_flags = $chan_flag->flags . $r_flag;
             if (!in_array($r_flag, str_split(self::$p_flags))) {
                 database::update('chans_flags', array('flags' => $new_chan_flags), array('channel', '=', $chan));
                 // update the row with the new flags.
                 self::$set[$chan] .= $r_flag;
                 // some magic :O
                 return true;
             } else {
                 database::update('chans_flags', array('flags' => $new_chan_flags, $param_field => $param), array('channel', '=', $chan));
                 // update the row with the new flags.
                 self::$set[$chan] .= $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[$chan] .= $r_flag;
             // some magic :O
             return false;
         }
     }
     // check if the flag is already set?
 }
예제 #8
0
 public static function flood_check(&$ircdata)
 {
     if (trim($ircdata[0]) == '') {
         return true;
     }
     // the data is empty, omgwtf..
     if (ircd::on_msg(&$ircdata) && $ircdata[2][0] == '#' && $ircdata[3][1] != self::$config->chanserv->fantasy_prefix) {
         return true;
     }
     // this is just here to instantly ignore any normal channel messages
     // otherwise we get lagged up on flood attempts
     if (ircd::on_notice(&$ircdata)) {
         return true;
     }
     // and ignore notices, since we shouldnt respond to any
     // notices what so ever, just saves wasting cpu cycles when we get a notice
     if (ircd::on_msg(&$ircdata) && $ircdata[2][0] != '#') {
         if (self::$config->settings->flood_msgs == 0 || self::$config->settings->flood_time == 0) {
             return false;
         }
         // check if it's disabled.
         $nick = self::get_nick(&$ircdata, 0);
         $time_limit = time() - self::$config->settings->flood_time;
         self::$nicks[$nick]['commands'][] = time();
         $from = self::get_nick(&$ircdata, 2);
         if (self::$nicks[$nick]['ircop']) {
             return false;
         }
         // ignore ircops
         $inc = 0;
         foreach (self::$nicks[$nick]['commands'] as $index => $timestamp) {
             if ($timestamp > $time_limit) {
                 $inc = 1;
             }
         }
         if ($inc == 1) {
             self::$nicks[$nick]['floodcmds']++;
         }
         // we've ++'d the floodcmds, if this goes higher than self::flood_trigger
         // they're flooding, floodcmds is cleared every 100 seconds.
         if (self::$nicks[$nick]['floodcmds'] > self::$config->settings->flood_msgs) {
             if (services::check_mask_ignore($nick) === true) {
                 return false;
             }
             if (self::$nicks[$nick]['offences'] == 0 || self::$nicks[$nick]['offences'] == 1) {
                 self::$nicks[$nick]['offences']++;
                 database::insert('ignored_users', array('who' => '*!*@' . self::$nicks[$nick]['host'], 'time' => core::$network_time));
                 timer::add(array('core', 'remove_ignore', array('*!*@' . self::$nicks[$nick]['host'])), 120, 1);
                 // add them to the ignore list.
                 // also, add a timer to unset it in 2 minutes.
                 $message = self::$nicks[$nick]['offences'] == 1 ? 'This is your first offence' : 'This is your last warning';
                 // compose a message.
                 services::communicate($from, $nick, operserv::$help->OS_COMMAND_LIMIT_1);
                 services::communicate($from, $nick, operserv::$help->OS_COMMAND_LIMIT_2, array('message' => $message));
                 self::alog(self::$config->operserv->nick . ': Offence #' . self::$nicks[$nick]['offences'] . ' for ' . self::get_full_hostname($nick) . ' being ignored for 2 minutes');
                 self::alog('flood_check(): Offence #' . self::$nicks[$nick]['offences'] . ' for ' . self::get_full_hostname($nick), 'BASIC');
                 return true;
             } elseif (self::$nicks[$nick]['offences'] >= 2) {
                 self::alog(self::$config->operserv->nick . ': Offence #' . self::$nicks[$nick]['offences'] . ' for ' . self::get_full_hostname($nick) . ' being glined for 10 minutes');
                 self::alog('flood_check(): Offence #' . self::$nicks[$nick]['offences'] . ' for ' . self::get_full_hostname($nick), 'BASIC');
                 ircd::gline(self::$config->operserv->nick, '*@' . self::$nicks[$nick]['oldhost'], 600, 'Flooding services, 10 minute ban.');
                 // third offence, wtf? add a 10 minute gline.
                 return true;
             }
         }
         // they're flooding
     }
 }
예제 #9
0
 public static function global_notice($nick, $mask, $message)
 {
     core::alog('global_notice(): sent from ' . $nick, 'BASIC');
     // debug info
     foreach (core::$nicks as $user => $data) {
         $hostname = core::get_full_hostname($user);
         // hostname
         if ($data['server'] != core::$config->server->name && services::match($hostname, $mask)) {
             services::communicate($nick, $user, $message);
         }
     }
 }
예제 #10
0
 public static function _clear_users($nick)
 {
     database::delete('ignored_users');
     services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_IGNORE_CLEARED, array('users' => database::num_rows($nicks_q)));
     // list cleared.
 }
예제 #11
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);
     }
 }
예제 #12
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.
     }
 }
예제 #13
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
 }
예제 #14
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.
 }
예제 #15
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
 }
예제 #16
0
 public function main(&$ircdata, $startup = false)
 {
     if (ircd::on_msg(&$ircdata)) {
         $nick = core::get_nick(&$ircdata, 0);
         $chan = core::get_chan(&$ircdata, 2);
         //if ( core::search_nick( $chan ) !== false )
         //return false;
         // bail if it thinks chan == nick.
         if (!($channel = services::chan_exists($chan, array('channel')))) {
             return false;
         }
         // channel isnt registered, halt immediatly..
         // either something has cocked up or someone
         // has forced us into a channel :S
         if (chanserv::check_flags($chan, array('F')) === false) {
             return false;
         }
         // we gotta check if the channel has fantasy commands enabled first
         if (commands::on_fantasy_cmd(&$ircdata, 'help', core::$config->chanserv->nick)) {
             if (ircd::$halfop) {
                 $help =& chanserv::$help->CS_HELP_FANTASY_ALL1;
             } else {
                 $help =& chanserv::$help->CS_HELP_FANTASY_ALL2;
             }
             foreach ($help as $line) {
                 services::communicate(core::$config->chanserv->nick, $nick, $line, array('p' => core::$config->chanserv->fantasy_prefix));
             }
         }
         // !help command
         if (commands::on_fantasy_cmd(&$ircdata, 'owner', core::$config->chanserv->nick) && ircd::$owner) {
             if (chanserv::check_levels($nick, $channel->channel, array('q', 'f', 'F')) === false) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '+q', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+q ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+q ' . $nick);
             }
             // check if another param is specified
         }
         // !owner command
         if (commands::on_fantasy_cmd(&$ircdata, 'deowner', core::$config->chanserv->nick) && ircd::$owner) {
             if (chanserv::check_levels($nick, $channel->channel, array('q', 'f', 'F')) === false) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '-q', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-q ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-q ' . $nick);
             }
             // check if another param is specified
         }
         // !deowner command
         if (commands::on_fantasy_cmd(&$ircdata, 'protect', core::$config->chanserv->nick) && ircd::$protect) {
             if (chanserv::check_levels($nick, $channel->channel, array('a', 'q', 'f', 'F')) === false) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '+a', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+a ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+a ' . $nick);
             }
             // check if another param is specified
         }
         // !protect command
         if (commands::on_fantasy_cmd(&$ircdata, 'deprotect', core::$config->chanserv->nick) && ircd::$protect) {
             if (chanserv::check_levels($nick, $channel->channel, array('a', 'q', 'f', 'F')) === false) {
                 return false;
             }
             if (strtolower($ircdata[4]) == strtolower(core::$config->chanserv->nick)) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '-a', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-a ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-a ' . $nick);
             }
             // check if another param is specified
         }
         // !protect command
         if (commands::on_fantasy_cmd(&$ircdata, 'op', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('o', 'a', 'q', 'f', 'F')) === false) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '+o', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+o ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+o ' . $nick);
             }
             // check if another param is specified
         }
         // !op command
         if (commands::on_fantasy_cmd(&$ircdata, 'deop', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('o', 'a', 'q', 'f', 'F')) === false) {
                 return false;
             }
             if (strtolower($ircdata[4]) == strtolower(core::$config->chanserv->nick)) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '-o', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-o ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-o ' . $nick);
             }
             // check if another param is specified
         }
         // !deop command
         if (commands::on_fantasy_cmd(&$ircdata, 'halfop', core::$config->chanserv->nick) && ircd::$halfop) {
             if (chanserv::check_levels($nick, $channel->channel, array('h', 'o', 'a', 'q', 'f', 'F')) === false) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '+h', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+h ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+h ' . $nick);
             }
             // check if another param is specified
         }
         // !hop command
         if (commands::on_fantasy_cmd(&$ircdata, 'dehalfop', core::$config->chanserv->nick) && ircd::$halfop) {
             if (chanserv::check_levels($nick, $channel->channel, array('h', 'o', 'a', 'q', 'f', 'F')) === false) {
                 return false;
             }
             if (strtolower($ircdata[4]) == strtolower(core::$config->chanserv->nick)) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '-h', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-h ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-h ' . $nick);
             }
             // check if another param is specified
         }
         // !dehop command
         if (commands::on_fantasy_cmd(&$ircdata, 'voice', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('v', 'h', 'o', 'a', 'q', 'f', 'F')) === false) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '+v', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+v ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '+v ' . $nick);
             }
             // check if another param is specified
         }
         // !voice command
         if (commands::on_fantasy_cmd(&$ircdata, 'devoice', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('v', 'h', 'o', 'a', 'q', 'f', 'F')) === false) {
                 return false;
             }
             if (strpos($ircdata[4], ':') !== false) {
                 mode::type_check($chan, $ircdata[4], '-v', core::$config->chanserv->nick);
             } elseif (isset($ircdata[4])) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-v ' . $ircdata[4]);
             } else {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-v ' . $nick);
             }
             // check if another param is specified
         }
         // !devoice command
         if (commands::on_fantasy_cmd(&$ircdata, 'topic', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('t', 'F')) === false) {
                 return false;
             }
             if (isset($ircdata[4])) {
                 $topicmask = chanserv::get_flags($chan, 't');
                 // get the topicmask
                 if ($topicmask != null) {
                     $new_topic = core::get_data_after(&$ircdata, 4);
                     $new_topic = str_replace(' *', ' ' . $new_topic, $topicmask);
                     $new_topic = str_replace('\\*', '*', $new_topic);
                     ircd::topic(core::$config->chanserv->nick, $channel->channel, $new_topic);
                     database::update('chans', array('topic' => $new_topic, 'topic_setter' => core::$config->chanserv->nick), array('channel', '=', $channel->channel));
                 } else {
                     $new_topic = trim(core::get_data_after(&$ircdata, 4));
                     ircd::topic(core::$config->chanserv->nick, $channel->channel, $new_topic);
                     database::update('chans', array('topic' => $new_topic, 'topic_setter' => core::$config->chanserv->nick), array('channel', '=', $channel->channel));
                 }
                 // if there isnt, just set it normally.
             }
             // make sure there is another mask x]
         }
         // !topic command
         if (commands::on_fantasy_cmd(&$ircdata, 'mode', core::$config->chanserv->nick) || commands::on_fantasy_cmd(&$ircdata, 'm', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('h', 'o', 'a', 'q', 'F')) === false) {
                 return false;
             }
             if (isset($ircdata[4])) {
                 $mode_queue = core::get_data_after(&$ircdata, 4);
                 // get the mode queue
                 if (!core::$nicks[$nick]['ircop']) {
                     $mode_queue[0] = str_replace('O', '', $mode_queue[0]);
                 }
                 // don't let them MODE +O if they're not an IRCop
                 ircd::mode(core::$config->chanserv->nick, $chan, $mode_queue);
                 // check if there are any other parameters in the !mode command
             }
             // are we even setting a mode?
         }
         // !mode command
         if (commands::on_fantasy_cmd(&$ircdata, 'kick', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('r', 'F')) === false) {
                 return false;
             }
             // ignore if the nick doesn't have access to perform this
             if (isset($ircdata[4])) {
                 if (chanserv::check_levels($nick, $channel->channel, array('o', 'F')) && chanserv::check_levels($nick, $channel->channel, array('o', 'F')) === false) {
                     return false;
                 }
                 // check if the user kicking, has the access to kick them. that doesn't make sense, but yeah.
                 if (isset($ircdata[5])) {
                     $reason = core::get_data_after(&$ircdata, 5);
                     ircd::kick(core::$config->chanserv->nick, $ircdata[4], $chan, '(' . $nick . ') ' . ($reason != '') ? $reason : 'No reason');
                     // kick them with the reason
                 } else {
                     ircd::kick(core::$config->chanserv->nick, $ircdata[4], $chan, $nick);
                     // kick them with no reason
                 }
             }
             // make sure a parameter is issued
         }
         // !kick command
         if (commands::on_fantasy_cmd(&$ircdata, 'kickban', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('r', 'F')) === false) {
                 return false;
             }
             // ignore if the nick doesn't have access to perform this
             if (isset($ircdata[4])) {
                 if (chanserv::check_levels($nick, $channel->channel, array('o', 'F')) && chanserv::check_levels($nick, $channel->channel, array('o', 'F')) === false) {
                     return false;
                 }
                 // check if the user kicking, has the access to kick them. that doesn't make sense, but yeah.
                 if ($user = core::search_nick($ircdata[4])) {
                     ircd::mode(core::$config->chanserv->nick, $chan, '+b *@' . $user['host']);
                     if (isset($ircdata[5])) {
                         $reason = core::get_data_after(&$ircdata, 5);
                         ircd::kick(core::$config->chanserv->nick, $ircdata[4], $chan, '(' . $nick . ') ' . ($reason != '') ? $reason : 'No reason');
                         // kick them with the reason
                     } else {
                         ircd::kick(core::$config->chanserv->nick, $ircdata[4], $chan, $nick);
                         // kick them with no reason
                     }
                     // check if there is a reason etc.
                 } else {
                     return false;
                 }
             }
             // make sure a parameter is issued
         }
         // !ban command
         if (commands::on_fantasy_cmd(&$ircdata, 'ban', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('r', 'F')) === false) {
                 return false;
             }
             // ignore if the nick doesn't have access to perform this
             if (isset($ircdata[4])) {
                 if (chanserv::check_levels($nick, $channel->channel, array('o', 'F')) && chanserv::check_levels($nick, $channel->channel, array('o', 'F')) === false) {
                     return false;
                 }
                 // check if the user kicking, has the access to kick them. that doesn't make sense, but yeah.
                 if (strpos($ircdata[4], '@') === false && ($user = core::search_nick($ircdata[4]))) {
                     ircd::mode(core::$config->chanserv->nick, $chan, '+b *@' . $user['host']);
                 } else {
                     ircd::mode(core::$config->chanserv->nick, $chan, '+b ' . $ircdata[4]);
                 }
                 // is the hostname in our cache? if not just set a ban on it lol.
             }
         }
         // !ban command
         if (commands::on_fantasy_cmd(&$ircdata, 'unban', core::$config->chanserv->nick)) {
             if (chanserv::check_levels($nick, $channel->channel, array('r', 'F')) === false) {
                 return false;
             }
             if (isset($ircdata[4])) {
                 if (strpos($ircdata[4], '@') === false && ($user = core::search_nick($ircdata[4]))) {
                     ircd::mode(core::$config->chanserv->nick, $chan, '-b *@' . $user['host']);
                 } else {
                     ircd::mode(core::$config->chanserv->nick, $chan, '-b ' . $ircdata[4]);
                 }
                 // is the hostname in our cache? if not unban it..
             }
         }
         // !unban command
         if (commands::on_fantasy_cmd(&$ircdata, 'flags', core::$config->chanserv->nick) && isset(modules::$list['cs_flags'])) {
             $n_ircdata = $ircdata;
             unset($n_ircdata[0], $n_ircdata[1], $n_ircdata[2], $n_ircdata[3]);
             array_unshift($n_ircdata, $chan);
             // construct a new ircdata array
             cs_flags::flags_command($nick, $n_ircdata, true);
             // execute the flags command with the new data
             unset($n_ircdata);
             // get rid of this, isn't longer needed
         }
         // !flags command (experimental)
         if (commands::on_fantasy_cmd(&$ircdata, 'levels', core::$config->chanserv->nick) && isset(modules::$list['cs_levels'])) {
             $n_ircdata = $ircdata;
             unset($n_ircdata[0], $n_ircdata[1], $n_ircdata[2], $n_ircdata[3]);
             array_unshift($n_ircdata, $chan);
             // construct a new ircdata array
             cs_levels::levels_command($nick, $n_ircdata, true);
             // execute the flags command with the new data
             unset($n_ircdata);
             // get rid of this, isn't longer needed
         }
         // !levels command (experimental)
         if (commands::on_fantasy_cmd(&$ircdata, 'sync', core::$config->chanserv->nick) && isset(modules::$list['cs_levels'])) {
             cs_levels::on_create(core::$chans[$chan]['users'], $channel);
             // execute on_create, cause we just treat it as that
             // this is kinda a shortcut, but well worth it.
             ircd::notice(core::$config->chanserv->nick, $chan, '' . $nick . ' used SYNC');
         }
         // !sync command (experimental)
     }
     // only trigger on channel messages
 }
예제 #17
0
 public static function list_command($nick, $ircdata = array())
 {
     $term = $ircdata[0];
     $limit = $ircdata[1];
     $mode = isset($ircdata[2]) ? strtolower($ircdata[2]) : '';
     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 and opered..
     if (trim($term) == '' || trim($limit) == '' || isset($mode) && !in_array($mode, array('', 'suspended'))) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INVALID_SYNTAX_RE, array('help' => 'INFO'));
         return false;
     }
     // invalid syntax
     if (!preg_match('/([0-9]+)\\-([0-9]+)/i', $limit)) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INVALID_SYNTAX_RE, array('help' => 'LIST'));
         return false;
     }
     // invalid syntax
     $total = database::select('chans', array('id'));
     $total = database::num_rows($total);
     $chans = self::_find_match($term, $mode, $limit);
     // try and find a match
     if (database::num_rows($chans) == 0) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_LIST_BOTTOM, array('num' => 0, 'total' => $total));
         return false;
     }
     // no channels?
     services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_LIST_TOP);
     services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_LIST_TOP2);
     // top of the list
     while ($channel = database::fetch($chans)) {
         $false_chan = $channel->channel;
         if (!isset($channel->channel[18])) {
             $y = strlen($channel->channel);
             for ($i = $y; $i <= 17; $i++) {
                 $false_chan .= ' ';
             }
         }
         // this is just a bit of fancy fancy, so everything displays neat
         if ($channel->suspended == 0) {
             $info = chanserv::get_flags($channel->channel, 'd');
         } else {
             $info = $channel->suspend_reason;
         }
         // suspend reason, or description?
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_LIST_ROW, array('chan' => $false_chan, 'info' => $info));
     }
     // loop through the channels
     services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_LIST_BOTTOM, array('num' => database::num_rows($chans) == 0 ? 0 : database::num_rows($chans), 'total' => $total));
 }
예제 #18
0
 public static function list_command($nick, $ircdata = array())
 {
     $term = $ircdata[0];
     $limit = $ircdata[1];
     $mode = isset($ircdata[2]) ? strtolower($ircdata[2]) : '';
     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 (trim($term) == '' || trim($limit) == '' || isset($mode) && !in_array($mode, array('', 'suspended'))) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_SYNTAX_RE, array('help' => 'LIST'));
         return false;
     }
     // invalid syntax
     if (!preg_match('/([0-9]+)\\-([0-9]+)/i', $limit)) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_SYNTAX_RE, array('help' => 'LIST'));
         return false;
     }
     // invalid syntax
     $total = database::select('users', array('id'));
     $total = database::num_rows($total);
     $nicks = self::_find_match($term, $mode, $limit);
     // try and find a match
     if (database::num_rows($nicks) == 0) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_LIST_BOTTOM, array('num' => 0, 'total' => $total));
         return false;
     }
     // no nicks?
     services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_LIST_TOP);
     services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_LIST_TOP2);
     // top of list.
     while ($user = database::fetch($nicks)) {
         $false_nick = $user->display;
         if (!isset($user->display[18])) {
             $y = strlen($user->display);
             for ($i = $y; $i <= 17; $i++) {
                 $false_nick .= ' ';
             }
         }
         // this is just a bit of fancy fancy, so everything displays neat
         if ($user->suspended == 0) {
             $hostmask = explode('!', $user->last_hostmask);
             $info = $hostmask[1];
         } else {
             $info = $user->suspend_reason;
         }
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_LIST_ROW, array('nick' => $false_nick, 'info' => $info));
     }
     // loop through the nicks
     services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_LIST_BOTTOM, array('num' => database::num_rows($nicks) == 0 ? 0 : database::num_rows($nicks), 'total' => $total));
 }
예제 #19
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.
 }
예제 #20
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?
 }
예제 #21
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
 }
예제 #22
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..
     }
 }
예제 #23
0
 public static function restart_command($nick, $ircdata = array())
 {
     // we don't even need to listen for any
     // parameters, because its just a straight command
     if (services::is_root($nick)) {
         if (isset(core::$config->settings->shutdown_message) || core::$config->settings->shutdown_message != null) {
             ircd::global_notice(core::$config->global->nick, '*!*@*', core::$config->settings->shutdown_message);
         }
         // is there a shutdown message?
         core::save_logs();
         // save logs.
         ircd::shutdown('shutdown command from ' . $nick, false);
         // exit the server
         fclose(core::$socket);
         // close the socket first.
         if (substr(php_uname(), 0, 7) != 'Windows') {
             if (core::$debug) {
                 system('php ' . BASEPATH . '/services.php debug');
             } else {
                 exec('php ' . BASEPATH . '/services.php > /dev/null &');
             }
             // reboot if we're running anything but windows
             // if debug we send the output back to the screen, else we send it to /dev/null
         } else {
             if (!isset(core::$config->settings->php_dir) || core::$config->settings->php_dir == '') {
                 define('PHPDIR', 'C:\\php\\php.exe');
             } else {
                 define('PHPDIR', core::$config->settings->php_dir);
             }
             // define where the php binary is located.
             exec('@cd ' . BASEPATH);
             // cd to the basedir
             if (core::$debug) {
                 system('@' . PHPDIR . ' services.php debug');
             } else {
                 exec('@' . PHPDIR . ' services.php');
             }
             // if we run windows we do a different method of reboot
             // again if we debug we send it to the screen, if not.. we don't
         }
         exit;
         // exit the program
     } else {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_ACCESS_DENIED);
     }
 }
예제 #24
0
 public static function check_channel($nick, $chan, $help)
 {
     if ($chan == '' || $chan[0] != '#') {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INVALID_SYNTAX_RE, array('help' => $help));
         return false;
         // wrong syntax
     }
     // make sure they've entered a channel
     if (!($channel = services::chan_exists($chan, array('channel')))) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_UNREGISTERED_CHAN, array('chan' => $chan));
         return false;
     }
     // make sure the channel exists.
     return $channel;
 }
예제 #25
0
 public static function stats_command($nick, $ircdata = array())
 {
     $type = $ircdata[0];
     // what type is it, currently valid types are
     // UPTIME, NETWORK, SERVERS, OPERS
     if (strtolower($type) == 'uptime') {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_STATS_U_1, array('time' => core::format_time(core::$uptime)));
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_STATS_U_2, array('memory' => core::get_size(memory_get_usage()), 'real' => memory_get_usage()));
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_STATS_U_3, array('memory' => core::get_size(core::$incoming), 'real' => core::$incoming));
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_STATS_U_4, array('memory' => core::get_size(core::$outgoing), 'real' => core::$outgoing));
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_STATS_U_5, array('lines' => core::$lines_processed));
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_STATS_U_6, array('lines' => core::$lines_sent));
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_STATS_U_7, array('time' => core::$burst_time . 's'));
         // uptime info, etc.
     } elseif (strtolower($type) == 'network') {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_STATS_N_1, array('network' => core::$config->server->network_name));
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_STATS_N_2, array('version' => core::$version));
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_STATS_N_3, array('users' => core::$max_users));
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_STATS_N_4, array('users' => count(core::$nicks)));
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_STATS_N_5, array('chans' => count(core::$chans)));
         // network info.
     } elseif (strtolower($type) == 'opers') {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_STATS_O_1);
         foreach (core::$nicks as $user => $info) {
             if (!$info['ircop'] || $info['server'] == core::$config->server->name) {
                 continue;
             }
             // skip if they aint an ircop
             $false_host = core::get_full_hostname($user);
             if (!isset($false_host[45])) {
                 $y = strlen($false_host);
                 for ($i = $y; $i <= 44; $i++) {
                     $false_host .= ' ';
                 }
             }
             // this is just a bit of fancy fancy, so everything displays neat
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_STATS_O_2, array('host' => $false_host, 'time' => date("F j, Y, g:i a", $info['timestamp'])));
         }
         // opers info.
     } else {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX_RE, array('help' => 'STATS'));
         return false;
         // wrong syntax
     }
     // if/else for our type, if one isnt given we bail out.
 }
예제 #26
0
 public static function set_flag($nick, $chan, $target, $flag, $param = '')
 {
     $mode = $flag[0];
     $r_flag = $flag[1];
     // get the real flag, eg. V, v and mode
     if (chanserv::check_levels($target, $chan, array($r_flag), false, false, false, false)) {
         $user_flag_q = database::select('chans_levels', array('id', 'channel', 'target', 'flags'), array('channel', '=', $chan, 'AND', 'target', '=', $target));
         if ($mode == '-') {
             if ($nick == $target && $r_flag == 'F') {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_LEVELS_BAD_FLAG, array('flag' => $flag));
                 return false;
             }
             // someone is trying to de-founder themselves?
             if (strpos(self::$set[$target], '-') === false) {
                 self::$set[$target] .= '-';
             }
             // ok, no - ?
             $user_flag = database::fetch($user_flag_q);
             // get the flag record
             $new_user_flags = str_replace($r_flag, '', $user_flag->flags);
             if ($new_user_flags == '') {
                 database::delete('chans_levels', array('channel', '=', $chan, 'AND', 'target', '=', $target));
             } else {
                 database::update('chans_levels', array('flags' => $new_user_flags), array('channel', '=', $chan, 'AND', 'target', '=', $target));
             }
             // check if it's empty, if it is just delete the row
             self::$set[$target] .= $r_flag;
             // some magic :O
             return true;
         } else {
             self::$already_set[$target] .= $r_flag;
             // some magic :O
             return false;
         }
         // the user has the flag, so, if it's - remove it, if it is +
         // we send a message back.
     } else {
         $user_flag_q = database::select('chans_levels', array('id', 'channel', 'target', 'flags'), array('channel', '=', $chan, 'AND', 'target', '=', $target));
         if ($mode == '+') {
             if (strpos(self::$set[$target], '+') === false) {
                 self::$set[$target] .= '+';
             }
             // ok, no + ?
             if (database::num_rows($user_flag_q) > 0) {
                 $user_flag = database::fetch($user_flag_q);
                 $new_user_flags = $user_flag->flags . $r_flag;
                 if ($r_flag == 'b' && $mode == '+') {
                     database::update('chans_levels', array('flags' => $new_user_flags, 'reason' => $param), array('channel', '=', $chan, 'AND', 'target', '=', $target));
                 } else {
                     database::update('chans_levels', array('flags' => $new_user_flags), array('channel', '=', $chan, 'AND', 'target', '=', $target));
                 }
                 // update.
                 self::$set[$target] .= $r_flag;
                 // some magic :O
                 return true;
             } else {
                 if ($r_flag == 'b' && $mode == '+') {
                     database::insert('chans_levels', array('channel' => $chan, 'target' => $target, 'flags' => $r_flag, 'reason' => $param));
                 } else {
                     database::insert('chans_levels', array('channel' => $chan, 'target' => $target, 'flags' => $r_flag));
                 }
                 // insert.
                 self::$set[$target] .= $r_flag;
                 // some magic :O
                 return true;
             }
         } else {
             self::$not_set[$target] .= $r_flag;
             // some magic :O
             return false;
         }
         // the user doesn't have the flag, so if it's + add it, if it is -
         // we send a message back, basically the opposite of above.
     }
 }
예제 #27
0
 public function main(&$ircdata, $startup = false)
 {
     if (ircd::on_connect(&$ircdata)) {
         $nick = core::get_nick(&$ircdata, core::$config->server->ircd == 'inspircd12' ? 4 : 3);
         if ($user = services::user_exists($nick, false, array('display', 'suspended'))) {
             if ($user->suspended == 1) {
                 $random_nick = 'Unknown' . rand(10000, 99999);
                 services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_SUSPEND_1, array('nick' => $user->display));
                 services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_NICK_CHANGE, array('nick' => $random_nick));
                 ircd::svsnick($nick, $random_nick, core::$network_time);
             }
         }
         // check if the nick is suspended etc.
     }
     // trigger on connect
     if (ircd::on_nick_change(&$ircdata)) {
         $nick = core::get_nick($ircdata, 2);
         // get the nicknames
         if ($user = services::user_exists($nick, false, array('display', 'suspended'))) {
             if ($user->suspended == 1) {
                 $random_nick = 'Unknown' . rand(10000, 99999);
                 services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_SUSPEND_1, array('nick' => $user->display));
                 services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_NICK_CHANGE, array('nick' => $random_nick));
                 ircd::svsnick($nick, $random_nick, core::$network_time);
             }
         }
         // check if the nick is suspended etc.
     }
     // trigger on nick change
 }
예제 #28
0
 public static function release_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' => 'RELEASE'));
         return false;
     }
     // invalid syntax
     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) {
             if (!isset(self::$held_nicks[$unick])) {
                 services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_NO_HOLD, array('nick' => $unick));
                 return false;
                 // nickname isnt locked.
             }
             ircd::remove_client($unick, 'RELEASED by ' . $nick);
             core::alog(core::$config->nickserv->nick . ': RELEASE command on ' . $unick . ' used by ' . core::get_full_hostname($nick));
             timer::remove(array('ns_recover', 'remove_callback', array($unick)));
             // if they are, remove client, respectively
             // unsetting data and removing them.
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_NICK_RELEASED, array('nick' => $unick));
             // tell the user their nick has been released (Y)
         } 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..
     }
 }
예제 #29
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..
     }
 }
예제 #30
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?
 }