Anope IRC Services

Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: webpanel extra pages  (Read 3588 times)

0 Members and 1 Guest are viewing this topic.

john

  • Anope User
  • Offline Offline
  • Posts: 1
webpanel extra pages
« on: July 23, 2020, 04:32:56 PM »

hi.
so i was trying today on a virtual machine anope and saw the webpanel which is a nice feature to have.
i set a a couple of registered nicks and wanted to add some vhosts to them. on irc i just have to view the request and activate them or not.
went to the webpanel to see if i have these options and the only active one was the request option. upon reading a little and poking here and there i see i have to modify webpanel.cpp and .h file, add a page template for the feature and files for it. now i have this:

in webpanel.cpp i have
Code: [Select]
WebCPanel::HostServ::Request hostserv_request;   (this was here already)
WebCPanel::HostServ::Waiting hostserv_waiting;    (new)

and added this with the opter options a little lower:   hostserv_waiting("HostServ", "/hostserv/waiting"),

in webpanel.h i have
Code: [Select]
#include "pages/hostserv/request.h"  (this was here already)
#include "pages/hostserv/waiting.h"  (new)
next is the template, i added waiting.html with
Code: [Select]
{INCLUDE header.html}
<div class="panel-heading">vHost Information</div>
<div class="panel-body">
{FOR M IN MESSAGES}
<div class="alert alert-info">
{M}<br>
</div>
{END FOR}

<table id="tableInfo" class="table table-hover">
<tbody>
<tr>
<td>Your current vHost:</td>
<td>
{IF EXISTS VHOST}
{VHOST}
{ELSE}
<em>None</em>
{END IF}
</td>
<td></td>
</tr>
{IF EXISTS CAN_REQUEST}
<tr>
<td>
{IF EXISTS VHOST}
View waiting vHost/s
{ELSE}
No vHost/s wainting approval
{END IF}
</td>
<form method="post" action="/hostserv/waiting">
<td><input class="form-control" name="req"></td>
<td><button type="submit" class="btn btn-primary">View</button></td>
</form>
</tr>
{ELSE}
<tr>
<td colspan="2" class="text-center"><strong>vHost requests are disabled on this network.</strong></td>
</tr>
{END IF}
</tbody>
</table>
</div>
{INCLUDE footer.html}


yes, it's the same with the request template.

and the other 2 files:
waiting.cpp
Code: [Select]
/*
 * (C) 2003-2019 Anope Team
 * Contact us at team@anope.org
 *
 * Please read COPYING and README for further details.
 */

#include "../../webcpanel.h"

WebCPanel::HostServ::Waiting::Waiting(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage (cat, u)
{
}

bool WebCPanel::HostServ::Waiting::OnWaiting(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;
params.push_back(HTTPUtils::URLDecode(message.post_data["req"]));

WebPanel::RunCommand(client, na->nc->display, na->nc, "HostServ", "hostserv/Waiting", params, replacements, "CMDR");
}

if (na->HasVhost())
{
if (na->GetVhostIdent().empty() == false)
replacements["VHOST"] = na->GetVhostIdent() + "@" + na->GetVhostHost();
else
replacements["VHOST"] = na->GetVhostHost();
}
if (ServiceReference<Command>("Command", "hostserv/Waiting"))
replacements["CAN_Waiting"] = "YES";
TemplateFileServer page("hostserv/Waiting.html");
page.Serve(server, page_name, client, message, reply, replacements);
return true;
}

and waiting.h
Code: [Select]
/*
 * (C) 2003-2019 Anope Team
 * Contact us at team@anope.org
 *
 * Please read COPYING and README for further details.
 */

namespace WebCPanel
{

namespace HostServ
{

class Waiting : public WebPanelProtectedPage
{
 public:
  Waiting(const Anope::string &cat, const Anope::string &u);

bool OnWaiting(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
};

}

}

i know i basically copy/pasted them. i do this by trial and error.
it gives me and error on compiling. i know the template needs modification, but since there is no documentation if you want to add new pages, nu sure what to do.
i was wondering what i did wrong and if anyone has an idea how to make it work.


Logged
Pages: [1]   Go Up