diff options
| author | Adam <Adam@anope.org> | 2014-01-02 11:02:14 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2014-01-02 11:03:33 -0500 |
| commit | 004c4cbe5f4c37cf455cb6d0caa434fbbb3406ea (patch) | |
| tree | 0e6675dfe28a829f5786b0b2f993566c61662de7 /modules/webcpanel/pages/nickserv | |
| parent | 072202c181943901c727782e64881adadf13d7dd (diff) | |
Move modules out of extras that dont have external dependencies
Diffstat (limited to 'modules/webcpanel/pages/nickserv')
| -rw-r--r-- | modules/webcpanel/pages/nickserv/access.cpp | 40 | ||||
| -rw-r--r-- | modules/webcpanel/pages/nickserv/access.h | 25 | ||||
| -rw-r--r-- | modules/webcpanel/pages/nickserv/alist.cpp | 59 | ||||
| -rw-r--r-- | modules/webcpanel/pages/nickserv/alist.h | 25 | ||||
| -rw-r--r-- | modules/webcpanel/pages/nickserv/cert.cpp | 43 | ||||
| -rw-r--r-- | modules/webcpanel/pages/nickserv/cert.h | 25 | ||||
| -rw-r--r-- | modules/webcpanel/pages/nickserv/info.cpp | 118 | ||||
| -rw-r--r-- | modules/webcpanel/pages/nickserv/info.h | 25 |
8 files changed, 360 insertions, 0 deletions
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; +}; + +} + +} + |
