]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_httpd_stats.cpp
Add support for blocking tag messages with the deaf mode.
[user/henk/code/inspircd.git] / src / modules / m_httpd_stats.cpp
index 3be8ec9703562225257e496016a01a5a81d964ac..1e9f4ef4b92f6d8a33809b5b70d4778b6cfed8e1 100644 (file)
@@ -1,11 +1,19 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2019 linuxdaemon <linuxdaemon.irc@gmail.com>
+ *   Copyright (C) 2018 Matt Schatz <genius3000@g3k.solutions>
+ *   Copyright (C) 2016 Johanna A <johanna-a@users.noreply.github.com>
+ *   Copyright (C) 2013-2016 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2013, 2017, 2019-2020 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- *   Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2008-2009 Robin Burchell <robin+git@viroteck.net>
  *   Copyright (C) 2008 Pippijn van Steenhoven <pip88nl@gmail.com>
- *   Copyright (C) 2006-2008 Craig Edwards <craigedwards@brainbox.cc>
+ *   Copyright (C) 2007 John Brooks <special@inspircd.org>
  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ *   Copyright (C) 2006-2008, 2010 Craig Edwards <brain@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -86,7 +94,7 @@ namespace Stats
                for (Extensible::ExtensibleStore::const_iterator i = ext->GetExtList().begin(); i != ext->GetExtList().end(); i++)
                {
                        ExtensionItem* item = i->first;
-                       std::string value = item->serialize(FORMAT_USER, ext, i->second);
+                       std::string value = item->ToHuman(ext, i->second);
                        if (!value.empty())
                                data << "<meta name=\"" << item->name << "\">" << Sanitize(value) << "</meta>";
                        else if (!item->name.empty())
@@ -415,32 +423,27 @@ class ModuleHttpStats : public Module, public HTTPRequestEventListener
 
        ModResult HandleRequest(HTTPRequest* http)
        {
-               std::string path = http->GetPath();
-
-               if (path != "/stats" && path.substr(0, 7) != "/stats/")
+               if (http->GetPath() != "/stats")
                        return MOD_RES_PASSTHRU;
 
-               if (path[path.size() - 1] == '/')
-                       path.erase(path.size() - 1, 1);
-
-               ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Handling httpd event");
+               ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Handling HTTP request for %s", http->GetPath().c_str());
 
                bool found = true;
                std::stringstream data;
                data << "<inspircdstats>";
 
-               if (path == "/stats")
+               if (http->GetPath() == "/stats")
                {
                        data << Stats::ServerInfo << Stats::General
                                << Stats::XLines << Stats::Modules
                                << Stats::Channels << Stats::Users
                                << Stats::Servers << Stats::Commands;
                }
-               else if (path == "/stats/general")
+               else if (http->GetPath() == "/stats/general")
                {
                        data << Stats::General;
                }
-               else if (path == "/stats/users")
+               else if (http->GetPath() == "/stats/users")
                {
                        if (enableparams)
                                Stats::ListUsers(data, http->GetParsedURI().query_params);
@@ -477,7 +480,7 @@ class ModuleHttpStats : public Module, public HTTPRequestEventListener
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Provides statistics over HTTP via m_httpd", VF_VENDOR);
+               return Version("Provides XML-serialised statistics about the server, channels, and users over HTTP via the /stats path.", VF_VENDOR);
        }
 };