Example #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
 }
Example #2
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..
 }
Example #3
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
 }
Example #4
0
 public static function devoice_command($nick, $ircdata = array())
 {
     $chan = $ircdata[0];
     // standard data here.
     if (self::check_channel($nick, $chan, 'DEVOICE') === false) {
         return false;
     }
     // check if the channel exists and stuff
     if (chanserv::check_levels($nick, $chan, array('v', '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?
     if (strpos($ircdata[1], ':') !== false) {
         mode::type_check($chan, $ircdata[1], '-v', core::$config->chanserv->nick);
     } elseif (isset($ircdata[1])) {
         ircd::mode(core::$config->chanserv->nick, $chan, '-v ' . $ircdata[1]);
     } else {
         ircd::mode(core::$config->chanserv->nick, $chan, '-v ' . $nick);
     }
 }
Example #5
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
 }
Example #6
0
function mode_update()
{
    foreach (mode::byType('mode') as $mode) {
        $mode->save();
    }
}
Example #7
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..
 }
Example #8
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..
 }