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 | |
| parent | 072202c181943901c727782e64881adadf13d7dd (diff) | |
Move modules out of extras that dont have external dependencies
Diffstat (limited to 'modules/extra')
71 files changed, 109 insertions, 5029 deletions
diff --git a/modules/extra/m_httpd.cpp b/modules/extra/m_httpd.cpp deleted file mode 100644 index e08452d81..000000000 --- a/modules/extra/m_httpd.cpp +++ /dev/null @@ -1,474 +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 "modules/ssl.h" - -static Anope::string BuildDate() -{ - char timebuf[64]; - struct tm *tm = localtime(&Anope::CurTime); - strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S %Z", tm); - return timebuf; -} - -static Anope::string GetStatusFromCode(HTTPError err) -{ - switch (err) - { - case HTTP_ERROR_OK: - return "200 OK"; - case HTTP_FOUND: - return "302 Found"; - case HTTP_BAD_REQUEST: - return "400 Bad Request"; - case HTTP_PAGE_NOT_FOUND: - return "404 Not Found"; - case HTTP_NOT_SUPPORTED: - return "505 HTTP Version Not Supported"; - } - - return "501 Not Implemented"; -} - -class MyHTTPClient : public HTTPClient -{ - HTTPProvider *provider; - HTTPMessage message; - bool header_done, served; - Anope::string page_name; - Reference<HTTPPage> page; - Anope::string ip; - - unsigned content_length; - - enum - { - ACTION_NONE, - ACTION_GET, - ACTION_POST - } action; - - void Serve() - { - if (this->served) - return; - this->served = true; - - if (!this->page) - { - this->SendError(HTTP_PAGE_NOT_FOUND, "Page not found"); - return; - } - - if (this->ip == this->provider->ext_ip) - { - for (unsigned i = 0; i < this->provider->ext_headers.size(); ++i) - { - const Anope::string &token = this->provider->ext_headers[i]; - - if (this->message.headers.count(token)) - { - this->ip = this->message.headers[token]; - Log(LOG_DEBUG, "httpd") << "m_httpd: IP for connection " << this->GetFD() << " changed to " << this->ip; - break; - } - } - } - - Log(LOG_DEBUG, "httpd") << "m_httpd: Serving page " << this->page_name << " to " << this->ip; - - HTTPReply reply; - reply.content_type = this->page->GetContentType(); - - if (this->page->OnRequest(this->provider, this->page_name, this, this->message, reply)) - this->SendReply(&reply); - } - - public: - time_t created; - - MyHTTPClient(HTTPProvider *l, int f, const sockaddrs &a) : Socket(f, l->IsIPv6()), HTTPClient(l, f, a), provider(l), header_done(false), served(false), ip(a.addr()), content_length(0), action(ACTION_NONE), created(Anope::CurTime) - { - Log(LOG_DEBUG, "httpd") << "Accepted connection " << f << " from " << a.addr(); - } - - ~MyHTTPClient() - { - Log(LOG_DEBUG, "httpd") << "Closing connection " << this->GetFD() << " from " << this->ip; - } - - /* Close connection once all data is written */ - bool ProcessWrite() anope_override - { - return !BinarySocket::ProcessWrite() || this->write_buffer.empty() ? false : true; - } - - const Anope::string GetIP() anope_override - { - return this->ip; - } - - bool Read(const char *buffer, size_t l) anope_override - { - message.content.append(buffer, l); - - for (size_t nl; !this->header_done && (nl = message.content.find('\n')) != Anope::string::npos;) - { - Anope::string token = message.content.substr(0, nl).trim(); - message.content = message.content.substr(nl + 1); - - if (token.empty()) - this->header_done = true; - else - this->Read(token); - } - - if (!this->header_done) - return true; - - if (this->message.content.length() >= this->content_length) - { - sepstream sep(this->message.content, '&'); - Anope::string token; - - while (sep.GetToken(token)) - { - size_t sz = token.find('='); - if (sz == Anope::string::npos || !sz || sz + 1 >= token.length()) - continue; - this->message.post_data[token.substr(0, sz)] = HTTPUtils::URLDecode(token.substr(sz + 1)); - Log(LOG_DEBUG_2) << "HTTP POST from " << this->clientaddr.addr() << ": " << token.substr(0, sz) << ": " << this->message.post_data[token.substr(0, sz)]; - } - - this->Serve(); - } - - return true; - } - - bool Read(const Anope::string &buf) - { - Log(LOG_DEBUG_2) << "HTTP from " << this->clientaddr.addr() << ": " << buf; - - if (this->action == ACTION_NONE) - { - std::vector<Anope::string> params; - spacesepstream(buf).GetTokens(params); - - if (params.empty() || (params[0] != "GET" && params[0] != "POST")) - { - this->SendError(HTTP_BAD_REQUEST, "Unknown operation"); - return true; - } - - if (params.size() != 3) - { - this->SendError(HTTP_BAD_REQUEST, "Invalid parameters"); - return true; - } - - if (params[0] == "GET") - this->action = ACTION_GET; - else if (params[0] == "POST") - this->action = ACTION_POST; - - Anope::string targ = params[1]; - size_t q = targ.find('?'); - if (q != Anope::string::npos) - { - sepstream sep(targ.substr(q + 1), '&'); - targ = targ.substr(0, q); - - Anope::string token; - while (sep.GetToken(token)) - { - size_t sz = token.find('='); - if (sz == Anope::string::npos || !sz || sz + 1 >= token.length()) - continue; - this->message.get_data[token.substr(0, sz)] = HTTPUtils::URLDecode(token.substr(sz + 1)); - } - } - - this->page = this->provider->FindPage(targ); - this->page_name = targ; - } - else if (buf.find("Cookie: ") == 0) - { - spacesepstream sep(buf.substr(8)); - Anope::string token; - - while (sep.GetToken(token)) - { - size_t sz = token.find('='); - if (sz == Anope::string::npos || !sz || sz + 1 >= token.length()) - continue; - size_t end = token.length() - (sz + 1); - if (!sep.StreamEnd()) - --end; // Remove trailing ; - this->message.cookies[token.substr(0, sz)] = token.substr(sz + 1, end); - } - } - else if (buf.find("Content-Length: ") == 0) - { - try - { - this->content_length = convertTo<unsigned>(buf.substr(16)); - } - catch (const ConvertException &ex) { } - } - else if (buf.find(':') != Anope::string::npos) - { - size_t sz = buf.find(':'); - if (sz + 2 < buf.length()) - this->message.headers[buf.substr(0, sz)] = buf.substr(sz + 2); - } - - return true; - } - - void SendError(HTTPError err, const Anope::string &msg) anope_override - { - HTTPReply h; - - h.error = err; - - h.Write(msg); - - this->SendReply(&h); - } - - void SendReply(HTTPReply *msg) anope_override - { - this->WriteClient("HTTP/1.1 " + GetStatusFromCode(msg->error)); - this->WriteClient("Date: " + BuildDate()); - this->WriteClient("Server: Anope-" + Anope::VersionShort()); - if (msg->content_type.empty()) - this->WriteClient("Content-Type: text/html"); - else - this->WriteClient("Content-Type: " + msg->content_type); - this->WriteClient("Content-Length: " + stringify(msg->length)); - - for (unsigned i = 0; i < msg->cookies.size(); ++i) - { - Anope::string buf = "Set-Cookie:"; - - for (HTTPReply::cookie::iterator it = msg->cookies[i].begin(), it_end = msg->cookies[i].end(); it != it_end; ++it) - buf += " " + it->first + "=" + it->second + ";"; - - buf.erase(buf.length() - 1); - - this->WriteClient(buf); - } - - typedef std::map<Anope::string, Anope::string> map; - for (map::iterator it = msg->headers.begin(), it_end = msg->headers.end(); it != it_end; ++it) - this->WriteClient(it->first + ": " + it->second); - - this->WriteClient("Connection: Close"); - this->WriteClient(""); - - for (unsigned i = 0; i < msg->out.size(); ++i) - { - HTTPReply::Data* d = msg->out[i]; - - this->Write(d->buf, d->len); - - delete d; - } - - msg->out.clear(); - } -}; - -class MyHTTPProvider : public HTTPProvider, public Timer -{ - int timeout; - std::map<Anope::string, HTTPPage *> pages; - std::list<Reference<MyHTTPClient> > clients; - - public: - MyHTTPProvider(Module *c, const Anope::string &n, const Anope::string &i, const unsigned short p, const int t, bool s) : Socket(-1, i.find(':') != Anope::string::npos), HTTPProvider(c, n, i, p, s), Timer(c, 10, Anope::CurTime, true), timeout(t) { } - - void Tick(time_t) anope_override - { - while (!this->clients.empty()) - { - Reference<MyHTTPClient>& c = this->clients.front(); - if (c && c->created + this->timeout >= Anope::CurTime) - break; - - delete c; - this->clients.pop_front(); - } - } - - ClientSocket* OnAccept(int fd, const sockaddrs &addr) anope_override - { - MyHTTPClient *c = new MyHTTPClient(this, fd, addr); - this->clients.push_back(c); - return c; - } - - bool RegisterPage(HTTPPage *page) anope_override - { - return this->pages.insert(std::make_pair(page->GetURL(), page)).second; - } - - void UnregisterPage(HTTPPage *page) anope_override - { - this->pages.erase(page->GetURL()); - } - - HTTPPage* FindPage(const Anope::string &pname) - { - if (this->pages.count(pname) == 0) - return NULL; - return this->pages[pname]; - } -}; - -class HTTPD : public Module -{ - ServiceReference<SSLService> sslref; - std::map<Anope::string, MyHTTPProvider *> providers; - public: - HTTPD(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), sslref("SSLService", "ssl") - { - - } - - ~HTTPD() - { - for (std::map<int, Socket *>::const_iterator it = SocketEngine::Sockets.begin(), it_end = SocketEngine::Sockets.end(); it != it_end;) - { - Socket *s = it->second; - ++it; - - if (dynamic_cast<MyHTTPProvider *>(s) || dynamic_cast<MyHTTPClient *>(s)) - delete s; - } - - this->providers.clear(); - } - - void OnReload(Configuration::Conf *config) anope_override - { - Configuration::Block *conf = config->GetModule(this); - std::set<Anope::string> existing; - - for (int i = 0; i < conf->CountBlock("httpd"); ++i) - { - Configuration::Block *block = conf->GetBlock("httpd", i); - - - const Anope::string &hname = block->Get<const Anope::string>("name", "httpd/main"); - existing.insert(hname); - - Anope::string ip = block->Get<const Anope::string>("ip"); - int port = block->Get<int>("port", "8080"); - int timeout = block->Get<int>("timeout", "30"); - bool ssl = block->Get<bool>("ssl", "no"); - Anope::string ext_ip = block->Get<const Anope::string>("extforward_ip"); - Anope::string ext_header = block->Get<const Anope::string>("extforward_header"); - - if (ip.empty()) - { - Log(this) << "You must configure a bind IP for HTTP server " << hname; - continue; - } - else if (port <= 0 || port > 65535) - { - Log(this) << "You must configure a (valid) listen port for HTTP server " << hname; - continue; - } - - MyHTTPProvider *p; - if (this->providers.count(hname) == 0) - { - try - { - p = new MyHTTPProvider(this, hname, ip, port, timeout, ssl); - if (ssl && sslref) - sslref->Init(p); - } - catch (const SocketException &ex) - { - Log(this) << "Unable to create HTTP server " << hname << ": " << ex.GetReason(); - continue; - } - this->providers[hname] = p; - - Log(this) << "Created HTTP server " << hname; - } - else - { - p = this->providers[hname]; - - if (p->GetIP() != ip || p->GetPort() != port) - { - delete p; - this->providers.erase(hname); - - Log(this) << "Changing HTTP server " << hname << " to " << ip << ":" << port; - - try - { - p = new MyHTTPProvider(this, hname, ip, port, timeout, ssl); - if (ssl && sslref) - sslref->Init(p); - } - catch (const SocketException &ex) - { - Log(this) << "Unable to create HTTP server " << hname << ": " << ex.GetReason(); - continue; - } - - this->providers[hname] = p; - } - } - - - p->ext_ip = ext_ip; - spacesepstream(ext_header).GetTokens(p->ext_headers); - } - - for (std::map<Anope::string, MyHTTPProvider *>::iterator it = this->providers.begin(), it_end = this->providers.end(); it != it_end;) - { - HTTPProvider *p = it->second; - ++it; - - if (existing.count(p->name) == 0) - { - Log(this) << "Removing HTTP server " << p->name; - this->providers.erase(p->name); - delete p; - } - } - } - - void OnModuleLoad(User *u, Module *m) anope_override - { - if (m->name != "m_ssl") - return; - - for (std::map<Anope::string, MyHTTPProvider *>::iterator it = this->providers.begin(), it_end = this->providers.end(); it != it_end; ++it) - { - MyHTTPProvider *p = it->second; - - if (p->IsSSL() && sslref) - try - { - sslref->Init(p); - } - catch (const CoreException &) { } // Throws on reinitialization - } - } -}; - -MODULE_INIT(HTTPD) diff --git a/modules/extra/m_proxyscan.cpp b/modules/extra/m_proxyscan.cpp deleted file mode 100644 index 98178260c..000000000 --- a/modules/extra/m_proxyscan.cpp +++ /dev/null @@ -1,379 +0,0 @@ -/* - * (C) 2003-2014 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -#include "module.h" - -struct ProxyCheck -{ - std::set<Anope::string, ci::less> types; - std::vector<unsigned short> ports; - time_t duration; - Anope::string reason; -}; - -static Anope::string ProxyCheckString; -static Anope::string target_ip; -static unsigned short target_port; -static bool add_to_akill; - -class ProxyCallbackListener : public ListenSocket -{ - class ProxyCallbackClient : public ClientSocket, public BufferedSocket - { - public: - ProxyCallbackClient(ListenSocket *l, int f, const sockaddrs &a) : Socket(f, l->IsIPv6()), ClientSocket(l, a), BufferedSocket() - { - } - - void OnAccept() anope_override - { - this->Write(ProxyCheckString); - } - - bool ProcessWrite() anope_override - { - return !BufferedSocket::ProcessWrite() || this->write_buffer.empty() ? false : true; - } - }; - - public: - ProxyCallbackListener(const Anope::string &b, int p) : Socket(-1, b.find(':') != Anope::string::npos), ListenSocket(b, p, false) - { - } - - ClientSocket *OnAccept(int fd, const sockaddrs &addr) anope_override - { - return new ProxyCallbackClient(this, fd, addr); - } -}; - -class ProxyConnect : public ConnectionSocket -{ - static ServiceReference<XLineManager> akills; - - public: - static std::set<ProxyConnect *> proxies; - - ProxyCheck proxy; - unsigned short port; - time_t created; - - ProxyConnect(ProxyCheck &p, unsigned short po) : Socket(-1), ConnectionSocket(), proxy(p), - port(po), created(Anope::CurTime) - { - proxies.insert(this); - } - - ~ProxyConnect() - { - proxies.erase(this); - } - - virtual void OnConnect() anope_override = 0; - virtual const Anope::string GetType() const = 0; - - protected: - void Ban() - { - Anope::string reason = this->proxy.reason; - - reason = reason.replace_all_cs("%t", this->GetType()); - reason = reason.replace_all_cs("%i", this->conaddr.addr()); - reason = reason.replace_all_cs("%p", stringify(this->conaddr.port())); - - BotInfo *OperServ = Config->GetClient("OperServ"); - Log(OperServ) << "PROXYSCAN: Open " << this->GetType() << " proxy found on " << this->conaddr.addr() << ":" << this->conaddr.port() << " (" << reason << ")"; - XLine *x = new XLine("*@" + this->conaddr.addr(), OperServ ? OperServ->nick : "", Anope::CurTime + this->proxy.duration, reason, XLineManager::GenerateUID()); - if (add_to_akill && akills) - { - akills->AddXLine(x); - akills->Send(NULL, x); - } - else - { - if (IRCD->CanSZLine) - IRCD->SendSZLine(NULL, x); - else - IRCD->SendAkill(NULL, x); - delete x; - } - } -}; -ServiceReference<XLineManager> ProxyConnect::akills("XLineManager", "xlinemanager/sgline"); -std::set<ProxyConnect *> ProxyConnect::proxies; - -class HTTPProxyConnect : public ProxyConnect, public BufferedSocket -{ - public: - HTTPProxyConnect(ProxyCheck &p, unsigned short po) : Socket(-1), ProxyConnect(p, po), BufferedSocket() - { - } - - void OnConnect() anope_override - { - this->Write("CONNECT %s:%d HTTP/1.0", target_ip.c_str(), target_port); - this->Write("Content-length: 0"); - this->Write("Connection: close"); - this->Write(""); - } - - const Anope::string GetType() const anope_override - { - return "HTTP"; - } - - bool ProcessRead() anope_override - { - bool b = BufferedSocket::ProcessRead(); - if (this->GetLine() == ProxyCheckString) - { - this->Ban(); - return false; - } - return b; - } -}; - -class SOCKS5ProxyConnect : public ProxyConnect, public BinarySocket -{ - public: - SOCKS5ProxyConnect(ProxyCheck &p, unsigned short po) : Socket(-1), ProxyConnect(p, po), BinarySocket() - { - } - - void OnConnect() anope_override - { - sockaddrs target_addr; - char buf[4 + sizeof(target_addr.sa4.sin_addr.s_addr) + sizeof(target_addr.sa4.sin_port)]; - int ptr = 0; - target_addr.pton(AF_INET, target_ip, target_port); - if (!target_addr.valid()) - return; - - buf[ptr++] = 5; // Version - buf[ptr++] = 1; // # of methods - buf[ptr++] = 0; // No authentication - - this->Write(buf, ptr); - - ptr = 1; - buf[ptr++] = 1; // Connect - buf[ptr++] = 0; // Reserved - buf[ptr++] = 1; // IPv4 - memcpy(buf + ptr, &target_addr.sa4.sin_addr.s_addr, sizeof(target_addr.sa4.sin_addr.s_addr)); - ptr += sizeof(target_addr.sa4.sin_addr.s_addr); - memcpy(buf + ptr, &target_addr.sa4.sin_port, sizeof(target_addr.sa4.sin_port)); - ptr += sizeof(target_addr.sa4.sin_port); - - this->Write(buf, ptr); - } - - const Anope::string GetType() const anope_override - { - return "SOCKS5"; - } - - bool Read(const char *buffer, size_t l) anope_override - { - if (l >= ProxyCheckString.length() && !strncmp(buffer, ProxyCheckString.c_str(), ProxyCheckString.length())) - { - this->Ban(); - return false; - } - return true; - } -}; - -class ModuleProxyScan : public Module -{ - Anope::string listen_ip; - unsigned short listen_port; - Anope::string con_notice, con_source; - std::vector<ProxyCheck> proxyscans; - - ProxyCallbackListener *listener; - - class ConnectionTimeout : public Timer - { - public: - ConnectionTimeout(Module *c, long timeout) : Timer(c, timeout, Anope::CurTime, true) - { - } - - void Tick(time_t) anope_override - { - for (std::set<ProxyConnect *>::iterator it = ProxyConnect::proxies.begin(), it_end = ProxyConnect::proxies.end(); it != it_end; ++it) - { - ProxyConnect *p = *it; - - if (p->created + this->GetSecs() < Anope::CurTime) - p->flags[SF_DEAD] = true; - } - } - } connectionTimeout; - - public: - ModuleProxyScan(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), - connectionTimeout(this, 5) - { - - - this->listener = NULL; - } - - ~ModuleProxyScan() - { - for (std::set<ProxyConnect *>::iterator it = ProxyConnect::proxies.begin(), it_end = ProxyConnect::proxies.end(); it != it_end;) - { - ProxyConnect *p = *it; - ++it; - delete p; - } - - for (std::map<int, Socket *>::const_iterator it = SocketEngine::Sockets.begin(), it_end = SocketEngine::Sockets.end(); it != it_end;) - { - Socket *s = it->second; - ++it; - - ClientSocket *cs = dynamic_cast<ClientSocket *>(s); - if (cs != NULL && cs->ls == this->listener) - delete s; - } - - delete this->listener; - } - - void OnReload(Configuration::Conf *conf) anope_override - { - Configuration::Block *config = Config->GetModule(this); - - Anope::string s_target_ip = config->Get<const Anope::string>("target_ip"); - if (s_target_ip.empty()) - throw ConfigException(this->name + " target_ip may not be empty"); - - int s_target_port = config->Get<int>("target_port", "-1"); - if (s_target_port <= 0) - throw ConfigException(this->name + " target_port may not be empty and must be a positive number"); - - Anope::string s_listen_ip = config->Get<const Anope::string>("listen_ip"); - if (s_listen_ip.empty()) - throw ConfigException(this->name + " listen_ip may not be empty"); - - int s_listen_port = config->Get<int>("listen_port", "-1"); - if (s_listen_port <= 0) - throw ConfigException(this->name + " listen_port may not be empty and must be a positive number"); - - target_ip = s_target_ip; - target_port = s_target_port; - this->listen_ip = s_listen_ip; - this->listen_port = s_listen_port; - this->con_notice = config->Get<const Anope::string>("connect_notice"); - this->con_source = config->Get<const Anope::string>("connect_source"); - add_to_akill = config->Get<bool>("add_to_akill", "true"); - this->connectionTimeout.SetSecs(config->Get<time_t>("timeout", "5s")); - - ProxyCheckString = Config->GetBlock("networkinfo")->Get<const Anope::string>("networkname") + " proxy check"; - delete this->listener; - this->listener = NULL; - try - { - this->listener = new ProxyCallbackListener(this->listen_ip, this->listen_port); - } - catch (const SocketException &ex) - { - throw ConfigException("m_proxyscan: " + ex.GetReason()); - } - - this->proxyscans.clear(); - for (int i = 0; i < config->CountBlock("proxyscan"); ++i) - { - Configuration::Block *block = config->GetBlock("proxyscan", i); - ProxyCheck p; - Anope::string token; - - commasepstream sep(block->Get<const Anope::string>("type")); - while (sep.GetToken(token)) - { - if (!token.equals_ci("HTTP") && !token.equals_ci("SOCKS5")) - continue; - p.types.insert(token); - } - if (p.types.empty()) - continue; - - commasepstream sep2(block->Get<const Anope::string>("port")); - while (sep2.GetToken(token)) - { - try - { - unsigned short port = convertTo<unsigned short>(token); - p.ports.push_back(port); - } - catch (const ConvertException &) { } - } - if (p.ports.empty()) - continue; - - p.duration = block->Get<time_t>("time", "4h"); - p.reason = block->Get<const Anope::string>("reason"); - if (p.reason.empty()) - continue; - - this->proxyscans.push_back(p); - } - } - - void OnUserConnect(User *user, bool &exempt) anope_override - { - if (exempt || user->Quitting() || !Me->IsSynced() || !user->server->IsSynced()) - return; - - /* At this time we only support IPv4 */ - sockaddrs user_ip; - user_ip.pton(AF_INET, user->ip); - if (!user_ip.valid()) - /* User doesn't have a valid IPv4 IP (ipv6/spoof/etc) */ - return; - - if (!this->con_notice.empty() && !this->con_source.empty()) - { - BotInfo *bi = BotInfo::Find(this->con_source); - if (bi) - user->SendMessage(bi, this->con_notice); - } - - for (unsigned i = this->proxyscans.size(); i > 0; --i) - { - ProxyCheck &p = this->proxyscans[i - 1]; - - for (std::set<Anope::string, ci::less>::iterator it = p.types.begin(), it_end = p.types.end(); it != it_end; ++it) - { - for (unsigned k = 0; k < p.ports.size(); ++k) - { - try - { - ProxyConnect *con = NULL; - if (it->equals_ci("HTTP")) - con = new HTTPProxyConnect(p, p.ports[k]); - else if (it->equals_ci("SOCKS5")) - con = new SOCKS5ProxyConnect(p, p.ports[k]); - else - continue; - con->Connect(user->ip, p.ports[k]); - } - catch (const SocketException &ex) - { - Log(LOG_DEBUG) << "m_proxyscan: " << ex.GetReason(); - } - } - } - } - } -}; - -MODULE_INIT(ModuleProxyScan) - diff --git a/modules/extra/m_sql_log.cpp b/modules/extra/m_sql_log.cpp new file mode 100644 index 000000000..b0c6c037f --- /dev/null +++ b/modules/extra/m_sql_log.cpp @@ -0,0 +1,109 @@ +/* + * + * (C) 2003-2014 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + */ + +#include "module.h" +#include "modules/sql.h" + +class SQLLog : public Module +{ + std::set<Anope::string> inited; + Anope::string table; + + public: + SQLLog(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + { + } + + void OnReload(Configuration::Conf *conf) anope_override + { + Configuration::Block *config = conf->GetModule(this); + this->table = config->Get<const Anope::string>("table", "logs"); + } + + void OnLogMessage(LogInfo *li, const Log *l, const Anope::string &msg) anope_override + { + Anope::string ref_name; + ServiceReference<SQL::Provider> SQL; + + for (unsigned i = 0; i < li->targets.size(); ++i) + { + const Anope::string &target = li->targets[i]; + size_t sz = target.find("sql_log:"); + if (!sz) + { + ref_name = target.substr(8); + SQL = ServiceReference<SQL::Provider>("SQL::Provider", ref_name); + break; + } + } + + if (!SQL) + return; + + if (!inited.count(ref_name)) + { + inited.insert(ref_name); + + SQL::Query create("CREATE TABLE IF NOT EXISTS `" + table + "` (" + "`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," + "`type` varchar(64) NOT NULL," + "`user` varchar(64) NOT NULL," + "`acc` varchar(64) NOT NULL," + "`command` varchar(64) NOT NULL," + "`channel` varchar(64) NOT NULL," + "`msg` text NOT NULL" + ")"); + + SQL->Run(NULL, create); + } + + SQL::Query insert("INSERT INTO `" + table + "` (`type`,`user`,`acc`,`command`,`channel`,`msg`)" + "VALUES (@type@, @user@, @acc@, @command@, @channel@, @msg@)"); + + switch (l->type) + { + case LOG_ADMIN: + insert.SetValue("type", "ADMIN"); + break; + case LOG_OVERRIDE: + insert.SetValue("type", "OVERRIDE"); + break; + case LOG_COMMAND: + insert.SetValue("type", "COMMAND"); + break; + case LOG_SERVER: + insert.SetValue("type", "SERVER"); + break; + case LOG_CHANNEL: + insert.SetValue("type", "CHANNEL"); + break; + case LOG_USER: + insert.SetValue("type", "USER"); + break; + case LOG_MODULE: + insert.SetValue("type", "MODULE"); + break; + case LOG_NORMAL: + insert.SetValue("type", "NORMAL"); + break; + default: + return; + } + + insert.SetValue("user", l->u ? l->u->nick : ""); + insert.SetValue("acc", l->nc ? l->nc->display : ""); + insert.SetValue("command", l->c ? l->c->name : ""); + insert.SetValue("channel", l->ci ? l->ci->name : ""); + insert.SetValue("msg", msg); + + SQL->Run(NULL, insert); + } +}; + +MODULE_INIT(SQLLog) diff --git a/modules/extra/m_xmlrpc.cpp b/modules/extra/m_xmlrpc.cpp deleted file mode 100644 index 36401b800..000000000 --- a/modules/extra/m_xmlrpc.cpp +++ /dev/null @@ -1,186 +0,0 @@ - -#include "module.h" -#include "modules/xmlrpc.h" -#include "modules/httpd.h" - -static struct special_chars -{ - Anope::string character; - Anope::string replace; - - special_chars(const Anope::string &c, const Anope::string &r) : character(c), replace(r) { } -} -special[] = { - special_chars("&", "&"), - special_chars("\"", """), - special_chars("<", "<"), - special_chars(">", "&qt;"), - special_chars("'", "'"), - special_chars("\n", "
"), - special_chars("\002", ""), // bold - special_chars("\003", ""), // color - special_chars("\035", ""), // italics - special_chars("\037", ""), // underline - special_chars("\026", ""), // reverses - special_chars("", "") -}; - -class MyXMLRPCServiceInterface : public XMLRPCServiceInterface, public HTTPPage -{ - std::deque<XMLRPCEvent *> events; - - public: - MyXMLRPCServiceInterface(Module *creator, const Anope::string &sname) : XMLRPCServiceInterface(creator, sname), HTTPPage("/xmlrpc", "text/xml") { } - - void Register(XMLRPCEvent *event) - { - this->events.push_back(event); - } - - void Unregister(XMLRPCEvent *event) - { - std::deque<XMLRPCEvent *>::iterator it = std::find(this->events.begin(), this->events.end(), event); - - if (it != this->events.end()) - this->events.erase(it); - } - - Anope::string Sanitize(const Anope::string &string) anope_override - { - Anope::string ret = string; - for (int i = 0; special[i].character.empty() == false; ++i) - ret = ret.replace_all_cs(special[i].character, special[i].replace); - return ret; - } - - private: - static bool GetData(Anope::string &content, Anope::string &tag, Anope::string &data) - { - if (content.empty()) - return false; - - Anope::string prev, cur; - bool istag; - - do - { - prev = cur; - cur.clear(); - - int len = 0; - istag = false; - - if (content[0] == '<') - { - len = content.find_first_of('>'); - istag = true; - } - else if (content[0] != '>') - { - len = content.find_first_of('<'); - } - - if (len) - { - if (istag) - { - cur = content.substr(1, len - 1); - content.erase(0, len + 1); - while (!content.empty() && content[0] == ' ') - content.erase(content.begin()); - } - else - { - cur = content.substr(0,len); - content.erase(0, len); - } - } - } - while (istag && !content.empty()); - - tag = prev; - data = cur; - return !istag && !data.empty(); - } - - public: - bool OnRequest(HTTPProvider *provider, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) anope_override - { - Anope::string content = message.content, tname, data; - XMLRPCRequest request(reply); - - while (GetData(content, tname, data)) - { - Log(LOG_DEBUG) << "m_xmlrpc: Tag name: " << tname << ", data: " << data; - if (tname == "methodName") - request.name = data; - else if (tname == "name" && data == "id") - { - GetData(content, tname, data); - request.id = data; - } - else if (tname == "string") - request.data.push_back(data); - } - - for (unsigned i = 0; i < this->events.size(); ++i) - { - XMLRPCEvent *e = this->events[i]; - - if (!e->Run(this, client, request)) - return false; - else if (!request.get_replies().empty()) - { - this->Reply(request); - return true; - } - } - - reply.error = HTTP_PAGE_NOT_FOUND; - reply.Write("Unrecognized query"); - return true; - } - - void Reply(XMLRPCRequest &request) - { - if (!request.id.empty()) - request.reply("id", request.id); - - Anope::string r = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<methodCall>\n<methodName>" + request.name + "</methodName>\n<params>\n<param>\n<value>\n<struct>\n"; - for (std::map<Anope::string, Anope::string>::const_iterator it = request.get_replies().begin(); it != request.get_replies().end(); ++it) - r += "<member>\n<name>" + it->first + "</name>\n<value>\n<string>" + this->Sanitize(it->second) + "</string>\n</value>\n</member>\n"; - r += "</struct>\n</value>\n</param>\n</params>\n</methodCall>"; - - request.r.Write(r); - } -}; - -class ModuleXMLRPC : public Module -{ - ServiceReference<HTTPProvider> httpref; - public: - MyXMLRPCServiceInterface xmlrpcinterface; - - ModuleXMLRPC(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), - httpref("HTTPProvider", "httpd/main"), xmlrpcinterface(this, "xmlrpc") - { - if (!httpref) - throw ModuleException("Unable to find http reference, is m_httpd loaded?"); - httpref->RegisterPage(&xmlrpcinterface); - - } - - ~ModuleXMLRPC() - { - if (httpref) - httpref->UnregisterPage(&xmlrpcinterface); - } - - void OnReload(Configuration::Conf *conf) anope_override - { - this->httpref = ServiceReference<HTTPProvider>("HTTPProvider", conf->GetModule(this)->Get<const Anope::string>("server", "httpd/main")); - } -}; - -MODULE_INIT(ModuleXMLRPC) - diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp deleted file mode 100644 index 17dd8b96f..000000000 --- a/modules/extra/m_xmlrpc_main.cpp +++ /dev/null @@ -1,280 +0,0 @@ -#include "module.h" -#include "modules/xmlrpc.h" - -static Module *me; - -class XMLRPCIdentifyRequest : public IdentifyRequest -{ - XMLRPCRequest request; - HTTPReply repl; /* Request holds a reference to the HTTPReply, because we might exist long enough to invalidate it - we'll copy it here then reset the reference before we use it */ - Reference<HTTPClient> client; - Reference<XMLRPCServiceInterface> xinterface; - - public: - XMLRPCIdentifyRequest(Module *m, XMLRPCRequest& req, HTTPClient *c, XMLRPCServiceInterface* iface, const Anope::string &acc, const Anope::string &pass) : IdentifyRequest(m, acc, pass), request(req), repl(request.r), client(c), xinterface(iface) { } - - void OnSuccess() anope_override - { - if (!xinterface || !client) - return; - - request.r = this->repl; - - request.reply("result", "Success"); - request.reply("account", GetAccount()); - - xinterface->Reply(request); - client->SendReply(&request.r); - } - - void OnFail() anope_override - { - if (!xinterface || !client) - return; - - request.r = this->repl; - - request.reply("error", "Invalid password"); - - xinterface->Reply(request); - client->SendReply(&request.r); - } -}; - -class MyXMLRPCEvent : public XMLRPCEvent -{ - public: - bool Run(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) anope_override - { - if (request.name == "command") - this->DoCommand(iface, client, request); - else if (request.name == "checkAuthentication") - return this->DoCheckAuthentication(iface, client, request); - else if (request.name == "stats") - this->DoStats(iface, client, request); - else if (request.name == "channel") - this->DoChannel(iface, client, request); - else if (request.name == "user") - this->DoUser(iface, client, request); - else if (request.name == "opers") - this->DoOperType(iface, client, request); - - return true; - } - - private: - void DoCommand(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) - { - Anope::string service = request.data.size() > 0 ? request.data[0] : ""; - Anope::string user = request.data.size() > 1 ? request.data[1] : ""; - Anope::string command = request.data.size() > 2 ? request.data[2] : ""; - - if (service.empty() || user.empty() || command.empty()) - request.reply("error", "Invalid parameters"); - else - { - BotInfo *bi = BotInfo::Find(service); - if (!bi) - request.reply("error", "Invalid service"); - else - { - request.reply("result", "Success"); - - NickAlias *na = NickAlias::Find(user); - - Anope::string out; - - struct XMLRPCommandReply : CommandReply - { - Anope::string &str; - - XMLRPCommandReply(Anope::string &s) : str(s) { } - - void SendMessage(BotInfo *, const Anope::string &msg) anope_override - { - str += msg + "\n"; - }; - } - reply(out); - - CommandSource source(user, NULL, na ? *na->nc : NULL, &reply, bi); - Command::Run(source, command); - - if (!out.empty()) - request.reply("return", iface->Sanitize(out)); - } - } - } - - bool DoCheckAuthentication(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) - { - Anope::string username = request.data.size() > 0 ? request.data[0] : ""; - Anope::string password = request.data.size() > 1 ? request.data[1] : ""; - - if (username.empty() || password.empty()) - request.reply("error", "Invalid parameters"); - else - { - XMLRPCIdentifyRequest *req = new XMLRPCIdentifyRequest(me, request, client, iface, username, password); - FOREACH_MOD(OnCheckAuthentication, (NULL, req)); - req->Dispatch(); - return false; - } - - return true; - } - - void DoStats(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) - { - request.reply("uptime", stringify(Anope::CurTime - Anope::StartTime)); - request.reply("uplinkname", Me->GetLinks().front()->GetName()); - { - Anope::string buf; - for (std::set<Anope::string>::iterator it = Servers::Capab.begin(); it != Servers::Capab.end(); ++it) - buf += " " + *it; - if (!buf.empty()) - buf.erase(buf.begin()); - request.reply("uplinkcapab", buf); - } - request.reply("usercount", stringify(UserListByNick.size())); - request.reply("maxusercount", stringify(MaxUserCount)); - request.reply("channelcount", stringify(ChannelList.size())); - } - - void DoChannel(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) - { - if (request.data.empty()) - return; - - Channel *c = Channel::Find(request.data[0]); - - request.reply("name", iface->Sanitize(c ? c->name : request.data[0])); - - if (c) - { - request.reply("bancount", stringify(c->HasMode("BAN"))); - int count = 0; - std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> its = c->GetModeList("BAN"); - for (; its.first != its.second; ++its.first) - request.reply("ban" + stringify(++count), iface->Sanitize(its.first->second)); - - request.reply("exceptcount", stringify(c->HasMode("EXCEPT"))); - count = 0; - its = c->GetModeList("EXCEPT"); - for (; its.first != its.second; ++its.first) - request.reply("except" + stringify(++count), iface->Sanitize(its.first->second)); - - request.reply("invitecount", stringify(c->HasMode("INVITEOVERRIDE"))); - count = 0; - its = c->GetModeList("INVITEOVERRIDE"); - for (; its.first != its.second; ++its.first) - request.reply("invite" + stringify(++count), iface->Sanitize(its.first->second)); - - Anope::string users; - for (Channel::ChanUserList::const_iterator it = c->users.begin(); it != c->users.end(); ++it) - { - ChanUserContainer *uc = it->second; - users += uc->status.BuildModePrefixList() + uc->user->nick + " "; - } - if (!users.empty()) - { - users.erase(users.length() - 1); - request.reply("users", iface->Sanitize(users)); - } - - if (!c->topic.empty()) - request.reply("topic", iface->Sanitize(c->topic)); - - if (!c->topic_setter.empty()) - request.reply("topicsetter", iface->Sanitize(c->topic_setter)); - - request.reply("topictime", stringify(c->topic_time)); - request.reply("topicts", stringify(c->topic_ts)); - } - } - - void DoUser(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) - { - if (request.data.empty()) - return; - - User *u = User::Find(request.data[0]); - - request.reply("nick", iface->Sanitize(u ? u->nick : request.data[0])); - - if (u) - { - request.reply("ident", iface->Sanitize(u->GetIdent())); - request.reply("vident", iface->Sanitize(u->GetVIdent())); - request.reply("host", iface->Sanitize(u->host)); - if (!u->vhost.empty()) - request.reply("vhost", iface->Sanitize(u->vhost)); - if (!u->chost.empty()) - request.reply("chost", iface->Sanitize(u->chost)); - if (!u->ip.empty()) - request.reply("ip", u->ip); - request.reply("timestamp", stringify(u->timestamp)); - request.reply("signon", stringify(u->signon)); - if (u->Account()) - { - request.reply("account", iface->Sanitize(u->Account()->display)); - if (u->Account()->o) - request.reply("opertype", iface->Sanitize(u->Account()->o->ot->GetName())); - } - - Anope::string channels; - for (User::ChanUserList::const_iterator it = u->chans.begin(); it != u->chans.end(); ++it) - { - ChanUserContainer *cc = it->second; - channels += cc->status.BuildModePrefixList() + cc->chan->name + " "; - } - if (!channels.empty()) - { - channels.erase(channels.length() - 1); - request.reply("channels", channels); - } - } - } - - void DoOperType(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) - { - for (unsigned i = 0; i < Config->MyOperTypes.size(); ++i) - { - OperType *ot = Config->MyOperTypes[i]; - Anope::string perms; - for (std::list<Anope::string>::const_iterator it2 = ot->GetPrivs().begin(), it2_end = ot->GetPrivs().end(); it2 != it2_end; ++it2) - perms += " " + *it2; - for (std::list<Anope::string>::const_iterator it2 = ot->GetCommands().begin(), it2_end = ot->GetCommands().end(); it2 != it2_end; ++it2) - perms += " " + *it2; - request.reply(ot->GetName(), perms); - } - } -}; - -class ModuleXMLRPCMain : public Module -{ - ServiceReference<XMLRPCServiceInterface> xmlrpc; - - MyXMLRPCEvent stats; - - public: - ModuleXMLRPCMain(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), xmlrpc("XMLRPCServiceInterface", "xmlrpc") - { - me = this; - - if (!xmlrpc) - throw ModuleException("Unable to find xmlrpc reference, is m_xmlrpc loaded?"); - - xmlrpc->Register(&stats); - } - - ~ModuleXMLRPCMain() - { - if (xmlrpc) - xmlrpc->Unregister(&stats); - } -}; - -MODULE_INIT(ModuleXMLRPCMain) - 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" |
