summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-27 15:31:37 +0000
committerom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-27 15:31:37 +0000
commit80005149269014babdcacd76f2be1d7249c489eb (patch)
tree63505b3e0fd6759697c96fd0468486e1199027bd
parente7f1d2d6b4a3970b8037ee2f91bec9b29ab5a94e (diff)
Indentation fixes, and stop it snoticing on every join by an override-allowed oper when there's no limit set
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3775 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/m_override.cpp88
1 files changed, 52 insertions, 36 deletions
diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp
index f73cd2aa3..16c3a5295 100644
--- a/src/modules/m_override.cpp
+++ b/src/modules/m_override.cpp
@@ -14,9 +14,6 @@
* ---------------------------------------------------
*/
-using namespace std;
-
-#include <stdio.h>
#include "users.h"
#include "channels.h"
#include "modules.h"
@@ -31,8 +28,6 @@ class ModuleOverride : public Module
Server *Srv;
override_t overrides;
bool NoisyOverride;
- ConfigReader *Conf;
-
public:
ModuleOverride(Server* Me)
@@ -43,7 +38,6 @@ class ModuleOverride : public Module
// classes.
Srv = Me;
- Conf = new ConfigReader;
// read our config options (main config file)
OnRehash("");
@@ -52,8 +46,8 @@ class ModuleOverride : public Module
virtual void OnRehash(const std::string &parameter)
{
// on a rehash we delete our classes for good measure and create them again.
- delete Conf;
- Conf = new ConfigReader;
+ ConfigReader* Conf = new ConfigReader;
+
// re-read our config options on a rehash
NoisyOverride = Conf->ReadFlag("override","noisy",0);
overrides.clear();
@@ -63,6 +57,8 @@ class ModuleOverride : public Module
std::string tokenlist = Conf->ReadValue("type","override",j);
overrides[typen] = tokenlist;
}
+
+ delete Conf;
}
void Implements(char* List)
@@ -70,20 +66,22 @@ class ModuleOverride : public Module
List[I_OnRehash] = List[I_OnAccessCheck] = List[I_On005Numeric] = List[I_OnUserPreJoin] = List[I_OnUserPreKick] = 1;
}
- virtual void On005Numeric(std::string &output)
- {
- output = output + std::string(" OVERRIDE");
- }
+ virtual void On005Numeric(std::string &output)
+ {
+ output.append(" OVERRIDE");
+ }
virtual bool CanOverride(userrec* source, char* token)
{
// checks to see if the oper's type has <type:override>
override_t::iterator j = overrides.find(source->oper);
+
if (j != overrides.end())
- {
+ {
// its defined, return its value as a boolean for if the token is set
- return strstr(j->second.c_str(),token);
- }
+ return (j->second.find(token, 0) != std::string::npos);
+ }
+
// its not defined at all, count as false
return false;
}
@@ -119,53 +117,71 @@ class ModuleOverride : public Module
if (CanOverride(source,"MODEDEOP"))
{
Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Deopped "+std::string(dest->nick)+" on "+std::string(channel->name));
- return ACR_ALLOW;
+ return ACR_ALLOW;
}
- else return ACR_DEFAULT;
- break;
+ else
+ {
+ return ACR_DEFAULT;
+ }
+
case AC_OP:
if (CanOverride(source,"MODEOP"))
{
Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Opped "+std::string(dest->nick)+" on "+std::string(channel->name));
- return ACR_ALLOW;
+ return ACR_ALLOW;
}
- else return ACR_DEFAULT;
- break;
+ else
+ {
+ return ACR_DEFAULT;
+ }
+
case AC_VOICE:
if (CanOverride(source,"MODEVOICE"))
{
Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Voiced "+std::string(dest->nick)+" on "+std::string(channel->name));
- return ACR_ALLOW;
+ return ACR_ALLOW;
+ }
+ else
+ {
+ return ACR_DEFAULT;
}
- else return ACR_DEFAULT;
- break;
+
case AC_DEVOICE:
if (CanOverride(source,"MODEDEVOICE"))
{
Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Devoiced "+std::string(dest->nick)+" on "+std::string(channel->name));
- return ACR_ALLOW;
+ return ACR_ALLOW;
+ }
+ else
+ {
+ return ACR_DEFAULT;
}
- else return ACR_DEFAULT;
- break;
+
case AC_HALFOP:
if (CanOverride(source,"MODEHALFOP"))
{
Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Halfopped "+std::string(dest->nick)+" on "+std::string(channel->name));
- return ACR_ALLOW;
+ return ACR_ALLOW;
+ }
+ else
+ {
+ return ACR_DEFAULT;
}
- else return ACR_DEFAULT;
- break;
+
case AC_DEHALFOP:
if (CanOverride(source,"MODEDEHALFOP"))
{
Srv->SendOpers("*** NOTICE: "+std::string(source->nick)+" Override-Dehalfopped "+std::string(dest->nick)+" on "+std::string(channel->name));
- return ACR_ALLOW;
+ return ACR_ALLOW;
+ }
+ else
+ {
+ return ACR_DEFAULT;
}
- else return ACR_DEFAULT;
- break;
}
}
}
+
if (CanOverride(source,"OTHERMODE"))
{
return ACR_ALLOW;
@@ -192,7 +208,8 @@ class ModuleOverride : public Module
irc::string x = chan->name;
if (!user->IsInvited(x))
{
- WriteChannelWithServ((char*)Srv->GetServerName().c_str(),chan,"NOTICE %s :%s invited himself into the channel",cname,user->nick);
+ /* XXX - Ugly cast for a parameter that isn't used? :< - Om */
+ WriteChannelWithServ((char*)Srv->GetServerName().c_str(), chan, "NOTICE %s :%s invited himself into the channel",cname,user->nick);
}
}
Srv->SendOpers("*** "+std::string(user->nick)+" used operoverride to bypass +i on "+std::string(cname));
@@ -207,7 +224,7 @@ class ModuleOverride : public Module
return -1;
}
- if ((Srv->CountUsers(chan) >= chan->limit) && (CanOverride(user,"LIMIT")))
+ if ((chan->limit > 0) && (Srv->CountUsers(chan) >= chan->limit) && (CanOverride(user,"LIMIT")))
{
if (NoisyOverride)
WriteChannelWithServ((char*)Srv->GetServerName().c_str(),chan,"NOTICE %s :%s passed through your channel limit",cname,user->nick);
@@ -227,7 +244,6 @@ class ModuleOverride : public Module
virtual ~ModuleOverride()
{
- delete Conf;
}
virtual Version GetVersion()