* 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 Sadie Powell <sadie@witchery.services>
+ * 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>
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 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);