summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-12-12 01:30:50 -0500
committerAdam <Adam@anope.org>2012-12-12 01:30:50 -0500
commit04f96a54b8387c1362e6695a13dd0dd71ce0a347 (patch)
tree34174d64dbb161654252807fead2f82751cc00a0 /modules
parent5f72d1fda5e297990aee7e0be805df0a734ca87d (diff)
Some small improvements to last few commits, and fixed some problems with the template engine
Diffstat (limited to 'modules')
-rw-r--r--modules/extra/webcpanel/pages/hostserv/request.cpp6
-rw-r--r--modules/extra/webcpanel/template_fileserver.cpp11
-rw-r--r--modules/extra/webcpanel/templates/default/hostserv/request.html26
3 files changed, 27 insertions, 16 deletions
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<Anope::string> 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>("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}
<table width="100%" height="100%">
<tr>
- <td>Your <b>current</b> vHost</td>
+ <td>Your <b>current</b> vHost:
{IF EXISTS VHOST}
- <td>{VHOST}</td>
+ {VHOST}
{ELSE}
- <td><b>None</td>
+ <b>None</b>
{END IF}
+ </td>
+ </tr>
</table>
- {IF EXISTS VHOST}
- <b>Request a new vHost</b>
+ {IF EXISTS CAN_REQUEST}
+ {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>
{ELSE}
- <b>Request a vHost</b>
+ vHost requests are disabled on this network.
{END IF}
- <form method="post" action="/hostserv/request">
- <input name="req">
- <input type="submit" value="Request">
- </form>
{INCLUDE footer.html}