2003-10-06 16:33:42 +00:00
|
|
|
/* NeoStats - IRC Statistical Services
|
2004-01-14 11:36:37 +00:00
|
|
|
** Copyright (c) 1999-2004 Adam Rutter, Justin Hammond
|
2002-09-04 08:40:29 +00:00
|
|
|
** http://www.neostats.net/
|
|
|
|
**
|
|
|
|
** Portions Copyright (c) 2000-2001 ^Enigma^
|
|
|
|
**
|
|
|
|
** Portions Copyright (c) 1999 Johnathan George net@lite.net
|
|
|
|
**
|
|
|
|
** This program is free software; you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation; either version 2 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** This program is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with this program; if not, write to the Free Software
|
|
|
|
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
** USA
|
|
|
|
**
|
|
|
|
** NeoStats CVS Identification
|
2003-09-22 15:04:15 +00:00
|
|
|
** $Id$
|
2000-02-03 23:45:51 +00:00
|
|
|
*/
|
2003-06-13 13:11:50 +00:00
|
|
|
|
2000-02-03 23:45:51 +00:00
|
|
|
#include "stats.h"
|
|
|
|
#include "dl.h"
|
2003-04-11 09:26:31 +00:00
|
|
|
#include "log.h"
|
2003-11-03 13:57:11 +00:00
|
|
|
#include "sock.h"
|
2003-11-18 11:51:09 +00:00
|
|
|
#include "ns_help.h"
|
|
|
|
#include "users.h"
|
|
|
|
#include "server.h"
|
|
|
|
#include "chans.h"
|
2003-12-16 12:39:54 +00:00
|
|
|
#include "ircd.h"
|
2003-11-18 11:51:09 +00:00
|
|
|
#include "hash.h"
|
2004-01-26 11:33:52 +00:00
|
|
|
#include "exclude.h"
|
2004-05-28 09:38:31 +00:00
|
|
|
#include "bans.h"
|
2003-11-18 11:51:09 +00:00
|
|
|
|
2003-11-27 22:49:10 +00:00
|
|
|
static int ns_set_debug (User * u, char **av, int ac);
|
|
|
|
static int ns_shutdown (User * u, char **av, int ac);
|
|
|
|
static int ns_reload (User * u, char **av, int ac);
|
|
|
|
static int ns_logs (User * u, char **av, int ac);
|
|
|
|
static int ns_jupe (User * u, char **av, int ac);
|
2004-01-26 11:33:52 +00:00
|
|
|
static int ns_exclude (User * u, char **av, int ac);
|
2003-11-18 11:51:09 +00:00
|
|
|
#ifdef USE_RAW
|
2003-11-27 22:49:10 +00:00
|
|
|
static int ns_raw (User * u, char **av, int ac);
|
2003-11-18 11:51:09 +00:00
|
|
|
#endif
|
2003-11-27 22:49:10 +00:00
|
|
|
static int ns_userdump (User * u, char **av, int ac);
|
|
|
|
static int ns_serverdump (User * u, char **av, int ac);
|
2004-05-28 09:38:31 +00:00
|
|
|
static int ns_bandump(User * u, char **av, int ac);
|
2003-11-27 22:49:10 +00:00
|
|
|
static int ns_chandump (User * u, char **av, int ac);
|
2003-12-12 20:38:45 +00:00
|
|
|
static int ns_status (User * u, char **av, int ac);
|
2003-11-27 22:49:10 +00:00
|
|
|
static int ns_version (User * u, char **av, int ac);
|
|
|
|
static int ns_level (User * u, char **av, int ac);
|
|
|
|
static int ns_load (User * u, char **av, int ac);
|
|
|
|
static int ns_unload (User * u, char **av, int ac);
|
2003-11-18 11:51:09 +00:00
|
|
|
|
2003-11-25 21:52:38 +00:00
|
|
|
static char quitmsg[BUFSIZE];
|
|
|
|
static char no_reason[]="no reason given";
|
|
|
|
|
2003-11-23 21:36:35 +00:00
|
|
|
static bot_cmd ns_commands[]=
|
2003-11-18 11:51:09 +00:00
|
|
|
{
|
2003-12-02 22:54:00 +00:00
|
|
|
{"LEVEL", ns_level, 0, 0, ns_help_level, ns_help_level_oneline},
|
2003-12-12 20:38:45 +00:00
|
|
|
{"STATUS", ns_status, 0, 0, ns_help_status, ns_help_status_oneline},
|
2003-12-02 22:54:00 +00:00
|
|
|
{"VERSION", ns_version, 0, 0, ns_help_version, ns_help_version_oneline},
|
|
|
|
{"SHUTDOWN", ns_shutdown, 0, NS_ULEVEL_ADMIN, ns_help_shutdown, ns_help_shutdown_oneline},
|
|
|
|
{"RELOAD", ns_reload, 0, NS_ULEVEL_ADMIN, ns_help_reload, ns_help_reload_oneline},
|
|
|
|
{"LOGS", ns_logs, 0, NS_ULEVEL_OPER, ns_help_logs, ns_help_logs_oneline},
|
|
|
|
{"MODLIST", list_modules, 0, NS_ULEVEL_ADMIN, ns_help_modlist, ns_help_modlist_oneline},
|
|
|
|
{"LOAD", ns_load, 1, NS_ULEVEL_ADMIN, ns_help_load, ns_help_load_oneline},
|
|
|
|
{"UNLOAD", ns_unload, 1, NS_ULEVEL_ADMIN, ns_help_unload, ns_help_unload_oneline},
|
|
|
|
{"JUPE", ns_jupe, 1, NS_ULEVEL_ADMIN, ns_help_jupe, ns_help_jupe_oneline},
|
2004-01-26 11:33:52 +00:00
|
|
|
{"EXCLUDE", ns_exclude, 0, NS_ULEVEL_ADMIN, ns_help_exclude, ns_help_exclude_oneline},
|
2003-11-27 22:49:10 +00:00
|
|
|
#ifdef USE_RAW
|
2003-12-02 22:54:00 +00:00
|
|
|
{"RAW", ns_raw, 0, NS_ULEVEL_ADMIN, ns_help_raw, ns_help_raw_oneline},
|
|
|
|
#endif
|
|
|
|
{"DEBUG", ns_set_debug, 1, NS_ULEVEL_ROOT, ns_help_debug, ns_help_debug_oneline},
|
|
|
|
{"BOTLIST", list_bots, 0, NS_ULEVEL_ROOT, ns_help_botlist, ns_help_botlist_oneline},
|
|
|
|
{"SOCKLIST", list_sockets, 0, NS_ULEVEL_ROOT, ns_help_socklist, ns_help_socklist_oneline},
|
|
|
|
{"TIMERLIST", list_timers, 0, NS_ULEVEL_ROOT, ns_help_timerlist, ns_help_timerlist_oneline},
|
|
|
|
{"BOTCHANLIST", list_bot_chans, 0, NS_ULEVEL_ROOT, ns_help_botchanlist,ns_help_botchanlist_oneline},
|
|
|
|
{"USERDUMP", ns_userdump, 0, NS_ULEVEL_ROOT, ns_help_userdump, ns_help_userdump_oneline},
|
|
|
|
{"CHANDUMP", ns_chandump, 0, NS_ULEVEL_ROOT, ns_help_chandump, ns_help_chandump_oneline},
|
|
|
|
{"SERVERDUMP", ns_serverdump, 0, NS_ULEVEL_ROOT, ns_help_serverdump, ns_help_serverdump_oneline},
|
2004-05-28 09:38:31 +00:00
|
|
|
{"BANDUMP", ns_bandump, 0, NS_ULEVEL_ROOT, ns_help_bandump, ns_help_bandump_oneline},
|
2003-12-02 22:54:00 +00:00
|
|
|
{NULL, NULL, 0, 0, NULL, NULL}
|
2003-11-18 11:51:09 +00:00
|
|
|
};
|
|
|
|
|
2003-11-25 21:52:38 +00:00
|
|
|
/** @brief init services
|
|
|
|
*
|
|
|
|
* Setup command list for main services bot
|
|
|
|
*
|
|
|
|
* @param none
|
|
|
|
* @returns NS_SUCCESS or NS_FAILURE
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
init_services(void)
|
2003-11-23 21:36:35 +00:00
|
|
|
{
|
2004-01-23 22:39:09 +00:00
|
|
|
ModUser* bot_ptr;
|
|
|
|
|
2003-11-25 21:52:38 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2003-11-23 21:36:35 +00:00
|
|
|
/* Add command list to services bot */
|
2004-01-23 22:39:09 +00:00
|
|
|
bot_ptr = add_neostats_mod_user (s_Services);
|
|
|
|
bot_ptr->flags = me.onlyopers ? BOT_FLAG_ONLY_OPERS : 0;
|
2004-03-06 22:25:41 +00:00
|
|
|
bot_ptr->flags |= BOT_FLAG_DEAF;
|
2004-02-06 20:07:07 +00:00
|
|
|
add_bot_cmd_list(bot_ptr, ns_commands);
|
2003-11-23 21:36:35 +00:00
|
|
|
return NS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-01-26 11:33:52 +00:00
|
|
|
/** @brief EXCLUDE command handler
|
|
|
|
*
|
|
|
|
* maintain global exclusion list, which modules can take advantage off
|
|
|
|
*
|
|
|
|
* @param u user
|
|
|
|
* @param av list of arguments
|
|
|
|
* @param ac number of arguments
|
|
|
|
* @returns none
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
|
|
|
ns_exclude (User *u, char **av, int ac)
|
|
|
|
{
|
2004-01-31 08:16:05 +00:00
|
|
|
if (ac < 3) {
|
|
|
|
prefmsg(u->nick, s_Services, "Invalid Syntax. /msg %s help exclude", s_Services);
|
|
|
|
return NS_FAILURE;
|
|
|
|
}
|
2004-01-27 13:32:54 +00:00
|
|
|
if (!ircstrcasecmp(av[2], "ADD")) {
|
2004-01-26 11:33:52 +00:00
|
|
|
if (ac < 5) {
|
|
|
|
prefmsg(u->nick, s_Services, "Invalid Syntax. /msg %s help exclude", s_Services);
|
|
|
|
return NS_FAILURE;
|
|
|
|
}
|
|
|
|
ns_do_exclude_add(u, av[3], av[4]);
|
2004-01-27 13:32:54 +00:00
|
|
|
} else if (!ircstrcasecmp(av[2], "DEL")) {
|
2004-01-26 11:33:52 +00:00
|
|
|
if (ac < 4) {
|
|
|
|
prefmsg(u->nick, s_Services, "Invalid Syntax. /msg %s help exclude", s_Services);
|
|
|
|
return NS_FAILURE;
|
|
|
|
}
|
|
|
|
ns_do_exclude_del(u, av[3]);
|
2004-01-27 13:32:54 +00:00
|
|
|
} else if (!ircstrcasecmp(av[2], "LIST")) {
|
2004-01-26 11:33:52 +00:00
|
|
|
ns_do_exclude_list(u, s_Services);
|
|
|
|
} else {
|
|
|
|
prefmsg(u->nick, s_Services, "Invalid Syntax. /msg %s help exclude", s_Services);
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2003-11-25 21:52:38 +00:00
|
|
|
/** @brief SHUTDOWN command handler
|
|
|
|
*
|
|
|
|
* Shutdown NeoStats
|
|
|
|
*
|
|
|
|
* @param user
|
|
|
|
* @param list of arguments
|
|
|
|
* @param number of arguments
|
|
|
|
* @returns none
|
|
|
|
*/
|
2003-11-27 22:49:10 +00:00
|
|
|
static int
|
2003-11-18 11:51:09 +00:00
|
|
|
ns_shutdown (User * u, char **av, int ac)
|
2003-10-06 16:33:42 +00:00
|
|
|
{
|
2003-11-21 10:56:04 +00:00
|
|
|
char *tmp;
|
|
|
|
|
2003-10-06 16:33:42 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2003-11-18 11:51:09 +00:00
|
|
|
if (ac <= 2) {
|
|
|
|
ircsnprintf (quitmsg, BUFSIZE, "%s [%s](%s) requested SHUTDOWN for %s.",
|
|
|
|
u->nick, u->username, u->hostname, no_reason);
|
|
|
|
} else {
|
|
|
|
tmp = joinbuf (av, ac, 2);
|
|
|
|
chanalert (s_Services, "%s Wants me to SHUTDOWN for %s", u->nick, tmp);
|
|
|
|
ircsnprintf (quitmsg, BUFSIZE, "%s [%s](%s) requested SHUTDOWN for %s.",
|
|
|
|
u->nick, u->username, u->hostname, tmp);
|
|
|
|
free (tmp);
|
|
|
|
}
|
2003-12-25 22:23:20 +00:00
|
|
|
globops (s_Services, "%s", quitmsg);
|
|
|
|
nlog (LOG_NOTICE, LOG_CORE, "%s", quitmsg);
|
2003-11-03 13:57:11 +00:00
|
|
|
do_exit (NS_EXIT_NORMAL, quitmsg);
|
2003-11-27 22:49:10 +00:00
|
|
|
return 1;
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
|
|
|
|
2003-11-25 21:52:38 +00:00
|
|
|
/** @brief RELOAD command handler
|
|
|
|
*
|
|
|
|
* Reload NeoStats
|
|
|
|
*
|
|
|
|
* @param user
|
|
|
|
* @param list of arguments
|
|
|
|
* @param number of arguments
|
|
|
|
* @returns none
|
|
|
|
*/
|
2003-11-27 22:49:10 +00:00
|
|
|
static int
|
2003-11-18 11:51:09 +00:00
|
|
|
ns_reload (User * u, char **av, int ac)
|
2000-02-03 23:45:51 +00:00
|
|
|
{
|
2003-11-21 10:56:04 +00:00
|
|
|
char *tmp;
|
|
|
|
|
2003-09-18 12:21:32 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2003-11-18 11:51:09 +00:00
|
|
|
if (ac <= 2) {
|
|
|
|
prefmsg (u->nick, s_Services, "You must supply a Reason to Reload");
|
2003-11-27 22:49:10 +00:00
|
|
|
return 0;
|
2003-11-18 11:51:09 +00:00
|
|
|
}
|
|
|
|
tmp = joinbuf (av, ac, 2);
|
|
|
|
chanalert (s_Services, "%s Wants me to RELOAD! for %s", u->nick, tmp);
|
2003-11-03 13:57:11 +00:00
|
|
|
ircsnprintf (quitmsg, BUFSIZE, "%s [%s](%s) requested RELOAD for %s.",
|
2003-11-18 11:51:09 +00:00
|
|
|
u->nick, u->username, u->hostname, tmp);
|
|
|
|
free (tmp);
|
2003-12-25 22:23:20 +00:00
|
|
|
globops (s_Services, "%s", quitmsg);
|
|
|
|
nlog (LOG_NOTICE, LOG_CORE, "%s", quitmsg);
|
2003-11-03 13:57:11 +00:00
|
|
|
do_exit (NS_EXIT_RELOAD, quitmsg);
|
2003-11-27 22:49:10 +00:00
|
|
|
return 1;
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
|
|
|
|
2003-11-25 21:52:38 +00:00
|
|
|
/** @brief LOGS command handler
|
|
|
|
*
|
|
|
|
* Send logs to nick
|
|
|
|
*
|
|
|
|
* @param user
|
|
|
|
* @param list of arguments
|
|
|
|
* @param number of arguments
|
|
|
|
* @returns none
|
|
|
|
*/
|
2003-11-27 22:49:10 +00:00
|
|
|
static int
|
2003-11-18 11:51:09 +00:00
|
|
|
ns_logs (User * u, char **av, int ac)
|
2000-02-03 23:45:51 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2003-07-30 13:58:22 +00:00
|
|
|
prefmsg (u->nick, s_Services, "This command is disabled while in DEBUG.");
|
2000-02-03 23:45:51 +00:00
|
|
|
#else
|
|
|
|
FILE *fp;
|
2003-11-03 13:57:11 +00:00
|
|
|
char buf[BUFSIZE];
|
2000-02-03 23:45:51 +00:00
|
|
|
|
2003-09-18 12:21:32 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2003-07-30 13:58:22 +00:00
|
|
|
fp = fopen ("logs/NeoStats.log", "r");
|
2000-02-03 23:45:51 +00:00
|
|
|
if (!fp) {
|
2003-07-30 13:58:22 +00:00
|
|
|
prefmsg (u->nick, s_Services, "Unable to open neostats.log");
|
2003-12-04 19:18:33 +00:00
|
|
|
return 1;
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
2003-11-03 13:57:11 +00:00
|
|
|
while (fgets (buf, BUFSIZE, fp)) {
|
2003-07-30 13:58:22 +00:00
|
|
|
buf[strlen (buf)] = '\0';
|
2003-11-03 13:57:11 +00:00
|
|
|
prefmsg (u->nick, s_Services, buf);
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
2003-07-30 13:58:22 +00:00
|
|
|
fclose (fp);
|
2000-02-03 23:45:51 +00:00
|
|
|
#endif
|
2003-11-27 22:49:10 +00:00
|
|
|
return 1;
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
|
|
|
|
2003-11-25 21:52:38 +00:00
|
|
|
/** @brief JUPE command handler
|
|
|
|
*
|
|
|
|
* Jupiter a server
|
|
|
|
*
|
|
|
|
* @param user
|
|
|
|
* @param list of arguments
|
|
|
|
* @param number of arguments
|
|
|
|
* @returns none
|
|
|
|
*/
|
2003-11-27 22:49:10 +00:00
|
|
|
static int
|
2003-11-18 11:51:09 +00:00
|
|
|
ns_jupe (User * u, char **av, int ac)
|
2000-02-03 23:45:51 +00:00
|
|
|
{
|
2002-03-05 08:13:45 +00:00
|
|
|
char infoline[255];
|
2003-11-18 11:51:09 +00:00
|
|
|
|
2003-09-18 12:21:32 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2003-11-03 13:57:11 +00:00
|
|
|
ircsnprintf (infoline, 255, "[Jupitered by %s]", u->nick);
|
2003-11-18 11:51:09 +00:00
|
|
|
sserver_cmd (av[2], 1, infoline);
|
|
|
|
nlog (LOG_NOTICE, LOG_CORE, "%s!%s@%s jupitered %s", u->nick, u->username, u->hostname, av[2]);
|
|
|
|
chanalert (s_Services, "%s Wants to JUPE this Server %s", u->nick, av[2]);
|
|
|
|
prefmsg(u->nick, s_Services, "%s has been Jupitered", av[2]);
|
2003-11-27 22:49:10 +00:00
|
|
|
return 1;
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
|
|
|
|
2003-11-25 21:52:38 +00:00
|
|
|
/** @brief DEBUG command handler
|
|
|
|
*
|
|
|
|
* Set debug mode on/off
|
|
|
|
*
|
|
|
|
* @param user
|
|
|
|
* @param list of arguments
|
|
|
|
* @param number of arguments
|
|
|
|
* @returns none
|
|
|
|
*/
|
2003-11-27 22:49:10 +00:00
|
|
|
static int
|
2003-11-18 11:51:09 +00:00
|
|
|
ns_set_debug (User * u, char **av, int ac)
|
2000-02-03 23:45:51 +00:00
|
|
|
{
|
2003-09-18 12:21:32 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2004-01-27 13:32:54 +00:00
|
|
|
if ((!ircstrcasecmp(av[2], "YES")) || (!ircstrcasecmp(av[2], "ON"))) {
|
2003-11-03 13:57:11 +00:00
|
|
|
me.debug_mode = 1;
|
2003-11-18 11:51:09 +00:00
|
|
|
globops (me.name, "\2DEBUG MODE\2 Activated by %s", u->nick);
|
|
|
|
prefmsg (u->nick, s_Services, "Debuging Mode Enabled!");
|
2004-01-27 13:32:54 +00:00
|
|
|
} else if ((!ircstrcasecmp(av[2], "NO")) || (!ircstrcasecmp(av[2], "OFF"))) {
|
2003-11-03 13:57:11 +00:00
|
|
|
me.debug_mode = 0;
|
2003-11-18 11:51:09 +00:00
|
|
|
globops (me.name, "\2DEBUG MODE\2 Deactivated by %s", u->nick);
|
|
|
|
prefmsg (u->nick, s_Services, "Debuging Mode Disabled");
|
|
|
|
} else {
|
|
|
|
prefmsg(u->nick, s_Services,
|
|
|
|
"Syntax Error: /msg %s HELP DEBUG for more info",
|
|
|
|
s_Services);
|
2003-11-27 22:49:10 +00:00
|
|
|
return 0;
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
2003-11-27 22:49:10 +00:00
|
|
|
return 1;
|
2003-06-13 13:11:50 +00:00
|
|
|
}
|
|
|
|
|
2003-11-25 21:52:38 +00:00
|
|
|
/** @brief USERDUMP command handler
|
|
|
|
*
|
|
|
|
* Dump user list
|
|
|
|
*
|
|
|
|
* @param user
|
|
|
|
* @param list of arguments
|
|
|
|
* @param number of arguments
|
|
|
|
* @returns none
|
|
|
|
*/
|
2003-11-27 22:49:10 +00:00
|
|
|
static int
|
|
|
|
ns_userdump (User * u, char **av, int ac)
|
2000-02-03 23:45:51 +00:00
|
|
|
{
|
2003-11-25 21:52:38 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2003-11-18 11:51:09 +00:00
|
|
|
if (!me.debug_mode) {
|
|
|
|
prefmsg (u->nick, s_Services, "\2Error:\2 Debug Mode Disabled");
|
2003-11-27 22:49:10 +00:00
|
|
|
return 0;
|
2003-06-13 13:11:50 +00:00
|
|
|
}
|
2004-01-10 22:48:53 +00:00
|
|
|
if(ac < 3) {
|
|
|
|
chanalert (s_Services, "\2DEBUG\2 \2%s\2 Requested a UserDump!", u->nick);
|
|
|
|
UserDump (NULL);
|
|
|
|
} else {
|
|
|
|
chanalert (s_Services, "\2DEBUG\2 \2%s\2 Requested a UserDump for %s!", u->nick, av[2]);
|
|
|
|
UserDump (av[2]);
|
|
|
|
}
|
2003-11-27 22:49:10 +00:00
|
|
|
return 1;
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
2003-11-25 21:52:38 +00:00
|
|
|
|
|
|
|
/** @brief SERVERDUMP command handler
|
|
|
|
*
|
|
|
|
* Dump server list
|
|
|
|
*
|
|
|
|
* @param user
|
|
|
|
* @param list of arguments
|
|
|
|
* @param number of arguments
|
|
|
|
* @returns none
|
|
|
|
*/
|
2003-11-27 22:49:10 +00:00
|
|
|
static int
|
|
|
|
ns_serverdump (User * u, char **av, int ac)
|
2000-02-03 23:45:51 +00:00
|
|
|
{
|
2003-09-18 12:21:32 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2003-11-18 11:51:09 +00:00
|
|
|
if (!me.debug_mode) {
|
|
|
|
prefmsg (u->nick, s_Services, "\2Error:\2 Debug Mode Disabled");
|
2003-11-27 22:49:10 +00:00
|
|
|
return 0;
|
2003-06-13 13:11:50 +00:00
|
|
|
}
|
2004-02-15 17:34:07 +00:00
|
|
|
if(ac < 3) {
|
|
|
|
chanalert (s_Services, "\2DEBUG\2 \2%s\2 Requested a ServerDump!", u->nick);
|
|
|
|
ServerDump (NULL);
|
|
|
|
} else {
|
|
|
|
chanalert (s_Services, "\2DEBUG\2 \2%s\2 Requested a ServerDump for %s!", u->nick, av[2]);
|
|
|
|
ServerDump (av[2]);
|
|
|
|
}
|
2003-11-27 22:49:10 +00:00
|
|
|
return 1;
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
2003-11-25 21:52:38 +00:00
|
|
|
|
2004-05-28 09:38:31 +00:00
|
|
|
/** @brief BANDUMP command handler
|
|
|
|
*
|
|
|
|
* Dump ban list
|
|
|
|
*
|
|
|
|
* @param user
|
|
|
|
* @param list of arguments
|
|
|
|
* @param number of arguments
|
|
|
|
* @returns none
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
ns_bandump (User * u, char **av, int ac)
|
|
|
|
{
|
|
|
|
SET_SEGV_LOCATION();
|
|
|
|
if (!me.debug_mode) {
|
|
|
|
prefmsg (u->nick, s_Services, "\2Error:\2 Debug Mode Disabled");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
chanalert (s_Services, "\2DEBUG\2 \2%s\2 Requested a BanDump!", u->nick);
|
|
|
|
BanDump();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2003-11-25 21:52:38 +00:00
|
|
|
/** @brief CHANDUMP command handler
|
|
|
|
*
|
|
|
|
* Dump channel list
|
|
|
|
*
|
|
|
|
* @param user
|
|
|
|
* @param list of arguments
|
|
|
|
* @param number of arguments
|
|
|
|
* @returns none
|
|
|
|
*/
|
2003-11-27 22:49:10 +00:00
|
|
|
static int
|
|
|
|
ns_chandump (User * u, char **av, int ac)
|
2000-02-03 23:45:51 +00:00
|
|
|
{
|
2003-09-18 12:21:32 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2003-11-18 11:51:09 +00:00
|
|
|
if (!me.debug_mode) {
|
|
|
|
prefmsg (u->nick, s_Services, "\2Error:\2 Debug Mode Disabled");
|
2003-11-27 22:49:10 +00:00
|
|
|
return 0;
|
2003-06-13 13:11:50 +00:00
|
|
|
}
|
2004-01-10 22:48:53 +00:00
|
|
|
if(ac < 3) {
|
|
|
|
chanalert (s_Services, "\2DEBUG\2 \2%s\2 Requested a ChannelDump!", u->nick);
|
|
|
|
ChanDump (NULL);
|
|
|
|
} else {
|
|
|
|
chanalert (s_Services, "\2DEBUG\2 \2%s\2 Requested a ChannelDump for %s!", u->nick, av[2]);
|
|
|
|
ChanDump (av[2]);
|
|
|
|
}
|
2003-11-27 22:49:10 +00:00
|
|
|
return 1;
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
2003-11-18 11:51:09 +00:00
|
|
|
|
2003-12-12 20:38:45 +00:00
|
|
|
/** @brief STATUS command handler
|
2003-11-25 21:52:38 +00:00
|
|
|
*
|
2003-12-12 20:38:45 +00:00
|
|
|
* Display NeoStats status
|
2003-11-25 21:52:38 +00:00
|
|
|
*
|
|
|
|
* @param user
|
|
|
|
* @param list of arguments
|
|
|
|
* @param number of arguments
|
|
|
|
* @returns none
|
|
|
|
*/
|
2003-11-27 22:49:10 +00:00
|
|
|
static int
|
2003-12-12 20:38:45 +00:00
|
|
|
ns_status (User * u, char **av, int ac)
|
2000-02-03 23:45:51 +00:00
|
|
|
{
|
2003-11-03 13:57:11 +00:00
|
|
|
int uptime = me.now - me.t_start;
|
2000-02-05 02:51:50 +00:00
|
|
|
|
2003-09-18 12:21:32 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2003-12-12 20:38:45 +00:00
|
|
|
prefmsg (u->nick, s_Services, "%s Status:", s_Services);
|
2002-02-28 04:49:10 +00:00
|
|
|
if (uptime > 86400) {
|
2003-12-04 15:47:53 +00:00
|
|
|
prefmsg (u->nick, s_Services, "%s up \2%d\2 day%s, \2%02d:%02d\2", s_Services, uptime / 86400, (uptime / 86400 == 1) ? "" : "s", (uptime / 3600) % 24, (uptime / 60) % 60);
|
2002-02-28 04:49:10 +00:00
|
|
|
} else if (uptime > 3600) {
|
2003-12-04 15:47:53 +00:00
|
|
|
prefmsg (u->nick, s_Services, "%s up \2%d hour%s, %d minute%s\2", s_Services, uptime / 3600, uptime / 3600 == 1 ? "" : "s", (uptime / 60) % 60, (uptime / 60) % 60 == 1 ? "" : "s");
|
2002-02-28 04:49:10 +00:00
|
|
|
} else if (uptime > 60) {
|
2003-12-04 15:47:53 +00:00
|
|
|
prefmsg (u->nick, s_Services, "%s up \2%d minute%s, %d second%s\2", s_Services, uptime / 60, uptime / 60 == 1 ? "" : "s", uptime % 60, uptime % 60 == 1 ? "" : "s");
|
2003-06-13 13:11:50 +00:00
|
|
|
} else {
|
2003-12-04 15:47:53 +00:00
|
|
|
prefmsg (u->nick, s_Services, "%s up \2%d second%s\2", s_Services, uptime, uptime == 1 ? "" : "s");
|
2003-06-13 13:11:50 +00:00
|
|
|
}
|
2003-07-30 13:58:22 +00:00
|
|
|
prefmsg (u->nick, s_Services, "Sent %ld Messages Totaling %ld Bytes", me.SendM, me.SendBytes);
|
2003-10-07 10:33:13 +00:00
|
|
|
prefmsg (u->nick, s_Services, "Received %ld Messages, Totaling %ld Bytes", me.RcveM, me.RcveBytes);
|
2003-07-30 13:58:22 +00:00
|
|
|
prefmsg (u->nick, s_Services, "Reconnect Time: %d", me.r_time);
|
|
|
|
prefmsg (u->nick, s_Services, "Statistic Requests: %d", me.requests);
|
|
|
|
prefmsg (u->nick, s_Services, "Max Sockets: %d (in use: %d)", me.maxsocks, me.cursocks);
|
2003-11-03 13:57:11 +00:00
|
|
|
if (me.debug_mode)
|
2003-07-30 13:58:22 +00:00
|
|
|
prefmsg (u->nick, s_Services, "Debugging Mode is \2ON!\2");
|
2003-06-13 13:11:50 +00:00
|
|
|
else
|
2003-07-30 13:58:22 +00:00
|
|
|
prefmsg (u->nick, s_Services, "Debugging Mode is Disabled!");
|
2003-11-27 22:49:10 +00:00
|
|
|
return 0;
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
2003-11-25 21:52:38 +00:00
|
|
|
|
|
|
|
/** @brief VERSION command handler
|
|
|
|
*
|
|
|
|
* NeoStats Version
|
|
|
|
*
|
|
|
|
* @param user
|
|
|
|
* @param list of arguments
|
|
|
|
* @param number of arguments
|
|
|
|
* @returns none
|
|
|
|
*/
|
2003-11-27 22:49:10 +00:00
|
|
|
static int
|
2003-11-18 11:51:09 +00:00
|
|
|
ns_version (User * u, char **av, int ac)
|
2000-02-03 23:45:51 +00:00
|
|
|
{
|
2003-09-18 12:21:32 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2003-12-12 20:38:45 +00:00
|
|
|
prefmsg (u->nick, s_Services, "\2NeoStats Version\2");
|
2004-02-20 15:43:28 +00:00
|
|
|
prefmsg (u->nick, s_Services, "NeoStats Version: %s", me.versionfull);
|
2003-07-30 13:58:22 +00:00
|
|
|
prefmsg (u->nick, s_Services, "http://www.neostats.net");
|
2003-11-27 22:49:10 +00:00
|
|
|
return 1;
|
2002-02-28 04:49:10 +00:00
|
|
|
}
|
2003-11-18 11:51:09 +00:00
|
|
|
|
2003-11-25 21:52:38 +00:00
|
|
|
/** @brief LEVEL command handler
|
|
|
|
*
|
|
|
|
* Display user level
|
|
|
|
*
|
|
|
|
* @param user
|
|
|
|
* @param list of arguments
|
|
|
|
* @param number of arguments
|
|
|
|
* @returns none
|
|
|
|
*/
|
2003-11-27 22:49:10 +00:00
|
|
|
static int
|
|
|
|
ns_level (User * u, char **av, int ac)
|
2003-11-18 11:51:09 +00:00
|
|
|
{
|
2003-11-25 21:52:38 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2003-11-20 22:34:12 +00:00
|
|
|
if(ac > 2) {
|
|
|
|
User * otheruser;
|
|
|
|
otheruser = finduser(av[2]);
|
|
|
|
if(otheruser) {
|
|
|
|
prefmsg (u->nick, s_Services, "User Level for %s is %d", otheruser->nick, UserLevel (otheruser));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
prefmsg (u->nick, s_Services, "Your Level is %d", UserLevel (u));
|
|
|
|
}
|
2003-11-27 22:49:10 +00:00
|
|
|
return 1;
|
2003-11-18 11:51:09 +00:00
|
|
|
}
|
|
|
|
|
2003-11-25 21:52:38 +00:00
|
|
|
/** @brief LOAD command handler
|
|
|
|
*
|
|
|
|
* Load module
|
|
|
|
*
|
|
|
|
* @param user
|
|
|
|
* @param list of arguments
|
|
|
|
* @param number of arguments
|
|
|
|
* @returns none
|
|
|
|
*/
|
2003-11-27 22:49:10 +00:00
|
|
|
static int
|
|
|
|
ns_load (User * u, char **av, int ac)
|
2003-11-18 11:51:09 +00:00
|
|
|
{
|
2003-11-25 21:52:38 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2003-11-18 11:51:09 +00:00
|
|
|
if (load_module (av[2], u) == NS_SUCCESS) {
|
|
|
|
chanalert (s_Services, "%s Loaded Module %s", u->nick, av[2]);
|
|
|
|
} else {
|
|
|
|
chanalert (s_Services, "%s Tried to Load Module %s, but Failed", u->nick, av[2]);
|
|
|
|
}
|
2003-11-27 22:49:10 +00:00
|
|
|
return 1;
|
2003-11-18 11:51:09 +00:00
|
|
|
}
|
|
|
|
|
2003-11-25 21:52:38 +00:00
|
|
|
/** @brief UNLOAD command handler
|
|
|
|
*
|
|
|
|
* Unload module
|
|
|
|
*
|
|
|
|
* @param user
|
|
|
|
* @param list of arguments
|
|
|
|
* @param number of arguments
|
|
|
|
* @returns none
|
|
|
|
*/
|
2003-11-27 22:49:10 +00:00
|
|
|
static int
|
|
|
|
ns_unload (User * u, char **av, int ac)
|
2003-11-18 11:51:09 +00:00
|
|
|
{
|
2003-11-25 21:52:38 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2003-11-18 11:51:09 +00:00
|
|
|
if (unload_module (av[2], u) > 0) {
|
|
|
|
chanalert (s_Services, "%s Unloaded Module %s", u->nick, av[2]);
|
|
|
|
}
|
2003-11-27 22:49:10 +00:00
|
|
|
return 1;
|
2003-11-18 11:51:09 +00:00
|
|
|
}
|
|
|
|
|
2003-11-25 21:52:38 +00:00
|
|
|
/** @brief RAW command handler
|
|
|
|
*
|
|
|
|
* issue a RAW command
|
|
|
|
*
|
|
|
|
* @param user
|
|
|
|
* @param list of arguments
|
|
|
|
* @param number of arguments
|
|
|
|
* @returns none
|
|
|
|
*/
|
2003-11-18 11:51:09 +00:00
|
|
|
#ifdef USE_RAW
|
2003-11-27 22:49:10 +00:00
|
|
|
static int
|
2003-11-18 11:51:09 +00:00
|
|
|
ns_raw (User * u, char **av, int ac)
|
|
|
|
{
|
|
|
|
char *message;
|
|
|
|
|
|
|
|
SET_SEGV_LOCATION();
|
2003-11-25 21:52:38 +00:00
|
|
|
message = joinbuf (av, ac, 2);
|
2003-11-18 11:51:09 +00:00
|
|
|
chanalert (s_Services, "\2RAW COMMAND\2 \2%s\2 Issued a Raw Command!(%s)", u->nick, message);
|
|
|
|
nlog (LOG_INFO, LOG_CORE, "RAW COMMAND %sIssued a Raw Command!(%s)", u->nick, message);
|
2004-02-04 22:59:41 +00:00
|
|
|
send_cmd ("%s", message);
|
2003-11-18 11:51:09 +00:00
|
|
|
free (message);
|
2003-11-27 22:49:10 +00:00
|
|
|
return 1;
|
2003-11-18 11:51:09 +00:00
|
|
|
}
|
|
|
|
#endif
|