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::stringstream data;
39 ModuleHttpStats(Server* Me) : Module::Module(Me)
45 void OnEvent(Event* event)
47 if (event->GetEventID() == "httpd_url")
49 log(DEBUG,"HTTP URL!");
52 data << "<html><h1>Chickens</h1></html>";
54 HTTPRequest* http = (HTTPRequest*)event->GetData();
55 HTTPDocument response(http->sock, &data, 200, "X-Powered-By: m_http_stats.so\r\n");
56 Request req((char*)&response, (Module*)this, event->GetSource());
63 char* OnRequest(Request* request)
68 void Implements(char* List)
70 List[I_OnEvent] = List[I_OnRequest] = 1;
73 virtual ~ModuleHttpStats()
77 virtual Version GetVersion()
79 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
84 class ModuleHttpStatsFactory : public ModuleFactory
87 ModuleHttpStatsFactory()
91 ~ModuleHttpStatsFactory()
95 virtual Module * CreateModule(Server* Me)
97 return new ModuleHttpStats(Me);
102 extern "C" void * init_module( void )
104 return new ModuleHttpStatsFactory;