diff --git a/modules/extra/send_raw.cpp b/modules/extra/send_raw.cpp index 4145ddde..6c3af533 100644 --- a/modules/extra/send_raw.cpp +++ b/modules/extra/send_raw.cpp @@ -25,6 +25,39 @@ public: return true; } + virtual CString GetWebMenuTitle() { return "Send Raw"; } + virtual bool WebRequiresAdmin() { return true; } + + virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) { + if (sPageName == "index") { + if (WebSock.IsPost()) { + CUser *pUser = CZNC::Get().FindUser(WebSock.GetParam("user")); + bool bOutgoing = WebSock.GetParam("direction") == "out"; + const CString sLine = WebSock.GetParam("line"); + + if (!pUser) { + Tmpl["user"] = WebSock.GetParam("user"); + Tmpl[bOutgoing ? "direction_out" : "direction_in"] = "true"; + Tmpl["line"] = sLine; + WebSock.GetSession()->AddError("User not found"); + return true; + } + + if (bOutgoing) { + pUser->PutIRC(sLine); + } else { + pUser->PutUser(sLine); + } + + WebSock.GetSession()->AddSuccess("Line sent"); + } + + return true; + } + + return false; + } + virtual void OnModCommand(const CString& sLine) { const CString sUser = sLine.Token(0); const CString sDirection = sLine.Token(1); diff --git a/modules/extra/send_raw/tmpl/index.tmpl b/modules/extra/send_raw/tmpl/index.tmpl new file mode 100644 index 00000000..c8ee0a8f --- /dev/null +++ b/modules/extra/send_raw/tmpl/index.tmpl @@ -0,0 +1,39 @@ + INC Header.tmpl ?> + +
+ + INC Footer.tmpl ?>