Example #1
0
 public function __construct()
 {
     require BASEPATH . '/lang/' . core::$config->server->lang . '/nickserv.php';
     self::$help =& $help;
     if (isset(core::$config->nickserv)) {
         ircd::introduce_client(core::$config->nickserv->nick, core::$config->nickserv->user, core::$config->nickserv->host, core::$config->nickserv->real);
     } else {
         return;
     }
     // connect the bot
     foreach (core::$config->nickserv_modules as $id => $module) {
         modules::load_module('ns_' . $module, $module . '.ns.php');
     }
     // load the nickserv modules
     timer::add(array('nickserv', 'check_expire', array()), 300, 0);
     // set a timer!
 }
Example #2
0
 public function __construct()
 {
     modules::init_module('mysql_driver', self::MOD_VERSION, self::MOD_AUTHOR, 'driver', 'static');
     // these are standard in module constructors
     if (!(self::$link = @mysql_connect(core::$config->database->server, core::$config->database->user, core::$config->database->pass))) {
         core::alog('database(): failed to connect to ' . core::$config->database->server . ' ' . core::$config->database->user . ':' . core::$config->database->pass, 'BASIC');
         core::save_logs();
         // force a log save
     }
     // can we connect to sql?
     if (!@mysql_select_db(core::$config->database->name, self::$link)) {
         core::alog('database(): failed to select database ' . core::$config->database->name, 'BASIC');
         core::save_logs();
         // force a log save
     }
     // can we select the database?
     core::alog('database(): connection to database sucessful', 'BASIC');
     // log the sucessful connection
     if (core::$config->database->optimize) {
         timer::add(array('database', 'optimize', array()), 86399, 0);
     }
     // add a timer to optimize the db every day.
 }
Example #3
0
 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
     }
 }
Example #4
0
 public static function get_information(&$ircdata)
 {
     if (isset($ircdata[0]) && $ircdata[0] == 'CAPAB' && $ircdata[1] == 'MODULES') {
         if (strpos($ircdata[2], 'm_services_account.so') === false) {
             timer::add(array('core', 'check_services', array()), 1, 1);
         } else {
             core::$services_account = true;
         }
         // we have services_account
         if (strpos($ircdata[2], 'm_globops.so') !== false) {
             self::$globops = true;
         }
         // we have globops!
         if (strpos($ircdata[2], 'm_chghost.so') !== false) {
             self::$chghost = true;
         }
         // we have chghost
         if (strpos($ircdata[2], 'm_chgident.so') !== false) {
             self::$chgident = true;
         }
         // and chgident
     }
     // only trigger when our modules info is coming through
     if (isset($ircdata[0]) && $ircdata[0] == 'CAPAB' && $ircdata[1] == 'CAPABILITIES') {
         $data = explode('=', $ircdata[16]);
         $data = $data[1];
         $new_mdata = isset($mdata) ? explode('=', $mdata) : '';
         $rmodes = '';
         if (strpos($data, 'q') !== false) {
             self::$owner = true;
             self::$status_modes[] .= 'q';
             $rmodes .= 'q';
         }
         // check if +q is there
         if (strpos($data, 'a') !== false) {
             self::$protect = true;
             self::$status_modes[] .= 'a';
             $rmodes .= 'a';
         }
         // and +a
         $hdata = implode(' ', $ircdata);
         if (strpos($hdata, 'HALFOP=1') !== false) {
             self::$halfop = true;
             self::$status_modes[] .= 'h';
             $rmodes .= 'h';
         }
         // we check halfop differently
         self::$status_modes[] .= 'o';
         self::$status_modes[] .= 'v';
         $modes = str_replace(',', '', $data);
         self::$modes = $rmodes . $modes . 'ov';
     }
     // only trigger when the capab capabilities is coming through
     return true;
 }
Example #5
0
 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
 }
Example #6
0
 public function introduce_callback($nick)
 {
     ircd::introduce_client($nick, 'enforcer', core::$config->server->name, $nick, true);
     self::$held_nicks[$nick] = core::$network_time;
     // introduce the client, set us as a held nick
     timer::add(array('ns_recover', 'remove_callback', array($nick)), self::$expiry_time, 1);
     // add a timer.
 }
Example #7
0
 public static function _registered_nick($nick, $user)
 {
     database::update('users', array('identified' => 0), array('display', '=', $nick));
     // set them to identified 0, this might fix that long term bug.
     ircd::on_user_logout($nick);
     // they shouldn't really have registered mode
     if (is_array(nickserv::$help->NS_REGISTERED_NICK)) {
         foreach (nickserv::$help->NS_REGISTERED_NICK as $line) {
             services::communicate(core::$config->nickserv->nick, $nick, $line);
         }
     } else {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_REGISTERED_NICK);
     }
     // this is just a crappy function, basically just parses the NS_REGISTERED thing
     // we check for arrays and single lines, even though the default is array
     // someone might have changed it.
     if (nickserv::check_flags($nick, array('S')) && isset(modules::$list['ns_flags'])) {
         timer::add(array('ns_identify', 'secured_callback', array($nick)), core::$config->nickserv->secure_time, 1);
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_SECURED_NICK, array('seconds' => core::$config->nickserv->secure_time));
     }
     // if the nickname has secure enabled, we let them know that we're watching them :o
 }
Example #8
0
 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.
 }