Esempio n. 1
0
 public static function motd(&$ircdata)
 {
     if (isset($ircdata[1]) && $ircdata[1] == 'MOTD') {
         $nick = core::get_nick(&$ircdata, 0);
         if (!file_exists(CONFPATH . 'services.motd')) {
             ircd::push(core::$config->server->name, $nick, 'MOTD File is missing');
             return false;
         }
         $lines = file(CONFPATH . 'services.motd');
         foreach ($lines as $num => $line) {
             $lines[$num] = rtrim($line);
         }
         // strip the crap out of it
         ircd::push(core::$config->server->name, 375, $nick, array(':', str_replace('{server}', core::$config->server->name, ircd::$motd_start)));
         // send the start of the motd.
         foreach ($lines as $num => $line) {
             if (strpos($line, '{version}') !== false) {
                 $line = str_replace('{version}', core::$version, $line);
             }
             if (strpos($line, '{uptime}') !== false) {
                 $line = str_replace('{uptime}', core::format_time(core::$uptime), $line);
             }
             // replaceable variables here.
             ircd::push(core::$config->server->name, 372, $nick, array(':', '-', $line));
         }
         // loop through, throwing the line at the client :D
         ircd::push(core::$config->server->name, 376, $nick, array(':', ircd::$motd_end));
         // send the end of the motd.
     }
     // only triggered if someone asks us for a MOTD.
 }
Esempio n. 2
0
 public static function ghost_command($nick, $ircdata = array())
 {
     $unick = $ircdata[0];
     $password = $ircdata[1];
     // get the parameters.
     if (trim($unick) == '' || trim($password) == '') {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_SYNTAX_RE, array('help' => 'GHOST'));
         return false;
     }
     // invalid syntax
     if (!isset(core::$nicks[$unick])) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_NOT_IN_USE, array('nick' => $unick));
         return false;
         // nickname isn't in use
     }
     if ($user = services::user_exists($unick, false, array('display', 'pass', 'salt'))) {
         if ($user->pass == sha1($password . $user->salt) || core::$nicks[$nick]['ircop'] && services::user_exists($nick, true, array('display', 'identified')) !== false) {
             ircd::kill(core::$config->nickserv->nick, $unick, 'GHOST command used by ' . core::get_full_hostname($nick));
             core::alog(core::$config->nickserv->nick . ': GHOST command used on ' . $unick . ' by ' . core::get_full_hostname($nick));
         } else {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_PASSWORD);
             // password isn't correct
         }
     } else {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ISNT_REGISTERED, array('nick' => $unick));
         return false;
         // doesn't even exist..
     }
 }
Esempio n. 3
0
 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
 }
Esempio n. 4
0
 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
 }
Esempio n. 5
0
 public static function drop_command($nick, $ircdata = array())
 {
     $unick = core::get_nick(&$ircdata, 0);
     $password = $ircdata[1];
     // get the nick.
     if (trim($unick) == '' || trim($password) == '' && (!core::$nicks[$nick]['ircop'] || services::user_exists($nick, true, array('display', 'identified')) === false)) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_SYNTAX_RE, array('help' => 'DROP'));
         return false;
     }
     // invalid syntax
     if (services::is_root($unick) && !services::is_root($nick)) {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ACCESS_DENIED);
         return false;
     }
     // is a non-root trying to drop a root?
     if ($user = services::user_exists($unick, false, array('id', 'display', 'pass', 'salt', 'suspended'))) {
         if ($user->suspended == 1) {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_SUSPEND_1, array('nick' => $user->display));
             return false;
         }
         // are they suspended?
         if ($user->pass == sha1($password . $user->salt) || core::$nicks[$nick]['ircop'] && services::user_exists($nick, true, array('display', 'identified')) !== false) {
             database::delete('users', array('display', '=', $user->display));
             database::delete('users_flags', array('nickname', '=', $user->display));
             // delete the users record
             database::delete('chans_levels', array('target', '=', $user->display));
             // also delete this users channel access.
             core::alog(core::$config->nickserv->nick . ': ' . $user->display . ' has been dropped by ' . core::get_full_hostname($nick));
             // logchan it
             core::alog('drop_command(): ' . $user->display . ' has been dropped by ' . core::get_full_hostname($nick), 'BASIC');
             // log what we need to log.
             if (isset(core::$nicks[$user->display])) {
                 ircd::on_user_logout($nick->display);
             }
             // if the nick is being used unregister it, even though it shouldn't be?
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_NICK_DROPPED, array('nick' => $user->display));
             // let the nick know the account has been dropped.
         } else {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_INVALID_PASSWORD);
             // password isn't correct
         }
     } else {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ISNT_REGISTERED, array('nick' => $unick));
         return false;
         // doesn't even exist..
     }
 }
Esempio n. 6
0
 public static function chanclear_command($nick, $ircdata = array())
 {
     $chan = core::get_chan(&$ircdata, 1);
     $reason = core::get_data_after(&$ircdata, 2);
     $mode = strtoupper($ircdata[0]);
     // get the data.
     if (trim($chan) == '' || trim($reason) == '' || !in_array($mode, array('KICK', 'KILL', 'GLINE'))) {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX_RE, array('help' => 'CHANCLEAR'));
         return false;
         // wrong syntax
     }
     if ($chan[0] != '#') {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX_RE, array('help' => 'CHANCLEAR'));
         return false;
         // wrong syntax
     }
     if (isset(core::$chans[$chan])) {
         foreach (core::$chans[$chan]['users'] as $user => $umode) {
             if (core::$nicks[$user]['ircop']) {
                 core::alog(core::$config->operserv->nick . ': Ignoring IRC Operator (' . $user . ')');
                 // ignore irc operator, infact, logchan it too
             } else {
                 if ($mode == 'KICK') {
                     ircd::kick(core::$config->operserv->nick, $user, $chan, 'CHANKILL by ' . $nick . ' (' . $reason . ')');
                     ircd::mode(core::$config->operserv->nick, $chan, '+b *@' . core::$nicks[$user]['host']);
                     // kick and +b them
                 } elseif ($mode == 'KILL') {
                     ircd::kill(core::$config->operserv->nick, $user, 'CHANKILL by ' . $nick . ' (' . $reason . ')');
                 } elseif ($mode == 'GLINE') {
                     ircd::gline(core::$config->operserv->nick, '*@' . core::$nicks[$user]['oldhost'], 604800, 'CHANKILL by ' . $nick . ' (' . $reason . ')');
                 }
                 // remove all other users.
             }
         }
         // loop through the people in the channel/
     } else {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_CHAN_INVALID, array('chan' => $chan));
     }
     // check if the channel is in use..
 }
Esempio n. 7
0
 public static function logout_command($nick, $ircdata = array())
 {
     // no parameter commands ftw.
     if ($user = services::user_exists($nick, false, array('display', 'id', 'identified', 'vhost'))) {
         if ($user->identified == 1) {
             ircd::on_user_logout($nick);
             // here we set unregistered mode
             database::update('users', array('identified' => 0, 'last_timestamp' => core::$network_time), array('display', '=', $nick));
             // unidentify them
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_LOGGED_OUT);
             // let them know
             core::alog(core::$config->nickserv->nick . ': ' . core::get_full_hostname($nick) . ' logged out of ' . core::$nicks[$nick]['nick']);
             // and log it.
         } else {
             services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_NOT_IDENTIFIED);
             // not even identified
         }
     } else {
         services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_UNREGISTERED);
         // unregistered nick name
     }
 }
Esempio n. 8
0
 public function modunload_command($nick, $ircdata = array())
 {
     $module = $ircdata[0];
     // get the module thats been requested.
     if (services::is_root($nick)) {
         if (trim($module) == '') {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX_RE, array('help' => 'MODUNLOAD'));
             // wrong syntax
             return false;
         }
         if (!isset(modules::$list[$module])) {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_MODUNLOAD_1, array('name' => $module));
             return false;
         }
         if (modules::$list[$module]['extra'] == 'static') {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_MODUNLOAD_2, array('name' => $module));
             core::alog(core::$config->operserv->nick . ': unable to unload static module ' . $module);
             core::alog('modunload_command(): unable to unload static module ' . $module . ' (cannot be unloaded)', 'BASIC');
             // log what we need to log.
             return false;
         }
         if (!class_exists($module)) {
             services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_MODUNLOAD_2, array('name' => $module));
             core::alog(core::$config->operserv->nick . ': unable to unload module ' . $module);
             core::alog('modunload_command(): unable to unload module ' . $module . ' (not booted)', 'BASIC');
             // log what we need to log.
             return false;
         }
         if (is_callable(array($module, 'modunload'), true) && method_exists($module, 'modunload')) {
             modules::$list[$module]['class']->modunload();
         }
         // if the module has an unload method, call it now before we destroy the class.
         unset(modules::$list[$module]);
         // unset the module
         modules::_unset_docs($module);
         // unset the modules help docs etc.
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_MODUNLOAD_3, array('name' => $module));
         core::alog(core::$config->operserv->nick . ': unloaded module ' . $module);
         ircd::globops(core::$config->operserv->nick, $nick . ' unloaded module ' . $module);
         // let everyone know :D
     } else {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_ACCESS_DENIED);
     }
 }
Esempio n. 9
0
 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.
 }
Esempio n. 10
0
 public static function increase_limit($chan, $force = 0)
 {
     $current_users = count(core::$chans[$chan]['users']);
     $new_limit = $current_users + 2 + $force;
     // plus 3
     ircd::mode(core::$config->chanserv->nick, $chan, '+l ' . $new_limit);
     // mode change.
 }
Esempio n. 11
0
 public static function init_server($name, $pass, $desc, $numeric)
 {
     self::$sid = $numeric;
     self::send('SERVER ' . $name . ' ' . $pass . ' 0 ' . self::$sid . ' :' . $desc);
     self::send(':' . self::$sid . ' BURST ' . core::$network_time);
     // init the server
     self::send(':' . self::$sid . ' VERSION :acora-' . core::$version . ' ' . core::$config->server_name . ' ' . core::$config->ircd . ' booted: ' . date('F j, Y, g:i a', core::$network_time) . '');
     // ooh, version?
     core::alog('init_server(): ' . $name . ' introduced :' . $desc, 'BASIC');
     // log it
 }
Esempio n. 12
0
 public static function type_check($chan, $level, $mode, $cnick)
 {
     $part = explode(':', $level);
     $nicks = array();
     if ($part[1] == '') {
         return false;
     }
     // we need to make sure we're actually given something.
     if ($mode[0] != '+' && $mode[0] != '-') {
         return false;
     }
     // make sure we're getting +/-
     if (strpos('qaohv', $mode[1]) === false) {
         return false;
     }
     // we can only set on these modes, for now.
     if (count(core::$chans[$chan]['users']) == 0) {
         return false;
     }
     // is the channel empty?
     if ($part[0] == 'level') {
         if ($part[1] == '0') {
             foreach (core::$chans[$chan]['users'] as $nick => $modes) {
                 if (strpos($modes, 'o') === false && strpos($modes, 'h') === false && strpos($modes, 'v') === false) {
                     $nicks[] .= $nick;
                 }
             }
             // loop through, finding users that are level 0, or more
             // commonly, don't have any status modes.
         } elseif ($part[1] == 'v' || $part[1] == ircd::$prefix_modes['v']) {
             foreach (core::$chans[$chan]['users'] as $nick => $modes) {
                 if (strpos($modes, 'v') !== false) {
                     $nicks[] .= $nick;
                 }
             }
             // again we loop, finding users that have voice.
         } elseif (($part[1] == 'h' || $part[1] == ircd::$prefix_modes['h']) && ircd::$halfop) {
             foreach (core::$chans[$chan]['users'] as $nick => $modes) {
                 if (strpos($modes, 'h') !== false) {
                     $nicks[] .= $nick;
                 }
             }
             // again we loop, finding users that have halfop.
         } elseif ($part[1] == 'o' || $part[1] == ircd::$prefix_modes['o']) {
             foreach (core::$chans[$chan]['users'] as $nick => $modes) {
                 if (strpos($modes, 'o') !== false) {
                     $nicks[] .= $nick;
                 }
             }
             // again we loop, finding users that have operator.
         } elseif (($part[1] == 'a' || $part[1] == ircd::$prefix_modes['a']) && ircd::$protect) {
             foreach (core::$chans[$chan]['users'] as $nick => $modes) {
                 if (strpos($modes, 'a') !== false) {
                     $nicks[] .= $nick;
                 }
             }
             // again we loop, finding users that have admin.
         } elseif (($part[1] == 'q' || $part[1] == ircd::$prefix_modes['q']) && ircd::$owner) {
             foreach (core::$chans[$chan]['users'] as $nick => $modes) {
                 if (strpos($modes, 'q') !== false) {
                     $nicks[] .= $nick;
                 }
             }
             // again we loop, finding users that have owner.
         } elseif ($part[1] == '*') {
             foreach (core::$chans[$chan]['users'] as $nick => $modes) {
                 $nicks[] .= $nick;
             }
             // and last but not least, all :)
             // note we don't need to do any checks here.
         } else {
             return false;
         }
     } elseif ($part[0] == 'mask') {
         if (strpos($part[1], '@') === false) {
             $part[1] = '*@' . $part[1];
         }
         if (strpos($part[1], '!') === false) {
             $part[1] = '*!' . $part[1];
         }
         // mask is malformed
         foreach (core::$chans[$chan]['users'] as $nick => $modes) {
             $hostname = core::get_full_hostname($nick);
             if (services::match($hostname, $part[1])) {
                 $nicks[] .= $nick;
             }
             // this needs tested, although i'm purty confident i'll work.
         }
         // loop through our users, and find a matching mask >:D
     } else {
         return false;
     }
     // something is invalid here, back out.
     if (count($nicks) == 0) {
         return false;
     }
     // empty array :(
     foreach ($nicks as $id => $nick) {
         if ($nick == $cnick) {
             unset($nicks[$id]);
         }
     }
     // we don't want chanserv in our list, eww.
     $i = 0;
     $x = count($nicks);
     $mode_string = $mode[0];
     $nick_string = ' ';
     foreach ($nicks as $id => $nick) {
         $i++;
         // plus plus
         $mode_string .= $mode[1];
         $nick_string .= $nick . ' ';
         // add stuff to the strings.
         if ($i == ircd::$max_params || $i == $x) {
             ircd::mode($cnick, $chan, trim($mode_string . $nick_string));
             // send the modes
             $i = 0;
             $mode_string = $mode[0];
             $nick_string = ' ';
             // reset all our strings :D
         } else {
             unset($nicks[$id]);
         }
         // bit of maths, well, not much, lol.
     }
     // ok, so we've got our list, instead of sending the modes one by one, here's
     // what we're gonna do, we're gonna compress it into a mode string, setting
     // 6 at a time, sound good? indeed it does.
     if (count($nicks) > 0) {
         ircd::mode($cnick, $chan, trim($mode_string . $nick_string));
     }
     // send the remaining modes
     unset($nicks);
 }
Esempio n. 13
0
 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
 }
Esempio n. 14
0
 public static function restart_command($nick, $ircdata = array())
 {
     // we don't even need to listen for any
     // parameters, because its just a straight command
     if (services::is_root($nick)) {
         if (isset(core::$config->settings->shutdown_message) || core::$config->settings->shutdown_message != null) {
             ircd::global_notice(core::$config->global->nick, '*!*@*', core::$config->settings->shutdown_message);
         }
         // is there a shutdown message?
         core::save_logs();
         // save logs.
         ircd::shutdown('shutdown command from ' . $nick, false);
         // exit the server
         fclose(core::$socket);
         // close the socket first.
         if (substr(php_uname(), 0, 7) != 'Windows') {
             if (core::$debug) {
                 system('php ' . BASEPATH . '/services.php debug');
             } else {
                 exec('php ' . BASEPATH . '/services.php > /dev/null &');
             }
             // reboot if we're running anything but windows
             // if debug we send the output back to the screen, else we send it to /dev/null
         } else {
             if (!isset(core::$config->settings->php_dir) || core::$config->settings->php_dir == '') {
                 define('PHPDIR', 'C:\\php\\php.exe');
             } else {
                 define('PHPDIR', core::$config->settings->php_dir);
             }
             // define where the php binary is located.
             exec('@cd ' . BASEPATH);
             // cd to the basedir
             if (core::$debug) {
                 system('@' . PHPDIR . ' services.php debug');
             } else {
                 exec('@' . PHPDIR . ' services.php');
             }
             // if we run windows we do a different method of reboot
             // again if we debug we send it to the screen, if not.. we don't
         }
         exit;
         // exit the program
     } else {
         services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_ACCESS_DENIED);
     }
 }
Esempio n. 15
0
 public static function get_nick(&$ircdata, $number)
 {
     return ircd::get_nick(&$ircdata, $number);
     // moved this into the protocol module
 }
Esempio n. 16
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;
 }
Esempio n. 17
0
 public static function get_information(&$ircdata)
 {
     if (isset($ircdata[0]) && $ircdata[0] == 'PROTOCTL') {
         $data = explode('=', $ircdata[13]);
         $data = $data[1];
         $new_mdata = isset($mdata) ? explode('=', $mdata) : '';
         $rmodes = '';
         if (strpos($data, 'h') !== false) {
             self::$halfop = true;
             self::$status_modes[] .= 'h';
             $rmodes .= 'h';
         }
         // and +h
         self::$status_modes[] .= 'q';
         self::$status_modes[] .= 'a';
         $rmodes .= 'q';
         $rmodes .= 'a';
         self::$status_modes[] .= 'o';
         self::$status_modes[] .= 'v';
         // we dont check for q/a, cause unreal supports them no matter what
         $modes = str_replace(',', '', $data);
         self::$modes = $rmodes . $modes . 'ov';
     }
     // only trigger when the capab capabilities is coming through
     return true;
 }
Esempio n. 18
0
 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
 }
Esempio n. 19
0
 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
 }
Esempio n. 20
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
 }
Esempio n. 21
0
 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.
     }
 }
Esempio n. 22
0
 public static function _drop_check($nick, $chan)
 {
     if ($chan == '' || $chan[0] != '#') {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_INVALID_SYNTAX_RE, array('help' => 'DROP'));
         return false;
         // wrong syntax
     }
     // make sure they've entered a channel
     if (services::chan_exists($chan, array('channel')) === false) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_UNREGISTERED_CHAN, array('chan' => $chan));
         return false;
     }
     // make sure the channel exists.
     if (chanserv::_is_founder($nick, $chan)) {
         return true;
     } elseif (core::$nicks[$nick]['ircop'] && services::user_exists($nick, true, array('display', 'identified'))) {
         ircd::globops(core::$config->chanserv->nick, $nick . ' used DROP on ' . $chan);
         return true;
     }
     services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
     return false;
     // do they have access?
 }
Esempio n. 23
0
 public static function rehash_command($nick, $ircdata = array())
 {
     $parser = new parser(CONFPATH . 'services.conf');
     // load the parser
     $total_modules_exceptions = array();
     $mod_info = array('cs' => 'chanserv', 'ns' => 'nickserv', 'os' => 'operserv', 'core' => 'core');
     foreach ($mod_info as $short => $full) {
         $category_name = $full . '_modules';
         foreach (core::$config->{$category_name} as $id => $module) {
             $total_modules[$short . '_' . $module] = array('type' => $short, 'file' => $module . '.' . $short . '.php');
         }
     }
     // merge all the arrays to check that the loaded and excluded modules are all correct
     foreach (modules::$list as $name => $details) {
         if (!isset($total_modules[$name]) && $details['extra'] != 'static') {
             if (is_callable(array($name, 'modunload'), true) && method_exists($name, 'modunload')) {
                 modules::$list[$name]['class']->modunload();
             }
             // if the module has an unload method, call it now before we destroy the class.
             unset(modules::$list[$name]);
             modules::_unset_docs($name);
             // destory relevant data to the module
             core::alog(core::$config->operserv->nick . ': unloaded module ' . $name);
             ircd::globops(core::$config->operserv->nick, 'unloaded module ' . $name);
             // unset the module
             core::alog('rehash_command(): ' . $name . ' unloaded from rehash', 'BASIC');
             // log what we need to log.
         }
         // the module is loaded and should be unloaded
     }
     // go through each set module and unset the now exempt modules
     foreach ($total_modules as $name => $details) {
         if (!isset(modules::$list[$name])) {
             if (!class_exists($name)) {
                 modules::load_module($name, $details['file']);
                 // load the module
             } else {
                 if (!(modules::$list[$name]['class'] = new $name())) {
                     core::alog('load_module(): unable to start: ' . $name . ' (boot error)', 'BASIC');
                     return false;
                 }
             }
             core::alog(core::$config->operserv->nick . ': loaded module ' . $name);
             ircd::globops(core::$config->operserv->nick, 'loaded module ' . $name);
             // load it up
             core::alog('rehash_command(): ' . $name . ' loaded from rehash', 'BASIC');
             // log what we need to log.
             modules::$list[$name]['class']->modload();
             // onload handler.
         }
     }
     // go through every module
     // load the ones that are new.
     core::alog(core::$config->operserv->nick . ': Successfully reloaded configuration.');
     ircd::globops(core::$config->operserv->nick, $nick . ' performed a REHASH');
     core::alog('rehash_command(): sucessful rehash', 'BASIC');
     // log what we need to log.
 }
Esempio n. 24
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
 }
Esempio n. 25
0
 public static function unban_command($nick, $ircdata = array())
 {
     $chan = $ircdata[0];
     $who = $ircdata[1];
     // standard data here.
     if (self::check_channel($nick, $chan, 'UNBAN') === false) {
         return false;
     }
     // check if the channel exists and stuff
     if (chanserv::check_levels($nick, $chan, array('r', 'F')) === false) {
         services::communicate(core::$config->chanserv->nick, $nick, &chanserv::$help->CS_ACCESS_DENIED);
         return false;
     }
     // do they have access?
     if (strpos($ircdata[1], '@') === false && ($user = core::search_nick($ircdata[1]))) {
         ircd::mode(core::$config->chanserv->nick, $chan, '-b *@' . $user['host']);
     } else {
         ircd::mode(core::$config->chanserv->nick, $chan, '-b ' . $ircdata[1]);
     }
     // -b
 }
Esempio n. 26
0
 public static function check_expire()
 {
     if (core::$config->nickserv->expire == 0) {
         return false;
     }
     // skip nicknames if config is set to no expire.
     $expiry_time = core::$config->nickserv->expire * 86400;
     $check_time = core::$network_time - $expiry_time;
     // set up our times.
     $nick_q = database::select('users', array('id', 'display', 'last_timestamp'), array('last_timestamp', '!=', '0', 'AND', 'last_timestamp', '<', $check_time));
     if (database::num_rows($nick_q) == 0) {
         return false;
     }
     // no expiring nicknames
     while ($nick = database::fetch($nick_q)) {
         // Mikeh gets most of the credit for helping
         // me code this function
         database::delete('users', array('display', '=', $nick->display));
         database::delete('users_flags', array('nickname', '=', $user->display));
         // delete the users record
         database::delete('chans_levels', array('target', '=', $nick->display));
         // also delete this users channel access.
         core::alog(core::$config->nickserv->nick . ': ' . $nick->display . ' has expired. Last used on ' . date('F j, Y, g:i a', $nick->last_timestamp));
         // logchan it
         if (isset(core::$nicks[$nick->display])) {
             ircd::on_user_logout($nick->display);
         }
         // if the nick is being used unregister it, even though it shouldn't be, just to be safe.
     }
     // loop through all expiring nicks.
 }
Esempio n. 27
0
 public function main(&$ircdata, $startup = false)
 {
     if (ircd::on_connect(&$ircdata)) {
         $nick = core::get_nick(&$ircdata, core::$config->server->ircd == 'inspircd12' ? 4 : 3);
         if ($user = services::user_exists($nick, false, array('display', 'suspended'))) {
             if ($user->suspended == 1) {
                 $random_nick = 'Unknown' . rand(10000, 99999);
                 services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_SUSPEND_1, array('nick' => $user->display));
                 services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_NICK_CHANGE, array('nick' => $random_nick));
                 ircd::svsnick($nick, $random_nick, core::$network_time);
             }
         }
         // check if the nick is suspended etc.
     }
     // trigger on connect
     if (ircd::on_nick_change(&$ircdata)) {
         $nick = core::get_nick($ircdata, 2);
         // get the nicknames
         if ($user = services::user_exists($nick, false, array('display', 'suspended'))) {
             if ($user->suspended == 1) {
                 $random_nick = 'Unknown' . rand(10000, 99999);
                 services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_SUSPEND_1, array('nick' => $user->display));
                 services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_NICK_CHANGE, array('nick' => $random_nick));
                 ircd::svsnick($nick, $random_nick, core::$network_time);
             }
         }
         // check if the nick is suspended etc.
     }
     // trigger on nick change
 }
Esempio n. 28
0
 public static function give_access($chan, $nick, $chan_access, $secure = 1)
 {
     if ($secure && services::user_exists($nick, true, array('display', 'identified')) === false) {
         return false;
     }
     // return false if secure is set to 1 and $nick isnt identified.
     $mode_string = '';
     $mode_params = '';
     foreach ($chan_access as $level) {
         if ($level == '5' && ircd::$owner) {
             $mode_string .= 'q';
             $mode_params .= $nick . ' ';
         }
         // we've found a +q!
         if ($level == '4' && ircd::$protect) {
             $mode_string .= 'a';
             $mode_params .= $nick . ' ';
         }
         // we've found a +a!
         if ($level == '3') {
             $mode_string .= 'o';
             $mode_params .= $nick . ' ';
         }
         // we've found a +o!
         if ($level == '2' && ircd::$halfop) {
             $mode_string .= 'h';
             $mode_params .= $nick . ' ';
         }
         // we've found a +h!
         if ($level == '1') {
             $mode_string .= 'v';
             $mode_params .= $nick . ' ';
         }
         // we've found a +v!
     }
     // loop through access records
     // levels are as follows;
     // 5 - q
     // 4 - a
     // 3 - o
     // 2 - h
     // 1 - v
     if ($mode_string != '') {
         ircd::mode(core::$config->chanserv->nick, $chan, '+' . $mode_string . ' ' . trim($mode_params));
     }
     // finally, we set the mode string on the nick
     // providing it isnt empty
     unset($mode_string);
 }
Esempio n. 29
0
 public function remove_callback($nick)
 {
     ircd::remove_client($nick, 'Hold on ' . $nick . ' expiring');
     core::alog(core::$config->nickserv->nick . ': Hold on ' . $nick . ' expiring');
     // remove client, respectively
 }
Esempio n. 30
0
 public function main(&$ircdata, $startup = false)
 {
     if ($startup) {
         return false;
     }
     // we're booting, f**k sending messages to everyone, they don't want to see
     // it if it's just a restart, and we don't want to waste the resources on it.
     if (ircd::on_connect(&$ircdata)) {
         $nick = core::get_nick(&$ircdata, core::$config->server->ircd == 'inspircd12' ? 4 : 3);
         $get_news = database::select('logon_news', array('nick', 'title', 'message', 'time'), '', array('time', 'DESC'), array(0 => 3));
         // get our news
         if (database::num_rows($get_news) > 0) {
             if (isset(operserv::$help->OS_LOGON_START)) {
                 services::communicate(core::$config->global->nick, $nick, &operserv::$help->OS_LOGON_START);
             }
             while ($news = database::fetch($get_news)) {
                 services::communicate(core::$config->global->nick, $nick, &operserv::$help->OS_LOGON_NEWS_1, array('title' => $news->title, 'user' => $news->nick, 'date' => date("F j, Y, g:i a", $news->time)));
                 services::communicate(core::$config->global->nick, $nick, &operserv::$help->OS_LOGON_NEWS_2, array('message' => $news->message));
             }
             // loop through the news
             if (isset(operserv::$help->OS_LOGON_END)) {
                 services::communicate(core::$config->global->nick, $nick, &operserv::$help->OS_LOGON_END);
             }
         }
         // there is news! epic
     }
     // trigger on connects
 }