public function main(&$ircdata, $startup = false) { self::on_chan_create(&$ircdata); // when a channel is created, NOT registered :) self::on_join(&$ircdata); // onjoin hook self::on_part(&$ircdata); // is the chan empty? gtfo. self::on_quit(&$ircdata); // is the channel empty? self::on_mode(&$ircdata); // check mode changes self::on_kick(&$ircdata); // on kick event. foreach (modules::$list as $module => $data) { if ($data['type'] == 'chanserv') { modules::$list[$module]['class']->main(&$ircdata, $startup); // loop through the modules for chanserv. } } if (ircd::on_msg(&$ircdata, core::$config->chanserv->nick)) { $nick = core::get_nick(&$ircdata, 0); $command = substr(core::get_data_after(&$ircdata, 3), 1); // convert to lower case because all the tingy wags are in lowercase self::get_command($nick, $command); } // this is what we use to handle command listens // should be quite epic. }
public function main(&$ircdata, $startup = false) { foreach (modules::$list as $module => $data) { if ($data['type'] == 'nickserv') { modules::$list[$module]['class']->main(&$ircdata, $startup); // loop through the modules for nickserv. } } if (ircd::on_msg(&$ircdata, core::$config->nickserv->nick)) { $nick = core::get_nick(&$ircdata, 0); $command = substr(core::get_data_after(&$ircdata, 3), 1); // convert to lower case because all the tingy wags are in lowercase self::get_command($nick, $command); } // this is what we use to handle command listens // should be quite epic. if (ircd::on_mode(&$ircdata) && core::$config->server->help_chan) { $chan = core::get_chan(&$ircdata, 2); if ($chan == strtolower(core::$config->server->help_chan)) { $re_data = $ircdata; unset($re_data[0], $re_data[1], $re_data[2], $re_data[3]); foreach ($re_data as $nick) { // we're going to guess that it's a nick here, lol. if (strstr(core::$chans[$chan]['users'][$nick], 'o')) { ircd::umode(core::$config->nickserv->nick, $nick, '+h'); } // user has +o, lets give em +h! } } // only deal with it if we're talking about the help chan } // here we deal with giving umode +h to ops :D if (ircd::on_chan_create(&$ircdata) && core::$config->server->help_chan) { $chans = explode(',', $ircdata[2]); // chans foreach ($chans as $chan) { if ($chan == strtolower(core::$config->server->help_chan)) { // the chan $nusers_str = implode(' ', $ircdata); $nusers_str = explode(':', $nusers_str); // right here we need to find out where the thing is $nusers = ircd::parse_users($chan, $nusers_str, 1); foreach ($nusers as $nick => $modes) { if (strstr($modes, 'o')) { ircd::umode(core::$config->nickserv->nick, $nick, '+h'); } // user has +o, lets give em +h! } } // only deal with it if we're talking about the help chan } } // and on_chan_create }
public function main(&$ircdata, $startup = false) { if (ircd::on_msg(&$ircdata, core::$config->nickserv->nick)) { $nick = core::get_nick(&$ircdata, 0); $query = substr(core::get_data_after(&$ircdata, 3), 1); // convert to lower case because all the tingy wags are in lowercase $query = strtolower($query); nickserv::get_help($nick, $query); } // only hook to the privmsg towards ChanServ, not channel messages // although chanserv shouldn't even be in any channels :P }
public function main(&$ircdata, $startup = false) { if (ircd::on_msg(&$ircdata, core::$config->operserv->nick)) { $nick = core::get_nick(&$ircdata, 0); $query = substr(core::get_data_after(&$ircdata, 3), 1); // convert to lower case because all the tingy wags are in lowercase $query = strtolower($query); if (core::$nicks[$nick]['ircop'] && services::user_exists($nick, true, array('display', 'identified') !== false)) { operserv::get_help($nick, $query); } } // only hook to the privmsg towards OperServ }
public static function ctcp(&$ircdata) { if (ircd::on_msg(&$ircdata)) { $nick = core::get_nick(&$ircdata, 0); $who = ircd::get_nick(&$ircdata, 2); if (substr($ircdata[3], 1) == 'VERSION') { ircd::notice($who, $nick, 'VERSION acora-' . core::$version . ' ' . ircd::$ircd . ' booted: ' . date('F j, Y, g:i a', core::$network_time) . ''); ircd::notice($who, $nick, 'VERSION (C) GamerGrid #acora @ irc.gamergrid.net'); } elseif (substr($ircdata[3], 1) == 'TIME') { ircd::notice($who, $nick, 'TIME ' . date('D M j G:i:s Y', core::$network_time) . ''); } elseif (substr($ircdata[3], 1) == 'PING') { ircd::notice($who, $nick, 'PING 0secs'); } elseif (substr($ircdata[3], 1) == 'FINGER') { ircd::notice($who, $nick, 'FINGER Get your finger out of my socket!'); } else { return false; } } // only trigger when we're being messaged. }
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 function main(&$ircdata, $startup = false) { foreach (modules::$list as $module => $data) { if ($data['type'] == 'operserv') { modules::$list[$module]['class']->main(&$ircdata, $startup); // loop through the modules for operserv. } } if (ircd::on_msg(&$ircdata, core::$config->operserv->nick)) { $nick = core::get_nick(&$ircdata, 0); $command = substr(core::get_data_after(&$ircdata, 3), 1); // convert to lower case because all the tingy wags are in lowercase core::alog(core::$config->operserv->nick . ': ' . $nick . ': ' . $command); // logchan it if (core::$nicks[$nick]['ircop'] && services::user_exists($nick, true, array('display', 'identified') !== false)) { self::get_command($nick, $command); } else { services::communicate(core::$config->operserv->nick, $nick, &self::$help->OS_DENIED_ACCESS); } // theyre an oper. } // this is what we use to handle command listens // should be quite epic. }
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 }