コード例 #1
0
ファイル: core.php プロジェクト: rickihastings/acorairc
 public static function flood_check(&$ircdata)
 {
     if (trim($ircdata[0]) == '') {
         return true;
     }
     // the data is empty, omgwtf..
     if (ircd::on_msg(&$ircdata) && $ircdata[2][0] == '#' && $ircdata[3][1] != self::$config->chanserv->fantasy_prefix) {
         return true;
     }
     // this is just here to instantly ignore any normal channel messages
     // otherwise we get lagged up on flood attempts
     if (ircd::on_notice(&$ircdata)) {
         return true;
     }
     // and ignore notices, since we shouldnt respond to any
     // notices what so ever, just saves wasting cpu cycles when we get a notice
     if (ircd::on_msg(&$ircdata) && $ircdata[2][0] != '#') {
         if (self::$config->settings->flood_msgs == 0 || self::$config->settings->flood_time == 0) {
             return false;
         }
         // check if it's disabled.
         $nick = self::get_nick(&$ircdata, 0);
         $time_limit = time() - self::$config->settings->flood_time;
         self::$nicks[$nick]['commands'][] = time();
         $from = self::get_nick(&$ircdata, 2);
         if (self::$nicks[$nick]['ircop']) {
             return false;
         }
         // ignore ircops
         $inc = 0;
         foreach (self::$nicks[$nick]['commands'] as $index => $timestamp) {
             if ($timestamp > $time_limit) {
                 $inc = 1;
             }
         }
         if ($inc == 1) {
             self::$nicks[$nick]['floodcmds']++;
         }
         // we've ++'d the floodcmds, if this goes higher than self::flood_trigger
         // they're flooding, floodcmds is cleared every 100 seconds.
         if (self::$nicks[$nick]['floodcmds'] > self::$config->settings->flood_msgs) {
             if (services::check_mask_ignore($nick) === true) {
                 return false;
             }
             if (self::$nicks[$nick]['offences'] == 0 || self::$nicks[$nick]['offences'] == 1) {
                 self::$nicks[$nick]['offences']++;
                 database::insert('ignored_users', array('who' => '*!*@' . self::$nicks[$nick]['host'], 'time' => core::$network_time));
                 timer::add(array('core', 'remove_ignore', array('*!*@' . self::$nicks[$nick]['host'])), 120, 1);
                 // add them to the ignore list.
                 // also, add a timer to unset it in 2 minutes.
                 $message = self::$nicks[$nick]['offences'] == 1 ? 'This is your first offence' : 'This is your last warning';
                 // compose a message.
                 services::communicate($from, $nick, operserv::$help->OS_COMMAND_LIMIT_1);
                 services::communicate($from, $nick, operserv::$help->OS_COMMAND_LIMIT_2, array('message' => $message));
                 self::alog(self::$config->operserv->nick . ': Offence #' . self::$nicks[$nick]['offences'] . ' for ' . self::get_full_hostname($nick) . ' being ignored for 2 minutes');
                 self::alog('flood_check(): Offence #' . self::$nicks[$nick]['offences'] . ' for ' . self::get_full_hostname($nick), 'BASIC');
                 return true;
             } elseif (self::$nicks[$nick]['offences'] >= 2) {
                 self::alog(self::$config->operserv->nick . ': Offence #' . self::$nicks[$nick]['offences'] . ' for ' . self::get_full_hostname($nick) . ' being glined for 10 minutes');
                 self::alog('flood_check(): Offence #' . self::$nicks[$nick]['offences'] . ' for ' . self::get_full_hostname($nick), 'BASIC');
                 ircd::gline(self::$config->operserv->nick, '*@' . self::$nicks[$nick]['oldhost'], 600, 'Flooding services, 10 minute ban.');
                 // third offence, wtf? add a 10 minute gline.
                 return true;
             }
         }
         // they're flooding
     }
 }