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 #include "commands/cmd_zline.h"
20 extern "C" DllExport Command* init_command(InspIRCd* Instance)
22 return new CommandZline(Instance);
25 CmdResult CommandZline::Handle (const std::vector<std::string>& parameters, User *user)
27 std::string target = parameters[0];
29 if (parameters.size() >= 3)
31 if (target.find('!') != std::string::npos)
33 user->WriteServ("NOTICE %s :*** You cannot include a nickname in a zline, a zline must ban only an IP mask",user->nick.c_str());
37 User *u = ServerInstance->FindNick(target.c_str());
41 target = u->GetIPString();
44 const char* ipaddr = target.c_str();
46 if (strchr(ipaddr,'@'))
48 while (*ipaddr != '@')
53 if (ServerInstance->IPMatchesEveryone(ipaddr,user))
56 long duration = ServerInstance->Duration(parameters[1].c_str());
58 ZLine* zl = new ZLine(ServerInstance, ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), ipaddr);
59 if (ServerInstance->XLines->AddLine(zl,user))
63 ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Z-line for %s: %s", user->nick.c_str(), ipaddr, parameters[2].c_str());
67 time_t c_requires_crap = duration + ServerInstance->Time();
68 ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Z-line for %s, expires on %s: %s",user->nick.c_str(),ipaddr,
69 ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
71 ServerInstance->XLines->ApplyLines();
76 user->WriteServ("NOTICE %s :*** Z-Line for %s already exists",user->nick.c_str(),ipaddr);
81 if (ServerInstance->XLines->DelLine(target.c_str(),"Z",user))
83 ServerInstance->SNO->WriteToSnoMask('x',"%s Removed Z-line on %s.",user->nick.c_str(),target.c_str());
87 user->WriteServ("NOTICE %s :*** Z-Line %s not found in list, try /stats Z.",user->nick.c_str(),target.c_str());