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.. } }
public static function suspend_command($nick, $ircdata = array()) { $unick = core::get_nick(&$ircdata, 0); $reason = core::get_data_after(&$ircdata, 1); $user_info = array(); // get the nick etc. if (!core::$nicks[$nick]['ircop'] || services::user_exists($nick, true, array('display', 'identified')) === false) { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ACCESS_DENIED); return false; } // they've gotta be identified and opered.. 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 (trim($reason) == '') { $reason = 'No reason'; } // is there a reason? if not we set it to 'No Reason' if ($user = services::user_exists($unick, false, array('display', 'suspended'))) { if ($user->suspended == 1) { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_SUSPEND_2, array('nick' => $unick)); return false; // channel is already suspended lol } else { database::update('users', array('suspended' => 1, 'suspend_reason' => $reason), array('display', '=', $user->display)); // channel isn't suspended, but it IS registered } } else { $user_info = array('display' => $unick, 'last_timestamp' => core::$network_time, 'timestamp' => core::$network_time, 'identified' => 0, 'real_user' => 0, 'suspended' => 1, 'suspend_reason' => $reason); // setup the user info array. database::insert('users', $user_info); // insert it into the database. } services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_SUSPEND_3, array('nick' => $unick, 'reason' => $reason)); core::alog(core::$config->nickserv->nick . ': ' . $nick . ' SUSPENDED ' . $unick . ' with the reason: ' . $reason); ircd::globops(core::$config->nickserv->nick, $nick . ' SUSPENDED ' . $unick); if (isset(core::$nicks[$unick])) { $random_nick = 'Unknown' . rand(10000, 99999); services::communicate(core::$config->nickserv->nick, $unick, &nickserv::$help->NS_SUSPEND_1, array('nick' => $unick)); services::communicate(core::$config->nickserv->nick, $unick, &nickserv::$help->NS_NICK_CHANGE, array('nick' => $random_nick)); ircd::svsnick($unick, $random_nick, core::$network_time); } // is the nick in use? we need to force change it. }
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); } }
public static function override_command($nick, $ircdata = array()) { $mode = strtolower($ircdata[0]); if (services::is_root($nick)) { if (trim($mode) == '' || !in_array($mode, array('on', 'off'))) { services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_INVALID_SYNTAX_RE, array('help' => 'OVERRIDE')); return false; } // is the format correct? if ($mode == 'on') { if (core::$nicks[$nick]['override']) { services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_OVERRIDE_IS_ON); return false; } // override is already on.. services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_OVERRIDE_ON); core::alog('override_command(): ' . $nick . ' is now using override mode.', 'BASIC'); ircd::globops(core::$config->operserv->nick, $nick . ' is now using override mode.'); // log and stuff core::$nicks[$nick]['override'] = true; return false; } // set override on if ($mode == 'off') { if (!core::$nicks[$nick]['override']) { services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_OVERRIDE_IS_OFF); return false; } // override isnt even on.. services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_OVERRIDE_OFF); core::alog('override_command(): ' . $nick . ' has turned override mode off.', 'BASIC'); ircd::globops(core::$config->operserv->nick, $nick . ' has turned override mode off.'); // log and stuff core::$nicks[$nick]['override'] = false; return false; } // set override off } else { services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_ACCESS_DENIED); } // are they root? }
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); } }
public static function sapass_command($nick, $ircdata = array()) { $unick = core::get_nick(&$ircdata, 0); $new_pass = $ircdata[1]; $conf_pass = $ircdata[2]; // new password. if (!($user = services::user_exists($unick, false, array('display', 'id', 'identified', 'salt')))) { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ISNT_REGISTERED, array('nick' => $unick)); return false; } // find out if our user is registered 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 change a root's password? if (!core::$nicks[$nick]['ircop'] || services::user_exists($nick, true, array('display', 'identified')) === false) { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ACCESS_DENIED); return false; } // do we have access to do this? if (strtolower($new_pass) == strtolower($unick)) { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_PASSWORD_NICK_U); return false; } // are they using a reasonable password, eg. != their nick, lol. if ($new_pass != $conf_pass) { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_PASSWORD_DIFF); return false; } // the passwords are different database::update('users', array('pass' => sha1($new_pass . $user->salt)), array('display', '=', $unick)); // we update the password here, with the users salt. services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_NEW_PASSWORD_U, array('nick' => $unick, 'pass' => $new_pass)); // let them know core::alog(core::$config->nickserv->nick . ': ' . core::get_full_hostname($nick) . ' changed the password for ' . $unick); // logchan }
public static function _add_user($nick, $who) { $check_nick_q = database::select('ignored_users', array('who'), array('who', '=', $who)); if (services::is_root($who) && !services::is_root($nick)) { services::communicate(core::$config->nickserv->nick, $nick, &operserv::$help->NS_ACCESS_DENIED); return false; } // is a non-root trying to drop a root? if (database::num_rows($check_nick_q) == 0) { if (strpos($who, '@') !== false && strpos($who, '!') === false) { $who = '*!' . $who; } // we need to check if it's a hostmask thats been written properly. database::insert('ignored_users', array('who' => $who, 'time' => core::$network_time)); services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_IGNORE_ADD, array('nick' => $who)); core::alog(core::$config->operserv->nick . ': ' . $nick . ' added ' . $who . ' to services ignore list'); // as simple, as. } else { services::communicate(core::$config->operserv->nick, $nick, &operserv::$help->OS_IGNORE_EXISTS, array('nick' => $who)); // already being ignored? :O NEVER! } }
public static function saflags_command($nick, $ircdata = array()) { $unick = core::get_nick(&$ircdata, 0); $flags = $ircdata[1]; $param = core::get_data_after(&$ircdata, 2); $rparams = explode('||', $param); // get the channel. if (!($user = services::user_exists($unick, false, array('display', 'id', 'identified', 'salt')))) { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ISNT_REGISTERED, array('nick' => $unick)); return false; } // find out if our user is registered 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 change a root's password? if (!core::$nicks[$nick]['ircop'] || services::user_exists($nick, true, array('display', 'identified')) === false) { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_ACCESS_DENIED); return false; } // do we have access to do this? $flag_a = array(); foreach (str_split($flags) as $flag) { if (strpos(self::$flags, $flag) === false) { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_FLAGS_UNKNOWN, array('flag' => $flag)); return false; } // flag is invalid. $flag_a[$flag]++; // plus if ($flag_a[$flag] > 1 || $flag != '-' && $flag != '+') { $flag_a[$flag]--; } // check for dupes } // check if the flag is valid $flags = ''; foreach ($flag_a as $flag => $count) { $flags .= $flag; } // reconstruct the flags $flag_array = mode::sort_modes($flags, false); // sort our flags up foreach (str_split(self::$p_flags) as $flag) { $param_num = strpos($flag_array['plus'], $flag); if ($param_num !== false) { $params[$flag] = trim($rparams[$param_num]); } // we do! } // check if we have any paramtized flags, eg +me foreach (str_split($flag_array['plus']) as $flag) { // paramtized flags (lowercase) ones come first // ----------- +e ----------- // if ($flag == 'e') { self::set_flag($nick, $unick, '+e', $params['e']); // +e the target in question } elseif ($flag == 'u') { self::set_flag($nick, $unick, '+u', $params['u']); // +u the target in question } elseif ($flag == 'S') { self::set_flag($nick, $unick, '+S', ''); // +S the target in question } elseif ($flag == 'P') { self::set_flag($nick, $unick, '+P', ''); // +P the target in question } // ----------- +P ----------- // } foreach (str_split($flag_array['minus']) as $flag) { // paramtized flags (lowercase) ones come first // ----------- -e ----------- // if ($flag == 'e') { self::set_flag($nick, $unick, '-e', $params['e']); // -e the target in question } elseif ($flag == 'u') { self::set_flag($nick, $unick, '-u', $params['u']); // -u the target in question } elseif ($flag == 'S') { self::set_flag($nick, $unick, '-S', ''); // -S the target in question } elseif ($flag == 'P') { self::set_flag($nick, $unick, '-P', ''); // -P the target in question } // ----------- -P ----------- // } if (isset(self::$set[$unick])) { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_FLAGS_SET, array('flag' => self::$set[$unick], 'target' => $unick)); unset(self::$set[$unick]); } // send back the target stuff.. if (isset(self::$already_set[$unick])) { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_FLAGS_ALREADY_SET, array('flag' => self::$already_set[$unick], 'target' => $unick)); unset(self::$already_set[$unick]); } // send back the target stuff.. if (isset(self::$not_set[$unick])) { services::communicate(core::$config->nickserv->nick, $nick, &nickserv::$help->NS_FLAGS_NOT_SET, array('flag' => self::$not_set[$unick], 'target' => $unick)); unset(self::$not_set[$unick]); } // send back the target stuff.. }