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/extra/webcpanel | |
parent | 072202c181943901c727782e64881adadf13d7dd (diff) |
Move modules out of extras that dont have external dependencies
Diffstat (limited to 'modules/extra/webcpanel')
66 files changed, 0 insertions, 3710 deletions
diff --git a/modules/extra/webcpanel/CMakeLists.txt b/modules/extra/webcpanel/CMakeLists.txt deleted file mode 100644 index 247973f61..000000000 --- a/modules/extra/webcpanel/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -build_subdir(${CMAKE_CURRENT_SOURCE_DIR}) - -install(DIRECTORY templates - DESTINATION "${DB_DIR}/modules/webcpanel" -) - diff --git a/modules/extra/webcpanel/pages/chanserv/access.cpp b/modules/extra/webcpanel/pages/chanserv/access.cpp deleted file mode 100644 index d87613ed7..000000000 --- a/modules/extra/webcpanel/pages/chanserv/access.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * (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/extra/webcpanel/pages/chanserv/access.h b/modules/extra/webcpanel/pages/chanserv/access.h deleted file mode 100644 index 7f81f2d39..000000000 --- a/modules/extra/webcpanel/pages/chanserv/access.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * (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/extra/webcpanel/pages/chanserv/akick.cpp b/modules/extra/webcpanel/pages/chanserv/akick.cpp deleted file mode 100644 index bff38910c..000000000 --- a/modules/extra/webcpanel/pages/chanserv/akick.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * (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/extra/webcpanel/pages/chanserv/akick.h b/modules/extra/webcpanel/pages/chanserv/akick.h deleted file mode 100644 index bd5b18132..000000000 --- a/modules/extra/webcpanel/pages/chanserv/akick.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * (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/extra/webcpanel/pages/chanserv/drop.cpp b/modules/extra/webcpanel/pages/chanserv/drop.cpp deleted file mode 100644 index 5fa37b5a2..000000000 --- a/modules/extra/webcpanel/pages/chanserv/drop.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * (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/extra/webcpanel/pages/chanserv/drop.h b/modules/extra/webcpanel/pages/chanserv/drop.h deleted file mode 100644 index d418ade8f..000000000 --- a/modules/extra/webcpanel/pages/chanserv/drop.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * (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/extra/webcpanel/pages/chanserv/info.cpp b/modules/extra/webcpanel/pages/chanserv/info.cpp deleted file mode 100644 index c16c3eaec..000000000 --- a/modules/extra/webcpanel/pages/chanserv/info.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * (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/extra/webcpanel/pages/chanserv/info.h b/modules/extra/webcpanel/pages/chanserv/info.h deleted file mode 100644 index 4302264d6..000000000 --- a/modules/extra/webcpanel/pages/chanserv/info.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * (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/extra/webcpanel/pages/chanserv/modes.cpp b/modules/extra/webcpanel/pages/chanserv/modes.cpp deleted file mode 100644 index e3e93dd03..000000000 --- a/modules/extra/webcpanel/pages/chanserv/modes.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * (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/extra/webcpanel/pages/chanserv/modes.h b/modules/extra/webcpanel/pages/chanserv/modes.h deleted file mode 100644 index 36f5a1d27..000000000 --- a/modules/extra/webcpanel/pages/chanserv/modes.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * (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/extra/webcpanel/pages/chanserv/set.cpp b/modules/extra/webcpanel/pages/chanserv/set.cpp deleted file mode 100644 index f763ba13b..000000000 --- a/modules/extra/webcpanel/pages/chanserv/set.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * (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/extra/webcpanel/pages/chanserv/set.h b/modules/extra/webcpanel/pages/chanserv/set.h deleted file mode 100644 index dcd483419..000000000 --- a/modules/extra/webcpanel/pages/chanserv/set.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * (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/extra/webcpanel/pages/chanserv/utils.cpp b/modules/extra/webcpanel/pages/chanserv/utils.cpp deleted file mode 100644 index b4571b74c..000000000 --- a/modules/extra/webcpanel/pages/chanserv/utils.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * (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/extra/webcpanel/pages/chanserv/utils.h b/modules/extra/webcpanel/pages/chanserv/utils.h deleted file mode 100644 index 111abb4ad..000000000 --- a/modules/extra/webcpanel/pages/chanserv/utils.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * (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/extra/webcpanel/pages/confirm.cpp b/modules/extra/webcpanel/pages/confirm.cpp deleted file mode 100644 index 7a4a3467e..000000000 --- a/modules/extra/webcpanel/pages/confirm.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * (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/extra/webcpanel/pages/confirm.h b/modules/extra/webcpanel/pages/confirm.h deleted file mode 100644 index eceeedee1..000000000 --- a/modules/extra/webcpanel/pages/confirm.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * (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/extra/webcpanel/pages/hostserv/request.cpp b/modules/extra/webcpanel/pages/hostserv/request.cpp deleted file mode 100644 index ee6356214..000000000 --- a/modules/extra/webcpanel/pages/hostserv/request.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (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/extra/webcpanel/pages/hostserv/request.h b/modules/extra/webcpanel/pages/hostserv/request.h deleted file mode 100644 index 59d790937..000000000 --- a/modules/extra/webcpanel/pages/hostserv/request.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * (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/extra/webcpanel/pages/index.cpp b/modules/extra/webcpanel/pages/index.cpp deleted file mode 100644 index 1b136c7fb..000000000 --- a/modules/extra/webcpanel/pages/index.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * (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/extra/webcpanel/pages/index.h b/modules/extra/webcpanel/pages/index.h deleted file mode 100644 index b3c638d05..000000000 --- a/modules/extra/webcpanel/pages/index.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * (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/extra/webcpanel/pages/logout.cpp b/modules/extra/webcpanel/pages/logout.cpp deleted file mode 100644 index d9f5432a3..000000000 --- a/modules/extra/webcpanel/pages/logout.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * (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/extra/webcpanel/pages/logout.h b/modules/extra/webcpanel/pages/logout.h deleted file mode 100644 index ab324bdf9..000000000 --- a/modules/extra/webcpanel/pages/logout.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * (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/extra/webcpanel/pages/memoserv/memos.cpp b/modules/extra/webcpanel/pages/memoserv/memos.cpp deleted file mode 100644 index 944864cdd..000000000 --- a/modules/extra/webcpanel/pages/memoserv/memos.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * (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/extra/webcpanel/pages/memoserv/memos.h b/modules/extra/webcpanel/pages/memoserv/memos.h deleted file mode 100644 index e55104823..000000000 --- a/modules/extra/webcpanel/pages/memoserv/memos.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * (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/extra/webcpanel/pages/nickserv/access.cpp b/modules/extra/webcpanel/pages/nickserv/access.cpp deleted file mode 100644 index de7809591..000000000 --- a/modules/extra/webcpanel/pages/nickserv/access.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * (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/extra/webcpanel/pages/nickserv/access.h b/modules/extra/webcpanel/pages/nickserv/access.h deleted file mode 100644 index 8c7337236..000000000 --- a/modules/extra/webcpanel/pages/nickserv/access.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * (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/extra/webcpanel/pages/nickserv/alist.cpp b/modules/extra/webcpanel/pages/nickserv/alist.cpp deleted file mode 100644 index 21e281f5f..000000000 --- a/modules/extra/webcpanel/pages/nickserv/alist.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * (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/extra/webcpanel/pages/nickserv/alist.h b/modules/extra/webcpanel/pages/nickserv/alist.h deleted file mode 100644 index 357699f4e..000000000 --- a/modules/extra/webcpanel/pages/nickserv/alist.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * (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/extra/webcpanel/pages/nickserv/cert.cpp b/modules/extra/webcpanel/pages/nickserv/cert.cpp deleted file mode 100644 index eb86f4bd8..000000000 --- a/modules/extra/webcpanel/pages/nickserv/cert.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * (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/extra/webcpanel/pages/nickserv/cert.h b/modules/extra/webcpanel/pages/nickserv/cert.h deleted file mode 100644 index 7fa86e6eb..000000000 --- a/modules/extra/webcpanel/pages/nickserv/cert.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * (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/extra/webcpanel/pages/nickserv/info.cpp b/modules/extra/webcpanel/pages/nickserv/info.cpp deleted file mode 100644 index f8753d83f..000000000 --- a/modules/extra/webcpanel/pages/nickserv/info.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * (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/extra/webcpanel/pages/nickserv/info.h b/modules/extra/webcpanel/pages/nickserv/info.h deleted file mode 100644 index 46e588f8b..000000000 --- a/modules/extra/webcpanel/pages/nickserv/info.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * (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/extra/webcpanel/pages/operserv/akill.cpp b/modules/extra/webcpanel/pages/operserv/akill.cpp deleted file mode 100644 index 24f1dbf63..000000000 --- a/modules/extra/webcpanel/pages/operserv/akill.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * (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/extra/webcpanel/pages/operserv/akill.h b/modules/extra/webcpanel/pages/operserv/akill.h deleted file mode 100644 index 9fd47d79a..000000000 --- a/modules/extra/webcpanel/pages/operserv/akill.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * (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/extra/webcpanel/pages/register.cpp b/modules/extra/webcpanel/pages/register.cpp deleted file mode 100644 index cd3494713..000000000 --- a/modules/extra/webcpanel/pages/register.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * (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/extra/webcpanel/pages/register.h b/modules/extra/webcpanel/pages/register.h deleted file mode 100644 index 38646c98c..000000000 --- a/modules/extra/webcpanel/pages/register.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * (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; -}; - -} - diff --git a/modules/extra/webcpanel/static_fileserver.cpp b/modules/extra/webcpanel/static_fileserver.cpp deleted file mode 100644 index 21f4e7052..000000000 --- a/modules/extra/webcpanel/static_fileserver.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * (C) 2003-2014 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#include "webcpanel.h" -#include <fstream> -#include <errno.h> - -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -StaticFileServer::StaticFileServer(const Anope::string &f_n, const Anope::string &u, const Anope::string &c_t) : HTTPPage(u, c_t), file_name(f_n) -{ -} - -bool StaticFileServer::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) -{ - int fd = open((template_base + "/" + this->file_name).c_str(), O_RDONLY); - if (fd < 0) - { - Log(LOG_NORMAL, "httpd") << "Error serving file " << page_name << " (" << (template_base + "/" + this->file_name) << "): " << strerror(errno); - - client->SendError(HTTP_PAGE_NOT_FOUND, "Page not found"); - return true; - } - - reply.content_type = this->GetContentType(); - reply.headers["Cache-Control"] = "public"; - - int i; - char buffer[BUFSIZE]; - while ((i = read(fd, buffer, sizeof(buffer))) > 0) - reply.Write(buffer, i); - - close(fd); - return true; -} - diff --git a/modules/extra/webcpanel/static_fileserver.h b/modules/extra/webcpanel/static_fileserver.h deleted file mode 100644 index 184c8661d..000000000 --- a/modules/extra/webcpanel/static_fileserver.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * (C) 2003-2014 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#include "modules/httpd.h" - -/* A basic file server. Used for serving static content on disk. */ -class StaticFileServer : public HTTPPage -{ - Anope::string file_name; - public: - StaticFileServer(const Anope::string &f_n, const Anope::string &u, const Anope::string &c_t); - - bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) anope_override; -}; - diff --git a/modules/extra/webcpanel/template_fileserver.cpp b/modules/extra/webcpanel/template_fileserver.cpp deleted file mode 100644 index d4e5ec7e4..000000000 --- a/modules/extra/webcpanel/template_fileserver.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* - * (C) 2003-2014 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#include "webcpanel.h" -#include <fstream> -#include <stack> -#include <errno.h> - -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -struct ForLoop -{ - static std::vector<ForLoop> Stack; - - size_t start; /* Index of start of this loop */ - std::vector<Anope::string> vars; /* User defined variables */ - typedef std::pair<TemplateFileServer::Replacements::iterator, TemplateFileServer::Replacements::iterator> range; - std::vector<range> ranges; /* iterator ranges for each variable */ - - ForLoop(size_t s, TemplateFileServer::Replacements &r, const std::vector<Anope::string> &v, const std::vector<Anope::string> &r_names) : start(s), vars(v) - { - for (unsigned i = 0; i < r_names.size(); ++i) - ranges.push_back(r.equal_range(r_names[i])); - } - - void increment(const TemplateFileServer::Replacements &r) - { - for (unsigned i = 0; i < ranges.size(); ++i) - { - range &ra = ranges[i]; - - if (ra.first != r.end() && ra.first != ra.second) - ++ra.first; - } - } - - bool finished(const TemplateFileServer::Replacements &r) const - { - for (unsigned i = 0; i < ranges.size(); ++i) - { - const range &ra = ranges[i]; - - if (ra.first != r.end() && ra.first != ra.second) - return false; - } - - return true; - } -}; -std::vector<ForLoop> ForLoop::Stack; - -std::stack<bool> IfStack; - -static Anope::string FindReplacement(const TemplateFileServer::Replacements &r, const Anope::string &key) -{ - /* Search first through for loop stack then global replacements */ - for (unsigned i = ForLoop::Stack.size(); i > 0; --i) - { - ForLoop &fl = ForLoop::Stack[i - 1]; - - for (unsigned j = 0; j < fl.vars.size(); ++j) - { - const Anope::string &var_name = fl.vars[j]; - - if (key == var_name) - { - const ForLoop::range &range = fl.ranges[j]; - - if (range.first != r.end() && range.first != range.second) - { - return range.first->second; - } - } - } - } - - TemplateFileServer::Replacements::const_iterator it = r.find(key); - if (it != r.end()) - return it->second; - return ""; -} - -TemplateFileServer::TemplateFileServer(const Anope::string &f_n) : file_name(f_n) -{ -} - -void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, Replacements &r) -{ - int fd = open((template_base + "/" + this->file_name).c_str(), O_RDONLY); - if (fd < 0) - { - Log(LOG_NORMAL, "httpd") << "Error serving file " << page_name << " (" << (template_base + "/" + this->file_name) << "): " << strerror(errno); - - client->SendError(HTTP_PAGE_NOT_FOUND, "Page not found"); - return; - } - - Anope::string buf; - - int i; - char buffer[BUFSIZE]; - while ((i = read(fd, buffer, sizeof(buffer) - 1)) > 0) - { - buffer[i] = 0; - buf += buffer; - } - - close(fd); - - Anope::string finished; - - bool escaped = false; - for (unsigned j = 0; j < buf.length(); ++j) - { - if (buf[j] == '\\' && j + 1 < buf.length() && (buf[j + 1] == '{' || buf[j + 1] == '}')) - escaped = true; - else if (buf[j] == '{' && !escaped) - { - size_t f = buf.substr(j).find('}'); - if (f == Anope::string::npos) - break; - const Anope::string &content = buf.substr(j + 1, f - 1); - - if (content.find("IF ") == 0) - { - std::vector<Anope::string> tokens; - spacesepstream(content).GetTokens(tokens); - - if (tokens.size() == 4 && tokens[1] == "EQ") - { - Anope::string first = FindReplacement(r, tokens[2]), second = FindReplacement(r, tokens[3]); - if (first.empty()) - first = tokens[2]; - if (second.empty()) - second = tokens[3]; - - bool stackok = IfStack.empty() || IfStack.top(); - IfStack.push(stackok && first == second); - } - else if (tokens.size() == 3 && tokens[1] == "EXISTS") - { - bool stackok = IfStack.empty() || IfStack.top(); - IfStack.push(stackok && r.count(tokens[2]) > 0); - } - else - Log() << "Invalid IF in web template " << this->file_name; - } - else if (content == "ELSE") - { - if (IfStack.empty()) - Log() << "Invalid ELSE with no stack in web template" << this->file_name; - else - { - bool old = IfStack.top(); - IfStack.pop(); // Pop off previous if() - bool stackok = IfStack.empty() || IfStack.top(); - IfStack.push(stackok && !old); // Push back the opposite of what was popped - } - } - else if (content == "END IF") - { - if (IfStack.empty()) - Log() << "END IF with empty stack?"; - else - IfStack.pop(); - } - else if (content.find("FOR ") == 0) - { - std::vector<Anope::string> tokens; - spacesepstream(content).GetTokens(tokens); - - if (tokens.size() != 4 || tokens[2] != "IN") - Log() << "Invalid FOR in web template " << this->file_name; - else - { - std::vector<Anope::string> temp_variables, real_variables; - commasepstream(tokens[1]).GetTokens(temp_variables); - commasepstream(tokens[3]).GetTokens(real_variables); - - if (temp_variables.size() != real_variables.size()) - Log() << "Invalid FOR in web template " << this->file_name << " variable mismatch"; - else - ForLoop::Stack.push_back(ForLoop(j + f, r, temp_variables, real_variables)); - } - } - else if (content == "END FOR") - { - if (ForLoop::Stack.empty()) - Log() << "END FOR with empty stack?"; - else - { - ForLoop &fl = ForLoop::Stack.back(); - if (fl.finished(r)) - ForLoop::Stack.pop_back(); - else - { - fl.increment(r); - if (fl.finished(r)) - ForLoop::Stack.pop_back(); - else - { - j = fl.start; // Move pointer back to start of the loop - continue; // To prevent skipping over this block which doesn't exist anymore - } - } - } - } - else if (content.find("INCLUDE ") == 0) - { - std::vector<Anope::string> tokens; - spacesepstream(content).GetTokens(tokens); - - if (tokens.size() != 2) - Log() << "Invalid INCLUDE in web template " << this->file_name; - else - { - reply.Write(finished); // Write out what we have currently so we insert this files contents here - finished.clear(); - - TemplateFileServer tfs(tokens[1]); - tfs.Serve(server, page_name, client, message, reply, r); - } - } - else - { - // If the if stack is empty or we are in a true statement - bool ifok = IfStack.empty() || IfStack.top(); - bool forok = ForLoop::Stack.empty() || !ForLoop::Stack.back().finished(r); - - if (ifok && forok) - { - const Anope::string &replacement = FindReplacement(r, content.substr(0, f - 1)); - finished += replacement; - } - } - - j += f; // Skip over this whole block - } - else - { - escaped = false; - - // If the if stack is empty or we are in a true statement - bool ifok = IfStack.empty() || IfStack.top(); - bool forok = ForLoop::Stack.empty() || !ForLoop::Stack.back().finished(r); - - if (ifok && forok) - finished += buf[j]; - } - } - - reply.Write(finished); - return; -} - diff --git a/modules/extra/webcpanel/template_fileserver.h b/modules/extra/webcpanel/template_fileserver.h deleted file mode 100644 index 0d2502e4f..000000000 --- a/modules/extra/webcpanel/template_fileserver.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * (C) 2003-2014 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#include "modules/httpd.h" - -/* A basic file server. Used for serving non-static non-binary content on disk. */ -class TemplateFileServer -{ - Anope::string file_name; - public: - struct Replacements : std::multimap<Anope::string, Anope::string> - { - Anope::string& operator[](const Anope::string &key) - { - return insert(std::make_pair(key, ""))->second; - } - }; - - TemplateFileServer(const Anope::string &f_n); - - void Serve(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, Replacements &); -}; - diff --git a/modules/extra/webcpanel/templates/default/chanserv/access.html b/modules/extra/webcpanel/templates/default/chanserv/access.html deleted file mode 100644 index c50434f8a..000000000 --- a/modules/extra/webcpanel/templates/default/chanserv/access.html +++ /dev/null @@ -1,77 +0,0 @@ -{INCLUDE header.html} -{INCLUDE chanserv/chanlist.html} - <div class="panel-heading">Access List</div> - <div class="panel-body"> - {FOR M IN MESSAGES} - <div class="alert alert-info"> - {M}<br> - </div> - {END FOR} - - {IF EQ ACCESS_LIST YES} - {IF EXISTS ACCESSES} - <table id="tableNSAccess" class="table table-hover"> - <thead> - <tr> - <th>Mask</th> - <th>Access</th> - <th>Creator</th> - <th></th> - </tr> - </thead> - <tbody> - {FOR MASK,ACCESS,CREATOR IN MASKS,ACCESSES,CREATORS} - <tr> - <td style="font-weight: bold;">{MASK}</td> - <td>{ACCESS}</td> - <td>{CREATOR}</td> - {IF EQ ACCESS_CHANGE YES} - <td><a href="/chanserv/access?channel={ESCAPED_CHANNEL}&mask={MASK}&del=1" class="btn btn-sm btn-danger">Delete</a></td> - {ELSE} - <td></td> - {END IF} - </tr> - {END FOR} - </tbody> - </table> - {ELSE} - <em>Access list is empty.</em> - {END IF} - - <hr> - - {IF EQ ACCESS_CHANGE YES} - <h4>Add an access entry</h4> - <form class="form-horizontal" method="post" action="/chanserv/access?channel={ESCAPED_CHANNEL}"> - <div class="form-group"> - <label class="control-label col-lg-2" for="mask">Mask:</label> - <div class="col-lg-6"> - <input class="form-control" type="text" name="mask" id="mask" placeholder="Mask must be in the form nick!user@host"> - </div> - </div> - <div class="form-group"> - <label class="control-label col-lg-2" for="access">Access:</label> - <div class="col-lg-6"> - <input class="form-control" type="text" name="access" id="access" placeholder="Access level"> - </div> - </div> - <div class="form-group"> - <label class="control-label col-lg-2" for="reason">Provider:</label> - <div class="col-lg-6"> - <select name="provider" class="form-control"> - {FOR PROVIDER IN PROVIDERS} - <option value="{PROVIDER}">{PROVIDER}</option> - {END FOR} - </select> - </div> - </div> - <div class="form-group"> - <div class="col-lg-offset-2 col-lg-6"> - <button type="submit" class="btn btn-primary">Send</button> - </div> - </div> - </form> - {END IF} - {END IF} - </div> -{INCLUDE footer.html} diff --git a/modules/extra/webcpanel/templates/default/chanserv/akick.html b/modules/extra/webcpanel/templates/default/chanserv/akick.html deleted file mode 100644 index ddfea546c..000000000 --- a/modules/extra/webcpanel/templates/default/chanserv/akick.html +++ /dev/null @@ -1,61 +0,0 @@ -{INCLUDE header.html} -{INCLUDE chanserv/chanlist.html} - <div class="panel-heading">Akick List</div> - <div class="panel-body"> - {FOR M IN MESSAGES} - <div class="alert alert-info"> - {M}<br> - </div> - {END FOR} - - {IF EQ AKICK YES} - {IF EXISTS MASKS} - <table id="tableNSAccess" class="table table-hover"> - <thead> - <tr> - <th>Mask</th> - <th>Reason</th> - <th>Creator</th> - <th></th> - </tr> - </thead> - <tbody> - {FOR MASK,REASON,CREATOR IN MASKS,REASONS,CREATORS} - <tr> - <td style="font-weight: bold;">{MASK}</td> - <td>{REASON}</td> - <td>{CREATOR}</td> - <td><a href="/chanserv/akick?channel={ESCAPED_CHANNEL}&mask={MASK}&del=1" class="btn btn-sm btn-danger">Delete</a></td> - </tr> - {END FOR} - </tbody> - </table> - {ELSE} - <em>Akick list is empty.</em> - {END IF} - - <hr> - - <h4>Add an akick entry</h4> - <form class="form-horizontal" method="post" action="/chanserv/akick?channel={ESCAPED_CHANNEL}"> - <div class="form-group"> - <label class="control-label col-lg-2" for="mask">Mask:</label> - <div class="col-lg-6"> - <input class="form-control" type="text" name="mask" id="mask" placeholder="Mask must be in the form nick!user@host"> - </div> - </div> - <div class="form-group"> - <label class="control-label col-lg-2" for="reason">Reason:</label> - <div class="col-lg-6"> - <input class="form-control" type="text" name="reason" id="reason" placeholder="Reason for AKICK"> - </div> - </div> - <div class="form-group"> - <div class="col-lg-offset-2 col-lg-6"> - <button type="submit" class="btn btn-primary">Send</button> - </div> - </div> - </form> - {END IF} - </div> -{INCLUDE footer.html} diff --git a/modules/extra/webcpanel/templates/default/chanserv/chanlist.html b/modules/extra/webcpanel/templates/default/chanserv/chanlist.html deleted file mode 100644 index 8f00f02ac..000000000 --- a/modules/extra/webcpanel/templates/default/chanserv/chanlist.html +++ /dev/null @@ -1,17 +0,0 @@ -<div class="panel-heading">Channels you have access in</div> -<div class="panel-body"> - {IF EXISTS CHANNEL_NAMES} - <div> - <h3 style="margin: -12px 0 20px 0;"><small>Choose a channel to access it's Settings, Access or Akick pages.</small></h3> - {FOR CH,ECH IN CHANNEL_NAMES,ESCAPED_CHANNEL_NAMES} - {IF EQ PAGE_NAME /chanserv/info} - <a href="set?channel={ECH}" class="btn btn-sm btn-primary {IF EQ ECH ESCAPED_CHANNEL}disabled{END IF}" style="margin-bottom: 4px;">{CH}</a> - {ELSE} - <a href="{PAGE_NAME}?channel={ECH}" class="btn btn-sm btn-primary {IF EQ ECH ESCAPED_CHANNEL}disabled{END IF}" style="margin-bottom: 4px;">{CH}</a> - {END IF} - {END FOR} - </div> - {ELSE} - <em>You don't have access in any channels.</em><br> - {END IF} -</div> diff --git a/modules/extra/webcpanel/templates/default/chanserv/drop.html b/modules/extra/webcpanel/templates/default/chanserv/drop.html deleted file mode 100644 index c28eb051a..000000000 --- a/modules/extra/webcpanel/templates/default/chanserv/drop.html +++ /dev/null @@ -1,32 +0,0 @@ -{INCLUDE header.html} -{INCLUDE chanserv/chanlist.html} - <div class="panel-heading">Channels you can drop</div> - <div class="panel-body"> - {FOR M IN MESSAGES} - <div class="alert alert-info"> - {M}<br> - </div> - {END FOR} - - {IF EXISTS CHANNEL_DROP} - <div class="alert alert-danger" style="margin-top: 15px; margin-bottom: 0; padding-bottom: 0;"> - <h4>Drop Channel <strong>{CHANNEL_DROP}</strong>?</h4> - <form class="form-horizontal" method="post" action="/chanserv/drop"> - <input type="hidden" value="{CHANNEL_DROP}" name="channel"> - <input type="hidden" value="yes" name="drop"> - <div class="form-group"> - <label class="control-label col-lg-4" for="confChan">Confirm channel name:</label> - <div class="col-lg-4"> - <input class="form-control" type="text" name="confChan" id="confChan" placeholder="This cannot be undone!"> - </div> - </div> - <div class="form-group"> - <div class="col-lg-offset-4 col-lg-4"> - <button type="submit" class="btn btn-danger">Drop</button> - </div> - </div> - </form> - </div> - {END IF} - </div> -{INCLUDE footer.html}
\ No newline at end of file diff --git a/modules/extra/webcpanel/templates/default/chanserv/main.html b/modules/extra/webcpanel/templates/default/chanserv/main.html deleted file mode 100644 index e77626f31..000000000 --- a/modules/extra/webcpanel/templates/default/chanserv/main.html +++ /dev/null @@ -1,3 +0,0 @@ -{INCLUDE header.html} -{INCLUDE chanserv/chanlist.html} -{INCLUDE footer.html} diff --git a/modules/extra/webcpanel/templates/default/chanserv/modes.html b/modules/extra/webcpanel/templates/default/chanserv/modes.html deleted file mode 100644 index 3c7fe7ab3..000000000 --- a/modules/extra/webcpanel/templates/default/chanserv/modes.html +++ /dev/null @@ -1,56 +0,0 @@ -{INCLUDE header.html} -{INCLUDE chanserv/chanlist.html} - <div class="panel-heading">Channel Mode List</div> - <div class="panel-body"> - {FOR M IN MESSAGES} - <div class="alert alert-info"> - {M}<br> - </div> - {END FOR} - - {IF EQ MODE YES} - {FOR LM IN LISTMODES} - <td><a href="/chanserv/modes?channel={ESCAPED_CHANNEL}&m={LM}" class="btn btn-sm btn-primary {IF EQ LM ESCAPED_MODE}disabled{END IF}">+{LM}</a></td> - {END FOR} - <br> - - {IF EXISTS MASKS} - <table id="tableNSAccess" class="table table-hover"> - <thead> - <tr> - <th>Mask</th> - <th></th> - </tr> - </thead> - <tbody> - {FOR MASK IN MASKS} - <tr> - <td style="font-weight: bold;">{MASK}</td> - <td><a href="/chanserv/modes?channel={ESCAPED_CHANNEL}&m={ESCAPED_MODE}&mask={MASK}&del=1" class="btn btn-sm btn-danger">Delete</a></td> - </tr> - {END FOR} - </tbody> - </table> - {ELSE} - <em>Nothing to display.</em> - {END IF} - - <hr> - - <h4>Set a new mode</h4> - <form class="form-horizontal" method="post" action="/chanserv/modes?channel={ESCAPED_CHANNEL}&m={ESCAPED_MODE}"> - <div class="form-group"> - <label class="control-label col-lg-2" for="mask">Mask:</label> - <div class="col-lg-6"> - <input class="form-control" type="text" name="mask" id="mask" placeholder="Mask must be in the form nick!user@host"> - </div> - </div> - <div class="form-group"> - <div class="col-lg-offset-2 col-lg-6"> - <button type="submit" class="btn btn-primary">Send</button> - </div> - </div> - </form> - {END IF} - </div> -{INCLUDE footer.html} diff --git a/modules/extra/webcpanel/templates/default/chanserv/set.html b/modules/extra/webcpanel/templates/default/chanserv/set.html deleted file mode 100644 index 050c37f69..000000000 --- a/modules/extra/webcpanel/templates/default/chanserv/set.html +++ /dev/null @@ -1,93 +0,0 @@ -{INCLUDE header.html} -{INCLUDE chanserv/chanlist.html} - <div class="panel-heading">Channel Information</div> - <div class="panel-body"> - {FOR M IN MESSAGES} - <div class="alert alert-info"> - {M}<br> - </div> - {END FOR} - - {IF EXISTS OKAY} - {IF EXISTS CAN_SET} - <form method="post" action="/chanserv/set?channel={CHANNEL_ESCAPED}"> - {END IF} - <table id="tableInfo" class="table table-hover"> - <tr> - <td>Channel Name</td> - <td>{CHANNEL}</td> - </tr> - {IF EXISTS FOUNDER} - <tr> - <td>Founder</td> - <td>{FOUNDER}</td> - </tr> - {END IF} - {IF EXISTS SUCCESSOR} - <tr> - <td>Succsesor</td> - <td>{SUCCESSOR}</td> - </tr> - {END IF} - <tr> - <td>Time registered</td> - <td>{TIME_REGISTERED}</td> - </tr> - <tr> - <td>Last used</td> - <td>{LAST_USED}</td> - </tr> - {IF EXISTS LAST_TOPIC} - <tr> - <td>Last topic</td> - <td>{LAST_TOPIC}</td> - </tr> - <tr> - <td>Set by</td> - <td>{LAST_TOPIC_SETTER}</td> - </tr> - {END IF} - {IF EXISTS CAN_SET} - <tr> - <td>Keep topic</td> - <td><input type="checkbox" name="keeptopic" value="on" {IF EXISTS KEEPTOPIC}checked{END IF}></td> - </tr> - <tr> - <td>Peace</td> - <td><input type="checkbox" name="peace" value="on" {IF EXISTS PEACE}checked{END IF}></td> - </tr> - <tr> - <td>Private</td> - <td><input type="checkbox" name="private" value="on" {IF EXISTS PRIVATE}checked{END IF}></td> - </tr> - <tr> - <td>Restricted</td> - <td><input type="checkbox" name="restricted" value="on" {IF EXISTS RESTRICTED}checked{END IF}></td> - </tr> - <tr> - <td>Secure</td> - <td><input type="checkbox" name="secure" value="on" {IF EXISTS SECURE}checked{END IF}></td> - </tr> - <tr> - <td>Secure Ops</td> - <td><input type="checkbox" name="secureops" value="on" {IF EXISTS SECUREOPS}checked{END IF}></td> - </tr> - <tr> - <td>Topic Lock</td> - <td><input type="checkbox" name="topiclock" value="on" {IF EXISTS TOPICLOCK}checked{END IF}></td> - </tr> - {IF EXISTS CAN_SET} - <tr> - <td></td> - <td><button type="submit" class="btn btn-primary">Save</button></td> - </tr> - {END IF} - {END IF} - </table> - - {IF EXISTS CAN_SET} - </form> - {END IF} - {END IF} - </div> -{INCLUDE footer.html} diff --git a/modules/extra/webcpanel/templates/default/confirm.html b/modules/extra/webcpanel/templates/default/confirm.html deleted file mode 100644 index f9f315fd3..000000000 --- a/modules/extra/webcpanel/templates/default/confirm.html +++ /dev/null @@ -1,51 +0,0 @@ -<!DOCTYPE html> -<!--[if IE 7]> <html lang="en" class="ie7"> <![endif]--> -<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]--> -<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]--> -<!--[if !IE]><!--> -<html lang="en"> - <!--<![endif]--> - <head> - <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"> - <link href="/static/style.css" media="screen" rel="stylesheet" type="text/css" /> - <!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]--> - - <title>{TITLE}</title> - </head> - <body> - <div id="frontPages" class="container"> - <div class="row"> - <div class="col-lg-offset-4 col-lg-4"> - <a href="/"> - <img src="/static/logo.png" class="img-responsive"> - </a> - <a href="/" class="btn btn-lg btn-default btn-block">Back Home</a> - - <h1 class="form-signin-heading">Register</h1> - - {IF EXISTS MESSAGES} - <div class="alert alert-warning"> - {FOR M IN MESSAGES} - {M}<br/> - {END FOR} - </div> - {END IF} - - <a href="/register" class="btn btn-lg btn-default btn-block">Retry</a> - </div> - </div> - - <br> - <div class="row"> - <div class="col-lg-offset-3 col-lg-6"> - <div class="footer text-center"> - Anope IRC Services - © 2013 Anope Team - <a href="http://anope.org">http://anope.org</a> - </div> - </div> - </div> - </div> - - <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> - <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> - </body> -</html> diff --git a/modules/extra/webcpanel/templates/default/cubes.png b/modules/extra/webcpanel/templates/default/cubes.png Binary files differdeleted file mode 100644 index d75208db7..000000000 --- a/modules/extra/webcpanel/templates/default/cubes.png +++ /dev/null diff --git a/modules/extra/webcpanel/templates/default/favicon.ico b/modules/extra/webcpanel/templates/default/favicon.ico Binary files differdeleted file mode 100644 index be735614a..000000000 --- a/modules/extra/webcpanel/templates/default/favicon.ico +++ /dev/null diff --git a/modules/extra/webcpanel/templates/default/footer.html b/modules/extra/webcpanel/templates/default/footer.html deleted file mode 100644 index 57794a9ff..000000000 --- a/modules/extra/webcpanel/templates/default/footer.html +++ /dev/null @@ -1,14 +0,0 @@ - <br> - </div> - </div> - </div> - <div class="row"> - <div class="col-lg-12"> - <div class="footer text-center"> - Anope IRC Services - © 2013 Anope Team - <a href="http://anope.org">http://anope.org</a> - </div> - </div> - </div> - </div> - </body> -</html>
\ No newline at end of file diff --git a/modules/extra/webcpanel/templates/default/header.html b/modules/extra/webcpanel/templates/default/header.html deleted file mode 100644 index 0ccf477c5..000000000 --- a/modules/extra/webcpanel/templates/default/header.html +++ /dev/null @@ -1,64 +0,0 @@ -<!DOCTYPE html> -<!--[if IE 7]> <html lang="en" class="ie7"> <![endif]--> -<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]--> -<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]--> -<!--[if !IE]><!--> -<html lang="en"> -<!--<![endif]--> - <head> - <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"> - <link href="/static/style.css" media="screen" rel="stylesheet" type="text/css" /> - - <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> - <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> - - <!--[if lt IE 9]> - <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.2/html5shiv.js"></script> - <script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.2.0/respond.js"></script> - <![endif]--> - - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> - <title>{TITLE}</title> - </head> - <body> - <div id="frontPages" class="container"> - <div class="navbar navbar-default"> - <span class="navbar-brand" style="margin-top: -1px">Anope Web <small>Control Panel</small></span> - <ul class="nav navbar-nav"> - {FOR CATEGORY_URL,CATEGORY_NAME IN CATEGORY_URLS,CATEGORY_NAMES} - <li - {IF EQ CATEGORY NickServ}{IF EQ CATEGORY_NAME NickServ}class="active"{END IF}{END IF} - {IF EQ CATEGORY ChanServ}{IF EQ CATEGORY_NAME ChanServ}class="active"{END IF}{END IF} - {IF EQ CATEGORY MemoServ}{IF EQ CATEGORY_NAME MemoServ}class="active"{END IF}{END IF} - {IF EQ CATEGORY HostServ}{IF EQ CATEGORY_NAME HostServ}class="active"{END IF}{END IF} - {IF EQ CATEGORY OperServ}{IF EQ CATEGORY_NAME OperServ}class="active"{END IF}{END IF}> - {IF EQ CATEGORY_NAME OperServ} - {IF EXISTS IS_OPER} - <a href="{CATEGORY_URL}">{CATEGORY_NAME}</a> - {END IF} - {ELSE} - <a href="{CATEGORY_URL}">{CATEGORY_NAME}</a> - {END IF} - </li> - {END FOR} - </ul> - <span id="loggedIn" class="pull-right"> - <span>Logged in as {ACCOUNT}</span> <a href="/logout">(Logout)</a> - </span> - </div> - - <div class="row"> - <div class="col-lg-3"> - <div id="navPanel" class="sidebar-nav-fixed"> - <div class="well" style="padding: 0;"> - <ul class="nav nav-list" style="padding: 10px;"> - {FOR SUBCATEGORY_URL,SUBCATEGORY_GET,SUBCATEGORY_NAME IN SUBCATEGORY_URLS,SUBCATEGORY_GETS,SUBCATEGORY_NAMES} - <li><a href="{SUBCATEGORY_URL}{SUBCATEGORY_GET}">{SUBCATEGORY_NAME}</a></li> - {END FOR} - </ul> - </div> - </div> - </div> - - <div class="col-lg-9"> - <div class="panel panel-default"> diff --git a/modules/extra/webcpanel/templates/default/hostserv/request.html b/modules/extra/webcpanel/templates/default/hostserv/request.html deleted file mode 100644 index f557244d1..000000000 --- a/modules/extra/webcpanel/templates/default/hostserv/request.html +++ /dev/null @@ -1,45 +0,0 @@ -{INCLUDE header.html} - <div class="panel-heading">vHost Information</div> - <div class="panel-body"> - {FOR M IN MESSAGES} - <div class="alert alert-info"> - {M}<br> - </div> - {END FOR} - - <table id="tableInfo" class="table table-hover"> - <tbody> - <tr> - <td>Your current vHost:</td> - <td> - {IF EXISTS VHOST} - {VHOST} - {ELSE} - <em>None</em> - {END IF} - </td> - <td></td> - </tr> - {IF EXISTS CAN_REQUEST} - <tr> - <td> - {IF EXISTS VHOST} - Request a new vHost - {ELSE} - Request a vHost - {END IF} - </td> - <form method="post" action="/hostserv/request"> - <td><input class="form-control" name="req"></td> - <td><button type="submit" class="btn btn-primary">Request</button></td> - </form> - </tr> - {ELSE} - <tr> - <td colspan="2" class="text-center"><strong>vHost requests are disabled on this network.</strong></td> - </tr> - {END IF} - </tbody> - </table> - </div> -{INCLUDE footer.html} diff --git a/modules/extra/webcpanel/templates/default/login.html b/modules/extra/webcpanel/templates/default/login.html deleted file mode 100644 index 6a0b6d7a9..000000000 --- a/modules/extra/webcpanel/templates/default/login.html +++ /dev/null @@ -1,55 +0,0 @@ -<!DOCTYPE html> -<!--[if IE 7]> <html lang="en" class="ie7"> <![endif]--> -<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]--> -<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]--> -<!--[if !IE]><!--> -<html lang="en"> - <!--<![endif]--> - <head> - <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"> - <link href="/static/style.css" media="screen" rel="stylesheet" type="text/css" /> - <!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]--> - - <title>{TITLE}</title> - </head> - <body> - <div id="frontPages" class="container"> - <div class="row"> - <div class="col-lg-offset-4 col-lg-4"> - <a href="/"> - <img src="/static/logo.png" class="img-responsive"> - </a> - - <h1 class="form-signin-heading">Login <small>to continue</small></h1> - - {IF EXISTS INVALID_LOGIN} - <div class="alert alert-danger"> - {INVALID_LOGIN} - </div> - {END IF} - - <form class="form-horizontal form-signin" action="/" method="post"> - <input type="text" name="username" class="form-control" placeholder="Username" required="required" autofocus - style="margin-bottom: -1px; border-bottom-left-radius: 0; border-bottom-right-radius: 0;"> - <input type="password" name="password" class="form-control" placeholder="Password" required="required" - style="margin-bottom: 10px; border-top-left-radius: 0; border-top-right-radius: 0;"> - <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button> - <a class="btn btn-lg btn-warning btn-block" href="/register">Register</a> - </form> - </div> - </div> - - <br> - <div class="row"> - <div class="col-lg-offset-3 col-lg-6"> - <div class="footer text-center"> - Anope IRC Services - © 2013 Anope Team - <a href="http://anope.org">http://anope.org</a> - </div> - </div> - </div> - </div> - - <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> - <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> - </body> -</html> diff --git a/modules/extra/webcpanel/templates/default/logo.png b/modules/extra/webcpanel/templates/default/logo.png Binary files differdeleted file mode 100644 index f7c2ff92a..000000000 --- a/modules/extra/webcpanel/templates/default/logo.png +++ /dev/null diff --git a/modules/extra/webcpanel/templates/default/memoserv/memos.html b/modules/extra/webcpanel/templates/default/memoserv/memos.html deleted file mode 100644 index b3b54d948..000000000 --- a/modules/extra/webcpanel/templates/default/memoserv/memos.html +++ /dev/null @@ -1,112 +0,0 @@ -{INCLUDE header.html} - <div class="panel-heading">Memos List</div> - <div class="panel-body"> - {FOR M IN MESSAGES} - <div class="alert alert-info"> - {M}<br> - </div> - {END FOR} - - {IF EXISTS NUMBER} - <script> - $("#tableInfoMemos").ready(function() \{ - $(".reply").click(function(e) \{ - e.preventDefault(); - var recv = $(this).attr('href'); - $("#receiver").val(recv); - $("#message").focus(); - \}); - \}); - </script> - - <script> - $(function () \{ - $('.table tbody tr td abbr').popover(); - \}); - </script> - - <table id="tableInfoMemos" class="table table-hover"> - <thead> - <th>Number</th> - <th>Sender</th> - <th>Message <small>(hover: Time)</small></th> - <th></th> - </thead> - <tbody> - {FOR I,S,T,TXT,U IN NUMBER,SENDER,TIME,TEXT,UNREAD} - {IF EQ U YES} - <tr class="read"> - {ELSE} - <tr class="unread"> - {END IF} - <td>{I}</td> - <td>{S}</td> - <td><abbr data-container="body" data-trigger="hover" data-placement="top" data-content="{T}">{TXT}</abbr></td> - <td style="text-align: right;" nowrap="nowrap"> - {IF EQ U YES} - <a class="label label-success reply" href="{S}" id="memo{I}">Reply</a> - <a class="label label-warning" href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&read=1">Mark as Read</a> - <a class="label label-danger" href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&del=1">Delete</a> - {ELSE} - <a class="label label-success reply" href="{S}" id="memo{I}">Reply</a> - <a class="label label-warning" href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&read=2">Mark as Unread</a> - <a class="label label-danger" href="/memoserv/memos?channel={ESCAPED_CHANNEL_NAME}&number={I}&del=1">Delete</a> - {END IF} - </td> - </tr> - {END FOR} - </tbody> - </table> - {ELSE} - <em>No memos to show.</em> - {END IF} - - <hr> - - <div class="row"> - <div class="col-lg-5"> - <h4>Memos for channel</h4> - {IF EXISTS CHANNEL_NAMES} - <div> - <ul id="channelList"> - {FOR CH,ECH IN CHANNEL_NAMES,ESCAPED_CHANNEL_NAMES} - <li><a href="/memoserv/memos?channel={ECH}">{CH}</a></li> - {END FOR} - </ul> - </div> - {ELSE} - <em>You don't have access in any channel</em><br> - {END IF} - - </div> - <div class="col-lg-7"> - <h4>Send a new Memo</h4> - <form class="form-horizontal" method="post" action="/memoserv/memos?channel={ESCAPED_CHANNEL}"> - <div class="form-group"> - <label class="control-label col-lg-2" for="receiver">Receiver:</label> - <div class="col-lg-10"> - <input class="form-control" type="text" name="receiver" id="receiver" placeholder="Nick or Channel" value=""> - </div> - </div> - <div class="form-group"> - <label class="control-label col-lg-2" for="message">Message:</label> - <div class="col-lg-10"> - <input class="form-control" type="text" name="message" id="message" placeholder="Your message here"> - </div> - </div> - <div class="form-group"> - <div class="col-lg-offset-2 col-lg-10"> - <button type="submit" class="btn btn-primary">Send</button> - </div> - </div> - </form> - </div> - </div> - - {IF EXISTS CMDR} - <div class="alert alert-info"> - {CMDR} - </div> - {END IF} - </div> -{INCLUDE footer.html} diff --git a/modules/extra/webcpanel/templates/default/nickserv/access.html b/modules/extra/webcpanel/templates/default/nickserv/access.html deleted file mode 100644 index d4be56279..000000000 --- a/modules/extra/webcpanel/templates/default/nickserv/access.html +++ /dev/null @@ -1,42 +0,0 @@ -{INCLUDE header.html} - <div class="panel-heading">Nick access list</div> - <div class="panel-body"> - {FOR M IN MESSAGES} - <div class="alert alert-info"> - {M}<br> - </div> - {END FOR} - - {IF EXISTS ACCESS} - <table id="tableNSAccess" class="table table-hover"> - <tbody> - {FOR A IN ACCESS} - <tr> - <td class="col-lg-4">{A}</td> - <td class="col-lg-8"><a href="/nickserv/access?mask={A}&del=1" class="btn btn-sm btn-danger">Delete</a></td> - </tr> - {END FOR} - </tbody> - </table> - {ELSE} - <em>Your access list is empty.</em> - {END IF} - - <hr> - - <h4>Add an access entry</h4> - <form class="form-horizontal" method="post" action="/nickserv/access"> - <div class="form-group"> - <label class="control-label col-lg-2" for="message">Hostmask:</label> - <div class="col-lg-5"> - <input class="form-control" type="text" name="message" id="message" placeholder="Mask must be in the form user@host"> - </div> - </div> - <div class="form-group"> - <div class="col-lg-offset-2 col-lg-5"> - <button type="submit" class="btn btn-primary">Add</button> - </div> - </div> - </form> - </div> -{INCLUDE footer.html} diff --git a/modules/extra/webcpanel/templates/default/nickserv/alist.html b/modules/extra/webcpanel/templates/default/nickserv/alist.html deleted file mode 100644 index f3b2e0124..000000000 --- a/modules/extra/webcpanel/templates/default/nickserv/alist.html +++ /dev/null @@ -1,23 +0,0 @@ -{INCLUDE header.html} - <div class="panel-heading">Channel access list</div> - <div class="panel-body"> - <table id="tableInfoNorm" class="table table-hover"> - <thead> - <tr> - <th>Number</th> - <th>Channel</th> - <th>Access</th> - </tr> - </thead> - <tbody> - {FOR N,C,A IN NUMBERS,CHANNELS,ACCESSES} - <tr> - <td>{N}</td> - <td>{C}</td> - <td>{A}</td> - </tr> - {END FOR} - </tbody> - </table> - </div> -{INCLUDE footer.html} diff --git a/modules/extra/webcpanel/templates/default/nickserv/cert.html b/modules/extra/webcpanel/templates/default/nickserv/cert.html deleted file mode 100644 index 6d41a44b4..000000000 --- a/modules/extra/webcpanel/templates/default/nickserv/cert.html +++ /dev/null @@ -1,42 +0,0 @@ -{INCLUDE header.html} - <div class="panel-heading">Your certificate fingerprints</div> - <div class="panel-body"> - {FOR M IN MESSAGES} - <div class="alert alert-info"> - {M}<br> - </div> - {END FOR} - - {IF EXISTS CERTS} - <table id="tableNSAccess" class="table table-hover"> - <tbody> - {FOR CERT IN CERTS} - <tr> - <td>{CERT}</td> - <td><a href="/nickserv/cert?mask={CERT}&del=1" class="btn btn-sm btn-danger">Delete</a></td> - </tr> - {END FOR} - </tbody> - </table> - {ELSE} - <em>Certificates list is empty.</em> - {END IF} - - <hr> - - <h4>Add a certificate fingerprint</h4> - <form class="form-horizontal" method="post" action="/nickserv/cert"> - <div class="form-group"> - <label class="control-label col-lg-2" for="certfp">Certificate:</label> - <div class="col-lg-5"> - <input class="form-control" type="text" name="certfp" id="certfp" placeholder="Your certificate"> - </div> - </div> - <div class="form-group"> - <div class="col-lg-offset-2 col-lg-5"> - <button type="submit" class="btn btn-primary">Add</button> - </div> - </div> - </form> - </div> -{INCLUDE footer.html} diff --git a/modules/extra/webcpanel/templates/default/nickserv/info.html b/modules/extra/webcpanel/templates/default/nickserv/info.html deleted file mode 100644 index 667c8b370..000000000 --- a/modules/extra/webcpanel/templates/default/nickserv/info.html +++ /dev/null @@ -1,72 +0,0 @@ -{INCLUDE header.html} - <div class="panel-heading">Your account information</div> - <div class="panel-body"> - {FOR M IN ERRORS} - <div class="alert alert-danger"> - {M}<br> - </div> - {END FOR} - - {FOR M IN MESSAGES} - <div class="alert alert-info"> - {M}<br> - </div> - {END FOR} - - <form method="post" action="/nickserv/info"> - <table id="tableInfo" class="table table-hover"> - <tbody> - <tr> - <td>Account:</td> - <td>{DISPLAY}</td> - </tr> - {IF EXISTS EMAIL} - <tr> - <td>E-mail:</td> - <td>{EMAIL}</td> - </tr> - {END IF} - <tr> - <td>Time registered:</td> - <td>{TIME_REGISTERED}</td> - </tr> - {IF EXISTS VHOST} - <tr> - <td>Vhost:</td> - <td>{VHOST}</td> - </tr> - {END IF} - <tr> - <td>Greet:</td> - <td><input name="greet" value="{GREET}" class="form-control input-sm"></td> - </tr> - <tr> - <td>Auto op:</td> - <td><input type="checkbox" name="autoop" value="on" {IF EXISTS AUTOOP}checked{END IF}></td> - </tr> - <tr> - <td>Private:</td> - <td><input type="checkbox" name="private" value="on" {IF EXISTS PRIVATE}checked{END IF}></td> - </tr> - <tr> - <td>Secure:</td> - <td><input type="checkbox" name="secure" value="on" {IF EXISTS SECURE}checked{END IF}></td> - </tr> - <tr> - <td>Kill:</td> - <td> - <select name="kill" class="form-control input-sm"> - <option value="on" {IF EXISTS KILL_ON}selected{END IF}>On</option> - <option value="quick" {IF EXISTS KILL_QUICK}selected{END IF}>Quick</option> - <option value="off" {IF EXISTS KILL_OFF}selected{END IF}>Off</option> - </select> - </td> - </tr> - </tbody> - </table> - <div class="text-center"> - <button type="submit" class="btn btn-lg btn-primary">Save</button> - </div> - </form> - </div> -{INCLUDE footer.html} diff --git a/modules/extra/webcpanel/templates/default/operserv/akill.html b/modules/extra/webcpanel/templates/default/operserv/akill.html deleted file mode 100644 index ffc73f8e4..000000000 --- a/modules/extra/webcpanel/templates/default/operserv/akill.html +++ /dev/null @@ -1,77 +0,0 @@ -{INCLUDE header.html} - <div class="panel-heading">Akill List</div> - <div class="panel-body"> - {IF EXISTS NOACCESS} - <h2>Access denied.</h2> - {ELSE} - - {FOR M IN MESSAGES} - <div class="alert alert-info"> - {M}<br> - </div> - {END FOR} - - <script> - $(function () \{ - $('.table tbody tr td abbr').popover(); - \}); - </script> - - {IF EXISTS AKILLS} - <em>{AKILLS}</em> - {ELSE} - <table id="tableNSAccess" class="table table-hover"> - <thead> - <tr> - <th>Number</th> - <th>Hostmask <small>(hover: Reason)</small></th> - <th>Expires <small>(hover: Set Date)</small></th> - <th>Setter</th> - <th></th> - </tr> - </thead> - <tbody> - {FOR N,H,S,T,E,R IN NUMBER,HOST,SETTER,TIME,EXPIRE,REASON} - <tr> - <td>{N}</td> - <td><abbr data-container="body" data-trigger="hover" data-placement="top" data-content="{R}">{H}</abbr></td> - <td><abbr data-container="body" data-trigger="hover" data-placement="top" data-content="{T}">{E}</abbr></td> - <td>{S}</td> - <td><a href="/operserv/akill?&number={N}&del=1" class="btn btn-sm btn-danger">Delete</a></td> - </tr> - {END FOR} - </tbody> - </table> - {END IF} - - <hr> - - <h4>Add a new Akill</h4> - <form class="form-horizontal" method="post" action="/operserv/akill"> - <div class="form-group"> - <label class="control-label col-lg-2" for="mask">HostMask:</label> - <div class="col-lg-6"> - <input class="form-control" type="text" name="mask" id="mask" placeholder="Mask must be in the form nick!user@host"> - </div> - </div> - <div class="form-group"> - <label class="control-label col-lg-2" for="expiry">Expiry:</label> - <div class="col-lg-6"> - <input class="form-control" type="text" name="expiry" id="expiry" placeholder="Expire time"> - </div> - </div> - <div class="form-group"> - <label class="control-label col-lg-2" for="reason">Message:</label> - <div class="col-lg-6"> - <input class="form-control" type="text" name="reason" id="reason" placeholder="Reason for AKILL"> - </div> - </div> - <div class="form-group"> - <div class="col-lg-offset-2 col-lg-6"> - <button type="submit" class="btn btn-primary">Send</button> - </div> - </div> - </form> - {END IF} - </div> -{INCLUDE footer.html} diff --git a/modules/extra/webcpanel/templates/default/register.html b/modules/extra/webcpanel/templates/default/register.html deleted file mode 100644 index bebf4e276..000000000 --- a/modules/extra/webcpanel/templates/default/register.html +++ /dev/null @@ -1,65 +0,0 @@ -<!DOCTYPE html> -<!--[if IE 7]> <html lang="en" class="ie7"> <![endif]--> -<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]--> -<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]--> -<!--[if !IE]><!--> -<html lang="en"> - <!--<![endif]--> - <head> - <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"> - <link href="/static/style.css" media="screen" rel="stylesheet" type="text/css" /> - <!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]--> - - <title>{TITLE}</title> - </head> - <body> - <div id="frontPages" class="container"> - <div class="row"> - <div class="col-lg-offset-4 col-lg-4"> - <a href="/"> - <img src="/static/logo.png" class="img-responsive"> - </a> - <a href="/" class="btn btn-lg btn-default btn-block">Back Home</a> - - <h1 class="form-signin-heading">Register</h1> - - {IF EXISTS MESSAGES} - <div class="alert alert-danger"> - {MESSAGES} - </div> - {END IF} - - <form class="form-horizontal form-signin" action="/confirm" method="post"> - <input type="text" name="username" class="form-control" placeholder="Username" required="required" autofocus - style="margin-bottom: -1px; border-bottom-left-radius: 0; border-bottom-right-radius: 0;"> - <input type="password" name="password" class="form-control" placeholder="Password" required="required" - style="margin-bottom: -1px; border-radius: 0;"> - - {IF EXISTS FORCE_EMAIL} - <input type="email" name="email" class="form-control" placeholder="Email" required="required" - style="margin-bottom: 15px; border-top-left-radius: 0; border-top-right-radius: 0;"> - {ELSE} - <h4>Optional</h4> - <input type="email" name="email" class="form-control" placeholder="Email" - style="margin-bottom: 15px;"> - {END IF} - - <button class="btn btn-lg btn-warning btn-block" type="submit">Register</button> - </form> - </div> - </div> - - <br> - <div class="row"> - <div class="col-lg-offset-3 col-lg-6"> - <div class="footer text-center"> - Anope IRC Services - © 2013 Anope Team - <a href="http://anope.org">http://anope.org</a> - </div> - </div> - </div> - </div> - - <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> - <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> - </body> -</html>
\ No newline at end of file diff --git a/modules/extra/webcpanel/templates/default/style.css b/modules/extra/webcpanel/templates/default/style.css deleted file mode 100644 index e425c3d8c..000000000 --- a/modules/extra/webcpanel/templates/default/style.css +++ /dev/null @@ -1,166 +0,0 @@ -@import url(//fonts.googleapis.com/css?family=Open+Sans:300,400); -@import url(//fonts.googleapis.com/css?family=Port+Lligat+Slab); - -*, html, body, h1, h2, h3, h4, div, p, span, a, button { - font-family: 'Open Sans', sans-serif; -} -body { - background-color: #eee; - background-image: url('/static/cubes.png'); -} - -/* RANDOM STUFF */ -#frontPages { - padding-top: 20px; -} - -h2 { - margin: 0 0 10px 0; -} -h4 { - margin-top: 30px; -} -.popover { - max-width: 450px; - -webkit-box-shadow: 0 1px 10px rgba(0, 0, 0, 0.8); - box-shadow: 0 1px 10px rgba(0, 0, 0, 0.8); -} - -.label { - font-size: 13px; - font-weight: normal; -} - -.label-info { - background-color: #4EA4EE; -} - -.label-info[href]:hover, .label-info[href]:focus { - background-color: #428BCA; -} - -/* LOGIN FORM */ -.form-signin .form-signin-heading, .form-signin .checkbox { - margin-bottom: 10px; -} -.form-signin .checkbox { - font-weight: normal; -} -.form-signin .form-control { - position: relative; - font-size: 16px; - height: auto; - padding: 10px; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} -.form-signin .form-control:focus { - z-index: 2; -} -/* FOOTER */ -.footer { - margin-top: 20px; -} - -/* Control Panel */ -.panel-default .panel-heading { - font-size: 24px; -} -#loggedIn { - margin: 15px 15px 0 0; -} - -#navPanel { - margin: 0; - padding: 0; -} -.table thead > tr:first-child > th, .table tbody > tr:first-child > th, .table tfoot > tr:first-child > th, .table thead > tr:first-child > td, .table tbody > tr:first-child > td, .table tfoot > tr:first-child > td { - vertical-align: top; - border-top: 0; -} -#tableInfo td { - vertical-align: middle; -} -#tableInfo td:first-child { - font-weight: bold; - padding-right: 10px; - text-align: right; - width: 25%; -} - -#tableInfoNorm td { - vertical-align: middle; -} -#tableInfoNorm td:first-child { - font-weight: bold; - padding-right: 10px; -} - -#tableInfoMemos td { - vertical-align: top; -} -#tableInfoMemos td:first-child { - font-weight: bold; - padding-right: 10px; -} -#tableInfoMemos th small { - font-weight: normal; -} - -#tableNSAccess td { - vertical-align: middle; -} -#tableNSAccess td:first-child { - padding-right: 10px; - text-align: left; -} -#tableNSAccess td:last-child { - padding-right: 10px; - text-align: right; -} -#tableNSAccess th small { - font-weight: normal; -} - -#channelList li { - margin-top: 10px; -} - -/* NAVBAR */ -.navbar, .well { - background-color: white; -} - -.navbar { - -webkit-box-shadow: 0 8px 6px -8px black; - -moz-box-shadow: 0 8px 6px -8px black; - box-shadow: 0 8px 6px -8px black; -} -.navbar-brand { - font-size: 25px; -} -.navbar-brand, .navbar-brand small { - font-family: 'Port Lligat Slab', serif; -} - -.navbar-default .nav { - margin-bottom: -1px; -} - -.navbar-default .nav > li > a { - color: #428BCA; -} - -.navbar-default .nav > li > a:hover, .navbar-default .nav > li > a:focus { - color: #428BCA; - border-top: 3px solid #0082D9; - margin-top: -3px; -} - -.navbar-default .nav > li.active > a, .navbar-default .nav > li.active > a:hover, .navbar-default .nav > li.active > a:focus { - color: #428BCA; - background-color: transparent; - background-color: rgba(66, 139, 202, 0.1); - border-bottom-color: transparent; -} diff --git a/modules/extra/webcpanel/webcpanel.cpp b/modules/extra/webcpanel/webcpanel.cpp deleted file mode 100644 index 0c1fc3903..000000000 --- a/modules/extra/webcpanel/webcpanel.cpp +++ /dev/null @@ -1,270 +0,0 @@ -/* - * (C) 2003-2014 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#include "webcpanel.h" - -Module *me; -Anope::string provider_name, template_name, template_base, page_title; - -class ModuleWebCPanel : public Module -{ - ServiceReference<HTTPProvider> provider; - Panel panel; - PrimitiveExtensibleItem<Anope::string> id, ip; - - StaticFileServer style_css, logo_png, cubes_png, favicon_ico; - - WebCPanel::Index index; - WebCPanel::Logout logout; - WebCPanel::Register _register; - WebCPanel::Confirm confirm; - - WebCPanel::NickServ::Info nickserv_info; - WebCPanel::NickServ::Cert nickserv_cert; - WebCPanel::NickServ::Access nickserv_access; - WebCPanel::NickServ::Alist nickserv_alist; - - WebCPanel::ChanServ::Info chanserv_info; - WebCPanel::ChanServ::Set chanserv_set; - WebCPanel::ChanServ::Access chanserv_access; - WebCPanel::ChanServ::Akick chanserv_akick; - WebCPanel::ChanServ::Modes chanserv_modes; - WebCPanel::ChanServ::Drop chanserv_drop; - - WebCPanel::MemoServ::Memos memoserv_memos; - - WebCPanel::HostServ::Request hostserv_request; - - WebCPanel::OperServ::Akill operserv_akill; - - - public: - ModuleWebCPanel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), - panel(this, "webcpanel"), id(this, "webcpanel_id"), ip(this, "webcpanel_ip"), - style_css("style.css", "/static/style.css", "text/css"), logo_png("logo.png", "/static/logo.png", "image/png"), cubes_png("cubes.png", "/static/cubes.png", "image/png"), favicon_ico("favicon.ico", "/favicon.ico", "image/x-icon"), - index("/"), logout("/logout"), _register("/register"), confirm("/confirm"), - nickserv_info("NickServ", "/nickserv/info"), nickserv_cert("NickServ", "/nickserv/cert"), nickserv_access("NickServ", "/nickserv/access"), nickserv_alist("NickServ", "/nickserv/alist"), - chanserv_info("ChanServ", "/chanserv/info"), chanserv_set("ChanServ", "/chanserv/set"), chanserv_access("ChanServ", "/chanserv/access"), chanserv_akick("ChanServ", "/chanserv/akick"), - chanserv_modes("ChanServ", "/chanserv/modes"), chanserv_drop("ChanServ", "/chanserv/drop"), memoserv_memos("MemoServ", "/memoserv/memos"), hostserv_request("HostServ", "/hostserv/request"), - operserv_akill("OperServ", "/operserv/akill") - { - - me = this; - - Configuration::Block *block = Config->GetModule(this); - provider_name = block->Get<const Anope::string>("server", "httpd/main"); - template_name = block->Get<const Anope::string>("template", "default"); - template_base = Anope::DataDir + "/modules/webcpanel/templates/" + template_name; - page_title = block->Get<const Anope::string>("title", "Anope IRC Services"); - - provider = ServiceReference<HTTPProvider>("HTTPProvider", provider_name); - if (!provider) - throw ModuleException("Unable to find HTTPD provider. Is m_httpd loaded?"); - - provider->RegisterPage(&this->style_css); - provider->RegisterPage(&this->logo_png); - provider->RegisterPage(&this->cubes_png); - provider->RegisterPage(&this->favicon_ico); - - provider->RegisterPage(&this->index); - provider->RegisterPage(&this->logout); - provider->RegisterPage(&this->_register); - provider->RegisterPage(&this->confirm); - - BotInfo *NickServ = Config->GetClient("NickServ"); - if (NickServ) - { - Section s; - s.name = NickServ->nick; - - SubSection ss; - ss.name = "Information"; - ss.url = "/nickserv/info"; - s.subsections.push_back(ss); - provider->RegisterPage(&this->nickserv_info); - - if (IRCD && IRCD->CanCertFP) - { - ss.name = "SSL Certificates"; - ss.url = "/nickserv/cert"; - s.subsections.push_back(ss); - provider->RegisterPage(&this->nickserv_cert); - } - - ss.name = "Access"; - ss.url = "/nickserv/access"; - s.subsections.push_back(ss); - provider->RegisterPage(&this->nickserv_access); - - ss.name = "AList"; - ss.url = "/nickserv/alist"; - s.subsections.push_back(ss); - provider->RegisterPage(&this->nickserv_alist); - - panel.sections.push_back(s); - } - - BotInfo *ChanServ = Config->GetClient("ChanServ"); - if (ChanServ) - { - Section s; - s.name = ChanServ->nick; - - SubSection ss; - ss.name = "Channels"; - ss.url = "/chanserv/info"; - s.subsections.push_back(ss); - provider->RegisterPage(&this->chanserv_info); - - ss.name = "Settings"; - ss.url = "/chanserv/set"; - s.subsections.push_back(ss); - provider->RegisterPage(&this->chanserv_set); - - ss.name = "Access"; - ss.url = "/chanserv/access"; - s.subsections.push_back(ss); - provider->RegisterPage(&this->chanserv_access); - - ss.name = "Akick"; - ss.url = "/chanserv/akick"; - s.subsections.push_back(ss); - provider->RegisterPage(&this->chanserv_akick); - - ss.name = "Modes"; - ss.url = "/chanserv/modes"; - s.subsections.push_back(ss); - provider->RegisterPage(&this->chanserv_modes); - - ss.name = "Drop"; - ss.url = "/chanserv/drop"; - s.subsections.push_back(ss); - provider->RegisterPage(&this->chanserv_drop); - - panel.sections.push_back(s); - } - - BotInfo *MemoServ = Config->GetClient("MemoServ"); - if (MemoServ) - { - Section s; - s.name = MemoServ->nick; - - SubSection ss; - ss.name = "Memos"; - ss.url = "/memoserv/memos"; - s.subsections.push_back(ss); - provider->RegisterPage(&this->memoserv_memos); - - panel.sections.push_back(s); - } - - BotInfo *HostServ = Config->GetClient("HostServ"); - if (HostServ) - { - Section s; - s.name = HostServ->nick; - - SubSection ss; - ss.name = "vHost Request"; - ss.url = "/hostserv/request"; - s.subsections.push_back(ss); - provider->RegisterPage(&this->hostserv_request); - - panel.sections.push_back(s); - } - - BotInfo *OperServ = Config->GetClient("OperServ"); - if (OperServ) - { - Section s; - s.name = OperServ->nick; - - SubSection ss; - ss.name = "Akill"; - ss.url = "/operserv/akill"; - s.subsections.push_back(ss); - provider->RegisterPage(&this->operserv_akill); - - panel.sections.push_back(s); - } - } - - ~ModuleWebCPanel() - { - if (provider) - { - provider->UnregisterPage(&this->style_css); - provider->UnregisterPage(&this->logo_png); - provider->UnregisterPage(&this->cubes_png); - provider->UnregisterPage(&this->favicon_ico); - - provider->UnregisterPage(&this->index); - provider->UnregisterPage(&this->logout); - provider->UnregisterPage(&this->_register); - provider->UnregisterPage(&this->confirm); - - provider->UnregisterPage(&this->nickserv_info); - provider->UnregisterPage(&this->nickserv_cert); - provider->UnregisterPage(&this->nickserv_access); - provider->UnregisterPage(&this->nickserv_alist); - - provider->UnregisterPage(&this->chanserv_info); - provider->UnregisterPage(&this->chanserv_set); - provider->UnregisterPage(&this->chanserv_access); - provider->UnregisterPage(&this->chanserv_akick); - provider->UnregisterPage(&this->chanserv_modes); - provider->UnregisterPage(&this->chanserv_drop); - - provider->UnregisterPage(&this->memoserv_memos); - - provider->UnregisterPage(&this->hostserv_request); - - provider->UnregisterPage(&this->operserv_akill); - } - } -}; - -namespace WebPanel -{ - void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, const std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key) - { - ServiceReference<Command> cmd("Command", c); - if (!cmd) - { - r[key] = "Unable to find command " + c; - return; - } - - BotInfo *bi = Config->GetClient(service); - if (!bi) - { - if (BotListByNick->empty()) - return; - bi = BotListByNick->begin()->second; // Pick one... - } - - struct MyComandReply : CommandReply - { - TemplateFileServer::Replacements &re; - const Anope::string &k; - - MyComandReply(TemplateFileServer::Replacements &_r, const Anope::string &_k) : re(_r), k(_k) { } - - void SendMessage(BotInfo *source, const Anope::string &msg) anope_override - { - re[k] = msg; - } - } - my_reply(r, key); - - CommandSource source(user, NULL, nc, &my_reply, bi); - cmd->Execute(source, params); - } -} - -MODULE_INIT(ModuleWebCPanel) diff --git a/modules/extra/webcpanel/webcpanel.h b/modules/extra/webcpanel/webcpanel.h deleted file mode 100644 index 7e4b5a556..000000000 --- a/modules/extra/webcpanel/webcpanel.h +++ /dev/null @@ -1,178 +0,0 @@ -/* - * (C) 2003-2014 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#include "module.h" -#include "modules/httpd.h" - -#include "static_fileserver.h" -#include "template_fileserver.h" - -extern Module *me; - -extern Anope::string provider_name, template_name, template_base, page_title; - -struct SubSection -{ - Anope::string name; - Anope::string url; -}; - -struct Section -{ - Anope::string name; - std::vector<SubSection> subsections; -}; - -/* An interface for this webpanel used by other modules */ -class Panel : public Section, public Service -{ - public: - Panel(Module *c, const Anope::string &n) : Service(c, "Panel", n) { } - - std::vector<Section> sections; - - NickAlias *GetNickFromSession(HTTPClient *client, HTTPMessage &msg) - { - if (!client) - return NULL; - - const Anope::string &acc = msg.cookies["account"], &id = msg.cookies["id"]; - - if (acc.empty() || id.empty()) - return NULL; - - NickAlias *na = NickAlias::Find(acc); - if (na == NULL) - return NULL; - - Anope::string *n_id = na->GetExt<Anope::string>("webcpanel_id"), *n_ip = na->GetExt<Anope::string>("webcpanel_ip"); - if (n_id == NULL || n_ip == NULL) - return NULL; - else if (id != *n_id) - return NULL; - else if (client->GetIP() != *n_ip) - return NULL; - else - return na; - } -}; - -class WebPanelPage : public HTTPPage -{ - public: - WebPanelPage(const Anope::string &u, const Anope::string &ct = "text/html") : HTTPPage(u, ct) - { - } - - virtual bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) = 0; -}; - -class WebPanelProtectedPage : public WebPanelPage -{ - Anope::string category; - - public: - WebPanelProtectedPage(const Anope::string &cat, const Anope::string &u, const Anope::string &ct = "text/html") : WebPanelPage(u, ct), category(cat) - { - } - - bool OnRequest(HTTPProvider *provider, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) anope_override anope_final - { - ServiceReference<Panel> panel("Panel", "webcpanel"); - NickAlias *na; - - if (!panel || !(na = panel->GetNickFromSession(client, message))) - { - reply.error = HTTP_FOUND; - reply.headers["Location"] = Anope::string("http") + (provider->IsSSL() ? "s" : "") + "://" + message.headers["Host"] + "/"; - return true; // Access denied - } - - TemplateFileServer::Replacements replacements; - - replacements["TITLE"] = page_title; - replacements["ACCOUNT"] = na->nc->display; - replacements["PAGE_NAME"] = page_name; - replacements["CATEGORY"] = category; - if (na->nc->IsServicesOper()) - replacements["IS_OPER"]; - - Anope::string sections, get; - - for (std::map<Anope::string, Anope::string>::iterator it = message.get_data.begin(), it_end = message.get_data.end(); it != it_end; ++it) - if (this->GetData().count(it->first) > 0) - get += "&" + it->first + "=" + HTTPUtils::URLEncode(it->second); - if (get.empty() == false) - get = "?" + get.substr(1); - - Section *ns = NULL; - for (unsigned i = 0; i < panel->sections.size(); ++i) - { - Section& s = panel->sections[i]; - if (s.name == this->category) - ns = &s; - replacements["CATEGORY_URLS"] = s.subsections[0].url; - replacements["CATEGORY_NAMES"] = s.name; - } - - if (ns) - { - sections = ""; - for (unsigned i = 0; i < ns->subsections.size(); ++i) - { - SubSection& ss = ns->subsections[i]; - replacements["SUBCATEGORY_URLS"] = ss.url; - replacements["SUBCATEGORY_GETS"] = get; - replacements["SUBCATEGORY_NAMES"] = ss.name; - } - } - - return this->OnRequest(provider, page_name, client, message, reply, na, replacements); - } - - virtual bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) = 0; - - /* What get data should be appended to links in the navbar */ - virtual std::set<Anope::string> GetData() { return std::set<Anope::string>(); } -}; - -namespace WebPanel -{ - /** Run a command - * @param User name to run command as, probably nc->display unless nc == NULL - * @param nc Nick core to run command from - * @param service Service for source.owner and source.service - * @param c Command to run (as a service name) - * @param params Command parameters - * @param r Replacements, reply from command goes back here into key - * @param key The key to put the replies into r - */ - extern void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, const std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES"); -} - -#include "pages/index.h" -#include "pages/logout.h" -#include "pages/register.h" -#include "pages/confirm.h" - -#include "pages/nickserv/info.h" -#include "pages/nickserv/cert.h" -#include "pages/nickserv/access.h" -#include "pages/nickserv/alist.h" - -#include "pages/chanserv/info.h" -#include "pages/chanserv/set.h" -#include "pages/chanserv/access.h" -#include "pages/chanserv/akick.h" -#include "pages/chanserv/modes.h" -#include "pages/chanserv/drop.h" - -#include "pages/memoserv/memos.h" - -#include "pages/hostserv/request.h" - -#include "pages/operserv/akill.h" |