]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/commands/cmd_eline.cpp
Correctly rewrite bans in 1.2 also, and make zline on nicks actually work.
[user/henk/code/inspircd.git] / src / commands / cmd_eline.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *          the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "xline.h"
16 #include "commands/cmd_eline.h"
17
18 extern "C" DllExport Command* init_command(InspIRCd* Instance)
19 {
20         return new CommandEline(Instance);
21 }
22
23 /** Handle /ELINE
24  */
25 CmdResult CommandEline::Handle (const char** parameters, int pcnt, User *user)
26 {
27         if (pcnt >= 3)
28         {
29                 IdentHostPair ih;
30                 User* find = ServerInstance->FindNick(parameters[0]);
31                 if (find)
32                 {
33                         ih.first = "*";
34                         ih.second = find->GetIPString();
35                         std::string c = std::string("*@") + find->GetIPString();
36                         parameters[0] = c.c_str();
37                 }
38                 else
39                         ih = ServerInstance->XLines->IdentSplit(parameters[0]);
40
41                 if (ServerInstance->HostMatchesEveryone(ih.first+"@"+ih.second,user))
42                         return CMD_FAILURE;
43
44                 long duration = ServerInstance->Duration(parameters[1]);
45
46                 ELine* el = new ELine(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2], ih.first.c_str(), ih.second.c_str());
47                 if (ServerInstance->XLines->AddLine(el, user))
48                 {
49                         if (!duration)
50                         {
51                                 ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent E-line for %s.",user->nick,parameters[0]);
52                         }
53                         else
54                         {
55                                 time_t c_requires_crap = duration + ServerInstance->Time();
56                                 ServerInstance->SNO->WriteToSnoMask('x',"%s added timed E-line for %s, expires on %s",user->nick,parameters[0],
57                                                 ServerInstance->TimeString(c_requires_crap).c_str());
58                         }
59                 }
60                 else
61                 {
62                         delete el;
63                         user->WriteServ("NOTICE %s :*** E-Line for %s already exists",user->nick,parameters[0]);
64                 }
65         }
66         else
67         {
68                 if (ServerInstance->XLines->DelLine(parameters[0], "E", user))
69                 {
70                         ServerInstance->SNO->WriteToSnoMask('x',"%s Removed E-line on %s.",user->nick,parameters[0]);
71                 }
72                 else
73                 {
74                         user->WriteServ("NOTICE %s :*** E-Line %s not found in list, try /stats e.",user->nick,parameters[0]);
75                 }
76         }
77
78         return CMD_SUCCESS;
79 }