From 04f96a54b8387c1362e6695a13dd0dd71ce0a347 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 12 Dec 2012 01:30:50 -0500 Subject: Some small improvements to last few commits, and fixed some problems with the template engine --- modules/extra/webcpanel/pages/hostserv/request.cpp | 6 ++--- modules/extra/webcpanel/template_fileserver.cpp | 11 ++++++--- .../templates/default/hostserv/request.html | 26 +++++++++++++--------- 3 files changed, 27 insertions(+), 16 deletions(-) (limited to 'modules') diff --git a/modules/extra/webcpanel/pages/hostserv/request.cpp b/modules/extra/webcpanel/pages/hostserv/request.cpp index aad933c3a..20b4f5740 100644 --- a/modules/extra/webcpanel/pages/hostserv/request.cpp +++ b/modules/extra/webcpanel/pages/hostserv/request.cpp @@ -16,10 +16,8 @@ bool WebCPanel::HostServ::Request::OnRequest(HTTPProvider *server, const Anope:: if (message.post_data.count("req") > 0) { std::vector params; - std::stringstream cmdstr; + params.push_back(HTTPUtils::URLDecode(message.post_data["req"])); - 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); } @@ -30,6 +28,8 @@ bool WebCPanel::HostServ::Request::OnRequest(HTTPProvider *server, const Anope:: else replacements["VHOST"] = na->GetVhostHost(); } + if (ServiceReference("Command", "hostserv/request")) + replacements["CAN_REQUEST"] = "YES"; TemplateFileServer page("hostserv/request.html"); page.Serve(server, page_name, client, message, reply, replacements); return true; diff --git a/modules/extra/webcpanel/template_fileserver.cpp b/modules/extra/webcpanel/template_fileserver.cpp index cf7094e39..ca2ff034f 100644 --- a/modules/extra/webcpanel/template_fileserver.cpp +++ b/modules/extra/webcpanel/template_fileserver.cpp @@ -137,10 +137,14 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n if (second.empty()) second = tokens[3]; - IfStack.push(first == second); + bool stackok = IfStack.empty() || IfStack.top(); + IfStack.push(stackok && first == second); } else if (tokens.size() == 3 && tokens[1] == "EXISTS") - IfStack.push(r.count(tokens[2]) > 0); + { + bool stackok = IfStack.empty() || IfStack.top(); + IfStack.push(stackok && r.count(tokens[2]) > 0); + } else Log() << "Invalid IF in web template " << this->file_name; } @@ -152,7 +156,8 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n { bool old = IfStack.top(); IfStack.pop(); // Pop off previous if() - IfStack.push(!old); // Push back the opposite of what was popped + bool stackok = IfStack.empty() || IfStack.top(); + IfStack.push(stackok && !old); // Push back the opposite of what was popped } } else if (content == "END IF") diff --git a/modules/extra/webcpanel/templates/default/hostserv/request.html b/modules/extra/webcpanel/templates/default/hostserv/request.html index ced414242..158bed28f 100644 --- a/modules/extra/webcpanel/templates/default/hostserv/request.html +++ b/modules/extra/webcpanel/templates/default/hostserv/request.html @@ -4,20 +4,26 @@ {END FOR} - + + {VHOST} {ELSE} - + None {END IF} + +
Your current vHostYour current vHost: {IF EXISTS VHOST} - {VHOST}None
- {IF EXISTS VHOST} - Request a new vHost + {IF EXISTS CAN_REQUEST} + {IF EXISTS VHOST} + Request a new vHost + {ELSE} + Request a vHost + {END IF} +
+ + +
{ELSE} - Request a vHost + vHost requests are disabled on this network. {END IF} -
- - -
{INCLUDE footer.html} -- cgit