]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_httpd_stats.cpp
Fix for bug #415, affects only trunk (wish i'd known this before i started!)
[user/henk/code/inspircd.git] / src / modules / m_httpd_stats.cpp
index d685d5c63c119c9ad8fd9738014490ff2a8933e6..445af1826b226eb73d6334845905d67ee6e07c10 100644 (file)
@@ -6,20 +6,16 @@
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
- *            the file COPYING for details.
+ *         the file COPYING for details.
  *
  * ---------------------------------------------------
  */
 
 #include "inspircd.h"
-#include "users.h"
-#include "channels.h"
-#include "configreader.h"
-#include "modules.h"
-#include "inspsocket.h"
 #include "httpd.h"
 
 /* $ModDesc: Provides statistics over HTTP via m_httpd.so */
+/* $ModDep: httpd.h */
 
 typedef std::map<irc::string,int> StatsHash;
 typedef StatsHash::iterator StatsIter;
@@ -110,13 +106,22 @@ class ModuleHttpStats : public Module
                                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++)
+                               for (int i = 0; i <= ServerInstance->Modules->GetCount(); i++)
                                {
                                        if (!ServerInstance->Config->module_names[i].empty())
                                        {
-                                               Version v = ServerInstance->modules[i]->GetVersion();
+                                               Version v = ServerInstance->Modules->modules[i]->GetVersion();
                                                data << "<module><name>" << ServerInstance->Config->module_names[i] << "</name><version>" << 
                                                        v.Major << "." <<  v.Minor << "." << v.Revision << "." << v.Build << "</version></module>";
                                        }
@@ -162,7 +167,9 @@ class ModuleHttpStats : public Module
                                data << "</inspircdstats>";
 
                                /* Send the document back to m_httpd */
-                               HTTPDocument response(http->sock, &data, 200, "X-Powered-By: m_http_stats.so\r\nContent-Type: text/xml\r\n");
+                               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();
                        }