From ba183e461fea68a621788ea46c54dbd6bd8d014f Mon Sep 17 00:00:00 2001 From: cflakes Date: Fri, 31 Dec 2010 15:09:07 +0000 Subject: [PATCH] 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 --- modules/perform.cpp | 18 +++++++++++------- modules/perform/tmpl/index.tmpl | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/perform.cpp b/modules/perform.cpp index b75e9881..80b1f5ed 100644 --- a/modules/perform.cpp +++ b/modules/perform.cpp @@ -15,7 +15,7 @@ public: virtual ~CPerform() {} - CString ParsePerform(const CString& sArg) { + CString ParsePerform(const CString& sArg) const { CString sPerf = sArg; if (sPerf.Left(1) == "/") @@ -67,7 +67,7 @@ public: } else if (sCmdName == "list") { int i = 1; 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); if (sExpanded != *it) PutModule(CString(i) + ": " + *it + " (" + sExpanded + ")"); @@ -95,8 +95,7 @@ public: } virtual void OnIRCConnected() { - 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) { PutIRC(GetUser()->ExpandString(*it)); } } @@ -104,18 +103,23 @@ public: virtual CString GetWebMenuTitle() { return "Perform"; } virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) { + if (sPageName != "index") { + // only accept requests to /mods/perform/ + return false; + } + if (WebSock.IsPost()) { VCString vsPerf; WebSock.GetRawParam("perform", true).Split("\n", vsPerf, false); 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)); 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"); Row["Perform"] = *it; } @@ -127,7 +131,7 @@ private: void Save() { 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"; } SetNV("Perform", sBuffer); diff --git a/modules/perform/tmpl/index.tmpl b/modules/perform/tmpl/index.tmpl index ab7cd6d0..d8a1d8cc 100644 --- a/modules/perform/tmpl/index.tmpl +++ b/modules/perform/tmpl/index.tmpl @@ -11,7 +11,7 @@
-
Commands sent to the IRCd on connect, one per line. +
Commands sent to the IRC server on connect, one per line.