]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_httpd_config.cpp
Remove the intercomm system since sqlite is synchronous.
[user/henk/code/inspircd.git] / src / modules / m_httpd_config.cpp
index d1bb515ebd75c44dcc68fc1df39b73ea5791a684..44013b429d7a0efd28a793d5aa15128371ceb74f 100644 (file)
@@ -3,7 +3,7 @@
  *       +------------------------------------+
  *
  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *         the file COPYING for details.
@@ -28,16 +28,15 @@ class ModuleHttpStats : public Module
 
        void ReadConfig()
        {
-               ConfigReader c(ServerInstance);
+               ConfigReader c;
                this->stylesheet = c.ReadValue("httpstats", "stylesheet", 0);
        }
 
-       ModuleHttpStats(InspIRCd* Me) : Module(Me)
-       {
+       ModuleHttpStats()       {
                ReadConfig();
                this->changed = true;
-               Implementation eventlist[] = { I_OnEvent, I_OnRequest };
-               ServerInstance->Modules->Attach(eventlist, this, 2);
+               Implementation eventlist[] = { I_OnEvent };
+               ServerInstance->Modules->Attach(eventlist, this, 1);
        }
 
        std::string Sanitize(const std::string &str)
@@ -74,14 +73,14 @@ class ModuleHttpStats : public Module
                return ret;
        }
 
-       void OnEvent(Event* event)
+       void OnEvent(Event& event)
        {
                std::stringstream data("");
 
-               if (event->GetEventID() == "httpd_url")
+               if (event.id == "httpd_url")
                {
                        ServerInstance->Logs->Log("m_http_stats", DEBUG,"Handling httpd event");
-                       HTTPRequest* http = (HTTPRequest*)event->GetData();
+                       HTTPRequest* http = (HTTPRequest*)&event;
 
                        if ((http->GetURI() == "/config") || (http->GetURI() == "/config/"))
                        {
@@ -91,37 +90,31 @@ class ModuleHttpStats : public Module
                                for (ConfigDataHash::iterator x = ServerInstance->Config->config_data.begin(); x != ServerInstance->Config->config_data.end(); ++x)
                                {
                                        data << "&lt;" << x->first << " ";
-                                       for (KeyValList::iterator j = x->second.begin(); j != x->second.end(); j++)
+                                       ConfigTag* tag = x->second;
+                                       for (std::vector<KeyVal>::iterator j = tag->items.begin(); j != tag->items.end(); j++)
                                        {
-                                               data << j->first << "=&quot;" << j->second << "&quot; ";
+                                               data << Sanitize(j->first) << "=&quot;" << Sanitize(j->second) << "&quot; ";
                                        }
                                        data << "&gt;<br>";
                                }
 
                                data << "</body></html>";
                                /* Send the document back to m_httpd */
-                               HTTPDocument response(http->sock, &data, 200);
+                               HTTPDocumentResponse response(this, *http, &data, 200);
                                response.headers.SetHeader("X-Powered-By", "m_httpd_config.so");
                                response.headers.SetHeader("Content-Type", "text/html");
-                               Request req((char*)&response, (Module*)this, event->GetSource());
-                               req.Send();
+                               response.Send();
                        }
                }
        }
 
-       const char* OnRequest(Request* request)
-       {
-               return NULL;
-       }
-
-
        virtual ~ModuleHttpStats()
        {
        }
 
        virtual Version GetVersion()
        {
-               return Version("$Id$", VF_VENDOR, API_VERSION);
+               return Version("Provides statistics over HTTP via m_httpd.so", VF_VENDOR);
        }
 };