#include "users.h"
#include "modes/cmode_k.h"
-ModeChannelKey::ModeChannelKey() : ModeHandler('k', 1, 1, false, MODETYPE_CHANNEL, false)
+ModeChannelKey::ModeChannelKey(InspIRCd* Instance) : ModeHandler(Instance, 'k', 1, 1, false, MODETYPE_CHANNEL, false)
{
}
if (((channel->modes[CM_KEY]) && (strcasecmp(parameter.c_str(),channel->key))) && (IS_LOCAL(source)))
{
/* Key is currently set and the correct key wasnt given */
- log(DEBUG,"Key Cond 2");
+ ServerInstance->Log(DEBUG,"Key Cond 2");
return MODEACTION_DENY;
}
else if ((!channel->modes[CM_KEY]) || ((adding) && (!IS_LOCAL(source))))
{
/* Key isnt currently set */
- strlcpy(channel->key,parameter.c_str(),32);
- channel->modes[CM_KEY] = adding;
- return MODEACTION_ALLOW;
+ if ((parameter.length()) && (parameter.rfind(' ') == std::string::npos))
+ {
+ strlcpy(channel->key,parameter.c_str(),32);
+ channel->modes[CM_KEY] = adding;
+ return MODEACTION_ALLOW;
+ }
+ else
+ return MODEACTION_DENY;
}
else if (((channel->modes[CM_KEY]) && (!strcasecmp(parameter.c_str(),channel->key))) || ((!adding) && (!IS_LOCAL(source))))
{
channel->modes[CM_KEY] = adding;
return MODEACTION_ALLOW;
}
- log(DEBUG,"Key Cond three");
+ ServerInstance->Log(DEBUG,"Key Cond three");
return MODEACTION_DENY;
}
else
{
- log(DEBUG,"Key Condition one");
+ ServerInstance->Log(DEBUG,"Key Condition one");
return MODEACTION_DENY;
}
}