X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_svshold.cpp;h=a056c9d84e2a5c0300c98cdff6a50fa9a4661f78;hb=8f81017710b608e134d063b40bc2815d39e747f1;hp=abef3d713f11a8b3052b435089e9930858f6c127;hpb=276bbd193ed9dc53f44a4f564401d577d8e31424;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp index abef3d713..a056c9d84 100644 --- a/src/modules/m_svshold.cpp +++ b/src/modules/m_svshold.cpp @@ -11,12 +11,12 @@ * --------------------------------------------------- */ +#include "inspircd.h" #include #include "users.h" #include "channels.h" #include "modules.h" #include "configreader.h" -#include "inspircd.h" /* $ModDesc: Implements SVSHOLD. Like Q:Lines, but can only be added/removed by Services. */ @@ -66,6 +66,12 @@ class cmd_svshold : public command_t /* syntax: svshold nickname time :reason goes here */ /* 'time' is a human-readable timestring, like 2d3h2s. */ + if (!ServerInstance->ULine(user->server)) + { + /* don't allow SVSHOLD from non-ulined clients */ + return CMD_FAILURE; + } + if (pcnt == 1) { SVSHoldMap::iterator n = HoldMap.find(parameters[0]); @@ -84,7 +90,7 @@ class cmd_svshold : public command_t } else { - user->WriteServ( "386 %s %s :Removed permenant SVSHOLD (%s)", user->nick, (*iter)->nickname.c_str(), (*iter)->reason.c_str()); + user->WriteServ( "386 %s %s :Removed permanent SVSHOLD (%s)", user->nick, (*iter)->nickname.c_str(), (*iter)->reason.c_str()); } SVSHolds.erase(iter); break; @@ -153,7 +159,7 @@ class ModuleSVSHold : public Module public: - ModuleSVSHold(InspIRCd* Me) : Module::Module(Me) + ModuleSVSHold(InspIRCd* Me) : Module(Me) { mycommand = new cmd_svshold(Me); ServerInstance->AddCommand(mycommand); @@ -232,19 +238,21 @@ class ModuleSVSHold : public Module std::string EncodeSVSHold(const SVSHold* ban) { std::ostringstream stream; - stream << ban->nickname << " " << ban->set_by << " " << ban->set_on << " " << ban->length << " " << ban->reason; + stream << ban->nickname << " " << ban->set_by << " " << ban->set_on << " " << ban->length << " :" << ban->reason; return stream.str(); } SVSHold* DecodeSVSHold(const std::string &data) { SVSHold* res = new SVSHold(); - std::istringstream stream(data); - stream >> res->nickname; - stream >> res->set_by; - stream >> res->set_on; - stream >> res->length; - res->reason = stream.str(); + int set_on; + irc::tokenstream tokens(data); + tokens.GetToken(res->nickname); + tokens.GetToken(res->set_by); + tokens.GetToken(set_on); + res->set_on = set_on; + tokens.GetToken(res->length); + tokens.GetToken(res->reason); return res; } @@ -271,26 +279,4 @@ class ModuleSVSHold : public Module } }; -class ModuleSVSHoldFactory : public ModuleFactory -{ - public: - ModuleSVSHoldFactory() - { - } - - ~ModuleSVSHoldFactory() - { - } - - virtual Module * CreateModule(InspIRCd* Me) - { - return new ModuleSVSHold(Me); - } - -}; - - -extern "C" void * init_module( void ) -{ - return new ModuleSVSHoldFactory; -} +MODULE_INIT(ModuleSVSHold);