X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_chghost.cpp;h=fc5507822eb927bf7298ff01c0f921b93bc860a9;hb=f9636a2eff46f6829bf9e01c711ab1ba45a7d50a;hp=42b1378e04e18be6c6e6524132ab0f37b26e2c20;hpb=9861679f40d2a4f03e524998039c00d2bc838636;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp index 42b1378e0..fc5507822 100644 --- a/src/modules/m_chghost.cpp +++ b/src/modules/m_chghost.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * Inspire is copyright (C) 2002-2004 ChatSpike-Dev. + * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. * E-mail: * * @@ -21,41 +21,50 @@ using namespace std; #include "users.h" #include "channels.h" #include "modules.h" +#include "helperfuncs.h" +#include "inspircd.h" /* $ModDesc: Provides support for the CHGHOST command */ -Server *Srv; - +static Server *Srv; +extern InspIRCd* ServerInstance; class cmd_chghost : public command_t { public: - cmd_chghost () : command_t("CHGHOST",'o',2) - { - this->source = "m_chghost.so"; - } + cmd_chghost () : command_t("CHGHOST",'o',2) + { + this->source = "m_chghost.so"; + syntax = " "; + } - void Handle(char **parameters, int pcnt, userrec *user) + void Handle(const char** parameters, int pcnt, userrec *user) { - for (unsigned int x = 0; x < strlen(parameters[1]); x++) + const char * x = parameters[1]; + + for (; *x; x++) { - if (((tolower(parameters[1][x]) < 'a') || (tolower(parameters[1][x]) > 'z')) && (parameters[1][x] != '.')) + if (((tolower(*x) < 'a') || (tolower(*x) > 'z')) && (*x != '.')) { - if (((parameters[1][x] < '0') || (parameters[1][x]> '9')) && (parameters[1][x] != '-')) + if (((*x < '0') || (*x > '9')) && (*x != '-')) { - Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname"); + user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname"); return; } } - } - userrec* dest = Srv->FindNick(std::string(parameters[0])); + } + if ((parameters[1] - x) > 63) + { + user->WriteServ("NOTICE %s :*** CHGHOST: Host too long",user->nick); + return; + } + userrec* dest = ServerInstance->FindNick(parameters[0]); if (dest) { - Srv->ChangeHost(dest,parameters[1]); - if (!Srv->IsUlined(user->server)) + if ((dest->ChangeDisplayedHost(parameters[1])) && (!Srv->IsUlined(user->server))) { // fix by brain - ulines set hosts silently - Srv->SendOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+std::string(dest->nick)+" become "+std::string(parameters[1])); + ServerInstance->WriteOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+dest->nick+" become "+parameters[1]); } } }