X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_httpd_stats.cpp;h=a682cd14c71b50a5019e76c6d173668283f02161;hb=1bfa48143c04504181d1b194af151fae2dac1eb1;hp=cfe8f9782da72dc4cb907bedb92167fac9c0b35e;hpb=0388139f5d9dd88d0d26997307b1fda05c5ac016;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index cfe8f9782..a682cd14c 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * InspIRCd: (C) 2002-2010 InspIRCd Development Team * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see @@ -13,6 +13,7 @@ #include "inspircd.h" #include "httpd.h" +#include "xline.h" #include "protocol.h" /* $ModDesc: Provides statistics over HTTP via m_httpd.so */ @@ -20,20 +21,10 @@ class ModuleHttpStats : public Module { static std::map const &entities; - std::string stylesheet; - bool changed; public: - void ReadConfig() - { - ConfigReader c; - this->stylesheet = c.ReadValue("httpstats", "stylesheet", 0); - } - ModuleHttpStats() { - ReadConfig(); - this->changed = true; Implementation eventlist[] = { I_OnEvent }; ServerInstance->Modules->Attach(eventlist, this, 1); } @@ -69,14 +60,14 @@ class ModuleHttpStats : public Module void DumpMeta(std::stringstream& data, Extensible* ext) { data << ""; - for(ExtensibleStore::const_iterator i = ext->GetExtList().begin(); i != ext->GetExtList().end(); i++) + for(Extensible::ExtensibleStore::const_iterator i = ext->GetExtList().begin(); i != ext->GetExtList().end(); i++) { ExtensionItem* item = i->first; std::string value = item->serialize(FORMAT_USER, ext, i->second); - if (value.empty()) - data << "key << "\"/>"; - else - data << "key << "\">" << Sanitize(value) << ""; + if (!value.empty()) + data << "name << "\">" << Sanitize(value) << ""; + else if (!item->name.empty()) + data << "name << "\"/>"; } data << ""; } @@ -92,12 +83,9 @@ class ModuleHttpStats : public Module if ((http->GetURI() == "/stats") || (http->GetURI() == "/stats/")) { - data << ""; - - data << "" << ServerInstance->Config->ServerName << "" + data << "" << ServerInstance->Config->ServerName << "" << Sanitize(ServerInstance->Config->ServerDesc) << "" - << Sanitize(ServerInstance->GetVersionString()) << "" - << Sanitize(ServerInstance->GetRevision()) << ""; + << Sanitize(ServerInstance->GetVersionString()) << ""; data << ""; data << "" << ServerInstance->Users->clientlist->size() << ""; @@ -112,18 +100,34 @@ class ModuleHttpStats : public Module stime = gmtime(&server_uptime); data << "" << stime->tm_yday << "" << stime->tm_hour << "" << stime->tm_min << "" << stime->tm_sec << "" << ServerInstance->startup_time << ""; - data << "" << Sanitize(ServerInstance->Config->data005) << ""; - data << ""; + data << "" << Sanitize(ServerInstance->Config->data005) << ""; + std::vector xltypes = ServerInstance->XLines->GetAllTypes(); + for (std::vector::iterator it = xltypes.begin(); it != xltypes.end(); ++it) + { + XLineLookup* lookup = ServerInstance->XLines->GetAll(*it); + + if (!lookup) + continue; + for (LookupIter i = lookup->begin(); i != lookup->end(); ++i) + { + data << "c_str() << "\">" + << Sanitize(i->second->Displayable()) << "" + << i->second->set_time << "" << i->second->duration + << "" << Sanitize(i->second->reason) + << ""; + } + } + + data << ""; std::vector module_names = ServerInstance->Modules->GetAllModuleNames(0); for (std::vector::iterator i = module_names.begin(); i != module_names.end(); ++i) { Module* m = ServerInstance->Modules->Find(i->c_str()); Version v = m->GetVersion(); - data << "" << *i << "" << v.version << "" << Sanitize(v.description) << ""; + data << "" << *i << "" << Sanitize(v.description) << ""; } - data << ""; - data << ""; + data << ""; for (chan_hash::const_iterator a = ServerInstance->chanlist->begin(); a != ServerInstance->chanlist->end(); ++a) { @@ -144,7 +148,9 @@ class ModuleHttpStats : public Module Membership* memb = x->second; data << "" << memb->user->uuid << "" << Sanitize(c->GetAllPrefixChars(x->first)) << "" - << memb->modes << ""; + << memb->modes << ""; + DumpMeta(data, memb); + data << ""; } DumpMeta(data, c); @@ -165,10 +171,12 @@ class ModuleHttpStats : public Module if (IS_AWAY(u)) data << "" << Sanitize(u->awaymsg) << "" << u->awaytime << ""; if (IS_OPER(u)) - data << "" << Sanitize(u->oper) << ""; + data << "" << Sanitize(u->oper->NameStr()) << ""; data << "" << u->FormatModes() << "" << Sanitize(u->ident) << ""; - if (IS_LOCAL(u)) - data << "" << u->GetServerPort() << "" << irc::sockets::satouser(&u->server_sa) << ""; + LocalUser* lu = IS_LOCAL(u); + if (lu) + data << "" << lu->GetServerPort() << "" + << irc::sockets::satouser(lu->server_sa) << ""; data << "" << u->GetIPString() << ""; DumpMeta(data, u); @@ -194,9 +202,7 @@ class ModuleHttpStats : public Module data << ""; } - data << ""; - - data << ""; + data << ""; /* Send the document back to m_httpd */ HTTPDocumentResponse response(this, *http, &data, 200); @@ -213,7 +219,7 @@ class ModuleHttpStats : public Module virtual Version GetVersion() { - return Version("Provides statistics over HTTP via m_httpd.so", VF_VENDOR, API_VERSION); + return Version("Provides statistics over HTTP via m_httpd.so", VF_VENDOR); } };