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/chanserv | |
| parent | 072202c181943901c727782e64881adadf13d7dd (diff) | |
Move modules out of extras that dont have external dependencies
Diffstat (limited to 'modules/webcpanel/pages/chanserv')
| -rw-r--r-- | modules/webcpanel/pages/chanserv/access.cpp | 162 | ||||
| -rw-r--r-- | modules/webcpanel/pages/chanserv/access.h | 27 | ||||
| -rw-r--r-- | modules/webcpanel/pages/chanserv/akick.cpp | 94 | ||||
| -rw-r--r-- | modules/webcpanel/pages/chanserv/akick.h | 27 | ||||
| -rw-r--r-- | modules/webcpanel/pages/chanserv/drop.cpp | 58 | ||||
| -rw-r--r-- | modules/webcpanel/pages/chanserv/drop.h | 25 | ||||
| -rw-r--r-- | modules/webcpanel/pages/chanserv/info.cpp | 28 | ||||
| -rw-r--r-- | modules/webcpanel/pages/chanserv/info.h | 25 | ||||
| -rw-r--r-- | modules/webcpanel/pages/chanserv/modes.cpp | 108 | ||||
| -rw-r--r-- | modules/webcpanel/pages/chanserv/modes.h | 27 | ||||
| -rw-r--r-- | modules/webcpanel/pages/chanserv/set.cpp | 155 | ||||
| -rw-r--r-- | modules/webcpanel/pages/chanserv/set.h | 27 | ||||
| -rw-r--r-- | modules/webcpanel/pages/chanserv/utils.cpp | 45 | ||||
| -rw-r--r-- | modules/webcpanel/pages/chanserv/utils.h | 19 |
14 files changed, 827 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 &); + +} + +} + |
