X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_httpd_stats.cpp;h=6c8e7909f0dd084d00e48f6d1c7674a2f1af9aef;hb=819147178db00008a215670992d0f532dd57f9e5;hp=131a9dca1071020e2eacfd2e1a370a1abfc65945;hpb=3fd8e7afd7f266b10813a0ec2153758d0c922ef0;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index 131a9dca1..6c8e7909f 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -2,11 +2,11 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2008 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see - * the file COPYING for details. + * the file COPYING for details. * * --------------------------------------------------- */ @@ -20,7 +20,7 @@ class ModuleHttpStats : public Module { - + static std::map const &entities; std::string stylesheet; bool changed; @@ -43,32 +43,26 @@ class ModuleHttpStats : public Module std::string Sanitize(const std::string &str) { std::string ret; + ret.reserve(str.length() * 2); for (std::string::const_iterator x = str.begin(); x != str.end(); ++x) { - switch (*x) + std::map::const_iterator it = entities.find(*x); + + if (it != entities.end()) { - case '<': - ret += "<"; - break; - case '>': - ret += ">"; - break; - case '&': - ret += "&"; - break; - case '"': - ret += """; - break; - default: - if (*x < 32 || *x > 126) - { - int n = *x; - ret += ("&#" + ConvToStr(n) + ";"); - } - else - ret += *x; - break; + ret += '&'; + ret += it->second; + ret += ';'; + } + else if (*x < 32 || *x > 126) + { + int n = (unsigned char)*x; + ret += ("&#" + ConvToStr(n) + ";"); + } + else + { + ret += *x; } } return ret; @@ -93,8 +87,7 @@ class ModuleHttpStats : public Module data << "" << ServerInstance->Users->clientlist->size() << ""; data << "" << ServerInstance->chanlist->size() << ""; data << "" << ServerInstance->Users->all_opers.size() << ""; - data << "" << (ServerInstance->SE->GetMaxFds() - ServerInstance->SE->GetRemainingFds()) << "" << ServerInstance->SE->GetMaxFds() << - "" << ServerInstance->SE->GetName() << ""; + data << "" << (ServerInstance->SE->GetMaxFds() - ServerInstance->SE->GetRemainingFds()) << "" << ServerInstance->SE->GetMaxFds() << "" << ServerInstance->SE->GetName() << ""; time_t current_time = 0; current_time = ServerInstance->Time(); @@ -107,11 +100,12 @@ class ModuleHttpStats : public Module data << ""; 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.Major << "." << v.Minor << "." << v.Revision << "." << v.Build << ""; + data << "" << *i << "" << v.version << ""; } data << ""; data << ""; @@ -125,7 +119,11 @@ class ModuleHttpStats : public Module data << "" << c->GetOppedUsers()->size() << ""; data << "" << c->GetHalfoppedUsers()->size() << ""; data << "" << c->GetVoicedUsers()->size() << ""; - data << "" << Sanitize(c->topic) << ""; + data << ""; + data << "" << Sanitize(c->topic) << ""; + data << "" << Sanitize(c->setby) << ""; + data << "" << c->topicset << ""; + data << ""; data << "" << Sanitize(c->ChanModes(true)) << ""; CUList* ulist = c->GetUsers(); @@ -133,6 +131,7 @@ class ModuleHttpStats : public Module { data << "" << x->first->uuid << "" << Sanitize(c->GetAllPrefixChars(x->first)) << ""; } + data << ""; } @@ -155,7 +154,7 @@ class ModuleHttpStats : public Module } data << ""; - + ProtoServerList sl; ServerInstance->PI->GetServerList(sl); @@ -164,11 +163,14 @@ class ModuleHttpStats : public Module data << ""; data << "" << b->servername << ""; data << "" << b->parentname << ""; + data << "" << b->gecos << ""; data << "" << b->usercount << ""; - data << "" << b->opercount << ""; +// This is currently not implemented, so, commented out. +// data << "" << b->opercount << ""; data << "" << b->latencyms << ""; data << ""; } + data << ""; data << ""; @@ -195,8 +197,20 @@ class ModuleHttpStats : public Module virtual Version GetVersion() { - return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION); + return Version("$Id$", VF_VENDOR, API_VERSION); } }; +static std::map const &init_entities() +{ + static std::map entities; + entities['<'] = "lt"; + entities['>'] = "gt"; + entities['&'] = "amp"; + entities['"'] = "quot"; + return entities; +} + +std::map const &ModuleHttpStats::entities = init_entities (); + MODULE_INIT(ModuleHttpStats)