anope

- supernets anope source code & configuration
git clone git://git.acid.vegas/anope.git
Log | Files | Refs | Archive | README

akill.cpp (2235B)

      1 /*
      2  * (C) 2003-2022 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 
     10 WebCPanel::OperServ::Akill::Akill(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u)
     11 {
     12 }
     13 
     14 bool WebCPanel::OperServ::Akill::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
     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(client, 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(client, 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 }