diff options
| author | DukePyrolator <DukePyrolator@anope.org> | 2012-10-02 05:36:31 +0200 |
|---|---|---|
| committer | DukePyrolator <DukePyrolator@anope.org> | 2012-10-02 05:36:31 +0200 |
| commit | e1d1d1828842a4b3423181ab4c140e65a7b8bbe8 (patch) | |
| tree | 0bea8a459d8628c1129c2a0ed992a79ea9ed525b /modules/extra/webcpanel/pages | |
| parent | 20a6f827539f0fe5537e83aecc6ed1641bb0acdf (diff) | |
added an operserv/akill page to webcpanel
Diffstat (limited to 'modules/extra/webcpanel/pages')
| -rw-r--r-- | modules/extra/webcpanel/pages/operserv/akill.cpp | 63 | ||||
| -rw-r--r-- | modules/extra/webcpanel/pages/operserv/akill.h | 25 |
2 files changed, 88 insertions, 0 deletions
diff --git a/modules/extra/webcpanel/pages/operserv/akill.cpp b/modules/extra/webcpanel/pages/operserv/akill.cpp new file mode 100644 index 000000000..8a66b8d9b --- /dev/null +++ b/modules/extra/webcpanel/pages/operserv/akill.cpp @@ -0,0 +1,63 @@ +/* + * (C) 2003-2012 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) +{ +} + +void WebCPanel::OperServ::Akill::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) +{ + + static service_reference<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["MESSAGES"] = "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; + 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, Config->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, Config->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"] = do_strftime(x->Created, NULL, true); + replacements["EXPIRE"] = expire_left(na->nc, x->Expires); + replacements["REASON"] = x->Reason; + } + } + + TemplateFileServer page("operserv/akill.html"); + page.Serve(server, page_name, client, message, reply, replacements); +} + diff --git a/modules/extra/webcpanel/pages/operserv/akill.h b/modules/extra/webcpanel/pages/operserv/akill.h new file mode 100644 index 000000000..4b5f8f1dd --- /dev/null +++ b/modules/extra/webcpanel/pages/operserv/akill.h @@ -0,0 +1,25 @@ +/* + * (C) 2003-2012 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +namespace WebCPanel +{ + +namespace OperServ +{ + +class Akill : public WebPanelProtectedPage +{ + public: + Akill(const Anope::string &cat, const Anope::string &u); + + void OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override; +}; + +} + +} + |
