summaryrefslogtreecommitdiff
path: root/modules/webcpanel/pages
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-01-02 11:02:14 -0500
committerAdam <Adam@anope.org>2014-01-02 11:03:33 -0500
commit004c4cbe5f4c37cf455cb6d0caa434fbbb3406ea (patch)
tree0e6675dfe28a829f5786b0b2f993566c61662de7 /modules/webcpanel/pages
parent072202c181943901c727782e64881adadf13d7dd (diff)
Move modules out of extras that dont have external dependencies
Diffstat (limited to 'modules/webcpanel/pages')
-rw-r--r--modules/webcpanel/pages/chanserv/access.cpp162
-rw-r--r--modules/webcpanel/pages/chanserv/access.h27
-rw-r--r--modules/webcpanel/pages/chanserv/akick.cpp94
-rw-r--r--modules/webcpanel/pages/chanserv/akick.h27
-rw-r--r--modules/webcpanel/pages/chanserv/drop.cpp58
-rw-r--r--modules/webcpanel/pages/chanserv/drop.h25
-rw-r--r--modules/webcpanel/pages/chanserv/info.cpp28
-rw-r--r--modules/webcpanel/pages/chanserv/info.h25
-rw-r--r--modules/webcpanel/pages/chanserv/modes.cpp108
-rw-r--r--modules/webcpanel/pages/chanserv/modes.h27
-rw-r--r--modules/webcpanel/pages/chanserv/set.cpp155
-rw-r--r--modules/webcpanel/pages/chanserv/set.h27
-rw-r--r--modules/webcpanel/pages/chanserv/utils.cpp45
-rw-r--r--modules/webcpanel/pages/chanserv/utils.h19
-rw-r--r--modules/webcpanel/pages/confirm.cpp32
-rw-r--r--modules/webcpanel/pages/confirm.h22
-rw-r--r--modules/webcpanel/pages/hostserv/request.cpp36
-rw-r--r--modules/webcpanel/pages/hostserv/request.h24
-rw-r--r--modules/webcpanel/pages/index.cpp99
-rw-r--r--modules/webcpanel/pages/index.h22
-rw-r--r--modules/webcpanel/pages/logout.cpp23
-rw-r--r--modules/webcpanel/pages/logout.h20
-rw-r--r--modules/webcpanel/pages/memoserv/memos.cpp115
-rw-r--r--modules/webcpanel/pages/memoserv/memos.h25
-rw-r--r--modules/webcpanel/pages/nickserv/access.cpp40
-rw-r--r--modules/webcpanel/pages/nickserv/access.h25
-rw-r--r--modules/webcpanel/pages/nickserv/alist.cpp59
-rw-r--r--modules/webcpanel/pages/nickserv/alist.h25
-rw-r--r--modules/webcpanel/pages/nickserv/cert.cpp43
-rw-r--r--modules/webcpanel/pages/nickserv/cert.h25
-rw-r--r--modules/webcpanel/pages/nickserv/info.cpp118
-rw-r--r--modules/webcpanel/pages/nickserv/info.h25
-rw-r--r--modules/webcpanel/pages/operserv/akill.cpp64
-rw-r--r--modules/webcpanel/pages/operserv/akill.h25
-rw-r--r--modules/webcpanel/pages/register.cpp24
-rw-r--r--modules/webcpanel/pages/register.h22
36 files changed, 1740 insertions, 0 deletions
diff --git a/modules/webcpanel/pages/chanserv/access.cpp b/modules/webcpanel/pages/chanserv/access.cpp
new file mode 100644
index 000000000..d87613ed7
--- /dev/null
+++ b/modules/webcpanel/pages/chanserv/access.cpp
@@ -0,0 +1,162 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../../webcpanel.h"
+#include "utils.h"
+
+WebCPanel::ChanServ::Access::Access(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u)
+{
+}
+
+bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
+{
+ TemplateFileServer Page("chanserv/access.html");
+ const Anope::string &chname = message.get_data["channel"];
+
+ BuildChanList(na, replacements);
+
+ if (chname.empty())
+ {
+ Page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+ }
+
+ ChannelInfo *ci = ChannelInfo::Find(chname);
+
+ if (!ci)
+ {
+ replacements["MESSAGES"] = "Channel not registered.";
+ Page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+ }
+
+ AccessGroup u_access = ci->AccessFor(na->nc);
+ bool has_priv = na->nc->IsServicesOper() && na->nc->o->ot->HasPriv("chanserv/access/modify");
+
+ if (!u_access.HasPriv("ACCESS_LIST") && !has_priv)
+ {
+ replacements["MESSAGES"] = "Access denied.";
+ Page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+ }
+
+ replacements["ACCESS_LIST"] = "YES";
+
+ const ChanAccess *highest = u_access.Highest();
+
+ if (u_access.HasPriv("ACCESS_CHANGE") || has_priv)
+ {
+ if (message.get_data["del"].empty() == false && message.get_data["mask"].empty() == false)
+ {
+ std::vector<Anope::string> params;
+ params.push_back(ci->name);
+ params.push_back("DEL");
+ params.push_back(message.get_data["mask"]);
+
+ WebPanel::RunCommand(na->nc->display, na->nc, "ChanServ", "chanserv/access", params, replacements);
+ }
+ else if (message.post_data["mask"].empty() == false && message.post_data["access"].empty() == false && message.post_data["provider"].empty() == false)
+ {
+ // Generic access add code here, works with any provider (so we can't call a command exactly)
+ AccessProvider *a = NULL;
+ for (std::list<AccessProvider *>::const_iterator it = AccessProvider::GetProviders().begin(); it != AccessProvider::GetProviders().end(); ++it)
+ if ((*it)->name == message.post_data["provider"])
+ a = *it;
+
+ if (a)
+ {
+ bool denied = false;
+
+ for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i)
+ {
+ ChanAccess *acc = ci->GetAccess(i);
+
+ if (acc->mask == message.post_data["mask"])
+ {
+ if ((!highest || *acc >= *highest) && !u_access.founder && !has_priv)
+ {
+ replacements["MESSAGES"] = "Access denied";
+ denied = true;
+ }
+ else
+ delete acc;
+ break;
+ }
+ }
+
+
+ unsigned access_max = Config->GetModule("chanserv")->Get<unsigned>("accessmax", "1024");
+ if (access_max && ci->GetAccessCount() >= access_max)
+ replacements["MESSAGES"] = "Sorry, you can only have " + stringify(access_max) + " access entries on a channel.";
+ else if (!denied)
+ {
+ ChanAccess *new_acc = a->Create();
+ new_acc->ci = ci;
+ new_acc->mask = message.post_data["mask"];
+ new_acc->creator = na->nc->display;
+ try
+ {
+ new_acc->AccessUnserialize(message.post_data["access"]);
+ }
+ catch (...)
+ {
+ replacements["MESSAGES"] = "Invalid access expression for the given type";
+ delete new_acc;
+ new_acc = NULL;
+ }
+ if (new_acc)
+ {
+ new_acc->last_seen = 0;
+ new_acc->created = Anope::CurTime;
+
+ if ((!highest || *highest <= *new_acc) && !u_access.founder && !has_priv)
+ delete new_acc;
+ else if (new_acc->AccessSerialize().empty())
+ {
+ replacements["MESSAGES"] = "Invalid access expression for the given type";
+ delete new_acc;
+ }
+ else
+ {
+ ci->AddAccess(new_acc);
+ replacements["MESSAGES"] = "Access for " + new_acc->mask + " set to " + new_acc->AccessSerialize();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname);
+ replacements["ACCESS_CHANGE"] = u_access.HasPriv("ACCESS_CHANGE") ? "YES" : "NO";
+
+ for (unsigned i = 0; i < ci->GetAccessCount(); ++i)
+ {
+ ChanAccess *access = ci->GetAccess(i);
+
+ replacements["MASKS"] = HTTPUtils::Escape(access->mask);
+ replacements["ACCESSES"] = HTTPUtils::Escape(access->AccessSerialize());
+ replacements["CREATORS"] = HTTPUtils::Escape(access->creator);
+ }
+
+ for (std::list<AccessProvider *>::const_iterator it = AccessProvider::GetProviders().begin(); it != AccessProvider::GetProviders().end(); ++it)
+ {
+ const AccessProvider *a = *it;
+ replacements["PROVIDERS"] = a->name;
+ }
+
+ Page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+}
+
+std::set<Anope::string> WebCPanel::ChanServ::Access::GetData()
+{
+ std::set<Anope::string> v;
+ v.insert("channel");
+ return v;
+}
+
diff --git a/modules/webcpanel/pages/chanserv/access.h b/modules/webcpanel/pages/chanserv/access.h
new file mode 100644
index 000000000..7f81f2d39
--- /dev/null
+++ b/modules/webcpanel/pages/chanserv/access.h
@@ -0,0 +1,27 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+namespace WebCPanel
+{
+
+namespace ChanServ
+{
+
+class Access : public WebPanelProtectedPage
+{
+ public:
+ Access(const Anope::string &cat, const Anope::string &u);
+
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+
+ std::set<Anope::string> GetData() anope_override;
+};
+
+}
+
+}
+
diff --git a/modules/webcpanel/pages/chanserv/akick.cpp b/modules/webcpanel/pages/chanserv/akick.cpp
new file mode 100644
index 000000000..bff38910c
--- /dev/null
+++ b/modules/webcpanel/pages/chanserv/akick.cpp
@@ -0,0 +1,94 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../../webcpanel.h"
+#include "utils.h"
+
+WebCPanel::ChanServ::Akick::Akick(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u)
+{
+}
+
+bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
+{
+ const Anope::string &chname = message.get_data["channel"];
+ TemplateFileServer Page("chanserv/akick.html");
+
+ BuildChanList(na, replacements);
+
+ if (chname.empty())
+ {
+ Page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+ }
+
+ ChannelInfo *ci = ChannelInfo::Find(chname);
+
+ if (!ci)
+ {
+ replacements["MESSAGES"] = "Channel not registered";
+ Page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+ }
+
+ AccessGroup u_access = ci->AccessFor(na->nc);
+ bool has_priv = na->nc->IsServicesOper() && na->nc->o->ot->HasPriv("chanserv/access/modify");
+
+ if (!u_access.HasPriv("AKICK") && !has_priv)
+ {
+ replacements["MESSAGES"] = "Permission denied.";
+ Page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+ }
+
+ replacements["AKICK"] = "YES";
+
+ if (message.get_data["del"].empty() == false && message.get_data["mask"].empty() == false)
+ {
+ std::vector<Anope::string> params;
+ params.push_back(ci->name);
+ params.push_back("DEL");
+ params.push_back(message.get_data["mask"]);
+
+ WebPanel::RunCommand(na->nc->display, na->nc, "ChanServ", "chanserv/akick", params, replacements);
+ }
+ else if (message.post_data["mask"].empty() == false)
+ {
+ std::vector<Anope::string> params;
+ params.push_back(ci->name);
+ params.push_back("ADD");
+ params.push_back(message.post_data["mask"]);
+ if (message.post_data["reason"].empty() == false)
+ params.push_back(message.post_data["reason"]);
+
+ WebPanel::RunCommand(na->nc->display, na->nc, "ChanServ", "chanserv/akick", params, replacements);
+ }
+
+ replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname);
+
+ for (unsigned i = 0; i < ci->GetAkickCount(); ++i)
+ {
+ AutoKick *akick = ci->GetAkick(i);
+
+ if (akick->nc)
+ replacements["MASKS"] = HTTPUtils::Escape(akick->nc->display);
+ else
+ replacements["MASKS"] = HTTPUtils::Escape(akick->mask);
+ replacements["CREATORS"] = HTTPUtils::Escape(akick->creator);
+ replacements["REASONS"] = HTTPUtils::Escape(akick->reason);
+ }
+
+ Page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+}
+
+std::set<Anope::string> WebCPanel::ChanServ::Akick::GetData()
+{
+ std::set<Anope::string> v;
+ v.insert("channel");
+ return v;
+}
+
diff --git a/modules/webcpanel/pages/chanserv/akick.h b/modules/webcpanel/pages/chanserv/akick.h
new file mode 100644
index 000000000..bd5b18132
--- /dev/null
+++ b/modules/webcpanel/pages/chanserv/akick.h
@@ -0,0 +1,27 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+namespace WebCPanel
+{
+
+namespace ChanServ
+{
+
+class Akick : public WebPanelProtectedPage
+{
+ public:
+ Akick(const Anope::string &cat, const Anope::string &u);
+
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+
+ std::set<Anope::string> GetData() anope_override;
+};
+
+}
+
+}
+
diff --git a/modules/webcpanel/pages/chanserv/drop.cpp b/modules/webcpanel/pages/chanserv/drop.cpp
new file mode 100644
index 000000000..5fa37b5a2
--- /dev/null
+++ b/modules/webcpanel/pages/chanserv/drop.cpp
@@ -0,0 +1,58 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../../webcpanel.h"
+#include "utils.h"
+
+WebCPanel::ChanServ::Drop::Drop(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage (cat, u)
+{
+}
+
+
+bool WebCPanel::ChanServ::Drop::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
+{
+
+ if (message.post_data.count("channel") > 0 && message.post_data.count("confChan") > 0)
+ {
+ if (message.post_data["channel"] == message.post_data["confChan"])
+ {
+ std::vector<Anope::string> params;
+ const Anope::string &channel = HTTPUtils::URLDecode(message.post_data["channel"]);
+ params.push_back(channel);
+ params.push_back(channel);
+
+ WebPanel::RunCommand(na->nc->display, na->nc, "ChanServ", "chanserv/drop", params, replacements);
+ }
+ else
+ replacements["MESSAGES"] = "Invalid Confirmation";
+ }
+
+ std::deque<ChannelInfo *> queue;
+ na->nc->GetChannelReferences(queue);
+ for (unsigned i = 0; i < queue.size(); ++i)
+ {
+ ChannelInfo *ci = queue[i];
+ if ((ci->HasExt("SECUREFOUNDER") ? ci->AccessFor(na->nc).founder : ci->AccessFor(na->nc).HasPriv("FOUNDER")) || (na->nc->IsServicesOper() && na->nc->o->ot->HasCommand("chanserv/drop")))
+ {
+ replacements["CHANNEL_NAMES"] = ci->name;
+ replacements["ESCAPED_CHANNEL_NAMES"] = HTTPUtils::URLEncode(ci->name);
+ }
+ }
+
+ if (message.get_data.count("channel") > 0)
+ {
+ const Anope::string &chname = message.get_data["channel"];
+
+ replacements["CHANNEL_DROP"] = chname;
+ replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname);
+ }
+
+ TemplateFileServer page("chanserv/drop.html");
+ page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+
+}
diff --git a/modules/webcpanel/pages/chanserv/drop.h b/modules/webcpanel/pages/chanserv/drop.h
new file mode 100644
index 000000000..d418ade8f
--- /dev/null
+++ b/modules/webcpanel/pages/chanserv/drop.h
@@ -0,0 +1,25 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+namespace WebCPanel
+{
+
+ namespace ChanServ
+ {
+
+ class Drop : public WebPanelProtectedPage
+ {
+ public:
+ Drop(const Anope::string &cat, const Anope::string &u);
+
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+
+ };
+
+ }
+
+}
diff --git a/modules/webcpanel/pages/chanserv/info.cpp b/modules/webcpanel/pages/chanserv/info.cpp
new file mode 100644
index 000000000..c16c3eaec
--- /dev/null
+++ b/modules/webcpanel/pages/chanserv/info.cpp
@@ -0,0 +1,28 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../../webcpanel.h"
+#include "utils.h"
+
+WebCPanel::ChanServ::Info::Info(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u)
+{
+}
+
+bool WebCPanel::ChanServ::Info::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
+{
+ const Anope::string &chname = message.get_data["channel"];
+
+ if (!chname.empty())
+ replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname);
+
+ BuildChanList(na, replacements);
+
+ TemplateFileServer page("chanserv/main.html");
+ page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+}
+
diff --git a/modules/webcpanel/pages/chanserv/info.h b/modules/webcpanel/pages/chanserv/info.h
new file mode 100644
index 000000000..4302264d6
--- /dev/null
+++ b/modules/webcpanel/pages/chanserv/info.h
@@ -0,0 +1,25 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+namespace WebCPanel
+{
+
+namespace ChanServ
+{
+
+class Info : public WebPanelProtectedPage
+{
+ public:
+ Info(const Anope::string &cat, const Anope::string &u);
+
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+};
+
+}
+
+}
+
diff --git a/modules/webcpanel/pages/chanserv/modes.cpp b/modules/webcpanel/pages/chanserv/modes.cpp
new file mode 100644
index 000000000..e3e93dd03
--- /dev/null
+++ b/modules/webcpanel/pages/chanserv/modes.cpp
@@ -0,0 +1,108 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../../webcpanel.h"
+#include "utils.h"
+
+WebCPanel::ChanServ::Modes::Modes(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u)
+{
+}
+
+bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
+{
+ const Anope::string &chname = message.get_data["channel"];
+ const Anope::string &mode = message.get_data["m"];
+ TemplateFileServer Page("chanserv/modes.html");
+
+ BuildChanList(na, replacements);
+
+ if (chname.empty())
+ {
+ Page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+ }
+
+ ChannelInfo *ci = ChannelInfo::Find(chname);
+
+ if (!ci)
+ {
+ Page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+ }
+
+ Channel *c = Channel::Find(chname);
+
+ if (!c)
+ {
+ replacements["MESSAGES"] = Anope::printf(CHAN_X_NOT_IN_USE, chname.c_str());
+ Page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+ }
+
+ AccessGroup u_access = ci->AccessFor(na->nc);
+ bool has_priv = na->nc->IsServicesOper() && na->nc->o->ot->HasPriv("chanserv/administration");
+
+ if (!u_access.HasPriv("MODE") && !has_priv)
+ {
+ replacements["MESSAGES"] = "Access denied.";
+ Page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+ }
+
+ replacements["MODE"] = "YES";
+
+ /* build a list with the names of all listmodes */
+ for (std::vector<ChannelMode *>::const_iterator it = ModeManager::GetChannelModes().begin(); it != ModeManager::GetChannelModes().end(); ++it)
+ {
+ /* "NAMEBASE" is a special mode from InspIRCds m_namedmodes, we dont want this here*/
+ if ((*it) && (*it)->type == MODE_LIST && (*it)->name != "NAMEBASE")
+ replacements["LISTMODES"] = (*it)->mchar;
+ }
+
+ ChannelMode *cm = ModeManager::FindChannelModeByName(mode);
+ if (cm)
+ {
+ if (message.get_data["del"].empty() == false && message.get_data["mask"].empty() == false)
+ {
+ std::vector<Anope::string> params;
+ params.push_back(ci->name);
+ params.push_back("SET");
+ params.push_back("-" + Anope::string(cm->mchar));
+ params.push_back(message.get_data["mask"]);
+ WebPanel::RunCommand(na->nc->display, na->nc, "ChanServ", "chanserv/mode", params, replacements);
+ }
+ else if (message.post_data["mask"].empty() == false)
+ {
+ std::vector<Anope::string> params;
+ params.push_back(ci->name);
+ params.push_back("SET");
+ params.push_back("+" + Anope::string(cm->mchar));
+ params.push_back(message.post_data["mask"]);
+ WebPanel::RunCommand(na->nc->display, na->nc, "ChanServ", "chanserv/mode", params, replacements);
+ }
+
+ for (Channel::ModeList::const_iterator it = c->GetModes().begin(); it != c->GetModes().end(); ++it)
+ {
+ if (it->first == mode)
+ replacements["MASKS"] = HTTPUtils::Escape(it->second);
+ }
+ }
+
+ replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname);
+ replacements["ESCAPED_MODE"] = HTTPUtils::URLEncode(mode);
+
+ Page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+}
+
+std::set<Anope::string> WebCPanel::ChanServ::Modes::GetData()
+{
+ std::set<Anope::string> v;
+ v.insert("channel");
+ return v;
+}
+
diff --git a/modules/webcpanel/pages/chanserv/modes.h b/modules/webcpanel/pages/chanserv/modes.h
new file mode 100644
index 000000000..36f5a1d27
--- /dev/null
+++ b/modules/webcpanel/pages/chanserv/modes.h
@@ -0,0 +1,27 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+namespace WebCPanel
+{
+
+namespace ChanServ
+{
+
+class Modes : public WebPanelProtectedPage
+{
+ public:
+ Modes(const Anope::string &cat, const Anope::string &u);
+
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+
+ std::set<Anope::string> GetData() anope_override;
+};
+
+}
+
+}
+
diff --git a/modules/webcpanel/pages/chanserv/set.cpp b/modules/webcpanel/pages/chanserv/set.cpp
new file mode 100644
index 000000000..f763ba13b
--- /dev/null
+++ b/modules/webcpanel/pages/chanserv/set.cpp
@@ -0,0 +1,155 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../../webcpanel.h"
+#include "utils.h"
+
+WebCPanel::ChanServ::Set::Set(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u)
+{
+}
+
+bool WebCPanel::ChanServ::Set::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
+{
+ const Anope::string &chname = message.get_data["channel"];
+ bool can_set = false;
+ TemplateFileServer page("chanserv/set.html");
+
+ BuildChanList(na, replacements);
+
+ if (chname.empty())
+ {
+ page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+ }
+
+ ChannelInfo *ci = ChannelInfo::Find(chname);
+
+ if (!ci)
+ {
+ page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+ }
+
+ replacements["OKAY"];
+
+ if (ci->AccessFor(na->nc).HasPriv("SET"))
+ {
+ replacements["CAN_SET"];
+ can_set = true;
+ }
+
+ if (can_set && message.post_data.empty() == false)
+ {
+ if (ci->HasExt("KEEPTOPIC") != message.post_data.count("keeptopic"))
+ {
+ if (!ci->HasExt("KEEPTOPIC"))
+ ci->Extend<bool>("KEEPTOPIC");
+ else
+ ci->Shrink<bool>("KEEPTOPIC");
+ replacements["MESSAGES"] = "Secure updated";
+ }
+ if (ci->HasExt("PEACE") != message.post_data.count("peace"))
+ {
+ if (!ci->HasExt("PEACE"))
+ ci->Extend<bool>("PEACE");
+ else
+ ci->Shrink<bool>("PEACE");
+ replacements["MESSAGES"] = "Peace updated";
+ }
+ if (ci->HasExt("CS_PRIVATE") != message.post_data.count("private"))
+ {
+ if (!ci->HasExt("CS_PRIVATE"))
+ ci->Extend<bool>("CS_PRIVATE");
+ else
+ ci->Shrink<bool>("CS_PRIVATE");
+ replacements["MESSAGES"] = "Private updated";
+ }
+ if (ci->HasExt("RESTRICTED") != message.post_data.count("restricted"))
+ {
+ if (!ci->HasExt("RESTRICTED"))
+ ci->Extend<bool>("RESTRICTED");
+ else
+ ci->Shrink<bool>("RESTRICTED");
+ replacements["MESSAGES"] = "Restricted updated";
+ }
+ if (ci->HasExt("CS_SECURE") != message.post_data.count("secure"))
+ {
+ if (!ci->HasExt("CS_SECURE"))
+ ci->Extend<bool>("CS_SECURE");
+ else
+ ci->Shrink<bool>("CS_SECURE");
+ replacements["MESSAGES"] = "Secure updated";
+ }
+ if (ci->HasExt("SECUREOPS") != message.post_data.count("secureops"))
+ {
+ if (!ci->HasExt("SECUREOPS"))
+ ci->Extend<bool>("SECUREOPS");
+ else
+ ci->Shrink<bool>("SECUREOPS");
+ replacements["MESSAGES"] = "Secureops updated";
+ }
+ if (ci->HasExt("TOPICLOCK") != message.post_data.count("topiclock"))
+ {
+ if (!ci->HasExt("TOPICLOCK"))
+ ci->Extend<bool>("TOPICLOCK");
+ else
+ ci->Shrink<bool>("TOPICLOCK");
+ replacements["MESSAGES"] = "Topiclock updated";
+ }
+ }
+
+ replacements["CHANNEL"] = HTTPUtils::Escape(ci->name);
+ replacements["CHANNEL_ESCAPED"] = HTTPUtils::URLEncode(ci->name);
+ if (ci->GetFounder())
+ replacements["FOUNDER"] = ci->GetFounder()->display;
+ if (ci->GetSuccessor())
+ replacements["SUCCESSOR"] = ci->GetSuccessor()->display;
+ replacements["TIME_REGISTERED"] = Anope::strftime(ci->time_registered, na->nc);
+ replacements["LAST_USED"] = Anope::strftime(ci->last_used, na->nc);
+ replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname);
+
+ if (!ci->last_topic.empty())
+ {
+ replacements["LAST_TOPIC"] = HTTPUtils::Escape(ci->last_topic);
+ replacements["LAST_TOPIC_SETTER"] = HTTPUtils::Escape(ci->last_topic_setter);
+ }
+
+ if (can_set)
+ {
+ if (ci->HasExt("KEEPTOPIC"))
+ replacements["KEEPTOPIC"];
+
+ if (ci->HasExt("PEACE"))
+ replacements["PEACE"];
+
+ if (ci->HasExt("CS_PRIVATE"))
+ replacements["PRIVATE"];
+
+ if (ci->HasExt("RESTRICTED"))
+ replacements["RESTRICTED"];
+
+ if (ci->HasExt("CS_SECURE"))
+ replacements["SECURE"];
+
+ if (ci->HasExt("SECUREOPS"))
+ replacements["SECUREOPS"];
+
+ if (ci->HasExt("TOPICLOCK"))
+ replacements["TOPICLOCK"];
+ }
+
+ page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+}
+
+std::set<Anope::string> WebCPanel::ChanServ::Set::GetData()
+{
+ std::set<Anope::string> v;
+ v.insert("channel");
+ return v;
+}
+
diff --git a/modules/webcpanel/pages/chanserv/set.h b/modules/webcpanel/pages/chanserv/set.h
new file mode 100644
index 000000000..dcd483419
--- /dev/null
+++ b/modules/webcpanel/pages/chanserv/set.h
@@ -0,0 +1,27 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+namespace WebCPanel
+{
+
+namespace ChanServ
+{
+
+class Set : public WebPanelProtectedPage
+{
+ public:
+ Set(const Anope::string &cat, const Anope::string &u);
+
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+
+ std::set<Anope::string> GetData() anope_override;
+};
+
+}
+
+}
+
diff --git a/modules/webcpanel/pages/chanserv/utils.cpp b/modules/webcpanel/pages/chanserv/utils.cpp
new file mode 100644
index 000000000..b4571b74c
--- /dev/null
+++ b/modules/webcpanel/pages/chanserv/utils.cpp
@@ -0,0 +1,45 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../../webcpanel.h"
+
+namespace
+{
+ bool ChannelSort(ChannelInfo *ci1, ChannelInfo *ci2)
+ {
+ return ci::less()(ci1->name, ci2->name);
+ }
+}
+
+namespace WebCPanel
+{
+
+namespace ChanServ
+{
+
+void BuildChanList(NickAlias *na, TemplateFileServer::Replacements &replacements)
+{
+ std::deque<ChannelInfo *> queue;
+ na->nc->GetChannelReferences(queue);
+ std::sort(queue.begin(), queue.end(), ChannelSort);
+
+ for (unsigned i = 0; i < queue.size(); ++i)
+ {
+ ChannelInfo *ci = queue[i];
+
+ if (na->nc != ci->GetFounder() && ci->AccessFor(na->nc).empty())
+ continue;
+
+ replacements["CHANNEL_NAMES"] = ci->name;
+ replacements["ESCAPED_CHANNEL_NAMES"] = HTTPUtils::URLEncode(ci->name);
+ }
+}
+
+}
+
+}
+
diff --git a/modules/webcpanel/pages/chanserv/utils.h b/modules/webcpanel/pages/chanserv/utils.h
new file mode 100644
index 000000000..111abb4ad
--- /dev/null
+++ b/modules/webcpanel/pages/chanserv/utils.h
@@ -0,0 +1,19 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+namespace WebCPanel
+{
+
+namespace ChanServ
+{
+
+extern void BuildChanList(NickAlias *, TemplateFileServer::Replacements &);
+
+}
+
+}
+
diff --git a/modules/webcpanel/pages/confirm.cpp b/modules/webcpanel/pages/confirm.cpp
new file mode 100644
index 000000000..7a4a3467e
--- /dev/null
+++ b/modules/webcpanel/pages/confirm.cpp
@@ -0,0 +1,32 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../webcpanel.h"
+
+bool WebCPanel::Confirm::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply)
+{
+ TemplateFileServer::Replacements replacements;
+ const Anope::string &user = message.post_data["username"], &pass = message.post_data["password"], &email = message.post_data["email"];
+
+ replacements["TITLE"] = page_title;
+
+ if (!user.empty() && !pass.empty())
+ {
+ std::vector<Anope::string> params;
+ params.push_back(pass);
+ if (!email.empty())
+ params.push_back(email);
+
+ WebPanel::RunCommand(user, NULL, "NickServ", "nickserv/register", params, replacements);
+ }
+
+ TemplateFileServer page("confirm.html");
+
+ page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+}
+
diff --git a/modules/webcpanel/pages/confirm.h b/modules/webcpanel/pages/confirm.h
new file mode 100644
index 000000000..eceeedee1
--- /dev/null
+++ b/modules/webcpanel/pages/confirm.h
@@ -0,0 +1,22 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "modules/httpd.h"
+
+namespace WebCPanel
+{
+
+class Confirm : public WebPanelPage
+{
+ public:
+ Confirm(const Anope::string &u) : WebPanelPage(u) { }
+
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) anope_override;
+};
+
+}
+
diff --git a/modules/webcpanel/pages/hostserv/request.cpp b/modules/webcpanel/pages/hostserv/request.cpp
new file mode 100644
index 000000000..ee6356214
--- /dev/null
+++ b/modules/webcpanel/pages/hostserv/request.cpp
@@ -0,0 +1,36 @@
+/*
+ * (C) 2003-2014 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;
+ params.push_back(HTTPUtils::URLDecode(message.post_data["req"]));
+
+ WebPanel::RunCommand(na->nc->display, na->nc, "HostServ", "hostserv/request", 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/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/webcpanel/pages/hostserv/request.h b/modules/webcpanel/pages/hostserv/request.h
new file mode 100644
index 000000000..59d790937
--- /dev/null
+++ b/modules/webcpanel/pages/hostserv/request.h
@@ -0,0 +1,24 @@
+/*
+ * (C) 2003-2014 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;
+};
+
+}
+
+}
diff --git a/modules/webcpanel/pages/index.cpp b/modules/webcpanel/pages/index.cpp
new file mode 100644
index 000000000..1b136c7fb
--- /dev/null
+++ b/modules/webcpanel/pages/index.cpp
@@ -0,0 +1,99 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../webcpanel.h"
+
+class WebpanelRequest : public IdentifyRequest
+{
+ HTTPReply reply;
+ HTTPMessage message;
+ Reference<HTTPProvider> server;
+ Anope::string page_name;
+ Reference<HTTPClient> client;
+ TemplateFileServer::Replacements replacements;
+
+ public:
+ WebpanelRequest(Module *o, HTTPReply &r, HTTPMessage &m, HTTPProvider *s, const Anope::string &p_n, HTTPClient *c, TemplateFileServer::Replacements &re, const Anope::string &user, const Anope::string &pass) : IdentifyRequest(o, user, pass), reply(r), message(m), server(s), page_name(p_n), client(c), replacements(re) { }
+
+ void OnSuccess() anope_override
+ {
+ if (!client || !server)
+ return;
+ NickAlias *na = NickAlias::Find(this->GetAccount());
+ if (!na)
+ {
+ this->OnFail();
+ return;
+ }
+
+ Anope::string id;
+ for (int i = 0; i < 64; ++i)
+ {
+ char c;
+ do
+ c = 48 + (rand() % 75);
+ while (!isalnum(c));
+ id += c;
+ }
+
+ na->Extend<Anope::string>("webcpanel_id", id);
+ na->Extend<Anope::string>("webcpanel_ip", client->GetIP());
+
+ {
+ HTTPReply::cookie c;
+ c.push_back(std::make_pair("account", na->nick));
+ c.push_back(std::make_pair("Path", "/"));
+ reply.cookies.push_back(c);
+ }
+
+ {
+ HTTPReply::cookie c;
+ c.push_back(std::make_pair("id", id));
+ c.push_back(std::make_pair("Path", "/"));
+ reply.cookies.push_back(c);
+ }
+
+ reply.error = HTTP_FOUND;
+ reply.headers["Location"] = Anope::string("http") + (server->IsSSL() ? "s" : "") + "://" + message.headers["Host"] + "/nickserv/info";
+
+ client->SendReply(&reply);
+ }
+
+ void OnFail() anope_override
+ {
+ if (!client || !server)
+ return;
+ replacements["INVALID_LOGIN"] = "Invalid username or password";
+ TemplateFileServer page("login.html");
+ page.Serve(server, page_name, client, message, reply, replacements);
+
+ client->SendReply(&reply);
+ }
+};
+
+bool WebCPanel::Index::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply)
+{
+ TemplateFileServer::Replacements replacements;
+ const Anope::string &user = message.post_data["username"], &pass = message.post_data["password"];
+
+ replacements["TITLE"] = page_title;
+
+ if (!user.empty() && !pass.empty())
+ {
+ // Rate limit check.
+
+ WebpanelRequest *req = new WebpanelRequest(me, reply, message, server, page_name, client, replacements, user, pass);
+ FOREACH_MOD(OnCheckAuthentication, (NULL, req));
+ req->Dispatch();
+ return false;
+ }
+
+ TemplateFileServer page("login.html");
+ page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+}
+
diff --git a/modules/webcpanel/pages/index.h b/modules/webcpanel/pages/index.h
new file mode 100644
index 000000000..b3c638d05
--- /dev/null
+++ b/modules/webcpanel/pages/index.h
@@ -0,0 +1,22 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "modules/httpd.h"
+
+namespace WebCPanel
+{
+
+class Index : public WebPanelPage
+{
+ public:
+ Index(const Anope::string &u) : WebPanelPage(u) { }
+
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) anope_override;
+};
+
+}
+
diff --git a/modules/webcpanel/pages/logout.cpp b/modules/webcpanel/pages/logout.cpp
new file mode 100644
index 000000000..d9f5432a3
--- /dev/null
+++ b/modules/webcpanel/pages/logout.cpp
@@ -0,0 +1,23 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../webcpanel.h"
+
+WebCPanel::Logout::Logout(const Anope::string &u) : WebPanelProtectedPage("", u)
+{
+}
+
+bool WebCPanel::Logout::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
+{
+ na->Shrink<Anope::string>("webcpanel_id");
+ na->Shrink<Anope::string>("webcpanel_ip");
+
+ reply.error = HTTP_FOUND;
+ reply.headers["Location"] = Anope::string("http") + (server->IsSSL() ? "s" : "") + "://" + message.headers["Host"] + "/";
+ return true;
+}
+
diff --git a/modules/webcpanel/pages/logout.h b/modules/webcpanel/pages/logout.h
new file mode 100644
index 000000000..ab324bdf9
--- /dev/null
+++ b/modules/webcpanel/pages/logout.h
@@ -0,0 +1,20 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+namespace WebCPanel
+{
+
+class Logout : public WebPanelProtectedPage
+{
+ public:
+ Logout(const Anope::string &u);
+
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+};
+
+}
+
diff --git a/modules/webcpanel/pages/memoserv/memos.cpp b/modules/webcpanel/pages/memoserv/memos.cpp
new file mode 100644
index 000000000..944864cdd
--- /dev/null
+++ b/modules/webcpanel/pages/memoserv/memos.cpp
@@ -0,0 +1,115 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../../webcpanel.h"
+
+WebCPanel::MemoServ::Memos::Memos(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u)
+{
+}
+
+bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
+{
+ const Anope::string &chname = message.get_data["channel"];
+ ChannelInfo *ci;
+ const MemoInfo *mi;
+ Memo *m;
+
+ for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
+ {
+ ci = it->second;
+
+ if (ci->AccessFor(na->nc).HasPriv("MEMO"))
+ {
+ replacements["CHANNEL_NAMES"] = ci->name;
+ replacements["ESCAPED_CHANNEL_NAMES"] = HTTPUtils::URLEncode(ci->name);
+ }
+ }
+
+ if (chname.empty())
+ {
+ replacements["MESSAGES"] = "No Channel specified, displaying the memos for your Nick";
+ mi = &na->nc->memos;
+ }
+ else
+ {
+ ci = ChannelInfo::Find(chname);
+ if (ci)
+ {
+ replacements["MESSAGES"] = "Displaying the memos for " + chname + ".";
+ mi = &ci->memos;
+ }
+ else
+ {
+ replacements["MESSAGES"] = "Channel " + chname + " not found, displaying the memos for your nick";
+ mi = &na->nc->memos;
+ }
+
+ replacements["CHANNEL_NAME"] = ci->name;
+ replacements["ESCAPED_CHANNEL_NAME"] = HTTPUtils::URLEncode(ci->name);
+ }
+ if (message.post_data.count("receiver") > 0 && message.post_data.count("message") > 0)
+ {
+ std::vector<Anope::string> params;
+ params.push_back(HTTPUtils::URLDecode(message.post_data["receiver"]));
+ params.push_back(HTTPUtils::URLDecode(message.post_data["message"]));
+
+ WebPanel::RunCommand(na->nc->display, na->nc, "MemoServ", "memoserv/send", params, replacements, "CMDR");
+ }
+ if (message.get_data.count("del") > 0 && message.get_data.count("number") > 0)
+ {
+ std::vector<Anope::string> params;
+ if (!chname.empty())
+ params.push_back(chname);
+ params.push_back(message.get_data["number"]);
+
+ WebPanel::RunCommand(na->nc->display, na->nc, "MemoServ", "memoserv/del", params, replacements, "CMDR");
+ }
+ if (message.get_data.count("read") > 0 && message.get_data.count("number") > 0)
+ {
+ std::vector<Anope::string> params;
+ int number = -1;
+
+ try
+ {
+ number = convertTo<int>(message.get_data["number"]);
+ }
+ catch (const ConvertException &ex)
+ {
+ replacements["MESSAGES"] = "ERROR - invalid parameter for NUMBER";
+ }
+
+ if (number > 0)
+ {
+ m = mi->GetMemo(number-1);
+
+ if (!m)
+ replacements["MESSAGES"] = "ERROR - invalid memo number.";
+ else if (message.get_data["read"] == "1")
+ m->unread = false;
+ else if (message.get_data["read"] == "2")
+ m->unread = true;
+ }
+ }
+
+ for (unsigned i = 0; i < mi->memos->size(); ++i)
+ {
+ m = mi->GetMemo(i);
+ replacements["NUMBER"] = stringify(i+1);
+ replacements["SENDER"] = m->sender;
+ replacements["TIME"] = Anope::strftime(m->time);
+ replacements["TEXT"] = HTTPUtils::Escape(m->text);
+ if (m->unread)
+ replacements["UNREAD"] = "YES";
+ else
+ replacements["UNREAD"] = "NO";
+ }
+
+ TemplateFileServer page("memoserv/memos.html");
+ page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+}
+
diff --git a/modules/webcpanel/pages/memoserv/memos.h b/modules/webcpanel/pages/memoserv/memos.h
new file mode 100644
index 000000000..e55104823
--- /dev/null
+++ b/modules/webcpanel/pages/memoserv/memos.h
@@ -0,0 +1,25 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+namespace WebCPanel
+{
+
+namespace MemoServ
+{
+
+class Memos : public WebPanelProtectedPage
+{
+ public:
+ Memos(const Anope::string &cat, const Anope::string &u);
+
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+};
+
+}
+
+}
+
diff --git a/modules/webcpanel/pages/nickserv/access.cpp b/modules/webcpanel/pages/nickserv/access.cpp
new file mode 100644
index 000000000..de7809591
--- /dev/null
+++ b/modules/webcpanel/pages/nickserv/access.cpp
@@ -0,0 +1,40 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../../webcpanel.h"
+
+WebCPanel::NickServ::Access::Access(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u)
+{
+}
+
+bool WebCPanel::NickServ::Access::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
+{
+ if (message.post_data.count("access") > 0)
+ {
+ std::vector<Anope::string> params;
+ params.push_back("ADD");
+ params.push_back(message.post_data["access"]);
+
+ WebPanel::RunCommand(na->nc->display, na->nc, "NickServ", "nickserv/access", params, replacements);
+ }
+ else if (message.get_data.count("del") > 0 && message.get_data.count("mask") > 0)
+ {
+ std::vector<Anope::string> params;
+ params.push_back("DEL");
+ params.push_back(message.get_data["mask"]);
+
+ WebPanel::RunCommand(na->nc->display, na->nc, "NickServ", "nickserv/access", params, replacements);
+ }
+
+ for (unsigned i = 0; i < na->nc->access.size(); ++i)
+ replacements["ACCESS"] = na->nc->access[i];
+
+ TemplateFileServer page("nickserv/access.html");
+ page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+}
+
diff --git a/modules/webcpanel/pages/nickserv/access.h b/modules/webcpanel/pages/nickserv/access.h
new file mode 100644
index 000000000..8c7337236
--- /dev/null
+++ b/modules/webcpanel/pages/nickserv/access.h
@@ -0,0 +1,25 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+namespace WebCPanel
+{
+
+namespace NickServ
+{
+
+class Access : public WebPanelProtectedPage
+{
+ public:
+ Access(const Anope::string &cat, const Anope::string &u);
+
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+};
+
+}
+
+}
+
diff --git a/modules/webcpanel/pages/nickserv/alist.cpp b/modules/webcpanel/pages/nickserv/alist.cpp
new file mode 100644
index 000000000..21e281f5f
--- /dev/null
+++ b/modules/webcpanel/pages/nickserv/alist.cpp
@@ -0,0 +1,59 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../../webcpanel.h"
+
+static bool ChannelSort(ChannelInfo *ci1, ChannelInfo *ci2)
+{
+ return ci::less()(ci1->name, ci2->name);
+}
+
+WebCPanel::NickServ::Alist::Alist(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u)
+{
+}
+
+bool WebCPanel::NickServ::Alist::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
+{
+ std::deque<ChannelInfo *> queue;
+ na->nc->GetChannelReferences(queue);
+ std::sort(queue.begin(), queue.end(), ChannelSort);
+
+ int chan_count = 0;
+
+ for (unsigned q = 0; q < queue.size(); ++q)
+ {
+ ChannelInfo *ci = queue[q];
+
+ if (ci->GetFounder() == na->nc)
+ {
+ ++chan_count;
+
+ replacements["NUMBERS"] = stringify(chan_count);
+ replacements["CHANNELS"] = (ci->HasExt("CS_NO_EXPIRE") ? "!" : "") + ci->name;
+ replacements["ACCESSES"] = "Founder";
+ continue;
+ }
+
+ AccessGroup access = ci->AccessFor(na->nc);
+ if (access.empty())
+ continue;
+
+ ++chan_count;
+
+ replacements["NUMBERS"] = stringify(chan_count);
+ replacements["CHANNELS"] = (ci->HasExt("CS_NO_EXPIRE") ? "!" : "") + ci->name;
+ Anope::string access_str;
+ for (unsigned i = 0; i < access.size(); ++i)
+ access_str += ", " + access[i]->AccessSerialize();
+ replacements["ACCESSES"] = access_str.substr(2);
+ }
+
+ TemplateFileServer page("nickserv/alist.html");
+ page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+}
+
diff --git a/modules/webcpanel/pages/nickserv/alist.h b/modules/webcpanel/pages/nickserv/alist.h
new file mode 100644
index 000000000..357699f4e
--- /dev/null
+++ b/modules/webcpanel/pages/nickserv/alist.h
@@ -0,0 +1,25 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+namespace WebCPanel
+{
+
+namespace NickServ
+{
+
+class Alist : public WebPanelProtectedPage
+{
+ public:
+ Alist(const Anope::string &cat, const Anope::string &u);
+
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+};
+
+}
+
+}
+
diff --git a/modules/webcpanel/pages/nickserv/cert.cpp b/modules/webcpanel/pages/nickserv/cert.cpp
new file mode 100644
index 000000000..eb86f4bd8
--- /dev/null
+++ b/modules/webcpanel/pages/nickserv/cert.cpp
@@ -0,0 +1,43 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../../webcpanel.h"
+#include "modules/ns_cert.h"
+
+WebCPanel::NickServ::Cert::Cert(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u)
+{
+}
+
+bool WebCPanel::NickServ::Cert::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
+{
+ if (message.post_data.count("certfp") > 0)
+ {
+ std::vector<Anope::string> params;
+ params.push_back("ADD");
+ params.push_back(message.post_data["certfp"]);
+
+ WebPanel::RunCommand(na->nc->display, na->nc, "NickServ", "nickserv/cert", params, replacements);
+ }
+ else if (message.get_data.count("del") > 0 && message.get_data.count("mask") > 0)
+ {
+ std::vector<Anope::string> params;
+ params.push_back("DEL");
+ params.push_back(message.get_data["mask"]);
+
+ WebPanel::RunCommand(na->nc->display, na->nc, "NickServ", "nickserv/cert", params, replacements);
+ }
+
+ NSCertList *cl = na->nc->GetExt<NSCertList>("certificates");
+ if (cl)
+ for (unsigned i = 0; i < cl->GetCertCount(); ++i)
+ replacements["CERTS"] = cl->GetCert(i);
+
+ TemplateFileServer page("nickserv/cert.html");
+ page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+}
+
diff --git a/modules/webcpanel/pages/nickserv/cert.h b/modules/webcpanel/pages/nickserv/cert.h
new file mode 100644
index 000000000..7fa86e6eb
--- /dev/null
+++ b/modules/webcpanel/pages/nickserv/cert.h
@@ -0,0 +1,25 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+namespace WebCPanel
+{
+
+namespace NickServ
+{
+
+class Cert : public WebPanelProtectedPage
+{
+ public:
+ Cert(const Anope::string &cat, const Anope::string &u);
+
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+};
+
+}
+
+}
+
diff --git a/modules/webcpanel/pages/nickserv/info.cpp b/modules/webcpanel/pages/nickserv/info.cpp
new file mode 100644
index 000000000..f8753d83f
--- /dev/null
+++ b/modules/webcpanel/pages/nickserv/info.cpp
@@ -0,0 +1,118 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../../webcpanel.h"
+
+WebCPanel::NickServ::Info::Info(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u)
+{
+}
+
+bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
+{
+ if (message.post_data.empty() == false)
+ {
+ if (message.post_data.count("email") > 0)
+ {
+ if (message.post_data["email"] != na->nc->email)
+ {
+ if (!message.post_data["email"].empty() && !Mail::Validate(message.post_data["email"]))
+ replacements["ERRORS"] = "Invalid email";
+ else
+ {
+ na->nc->email = message.post_data["email"];
+ replacements["MESSAGES"] = "Email updated";
+ }
+ }
+ }
+ if (message.post_data.count("greet") > 0)
+ {
+ Anope::string *greet = na->nc->GetExt<Anope::string>("greet");
+ const Anope::string &post_greet = HTTPUtils::URLDecode(message.post_data["greet"].replace_all_cs("+", " "));
+
+ if (post_greet.empty())
+ na->nc->Shrink<Anope::string>("greet");
+ else if (!greet || post_greet != *greet)
+ na->nc->Extend<Anope::string>("greet", post_greet);
+
+ replacements["MESSAGES"] = "Greet updated";
+ }
+ if (na->nc->HasExt("AUTOOP") != message.post_data.count("autoop"))
+ {
+ if (!na->nc->HasExt("AUTOOP"))
+ na->nc->Extend<bool>("AUTOOP");
+ else
+ na->nc->Shrink<bool>("AUTOOP");
+ replacements["MESSAGES"] = "Autoop updated";
+ }
+ if (na->nc->HasExt("NS_PRIVATE") != message.post_data.count("private"))
+ {
+ if (!na->nc->HasExt("NS_PRIVATE"))
+ na->nc->Extend<bool>("NS_PRIVATE");
+ else
+ na->nc->Shrink<bool>("NS_PRIVATE");
+ replacements["MESSAGES"] = "Private updated";
+ }
+ if (na->nc->HasExt("NS_SECURE") != message.post_data.count("secure"))
+ {
+ if (!na->nc->HasExt("NS_SECURE"))
+ na->nc->Extend<bool>("NS_SECURE");
+ else
+ na->nc->Shrink<bool>("NS_SECURE");
+ replacements["MESSAGES"] = "Secure updated";
+ }
+ if (message.post_data["kill"] == "on" && !na->nc->HasExt("KILLPROTECT"))
+ {
+ na->nc->Extend<bool>("KILLPROTECT");
+ na->nc->Shrink<bool>("KILL_QUICK");
+ replacements["MESSAGES"] = "Kill updated";
+ }
+ else if (message.post_data["kill"] == "quick" && !na->nc->HasExt("KILL_QUICK"))
+ {
+ na->nc->Shrink<bool>("KILLPROTECT");
+ na->nc->Extend<bool>("KILL_QUICK");
+ replacements["MESSAGES"] = "Kill updated";
+ }
+ else if (message.post_data["kill"] == "off" && (na->nc->HasExt("KILLPROTECT") || na->nc->HasExt("KILL_QUICK")))
+ {
+ na->nc->Shrink<bool>("KILLPROTECT");
+ na->nc->Shrink<bool>("KILL_QUICK");
+ replacements["MESSAGES"] = "Kill updated";
+ }
+ }
+
+ replacements["DISPLAY"] = HTTPUtils::Escape(na->nc->display);
+ if (na->nc->email.empty() == false)
+ replacements["EMAIL"] = HTTPUtils::Escape(na->nc->email);
+ replacements["TIME_REGISTERED"] = Anope::strftime(na->time_registered, na->nc);
+ if (na->HasVhost())
+ {
+ if (na->GetVhostIdent().empty() == false)
+ replacements["VHOST"] = na->GetVhostIdent() + "@" + na->GetVhostHost();
+ else
+ replacements["VHOST"] = na->GetVhostHost();
+ }
+ Anope::string *greet = na->nc->GetExt<Anope::string>("greet");
+ if (greet)
+ replacements["GREET"] = HTTPUtils::Escape(*greet);
+ if (na->nc->HasExt("AUTOOP"))
+ replacements["AUTOOP"];
+ if (na->nc->HasExt("NS_PRIVATE"))
+ replacements["PRIVATE"];
+ if (na->nc->HasExt("NS_SECURE"))
+ replacements["SECURE"];
+ if (na->nc->HasExt("KILLPROTECT"))
+ replacements["KILL_ON"];
+ if (na->nc->HasExt("KILL_QUICK"))
+ replacements["KILL_QUICK"];
+ if (!na->nc->HasExt("KILLPROTECT") && !na->nc->HasExt("KILL_QUICK"))
+ replacements["KILL_OFF"];
+
+ TemplateFileServer page("nickserv/info.html");
+ page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+}
+
diff --git a/modules/webcpanel/pages/nickserv/info.h b/modules/webcpanel/pages/nickserv/info.h
new file mode 100644
index 000000000..46e588f8b
--- /dev/null
+++ b/modules/webcpanel/pages/nickserv/info.h
@@ -0,0 +1,25 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+namespace WebCPanel
+{
+
+namespace NickServ
+{
+
+class Info : public WebPanelProtectedPage
+{
+ public:
+ Info(const Anope::string &cat, const Anope::string &u);
+
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+};
+
+}
+
+}
+
diff --git a/modules/webcpanel/pages/operserv/akill.cpp b/modules/webcpanel/pages/operserv/akill.cpp
new file mode 100644
index 000000000..24f1dbf63
--- /dev/null
+++ b/modules/webcpanel/pages/operserv/akill.cpp
@@ -0,0 +1,64 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../../webcpanel.h"
+
+WebCPanel::OperServ::Akill::Akill(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u)
+{
+}
+
+bool WebCPanel::OperServ::Akill::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
+{
+
+ static ServiceReference<XLineManager> akills("XLineManager","xlinemanager/sgline");
+
+ if (!na->nc->IsServicesOper() && !(na->nc->o && na->nc->o->ot && na->nc->o->ot->HasPriv("operserv/akill")))
+ {
+ replacements["NOACCESS"];
+ }
+ else
+ {
+ if (akills->GetCount() == 0)
+ replacements["AKILLS"] = "No Akills to display.";
+
+ if (message.post_data.count("mask") > 0 && message.post_data.count("expiry") > 0 && message.post_data.count("reason") > 0)
+ {
+ std::vector<Anope::string> params;
+ std::stringstream cmdstr;
+ params.push_back("ADD");
+ cmdstr << "+" << HTTPUtils::URLDecode(message.post_data["expiry"]);
+ cmdstr << " " << HTTPUtils::URLDecode(message.post_data["mask"]);
+ cmdstr << " " << HTTPUtils::URLDecode(message.post_data["reason"]);
+ params.push_back(cmdstr.str());
+ WebPanel::RunCommand(na->nc->display, na->nc, "OperServ", "operserv/akill", params, replacements);
+ }
+
+ if (message.get_data["del"] == "1" && message.get_data.count("number") > 0)
+ {
+ std::vector<Anope::string> params;
+ params.push_back("DEL");
+ params.push_back(HTTPUtils::URLDecode(message.get_data["number"]));
+ WebPanel::RunCommand(na->nc->display, na->nc, "OperServ", "operserv/akill", params, replacements);
+ }
+
+ for (unsigned i = 0, end = akills->GetCount(); i < end; ++i)
+ {
+ const XLine *x = akills->GetEntry(i);
+ replacements["NUMBER"] = stringify(i + 1);
+ replacements["HOST"] = x->mask;
+ replacements["SETTER"] = x->by;
+ replacements["TIME"] = Anope::strftime(x->created, NULL, true);
+ replacements["EXPIRE"] = Anope::Expires(x->expires, na->nc);
+ replacements["REASON"] = x->reason;
+ }
+ }
+
+ TemplateFileServer page("operserv/akill.html");
+ page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+}
+
diff --git a/modules/webcpanel/pages/operserv/akill.h b/modules/webcpanel/pages/operserv/akill.h
new file mode 100644
index 000000000..9fd47d79a
--- /dev/null
+++ b/modules/webcpanel/pages/operserv/akill.h
@@ -0,0 +1,25 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+namespace WebCPanel
+{
+
+namespace OperServ
+{
+
+class Akill : public WebPanelProtectedPage
+{
+ public:
+ Akill(const Anope::string &cat, const Anope::string &u);
+
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) anope_override;
+};
+
+}
+
+}
+
diff --git a/modules/webcpanel/pages/register.cpp b/modules/webcpanel/pages/register.cpp
new file mode 100644
index 000000000..cd3494713
--- /dev/null
+++ b/modules/webcpanel/pages/register.cpp
@@ -0,0 +1,24 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "../webcpanel.h"
+
+bool WebCPanel::Register::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply)
+{
+ TemplateFileServer::Replacements replacements;
+
+ replacements["TITLE"] = page_title;
+
+ if (Config->GetModule("nickserv")->Get<bool>("forceemail", "yes"))
+ replacements["FORCE_EMAIL"] = "yes";
+
+ TemplateFileServer page("register.html");
+
+ page.Serve(server, page_name, client, message, reply, replacements);
+ return true;
+}
+
diff --git a/modules/webcpanel/pages/register.h b/modules/webcpanel/pages/register.h
new file mode 100644
index 000000000..38646c98c
--- /dev/null
+++ b/modules/webcpanel/pages/register.h
@@ -0,0 +1,22 @@
+/*
+ * (C) 2003-2014 Anope Team
+ * Contact us at team@anope.org
+ *
+ * Please read COPYING and README for further details.
+ */
+
+#include "modules/httpd.h"
+
+namespace WebCPanel
+{
+
+class Register : public WebPanelPage
+{
+ public:
+ Register(const Anope::string &u) : WebPanelPage(u) { }
+
+ bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) anope_override;
+};
+
+}
+