1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 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 /** Handle /ZLINE. These command handlers can be reloaded by the core,
17 * and handle basic RFC1459 commands. Commands within modules work
18 * the same way, however, they can be fully unloaded, where these
21 class CommandZline : public Command
24 /** Constructor for zline.
26 CommandZline ( Module* parent) : Command(parent,"ZLINE",1,3) { flags_needed = 'o'; Penalty = 0; syntax = "<ipmask> [<duration> :<reason>]"; }
28 * @param parameters The parameters to the comamnd
29 * @param pcnt The number of parameters passed to teh command
30 * @param user The user issuing the command
31 * @return A value from CmdResult to indicate command success or failure.
33 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
36 CmdResult CommandZline::Handle (const std::vector<std::string>& parameters, User *user)
38 std::string target = parameters[0];
40 if (parameters.size() >= 3)
42 if (target.find('!') != std::string::npos)
44 user->WriteServ("NOTICE %s :*** You cannot include a nickname in a zline, a zline must ban only an IP mask",user->nick.c_str());
48 User *u = ServerInstance->FindNick(target.c_str());
52 target = u->GetIPString();
55 const char* ipaddr = target.c_str();
57 if (strchr(ipaddr,'@'))
59 while (*ipaddr != '@')
64 if (ServerInstance->IPMatchesEveryone(ipaddr,user))
67 long duration = ServerInstance->Duration(parameters[1].c_str());
69 ZLine* zl = new ZLine(ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ipaddr);
70 if (ServerInstance->XLines->AddLine(zl,user))
74 ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Z-line for %s: %s", user->nick.c_str(), ipaddr, parameters[2].c_str());
78 time_t c_requires_crap = duration + ServerInstance->Time();
79 ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Z-line for %s, expires on %s: %s",user->nick.c_str(),ipaddr,
80 ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
82 ServerInstance->XLines->ApplyLines();
87 user->WriteServ("NOTICE %s :*** Z-Line for %s already exists",user->nick.c_str(),ipaddr);
92 if (ServerInstance->XLines->DelLine(target.c_str(),"Z",user))
94 ServerInstance->SNO->WriteToSnoMask('x',"%s removed Z-line on %s",user->nick.c_str(),target.c_str());
98 user->WriteServ("NOTICE %s :*** Z-Line %s not found in list, try /stats Z.",user->nick.c_str(),target.c_str());
106 COMMAND_INIT(CommandZline)