public function modload() { modules::init_module('cs_levels', self::MOD_VERSION, self::MOD_AUTHOR, 'chanserv', 'default'); // these are standard in module constructors chanserv::add_help('cs_levels', 'help', &chanserv::$help->CS_HELP_LEVELS_1); // add the help if (ircd::$halfop) { chanserv::add_help('cs_levels', 'help levels', &chanserv::$help->CS_HELP_LEVELS_ALL); } else { chanserv::add_help('cs_levels', 'help levels', &chanserv::$help->CS_HELP_LEVELS_ALL2); } // if we have halfop enabled the help we add is different. chanserv::add_command('levels', 'cs_levels', 'levels_command'); // add the command self::$flags = '+-kvhoaqsrftFb'; // string of valid flags if (!ircd::$halfop) { self::$flags = str_replace('h', '', self::$flags); } // if halfop isnt enabled, remove h and H if (!ircd::$protect) { self::$flags = str_replace('a', '', self::$flags); } // same for protect if (!ircd::$owner) { self::$flags = str_replace('q', '', self::$flags); } // and finally, owner }
public static function identify_command($nick, $ircdata = array()) { $password = $ircdata[0]; if (trim($password) == '') { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_SYNTAX_RE, array('help' => 'IDENTIFY')); return false; } // wrong syntax damit! if ($user = services::user_exists($nick, false, array('display', 'pass', 'identified', 'validated', 'salt', 'vhost'))) { if ($user->validated == 0) { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_AWAITING_VALIDATION); return false; } elseif ($user->identified == 1) { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ALREADY_IDENTIFIED); return false; } else { if ($user->pass == sha1($password . $user->salt)) { timer::remove(array('ns_identify', 'secured_callback', array($nick))); // remove the secured timer. if there is one ircd::on_user_login($nick); // registered mode database::update('users', array('identified' => 1, 'last_hostmask' => core::get_full_hostname($nick), 'last_timestamp' => 0), array('display', '=', $nick)); services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_IDENTIFIED); // right, standard identify crap core::alog(core::$config->nickserv->nick . ': ' . core::get_full_hostname($nick) . ' identified for nick ' . core::$nicks[$nick]['nick']); // logchan if ($user->vhost != '' && isset(modules::$list['os_vhost'])) { if (substr_count($user->vhost, '@') == 1) { $new_host = explode('@', $user->vhost); $ident = $new_host[0]; $host = $new_host[1]; ircd::setident(core::$config->operserv->nick, $user->display, $ident); ircd::sethost(core::$config->operserv->nick, $user->display, $host); } else { ircd::sethost(core::$config->operserv->nick, $user->display, $user->vhost); } } // first thing we do, check if they have a vhost, if they do, apply it. $failed_attempts = database::select('failed_attempts', array('nick', 'mask', 'time'), array('nick', '=', $nick)); if (database::num_rows($failed_attempts) > 0) { services::communicate(core::$config->nickserv->nick, $nick, '' . database::num_rows($failed_attempts) . ' failed login(s) since last login.'); while ($row = database::fetch($failed_attempts)) { services::communicate(core::$config->nickserv->nick, $nick, 'Failed login from: ' . $row->mask . ' on ' . date("F j, Y, g:i a", $row->time) . ''); } // loop through the failed attempts messaging them to the user database::delete('failed_attempts', array('nick', '=', $nick)); // clear them now that they've been seen } // we got any failed attempts? HUMM $hostname = core::get_full_hostname($nick); // generate a hostname. if (core::$config->settings->mode_on_id == 'yes' && isset(modules::$list['cs_levels'])) { foreach (core::$chans as $chan => $cdata) { $access_array = cs_levels::get_access($chan); // get the access array if ($nick == core::$config->chanserv->nick) { continue; } // skip us :D $hostname = core::get_full_hostname($nick); // get the hostname ready. foreach ($access_array as $target => $access) { if ($target == $nick) { $remove_access = false; // don't remove access cs_levels::give_access($chan, $nick, $access, chanserv::check_flags($chan, array('S'))); // give them access continue 2; // continue to next loop cause we've found a match } elseif (strpos($target, '@') !== false && services::match($hostname, $target)) { $remove_access = false; // don't remove access cs_levels::give_access($chan, $nick, $access, chanserv::check_flags($chan, array('S'))); // give them access continue 2; // continue to next loop cause we've found a match } elseif (strpos(core::$chans[$chan]['users'][$nick], 'o') !== false) { $remove_access = true; // set remove access to true continue 1; // continue to next loop to check other access records } else { continue 1; // continue to next loop to check other access records } // we check if the user has access, if they do break; // we also check if they dont have access and have op, if they do remove it. } // loop through the access records } // loop through channels, check if they are in any } // check if mode_on_id is set, also cs_access is enabled, and lets do a remote access gain :D } else { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_PASSWORD); core::alog(core::$config->nickserv->nick . ': Invalid password from ' . core::get_full_hostname($nick)); // some logging stuff database::insert('failed_attempts', array('nick' => $nick, 'mask' => core::get_full_hostname($nick), 'time' => core::$network_time)); core::$nicks[$nick]['failed_attempts']++; // ooh, we have something to log :) if (core::$nicks[$nick]['failed_attempts'] == 5) { ircd::kill(core::$config->nickserv->nick, $nick, 'Maxmium FAILED login attempts reached.'); } // have they reached the failed attempts limit? we gonna f*****g KILL mwhaha } // invalid password? HAX!! } // are they already identifed? } else { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_UNREGISTERED); return false; // doesn't even exist.. } // right now we need to check if the user exists, and password matches }
public static function sync_command($nick, $ircdata = array()) { $chan = $ircdata[0]; // standard data here. $channel = self::check_channel($nick, $chan, 'SYNC'); if ($channel === false) { return false; } // check if the channel exists and stuff if (chanserv::check_levels($nick, $chan, array('q', 'f', 'F')) === false) { services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED); return false; } // do they have access? 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. }
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 }