public function main(&$ircdata, $startup = false) { if (ircd::on_topic(&$ircdata) || ircd::on_ftopic(&$ircdata)) { $chan = core::get_chan(&$ircdata, 2); $topic = core::$chans[$chan]['topic']; $setter = core::$chans[$chan]['topic_setter']; // i forgot this was done by the protocol modules if ($channel = services::chan_exists($chan, array('channel', 'topic'))) { if (chanserv::check_flags($chan, array('T')) && chanserv::check_flags($chan, array('K')) && $channel->topic != $topic) { ircd::topic(core::$config->chanserv->nick, $channel->channel, $channel->topic); database::update('chans', array('topic_setter' => core::$config->chanserv->nick), array('channel', '=', $chan)); return false; // reset it i reckon. } elseif ($channel->topiclock == 0) { database::update('chans', array('topic' => $topic, 'topic_setter' => $setter), array('channel', '=', $chan)); // OTHERWISE, update it. } // some housekeepin. } // make sure the channel exists. } // now we check for topiclocking // moved this from cs_set to here // there was 2 versions O.o }
public static function _join_channel(&$channel) { database::update('chans', array('last_timestamp' => core::$network_time), array('channel', '=', $channel->channel)); // lets update the last used timestamp if (self::check_flags($channel->channel, array('G')) && $channel->suspended == 0 && isset(modules::$list['cs_fantasy']) && !isset(core::$chans[$channel->channel]['users'][core::$config->chanserv->nick])) { ircd::join_chan(core::$config->chanserv->nick, $channel->channel); // join the chan. if (ircd::$protect) { ircd::mode(core::$config->chanserv->nick, $channel->channel, '+ao ' . core::$config->chanserv->nick . ' ' . core::$config->chanserv->nick); } else { ircd::mode(core::$config->chanserv->nick, $channel->channel, '+o ' . core::$config->chanserv->nick); } // +o its self. } // check if guard is on $modelock = self::get_flags($channel->channel, 'm'); // store some flag values in variables. if ($modelock != null && $channel->suspended == 0) { ircd::mode(core::$config->chanserv->nick, $channel->channel, $modelock); // Going to have to do some fuffing around here, basically if the channel // in question is mlocked +i, and somebody has joined it, while its empty // +i will be set after they have joined the channel, so here we're gonna // have to kick them out, same applies for +O and +k $mode_array = mode::sort_modes($modelock); if (strstr($mode_array['plus'], 'i') || strstr($mode_array['plus'], 'k')) { foreach (core::$chans[$channel->channel]['users'] as $nick => $modes) { if (count(core::$chans[$channel->channel]['users']) == 2 && isset(core::$chans[$channel->channel]['users'][core::$config->chanserv->nick])) { if (self::check_levels($nick, $channel->channel, array('k', 'v', 'h', 'o', 'a', 'q', 'F'), true, false) === false) { if (strstr($mode_array['plus'], 'i') && $nick != core::$config->chanserv->nick) { ircd::kick(core::$config->chanserv->nick, $nick, $channel->channel, 'Invite only channel'); timer::add(array('chanserv', 'part_chan_callback', array($channel->channel)), 1, 1); } if (strstr($mode_array['plus'], 'k') && $nick != core::$config->chanserv->nick) { ircd::kick(core::$config->chanserv->nick, $nick, $channel->channel, 'Passworded channel'); timer::add(array('chanserv', 'part_chan_callback', array($channel->channel)), 1, 1); } } } // if the user isn't on the access list // we kick them out ^_^ } } // is mode i in the modelock? if (strstr($mode_array['plus'], 'O')) { foreach (core::$chans[$channel->channel]['users'] as $nick => $modes) { if (!core::$nicks[$nick]['ircop']) { ircd::kick(core::$config->chanserv->nick, $nick, $channel->channel, 'IRCop only channel'); timer::add(array('chanserv', 'part_chan_callback', array($channel->channel)), 1, 1); } // if the user isn't on the access list // we kick them out ^_^ } } // how about +O? } // any modelocks? if (self::check_flags($channel->channel, array('K')) && !self::check_flags($channel->channel, array('T')) && isset(modules::$list['cs_flags']) && isset(modules::$list['cs_topic'])) { if (trim($channel->topic) != trim(core::$chans[$channel->channel]['topic']) || $channel->topic != '') { ircd::topic(core::$config->chanserv->nick, $channel->channel, $channel->topic); } // set the previous topic } // set the topic to the last known topic }
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 }