Пример #1
0
 public static function mode($nick, $chan, $mode)
 {
     if ($mode[0] != '-' && $mode[0] != '+') {
         $mode = '+' . $mode;
     }
     $mode = mode::check_modes($mode);
     // we don't want nobody messing about
     if ($mode != '') {
         if (!isset(core::$chans[$chan]['timestamp']) || core::$chans[$chan]['timestamp'] == '') {
             core::$chans[$chan]['timestamp'] = core::$network_time;
         }
         self::send(':' . $nick . ' FMODE ' . $chan . ' ' . core::$chans[$chan]['timestamp'] . ' ' . $mode);
         $mode_array = mode::sort_modes($mode);
         mode::append_modes($chan, $mode_array);
         mode::handle_params($chan, $mode_array);
     }
     // we only send it if the mode actually has anything in it.
     core::alog('mode(): ' . $nick . ' set ' . $mode . ' on ' . $chan, 'BASIC');
     // debug info
 }
Пример #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..
 }
Пример #4
0
 public static function levels_command($nick, $ircdata = array(), $announce = false)
 {
     $chan = core::get_chan(&$ircdata, 0);
     $target = $ircdata[2];
     $flags = $ircdata[1];
     // get the channel.
     if ($target == '' && $flags == '' && chanserv::check_levels($nick, $chan, array('v', 'h', 'o', 'a', 'q', 'r', 'f', 'F'))) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_LEVELS_LIST_TOP, array('chan' => $chan));
         // start of flag list
         $flags_q = database::select('chans_levels', array('id', 'channel', 'target', 'flags', 'reason'), array('channel', '=', $chan));
         // get the flag records
         $x = 0;
         while ($flags = database::fetch($flags_q)) {
             $x++;
             $false_flag = $flags->flags;
             if (!isset($flags->flags[13])) {
                 $y = strlen($flags->flags);
                 for ($i = $y; $i <= 12; $i++) {
                     $false_flag .= ' ';
                 }
             }
             // this is just a bit of fancy fancy, so everything displays neat, like so:
             // +ao  N0valyfe
             // +v   tool
             if ($flags->reason != '') {
                 $extra = '(' . $flags->reason . ')';
             } else {
                 $extra = '';
             }
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_LEVELS_LIST, array('num' => $x, 'target' => $flags->target, 'flags' => '+' . $false_flag, 'reason' => $extra));
             // show the flag
         }
         // loop through them
         return false;
     }
     // no params
     // lets show the current flags.
     if ($target == '' || $flags == '') {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INVALID_SYNTAX_RE, array('help' => 'LEVELS'));
         return false;
     }
     // missing params?
     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.
     $flag_a = array();
     foreach (str_split($flags) as $pos => $flag) {
         if (strpos(self::$flags, $flag) === false) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_LEVELS_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
     if (strpos($target, '@') === false) {
         if (!($user = services::user_exists($target, false, array('id', 'display')))) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_UNREGISTERED_NICK, array('nick' => $target));
             return false;
         }
         // they aint even identified..
         // were dealing with a nickname, check if it is registered
         // if not, back out
     } else {
         if (strpos($target, '!') === false) {
             $target = '*!' . $target;
         }
         // we're dealing with a mask, check if it a proper mask
         // *!*@* < like so.
     }
     $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($flag_array['plus']) as $flag) {
         // ----------- +k ----------- //
         if ($flag == 'k') {
             if (chanserv::check_levels($nick, $chan, array('h', 'o', 'a', 'q', 'f', '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, $target, '+k');
             // +k the target in question
         } elseif ($flag == 'v') {
             if (chanserv::check_levels($nick, $chan, array('h', 'o', 'a', 'q', 'f', '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, $target, '+v');
             // +v the target in question
         } elseif ($flag == 'h' && ircd::$halfop) {
             if (chanserv::check_levels($nick, $chan, array('o', 'a', 'q', 'f', '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, $target, '+h');
             // +h the target in question
         } elseif ($flag == 'o') {
             if (chanserv::check_levels($nick, $chan, array('a', 'q', 'f', '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, $target, '+o');
             // +o the target in question
         } elseif ($flag == 'a' && ircd::$protect) {
             if (chanserv::check_levels($nick, $chan, array('q', 'f', '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, $target, '+a');
             // +a the target in question
         } elseif ($flag == 'q' && ircd::$owner) {
             if (chanserv::check_levels($nick, $chan, array('f', '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, $target, '+q');
             // +q the target in question
         } elseif ($flag == 's') {
             if (chanserv::check_levels($nick, $chan, array('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, $target, '+s');
             // +s the target in question
         } elseif ($flag == 'r') {
             if (chanserv::check_levels($nick, $chan, array('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, $target, '+r');
             // +r the target in question
         } elseif ($flag == 'r') {
             if (chanserv::check_levels($nick, $chan, array('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, $target, '+r');
             // +r the target in question
         } elseif ($flag == 'f') {
             if (chanserv::check_levels($nick, $chan, array('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, $target, '+f');
             // +f the target in question
         } elseif ($flag == 't') {
             if (chanserv::check_levels($nick, $chan, array('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, $target, '+t');
             // +t the target in question
         } elseif ($flag == 'F') {
             if (chanserv::check_levels($nick, $chan, array('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, $target, '+F');
             // +F the target in question
         } elseif ($flag == 'b') {
             $reason = core::get_data_after(&$ircdata, 3);
             $reason = $reason == '' ? 'No reason' : $reason;
             // grab the reason
             if (chanserv::check_levels($nick, $chan, array('r', '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, $target, '+b', $reason) !== false) {
                 foreach (core::$chans[$chan]['users'] as $user => $modes) {
                     $hostname = core::get_full_hostname($nick);
                     if (strpos($mask, '@') && services::match($hostname, $target) || $user == $target) {
                         if (chanserv::check_levels($nick, $channel->channel, array('v', 'h', 'o', 'a', 'q', 'F'))) {
                             continue;
                         }
                         // don't trigger if they are on the old access list.
                         ircd::mode(core::$config->chanserv->nick, $chan, '+b *@' . core::$nicks[$user]['host']);
                         ircd::kick(core::$config->chanserv->nick, $user, $chan, $reason);
                         // kickban them, but don't stop looping, because there could be more than one match.
                     }
                     // check for a match
                 }
                 // loop through the users in this channel, finding
                 // matches to the +b flag thats just been set
             }
             // +b the target in question
         }
         // ----------- +b ----------- //
     }
     // loop though our plus flags
     foreach (str_split($flag_array['minus']) as $flag) {
         // ----------- -k ----------- //
         if ($flag == 'k') {
             if (chanserv::check_levels($nick, $chan, array('h', 'o', 'a', 'q', 'f', '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, $target, '-k');
             // -k the target in question
         } elseif ($flag == 'v') {
             if (chanserv::check_levels($nick, $chan, array('h', 'o', 'a', 'q', 'f', '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, $target, '-v');
             // -v the target in question
         } elseif ($flag == 'h' && ircd::$halfop) {
             if (chanserv::check_levels($nick, $chan, array('o', 'a', 'q', 'f', '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, $target, '-h');
             // -h the target in question
         } elseif ($flag == 'o') {
             if (chanserv::check_levels($nick, $chan, array('a', 'q', 'f', '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, $target, '-o');
             // -o the target in question
         } elseif ($flag == 'a' && ircd::$protect) {
             if (chanserv::check_levels($nick, $chan, array('q', 'f', '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, $target, '-a');
             // -a the target in question
         } elseif ($flag == 'q' && ircd::$owner) {
             if (chanserv::check_levels($nick, $chan, array('f', '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, $target, '-q');
             // -q the target in question
         } elseif ($flag == 's') {
             if (chanserv::check_levels($nick, $chan, array('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, $target, '-s');
             // -s the target in question
         } elseif ($flag == 'r') {
             if (chanserv::check_levels($nick, $chan, array('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, $target, '-r');
             // -r the target in question
         } elseif ($flag == 'r') {
             if (chanserv::check_levels($nick, $chan, array('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, $target, '-r');
             // -r the target in question
         } elseif ($flag == 'f') {
             if (chanserv::check_levels($nick, $chan, array('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, $target, '-f');
             // -f the target in question
         } elseif ($flag == 't') {
             if (chanserv::check_levels($nick, $chan, array('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, $target, '-t');
             // -t the target in question
         } elseif ($flag == 'F') {
             if (chanserv::check_levels($nick, $chan, array('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, $target, '-F');
             // -F the target in question
         } elseif ($flag == 'b') {
             if (chanserv::check_levels($nick, $chan, array('r', '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, $target, '-b') !== false) {
                 if (strpos($target, '@') === false && ($user = core::search_nick($target))) {
                     ircd::mode(core::$config->chanserv->nick, $chan, '-b *@' . $user['host']);
                 } else {
                     ircd::mode(core::$config->chanserv->nick, $chan, '-b ' . $target);
                 }
                 // is the hostname in our cache? if not unban it..
             }
             // -b the target in question
         }
         // ----------- -b ----------- //
     }
     // loop through the minus flags
     if (isset(self::$set[$target])) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_LEVELS_SET, array('target' => $target, 'flag' => self::$set[$target], 'chan' => $chan));
         // who do we notice?
         unset(self::$set[$target]);
     }
     // send back the target stuff..
     if (isset(self::$already_set[$target])) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_LEVELS_ALREADY_SET, array('target' => $target, 'flag' => self::$already_set[$target], 'chan' => $chan));
         unset(self::$already_set[$target]);
     }
     // send back the target stuff..
     if (isset(self::$not_set[$target])) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_LEVELS_NOT_SET, array('target' => $target, 'flag' => self::$not_set[$target], 'chan' => $chan));
         unset(self::$not_set[$target]);
     }
     // send back the target stuff..
 }
Пример #5
0
 public static function saflags_command($nick, $ircdata = array())
 {
     $unick = core::get_nick(&$ircdata, 0);
     $flags = $ircdata[1];
     $param = core::get_data_after(&$ircdata, 2);
     $rparams = explode('||', $param);
     // get the channel.
     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?
     $flag_a = array();
     foreach (str_split($flags) as $flag) {
         if (strpos(self::$flags, $flag) === false) {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_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 +me
     foreach (str_split($flag_array['plus']) as $flag) {
         // paramtized flags (lowercase) ones come first
         // ----------- +e ----------- //
         if ($flag == 'e') {
             self::set_flag($nick, $unick, '+e', $params['e']);
             // +e the target in question
         } elseif ($flag == 'u') {
             self::set_flag($nick, $unick, '+u', $params['u']);
             // +u the target in question
         } elseif ($flag == 'S') {
             self::set_flag($nick, $unick, '+S', '');
             // +S the target in question
         } elseif ($flag == 'P') {
             self::set_flag($nick, $unick, '+P', '');
             // +P the target in question
         }
         // ----------- +P ----------- //
     }
     foreach (str_split($flag_array['minus']) as $flag) {
         // paramtized flags (lowercase) ones come first
         // ----------- -e ----------- //
         if ($flag == 'e') {
             self::set_flag($nick, $unick, '-e', $params['e']);
             // -e the target in question
         } elseif ($flag == 'u') {
             self::set_flag($nick, $unick, '-u', $params['u']);
             // -u the target in question
         } elseif ($flag == 'S') {
             self::set_flag($nick, $unick, '-S', '');
             // -S the target in question
         } elseif ($flag == 'P') {
             self::set_flag($nick, $unick, '-P', '');
             // -P the target in question
         }
         // ----------- -P ----------- //
     }
     if (isset(self::$set[$unick])) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_FLAGS_SET, array('flag' => self::$set[$unick], 'target' => $unick));
         unset(self::$set[$unick]);
     }
     // send back the target stuff..
     if (isset(self::$already_set[$unick])) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_FLAGS_ALREADY_SET, array('flag' => self::$already_set[$unick], 'target' => $unick));
         unset(self::$already_set[$unick]);
     }
     // send back the target stuff..
     if (isset(self::$not_set[$unick])) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_FLAGS_NOT_SET, array('flag' => self::$not_set[$unick], 'target' => $unick));
         unset(self::$not_set[$unick]);
     }
     // send back the target stuff..
 }