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 } }
public static function get_command($hook, &$nick, &$command) { // this works better than i imagined if (services::check_mask_ignore($nick) === true) { return false; } // this is basically to check if we have // an ignored user, via their hostmask, or their nickname. if ($hook == 'chanserv') { $bot = core::$config->chanserv->nick; } if ($hook == 'nickserv') { $bot = core::$config->nickserv->nick; } if ($hook == 'operserv') { $bot = core::$config->operserv->nick; } // what we sending from? $command = trim($command); $commands = explode(' ', $command); $num_cmds = count($commands); $commands_r = $commands; // some vars.. if (strtolower($commands[0]) == 'help' || $command == '' || substr($commands[0], 0, 1) == '') { return false; } // its a command we don't need to deal with, ignore it for ($i = $num_cmds; $i > -1; $i--) { unset($commands[$i]); $new_params[] = trim($commands_r[$i]); $new = strtolower(implode(' ', $commands)); // i really cba explaining this.. if (isset(self::$commands[$hook][$new])) { break; } } // just a loop to.. err can't remember what this does.. // something interesting though $new_params = array_reverse($new_params); // house keeping foreach ($new_params as $ii => $pp) { if ($pp == '') { unset($new_params[$ii]); } } // more housekeeping if (!isset(self::$commands[$hook][$new])) { self::$unknown_cmds++; services::communicate($bot, $nick, 'Unknown command ' . $commands_r[0] . '.'); return false; } // command don't exist, at all.. $class = strtolower(self::$commands[$hook][$new]['class']); $function = strtolower(self::$commands[$hook][$new]['function']); // get the function stuff. if (!is_callable(array($class, $function), true) || !method_exists($class, $function)) { core::alog($class . '::' . $function . '() isn\'t callable, command rejected.', 'BASIC'); return false; } // reject the command attempt. output an error //modules::$list[$class]['class']->$function( $nick, $new_params ); call_user_func_array(array($class, $function), array($nick, $new_params)); // it does! execute the callback }