2007-07-16 17:30:04 +00:00
|
|
|
/* +------------------------------------+
|
|
|
|
* | Inspire Internet Relay Chat Daemon |
|
|
|
|
* +------------------------------------+
|
|
|
|
*
|
|
|
|
* InspIRCd: (C) 2002-2007 InspIRCd Development Team
|
|
|
|
* See: http://www.inspircd.org/wiki/index.php/Credits
|
|
|
|
*
|
|
|
|
* This program is free but copyrighted software; see
|
|
|
|
* the file COPYING for details.
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $ModDesc: Allows global loading of a module. */
|
|
|
|
|
|
|
|
#include "inspircd.h"
|
|
|
|
|
|
|
|
/** Handle /GLOADMODULE
|
|
|
|
*/
|
2007-10-21 21:43:48 +00:00
|
|
|
class CommandGloadmodule : public Command
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-10-21 21:43:48 +00:00
|
|
|
CommandGloadmodule (InspIRCd* Instance) : Command(Instance,"GLOADMODULE", 'o', 1)
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
|
|
|
this->source = "m_globalload.so";
|
2007-08-25 11:26:44 +00:00
|
|
|
syntax = "<modulename> [servermask]";
|
2007-08-27 16:05:59 +00:00
|
|
|
TRANSLATE3(TR_TEXT, TR_TEXT, TR_END);
|
2007-07-16 17:30:04 +00:00
|
|
|
}
|
|
|
|
|
2007-10-15 20:59:05 +00:00
|
|
|
CmdResult Handle (const char** parameters, int pcnt, User *user)
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
2007-08-25 11:26:44 +00:00
|
|
|
std::string servername = pcnt > 1 ? parameters[1] : "*";
|
2007-07-16 17:30:04 +00:00
|
|
|
|
2007-08-25 11:26:44 +00:00
|
|
|
if (ServerInstance->MatchText(ServerInstance->Config->ServerName, servername))
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
2007-08-28 23:32:41 +00:00
|
|
|
if (ServerInstance->Modules->Load(parameters[0]))
|
2007-08-25 11:26:44 +00:00
|
|
|
{
|
|
|
|
ServerInstance->WriteOpers("*** NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick);
|
|
|
|
user->WriteServ("975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-08-28 23:32:41 +00:00
|
|
|
user->WriteServ("974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->Modules->LastError());
|
2007-08-25 11:26:44 +00:00
|
|
|
}
|
2007-07-16 17:30:04 +00:00
|
|
|
}
|
2007-08-25 11:26:44 +00:00
|
|
|
else
|
|
|
|
ServerInstance->WriteOpers("*** MODULE '%s' GLOBAL LOAD BY '%s' (not loaded here)",parameters[0],user->nick);
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
2007-07-16 17:30:04 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Handle /GUNLOADMODULE
|
|
|
|
*/
|
2007-10-21 21:43:48 +00:00
|
|
|
class CommandGunloadmodule : public Command
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-10-21 21:43:48 +00:00
|
|
|
CommandGunloadmodule (InspIRCd* Instance) : Command(Instance,"GUNLOADMODULE", 'o', 1)
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
|
|
|
this->source = "m_globalload.so";
|
2007-08-25 11:26:44 +00:00
|
|
|
syntax = "<modulename> [servermask]";
|
2007-07-16 17:30:04 +00:00
|
|
|
}
|
|
|
|
|
2007-10-15 20:59:05 +00:00
|
|
|
CmdResult Handle (const char** parameters, int pcnt, User *user)
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
2007-08-25 11:26:44 +00:00
|
|
|
std::string servername = pcnt > 1 ? parameters[1] : "*";
|
|
|
|
|
|
|
|
if (ServerInstance->MatchText(ServerInstance->Config->ServerName, servername))
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
2007-08-28 23:32:41 +00:00
|
|
|
if (ServerInstance->Modules->Unload(parameters[0]))
|
2007-08-25 11:26:44 +00:00
|
|
|
{
|
|
|
|
ServerInstance->WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick);
|
|
|
|
user->WriteServ("973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-08-28 23:32:41 +00:00
|
|
|
user->WriteServ("972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->Modules->LastError());
|
2007-08-25 11:26:44 +00:00
|
|
|
}
|
2007-07-16 17:30:04 +00:00
|
|
|
}
|
|
|
|
else
|
2007-08-25 11:26:44 +00:00
|
|
|
ServerInstance->WriteOpers("*** MODULE '%s' GLOBAL UNLOAD BY '%s' (not unloaded here)",parameters[0],user->nick);
|
|
|
|
|
2007-07-16 17:30:04 +00:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Handle /GRELOADMODULE
|
|
|
|
*/
|
2007-10-21 21:43:48 +00:00
|
|
|
class CommandGreloadmodule : public Command
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-10-21 21:43:48 +00:00
|
|
|
CommandGreloadmodule (InspIRCd* Instance) : Command(Instance, "GRELOADMODULE", 'o', 1)
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
|
|
|
this->source = "m_globalload.so";
|
2007-08-25 11:26:44 +00:00
|
|
|
syntax = "<modulename> [servermask]";
|
2007-07-16 17:30:04 +00:00
|
|
|
}
|
|
|
|
|
2007-10-15 20:59:05 +00:00
|
|
|
CmdResult Handle(const char** parameters, int pcnt, User *user)
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
2007-08-25 11:26:44 +00:00
|
|
|
std::string servername = pcnt > 1 ? parameters[1] : "*";
|
2007-07-16 17:30:04 +00:00
|
|
|
|
2007-08-25 11:26:44 +00:00
|
|
|
if (ServerInstance->MatchText(ServerInstance->Config->ServerName, servername))
|
2007-07-16 17:30:04 +00:00
|
|
|
{
|
2007-08-28 23:32:41 +00:00
|
|
|
if (!ServerInstance->Modules->Unload(parameters[0]))
|
2007-08-25 11:26:44 +00:00
|
|
|
{
|
2007-08-28 23:32:41 +00:00
|
|
|
user->WriteServ("972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->Modules->LastError());
|
2007-08-25 11:26:44 +00:00
|
|
|
}
|
2007-08-28 23:32:41 +00:00
|
|
|
if (!ServerInstance->Modules->Load(parameters[0]))
|
2007-08-25 11:26:44 +00:00
|
|
|
{
|
2007-08-28 23:32:41 +00:00
|
|
|
user->WriteServ("974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->Modules->LastError());
|
2007-08-25 11:26:44 +00:00
|
|
|
}
|
|
|
|
ServerInstance->WriteOpers("*** MODULE '%s' GLOBALLY RELOADED BY '%s'",parameters[0],user->nick);
|
|
|
|
user->WriteServ("975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
|
2007-07-16 17:30:04 +00:00
|
|
|
}
|
2007-08-25 11:26:44 +00:00
|
|
|
else
|
|
|
|
ServerInstance->WriteOpers("*** MODULE '%s' GLOBAL RELOAD BY '%s' (not reloaded here)",parameters[0],user->nick);
|
2007-07-16 17:30:04 +00:00
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class ModuleGlobalLoad : public Module
|
|
|
|
{
|
2007-10-21 21:43:48 +00:00
|
|
|
CommandGloadmodule *mycommand;
|
|
|
|
CommandGunloadmodule *mycommand2;
|
|
|
|
CommandGreloadmodule *mycommand3;
|
2007-07-16 17:30:04 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
ModuleGlobalLoad(InspIRCd* Me) : Module(Me)
|
|
|
|
{
|
|
|
|
|
2007-10-21 21:43:48 +00:00
|
|
|
mycommand = new CommandGloadmodule(ServerInstance);
|
|
|
|
mycommand2 = new CommandGunloadmodule(ServerInstance);
|
|
|
|
mycommand3 = new CommandGreloadmodule(ServerInstance);
|
2007-07-16 17:30:04 +00:00
|
|
|
ServerInstance->AddCommand(mycommand);
|
|
|
|
ServerInstance->AddCommand(mycommand2);
|
|
|
|
ServerInstance->AddCommand(mycommand3);
|
2007-11-04 18:30:43 +00:00
|
|
|
|
2007-07-16 17:30:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~ModuleGlobalLoad()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual Version GetVersion()
|
|
|
|
{
|
2007-08-03 21:22:10 +00:00
|
|
|
return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
|
2007-07-16 17:30:04 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_INIT(ModuleGlobalLoad)
|