]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_httpd_stats.cpp
957c9abfd7dc88eb46a2da13732aa35740ca927b
[user/henk/code/inspircd.git] / src / modules / m_httpd_stats.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                     E-mail:
7  *              <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *          the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 using namespace std;
18
19 #include <stdio.h>
20 #include "users.h"
21 #include "channels.h"
22 #include "modules.h"
23 #include "inspsocket.h"
24 #include "helperfuncs.h"
25 #include "httpd.h"
26
27 /* $ModDesc: Provides statistics over HTTP via m_httpd.so */
28
29 class ModuleHttpStats : public Module
30 {
31         Server* Srv;
32         std::stringstream data;
33  public:
34
35         void ReadConfig()
36         {
37         }
38
39         ModuleHttpStats(Server* Me) : Module::Module(Me)
40         {
41                 Srv = Me;
42                 ReadConfig();
43         }
44
45         void OnEvent(Event* event)
46         {
47                 if (event->GetEventID() == "httpd_url")
48                 {
49                         log(DEBUG,"HTTP URL!");
50
51                         data << "<html><h1>Chickens</h1></html>";
52
53                         HTTPDocument response(&data, 200, event->GetData()->sock);
54                         Request req(&response, this, event->GetSource());
55                         req.Send();
56                 }
57         }
58
59         char* OnRequest(Request* request)
60         {
61                 return NULL;
62         }
63
64         void Implements(char* List)
65         {
66                 List[I_OnEvent] = List[I_OnRequest] = 1;
67         }
68
69         virtual ~ModuleHttpStats()
70         {
71         }
72
73         virtual Version GetVersion()
74         {
75                 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
76         }
77 };
78
79
80 class ModuleHttpStatsFactory : public ModuleFactory
81 {
82  public:
83         ModuleHttpStatsFactory()
84         {
85         }
86         
87         ~ModuleHttpStatsFactory()
88         {
89         }
90         
91         virtual Module * CreateModule(Server* Me)
92         {
93                 return new ModuleHttpStats(Me);
94         }
95 };
96
97
98 extern "C" void * init_module( void )
99 {
100         return new ModuleHttpStatsFactory;
101 }