1
0
mirror of https://github.com/anope/anope.git synced 2026-07-03 00:03:13 +02:00

Started work on adding HostServ to the web panel

This commit is contained in:
MatthewM
2012-12-10 23:44:51 -05:00
parent 0edd26467e
commit b356a46789
6 changed files with 107 additions and 2 deletions
+2 -1
View File
@@ -152,7 +152,8 @@ class CommandHSRequest : public Command
HostRequest *req = new HostRequest;
req->nick = u->nick;
//req->nick = u->nick;
req->nick = source.GetNick();
req->ident = user;
req->host = host;
req->time = Anope::CurTime;
@@ -0,0 +1,36 @@
/*
* (C) 2003-2012 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*/
#include "../../webcpanel.h"
WebCPanel::HostServ::Request::Request(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage (cat, u)
{
}
bool WebCPanel::HostServ::Request::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
{
if (message.post_data.count("req") > 0)
{
std::vector<Anope::string> params;
std::stringstream cmdstr;
cmdstr << HTTPUtils::URLDecode(message.post_data["req"]);
params.push_back(cmdstr.str());
WebPanel::RunCommand(na->nc->display, na->nc, Config->HostServ, "hostserv/request", params, replacements);
}
if (na->HasVhost())
{
if (na->GetVhostIdent().empty() == false)
replacements["VHOST"] = na->GetVhostIdent() + "@" + na->GetVhostHost();
else
replacements["VHOST"] = na->GetVhostHost();
}
TemplateFileServer page("hostserv/request.html");
page.Serve(server, page_name, client, message, reply, replacements);
return true;
}
@@ -0,0 +1,24 @@
/*
* (C) 2003-2012 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*/
namespace WebCPanel
{
namespace HostServ
{
class Request : public WebPanelProtectedPage
{
public:
Request(const Anope::string &cat, const Anope::string &u);
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
};
}
}
@@ -0,0 +1,23 @@
{INCLUDE header.html}
{FOR M IN MESSAGES}
{M}<br/>
{END FOR}
<table width="100%" height="100%">
<tr>
<td>Your <b>current</b> vHost</td>
{IF EXISTS VHOST}
<td>{VHOST}</td>
{ELSE}
<td><b>None</td>
{END IF}
</table>
{IF EXISTS VHOST}
<b>Request a new vHost</b>
{ELSE}
<b>Request a vHost</b>
{END IF}
<form method="post" action="/hostserv/request">
<input name="req">
<input type="submit" value="Request">
</form>
{INCLUDE footer.html}
+20 -1
View File
@@ -34,8 +34,11 @@ class ModuleWebCPanel : public Module
WebCPanel::MemoServ::Memos memoserv_memos;
WebCPanel::HostServ::Request hostserv_request;
WebCPanel::OperServ::Akill operserv_akill;
public:
ModuleWebCPanel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED),
panel(this, "webcpanel"),
@@ -43,7 +46,7 @@ class ModuleWebCPanel : public Module
index("/"), logout("/logout"), _register("/register"), confirm("/confirm"),
nickserv_info(Config->NickServ, "/nickserv/info"), nickserv_cert(Config->NickServ, "/nickserv/cert"), nickserv_access(Config->NickServ, "/nickserv/access"), nickserv_alist(Config->NickServ, "/nickserv/alist"),
chanserv_info(Config->ChanServ, "/chanserv/info"), chanserv_set(Config->ChanServ, "/chanserv/set"), chanserv_access(Config->ChanServ, "/chanserv/access"), chanserv_akick(Config->ChanServ, "/chanserv/akick"),
memoserv_memos(Config->MemoServ, "/memoserv/memos"), operserv_akill(Config->OperServ, "/operserv/akill")
memoserv_memos(Config->MemoServ, "/memoserv/memos"), hostserv_request(Config->HostServ, "/hostserv/request"), operserv_akill(Config->OperServ, "/operserv/akill")
{
this->SetAuthor("Anope");
@@ -142,6 +145,20 @@ class ModuleWebCPanel : public Module
panel.sections.push_back(s);
}
if (IRCD || IRCD->CanSetVHost)
{
if (Config->HostServ.empty() == false)
{
Section s;
s.name = Config->HostServ;
SubSection ss;
ss.name = "Request";
ss.url = "/hostserv/request";
s.subsections.push_back(ss);
provider->RegisterPage(&this->hostserv_request);
}
}
if (Config->OperServ.empty() == false)
{
@@ -183,6 +200,8 @@ class ModuleWebCPanel : public Module
provider->UnregisterPage(&this->chanserv_akick);
provider->UnregisterPage(&this->memoserv_memos);
provider->UnregisterPage(&this->hostserv_request);
}
}
};
+2
View File
@@ -165,4 +165,6 @@ namespace WebPanel
#include "pages/memoserv/memos.h"
#include "pages/hostserv/request.h"
#include "pages/operserv/akill.h"