1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/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 char** parameters, int pcnt, User *user)
27 std::string target = parameters[0];
31 if (strchr(target.c_str(),'@') || strchr(target.c_str(),'!'))
33 user->WriteServ("NOTICE %s :*** You cannot include a username or nickname in a zline, a zline must ban only an IP mask",user->nick);
37 User *u = ServerInstance->FindNick(target.c_str());
41 target = u->GetIPString();
44 if (ServerInstance->IPMatchesEveryone(target.c_str(),user))
47 long duration = ServerInstance->Duration(parameters[1]);
49 const char* ipaddr = target.c_str();
50 User* find = ServerInstance->FindNick(target.c_str());
54 ipaddr = find->GetIPString();
58 if (strchr(ipaddr,'@'))
60 while (*ipaddr != '@')
65 ZLine* zl = new ZLine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2], ipaddr);
66 if (ServerInstance->XLines->AddLine(zl,user))
70 ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent Z-line for %s.",user->nick,target.c_str());
74 time_t c_requires_crap = duration + ServerInstance->Time();
75 ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Z-line for %s, expires on %s",user->nick,target.c_str(),
76 ServerInstance->TimeString(c_requires_crap).c_str());
78 ServerInstance->XLines->ApplyLines();
83 user->WriteServ("NOTICE %s :*** Z-Line for %s already exists",user->nick,target.c_str());
88 if (ServerInstance->XLines->DelLine(target.c_str(),"Z",user))
90 ServerInstance->SNO->WriteToSnoMask('x',"%s Removed Z-line on %s.",user->nick,target.c_str());
94 user->WriteServ("NOTICE %s :*** Z-Line %s not found in list, try /stats Z.",user->nick,target.c_str());