summaryrefslogtreecommitdiff
path: root/src/operserv.c
diff options
context:
space:
mode:
authorrob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2005-05-02 19:02:12 +0000
committerrob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2005-05-02 19:02:12 +0000
commite0583918834a3f8683e430adf3923ea89d2a449a (patch)
treeff36ada734c3874d3be1a806e3a2b994386b54ed /src/operserv.c
parent49491770383e66f1b8074d8b0f80026e3086e9d8 (diff)
BUILD : 1.7.8 (753) BUGS : N/a NOTES : Merged anope-dev with trunk
git-svn-id: svn://svn.anope.org/anope/trunk@753 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@516 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/operserv.c')
-rw-r--r--src/operserv.c3737
1 files changed, 50 insertions, 3687 deletions
diff --git a/src/operserv.c b/src/operserv.c
index 42b1b94b5..08b42ad15 100644
--- a/src/operserv.c
+++ b/src/operserv.c
@@ -15,23 +15,16 @@
#include "services.h"
#include "pseudo.h"
-extern Module *mod_current_module;
-extern int mod_current_op;
-extern User *mod_current_user;
-extern ModuleHash *MODULE_HASH[MAX_CMD_HASH];
/*************************************************************************/
-struct clone {
- char *host;
- long time;
-};
+
/* List of most recent users - statically initialized to zeros */
-static struct clone clonelist[CLONE_DETECT_SIZE];
+struct clone clonelist[CLONE_DETECT_SIZE];
/* Which hosts have we warned about, and when? This is used to keep us
* from sending out notices over and over for clones from the same host. */
-static struct clone warnings[CLONE_DETECT_SIZE];
+struct clone warnings[CLONE_DETECT_SIZE];
/* List of Services administrators */
SList servadmins;
@@ -42,8 +35,6 @@ SList akills, sglines, sqlines, szlines;
/*************************************************************************/
-static void get_operserv_stats(long *nrec, long *memuse);
-
static int compare_adminlist_entries(SList * slist, void *item1,
void *item2);
static int compare_operlist_entries(SList * slist, void *item1,
@@ -60,66 +51,20 @@ static void free_sqline_entry(SList * slist, void *item);
static int is_szline_entry_equal(SList * slist, void *item1, void *item2);
static void free_szline_entry(SList * slist, void *item);
-static int do_help(User * u);
-static int do_global(User * u);
-static int do_stats(User * u);
-static int do_admin(User * u);
-static int do_oper(User * u);
-static int do_os_mode(User * u);
-static int do_clearmodes(User * u);
-static int do_os_kick(User * u);
-static int do_akill(User * u);
-static int do_sgline(User * u);
-static int do_sqline(User * u);
-static int do_szline(User * u);
-static int do_set(User * u);
-static int do_noop(User * u);
-static int do_jupe(User * u);
-static int do_raw(User * u);
-static int do_update(User * u);
-static int do_reload(User * u);
-static int do_os_quit(User * u);
-static int do_shutdown(User * u);
-static int do_restart(User * u);
-static int do_ignorelist(User * u);
-static int do_clearignore(User * u);
-static int do_killclones(User * u);
-static int do_chanlist(User * u);
-static int do_userlist(User * u);
-static int do_ignoreuser(User * u);
-static int do_staff(User * u);
-static int do_defcon(User * u);
-static int do_chankill(User * u);
-static void defcon_sendlvls(User * u);
-char *defconReverseModes(const char *modes);
-int DefConModesSet = 0;
+void resetDefCon(int level);
+
time_t DefContimer;
+int DefConModesSet = 0;
void runDefCon(void);
-void resetDefCon(int level);
+char *defconReverseModes(const char *modes);
void oper_global(char *nick, char *fmt, ...);
-#ifdef USE_MODULES
-int do_modload(User * u);
-int do_modunload(User * u);
-int do_modlist(User * u);
-int do_modinfo(User * u);
-static int showModuleCmdLoaded(CommandHash * cmdList, char *mod_name,
- User * u);
-static int showModuleMsgLoaded(MessageHash * msgList, char *mod_name,
- User * u);
-#endif
-
-static int do_operumodes(User * u);
-static int do_svsnick(User * u);
-static int do_operoline(User * u);
#ifdef DEBUG_COMMANDS
static int send_clone_lists(User * u);
static int do_matchwild(User * u);
#endif
-/* OperServ restart needs access to this if were gonna avoid sending ourself a signal */
-extern int do_restart_services(void);
void moduleAddOperServCmds(void);
/*************************************************************************/
@@ -140,70 +85,9 @@ SListOpts szopts = { 0, NULL, &is_szline_entry_equal, &free_szline_entry };
/* *INDENT-OFF* */
void moduleAddOperServCmds(void) {
Command *c;
- c = createCommand("HELP", do_help, NULL, -1, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("GLOBAL", do_global, NULL, OPER_HELP_GLOBAL, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("STATS", do_stats, NULL, OPER_HELP_STATS, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("UPTIME", do_stats, NULL, OPER_HELP_STATS, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
-
- /* Anyone can use the LIST option to the ADMIN and OPER commands; those
- * routines check privileges to ensure that only authorized users
- * modify the list. */
- c = createCommand("ADMIN", do_admin, NULL, OPER_HELP_ADMIN, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("OPER", do_oper, NULL, OPER_HELP_OPER, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("STAFF", do_staff, NULL, OPER_HELP_STAFF, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- /* Similarly, anyone can use *NEWS LIST, but *NEWS {ADD,DEL} are
- * reserved for Services admins. */
- c = createCommand("LOGONNEWS", do_logonnews, NULL, NEWS_HELP_LOGON, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("OPERNEWS", do_opernews, NULL, NEWS_HELP_OPER, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("RANDOMNEWS", do_randomnews, NULL, NEWS_HELP_RANDOM, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
-
- /* Commands for Services opers: */
- c = createCommand("MODE", do_os_mode, is_services_oper,OPER_HELP_MODE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("CLEARMODES", do_clearmodes, is_services_oper,OPER_HELP_CLEARMODES, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("KICK", do_os_kick, is_services_oper,OPER_HELP_KICK, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("KILLCLONES", do_killclones, is_services_oper,OPER_HELP_KILLCLONES, -1,-1,-1, -1); addCoreCommand(OPERSERV,c);
- c = createCommand("AKILL", do_akill, is_services_oper,OPER_HELP_AKILL, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SGLINE", do_sgline, is_services_oper,OPER_HELP_SGLINE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SQLINE", do_sqline, is_services_oper,OPER_HELP_SQLINE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SZLINE", do_szline, is_services_oper,OPER_HELP_SZLINE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
-
- /* Commands for Services admins: */
- c = createCommand("SET", do_set, is_services_admin,OPER_HELP_SET, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SET LIST", NULL, NULL,OPER_HELP_SET_LIST, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SET READONLY", NULL, NULL,OPER_HELP_SET_READONLY, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SET LOGCHAN", NULL, NULL,OPER_HELP_SET_LOGCHAN, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SET DEBUG", NULL, NULL,OPER_HELP_SET_DEBUG, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SET NOEXPIRE", NULL, NULL,OPER_HELP_SET_NOEXPIRE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SET IGNORE", NULL, NULL,OPER_HELP_SET_IGNORE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SET SUPERADMIN", NULL, NULL,OPER_HELP_SET_SUPERADMIN, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
-#ifdef USE_MYSQL
- c = createCommand("SET SQL", NULL, NULL,OPER_HELP_SET_SQL, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
-#endif
- c = createCommand("SVSNICK", do_svsnick, is_services_admin,OPER_HELP_SVSNICK, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("UMODE", do_operumodes, is_services_admin,OPER_HELP_UMODE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("NOOP", do_noop, is_services_admin,OPER_HELP_NOOP, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("JUPE", do_jupe, is_services_admin,OPER_HELP_JUPE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("RAW", do_raw, is_services_admin,OPER_HELP_RAW, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("IGNORE", do_ignoreuser, is_services_admin,OPER_HELP_IGNORE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("OLINE", do_operoline, is_services_admin,OPER_HELP_OLINE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("UPDATE", do_update, is_services_admin,OPER_HELP_UPDATE, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("RELOAD", do_reload, is_services_admin,OPER_HELP_RELOAD, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("QUIT", do_os_quit, is_services_admin,OPER_HELP_QUIT, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SHUTDOWN", do_shutdown, is_services_admin,OPER_HELP_SHUTDOWN, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("RESTART", do_restart, is_services_admin,OPER_HELP_RESTART, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("SESSION", do_session, is_services_admin,OPER_HELP_SESSION, -1,-1,-1, -1); addCoreCommand(OPERSERV,c);
- c = createCommand("EXCEPTION", do_exception, is_services_admin,OPER_HELP_EXCEPTION, -1,-1,-1, -1); addCoreCommand(OPERSERV,c);
- c = createCommand("CHANLIST", do_chanlist, is_services_admin,OPER_HELP_CHANLIST, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("USERLIST", do_userlist, is_services_admin,OPER_HELP_USERLIST, -1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("DEFCON", do_defcon, is_services_admin, OPER_HELP_DEFCON,-1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- c = createCommand("CHANKILL", do_chankill, is_services_admin, OPER_HELP_CHANKILL,-1,-1,-1,-1); addCoreCommand(OPERSERV,c);
- /* Commands for Services root: */
-#ifdef USE_MODULES
- c = createCommand("MODLOAD", do_modload, is_services_root, -1,-1,-1,-1,OPER_HELP_MODLOAD); addCoreCommand(OPERSERV,c);
- c = createCommand("MODUNLOAD", do_modunload, is_services_root, -1,-1,-1,-1,OPER_HELP_MODUNLOAD); addCoreCommand(OPERSERV,c);
- c = createCommand("MODLIST", do_modlist, is_services_root, -1,-1,-1,-1,OPER_HELP_MODLIST); addCoreCommand(OPERSERV,c);
- c = createCommand("MODINFO", do_modinfo, is_services_root, -1,-1,-1,-1,OPER_HELP_MODINFO); addCoreCommand(OPERSERV,c);
-#endif
+
+ modules_core_init(OperServCoreNumber, OperServCoreModules);
+
#ifdef DEBUG_COMMANDS
c = createCommand("LISTTIMERS", send_timeout_list, is_services_root, -1,-1,-1,-1,-1); addCoreCommand(OPERSERV,c);
c = createCommand("MATCHWILD", do_matchwild, is_services_root, -1,-1,-1,-1,-1); addCoreCommand(OPERSERV,c);
@@ -278,88 +162,6 @@ void operserv(User * u, char *buf)
}
}
-static void get_operserv_stats(long *nrec, long *memuse)
-{
- int i;
- long mem = 0, count = 0, mem2 = 0, count2 = 0;
- Akill *ak;
- SXLine *sx;
-
- if (CheckClones) {
- mem = sizeof(struct clone) * CLONE_DETECT_SIZE * 2;
- for (i = 0; i < CLONE_DETECT_SIZE; i++) {
- if (clonelist[i].host) {
- count++;
- mem += strlen(clonelist[i].host) + 1;
- }
- if (warnings[i].host) {
- count++;
- mem += strlen(warnings[i].host) + 1;
- }
- }
- }
-
- count += akills.count;
- mem += akills.capacity;
- mem += akills.count * sizeof(Akill);
-
- for (i = 0; i < akills.count; i++) {
- ak = akills.list[i];
- mem += strlen(ak->user) + 1;
- mem += strlen(ak->host) + 1;
- mem += strlen(ak->by) + 1;
- mem += strlen(ak->reason) + 1;
- }
-
- if (ircd->sgline) {
- count += sglines.count;
- mem += sglines.capacity;
- mem += sglines.count * sizeof(SXLine);
-
- for (i = 0; i < sglines.count; i++) {
- sx = sglines.list[i];
- mem += strlen(sx->mask) + 1;
- mem += strlen(sx->by) + 1;
- mem += strlen(sx->reason) + 1;
- }
- }
- if (ircd->sqline) {
- count += sqlines.count;
- mem += sqlines.capacity;
- mem += sqlines.count * sizeof(SXLine);
-
- for (i = 0; i < sqlines.count; i++) {
- sx = sqlines.list[i];
- mem += strlen(sx->mask) + 1;
- mem += strlen(sx->by) + 1;
- mem += strlen(sx->reason) + 1;
- }
- }
- if (ircd->szline) {
- count += szlines.count;
- mem += szlines.capacity;
- mem += szlines.count * sizeof(SXLine);
-
- for (i = 0; i < szlines.count; i++) {
- sx = szlines.list[i];
- mem += strlen(sx->mask) + 1;
- mem += strlen(sx->by) + 1;
- mem += strlen(sx->reason) + 1;
- }
- }
-
-
- get_news_stats(&count2, &mem2);
- count += count2;
- mem += mem2;
- get_exception_stats(&count2, &mem2);
- count += count2;
- mem += mem2;
-
- *nrec = count;
- *memuse = mem;
-}
-
/*************************************************************************/
/**************************** Privilege checks ***************************/
/*************************************************************************/
@@ -915,73 +717,8 @@ static int send_clone_lists(User * u)
/*********************** OperServ command functions **********************/
/*************************************************************************/
-/* HELP command. */
-
-static int do_help(User * u)
-{
- const char *cmd = strtok(NULL, "");
-
- if (!cmd) {
- notice_help(s_OperServ, u, OPER_HELP);
- if (is_services_oper(u)) {
- notice_help(s_OperServ, u, OPER_HELP_OPER_CMD);
- if (ircd->sgline || ircd->sqline || ircd->szline) {
- notice_help(s_OperServ, u, OPER_HELP_OPER_CMD_EXTRA);
- }
- if (ircd->sgline) {
- notice_help(s_OperServ, u, OPER_HELP_OPER_CMD_SGLINE);
- }
- if (ircd->sqline) {
- notice_help(s_OperServ, u, OPER_HELP_OPER_CMD_SQLINE);
- }
- if (ircd->szline) {
- notice_help(s_OperServ, u, OPER_HELP_OPER_CMD_SZLINE);
- }
- }
- if (is_services_admin(u)) {
- notice_help(s_OperServ, u, OPER_HELP_ADMIN_CMD);
- if (ircd->svsnick || ircd->omode || ircd->umode) {
- notice_help(s_OperServ, u, OPER_HELP_ADMIN_CMD_EXTRA);
- }
- if (ircd->svsnick) {
- notice_help(s_OperServ, u, OPER_HELP_ADMIN_CMD_SVSNICK);
- }
- if (ircd->omode) {
- notice_help(s_OperServ, u, OPER_HELP_ADMIN_CMD_OLINE);
- }
- if (ircd->umode) {
- notice_help(s_OperServ, u, OPER_HELP_ADMIN_CMD_UMODE);
- }
- }
-#ifdef USE_MODULES
- if (is_services_root(u)) {
- notice_help(s_OperServ, u, OPER_HELP_ROOT_CMD);
- }
-#endif
- moduleDisplayHelp(5, u);
- notice_help(s_OperServ, u, OPER_HELP_LOGGED);
- } else {
- mod_help_cmd(s_OperServ, u, OPERSERV, cmd);
- }
- return MOD_CONT;
-}
-
/*************************************************************************/
-static int do_global(User * u)
-{
- char *msg = strtok(NULL, "");
-
- if (!msg) {
- syntax_error(s_OperServ, u, "GLOBAL", OPER_GLOBAL_SYNTAX);
- return MOD_CONT;
- }
- if (WallOSGlobal)
- anope_cmd_global(s_OperServ, "\2%s\2 just used GLOBAL command.",
- u->nick);
- oper_global(u->nick, "%s", msg);
- return MOD_CONT;
-}
Server *server_global(Server * s, char *msg)
{
@@ -1023,934 +760,10 @@ void oper_global(char *nick, char *fmt, ...)
}
-/*************************************************************************/
-
-/* STATS command. */
-
-static int do_stats(User * u)
-{
- time_t uptime = time(NULL) - start_time;
- char *extra = strtok(NULL, "");
- int days = uptime / 86400, hours = (uptime / 3600) % 24,
- mins = (uptime / 60) % 60, secs = uptime % 60;
- struct tm *tm;
- char timebuf[64];
-
- if (extra && stricmp(extra, "ALL") != 0) {
- if (stricmp(extra, "AKILL") == 0) {
- int timeout;
- /* AKILLs */
- notice_lang(s_OperServ, u, OPER_STATS_AKILL_COUNT,
- akills.count);
- timeout = AutokillExpiry + 59;
- if (timeout >= 172800)
- notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_DAYS,
- timeout / 86400);
- else if (timeout >= 86400)
- notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_DAY);
- else if (timeout >= 7200)
- notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_HOURS,
- timeout / 3600);
- else if (timeout >= 3600)
- notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_HOUR);
- else if (timeout >= 120)
- notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_MINS,
- timeout / 60);
- else if (timeout >= 60)
- notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_MIN);
- else
- notice_lang(s_OperServ, u, OPER_STATS_AKILL_EXPIRE_NONE);
- if (ircd->sgline) {
- /* SGLINEs */
- notice_lang(s_OperServ, u, OPER_STATS_SGLINE_COUNT,
- sglines.count);
- timeout = SGLineExpiry + 59;
- if (timeout >= 172800)
- notice_lang(s_OperServ, u,
- OPER_STATS_SGLINE_EXPIRE_DAYS,
- timeout / 86400);
- else if (timeout >= 86400)
- notice_lang(s_OperServ, u,
- OPER_STATS_SGLINE_EXPIRE_DAY);
- else if (timeout >= 7200)
- notice_lang(s_OperServ, u,
- OPER_STATS_SGLINE_EXPIRE_HOURS,
- timeout / 3600);
- else if (timeout >= 3600)
- notice_lang(s_OperServ, u,
- OPER_STATS_SGLINE_EXPIRE_HOUR);
- else if (timeout >= 120)
- notice_lang(s_OperServ, u,
- OPER_STATS_SGLINE_EXPIRE_MINS,
- timeout / 60);
- else if (timeout >= 60)
- notice_lang(s_OperServ, u,
- OPER_STATS_SGLINE_EXPIRE_MIN);
- else
- notice_lang(s_OperServ, u,
- OPER_STATS_SGLINE_EXPIRE_NONE);
- }
- if (ircd->sqline) {
- /* SQLINEs */
- notice_lang(s_OperServ, u, OPER_STATS_SQLINE_COUNT,
- sqlines.count);
- timeout = SQLineExpiry + 59;
- if (timeout >= 172800)
- notice_lang(s_OperServ, u,
- OPER_STATS_SQLINE_EXPIRE_DAYS,
- timeout / 86400);
- else if (timeout >= 86400)
- notice_lang(s_OperServ, u,
- OPER_STATS_SQLINE_EXPIRE_DAY);
- else if (timeout >= 7200)
- notice_lang(s_OperServ, u,
- OPER_STATS_SQLINE_EXPIRE_HOURS,
- timeout / 3600);
- else if (timeout >= 3600)
- notice_lang(s_OperServ, u,
- OPER_STATS_SQLINE_EXPIRE_HOUR);
- else if (timeout >= 120)
- notice_lang(s_OperServ, u,
- OPER_STATS_SQLINE_EXPIRE_MINS,
- timeout / 60);
- else if (timeout >= 60)
- notice_lang(s_OperServ, u,
- OPER_STATS_SQLINE_EXPIRE_MIN);
- else
- notice_lang(s_OperServ, u,
- OPER_STATS_SQLINE_EXPIRE_NONE);
- }
- if (ircd->szline) {
- /* SZLINEs */
- notice_lang(s_OperServ, u, OPER_STATS_SZLINE_COUNT,
- szlines.count);
- timeout = SZLineExpiry + 59;
- if (timeout >= 172800)
- notice_lang(s_OperServ, u,
- OPER_STATS_SZLINE_EXPIRE_DAYS,
- timeout / 86400);
- else if (timeout >= 86400)
- notice_lang(s_OperServ, u,
- OPER_STATS_SZLINE_EXPIRE_DAY);
- else if (timeout >= 7200)
- notice_lang(s_OperServ, u,
- OPER_STATS_SZLINE_EXPIRE_HOURS,
- timeout / 3600);
- else if (timeout >= 3600)
- notice_lang(s_OperServ, u,
- OPER_STATS_SZLINE_EXPIRE_HOUR);
- else if (timeout >= 120)
- notice_lang(s_OperServ, u,
- OPER_STATS_SZLINE_EXPIRE_MINS,
- timeout / 60);
- else if (timeout >= 60)
- notice_lang(s_OperServ, u,
- OPER_STATS_SZLINE_EXPIRE_MIN);
- else
- notice_lang(s_OperServ, u,
- OPER_STATS_SZLINE_EXPIRE_NONE);
- }
- return MOD_CONT;
- } else if (!stricmp(extra, "RESET")) {
- if (is_services_admin(u)) {
- maxusercnt = usercnt;
- notice_lang(s_OperServ, u, OPER_STATS_RESET);
- } else {
- notice_lang(s_OperServ, u, PERMISSION_DENIED);
- }
- return MOD_CONT;
- } else {
- notice_lang(s_OperServ, u, OPER_STATS_UNKNOWN_OPTION, extra);
- }
- }
-
- notice_lang(s_OperServ, u, OPER_STATS_CURRENT_USERS, usercnt, opcnt);
- tm = localtime(&maxusertime);
- strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_DATE_TIME_FORMAT,
- tm);
- notice_lang(s_OperServ, u, OPER_STATS_MAX_USERS, maxusercnt, timebuf);
- if (days > 1) {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_DHMS,
- days, hours, mins, secs);
- } else if (days == 1) {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1DHMS,
- days, hours, mins, secs);
- } else {
- if (hours > 1) {
- if (mins != 1) {
- if (secs != 1) {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_HMS,
- hours, mins, secs);
- } else {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_HM1S,
- hours, mins, secs);
- }
- } else {
- if (secs != 1) {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_H1MS,
- hours, mins, secs);
- } else {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_H1M1S,
- hours, mins, secs);
- }
- }
- } else if (hours == 1) {
- if (mins != 1) {
- if (secs != 1) {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1HMS,
- hours, mins, secs);
- } else {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1HM1S,
- hours, mins, secs);
- }
- } else {
- if (secs != 1) {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1H1MS,
- hours, mins, secs);
- } else {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1H1M1S,
- hours, mins, secs);
- }
- }
- } else {
- if (mins != 1) {
- if (secs != 1) {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_MS,
- mins, secs);
- } else {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_M1S,
- mins, secs);
- }
- } else {
- if (secs != 1) {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1MS,
- mins, secs);
- } else {
- notice_lang(s_OperServ, u, OPER_STATS_UPTIME_1M1S,
- mins, secs);
- }
- }
- }
- }
-
- if (extra && stricmp(extra, "ALL") == 0 && is_services_admin(u)) {
- long count, mem;
-
- notice_lang(s_OperServ, u, OPER_STATS_BYTES_READ,
- total_read / 1024);
- notice_lang(s_OperServ, u, OPER_STATS_BYTES_WRITTEN,
- total_written / 1024);
-
- get_user_stats(&count, &mem);
- notice_lang(s_OperServ, u, OPER_STATS_USER_MEM, count,
- (mem + 512) / 1024);
- get_channel_stats(&count, &mem);
- notice_lang(s_OperServ, u, OPER_STATS_CHANNEL_MEM, count,
- (mem + 512) / 1024);
- get_core_stats(&count, &mem);
- notice_lang(s_OperServ, u, OPER_STATS_GROUPS_MEM, count,
- (mem + 512) / 1024);
- get_aliases_stats(&count, &mem);
- notice_lang(s_OperServ, u, OPER_STATS_ALIASES_MEM, count,
- (mem + 512) / 1024);
- get_chanserv_stats(&count, &mem);
- notice_lang(s_OperServ, u, OPER_STATS_CHANSERV_MEM, count,
- (mem + 512) / 1024);
- get_botserv_stats(&count, &mem);
- notice_lang(s_OperServ, u, OPER_STATS_BOTSERV_MEM, count,
- (mem + 512) / 1024);
- get_operserv_stats(&count, &mem);
- notice_lang(s_OperServ, u, OPER_STATS_OPERSERV_MEM, count,
- (mem + 512) / 1024);
- get_session_stats(&count, &mem);
- notice_lang(s_OperServ, u, OPER_STATS_SESSIONS_MEM, count,
- (mem + 512) / 1024);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/* make Services ignore users for a certain time */
-
-static int do_ignoreuser(User * u)
-{
- char *cmd = strtok(NULL, " ");
- int t;
-
- if (!cmd) {
- notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX);
- return MOD_CONT;
- }
-
- if (!stricmp(cmd, "ADD")) {
-
- char *time = strtok(NULL, " ");
- char *nick = strtok(NULL, " ");
- char *rest = strtok(NULL, "");
-
- if (!nick) {
- notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX);
- return MOD_CONT;
- } else if (!time) {
- notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX);
- return MOD_CONT;
- } else {
- t = dotime(time);
- rest = NULL;
-
- if (t <= -1) {
- notice_lang(s_OperServ, u, OPER_IGNORE_VALID_TIME);
- return MOD_CONT;
- } else if (t == 0) {
- t = 157248000; /* if 0 is given, we set time to 157248000 seconds == 5 years (let's hope the next restart will be before that time ;-)) */
- add_ignore(nick, t);
- notice_lang(s_OperServ, u, OPER_IGNORE_PERM_DONE, nick);
- } else {
- add_ignore(nick, t);
- notice_lang(s_OperServ, u, OPER_IGNORE_TIME_DONE, nick,
- time);
- }
- }
- } else if (!stricmp(cmd, "LIST")) {
- do_ignorelist(u);
- }
-
- else if (!stricmp(cmd, "DEL")) {
- char *nick = strtok(NULL, " ");
- if (!nick) {
- notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX);
- } else {
- if (get_ignore(nick) == 0) {
- notice_lang(s_OperServ, u, OPER_IGNORE_LIST_NOMATCH, nick);
- return MOD_CONT;
- } else {
- delete_ignore(nick);
- notice_lang(s_OperServ, u, OPER_IGNORE_DEL_DONE, nick);
- }
- }
- } else if (!stricmp(cmd, "CLEAR")) {
- do_clearignore(u);
-
- } else
- notice_lang(s_OperServ, u, OPER_IGNORE_SYNTAX);
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/* deletes a nick from the ignore list */
-
-void delete_ignore(const char *nick)
-{
- IgnoreData *ign, *prev;
- IgnoreData **whichlist;
-
- if (!nick || !*nick) {
- return;
- }
-
- whichlist = &ignore[tolower(nick[0])];
-
- for (ign = *whichlist, prev = NULL; ign; prev = ign, ign = ign->next) {
- if (stricmp(ign->who, nick) == 0)
- break;
- }
- if (prev)
- prev->next = ign->next;
- else
- *whichlist = ign->next;
- free(ign);
- ign = NULL;
-}
-
-/*************************************************************************/
-
-/* shows the Services ignore list */
-
-static int do_ignorelist(User * u)
-{
- int sent_header = 0;
- IgnoreData *id;
- int i;
-
- for (i = 0; i < 256; i++) {
- for (id = ignore[i]; id; id = id->next) {
- if (!sent_header) {
- notice_lang(s_OperServ, u, OPER_IGNORE_LIST);
- sent_header = 1;
- }
- notice_user(s_OperServ, u, "%s", id->who);
- }
- }
- if (!sent_header)
- notice_lang(s_OperServ, u, OPER_IGNORE_LIST_EMPTY);
- return MOD_CONT;
-}
-
-/**************************************************************************/
-/* Cleares the Services ignore list */
-
-static int do_clearignore(User * u)
-{
- IgnoreData *id = NULL, *next = NULL;
- int i;
- for (i = 0; i < 256; i++) {
- for (id = ignore[i]; id; id = next) {
- next = id->next;
- free(id);
- if (!next) {
- ignore[i] = NULL;
- }
- }
- }
- notice_lang(s_OperServ, u, OPER_IGNORE_LIST_CLEARED);
- return MOD_CONT;
-}
-
-/**************************************************************************/
-
-/* Channel mode changing (MODE command). */
-
-static int do_os_mode(User * u)
-{
- int ac;
- char **av;
- char *chan = strtok(NULL, " "), *modes = strtok(NULL, "");
- Channel *c;
-
- if (!chan || !modes) {
- syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX);
- return MOD_CONT;
- }
-
- if (!(c = findchan(chan))) {
- notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan);
- } else if (c->bouncy_modes) {
- notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
- return MOD_CONT;
- } else if ((ircd->adminmode) && (!is_services_admin(u))
- && (c->mode & ircd->adminmode)) {
- notice_lang(s_OperServ, u, PERMISSION_DENIED);
- return MOD_CONT;
- } else {
- anope_cmd_mode(s_OperServ, chan, "%s", modes);
-
- ac = split_buf(modes, &av, 1);
- chan_set_modes(s_OperServ, c, ac, av, 0);
-
- if (WallOSMode)
- anope_cmd_global(s_OperServ, "%s used MODE %s on %s", u->nick,
- modes, chan);
- }
- return MOD_CONT;
-}
-
-/**************************************************************************/
-
-/**
- * Change any user's UMODES
- *
- * modified to be part of the SuperAdmin directive -jester
- * check user flag for SuperAdmin -rob
- */
-static int do_operumodes(User * u)
-{
- char *nick = strtok(NULL, " ");
- char *modes = strtok(NULL, "");
-
- User *u2;
-
- if (!ircd->umode) {
- notice_lang(s_OperServ, u, OPER_UMODE_UNSUPPORTED);
- return MOD_CONT;
- }
-
- /* Only allow this if SuperAdmin is enabled */
- if (!u->isSuperAdmin) {
- notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY);
- return MOD_CONT;
- }
-
- if (!nick || !modes) {
- syntax_error(s_OperServ, u, "UMODE", OPER_UMODE_SYNTAX);
- return MOD_CONT;
- }
-
- /**
- * Only accept a +/- mode string
- *-rob
- **/
- if ((modes[0] != '+') && (modes[0] != '-')) {
- syntax_error(s_OperServ, u, "UMODE", OPER_UMODE_SYNTAX);
- return MOD_CONT;
- }
- if (!(u2 = finduser(nick))) {
- notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick);
- } else {
- anope_cmd_mode(s_OperServ, nick, "%s", modes);
-
- common_svsmode(u2, modes, NULL);
-
- notice_lang(s_OperServ, u, OPER_UMODE_SUCCESS, nick);
- notice_lang(s_OperServ, u2, OPER_UMODE_CHANGED, u->nick);
-
- if (WallOSMode)
- anope_cmd_global(s_OperServ, "\2%s\2 used UMODE on %s",
- u->nick, nick);
- }
- return MOD_CONT;
-}
-
/**************************************************************************/
-/**
- * give Operflags to any user
- *
- * modified to be part of the SuperAdmin directive -jester
- * check u-> for SuperAdmin -rob
- */
-
-static int do_operoline(User * u)
-{
- char *nick = strtok(NULL, " ");
- char *flags = strtok(NULL, "");
- User *u2 = NULL;
-
- if (!ircd->omode) {
- notice_lang(s_OperServ, u, OPER_SVSO_UNSUPPORTED);
- return MOD_CONT;
- }
-
- /* Only allow this if SuperAdmin is enabled */
- if (!u->isSuperAdmin) {
- notice_lang(s_OperServ, u, OPER_SUPER_ADMIN_ONLY);
- return MOD_CONT;
- }
-
- if (!nick || !flags) {
- syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX);
- return MOD_CONT;
- } else {
- u2 = finduser(nick);
-
-/* let's check whether the user is online */
-
- if (!finduser(nick)) {
- notice_lang(s_OperServ, u, NICK_X_NOT_IN_USE, nick);
- } else if (u2 && flags[0] == '+') {
- anope_cmd_svso(s_OperServ, nick, flags);
- anope_cmd_mode(s_OperServ, nick, "+o");
- common_svsmode(u2, "+o", NULL);
- notice_lang(s_OperServ, u2, OPER_OLINE_IRCOP);
- notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick);
- anope_cmd_global(s_OperServ, "\2%s\2 used OLINE for %s",
- u->nick, nick);
- } else if (u2 && flags[0] == '-') {
- anope_cmd_svso(s_OperServ, nick, flags);
- notice_lang(s_OperServ, u, OPER_OLINE_SUCCESS, flags, nick);
- anope_cmd_global(s_OperServ, "\2%s\2 used OLINE for %s",
- u->nick, nick);
- } else
- syntax_error(s_OperServ, u, "OLINE", OPER_OLINE_SYNTAX);
- }
- return MOD_CONT;
-}
-
-/*************************************************************************/
-
-/* Clear all modes from a channel. */
-
-static int do_clearmodes(User * u)
-{
- char *s;
- int i;
- char *argv[2];
- char *chan = strtok(NULL, " ");
- Channel *c;
- int all = 0;
- int count; /* For saving ban info */
- char **bans; /* For saving ban info */
- int exceptcount; /* For saving except info */
- char **excepts; /* For saving except info */
- int invitecount; /* For saving invite info */
- char **invites; /* For saving invite info */
- struct c_userlist *cu, *next;
-
- if (!chan) {
- syntax_error(s_OperServ, u, "CLEARMODES", OPER_CLEARMODES_SYNTAX);
- return MOD_CONT;
- } else if (!(c = findchan(chan))) {
- notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan);
- return MOD_CONT;
- } else if (c->bouncy_modes) {
- notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
- return MOD_CONT;
- } else {
- s = strtok(NULL, " ");
- if (s) {
- if (stricmp(s, "ALL") == 0) {
- all = 1;
- } else {
- syntax_error(s_OperServ, u, "CLEARMODES",
- OPER_CLEARMODES_SYNTAX);
- return MOD_CONT;
- }
- }
-
- if (WallOSClearmodes) {
- anope_cmd_global(s_OperServ, "%s used CLEARMODES%s on %s",
- u->nick, all ? " ALL" : "", chan);
- }
- if (all) {
- /* Clear mode +o */
- if (ircd->svsmode_ucmode) {
- anope_cmd_svsmode_chan(c->name, "-o", NULL);
- for (cu = c->users; cu; cu = next) {
- next = cu->next;
- if (!chan_has_user_status(c, cu->user, CUS_OP)) {
- continue;
- }
- argv[0] = sstrdup("-o");
-