1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
23 #include "inspsocket.h"
24 #include "helperfuncs.h"
27 /* $ModDesc: Provides statistics over HTTP via m_httpd.so */
29 class ModuleHttpStats : public Module
32 std::string stylesheet;
39 this->stylesheet = c.ReadValue("httpstats", "stylesheet", 0);
42 ModuleHttpStats(Server* Me) : Module::Module(Me)
48 void OnEvent(Event* event)
50 std::stringstream data("");
52 if (event->GetEventID() == "httpd_url")
54 HTTPRequest* http = (HTTPRequest*)event->GetData();
56 if ((http->GetURI() == "/stats") || (http->GetURI() == "/stats/"))
58 log(DEBUG,"HTTP URL!");
60 data << "<HTML><HEAD>";
61 data << "<TITLE>InspIRCd server statisitics for " << Srv->GetServerName() << " (" << Srv->GetServerDescription() << ")</TITLE>";
62 data << "</HEAD><BODY>";
63 data << "<H1>InspIRCd server statisitics for " << Srv->GetServerName() << " (" << Srv->GetServerDescription() << ")</H1>";
68 HTTPDocument response(http->sock, &data, 200, "X-Powered-By: m_http_stats.so\r\nContent-Type: text/html\r\n");
69 Request req((char*)&response, (Module*)this, event->GetSource());
77 char* OnRequest(Request* request)
82 void Implements(char* List)
84 List[I_OnEvent] = List[I_OnRequest] = 1;
87 virtual ~ModuleHttpStats()
91 virtual Version GetVersion()
93 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
98 class ModuleHttpStatsFactory : public ModuleFactory
101 ModuleHttpStatsFactory()
105 ~ModuleHttpStatsFactory()
109 virtual Module * CreateModule(Server* Me)
111 return new ModuleHttpStats(Me);
116 extern "C" void * init_module( void )
118 return new ModuleHttpStatsFactory;