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 communicate($from, $to, $template, $data = '') { $ntemplate = $template; if ($data != '' && is_array($data)) { foreach ($data as $var => $value) { $ntemplate = str_replace('{' . $var . '}', $value, $ntemplate); } // loop through the array replacing each variable. } // IF there is a $data defined, we do some replacing // otherwise leave it alone if (nickserv::check_flags($to, array('P'))) { ircd::msg($from, $to, $ntemplate); } else { ircd::notice($from, $to, $ntemplate); } // if they are registered, we check their means of contact }
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 }
public function main(&$ircdata, $startup = false) { if ((core::$config->settings->loglevel == 'server' || core::$config->settings->loglevel == 'all') && ircd::on_connect(&$ircdata)) { $nick = core::get_nick(&$ircdata, core::$config->server->ircd == 'inspircd12' ? 4 : 3); // get nick ircd::notice(core::$config->global->nick, $nick, 'Services are currently running in debug mode, please be careful when sending passwords.'); // give them a quick notice that people can see their passwords. } if (ircd::on_chan_create(&$ircdata)) { $chans = explode(',', $ircdata[2]); // chan foreach ($chans as $chan) { if (core::$config->settings->logchan == $chan) { self::join_logchan(); } // join global to the logchan. } // on chan create bring our bot into it. } }
public function main(&$ircdata, $startup = false) { if (ircd::on_mode(&$ircdata)) { $nick = core::get_nick(&$ircdata, 0); $chan = core::get_chan(&$ircdata, 2); $mode_queue = core::get_data_after(&$ircdata, 4); if (strpos($nick, '.') !== false && core::$config->server->ircd != 'inspircd12') { $server = $nick; } elseif (strlen($nick) == 3 && core::$config->server->ircd == 'inspircd12') { $server = core::$servers[$nick]['sid']; } else { $server = ''; } // we've found a.in nick, which means it's a server? And it's NOT insp1.2 // OR we've noticed $nick is 3 chars long, which is a SID and it's insp1.2 if ($server == core::$config->ulined_servers || is_array(core::$config->ulined_servers) && in_array($server, core::$config->ulined_servers)) { return false; } // ignore mode changing from ulined servers. if (!($channel = services::chan_exists($chan, array('channel')))) { return false; } // channel isnt registered $modelock = chanserv::get_flags($chan, 'm'); // get the modelock if ($modelock != null) { $nmodelock = explode(' ', $modelock); foreach (str_split($nmodelock[0]) as $mode) { if (strstr($mode_queue, $mode)) { ircd::mode(core::$config->chanserv->nick, $chan, $modelock); } // reset the modes } } // modelock? } // we need to check for any modechanges here, for modelocking if (ircd::on_part(&$ircdata)) { $chan = core::get_chan(&$ircdata, 2); // get the channel if (chanserv::check_flags($chan, array('L'))) { timer::add(array('cs_flags', 'increase_limit', array($chan)), 10, 1); // add a timer to update the limit, in 15 seconds } // is there auto-limit enabled? } // on part we check for if (ircd::on_quit(&$ircdata)) { foreach (core::$chans as $chan => $data) { if (chanserv::check_flags($chan, array('L'))) { timer::add(array('cs_flags', 'increase_limit', array($chan)), 10, 1); // add a timer to update the limit, in 15 seconds } // is there auto-limit enabled? } } // on part we check for if (ircd::on_join(&$ircdata)) { $nick = core::get_nick(&$ircdata, 0); $chans = explode(',', $ircdata[2]); // find the nick & chan foreach ($chans as $chan) { if (!($channel = services::chan_exists($chan, array('channel')))) { return false; } // channel isnt registered if (chanserv::check_flags($chan, array('I'))) { if (chanserv::check_levels($nick, $chan, array('k', 'q', 'a', 'o', 'h', 'v', 'F'), true, false) === false) { ircd::mode(core::$config->chanserv->nick, $chan, '+b *@' . core::$nicks[$nick]['host']); ircd::kick(core::$config->chanserv->nick, $nick, $chan, '+k only channel.'); return false; } // they don't have +k, KICKEM } // is the channel +I, eg, +k users only? $welcome = chanserv::get_flags($chan, 'w'); // get the welcome msg if ($welcome != null) { ircd::notice(core::$config->chanserv->nick, $nick, '(' . $chan . ') ' . $welcome); // we give them the welcome msg } // is there any welcome msg? notice it to them if (chanserv::check_flags($chan, array('L'))) { timer::add(array('cs_flags', 'increase_limit', array($chan)), 10, 1); // add a timer to update the limit, in 15 seconds } // is there auto-limit enabled? } } // on_join entry msg // this is just a basic JOIN trigger if (ircd::on_chan_create(&$ircdata)) { $chans = explode(',', $ircdata[2]); // chan foreach ($chans as $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); if (!($channel = services::chan_exists($chan, array('channel')))) { return false; } // channel isnt registered if (chanserv::check_flags($chan, array('I'))) { foreach ($nusers as $nick => $mode) { if (chanserv::check_levels($nick, $chan, array('k', 'q', 'a', 'o', 'h', 'v', 'F'), true, false) === false) { ircd::mode(core::$config->chanserv->nick, $chan, '+b *@' . core::$nicks[$nick]['host']); ircd::kick(core::$config->chanserv->nick, $nick, $chan, '+k only channel.'); } // they don't have +k, KICKEM } } // is the channel +I, eg, +k users only? $welcome = chanserv::get_flags($chan, 'w'); // get the welcome msg if ($welcome != null) { foreach ($nusers as $nick => $mode) { if ($nick == core::$config->chanserv->nick) { continue; } // skip if it's chanserv ircd::notice(core::$config->chanserv->nick, $nick, '(' . $chan . ') ' . $welcome); // we give them the entrymsg } } // check for a welcome msg, if so // message it to the joining users. if (chanserv::check_flags($chan, array('L'))) { cs_flags::increase_limit($chan, 1); // add a timer to update the limit, in 15 seconds } // is there auto-limit enabled? } } // on channel create, we send out the welcome message // if there is one. }