00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "inspircd.h"
00017
00020 class CommandGloadmodule : public Command
00021 {
00022 public:
00023 CommandGloadmodule (InspIRCd* Instance) : Command(Instance,"GLOADMODULE", "o", 1)
00024 {
00025 this->source = "m_globalload.so";
00026 syntax = "<modulename> [servermask]";
00027 TRANSLATE3(TR_TEXT, TR_TEXT, TR_END);
00028 }
00029
00030 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
00031 {
00032 std::string servername = parameters.size() > 1 ? parameters[1] : "*";
00033
00034 if (InspIRCd::Match(ServerInstance->Config->ServerName, servername))
00035 {
00036 if (ServerInstance->Modules->Load(parameters[0].c_str()))
00037 {
00038 ServerInstance->SNO->WriteToSnoMask('A', "NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0].c_str(), user->nick.c_str());
00039 user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick.c_str(), parameters[0].c_str());
00040 }
00041 else
00042 {
00043 user->WriteNumeric(974, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
00044 }
00045 }
00046 else
00047 ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBAL LOAD BY '%s' (not loaded here)",parameters[0].c_str(), user->nick.c_str());
00048
00049 return CMD_SUCCESS;
00050 }
00051 };
00052
00055 class CommandGunloadmodule : public Command
00056 {
00057 public:
00058 CommandGunloadmodule (InspIRCd* Instance) : Command(Instance,"GUNLOADMODULE", "o", 1)
00059 {
00060 this->source = "m_globalload.so";
00061 syntax = "<modulename> [servermask]";
00062 }
00063
00064 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
00065 {
00066 std::string servername = parameters.size() > 1 ? parameters[1] : "*";
00067
00068 if (InspIRCd::Match(ServerInstance->Config->ServerName, servername))
00069 {
00070 if (ServerInstance->Modules->Unload(parameters[0].c_str()))
00071 {
00072 ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0].c_str(), user->nick.c_str());
00073 user->WriteNumeric(973, "%s %s :Module successfully unloaded.",user->nick.c_str(), parameters[0].c_str());
00074 }
00075 else
00076 {
00077 user->WriteNumeric(972, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
00078 }
00079 }
00080 else
00081 ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBAL UNLOAD BY '%s' (not unloaded here)",parameters[0].c_str(), user->nick.c_str());
00082
00083 return CMD_SUCCESS;
00084 }
00085 };
00086
00089 class CommandGreloadmodule : public Command
00090 {
00091 public:
00092 CommandGreloadmodule (InspIRCd* Instance) : Command(Instance, "GRELOADMODULE", "o", 1)
00093 {
00094 this->source = "m_globalload.so";
00095 syntax = "<modulename> [servermask]";
00096 }
00097
00098 CmdResult Handle(const std::vector<std::string> ¶meters, User *user)
00099 {
00100 std::string servername = parameters.size() > 1 ? parameters[1] : "*";
00101
00102 if (InspIRCd::Match(ServerInstance->Config->ServerName, servername))
00103 {
00104 if (!ServerInstance->Modules->Unload(parameters[0].c_str()))
00105 {
00106 user->WriteNumeric(972, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
00107 }
00108 if (!ServerInstance->Modules->Load(parameters[0].c_str()))
00109 {
00110 user->WriteNumeric(974, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
00111 }
00112 ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBALLY RELOADED BY '%s'",parameters[0].c_str(), user->nick.c_str());
00113 user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick.c_str(), parameters[0].c_str());
00114 }
00115 else
00116 ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBAL RELOAD BY '%s' (not reloaded here)",parameters[0].c_str(), user->nick.c_str());
00117
00118 return CMD_SUCCESS;
00119 }
00120 };
00121
00122 class ModuleGlobalLoad : public Module
00123 {
00124 CommandGloadmodule *mycommand;
00125 CommandGunloadmodule *mycommand2;
00126 CommandGreloadmodule *mycommand3;
00127
00128 public:
00129 ModuleGlobalLoad(InspIRCd* Me) : Module(Me)
00130 {
00131
00132 mycommand = new CommandGloadmodule(ServerInstance);
00133 mycommand2 = new CommandGunloadmodule(ServerInstance);
00134 mycommand3 = new CommandGreloadmodule(ServerInstance);
00135 ServerInstance->AddCommand(mycommand);
00136 ServerInstance->AddCommand(mycommand2);
00137 ServerInstance->AddCommand(mycommand3);
00138
00139 }
00140
00141 virtual ~ModuleGlobalLoad()
00142 {
00143 }
00144
00145 virtual Version GetVersion()
00146 {
00147 return Version("$Id: m_globalload.cpp 10291 2008-08-25 20:35:51Z w00t $", VF_COMMON | VF_VENDOR, API_VERSION);
00148 }
00149 };
00150
00151 MODULE_INIT(ModuleGlobalLoad)
00152