Perform module:

* Be more const.
* Be more correct: only accept requests to /mods/perform/, not to all URLs starting with that.
* Be more considerate: Use "IRC server" instead of "IRCd".



git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2232 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
cflakes
2010-12-31 15:09:07 +00:00
parent 89edf703f6
commit ba183e461f
2 changed files with 12 additions and 8 deletions
+11 -7
View File
@@ -15,7 +15,7 @@ public:
virtual ~CPerform() {} virtual ~CPerform() {}
CString ParsePerform(const CString& sArg) { CString ParsePerform(const CString& sArg) const {
CString sPerf = sArg; CString sPerf = sArg;
if (sPerf.Left(1) == "/") if (sPerf.Left(1) == "/")
@@ -67,7 +67,7 @@ public:
} else if (sCmdName == "list") { } else if (sCmdName == "list") {
int i = 1; int i = 1;
CString sExpanded; CString sExpanded;
for (VCString::iterator it = m_vPerform.begin(); it != m_vPerform.end(); it++, i++) { for (VCString::const_iterator it = m_vPerform.begin(); it != m_vPerform.end(); it++, i++) {
sExpanded = GetUser()->ExpandString(*it); sExpanded = GetUser()->ExpandString(*it);
if (sExpanded != *it) if (sExpanded != *it)
PutModule(CString(i) + ": " + *it + " (" + sExpanded + ")"); PutModule(CString(i) + ": " + *it + " (" + sExpanded + ")");
@@ -95,8 +95,7 @@ public:
} }
virtual void OnIRCConnected() { virtual void OnIRCConnected() {
for (VCString::iterator it = m_vPerform.begin(); for (VCString::const_iterator it = m_vPerform.begin(); it != m_vPerform.end(); ++it) {
it != m_vPerform.end(); ++it) {
PutIRC(GetUser()->ExpandString(*it)); PutIRC(GetUser()->ExpandString(*it));
} }
} }
@@ -104,18 +103,23 @@ public:
virtual CString GetWebMenuTitle() { return "Perform"; } virtual CString GetWebMenuTitle() { return "Perform"; }
virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) { virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) {
if (sPageName != "index") {
// only accept requests to /mods/perform/
return false;
}
if (WebSock.IsPost()) { if (WebSock.IsPost()) {
VCString vsPerf; VCString vsPerf;
WebSock.GetRawParam("perform", true).Split("\n", vsPerf, false); WebSock.GetRawParam("perform", true).Split("\n", vsPerf, false);
m_vPerform.clear(); m_vPerform.clear();
for (VCString::iterator it = vsPerf.begin(); it != vsPerf.end(); ++it) for (VCString::const_iterator it = vsPerf.begin(); it != vsPerf.end(); ++it)
m_vPerform.push_back(ParsePerform(*it)); m_vPerform.push_back(ParsePerform(*it));
Save(); Save();
} }
for (VCString::iterator it = m_vPerform.begin(); it != m_vPerform.end(); ++it) { for (VCString::const_iterator it = m_vPerform.begin(); it != m_vPerform.end(); ++it) {
CTemplate& Row = Tmpl.AddRow("PerformLoop"); CTemplate& Row = Tmpl.AddRow("PerformLoop");
Row["Perform"] = *it; Row["Perform"] = *it;
} }
@@ -127,7 +131,7 @@ private:
void Save() { void Save() {
CString sBuffer = ""; CString sBuffer = "";
for (VCString::iterator it = m_vPerform.begin(); it != m_vPerform.end(); ++it) { for (VCString::const_iterator it = m_vPerform.begin(); it != m_vPerform.end(); ++it) {
sBuffer += *it + "\n"; sBuffer += *it + "\n";
} }
SetNV("Perform", sBuffer); SetNV("Perform", sBuffer);
+1 -1
View File
@@ -11,7 +11,7 @@
<div><textarea name="perform" cols="70" rows="5" class="monospace"><? LOOP PerformLoop ?><? VAR Perform ?> <div><textarea name="perform" cols="70" rows="5" class="monospace"><? LOOP PerformLoop ?><? VAR Perform ?>
<? ENDLOOP ?> <? ENDLOOP ?>
</textarea></div> </textarea></div>
<br /><span class="info">Commands sent to the IRCd on connect, one per line.</span> <br /><span class="info">Commands sent to the IRC server on connect, one per line.</span>
</div> </div>
<div class="subsection submitline"> <div class="subsection submitline">
<input type="submit" name="save" value="Save" /> <input type="submit" name="save" value="Save" />