Anope IRC Services  Version 2.0
akill.cpp
Go to the documentation of this file.
1 /*
2  * (C) 2003-2014 Anope Team
3  * Contact us at team@anope.org
4  *
5  * Please read COPYING and README for further details.
6  */
7 
8 #include "../../webcpanel.h"
9 
11 {
12 }
13 
15 {
16 
17  static ServiceReference<XLineManager> akills("XLineManager","xlinemanager/sgline");
18 
19  if (!na->nc->o || !na->nc->o->ot->HasCommand("operserv/akill"))
20  {
21  replacements["NOACCESS"];
22  }
23  else
24  {
25  if (akills->GetCount() == 0)
26  replacements["AKILLS"] = "No Akills to display.";
27 
28  if (message.post_data.count("mask") > 0 && message.post_data.count("expiry") > 0 && message.post_data.count("reason") > 0)
29  {
30  std::vector<Anope::string> params;
31  std::stringstream cmdstr;
32  params.push_back("ADD");
33  cmdstr << "+" << HTTPUtils::URLDecode(message.post_data["expiry"]);
34  cmdstr << " " << HTTPUtils::URLDecode(message.post_data["mask"]);
35  cmdstr << " " << HTTPUtils::URLDecode(message.post_data["reason"]);
36  params.push_back(cmdstr.str());
37  WebPanel::RunCommand(na->nc->display, na->nc, "OperServ", "operserv/akill", params, replacements);
38  }
39 
40  if (message.get_data["del"] == "1" && message.get_data.count("number") > 0)
41  {
42  std::vector<Anope::string> params;
43  params.push_back("DEL");
44  params.push_back(HTTPUtils::URLDecode(message.get_data["number"]));
45  WebPanel::RunCommand(na->nc->display, na->nc, "OperServ", "operserv/akill", params, replacements);
46  }
47 
48  for (unsigned i = 0, end = akills->GetCount(); i < end; ++i)
49  {
50  const XLine *x = akills->GetEntry(i);
51  replacements["NUMBER"] = stringify(i + 1);
52  replacements["HOST"] = x->mask;
53  replacements["SETTER"] = x->by;
54  replacements["TIME"] = Anope::strftime(x->created, NULL, true);
55  replacements["EXPIRE"] = Anope::Expires(x->expires, na->nc);
56  replacements["REASON"] = x->reason;
57  }
58  }
59 
60  TemplateFileServer page("operserv/akill.html");
61  page.Serve(server, page_name, client, message, reply, replacements);
62  return true;
63 }
64 
Serialize::Reference< NickCore > nc
Definition: account.h:47
Anope::string reason
Definition: xline.h:29
Anope::string mask
Definition: xline.h:24
void Serve(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, Replacements &)
Akill(const Anope::string &cat, const Anope::string &u)
Definition: akill.cpp:10
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override
Definition: akill.cpp:14
void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, const std::vector< Anope::string > &params, TemplateFileServer::Replacements &r, const Anope::string &key)
Definition: webcpanel.cpp:234
Anope::string by
Definition: xline.h:26
time_t expires
Definition: xline.h:28
static ServiceReference< XLineManager > akills("XLineManager","xlinemanager/sgline")
Anope::string stringify(const T &x)
Definition: anope.h:710
std::map< Anope::string, Anope::string > post_data
Definition: httpd.h:81
Definition: xline.h:18
Anope::string URLDecode(const Anope::string &url)
Definition: httpd.h:163
std::map< Anope::string, Anope::string > get_data
Definition: httpd.h:80
CoreExport Anope::string strftime(time_t t, const NickCore *nc=NULL, bool short_output=false)
Definition: misc.cpp:356
time_t created
Definition: xline.h:27
CoreExport Anope::string Expires(time_t seconds, const NickCore *nc=NULL)
Definition: misc.cpp:371