diff options
author | Adam <Adam@anope.org> | 2014-01-02 11:02:14 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2014-01-02 11:03:33 -0500 |
commit | 004c4cbe5f4c37cf455cb6d0caa434fbbb3406ea (patch) | |
tree | 0e6675dfe28a829f5786b0b2f993566c61662de7 /modules/webcpanel/pages/operserv/akill.cpp | |
parent | 072202c181943901c727782e64881adadf13d7dd (diff) |
Move modules out of extras that dont have external dependencies
Diffstat (limited to 'modules/webcpanel/pages/operserv/akill.cpp')
-rw-r--r-- | modules/webcpanel/pages/operserv/akill.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/modules/webcpanel/pages/operserv/akill.cpp b/modules/webcpanel/pages/operserv/akill.cpp new file mode 100644 index 000000000..24f1dbf63 --- /dev/null +++ b/modules/webcpanel/pages/operserv/akill.cpp @@ -0,0 +1,64 @@ +/* + * (C) 2003-2014 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#include "../../webcpanel.h" + +WebCPanel::OperServ::Akill::Akill(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u) +{ +} + +bool WebCPanel::OperServ::Akill::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) +{ + + static ServiceReference<XLineManager> akills("XLineManager","xlinemanager/sgline"); + + if (!na->nc->IsServicesOper() && !(na->nc->o && na->nc->o->ot && na->nc->o->ot->HasPriv("operserv/akill"))) + { + replacements["NOACCESS"]; + } + else + { + if (akills->GetCount() == 0) + replacements["AKILLS"] = "No Akills to display."; + + if (message.post_data.count("mask") > 0 && message.post_data.count("expiry") > 0 && message.post_data.count("reason") > 0) + { + std::vector<Anope::string> params; + std::stringstream cmdstr; + params.push_back("ADD"); + cmdstr << "+" << HTTPUtils::URLDecode(message.post_data["expiry"]); + cmdstr << " " << HTTPUtils::URLDecode(message.post_data["mask"]); + cmdstr << " " << HTTPUtils::URLDecode(message.post_data["reason"]); + params.push_back(cmdstr.str()); + WebPanel::RunCommand(na->nc->display, na->nc, "OperServ", "operserv/akill", params, replacements); + } + + if (message.get_data["del"] == "1" && message.get_data.count("number") > 0) + { + std::vector<Anope::string> params; + params.push_back("DEL"); + params.push_back(HTTPUtils::URLDecode(message.get_data["number"])); + WebPanel::RunCommand(na->nc->display, na->nc, "OperServ", "operserv/akill", params, replacements); + } + + for (unsigned i = 0, end = akills->GetCount(); i < end; ++i) + { + const XLine *x = akills->GetEntry(i); + replacements["NUMBER"] = stringify(i + 1); + replacements["HOST"] = x->mask; + replacements["SETTER"] = x->by; + replacements["TIME"] = Anope::strftime(x->created, NULL, true); + replacements["EXPIRE"] = Anope::Expires(x->expires, na->nc); + replacements["REASON"] = x->reason; + } + } + + TemplateFileServer page("operserv/akill.html"); + page.Serve(server, page_name, client, message, reply, replacements); + return true; +} + |