Пример #1
0
 public static function join_logchan()
 {
     ircd::join_chan(core::$config->global->nick, core::$config->settings->logchan);
     // join the logchan
     core::alog('Now sending log messages to ' . core::$config->settings->logchan);
     // tell the chan we're logging shit.
 }
Пример #2
0
 public static function _join_channel(&$channel)
 {
     database::update('chans', array('last_timestamp' => core::$network_time), array('channel', '=', $channel->channel));
     // lets update the last used timestamp
     if (self::check_flags($channel->channel, array('G')) && $channel->suspended == 0 && isset(modules::$list['cs_fantasy']) && !isset(core::$chans[$channel->channel]['users'][core::$config->chanserv->nick])) {
         ircd::join_chan(core::$config->chanserv->nick, $channel->channel);
         // join the chan.
         if (ircd::$protect) {
             ircd::mode(core::$config->chanserv->nick, $channel->channel, '+ao ' . core::$config->chanserv->nick . ' ' . core::$config->chanserv->nick);
         } else {
             ircd::mode(core::$config->chanserv->nick, $channel->channel, '+o ' . core::$config->chanserv->nick);
         }
         // +o its self.
     }
     // check if guard is on
     $modelock = self::get_flags($channel->channel, 'm');
     // store some flag values in variables.
     if ($modelock != null && $channel->suspended == 0) {
         ircd::mode(core::$config->chanserv->nick, $channel->channel, $modelock);
         // Going to have to do some fuffing around here, basically if the channel
         // in question is mlocked +i, and somebody has joined it, while its empty
         // +i will be set after they have joined the channel, so here we're gonna
         // have to kick them out, same applies for +O and +k
         $mode_array = mode::sort_modes($modelock);
         if (strstr($mode_array['plus'], 'i') || strstr($mode_array['plus'], 'k')) {
             foreach (core::$chans[$channel->channel]['users'] as $nick => $modes) {
                 if (count(core::$chans[$channel->channel]['users']) == 2 && isset(core::$chans[$channel->channel]['users'][core::$config->chanserv->nick])) {
                     if (self::check_levels($nick, $channel->channel, array('k', 'v', 'h', 'o', 'a', 'q', 'F'), true, false) === false) {
                         if (strstr($mode_array['plus'], 'i') && $nick != core::$config->chanserv->nick) {
                             ircd::kick(core::$config->chanserv->nick, $nick, $channel->channel, 'Invite only channel');
                             timer::add(array('chanserv', 'part_chan_callback', array($channel->channel)), 1, 1);
                         }
                         if (strstr($mode_array['plus'], 'k') && $nick != core::$config->chanserv->nick) {
                             ircd::kick(core::$config->chanserv->nick, $nick, $channel->channel, 'Passworded channel');
                             timer::add(array('chanserv', 'part_chan_callback', array($channel->channel)), 1, 1);
                         }
                     }
                 }
                 // if the user isn't on the access list
                 // we kick them out ^_^
             }
         }
         // is mode i in the modelock?
         if (strstr($mode_array['plus'], 'O')) {
             foreach (core::$chans[$channel->channel]['users'] as $nick => $modes) {
                 if (!core::$nicks[$nick]['ircop']) {
                     ircd::kick(core::$config->chanserv->nick, $nick, $channel->channel, 'IRCop only channel');
                     timer::add(array('chanserv', 'part_chan_callback', array($channel->channel)), 1, 1);
                 }
                 // if the user isn't on the access list
                 // we kick them out ^_^
             }
         }
         // how about +O?
     }
     // any modelocks?
     if (self::check_flags($channel->channel, array('K')) && !self::check_flags($channel->channel, array('T')) && isset(modules::$list['cs_flags']) && isset(modules::$list['cs_topic'])) {
         if (trim($channel->topic) != trim(core::$chans[$channel->channel]['topic']) || $channel->topic != '') {
             ircd::topic(core::$config->chanserv->nick, $channel->channel, $channel->topic);
         }
         // set the previous topic
     }
     // set the topic to the last known topic
 }
Пример #3
0
 public static function flags_command($nick, $ircdata = array(), $announce = false)
 {
     $chan = core::get_chan(&$ircdata, 0);
     $flags = $ircdata[1];
     $param = core::get_data_after(&$ircdata, 2);
     $rparams = explode('||', $param);
     // get the 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 ($flags == '') {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INVALID_SYNTAX_RE, array('help' => 'FLAGS'));
         return false;
     }
     // missing params?
     $flag_a = array();
     foreach (str_split($flags) as $flag) {
         if (strpos(self::$flags, $flag) === false) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_FLAGS_UNKNOWN, array('flag' => $flag));
             return false;
         }
         // flag is invalid.
         $flag_a[$flag]++;
         // plus
         if ($flag_a[$flag] > 1 || $flag != '-' && $flag != '+') {
             $flag_a[$flag]--;
         }
         // check for dupes
     }
     // check if the flag is valid
     $flags = '';
     foreach ($flag_a as $flag => $count) {
         $flags .= $flag;
     }
     // reconstruct the flags
     $flag_array = mode::sort_modes($flags, false);
     // sort our flags up
     foreach (str_split(self::$p_flags) as $flag) {
         $param_num = strpos($flag_array['plus'], $flag);
         if ($param_num !== false) {
             $params[$flag] = trim($rparams[$param_num]);
         }
         // we do!
     }
     // check if we have any paramtized flags, eg +mw
     foreach (str_split($flag_array['plus']) as $flag) {
         // paramtized flags (lowercase) ones come first
         // ----------- +d ----------- //
         if ($flag == 'd') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '+d', $params['d']);
             // +d the target in question
         } elseif ($flag == 'u') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '+u', $params['u']);
             // +u the target in question
         } elseif ($flag == 'e') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '+e', $params['e']);
             // +e the target in question
         } elseif ($flag == 'w') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '+w', $params['w']);
             // +w the target in question
         } elseif ($flag == 'm') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '+m', $params['m']);
             // +m the target in question
         } elseif ($flag == 't') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '+t', $params['t']);
             // +t the target in question
         } elseif ($flag == 'S') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '+S', '');
             // +S the target in question
         } elseif ($flag == 'F') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '+F', '');
             // +F the target in question
         } elseif ($flag == 'G') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             if (self::set_flag($nick, $chan, '+G', '') !== false && count(core::$chans[$chan]['users']) > 0) {
                 ircd::join_chan(core::$config->chanserv->nick, $chan);
                 // join the chan.
                 if (ircd::$protect) {
                     ircd::mode(core::$config->chanserv->nick, $chan, '+ao ' . core::$config->chanserv->nick . ' ' . core::$config->chanserv->nick);
                 } else {
                     ircd::mode(core::$config->chanserv->nick, $chan, '+o ' . core::$config->chanserv->nick);
                 }
                 // +o its self.
             }
             // only join if channel has above 0 users in it.
             // +G the target in question
         } elseif ($flag == 'T') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '+T', '');
             // +F the target in question
         } elseif ($flag == 'K') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '+K', '');
             // +K the target in question
         } elseif ($flag == 'L') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             if (self::set_flag($nick, $chan, '+L', '') != false) {
                 self::increase_limit($chan);
                 // execute it directly.
             }
             // +L the target in question
         } elseif ($flag == 'I') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             if (self::set_flag($nick, $chan, '+I', '') != false) {
                 foreach (core::$chans[$chan]['users'] as $unick => $mode) {
                     if (chanserv::check_levels($unick, $chan, array('k', 'q', 'a', 'o', 'h', 'v', 'F'), true, false) === false) {
                         ircd::mode(core::$config->chanserv->nick, $chan, '+b *@' . core::$nicks[$unick]['host']);
                         ircd::kick(core::$config->chanserv->nick, $unick, $chan, '+k only channel.');
                     }
                     // they don't have +k, KICKEM
                 }
             }
             // +I the target in question
         }
         // ----------- +I ----------- //
     }
     // loop through the flags being set, and do what we need to do with them.
     foreach (str_split($flag_array['minus']) as $flag) {
         // paramtized flags (lowercase) ones come first
         // ----------- -d ----------- //
         if ($flag == 'd') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '-d', $params['d']);
             // -d the target in question
         } elseif ($flag == 'u') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '-u', $params['u']);
             // -u the target in question
         } elseif ($flag == 'e') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '-e', $params['e']);
             // -e the target in question
         } elseif ($flag == 'w') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '-w', $params['w']);
             // -w the target in question
         } elseif ($flag == 'm') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '-m', $params['m']);
             // -m the target in question
         } elseif ($flag == 't') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '-t', $params['t']);
             // -t the target in question
         } elseif ($flag == 'S') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '-S', '');
             // +S the target in question
         } elseif ($flag == 'F') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '-F', '');
             // -F the target in question
         } elseif ($flag == 'G') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             if (self::set_flag($nick, $chan, '-G', '') != false) {
                 ircd::part_chan(core::$config->chanserv->nick, $chan);
                 // leave the channel
             }
             // -G the target in question
         } elseif ($flag == 'T') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '-T', '');
             // -T the target in question
         } elseif ($flag == 'K') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '-K', '');
             // -K the target in question
         } elseif ($flag == 'L') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             if (self::set_flag($nick, $chan, '-L', '') != false) {
                 ircd::mode(core::$config->chanserv->nick, $chan, '-l');
                 // -l the channel
             }
             // -L the target in question
         } elseif ($flag == 'I') {
             if (chanserv::check_levels($nick, $chan, array('s', 'F')) === false) {
                 services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
                 return false;
             }
             // do they have access to alter this?
             self::set_flag($nick, $chan, '-I', '');
             // -I the target in question
         }
         // ----------- -I ----------- //
     }
     // loop through the flags being unset, and do what we need to do with them.
     if (isset(self::$set[$chan])) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_FLAGS_SET, array('flag' => self::$set[$chan], 'chan' => $chan));
         // who do we notice?
         unset(self::$set[$chan]);
     }
     // send back the target stuff..
     if (isset(self::$already_set[$chan])) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_FLAGS_ALREADY_SET, array('flag' => self::$already_set[$chan], 'chan' => $chan));
         unset(self::$already_set[$chan]);
     }
     // send back the target stuff..
     if (isset(self::$not_set[$chan])) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_FLAGS_NOT_SET, array('flag' => self::$not_set[$chan], 'chan' => $chan));
         unset(self::$not_set[$chan]);
     }
     // send back the target stuff..
 }