From: brain Date: Sat, 10 May 2008 18:17:15 +0000 (+0000) Subject: Give tons more information in the xml feed, should be enough to construct just about... X-Git-Tag: v2.0.23~3196 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=050e232499a04bb516c2dfee50b1f8c41ef1f5a6;p=user%2Fhenk%2Fcode%2Finspircd.git Give tons more information in the xml feed, should be enough to construct just about any stat i can think of right now. let me know if you need more info in the feed git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9694 e03df62e-2008-0410-955e-edbf42e46eb7 --- diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index aa64dc3ea..ed7223f20 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -18,15 +18,6 @@ /* $ModDesc: Provides statistics over HTTP via m_httpd.so */ /* $ModDep: httpd.h */ -typedef std::map StatsHash; -typedef StatsHash::iterator StatsIter; - -typedef std::vector > SortedList; -typedef SortedList::iterator SortedIter; - -static StatsHash* sh = new StatsHash(); -static SortedList* so = new SortedList(); - class ModuleHttpStats : public Module { @@ -45,34 +36,8 @@ class ModuleHttpStats : public Module { ReadConfig(); this->changed = true; - Implementation eventlist[] = { I_OnEvent, I_OnRequest, I_OnChannelDelete, I_OnUserJoin, I_OnUserPart, I_OnUserQuit }; - ServerInstance->Modules->Attach(eventlist, this, 6); - } - - void InsertOrder(irc::string channel, int count) - { - /* This function figures out where in the sorted list to put an item from the hash */ - SortedIter a; - for (a = so->begin(); a != so->end(); a++) - { - /* Found an item equal to or less than, we insert our item before it */ - if (a->first <= count) - { - so->insert(a,std::pair(count,channel)); - return; - } - } - /* There are no items in the list yet, insert something at the beginning */ - so->insert(so->begin(), std::pair(count,channel)); - } - - void SortList() - { - /* Sorts the hash into the sorted list using an insertion sort */ - so->clear(); - for (StatsIter a = sh->begin(); a != sh->end(); a++) - InsertOrder(a->first, a->second); - this->changed = false; + Implementation eventlist[] = { I_OnEvent, I_OnRequest }; + ServerInstance->Modules->Attach(eventlist, this, 2); } void OnEvent(Event* event) @@ -115,33 +80,47 @@ class ModuleHttpStats : public Module data << "" << *i << "" << v.Major << "." << v.Minor << "." << v.Revision << "." << v.Build << ""; } data << ""; - data << ""; - /* If the list has changed since last time it was displayed, re-sort it - * this time only (not every time, as this would be moronic) - */ - if (this->changed) - this->SortList(); - for (SortedIter a = so->begin(); a != so->end(); a++) + for (chan_hash::const_iterator a = ServerInstance->chanlist->begin(); a != ServerInstance->chanlist->end(); ++a) { - Channel* c = ServerInstance->FindChan(a->second.c_str()); - if (c && !c->IsModeSet('s') && !c->IsModeSet('p')) + Channel* c = a->second; + + data << ""; + data << "" << c->GetUsers()->size() << "" << c->name << ""; + data << "" << c->GetOppedUsers()->size() << ""; + data << "" << c->GetHalfoppedUsers()->size() << ""; + data << "" << c->GetVoicedUsers()->size() << ""; + data << "" << c->topic << ""; + data << "" << c->ChanModes(false) << ""; + CUList* ulist = c->GetUsers(); + + for (CUList::iterator x = ulist->begin(); x != ulist->end(); ++x) { - data << ""; - data << "" << c->GetUsers()->size() << "" << c->name << ""; - data << "" << c->GetOppedUsers()->size() << ""; - data << "" << c->GetHalfoppedUsers()->size() << ""; - data << "" << c->GetVoicedUsers()->size() << ""; - data << "" << c->topic << ""; - data << "" << c->ChanModes(false) << ""; - data << ""; + data << "" << x->first->uuid << "" << c->GetAllPrefixChars(x->first) << ""; } + data << ""; } - data << ""; + data << ""; + + for (user_hash::const_iterator a = ServerInstance->Users->clientlist->begin(); a != ServerInstance->Users->clientlist->end(); ++a) + { + User* u = a->second; + + data << ""; + data << "" << u->nick << "" << u->uuid << "" << u->host << "" << u->dhost << ""; + data << "" << u->fullname << "" << u->server << "" << u->awaymsg << "" << u->oper << ""; + std::string modes; + for (unsigned char n = 'A'; n <= 'z'; ++n) + if (u->IsModeSet(n)) + modes += n; + + data << modes << ""; + data << ""; + } - data << ""; + data << ""; ProtoServerList sl; ServerInstance->PI->GetServerList(sl); @@ -170,55 +149,6 @@ class ModuleHttpStats : public Module } } - void OnChannelDelete(Channel* chan) - { - StatsIter a = sh->find(chan->name); - if (a != sh->end()) - { - sh->erase(a); - } - this->changed = true; - } - - void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent) - { - StatsIter a = sh->find(channel->name); - if (a != sh->end()) - { - a->second++; - } - else - { - irc::string name = channel->name; - sh->insert(std::pair(name,1)); - } - this->changed = true; - } - - void OnUserPart(User* user, Channel* channel, const std::string &partmessage, bool &silent) - { - StatsIter a = sh->find(channel->name); - if (a != sh->end()) - { - a->second--; - } - this->changed = true; - } - - void OnUserQuit(User* user, const std::string &message, const std::string &oper_message) - { - for (UCListIter v = user->chans.begin(); v != user->chans.end(); v++) - { - Channel* c = v->first; - StatsIter a = sh->find(c->name); - if (a != sh->end()) - { - a->second--; - } - } - this->changed = true; - } - const char* OnRequest(Request* request) { return NULL; @@ -227,8 +157,6 @@ class ModuleHttpStats : public Module virtual ~ModuleHttpStats() { - delete sh; - delete so; } virtual Version GetVersion()