mirror of
https://github.com/znc/znc.git
synced 2026-06-26 13:01:44 +02:00
send_raw: Add a web interface
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user