ModResult HandleRequest(HTTPRequest* http) { std::stringstream data(""); { ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Handling httpd event"); if ((http->GetURI() == "/config") || (http->GetURI() == "/config/")) { data << "<html><head><title>InspIRCd Configuration</title></head><body>"; data << "<h1>InspIRCd Configuration</h1><p>"; for (ConfigDataHash::iterator x = ServerInstance->Config->config_data.begin(); x != ServerInstance->Config->config_data.end(); ++x) { data << "<" << x->first << " "; ConfigTag* tag = x->second; for (std::vector<KeyVal>::const_iterator j = tag->getItems().begin(); j != tag->getItems().end(); j++) { data << Sanitize(j->first) << "="" << Sanitize(j->second) << "" "; } data << "><br>"; } data << "</body></html>"; /* Send the document back to m_httpd */ HTTPDocumentResponse response(this, *http, &data, 200); response.headers.SetHeader("X-Powered-By", MODNAME); response.headers.SetHeader("Content-Type", "text/html"); API->SendResponse(response); return MOD_RES_DENY; // Handled } } return MOD_RES_PASSTHRU; }
void OnEvent(Event& event) { std::stringstream data(""); if (event.id == "httpd_url") { ServerInstance->Logs->Log("m_http_stats", LOG_DEBUG,"Handling httpd event"); HTTPRequest* http = (HTTPRequest*)&event; if ((http->GetURI() == "/config") || (http->GetURI() == "/config/")) { data << "<html><head><title>InspIRCd Configuration</title></head><body>"; data << "<h1>InspIRCd Configuration</h1><p>"; for (ConfigDataHash::iterator x = ServerInstance->Config->config_data.begin(); x != ServerInstance->Config->config_data.end(); ++x) { data << "<" << x->first << " "; ConfigTag* tag = x->second; for (std::vector<KeyVal>::const_iterator j = tag->getItems().begin(); j != tag->getItems().end(); j++) { data << Sanitize(j->first) << "="" << Sanitize(j->second) << "" "; } data << "><br>"; } data << "</body></html>"; /* Send the document back to m_httpd */ HTTPDocumentResponse response(this, *http, &data, 200); response.headers.SetHeader("X-Powered-By", "m_httpd_config.so"); response.headers.SetHeader("Content-Type", "text/html"); response.Send(); } } }