2005-12-16 18:10:38 +00:00
|
|
|
/* +------------------------------------+
|
|
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
|
|
* +------------------------------------+
|
|
|
|
*
|
2006-12-15 21:45:30 +00:00
|
|
|
* InspIRCd: (C) 2002-2007 InspIRCd Development Team
|
|
|
|
* See: http://www.inspircd.org/wiki/index.php/Credits
|
2005-12-16 18:10:38 +00:00
|
|
|
*
|
|
|
|
* This program is free but copyrighted software; see
|
|
|
|
* the file COPYING for details.
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "inspircd.h"
|
2006-04-08 17:05:48 +00:00
|
|
|
#include "configreader.h"
|
2005-12-16 18:10:38 +00:00
|
|
|
#include "users.h"
|
|
|
|
#include "modules.h"
|
|
|
|
#include "xline.h"
|
2006-04-20 18:55:46 +00:00
|
|
|
#include "commands/cmd_zline.h"
|
2005-12-16 18:10:38 +00:00
|
|
|
|
2006-09-03 00:09:38 +00:00
|
|
|
|
|
|
|
|
2007-05-19 15:56:42 +00:00
|
|
|
extern "C" DllExport command_t* init_command(InspIRCd* Instance)
|
2006-09-03 00:09:38 +00:00
|
|
|
{
|
|
|
|
return new cmd_zline(Instance);
|
|
|
|
}
|
|
|
|
|
2006-09-06 17:21:59 +00:00
|
|
|
CmdResult cmd_zline::Handle (const char** parameters, int pcnt, userrec *user)
|
2005-12-16 18:10:38 +00:00
|
|
|
{
|
|
|
|
if (pcnt >= 3)
|
|
|
|
{
|
2007-04-06 18:43:58 +00:00
|
|
|
if (strchr(parameters[0],'@') || strchr(parameters[0],'!'))
|
2005-12-16 18:10:38 +00:00
|
|
|
{
|
2007-04-06 18:43:58 +00:00
|
|
|
user->WriteServ("NOTICE %s :*** You cannot include a username or nickname in a zline, a zline must ban only an IP mask",user->nick);
|
2006-09-06 17:21:59 +00:00
|
|
|
return CMD_FAILURE;
|
2005-12-16 18:10:38 +00:00
|
|
|
}
|
2006-09-06 17:21:59 +00:00
|
|
|
|
2006-08-11 16:14:44 +00:00
|
|
|
if (ServerInstance->IPMatchesEveryone(parameters[0],user))
|
2006-09-06 17:21:59 +00:00
|
|
|
return CMD_FAILURE;
|
|
|
|
|
2007-06-05 17:39:36 +00:00
|
|
|
long duration = ServerInstance->Duration(parameters[1]);
|
|
|
|
if (ServerInstance->XLines->add_zline(duration,user->nick,parameters[2],parameters[0]))
|
2005-12-16 18:10:38 +00:00
|
|
|
{
|
2007-01-10 17:34:57 +00:00
|
|
|
int to_apply = APPLY_ZLINES;
|
|
|
|
|
2007-06-05 17:39:36 +00:00
|
|
|
FOREACH_MOD(I_OnAddZLine,OnAddZLine(duration, user, parameters[2], parameters[0]));
|
|
|
|
if (!duration)
|
2007-01-10 17:34:57 +00:00
|
|
|
{
|
|
|
|
to_apply |= APPLY_PERM_ONLY;
|
|
|
|
ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Z-line for %s.",user->nick,parameters[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-06-05 17:39:36 +00:00
|
|
|
time_t c_requires_crap = duration + ServerInstance->Time();
|
2007-04-06 19:18:08 +00:00
|
|
|
ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Z-line for %s, expires on %s",user->nick,parameters[0],
|
|
|
|
ServerInstance->TimeString(c_requires_crap).c_str());
|
2007-01-10 17:34:57 +00:00
|
|
|
}
|
|
|
|
ServerInstance->XLines->apply_lines(to_apply);
|
2005-12-16 18:10:38 +00:00
|
|
|
}
|
2007-06-14 17:03:16 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
user->WriteServ("NOTICE %s :*** Z-Line for %s already exists",user->nick,parameters[0]);
|
|
|
|
}
|
2005-12-16 18:10:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-08-11 11:06:40 +00:00
|
|
|
if (ServerInstance->XLines->del_zline(parameters[0]))
|
2005-12-16 18:10:38 +00:00
|
|
|
{
|
2005-12-26 17:26:16 +00:00
|
|
|
FOREACH_MOD(I_OnDelZLine,OnDelZLine(user, parameters[0]));
|
2006-08-29 19:38:46 +00:00
|
|
|
ServerInstance->SNO->WriteToSnoMask('x',"%s Removed Z-line on %s.",user->nick,parameters[0]);
|
2005-12-16 18:10:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-08-08 18:59:13 +00:00
|
|
|
user->WriteServ("NOTICE %s :*** Z-Line %s not found in list, try /stats Z.",user->nick,parameters[0]);
|
2006-09-06 17:21:59 +00:00
|
|
|
return CMD_FAILURE;
|
2005-12-16 18:10:38 +00:00
|
|
|
}
|
|
|
|
}
|
2006-09-06 17:21:59 +00:00
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
2005-12-16 18:10:38 +00:00
|
|
|
}
|