#include "inspircd.h"
-#include "httpd.h"
+#include "modules/httpd.h"
#include "xline.h"
#include "protocol.h"
-/* $ModDesc: Provides statistics over HTTP via m_httpd.so */
-
class ModuleHttpStats : public Module
{
static std::map<char, char const*> const &entities;
+ HTTPdAPI API;
public:
+ ModuleHttpStats()
+ : API(this)
+ {
+ }
- void init()
+ void init() CXX11_OVERRIDE
{
Implementation eventlist[] = { I_OnEvent };
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
data << "</metadata>";
}
- void OnEvent(Event& event)
+ void OnEvent(Event& event) CXX11_OVERRIDE
{
std::stringstream data("");
if (event.id == "httpd_url")
{
- ServerInstance->Logs->Log("m_http_stats", LOG_DEBUG,"Handling httpd event");
+ ServerInstance->Logs->Log("m_http_stats", LOG_DEBUG, "Handling httpd event");
HTTPRequest* http = (HTTPRequest*)&event;
if ((http->GetURI() == "/stats") || (http->GetURI() == "/stats/"))
if (u->IsAway())
data << "<away>" << Sanitize(u->awaymsg) << "</away><awaytime>" << u->awaytime << "</awaytime>";
if (u->IsOper())
- data << "<opertype>" << Sanitize(u->oper->NameStr()) << "</opertype>";
+ data << "<opertype>" << Sanitize(u->oper->name) << "</opertype>";
data << "<modes>" << u->FormatModes() << "</modes><ident>" << Sanitize(u->ident) << "</ident>";
LocalUser* lu = IS_LOCAL(u);
if (lu)
HTTPDocumentResponse response(this, *http, &data, 200);
response.headers.SetHeader("X-Powered-By", "m_httpd_stats.so");
response.headers.SetHeader("Content-Type", "text/xml");
- response.Send();
+ API->SendResponse(response);
}
}
}
- virtual Version GetVersion()
+ Version GetVersion() CXX11_OVERRIDE
{
return Version("Provides statistics over HTTP via m_httpd.so", VF_VENDOR);
}