+
+ if ((http->GetURI() == "/stats") || (http->GetURI() == "/stats/"))
+ {
+ data << "<inspircdstats>";
+
+ data << "<server><name>" << ServerInstance->Config->ServerName << "</name><gecos>" << ServerInstance->Config->ServerDesc << "</gecos></server>";
+
+ data << "<general>";
+ data << "<usercount>" << ServerInstance->clientlist->size() << "</usercount>";
+ data << "<channelcount>" << ServerInstance->chanlist->size() << "</channelcount>";
+ data << "<opercount>" << ServerInstance->all_opers.size() << "</opercount>";
+ data << "<socketcount>" << (ServerInstance->SE->GetMaxFds() - ServerInstance->SE->GetRemainingFds()) << "</socketcount><socketmax>" << ServerInstance->SE->GetMaxFds() <<
+ "</socketmax><socketengine>" << ServerInstance->SE->GetName() << "</socketengine>";
+
+ time_t current_time = 0;
+ current_time = ServerInstance->Time();
+ time_t server_uptime = current_time - ServerInstance->startup_time;
+ struct tm* stime;
+ stime = gmtime(&server_uptime);
+ data << "<uptime><days>" << stime->tm_yday << "</days><hours>" << stime->tm_hour << "</hours><mins>" << stime->tm_min << "</mins><secs>" << stime->tm_sec << "</secs></uptime>";
+
+
+ data << "</general>";
+ data << "<modulelist>";
+ for (int i = 0; i <= ServerInstance->GetModuleCount(); i++)
+ {
+ if (!ServerInstance->Config->module_names[i].empty())
+ {
+ Version v = ServerInstance->modules[i]->GetVersion();
+ data << "<module><name>" << ServerInstance->Config->module_names[i] << "</name><version>" <<
+ v.Major << "." << v.Minor << "." << v.Revision << "." << v.Build << "</version></module>";
+ }
+ }
+ data << "</modulelist>";
+
+ data << "<channellist>";
+ /* 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++)
+ {
+ chanrec* c = ServerInstance->FindChan(a->second.c_str());
+ if (c && !c->IsModeSet('s') && !c->IsModeSet('p'))
+ {
+ data << "<channel>";
+ data << "<usercount>" << c->GetUsers()->size() << "</usercount><channelname>" << c->name << "</channelname>";
+ data << "<channelops>" << c->GetOppedUsers()->size() << "</channelops>";
+ data << "<channelhalfops>" << c->GetHalfoppedUsers()->size() << "</channelhalfops>";
+ data << "<channelvoices>" << c->GetVoicedUsers()->size() << "</channelvoices>";
+ data << "<channeltopic>" << c->topic << "</channeltopic>";
+ data << "<channelmodes>" << c->ChanModes(false) << "</channelmodes>";
+ data << "</channel>";
+ }
+ }
+
+ data << "</channellist>";
+
+ data << "<serverlist>";
+
+ for (StatsHash::iterator b = Servers->begin(); b != Servers->end(); b++)
+ {
+ data << "<server>";
+ data << "<servername>" << b->first << "</servername>";
+ data << "<usercount>" << b->second << "</usercount>";
+ data << "</server>";
+ }
+ data << "</serverlist>";
+
+ data << "</inspircdstats>";
+
+ /* Send the document back to m_httpd */
+ HTTPDocument response(http->sock, &data, 200);
+ response.headers.SetHeader("X-Powered-By", "m_httpd_stats.so");
+ response.headers.SetHeader("Content-Type", "text/xml");
+ Request req((char*)&response, (Module*)this, event->GetSource());
+ req.Send();
+ }