1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* +------------------------------------+
17 * | Inspire Internet Relay Chat Daemon |
18 * +------------------------------------+
20 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
21 * See: http://wiki.inspircd.org/Credits
23 * This program is free but copyrighted software; see
24 * the file COPYING for details.
26 * ---------------------------------------------------
29 #ifndef __CMD_ZLINE_H__
30 #define __CMD_ZLINE_H__
32 // include the common header files
37 /** Handle /ZLINE. These command handlers can be reloaded by the core,
38 * and handle basic RFC1459 commands. Commands within modules work
39 * the same way, however, they can be fully unloaded, where these
42 class CommandZline : public Command
45 /** Constructor for zline.
47 CommandZline (InspIRCd* Instance, Module* parent) : Command(Instance,parent,"ZLINE","o",1,3,false,0) { syntax = "<ipmask> [<duration> :<reason>]"; }
49 * @param parameters The parameters to the comamnd
50 * @param pcnt The number of parameters passed to teh command
51 * @param user The user issuing the command
52 * @return A value from CmdResult to indicate command success or failure.
54 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
62 CmdResult CommandZline::Handle (const std::vector<std::string>& parameters, User *user)
64 std::string target = parameters[0];
66 if (parameters.size() >= 3)
68 if (target.find('!') != std::string::npos)
70 user->WriteServ("NOTICE %s :*** You cannot include a nickname in a zline, a zline must ban only an IP mask",user->nick.c_str());
74 User *u = ServerInstance->FindNick(target.c_str());
78 target = u->GetIPString();
81 const char* ipaddr = target.c_str();
83 if (strchr(ipaddr,'@'))
85 while (*ipaddr != '@')
90 if (ServerInstance->IPMatchesEveryone(ipaddr,user))
93 long duration = ServerInstance->Duration(parameters[1].c_str());
95 ZLine* zl = new ZLine(ServerInstance, ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ipaddr);
96 if (ServerInstance->XLines->AddLine(zl,user))
100 ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Z-line for %s: %s", user->nick.c_str(), ipaddr, parameters[2].c_str());
104 time_t c_requires_crap = duration + ServerInstance->Time();
105 ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Z-line for %s, expires on %s: %s",user->nick.c_str(),ipaddr,
106 ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
108 ServerInstance->XLines->ApplyLines();
113 user->WriteServ("NOTICE %s :*** Z-Line for %s already exists",user->nick.c_str(),ipaddr);
118 if (ServerInstance->XLines->DelLine(target.c_str(),"Z",user))
120 ServerInstance->SNO->WriteToSnoMask('x',"%s Removed Z-line on %s.",user->nick.c_str(),target.c_str());
124 user->WriteServ("NOTICE %s :*** Z-Line %s not found in list, try /stats Z.",user->nick.c_str(),target.c_str());
132 COMMAND_INIT(CommandZline)