Anope IRC Services  Version 2.0
akick.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 #include "utils.h"
10 
12 {
13 }
14 
16 {
17  const Anope::string &chname = message.get_data["channel"];
18  TemplateFileServer Page("chanserv/akick.html");
19 
20  BuildChanList(na, replacements);
21 
22  if (chname.empty())
23  {
24  Page.Serve(server, page_name, client, message, reply, replacements);
25  return true;
26  }
27 
28  ChannelInfo *ci = ChannelInfo::Find(chname);
29 
30  if (!ci)
31  {
32  replacements["MESSAGES"] = "Channel not registered";
33  Page.Serve(server, page_name, client, message, reply, replacements);
34  return true;
35  }
36 
37  AccessGroup u_access = ci->AccessFor(na->nc);
38  bool has_priv = na->nc->IsServicesOper() && na->nc->o->ot->HasPriv("chanserv/access/modify");
39 
40  if (!u_access.HasPriv("AKICK") && !has_priv)
41  {
42  replacements["MESSAGES"] = "Permission denied.";
43  Page.Serve(server, page_name, client, message, reply, replacements);
44  return true;
45  }
46 
47  replacements["AKICK"] = "YES";
48 
49  if (message.get_data["del"].empty() == false && message.get_data["mask"].empty() == false)
50  {
51  std::vector<Anope::string> params;
52  params.push_back(ci->name);
53  params.push_back("DEL");
54  params.push_back(message.get_data["mask"]);
55 
56  WebPanel::RunCommand(na->nc->display, na->nc, "ChanServ", "chanserv/akick", params, replacements);
57  }
58  else if (message.post_data["mask"].empty() == false)
59  {
60  std::vector<Anope::string> params;
61  params.push_back(ci->name);
62  params.push_back("ADD");
63  params.push_back(message.post_data["mask"]);
64  if (message.post_data["reason"].empty() == false)
65  params.push_back(message.post_data["reason"]);
66 
67  WebPanel::RunCommand(na->nc->display, na->nc, "ChanServ", "chanserv/akick", params, replacements);
68  }
69 
70  replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname);
71 
72  for (unsigned i = 0; i < ci->GetAkickCount(); ++i)
73  {
74  AutoKick *akick = ci->GetAkick(i);
75 
76  if (akick->nc)
77  replacements["MASKS"] = HTTPUtils::Escape(akick->nc->display);
78  else
79  replacements["MASKS"] = HTTPUtils::Escape(akick->mask);
80  replacements["CREATORS"] = HTTPUtils::Escape(akick->creator);
81  replacements["REASONS"] = HTTPUtils::Escape(akick->reason);
82  }
83 
84  Page.Serve(server, page_name, client, message, reply, replacements);
85  return true;
86 }
87 
88 std::set<Anope::string> WebCPanel::ChanServ::Akick::GetData()
89 {
90  std::set<Anope::string> v;
91  v.insert("channel");
92  return v;
93 }
94 
Serialize::Reference< NickCore > nc
Definition: account.h:47
void Serve(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, Replacements &)
Definition: hashcomp.h:84
unsigned GetAkickCount() const
Definition: regchannel.cpp:562
Anope::string Escape(const Anope::string &src)
Definition: httpd.h:206
Anope::string name
Definition: regchannel.h:63
void BuildChanList(NickAlias *na, TemplateFileServer::Replacements &replacements)
Definition: utils.cpp:24
Anope::string URLEncode(const Anope::string &url)
Definition: httpd.h:187
std::set< Anope::string > GetData() anope_override
Definition: akick.cpp:88
bool HasPriv(const Anope::string &priv) const
Definition: access.cpp:384
static ChannelInfo * Find(const Anope::string &name)
Definition: regchannel.cpp:630
Anope::string reason
Definition: regchannel.h:35
Akick(const Anope::string &cat, const Anope::string &u)
Definition: akick.cpp:11
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
bool empty() const
Definition: anope.h:126
Anope::string creator
Definition: regchannel.h:36
AutoKick * GetAkick(unsigned index) const
Definition: regchannel.cpp:552
AccessGroup AccessFor(const User *u)
Definition: regchannel.cpp:413
std::map< Anope::string, Anope::string > post_data
Definition: httpd.h:81
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override
Definition: akick.cpp:15
Anope::string mask
Definition: regchannel.h:32
Serialize::Reference< NickCore > nc
Definition: regchannel.h:33
std::map< Anope::string, Anope::string > get_data
Definition: httpd.h:80