示例#1
0
 public static function drop_command($nick, $ircdata = array())
 {
     $chan = core::get_chan(&$ircdata, 0);
     // get the channel.
     if (self::_drop_check($nick, $chan) === false) {
         return false;
     }
     // do nessicary checks
     if ($channel = services::chan_exists($chan, array('channel', 'suspended'))) {
         if ($channel->suspended == 1) {
             services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_SUSPEND_1, array('chan' => $chan));
             return false;
         }
     }
     // is the channel suspended?
     database::delete('chans', array('channel', '=', $chan));
     database::delete('chans_levels', array('channel', '=', $chan));
     // delete all associated records
     services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_CHAN_DROPPED, array('chan' => $chan));
     // let the user know
     if (isset(core::$chans[$chan])) {
         ircd::part_chan(core::$config->chanserv->nick, $chan);
         // now lets leave the channel if we're in it
     }
     // is the channel in existance? if so unregister mode
     // remember we DON'T unset the channel record, because the channel
     // is still there, just isnt registered, completely different things
     core::alog(core::$config->chanserv->nick . ': ' . $chan . ' has been dropped by ' . core::get_full_hostname($nick));
     // logchan it
     core::alog('drop_command(): ' . $chan . ' has been dropped by ' . core::get_full_hostname($nick), 'BASIC');
     // log what we need to log.
 }
示例#2
0
 public static function check_expire()
 {
     if (core::$config->chanserv->expire == 0) {
         return false;
     }
     // skip channels if config is set to no expire.
     $expiry_time = core::$config->chanserv->expire * 86400;
     $check_time = core::$network_time - $expiry_time;
     // set up our times
     $channel_q = database::select('chans', array('channel', 'last_timestamp'), array('last_timestamp', '<', $check_time));
     if (database::num_rows($channel_q) == 0) {
         return false;
     }
     // no registered channels
     while ($channel = database::fetch($channel_q)) {
         database::delete('chans', array('channel', '=', $channel->channel));
         database::delete('chans_levels', array('channel', '=', $channel->channel));
         core::alog(core::$config->chanserv->nick . ': ' . $channel->channel . ' has expired. Last used on ' . date('F j, Y, g:i a', $channel->last_timestamp));
         // logchan it
         if (isset(core::$chans[$channel->channel])) {
             ircd::part_chan(core::$config->chanserv->nick, $channel->channel);
             // now lets leave the channel if we're in it
         }
         // unset some modes, leave the channel if its in use.. i know this shouldn't
         // be even thought about.. but maybe somebody idled in it and never even did
         // anything for the whole expiry period? :P
     }
     // channel is old i'm afraid, expire it
 }
示例#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..
 }