mirror of
https://github.com/znc/znc.git
synced 2026-05-04 04:22:37 +02:00
Merge remote branch 'github-kylef/send_raw'
This commit is contained in:
@@ -25,6 +25,45 @@ 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");
|
||||
}
|
||||
|
||||
const map<CString,CUser*>& msUsers = CZNC::Get().GetUserMap();
|
||||
for (map<CString,CUser*>::const_iterator it = msUsers.begin(); it != msUsers.end(); ++it) {
|
||||
CTemplate& l = Tmpl.AddRow("UserLoop");
|
||||
l["Username"] = (*it->second).GetUserName();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void OnModCommand(const CString& sLine) {
|
||||
const CString sUser = sLine.Token(0);
|
||||
const CString sDirection = sLine.Token(1);
|
||||
|
||||
43
modules/extra/send_raw/tmpl/index.tmpl
Normal file
43
modules/extra/send_raw/tmpl/index.tmpl
Normal file
@@ -0,0 +1,43 @@
|
||||
<? INC Header.tmpl ?>
|
||||
|
||||
<form method="post" action="/mods/send_raw/">
|
||||
<? INC _csrf_check.tmpl ?>
|
||||
|
||||
<div class="section">
|
||||
<h3>Send a raw IRC line</h3>
|
||||
|
||||
<div class="sectionbg">
|
||||
<div class="sectionbody">
|
||||
<div class="subsection third">
|
||||
<div class="inputlabel">User:</div>
|
||||
<div><select name="user">
|
||||
<? LOOP UserLoop?>
|
||||
<option value="<? VAR Username ESC=HTML ?>"><? VAR Username ESC=HTML ?></option>
|
||||
<? ENDLOOP ?>
|
||||
</select></div>
|
||||
</div>
|
||||
|
||||
<div class="subsection third">
|
||||
<div class="inputlabel">Direction:</div>
|
||||
<div>
|
||||
<select name="direction">
|
||||
<option value="in"<? IF direction_in ?> selected="yes"<? ENDIF ?>>in</option>
|
||||
<option value="out"<? IF direction_out ?> selected="yes"<? ENDIF ?>>out</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="subsection full">
|
||||
<div class="inputlabel">Line:</div>
|
||||
<div><input type="text" name="line" value="<? VAR line ?>" /></div>
|
||||
</div>
|
||||
|
||||
<div class="subsection submitline">
|
||||
<input type="submit" value="Send">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<? INC Footer.tmpl ?>
|
||||
Reference in New Issue
Block a user