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(); } } }
void OnEvent(Event* event) { std::stringstream data(""); if (event->GetEventID() == "httpd_url") { HTTPRequest* http = (HTTPRequest*)event->GetData(); if (http->GetURI() == "/jsonrpc" && http->GetType() == "POST") { try { std::string response_text; json::rpc::process (http, response_text, http->GetPostData().c_str()); data << response_text; } catch (std::runtime_error &) { data << "{ \"result\": \"JSON Fault\", \"error\": \"Invalid RPC call\", \"id\": 1}"; } /* Send the document back to m_httpd */ HTTPDocument response(http->sock, &data, 200, "X-Powered-By: m_rpc_json.so\r\n" "Content-Type: application/json; charset=iso-8859-1\r\n"); Request req((char*)&response, (Module*)this, event->GetSource()); req.Send(); } } }
bool PluginLocate::HttpRequestHandle(HTTPRequest & request) { QString uri = request.GetURI(); if (uri.startsWith("/vl/locate.jsp")) { QString serialnumber = request.GetArg("sn").remove(':'); LogInfo(QString("Requesting LOCATE for tag %1").arg(serialnumber)); if(GlobalSettings::Get("Config/StandAlone", true) == false) { // Forward request to Violet QByteArray violetAnswer = request.ForwardTo(GlobalSettings::GetString("DefaultVioletServers/BootServer")); // Analyse the answer to see if servers has changed QList<QByteArray> lines = violetAnswer.split('\n'); foreach(QByteArray line, lines) { if (line.startsWith("ping")) {} else if (line.startsWith("broad")) {} else if (line.startsWith("xmpp_domain")) {} else if (line.size() != 0) LogError(QString("Unknown locate server : ") + line); } }
void PluginXmppport::HttpRequestAfter(HTTPRequest & request) { QString uri = request.GetURI(); int Cport = GetSettings("global/XmppPort", 5222).toInt(); if (uri.startsWith("/vl/bc.jsp") && Cport != 5222) { QByteArray port = convertLSBFirst(Cport); QByteArray origin = convertLSBFirst(5222); patchBootcode(request, 0x000111CF, 4, origin, port); } }
bool PluginRFID::HttpRequestHandle(HTTPRequest & request) { QString uri = request.GetURI(); if (uri.startsWith("/vl/rfid.jsp")) { QString serialnumber = request.GetArg("sn"); QString tagId = request.GetArg("t"); SetSettings("global/LastTag", tagId); Ztamp * z = ZtampManager::GetZtamp(this, tagId.toAscii()); Bunny * b = BunnyManager::GetBunny(this, serialnumber.toAscii()); b->SetPluginSetting(GetName(), "LastTag", tagId); if (z->OnRFID(b)) return true; if (b->OnRFID(QByteArray::fromHex(tagId.toAscii()))) return true; } return false; }
bool PluginTest::HttpRequestHandle(HTTPRequest & request) { QString uri = request.GetURI(); if (uri.startsWith("/openjabnab/plugin_test")) { Choregraphy c; c.SetTempo(400); for (int i = 0; i < 48; i++) { c.AddLedAction(i, Choregraphy::Led_Left, (i%3 == 0)?255:0, 0, 0); c.AddLedAction(i, Choregraphy::Led_Middle, 0, (i%3 == 1)?255:0, 0); c.AddLedAction(i, Choregraphy::Led_Right, 0, 0, (i%3 == 2)?255:0); } for (int i = 0; i < 12; i++) { c.AddMotorAction(4*i, Choregraphy::Ear_Left, 36*i, Choregraphy::Dir_Forward); c.AddMotorAction(4*i+2, Choregraphy::Ear_Right, 36*i, Choregraphy::Dir_Forward); } request.reply = c.GetData(); return true; } return false; }
void OnEvent(Event* event) { std::stringstream data(""); if (event->GetEventID() == "httpd_url") { HTTPRequest* http = (HTTPRequest*)event->GetData(); if ((http->GetURI() == "/stats") || (http->GetURI() == "/stats/")) { data << "<!DOCTYPE html PUBLIC \ \"-//W3C//DTD XHTML 1.1//EN\" \ \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n\ <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">"; data << "<head>"; data << "<link rel='stylesheet' href='" << this->stylesheet << "' type='text/css' />"; data << "<title>InspIRCd server statisitics for " << ServerInstance->Config->ServerName << " (" << ServerInstance->Config->ServerDesc << ")</title>"; data << "</head><body>"; data << "<h1>InspIRCd server statisitics for " << ServerInstance->Config->ServerName << " (" << ServerInstance->Config->ServerDesc << ")</h1>"; data << "<div class='totals'>"; data << "<h2>Totals</h2>"; data << "<table>"; data << "<tr><td>Users</td><td>" << ServerInstance->clientlist->size() << "</td></tr>"; data << "<tr><td>Channels</td><td>" << ServerInstance->chanlist->size() << "</td></tr>"; data << "<tr><td>Opers</td><td>" << ServerInstance->all_opers.size() << "</td></tr>"; data << "<tr><td>Sockets</td><td>" << (ServerInstance->SE->GetMaxFds() - ServerInstance->SE->GetRemainingFds()) << " (Max: " << ServerInstance->SE->GetMaxFds() << " via socket engine '" << ServerInstance->SE->GetName() << "')</td></tr>"; data << "</table>"; data << "</div>"; data << "<div class='modules'>"; data << "<h2>Modules</h2>"; data << "<table>"; for (int i = 0; i <= ServerInstance->GetModuleCount(); i++) { if (!ServerInstance->Config->module_names[i].empty()) data << "<tr><td>" << ServerInstance->Config->module_names[i] << "</td></tr>"; } data << "</table>"; data << "</div>"; data << "<div class='channels'>"; data << "<h2>Channels</h2>"; data << "<table>"; data << "<tr><th>Users</th><th>Name</th><th>@</th><th>%</th><th>+</th><th>Topic</th></tr>"; /* If the list has changed since last time it was displayed, re-sort it * this time only (not every time, as this would be moronic) */ if (this->changed) this->SortList(); int n = 0; for (SortedIter a = so->begin(); ((a != so->end()) && (n < 25)); a++, n++) { chanrec* c = ServerInstance->FindChan(a->second.c_str()); if (c) { data << "<tr><td>" << a->first << "</td><td>" << a->second << "</td>"; data << "<td>" << c->GetOppedUsers()->size() << "</td>"; data << "<td>" << c->GetHalfoppedUsers()->size() << "</td>"; data << "<td>" << c->GetVoicedUsers()->size() << "</td>"; data << "<td>" << c->topic << "</td>"; data << "</tr>"; } } data << "</table>"; data << "</div>"; data << "<div class='validion'>"; data << "<p><a href='http://validator.w3.org/check?uri=referer'><img src='http://www.w3.org/Icons/valid-xhtml11' alt='Valid XHTML 1.1' height='31' width='88' /></a></p>"; data << "</div>"; data << "</body>"; data << "</html>"; /* Send the document back to m_httpd */ HTTPDocument response(http->sock, &data, 200, "X-Powered-By: m_http_stats.so\r\nContent-Type: text/html; charset=iso-8859-1\r\n"); Request req((char*)&response, (Module*)this, event->GetSource()); req.Send(); }
void PluginAuth::HttpRequestAfter(HTTPRequest & request) { QString uri = request.GetURI(); if (uri.startsWith("/vl/bc.jsp")) { QString version = request.GetArg("v"); QString serialnumber = request.GetArg("m").remove(':'); Bunny * b = BunnyManager::GetBunny(this, serialnumber.toAscii()); if(b->GetBunnyPassword() == "" && GetSettings("global/authMethod", QString()).toString() == "patched") { LogDebug("Analyzing firmware for patch application"); long address1 = 0x00011A4A; long address2 = 0x00011A91; long address3 = 0x00011AC9; long address4 = 0x00011AEB; int size1 = 3; int size2 = 6; int size3 = 6; int size4 = 1; QByteArray origin1; QByteArray origin2; QByteArray origin3; QByteArray origin4; QByteArray patch1; QByteArray patch2; QByteArray patch3; QByteArray patch4; origin1.append((char)0x02).append((char)0x3D).append((char)0x00); origin2.append((char)0x02).append((char)0x3D).append((char)0x00).append((char)0x02).append((char)0x3E).append((char)0x00); origin3.append((char)0x02).append((char)0x3D).append((char)0x00).append((char)0x02).append((char)0x3E).append((char)0x00); origin4.append((char)0x02); patch1.append((char)0x07).append((char)0x00).append((char)0x05); patch2.append((char)0x04).append((char)0x05).append((char)0x04).append((char)0x05).append((char)0x04).append((char)0x05); patch3.append((char)0x04).append((char)0x05).append((char)0x04).append((char)0x05).append((char)0x04).append((char)0x05); patch4.append((char)0x01); bool patch = true; if(request.reply.indexOf(origin1, address1) != address1) { LogDebug("Part 1 : KO"); patch = false; } else LogDebug("Part 1 : OK"); if(request.reply.indexOf(origin2, address2) != address2) { LogDebug("Part 2 : KO"); patch = false; } else LogDebug("Part 2 : OK"); if(request.reply.indexOf(origin3, address3) != address3) { LogDebug("Part 3 : KO"); patch = false; } else LogDebug("Part 3 : OK"); if(request.reply.indexOf(origin4, address4) != address4) { LogDebug("Part 4 : KO"); patch = false; } else LogDebug("Part 4 : OK"); if(patch) { LogDebug("Patching firmware"); request.reply.replace(address1, size1, patch1); request.reply.replace(address2, size2, patch2); request.reply.replace(address3, size3, patch3); request.reply.replace(address4, size4, patch4); } } } }