mirror of
https://github.com/anope/anope.git
synced 2026-07-06 22:03:12 +02:00
The next of a few "CBX OCDing over code style" commits, maybe the last.
NOTES: I have been unable to compile the db_mysql_* functions on my system here, so those are untested. db-convert seems to be badly programmed and needs more work in my opinion.
This commit is contained in:
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -22,7 +21,7 @@ class AkillDelCallback : public NumberList
|
||||
AkillDelCallback(User *_u, const std::string &numlist) : NumberList(numlist, true), u(_u), Deleted(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
~AkillDelCallback()
|
||||
{
|
||||
if (!Deleted)
|
||||
@@ -83,7 +82,7 @@ class AkillListCallback : public NumberList
|
||||
|
||||
DoList(u, x, Number);
|
||||
}
|
||||
|
||||
|
||||
static void DoList(User *u, XLine *x, unsigned Number)
|
||||
{
|
||||
notice_lang(Config.s_OperServ, u, OPER_AKILL_LIST_FORMAT, Number + 1, x->Mask.c_str(), x->Reason.c_str());
|
||||
@@ -274,11 +273,11 @@ class CommandOSAKill : public Command
|
||||
{
|
||||
bool SentHeader = false;
|
||||
|
||||
for (unsigned i = 0; i < SGLine->GetCount(); ++i)
|
||||
for (unsigned i = 0, end = SGLine->GetCount(); i < end; ++i)
|
||||
{
|
||||
XLine *x = SGLine->GetEntry(i);
|
||||
|
||||
if (mask.empty() || (mask == x->Mask || Anope::Match(x->Mask, mask)))
|
||||
if (mask.empty() || mask == x->Mask || Anope::Match(x->Mask, mask))
|
||||
{
|
||||
if (!SentHeader)
|
||||
{
|
||||
@@ -315,11 +314,11 @@ class CommandOSAKill : public Command
|
||||
{
|
||||
bool SentHeader = false;
|
||||
|
||||
for (unsigned i = 0; i < SGLine->GetCount(); ++i)
|
||||
for (unsigned i = 0, end = SGLine->GetCount(); i < end; ++i)
|
||||
{
|
||||
XLine *x = SGLine->GetEntry(i);
|
||||
|
||||
if (mask.empty() || (mask == x->Mask || Anope::Match(x->Mask, mask)))
|
||||
if (mask.empty() || mask == x->Mask || Anope::Match(x->Mask, mask))
|
||||
{
|
||||
if (!SentHeader)
|
||||
{
|
||||
@@ -394,6 +393,7 @@ class OSAKill : public Module
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
this->SetType(CORE);
|
||||
|
||||
this->AddCommand(OperServ, new CommandOSAKill());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -67,7 +66,7 @@ class CommandOSChanKill : public Command
|
||||
|
||||
if ((c = findchan(channel)))
|
||||
{
|
||||
for (CUserList::iterator it = c->users.begin(); it != c->users.end();)
|
||||
for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
|
||||
{
|
||||
UserContainer *uc = *it++;
|
||||
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -38,18 +37,14 @@ class CommandOSChanList : public Command
|
||||
{
|
||||
notice_lang(Config.s_OperServ, u, OPER_CHANLIST_HEADER_USER, u2->nick.c_str());
|
||||
|
||||
for (UChannelList::iterator uit = u2->chans.begin(); uit != u2->chans.end(); ++uit)
|
||||
for (UChannelList::iterator uit = u2->chans.begin(), uit_end = u2->chans.end(); uit != uit_end; ++uit)
|
||||
{
|
||||
ChannelContainer *cc = *uit;
|
||||
|
||||
if (!Modes.empty())
|
||||
{
|
||||
for (std::list<ChannelModeName>::iterator it = Modes.begin(); it != Modes.end(); ++it)
|
||||
{
|
||||
for (std::list<ChannelModeName>::iterator it = Modes.begin(), it_end = Modes.end(); it != it_end; ++it)
|
||||
if (!cc->chan->HasMode(*it))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
notice_lang(Config.s_OperServ, u, OPER_CHANLIST_RECORD, cc->chan->name.c_str(), cc->chan->users.size(), chan_get_modes(cc->chan, 1, 1), cc->chan->topic ? cc->chan->topic : "");
|
||||
}
|
||||
@@ -58,20 +53,16 @@ class CommandOSChanList : public Command
|
||||
{
|
||||
notice_lang(Config.s_OperServ, u, OPER_CHANLIST_HEADER);
|
||||
|
||||
for (channel_map::const_iterator cit = ChannelList.begin(); cit != ChannelList.end(); ++cit)
|
||||
for (channel_map::const_iterator cit = ChannelList.begin(), cit_end = ChannelList.end(); cit != cit_end; ++cit)
|
||||
{
|
||||
Channel *c = cit->second;
|
||||
|
||||
|
||||
if (pattern && !Anope::Match(c->name, pattern, false))
|
||||
continue;
|
||||
if (!Modes.empty())
|
||||
{
|
||||
for (std::list<ChannelModeName>::iterator it = Modes.begin(); it != Modes.end(); ++it)
|
||||
{
|
||||
for (std::list<ChannelModeName>::iterator it = Modes.begin(), it_end = Modes.end(); it != it_end; ++it)
|
||||
if (!c->HasMode(*it))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
notice_lang(Config.s_OperServ, u, OPER_CHANLIST_RECORD, c->name.c_str(), c->users.size(), chan_get_modes(c, 1, 1), c->topic ? c->topic : "");
|
||||
}
|
||||
|
||||
+11
-10
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -42,10 +41,12 @@ class CommandOSClearModes : public Command
|
||||
else
|
||||
{
|
||||
ci::string s = params.size() > 1 ? params[1] : "";
|
||||
if (!s.empty()) {
|
||||
if (!s.empty())
|
||||
{
|
||||
if (s == "ALL")
|
||||
all = 1;
|
||||
else {
|
||||
else
|
||||
{
|
||||
this->OnSyntaxError(u, "");
|
||||
return MOD_CONT;
|
||||
}
|
||||
@@ -60,7 +61,7 @@ class CommandOSClearModes : public Command
|
||||
ircdproto->SendSVSModeChan(c, "-o", NULL);
|
||||
else
|
||||
{
|
||||
for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it)
|
||||
for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
|
||||
{
|
||||
UserContainer *uc = *it;
|
||||
|
||||
@@ -74,11 +75,11 @@ class CommandOSClearModes : public Command
|
||||
ircdproto->SendSVSModeChan(c, "-v", NULL);
|
||||
else
|
||||
{
|
||||
for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it)
|
||||
for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
|
||||
{
|
||||
UserContainer *uc = *it;
|
||||
|
||||
if (uc->Status->HasFlag(CMODE_VOICE))
|
||||
if (uc->Status->HasFlag(CMODE_VOICE))
|
||||
c->RemoveMode(NULL, CMODE_VOICE, uc->user->nick);
|
||||
}
|
||||
}
|
||||
@@ -90,7 +91,7 @@ class CommandOSClearModes : public Command
|
||||
ircdproto->SendSVSModeChan(c, "-h", NULL);
|
||||
else
|
||||
{
|
||||
for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it)
|
||||
for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
|
||||
{
|
||||
UserContainer *uc = *it;
|
||||
|
||||
@@ -110,7 +111,7 @@ class CommandOSClearModes : public Command
|
||||
ircdproto->SendSVSModeChan(c, buf.c_str(), NULL);
|
||||
else
|
||||
{
|
||||
for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it)
|
||||
for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
|
||||
{
|
||||
UserContainer *uc = *it;
|
||||
|
||||
@@ -130,7 +131,7 @@ class CommandOSClearModes : public Command
|
||||
ircdproto->SendSVSModeChan(c, buf.c_str(), NULL);
|
||||
else
|
||||
{
|
||||
for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it)
|
||||
for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
|
||||
{
|
||||
UserContainer *uc = *it;
|
||||
|
||||
|
||||
+22
-45
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -125,7 +124,7 @@ class CommandOSDEFCON : public Command
|
||||
{
|
||||
syntax_error(Config.s_OperServ, u, "DEFCON", OPER_DEFCON_SYNTAX);
|
||||
}
|
||||
|
||||
|
||||
void OnServHelp(User *u)
|
||||
{
|
||||
notice_lang(Config.s_OperServ, u, OPER_HELP_CMD_DEFCON);
|
||||
@@ -137,14 +136,12 @@ class OSDEFCON : public Module
|
||||
public:
|
||||
OSDEFCON(const std::string &modname, const std::string &creator) : Module(modname, creator)
|
||||
{
|
||||
if (!Config.DefConLevel)
|
||||
throw ModuleException("Invalid configuration settings");
|
||||
|
||||
this->SetAuthor("Anope");
|
||||
this->SetType(CORE);
|
||||
|
||||
if (!Config.DefConLevel)
|
||||
{
|
||||
throw ModuleException("Invalid configuration settings");
|
||||
}
|
||||
|
||||
Implementation i[] = { I_OnPreUserConnect, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnPreCommandRun, I_OnPreCommand, I_OnUserConnect, I_OnChannelModeAdd, I_OnChannelCreate };
|
||||
ModuleManager::Attach(i, this, 8);
|
||||
|
||||
@@ -197,9 +194,7 @@ class OSDEFCON : public Module
|
||||
std::string param;
|
||||
|
||||
if (GetDefConParam(Name, param))
|
||||
{
|
||||
c->SetMode(OperServ, Name, param);
|
||||
}
|
||||
else
|
||||
c->SetMode(OperServ, Name);
|
||||
|
||||
@@ -220,9 +215,7 @@ class OSDEFCON : public Module
|
||||
if ((CheckDefCon(DEFCON_OPER_ONLY) || CheckDefCon(DEFCON_SILENT_OPER_ONLY)) && !is_oper(u))
|
||||
{
|
||||
if (!CheckDefCon(DEFCON_SILENT_OPER_ONLY))
|
||||
{
|
||||
notice_lang(bi->nick.c_str(), u, OPER_DEFCON_DENIED);
|
||||
}
|
||||
|
||||
return EVENT_STOP;
|
||||
}
|
||||
@@ -236,13 +229,10 @@ class OSDEFCON : public Module
|
||||
{
|
||||
if (command == "SET")
|
||||
{
|
||||
if (!params.empty() && params[0] == "MLOCK")
|
||||
if (!params.empty() && params[0] == "MLOCK" && CheckDefCon(DEFCON_NO_MLOCK_CHANGE))
|
||||
{
|
||||
if (CheckDefCon(DEFCON_NO_MLOCK_CHANGE))
|
||||
{
|
||||
notice_lang(Config.s_ChanServ, u, OPER_DEFCON_DENIED);
|
||||
return EVENT_STOP;
|
||||
}
|
||||
notice_lang(Config.s_ChanServ, u, OPER_DEFCON_DENIED);
|
||||
return EVENT_STOP;
|
||||
}
|
||||
}
|
||||
else if (command == "REGISTER" || command == "GROUP")
|
||||
@@ -295,7 +285,7 @@ class OSDEFCON : public Module
|
||||
ircdproto->SendMessage(OperServ, u->nick.c_str(), "%s", Config.SessionLimitDetailsLoc);
|
||||
|
||||
kill_user(Config.s_OperServ, u->nick, "Session limit exceeded");
|
||||
session->hits++;
|
||||
++session->hits;
|
||||
if (Config.MaxSessionKill && session->hits >= Config.MaxSessionKill)
|
||||
{
|
||||
SGLine->Add(NULL, NULL, ci::string("*@") + u->host, time(NULL) + Config.SessionAutoKillExpiry, "Session limit exceeded");
|
||||
@@ -312,21 +302,17 @@ class OSDEFCON : public Module
|
||||
std::string modes = Config.DefConChanModes;
|
||||
|
||||
if (modes.find(cm->ModeChar) != std::string::npos)
|
||||
{
|
||||
/* New mode has been added to Anope, check to see if defcon
|
||||
* requires it
|
||||
*/
|
||||
defconParseModeString(Config.DefConChanModes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnChannelCreate(Channel *c)
|
||||
{
|
||||
if (CheckDefCon(DEFCON_FORCE_CHAN_MODES))
|
||||
{
|
||||
c->SetModes(OperServ, false, Config.DefConChanModes);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -398,7 +384,7 @@ void runDefCon()
|
||||
*/
|
||||
void defconParseModeString(const char *str)
|
||||
{
|
||||
int add = -1; /* 1 if adding, 0 if deleting, -1 if neither */
|
||||
int add = -1; /* 1 if adding, 0 if deleting, -1 if neither */
|
||||
unsigned char mode;
|
||||
ChannelMode *cm;
|
||||
ChannelModeParam *cmp;
|
||||
@@ -414,7 +400,7 @@ void defconParseModeString(const char *str)
|
||||
ss.GetToken(modes);
|
||||
|
||||
/* Loop while there are modes to set */
|
||||
for (unsigned i = 0; i < modes.size(); ++i)
|
||||
for (unsigned i = 0, end = modes.size(); i < end; ++i)
|
||||
{
|
||||
mode = modes[i];
|
||||
|
||||
@@ -466,34 +452,26 @@ void defconParseModeString(const char *str)
|
||||
DefConModesOn.UnsetFlag(cm->Name);
|
||||
|
||||
if (cm->Type == MODE_PARAM)
|
||||
{
|
||||
UnsetDefConParam(cm->Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((cm = ModeManager::FindChannelModeByName(CMODE_REDIRECT)))
|
||||
/* We can't mlock +L if +l is not mlocked as well. */
|
||||
if ((cm = ModeManager::FindChannelModeByName(CMODE_REDIRECT)) && DefConModesOn.HasFlag(cm->Name) && !DefConModesOn.HasFlag(CMODE_LIMIT))
|
||||
{
|
||||
/* We can't mlock +L if +l is not mlocked as well. */
|
||||
if (DefConModesOn.HasFlag(cm->Name) && !DefConModesOn.HasFlag(CMODE_LIMIT))
|
||||
{
|
||||
DefConModesOn.UnsetFlag(CMODE_REDIRECT);
|
||||
DefConModesOn.UnsetFlag(CMODE_REDIRECT);
|
||||
|
||||
Alog() << "DefConChanModes must lock mode +l as well to lock mode +L";
|
||||
}
|
||||
Alog() << "DefConChanModes must lock mode +l as well to lock mode +L";
|
||||
}
|
||||
|
||||
/* Some ircd we can't set NOKNOCK without INVITE */
|
||||
/* So check if we need there is a NOKNOCK MODE and that we need INVITEONLY */
|
||||
if (ircd->knock_needs_i && (cm = ModeManager::FindChannelModeByName(CMODE_NOKNOCK)))
|
||||
if (ircd->knock_needs_i && (cm = ModeManager::FindChannelModeByName(CMODE_NOKNOCK)) && DefConModesOn.HasFlag(cm->Name) && !DefConModesOn.HasFlag(CMODE_INVITE))
|
||||
{
|
||||
if (DefConModesOn.HasFlag(cm->Name) && !DefConModesOn.HasFlag(CMODE_INVITE))
|
||||
{
|
||||
DefConModesOn.UnsetFlag(CMODE_NOKNOCK);
|
||||
Alog() << "DefConChanModes must lock mode +i as well to lock mode +K";
|
||||
}
|
||||
DefConModesOn.UnsetFlag(CMODE_NOKNOCK);
|
||||
Alog() << "DefConChanModes must lock mode +i as well to lock mode +K";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,13 +479,12 @@ static char *defconReverseModes(const char *modes)
|
||||
{
|
||||
char *newmodes = NULL;
|
||||
unsigned i = 0;
|
||||
if (!modes) {
|
||||
if (!modes)
|
||||
return NULL;
|
||||
}
|
||||
if (!(newmodes = new char[strlen(modes) + 1])) {
|
||||
if (!(newmodes = new char[strlen(modes) + 1]))
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < strlen(modes); i++) {
|
||||
for (i = 0; i < strlen(modes); ++i)
|
||||
{
|
||||
if (modes[i] == '+')
|
||||
newmodes[i] = '-';
|
||||
else if (modes[i] == '-')
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -30,7 +29,7 @@ class CommandOSHelp : public Command
|
||||
void OnSyntaxError(User *u, const ci::string &subcommand)
|
||||
{
|
||||
notice_help(Config.s_OperServ, u, OPER_HELP);
|
||||
for (CommandMap::const_iterator it = NickServ->Commands.begin(); it != NickServ->Commands.end(); ++it)
|
||||
for (CommandMap::const_iterator it = OperServ->Commands.begin(), it_end = OperServ->Commands.end(); it != it_end; ++it)
|
||||
it->second->OnServHelp(u);
|
||||
notice_help(Config.s_OperServ, u, OPER_HELP_LOGGED);
|
||||
}
|
||||
@@ -43,6 +42,7 @@ class OSHelp : public Module
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
this->SetType(CORE);
|
||||
|
||||
this->AddCommand(OperServ, new CommandOSHelp());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -141,12 +140,13 @@ class OSIgnore : public Module
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
this->SetType(CORE);
|
||||
|
||||
this->AddCommand(OperServ, new CommandOSIgnore());
|
||||
|
||||
Implementation i[] = { I_OnDatabaseRead, I_OnDatabaseWrite };
|
||||
ModuleManager::Attach(i, this, 2);
|
||||
}
|
||||
|
||||
|
||||
EventReturn OnDatabaseRead(const std::vector<std::string> ¶ms)
|
||||
{
|
||||
std::string buf;
|
||||
@@ -177,7 +177,7 @@ class OSIgnore : public Module
|
||||
{
|
||||
next = ign->next;
|
||||
|
||||
if (ign->time != 0 && ign->time <= now)
|
||||
if (ign->time && ign->time <= now)
|
||||
{
|
||||
Alog(LOG_DEBUG) << "[os_ignore] Expiring ignore entry " << ign->mask;
|
||||
if (ign->prev)
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -35,7 +34,7 @@ class CommandOSModInfo : public Command
|
||||
tm = *localtime(&m->created);
|
||||
strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_DATE_TIME_FORMAT, &tm);
|
||||
notice_lang(Config.s_OperServ, u, OPER_MODULE_INFO_LIST, m->name.c_str(), !m->version.empty() ? m->version.c_str() : "?", !m->author.empty() ? m->author.c_str() : "?", timebuf);
|
||||
|
||||
|
||||
showModuleCmdLoaded(HostServ, m->name.c_str(), u);
|
||||
showModuleCmdLoaded(OperServ, m->name.c_str(), u);
|
||||
showModuleCmdLoaded(NickServ, m->name.c_str(), u);
|
||||
@@ -73,6 +72,7 @@ class OSModInfo : public Module
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
this->SetType(CORE);
|
||||
|
||||
this->AddCommand(OperServ, new CommandOSModInfo());
|
||||
}
|
||||
};
|
||||
@@ -81,10 +81,10 @@ static int showModuleCmdLoaded(BotInfo *bi, const ci::string &mod_name, User *u)
|
||||
{
|
||||
if (!bi)
|
||||
return 0;
|
||||
|
||||
|
||||
int display = 0;
|
||||
|
||||
for (std::map<ci::string, Command *>::iterator it = bi->Commands.begin(); it != bi->Commands.end(); ++it)
|
||||
for (std::map<ci::string, Command *>::iterator it = bi->Commands.begin(), it_end = bi->Commands.end(); it != it_end; ++it)
|
||||
{
|
||||
Command *c = it->second;
|
||||
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
|
||||
+24
-33
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -18,19 +17,21 @@
|
||||
|
||||
/* List of messages for each news type. This simplifies message sending. */
|
||||
|
||||
#define MSG_SYNTAX 0
|
||||
#define MSG_LIST_HEADER 1
|
||||
#define MSG_LIST_ENTRY 2
|
||||
#define MSG_LIST_NONE 3
|
||||
#define MSG_ADD_SYNTAX 4
|
||||
#define MSG_ADD_FULL 5
|
||||
#define MSG_ADDED 6
|
||||
#define MSG_DEL_SYNTAX 7
|
||||
#define MSG_DEL_NOT_FOUND 8
|
||||
#define MSG_DELETED 9
|
||||
#define MSG_DEL_NONE 10
|
||||
#define MSG_DELETED_ALL 11
|
||||
#define MSG_MAX 11
|
||||
enum
|
||||
{
|
||||
MSG_SYNTAX,
|
||||
MSG_LIST_HEADER,
|
||||
MSG_LIST_ENTRY,
|
||||
MSG_LIST_NONE,
|
||||
MSG_ADD_SYNTAX,
|
||||
MSG_ADD_FULL,
|
||||
MSG_ADDED,
|
||||
MSG_DEL_SYNTAX,
|
||||
MSG_DEL_NOT_FOUND,
|
||||
MSG_DELETED,
|
||||
MSG_DEL_NONE,
|
||||
MSG_DELETED_ALL
|
||||
};
|
||||
|
||||
struct newsmsgs msgarray[] = {
|
||||
{NEWS_LOGON, "LOGON",
|
||||
@@ -96,7 +97,7 @@ static void DisplayNews(User *u, NewsType Type)
|
||||
|
||||
unsigned displayed = 0;
|
||||
bool NewsExists = false;
|
||||
for (unsigned i = 0; i < News.size(); ++i)
|
||||
for (unsigned i = 0, end = News.size(); i < end; ++i)
|
||||
{
|
||||
if (News[i]->type == Type)
|
||||
{
|
||||
@@ -129,18 +130,16 @@ static void DisplayNews(User *u, NewsType Type)
|
||||
}
|
||||
}
|
||||
|
||||
static int add_newsitem(User * u, const char *text, NewsType type)
|
||||
static int add_newsitem(User *u, const char *text, NewsType type)
|
||||
{
|
||||
int num = 0;
|
||||
|
||||
for (unsigned i = News.size(); i > 0; --i)
|
||||
{
|
||||
if (News[i - 1]->type == type)
|
||||
{
|
||||
num = News[i - 1]->num;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NewsItem *news = new NewsItem;
|
||||
news->type = type;
|
||||
@@ -159,27 +158,25 @@ static int del_newsitem(unsigned num, NewsType type)
|
||||
int count = 0;
|
||||
|
||||
for (unsigned i = News.size(); i > 0; --i)
|
||||
{
|
||||
if (News[i - 1]->type == type && (num == 0 || News[i - 1]->num == num))
|
||||
{
|
||||
delete News[i - 1];
|
||||
News.erase(News.begin() + i - 1);
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static int *findmsgs(NewsType type, const char **type_name)
|
||||
{
|
||||
for (unsigned i = 0; i < lenof(msgarray); i++) {
|
||||
if (msgarray[i].type == type) {
|
||||
for (unsigned i = 0; i < lenof(msgarray); ++i)
|
||||
if (msgarray[i].type == type)
|
||||
{
|
||||
if (type_name)
|
||||
*type_name = msgarray[i].name;
|
||||
return msgarray[i].msgs;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -192,8 +189,7 @@ class NewsBase : public Command
|
||||
char timebuf[64];
|
||||
struct tm *tm;
|
||||
|
||||
for (unsigned i = 0; i < News.size(); ++i)
|
||||
{
|
||||
for (unsigned i = 0, end = News.size(); i < end; ++i)
|
||||
if (News[i]->type == type)
|
||||
{
|
||||
if (!count)
|
||||
@@ -203,7 +199,6 @@ class NewsBase : public Command
|
||||
notice_lang(Config.s_OperServ, u, msgs[MSG_LIST_ENTRY], News[i]->num, timebuf, !News[i]->who.empty() ? News[i]->who.c_str() : "<unknown>", News[i]->Text.c_str());
|
||||
++count;
|
||||
}
|
||||
}
|
||||
if (!count)
|
||||
notice_lang(Config.s_OperServ, u, msgs[MSG_LIST_NONE]);
|
||||
else
|
||||
@@ -256,11 +251,9 @@ class NewsBase : public Command
|
||||
if (num > 0 && del_newsitem(num, type))
|
||||
{
|
||||
notice_lang(Config.s_OperServ, u, msgs[MSG_DELETED], num);
|
||||
for (unsigned i = 0; i < News.size(); ++i)
|
||||
{
|
||||
for (unsigned i = 0, end = News.size(); i < end; ++i)
|
||||
if (News[i]->type == type && News[i]->num > num)
|
||||
--News[i]->num;
|
||||
}
|
||||
}
|
||||
else
|
||||
notice_lang(Config.s_OperServ, u, msgs[MSG_DEL_NOT_FOUND], num);
|
||||
@@ -422,7 +415,7 @@ class OSNews : public Module
|
||||
|
||||
~OSNews()
|
||||
{
|
||||
for (std::vector<NewsItem *>::iterator it = News.begin(); it != News.end(); ++it)
|
||||
for (std::vector<NewsItem *>::iterator it = News.begin(), it_end = News.end(); it != it_end; ++it)
|
||||
delete *it;
|
||||
News.clear();
|
||||
}
|
||||
@@ -430,9 +423,7 @@ class OSNews : public Module
|
||||
void OnUserModeSet(User *u, UserModeName Name)
|
||||
{
|
||||
if (Name == UMODE_OPER)
|
||||
{
|
||||
DisplayNews(u, NEWS_OPER);
|
||||
}
|
||||
}
|
||||
|
||||
void OnUserConnect(User *u)
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -39,7 +38,7 @@ class CommandOSNOOP : public Command
|
||||
notice_lang(Config.s_OperServ, u, OPER_NOOP_SET, server);
|
||||
|
||||
/* Kill all the IRCops of the server */
|
||||
for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end();)
|
||||
for (user_map::const_iterator it = UserListByNick.begin(), it_end = UserListByNick.end(); it != it_end; )
|
||||
{
|
||||
User *u2 = it->second;
|
||||
++it;
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -71,13 +70,13 @@ class OSOLine : public Module
|
||||
public:
|
||||
OSOLine(const std::string &modname, const std::string &creator) : Module(modname, creator)
|
||||
{
|
||||
if (!ircd->omode)
|
||||
throw ModuleException("Your IRCd does not support OMODE.");
|
||||
|
||||
this->SetAuthor("Anope");
|
||||
this->SetType(CORE);
|
||||
|
||||
this->AddCommand(OperServ, new CommandOSOLine());
|
||||
|
||||
if (!ircd->omode)
|
||||
throw ModuleException("Your IRCd does not support OMODE.");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ class CommandOSQuit : public Command
|
||||
|
||||
CommandReturn Execute(User *u, const std::vector<ci::string> ¶ms)
|
||||
{
|
||||
|
||||
quitmsg = new char[28 + u->nick.length()];
|
||||
if (!quitmsg)
|
||||
quitmsg = "QUIT command received, but out of memory!";
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -55,6 +54,7 @@ class OSRestart : public Module
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
this->SetType(CORE);
|
||||
|
||||
this->AddCommand(OperServ, new CommandOSRestart());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -144,7 +143,7 @@ class CommandOSSession : public Command
|
||||
notice_lang(Config.s_OperServ, u, OPER_SESSION_LIST_HEADER, mincount);
|
||||
notice_lang(Config.s_OperServ, u, OPER_SESSION_LIST_COLHEAD);
|
||||
|
||||
for (session_map::const_iterator it = SessionList.begin(); it != SessionList.end(); ++it)
|
||||
for (session_map::const_iterator it = SessionList.begin(), it_end = SessionList.end(); it != it_end; ++it)
|
||||
{
|
||||
Session *session = it->second;
|
||||
|
||||
@@ -300,7 +299,6 @@ class CommandOSException : public Command
|
||||
int deleted = 0;
|
||||
|
||||
for (i = 0; i < nexceptions; ++i)
|
||||
{
|
||||
if (!stricmp(mask, exceptions[i].mask))
|
||||
{
|
||||
ExceptionDelCallback::DoDel(u, i);
|
||||
@@ -308,7 +306,6 @@ class CommandOSException : public Command
|
||||
deleted = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!deleted && i == nexceptions)
|
||||
notice_lang(Config.s_OperServ, u, OPER_EXCEPTION_NOT_FOUND, mask);
|
||||
}
|
||||
@@ -391,7 +388,6 @@ class CommandOSException : public Command
|
||||
bool SentHeader = false;
|
||||
|
||||
for (i = 0; i < nexceptions; ++i)
|
||||
{
|
||||
if (!mask || Anope::Match(exceptions[i].mask, mask, false))
|
||||
{
|
||||
if (!SentHeader)
|
||||
@@ -403,7 +399,6 @@ class CommandOSException : public Command
|
||||
|
||||
ExceptionListCallback::DoList(u, i);
|
||||
}
|
||||
}
|
||||
|
||||
if (!SentHeader)
|
||||
notice_lang(Config.s_OperServ, u, OPER_EXCEPTION_NO_MATCH);
|
||||
@@ -425,7 +420,6 @@ class CommandOSException : public Command
|
||||
bool SentHeader = false;
|
||||
|
||||
for (i = 0; i < nexceptions; ++i)
|
||||
{
|
||||
if (!mask || Anope::Match(exceptions[i].mask, mask, false))
|
||||
{
|
||||
if (!SentHeader)
|
||||
@@ -436,7 +430,6 @@ class CommandOSException : public Command
|
||||
|
||||
ExceptionViewCallback::DoList(u, i);
|
||||
}
|
||||
}
|
||||
|
||||
if (!SentHeader)
|
||||
notice_lang(Config.s_OperServ, u, OPER_EXCEPTION_NO_MATCH);
|
||||
|
||||
+1
-2
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -23,7 +22,6 @@ class CommandOSShutdown : public Command
|
||||
|
||||
CommandReturn Execute(User *u, const std::vector<ci::string> ¶ms)
|
||||
{
|
||||
|
||||
quitmsg = new char[32 + u->nick.length()];
|
||||
if (!quitmsg)
|
||||
quitmsg = "SHUTDOWN command received, but out of memory!";
|
||||
|
||||
+9
-12
@@ -7,10 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -178,7 +176,8 @@ class CommandOSSNLine : public Command
|
||||
sep.GetToken(mask);
|
||||
std::string reason = sep.GetRemaining();
|
||||
|
||||
if (!mask.empty() && !reason.empty()) {
|
||||
if (!mask.empty() && !reason.empty())
|
||||
{
|
||||
/* Clean up the last character of the mask if it is a space
|
||||
* See bug #761
|
||||
*/
|
||||
@@ -292,11 +291,11 @@ class CommandOSSNLine : public Command
|
||||
{
|
||||
bool SentHeader = false;
|
||||
|
||||
for (unsigned i = 0; i < SNLine->GetCount(); ++i)
|
||||
for (unsigned i = 0, end = SNLine->GetCount(); i < end; ++i)
|
||||
{
|
||||
XLine *x = SNLine->GetEntry(i);
|
||||
|
||||
if (mask.empty() || (mask == x->Mask || Anope::Match(x->Mask, mask)))
|
||||
if (mask.empty() || mask == x->Mask || Anope::Match(x->Mask, mask))
|
||||
{
|
||||
if (!SentHeader)
|
||||
{
|
||||
@@ -333,11 +332,11 @@ class CommandOSSNLine : public Command
|
||||
{
|
||||
bool SentHeader = false;
|
||||
|
||||
for (unsigned i = 0; i < SNLine->GetCount(); ++i)
|
||||
for (unsigned i = 0, end = SNLine->GetCount(); i < end; ++i)
|
||||
{
|
||||
XLine *x = SNLine->GetEntry(i);
|
||||
|
||||
if (mask.empty() || (mask == x->Mask || Anope::Match(x->Mask, mask)))
|
||||
if (mask.empty() || mask == x->Mask || Anope::Match(x->Mask, mask))
|
||||
{
|
||||
if (!SentHeader)
|
||||
{
|
||||
@@ -410,15 +409,13 @@ class OSSNLine : public Module
|
||||
public:
|
||||
OSSNLine(const std::string &modname, const std::string &creator) : Module(modname, creator)
|
||||
{
|
||||
if (!ircd->snline)
|
||||
throw ModuleException("Your IRCd does not support SNLine");
|
||||
|
||||
this->SetAuthor("Anope");
|
||||
this->SetVersion("$Id$");
|
||||
this->SetType(CORE);
|
||||
|
||||
this->AddCommand(OperServ, new CommandOSSNLine());
|
||||
|
||||
if (!ircd->snline)
|
||||
throw ModuleException("Your IRCd does not support SNLine");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+11
-13
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -27,7 +26,7 @@ class SQLineDelCallback : public NumberList
|
||||
{
|
||||
if (!Deleted)
|
||||
notice_lang(Config.s_OperServ, u, OPER_SQLINE_NO_MATCH);
|
||||
else if (Deleted == 0)
|
||||
else if (Deleted == 1)
|
||||
notice_lang(Config.s_OperServ, u, OPER_SQLINE_DELETED_ONE);
|
||||
else
|
||||
notice_lang(Config.s_OperServ, u, OPER_SQLINE_DELETED_SEVERAL, Deleted);
|
||||
@@ -119,8 +118,7 @@ class SQLineViewCallback : public SQLineListCallback
|
||||
tm = *localtime(&x->Created);
|
||||
strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT, &tm);
|
||||
expire_left(u->Account(), expirebuf, sizeof(expirebuf), x->Expires);
|
||||
notice_lang(Config.s_OperServ, u, OPER_SQLINE_VIEW_FORMAT, Number + 1, x->Mask.c_str(), x->By.c_str(), timebuf,
|
||||
expirebuf, x->Reason.c_str());
|
||||
notice_lang(Config.s_OperServ, u, OPER_SQLINE_VIEW_FORMAT, Number + 1, x->Mask.c_str(), x->By.c_str(), timebuf, expirebuf, x->Reason.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -169,7 +167,7 @@ class CommandOSSQLine : public Command
|
||||
if (mask && *reason)
|
||||
{
|
||||
XLine *x = SQLine->Add(OperServ, u, mask, expires, reason);
|
||||
|
||||
|
||||
if (!x)
|
||||
return MOD_CONT;
|
||||
|
||||
@@ -274,11 +272,11 @@ class CommandOSSQLine : public Command
|
||||
{
|
||||
bool SentHeader = false;
|
||||
|
||||
for (unsigned i = 0; i < SQLine->GetCount(); ++i)
|
||||
for (unsigned i = 0, end = SQLine->GetCount(); i < end; ++i)
|
||||
{
|
||||
XLine *x = SQLine->GetEntry(i);
|
||||
|
||||
if (mask.empty() || (mask == x->Mask || Anope::Match(x->Mask, mask)))
|
||||
if (mask.empty() || mask == x->Mask || Anope::Match(x->Mask, mask))
|
||||
{
|
||||
if (!SentHeader)
|
||||
{
|
||||
@@ -315,11 +313,11 @@ class CommandOSSQLine : public Command
|
||||
{
|
||||
bool SentHeader = false;
|
||||
|
||||
for (unsigned i = 0; i < SQLine->GetCount(); ++i)
|
||||
for (unsigned i = 0, end = SQLine->GetCount(); i < end; ++i)
|
||||
{
|
||||
XLine *x = SQLine->GetEntry(i);
|
||||
|
||||
if (mask.empty() || (mask == x->Mask || Anope::Match(x->Mask, mask)))
|
||||
if (mask.empty() || mask == x->Mask || Anope::Match(x->Mask, mask))
|
||||
{
|
||||
if (!SentHeader)
|
||||
{
|
||||
@@ -392,13 +390,13 @@ class OSSQLine : public Module
|
||||
public:
|
||||
OSSQLine(const std::string &modname, const std::string &creator) : Module(modname, creator)
|
||||
{
|
||||
if (!ircd->sqline)
|
||||
throw ModuleException("Your IRCd does not support QLines.");
|
||||
|
||||
this->SetAuthor("Anope");
|
||||
this->SetType(CORE);
|
||||
|
||||
this->AddCommand(OperServ, new CommandOSSQLine());
|
||||
|
||||
if (!ircd->sqline)
|
||||
throw ModuleException("Your IRCd does not support QLines.");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -25,7 +24,7 @@ class CommandOSStaff : public Command
|
||||
{
|
||||
notice_lang(Config.s_OperServ, u, OPER_STAFF_LIST_HEADER);
|
||||
|
||||
for (std::list<std::pair<ci::string, ci::string> >::iterator it = Config.Opers.begin(); it != Config.Opers.end(); ++it)
|
||||
for (std::list<std::pair<ci::string, ci::string> >::iterator it = Config.Opers.begin(), it_end = Config.Opers.end(); it != it_end; ++it)
|
||||
{
|
||||
int found = 0;
|
||||
ci::string nick = it->first, type = it->second;
|
||||
@@ -34,7 +33,7 @@ class CommandOSStaff : public Command
|
||||
if (na)
|
||||
{
|
||||
/* We have to loop all users as some may be logged into an account but not a nick */
|
||||
for (user_map::iterator uit = UserListByNick.begin(); uit != UserListByNick.end(); ++uit)
|
||||
for (user_map::iterator uit = UserListByNick.begin(), uit_end = UserListByNick.end(); uit != uit_end; ++uit)
|
||||
{
|
||||
User *u2 = uit->second;
|
||||
|
||||
@@ -48,9 +47,7 @@ class CommandOSStaff : public Command
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
notice_lang(Config.s_OperServ, u, OPER_STAFF_FORMAT, ' ', type.c_str(), na->nick);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-27
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -25,16 +24,12 @@ static int stats_count_servers(Server *s)
|
||||
{
|
||||
if (!s)
|
||||
return 0;
|
||||
|
||||
|
||||
int count = 1;
|
||||
|
||||
if (s->GetLinks())
|
||||
{
|
||||
for (std::list<Server *>::const_iterator it = s->GetLinks()->begin(); it != s->GetLinks()->end(); ++it)
|
||||
{
|
||||
for (std::list<Server *>::const_iterator it = s->GetLinks()->begin(), it_end = s->GetLinks()->end(); it != it_end; ++it)
|
||||
count += stats_count_servers(*it);
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
@@ -147,7 +142,8 @@ class CommandOSStats : public Command
|
||||
notice_lang(Config.s_OperServ, u, OPER_STATS_UPTIME_1DHMS, days, hours, mins, secs);
|
||||
else
|
||||
{
|
||||
if (hours > 1) {
|
||||
if (hours > 1)
|
||||
{
|
||||
if (mins != 1)
|
||||
{
|
||||
if (secs != 1)
|
||||
@@ -207,12 +203,8 @@ class CommandOSStats : public Command
|
||||
std::string buf;
|
||||
|
||||
for (unsigned j = 0; !Capab_Info[j].Token.empty(); ++j)
|
||||
{
|
||||
if (Capab.HasFlag(Capab_Info[j].Flag))
|
||||
{
|
||||
buf += " " + Capab_Info[j].Token;
|
||||
}
|
||||
}
|
||||
|
||||
if (!buf.empty())
|
||||
buf.erase(buf.begin());
|
||||
@@ -314,14 +306,15 @@ class OSStats : public Module
|
||||
|
||||
void get_operserv_stats(long *nrec, long *memuse)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned i, end;
|
||||
long mem = 0, count = 0, mem2 = 0, count2 = 0;
|
||||
XLine *x;
|
||||
|
||||
count += SGLine->GetCount();
|
||||
mem += SGLine->GetCount() * sizeof(XLine);
|
||||
end = SGLine->GetCount();
|
||||
count += end;
|
||||
mem += end * sizeof(XLine);
|
||||
|
||||
for (i = 0; i < SGLine->GetCount(); ++i)
|
||||
for (i = 0; i < end; ++i)
|
||||
{
|
||||
x = SGLine->GetEntry(i);
|
||||
|
||||
@@ -335,10 +328,11 @@ void get_operserv_stats(long *nrec, long *memuse)
|
||||
|
||||
if (ircd->snline)
|
||||
{
|
||||
count += SNLine->GetCount();
|
||||
mem += SNLine->GetCount() * sizeof(XLine);
|
||||
end = SNLine->GetCount();
|
||||
count += end;
|
||||
mem += end * sizeof(XLine);
|
||||
|
||||
for (i = 0; i < SNLine->GetCount(); ++i)
|
||||
for (i = 0; i < end; ++i)
|
||||
{
|
||||
x = SNLine->GetEntry(i);
|
||||
|
||||
@@ -352,10 +346,11 @@ void get_operserv_stats(long *nrec, long *memuse)
|
||||
}
|
||||
if (ircd->sqline)
|
||||
{
|
||||
count += SQLine->GetCount();
|
||||
mem += SGLine->GetCount() * sizeof(XLine);
|
||||
end = SQLine->GetCount();
|
||||
count += end;
|
||||
mem += end * sizeof(XLine);
|
||||
|
||||
for (i = 0; i < SQLine->GetCount(); ++i)
|
||||
for (i = 0; i < end; ++i)
|
||||
{
|
||||
x = SNLine->GetEntry(i);
|
||||
|
||||
@@ -369,10 +364,11 @@ void get_operserv_stats(long *nrec, long *memuse)
|
||||
}
|
||||
if (ircd->szline)
|
||||
{
|
||||
count += SZLine->GetCount();
|
||||
mem += SZLine->GetCount() * sizeof(XLine);
|
||||
|
||||
for (i = 0; i < SZLine->GetCount(); ++i)
|
||||
end = SZLine->GetCount();
|
||||
count += end;
|
||||
mem += end * sizeof(XLine);
|
||||
|
||||
for (i = 0; i < end; ++i)
|
||||
{
|
||||
x = SZLine->GetEntry(i);
|
||||
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -42,14 +41,12 @@ class CommandOSSVSNick : public Command
|
||||
notice_lang(Config.s_OperServ, u, NICK_X_ILLEGAL, newnick.c_str());
|
||||
return MOD_CONT;
|
||||
}
|
||||
for (unsigned i = 0; i < newnick.size(); ++i)
|
||||
{
|
||||
for (unsigned i = 0, end = newnick.size(); i < end; ++i)
|
||||
if (!isvalidnick(newnick[i]))
|
||||
{
|
||||
notice_lang(Config.s_OperServ, u, NICK_X_ILLEGAL, newnick.c_str());
|
||||
return MOD_CONT;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for a nick in use or a forbidden/suspended nick */
|
||||
if (!(u2 = finduser(nick)))
|
||||
@@ -89,13 +86,13 @@ class OSSVSNick : public Module
|
||||
public:
|
||||
OSSVSNick(const std::string &modname, const std::string &creator) : Module(modname, creator)
|
||||
{
|
||||
if (!ircd->svsnick)
|
||||
throw ModuleException("Your IRCd does not support SVSNICK");
|
||||
|
||||
this->SetAuthor("Anope");
|
||||
this->SetType(CORE);
|
||||
|
||||
this->AddCommand(OperServ, new CommandOSSVSNick());
|
||||
|
||||
if (!ircd->svsnick)
|
||||
throw ModuleException("Your IRCd does not support SVSNICK");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+9
-12
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -119,12 +118,10 @@ class SZLineViewCallback : public SZLineListCallback
|
||||
tm = *localtime(&x->Created);
|
||||
strftime_lang(timebuf, sizeof(timebuf), u, STRFTIME_SHORT_DATE_FORMAT, &tm);
|
||||
expire_left(u->Account(), expirebuf, sizeof(expirebuf), x->Expires);
|
||||
notice_lang(Config.s_OperServ, u, OPER_SZLINE_VIEW_FORMAT, Number + 1, x->Mask.c_str(), x->By.c_str(), timebuf,
|
||||
expirebuf, x->Reason.c_str());
|
||||
notice_lang(Config.s_OperServ, u, OPER_SZLINE_VIEW_FORMAT, Number + 1, x->Mask.c_str(), x->By.c_str(), timebuf, expirebuf, x->Reason.c_str());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class CommandOSSZLine : public Command
|
||||
{
|
||||
private:
|
||||
@@ -274,11 +271,11 @@ class CommandOSSZLine : public Command
|
||||
{
|
||||
bool SentHeader = false;
|
||||
|
||||
for (unsigned i = 0; i < SZLine->GetCount(); ++i)
|
||||
for (unsigned i = 0, end = SZLine->GetCount(); i < end; ++i)
|
||||
{
|
||||
XLine *x = SZLine->GetEntry(i);
|
||||
|
||||
if (mask.empty() || (mask == x->Mask || Anope::Match(x->Mask, mask)))
|
||||
if (mask.empty() || mask == x->Mask || Anope::Match(x->Mask, mask))
|
||||
{
|
||||
if (!SentHeader)
|
||||
{
|
||||
@@ -313,11 +310,11 @@ class CommandOSSZLine : public Command
|
||||
{
|
||||
bool SentHeader = false;
|
||||
|
||||
for (unsigned i = 0; i < SZLine->GetCount(); ++i)
|
||||
for (unsigned i = 0, end = SZLine->GetCount(); i < end; ++i)
|
||||
{
|
||||
XLine *x = SZLine->GetEntry(i);
|
||||
|
||||
if (mask.empty() || (mask == x->Mask || Anope::Match(x->Mask, mask)))
|
||||
if (mask.empty() || mask == x->Mask || Anope::Match(x->Mask, mask))
|
||||
{
|
||||
if (!SentHeader)
|
||||
{
|
||||
@@ -390,13 +387,13 @@ class OSSZLine : public Module
|
||||
public:
|
||||
OSSZLine(const std::string &modname, const std::string &creator) : Module(modname, creator)
|
||||
{
|
||||
if (!ircd->szline)
|
||||
throw ModuleException("Your IRCd does not support ZLINEs");
|
||||
|
||||
this->SetAuthor("Anope");
|
||||
this->SetType(CORE);
|
||||
|
||||
this->AddCommand(OperServ, new CommandOSSZLine());
|
||||
|
||||
if (!ircd->szline)
|
||||
throw ModuleException("Your IRCd does not support ZLINEs");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -74,13 +73,13 @@ class OSUMode : public Module
|
||||
public:
|
||||
OSUMode(const std::string &modname, const std::string &creator) : Module(modname, creator)
|
||||
{
|
||||
if (!ircd->umode)
|
||||
throw ModuleException("Your IRCd does not support setting umodes");
|
||||
|
||||
this->SetAuthor("Anope");
|
||||
this->SetType(CORE);
|
||||
|
||||
this->AddCommand(OperServ, new CommandOSUMode());
|
||||
|
||||
if (!ircd->umode)
|
||||
throw ModuleException("Your IRCd does not support setting umodes");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -29,26 +28,20 @@ class CommandOSUserList : public Command
|
||||
std::list<UserModeName> Modes;
|
||||
|
||||
if (!opt.empty() && opt == "INVISIBLE")
|
||||
{
|
||||
Modes.push_back(UMODE_INVIS);
|
||||
}
|
||||
|
||||
if (pattern && (c = findchan(pattern)))
|
||||
{
|
||||
notice_lang(Config.s_OperServ, u, OPER_USERLIST_HEADER_CHAN, pattern);
|
||||
|
||||
for (CUserList::iterator cuit = c->users.begin(); cuit != c->users.end(); ++cuit)
|
||||
for (CUserList::iterator cuit = c->users.begin(), cuit_end = c->users.end(); cuit != cuit_end; ++cuit)
|
||||
{
|
||||
UserContainer *uc = *cuit;
|
||||
|
||||
if (!Modes.empty())
|
||||
{
|
||||
for (std::list<UserModeName>::iterator it = Modes.begin(); it != Modes.end(); ++it)
|
||||
{
|
||||
for (std::list<UserModeName>::iterator it = Modes.begin(), it_end = Modes.end(); it != it_end; ++it)
|
||||
if (!uc->user->HasMode(*it))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
notice_lang(Config.s_OperServ, u, OPER_USERLIST_RECORD, uc->user->nick.c_str(), uc->user->GetIdent().c_str(), uc->user->GetDisplayedHost().c_str());
|
||||
}
|
||||
@@ -57,7 +50,7 @@ class CommandOSUserList : public Command
|
||||
{
|
||||
notice_lang(Config.s_OperServ, u, OPER_USERLIST_HEADER);
|
||||
|
||||
for (user_map::const_iterator uit = UserListByNick.begin(); uit != UserListByNick.end(); ++uit)
|
||||
for (user_map::const_iterator uit = UserListByNick.begin(), uit_end = UserListByNick.end(); uit != uit_end; ++uit)
|
||||
{
|
||||
User *u2 = uit->second;
|
||||
|
||||
@@ -68,13 +61,9 @@ class CommandOSUserList : public Command
|
||||
if (!Anope::Match(mask, pattern, false))
|
||||
continue;
|
||||
if (!Modes.empty())
|
||||
{
|
||||
for (std::list<UserModeName>::iterator it = Modes.begin(); it != Modes.end(); ++it)
|
||||
{
|
||||
for (std::list<UserModeName>::iterator it = Modes.begin(), it_end = Modes.end(); it != it_end; ++it)
|
||||
if (!u2->HasMode(*it))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
notice_lang(Config.s_OperServ, u, OPER_USERLIST_RECORD, u2->nick.c_str(), u2->GetIdent().c_str(), u2->GetDisplayedHost().c_str());
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "module.h"
|
||||
@@ -53,10 +51,8 @@ class SSMain : public Module
|
||||
{
|
||||
if (statserv)
|
||||
{
|
||||
for (std::map<ci::string, Command *>::iterator it = statserv->Commands.begin(); it != statserv->Commands.end(); ++it)
|
||||
{
|
||||
for (std::map<ci::string, Command *>::iterator it = statserv->Commands.begin(), it_end = statserv->Commands.end(); it != it_end; ++it)
|
||||
this->DelCommand(statserv, it->second);
|
||||
}
|
||||
|
||||
ircdproto->SendQuit(statserv, "Quit due to module unload.");
|
||||
delete statserv;
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* Send bug reports to the Anope Coder instead of the module
|
||||
* author, because any changes since the inclusion into anope
|
||||
* are not supported by the original author.
|
||||
*
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "module.h"
|
||||
@@ -41,11 +41,13 @@
|
||||
/* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
#define LNG_NUM_STRINGS 3
|
||||
|
||||
#define LNG_CHAN_HELP 0
|
||||
#define LNG_CHAN_HELP_APPENDTOPIC 1
|
||||
#define LNG_APPENDTOPIC_SYNTAX 2
|
||||
enum
|
||||
{
|
||||
LNG_CHAN_HELP,
|
||||
LNG_CHAN_HELP_APPENDTOPIC,
|
||||
LNG_APPENDTOPIC_SYNTAX,
|
||||
LNG_NUM_STRINGS
|
||||
};
|
||||
|
||||
static Module *me;
|
||||
|
||||
@@ -96,20 +98,14 @@ class CommandCSAppendTopic : public Command
|
||||
|
||||
if (!check_access(u, ci, CA_TOPIC))
|
||||
Alog() << Config.s_ChanServ << ": " << u->GetMask() << " changed topic of " << c->name << " as services admin.";
|
||||
if (ircd->join2set)
|
||||
if (ircd->join2set && whosends(ci) == ChanServ)
|
||||
{
|
||||
if (whosends(ci) == ChanServ)
|
||||
{
|
||||
ChanServ->Join(c);
|
||||
ircdproto->SendMode(NULL, c, "+o %s", Config.s_ChanServ); // XXX
|
||||
}
|
||||
ChanServ->Join(c);
|
||||
ircdproto->SendMode(NULL, c, "+o %s", Config.s_ChanServ); // XXX
|
||||
}
|
||||
ircdproto->SendTopic(whosends(ci), c, u->nick.c_str(), topic);
|
||||
if (ircd->join2set)
|
||||
{
|
||||
if (whosends(ci) == ChanServ)
|
||||
ChanServ->Part(c);
|
||||
}
|
||||
if (ircd->join2set && whosends(ci) == ChanServ)
|
||||
ChanServ->Part(c);
|
||||
}
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
+14
-17
@@ -17,14 +17,16 @@
|
||||
|
||||
#define AUTHOR "Anope"
|
||||
|
||||
#define LNG_NUM_STRINGS 6
|
||||
|
||||
#define LNG_CHAN_HELP 0
|
||||
#define LNG_ENFORCE_SYNTAX 1
|
||||
#define LNG_CHAN_HELP_ENFORCE 2
|
||||
#define LNG_CHAN_HELP_ENFORCE_R_ENABLED 3
|
||||
#define LNG_CHAN_HELP_ENFORCE_R_DISABLED 4
|
||||
#define LNG_CHAN_RESPONSE 5
|
||||
enum
|
||||
{
|
||||
LNG_CHAN_HELP,
|
||||
LNG_ENFORCE_SYNTAX,
|
||||
LNG_CHAN_HELP_ENFORCE,
|
||||
LNG_CHAN_HELP_ENFORCE_R_ENABLED,
|
||||
LNG_CHAN_HELP_ENFORCE_R_DISABLED,
|
||||
LNG_CHAN_RESPONSE,
|
||||
LNG_NUM_STRINGS
|
||||
};
|
||||
|
||||
static Module *me;
|
||||
|
||||
@@ -71,7 +73,7 @@ class CommandCSEnforce : public Command
|
||||
hadsecureops = true;
|
||||
}
|
||||
|
||||
for (CUserList::iterator it = c->users.begin(); it != c->users.end(); ++it)
|
||||
for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
|
||||
{
|
||||
UserContainer *uc = *it;
|
||||
|
||||
@@ -79,10 +81,7 @@ class CommandCSEnforce : public Command
|
||||
}
|
||||
|
||||
if (hadsecureops)
|
||||
{
|
||||
ci->UnsetFlag(CI_SECUREOPS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DoRestricted(Channel *c)
|
||||
@@ -101,7 +100,7 @@ class CommandCSEnforce : public Command
|
||||
if (ci->levels[CA_NOJOIN] < 0)
|
||||
ci->levels[CA_NOJOIN] = 0;
|
||||
|
||||
for (CUserList::iterator it = c->users.begin(); it != c->users.end();)
|
||||
for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
|
||||
{
|
||||
UserContainer *uc = *it++;
|
||||
|
||||
@@ -128,18 +127,16 @@ class CommandCSEnforce : public Command
|
||||
|
||||
Alog(LOG_DEBUG) << "[cs_enforce] Enforcing mode +R on " << c->name;
|
||||
|
||||
for (CUserList::iterator it = c->users.begin(); it != c->users.end();)
|
||||
for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
|
||||
{
|
||||
UserContainer *uc = *it++;
|
||||
|
||||
|
||||
if (!uc->user->IsIdentified())
|
||||
{
|
||||
get_idealban(ci, uc->user, mask, sizeof(mask));
|
||||
reason = getstring(uc->user, CHAN_NOT_ALLOWED_TO_JOIN);
|
||||
if (!c->HasMode(CMODE_REGISTERED))
|
||||
{
|
||||
c->SetMode(NULL, CMODE_BAN, mask);
|
||||
}
|
||||
c->Kick(NULL, uc->user, "%s", reason);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-10
@@ -12,7 +12,6 @@
|
||||
* Send bug reports to the Anope Coder instead of the module
|
||||
* author, because any changes since the inclusion into anope
|
||||
* are not supported by the original author.
|
||||
*
|
||||
*/
|
||||
/*************************************************************************/
|
||||
|
||||
@@ -29,11 +28,14 @@ void mAddLanguages();
|
||||
|
||||
static Module *me = NULL;
|
||||
|
||||
#define LANG_NUM_STRINGS 4
|
||||
#define TBAN_HELP 0
|
||||
#define TBAN_SYNTAX 1
|
||||
#define TBAN_HELP_DETAIL 2
|
||||
#define TBAN_RESPONSE 3
|
||||
enum
|
||||
{
|
||||
TBAN_HELP,
|
||||
TBAN_SYNTAX,
|
||||
TBAN_HELP_DETAIL,
|
||||
TBAN_RESPONSE,
|
||||
LANG_NUM_STRINGS
|
||||
};
|
||||
|
||||
class CommandCSTBan : public Command
|
||||
{
|
||||
@@ -57,14 +59,12 @@ class CommandCSTBan : public Command
|
||||
else if (!(u2 = finduser(nick)))
|
||||
notice_lang(Config.s_ChanServ, u, NICK_X_NOT_IN_USE, nick);
|
||||
else
|
||||
{
|
||||
if (canBanUser(c, u, u2))
|
||||
{
|
||||
get_idealban(c->ci, u2, mask, sizeof(mask));
|
||||
addBan(c, dotime(time), mask);
|
||||
mySendResponse(u, chan, mask, time);
|
||||
}
|
||||
}
|
||||
|
||||
return MOD_CONT;
|
||||
}
|
||||
@@ -179,9 +179,7 @@ class TempBan : public CallBack
|
||||
Channel *c;
|
||||
|
||||
if ((c = findchan(chan)) && c->ci)
|
||||
{
|
||||
c->RemoveMode(NULL, CMODE_BAN, mask);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+37
-44
@@ -25,29 +25,31 @@ int HSRequestMemoOper = 0;
|
||||
int HSRequestMemoSetters = 0;
|
||||
|
||||
/* Language defines */
|
||||
#define LNG_NUM_STRINGS 21
|
||||
|
||||
#define LNG_REQUEST_SYNTAX 0
|
||||
#define LNG_REQUESTED 1
|
||||
#define LNG_REQUEST_WAIT 2
|
||||
#define LNG_REQUEST_MEMO 3
|
||||
#define LNG_ACTIVATE_SYNTAX 4
|
||||
#define LNG_ACTIVATED 5
|
||||
#define LNG_ACTIVATE_MEMO 6
|
||||
#define LNG_REJECT_SYNTAX 7
|
||||
#define LNG_REJECTED 8
|
||||
#define LNG_REJECT_MEMO 9
|
||||
#define LNG_REJECT_MEMO_REASON 10
|
||||
#define LNG_NO_REQUEST 11
|
||||
#define LNG_HELP 12
|
||||
#define LNG_HELP_SETTER 13
|
||||
#define LNG_HELP_REQUEST 14
|
||||
#define LNG_HELP_ACTIVATE 15
|
||||
#define LNG_HELP_ACTIVATE_MEMO 16
|
||||
#define LNG_HELP_REJECT 17
|
||||
#define LNG_HELP_REJECT_MEMO 18
|
||||
#define LNG_WAITING_SYNTAX 19
|
||||
#define LNG_HELP_WAITING 20
|
||||
enum
|
||||
{
|
||||
LNG_REQUEST_SYNTAX,
|
||||
LNG_REQUESTED,
|
||||
LNG_REQUEST_WAIT,
|
||||
LNG_REQUEST_MEMO,
|
||||
LNG_ACTIVATE_SYNTAX,
|
||||
LNG_ACTIVATED,
|
||||
LNG_ACTIVATE_MEMO,
|
||||
LNG_REJECT_SYNTAX,
|
||||
LNG_REJECTED,
|
||||
LNG_REJECT_MEMO,
|
||||
LNG_REJECT_MEMO_REASON,
|
||||
LNG_NO_REQUEST,
|
||||
LNG_HELP,
|
||||
LNG_HELP_SETTER,
|
||||
LNG_HELP_REQUEST,
|
||||
LNG_HELP_ACTIVATE,
|
||||
LNG_HELP_ACTIVATE_MEMO,
|
||||
LNG_HELP_REJECT,
|
||||
LNG_HELP_REJECT_MEMO,
|
||||
LNG_WAITING_SYNTAX,
|
||||
LNG_HELP_WAITING,
|
||||
LNG_NUM_STRINGS
|
||||
};
|
||||
|
||||
void my_add_host_request(char *nick, char *vIdent, char *vhost, char *creator, time_t tmp_time);
|
||||
int my_isvalidchar(const char c);
|
||||
@@ -107,9 +109,7 @@ class CommandHSRequest : public Command
|
||||
return MOD_CONT;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (s = vIdent; *s; ++s)
|
||||
{
|
||||
if (!my_isvalidchar(*s))
|
||||
{
|
||||
notice_lang(Config.s_HostServ, u, HOST_SET_IDENT_ERROR);
|
||||
@@ -118,8 +118,6 @@ class CommandHSRequest : public Command
|
||||
delete [] hostmask;
|
||||
return MOD_CONT;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ircd->vident)
|
||||
{
|
||||
notice_lang(Config.s_HostServ, u, HOST_NO_VIDENT);
|
||||
@@ -157,20 +155,17 @@ class CommandHSRequest : public Command
|
||||
|
||||
if ((na = findnick(nick)))
|
||||
{
|
||||
if (HSRequestMemoOper || HSRequestMemoSetters)
|
||||
if ((HSRequestMemoOper || HSRequestMemoSetters) && Config.MSSendDelay > 0 && u && u->lastmemosend + Config.MSSendDelay > now)
|
||||
{
|
||||
if (Config.MSSendDelay > 0 && u && u->lastmemosend + Config.MSSendDelay > now)
|
||||
me->NoticeLang(Config.s_HostServ, u, LNG_REQUEST_WAIT, Config.MSSendDelay);
|
||||
u->lastmemosend = now;
|
||||
if (vIdent)
|
||||
{
|
||||
me->NoticeLang(Config.s_HostServ, u, LNG_REQUEST_WAIT, Config.MSSendDelay);
|
||||
u->lastmemosend = now;
|
||||
if (vIdent)
|
||||
{
|
||||
delete [] vIdent;
|
||||
delete [] rawhostmask;
|
||||
}
|
||||
delete [] hostmask;
|
||||
return MOD_CONT;
|
||||
delete [] vIdent;
|
||||
delete [] rawhostmask;
|
||||
}
|
||||
delete [] hostmask;
|
||||
return MOD_CONT;
|
||||
}
|
||||
my_add_host_request(const_cast<char *>(nick), vIdent, hostmask, const_cast<char *>(u->nick.c_str()), now);
|
||||
|
||||
@@ -328,7 +323,7 @@ class HSListBase : public Command
|
||||
unsigned display_counter = 0;
|
||||
tm *tm;
|
||||
|
||||
for (std::map<std::string, HostRequest *>::iterator it = Requests.begin(); it != Requests.end(); ++it)
|
||||
for (std::map<std::string, HostRequest *>::iterator it = Requests.begin(), it_end = Requests.end(); it != it_end; ++it)
|
||||
{
|
||||
HostRequest *hr = it->second;
|
||||
if (((counter >= from && counter <= to) || (!from && !to)) && display_counter < Config.NSListMax)
|
||||
@@ -721,7 +716,7 @@ class HSRequest : public Module
|
||||
|
||||
void OnDatabaseWrite(void (*Write)(const std::string &))
|
||||
{
|
||||
for (std::map<std::string, HostRequest *>::iterator it = Requests.begin(); it != Requests.end(); ++it)
|
||||
for (std::map<std::string, HostRequest *>::iterator it = Requests.begin(), it_end = Requests.end(); it != it_end; ++it)
|
||||
{
|
||||
HostRequest *hr = it->second;
|
||||
std::stringstream buf;
|
||||
@@ -779,7 +774,7 @@ void req_send_memos(User *u, char *vIdent, char *vHost)
|
||||
{
|
||||
int z = 2;
|
||||
char host[BUFSIZE];
|
||||
std::list<std::pair<ci::string, ci::string> >::iterator it;
|
||||
std::list<std::pair<ci::string, ci::string> >::iterator it, it_end;
|
||||
|
||||
if (vIdent)
|
||||
snprintf(host, sizeof(host), "%s@%s", vIdent, vHost);
|
||||
@@ -787,13 +782,11 @@ void req_send_memos(User *u, char *vIdent, char *vHost)
|
||||
snprintf(host, sizeof(host), "%s", vHost);
|
||||
|
||||
if (HSRequestMemoOper == 1)
|
||||
{
|
||||
for (it = Config.Opers.begin(); it != Config.Opers.end(); ++it)
|
||||
for (it = Config.Opers.begin(), it_end = Config.Opers.end(); it != it_end; ++it)
|
||||
{
|
||||
ci::string nick = it->first;
|
||||
my_memo_lang(u, nick.c_str(), z, LNG_REQUEST_MEMO, host);
|
||||
}
|
||||
}
|
||||
if (HSRequestMemoSetters == 1)
|
||||
{
|
||||
/* Needs to be rethought because of removal of HostSetters in favor of opertype priv -- CyberBotX
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef DB_MYSQL_H
|
||||
#define DB_MYSQL_H
|
||||
|
||||
#include "module.h"
|
||||
|
||||
struct NickAliasFlagInfo
|
||||
@@ -117,15 +120,15 @@ MemoFlagInfo MemoFlags[] = {
|
||||
#define MYSQLPP_MYSQL_HEADERS_BURIED
|
||||
#include <mysql++/mysql++.h>
|
||||
|
||||
inline std::string SQLAssign(const mysqlpp::String& s) { return s.c_str(); }
|
||||
inline std::string SQLAssign(const mysqlpp::String &s) { return s.c_str(); }
|
||||
|
||||
class DBMySQL;
|
||||
static DBMySQL *me;
|
||||
|
||||
bool ExecuteQuery(mysqlpp::Query& query)
|
||||
bool ExecuteQuery(mysqlpp::Query &query)
|
||||
{
|
||||
Alog(LOG_DEBUG) << "MySQL: " << query.str();
|
||||
|
||||
|
||||
if (!query.execute())
|
||||
{
|
||||
Alog() << "MySQL: error executing query: " << query.error();
|
||||
@@ -135,15 +138,13 @@ bool ExecuteQuery(mysqlpp::Query& query)
|
||||
return true;
|
||||
}
|
||||
|
||||
mysqlpp::StoreQueryResult StoreQuery(mysqlpp::Query& query)
|
||||
mysqlpp::StoreQueryResult StoreQuery(mysqlpp::Query &query)
|
||||
{
|
||||
Alog(LOG_DEBUG) << "MySQL: " << query.str();
|
||||
|
||||
mysqlpp::StoreQueryResult result = query.store();
|
||||
if (!result)
|
||||
{
|
||||
Alog() << "MySQL: error executing query: " << query.error();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -195,7 +196,7 @@ class DBMySQL : public Module
|
||||
delete Con;
|
||||
throw ModuleException(Error.c_str());
|
||||
}
|
||||
|
||||
|
||||
mysqlpp::Query query(Con);
|
||||
query << "SET NAMES 'utf8'";
|
||||
ExecuteQuery(query);
|
||||
@@ -208,3 +209,4 @@ class DBMySQL : public Module
|
||||
}
|
||||
};
|
||||
|
||||
#endif // DB_MYSQL_H
|
||||
|
||||
@@ -75,7 +75,7 @@ class SQLTimer : public Timer
|
||||
|
||||
if (qres && qres.num_rows())
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
User *u;
|
||||
NickAlias *na = NULL;
|
||||
@@ -149,7 +149,7 @@ class DBMySQLExecute : public DBMySQL
|
||||
{
|
||||
_SQLTimer = new SQLTimer();
|
||||
}
|
||||
|
||||
|
||||
~DBMySQLExecute()
|
||||
{
|
||||
delete _SQLTimer;
|
||||
|
||||
@@ -34,8 +34,7 @@ static void LoadDatabase()
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
NickCore *nc = new NickCore(SQLAssign(qres[i]["display"]));
|
||||
nc->pass = SQLAssign(qres[i]["pass"]);
|
||||
@@ -51,28 +50,20 @@ static void LoadDatabase()
|
||||
spacesepstream sep(SQLAssign(qres[i]["flags"]));
|
||||
std::string buf;
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
for (int j = 0; NickCoreFlags[j].Flag != -1; ++j)
|
||||
{
|
||||
if (NickCoreFlags[j].Name == buf)
|
||||
{
|
||||
nc->SetFlag(NickCoreFlags[j].Flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nc->language = atoi(qres[i]["language"].c_str());
|
||||
nc->channelcount = atoi(qres[i]["channelcount"].c_str());
|
||||
nc->memos.memomax = atoi(qres[i]["memomax"].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_ns_access`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
NickCore *nc = findcore(qres[i]["display"].c_str());
|
||||
if (!nc)
|
||||
@@ -83,14 +74,12 @@ static void LoadDatabase()
|
||||
|
||||
nc->AddAccess(SQLAssign(qres[i]["access"]));
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_ns_core_metadata`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
NickCore *nc = findcore(qres[i]["display"].c_str());
|
||||
if (!nc)
|
||||
@@ -102,14 +91,12 @@ static void LoadDatabase()
|
||||
std::vector<std::string> Params = MakeVector(SQLAssign(qres[i]["value"]));
|
||||
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(nc, SQLAssign(qres[i]["name"]), Params));
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_ns_alias`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
NickCore *nc = findcore(qres[i]["display"].c_str());
|
||||
if (!nc)
|
||||
@@ -128,24 +115,16 @@ static void LoadDatabase()
|
||||
spacesepstream sep(SQLAssign(qres[i]["flags"]));
|
||||
std::string buf;
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
for (int j = 0; NickAliasFlags[j].Flag != -1; ++j)
|
||||
{
|
||||
if (NickAliasFlags[j].Name == buf)
|
||||
{
|
||||
na->SetFlag(NickAliasFlags[j].Flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_ns_alias_metadata`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
NickAlias *na = findnick(SQLAssign(qres[i]["nick"]));
|
||||
if (!na)
|
||||
@@ -157,14 +136,12 @@ static void LoadDatabase()
|
||||
std::vector<std::string> Params = MakeVector(SQLAssign(qres[i]["value"]));
|
||||
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(na, SQLAssign(qres[i]["name"]), Params));
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_bs_core`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
BotInfo *bi = findbot(SQLAssign(qres[i]["nick"]));
|
||||
if (!bi)
|
||||
@@ -178,28 +155,22 @@ static void LoadDatabase()
|
||||
spacesepstream sep(SQLAssign(qres[i]["flags"]));
|
||||
std::string buf;
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
for (unsigned j = 0; BotServFlags[j].Flag != -1; ++j)
|
||||
{
|
||||
if (buf == BotServFlags[j].Name)
|
||||
{
|
||||
bi->SetFlag(BotServFlags[j].Flag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bi->created = atol(qres[i]["created"]);
|
||||
bi->chancount = atol(qres[i]["chancount"]);
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_bs_info_metadata`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
BotInfo *bi = findbot(SQLAssign(qres[i]["botname"]));
|
||||
if (!bi)
|
||||
@@ -212,14 +183,12 @@ static void LoadDatabase()
|
||||
std::vector<std::string> Params = MakeVector(SQLAssign(qres[i]["value"]));
|
||||
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(bi, SQLAssign(qres[i]["name"]), Params));
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_cs_info`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
NickCore *nc;
|
||||
if (qres[i]["founder"].size())
|
||||
@@ -254,16 +223,12 @@ static void LoadDatabase()
|
||||
std::string buf;
|
||||
spacesepstream sep(SQLAssign(qres[i]["flags"]));
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
for (int j = 0; ChannelFlags[j].Flag != -1; ++j)
|
||||
{
|
||||
if (buf == ChannelFlags[j].Name)
|
||||
{
|
||||
ci->SetFlag(ChannelFlags[j].Flag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (qres[i]["forbidby"].size())
|
||||
ci->forbidby = sstrdup(qres[i]["forbidby"].c_str());
|
||||
@@ -316,16 +281,12 @@ static void LoadDatabase()
|
||||
std::string buf;
|
||||
spacesepstream sep(SQLAssign(qres[i]["botflags"]));
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
for (int j = 0; BotFlags[j].Flag != -1; ++j)
|
||||
{
|
||||
if (buf == BotFlags[j].Name)
|
||||
{
|
||||
ci->botflags.SetFlag(BotFlags[j].Flag);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (qres[i]["capsmin"].size())
|
||||
@@ -339,14 +300,12 @@ static void LoadDatabase()
|
||||
if (qres[i]["repeattimes"].size())
|
||||
ci->repeattimes = atoi(qres[i]["repeattimes"].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_cs_ttb";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
|
||||
if (!ci)
|
||||
@@ -357,14 +316,12 @@ static void LoadDatabase()
|
||||
|
||||
ci->ttb[atoi(qres[i]["ttb_id"].c_str())] = atoi(qres[i]["value"].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_bs_badwords`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
|
||||
if (!ci)
|
||||
@@ -372,7 +329,7 @@ static void LoadDatabase()
|
||||
Alog() << "MySQL: Channel badwords entry for nonexistant channel " << qres[i]["channel"];
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
BadWordType BWTYPE = BW_ANY;
|
||||
if (qres[i]["type"] == "SINGLE")
|
||||
BWTYPE = BW_SINGLE;
|
||||
@@ -382,14 +339,12 @@ static void LoadDatabase()
|
||||
BWTYPE = BW_END;
|
||||
ci->AddBadWord(SQLAssign(qres[i]["word"]), BWTYPE);
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_cs_access`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
|
||||
if (!ci)
|
||||
@@ -406,14 +361,12 @@ static void LoadDatabase()
|
||||
|
||||
ci->AddAccess(nc, atoi(qres[i]["level"]), SQLAssign(qres[i]["creator"]), atol(qres[i]["last_seen"]));
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_cs_akick`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
|
||||
if (!ci)
|
||||
@@ -426,12 +379,10 @@ static void LoadDatabase()
|
||||
std::string flag, mask;
|
||||
bool stuck = false;
|
||||
while (sep.GetToken(flag))
|
||||
{
|
||||
if (flag == "ISNICK")
|
||||
nc = findcore(qres[i]["mask"]);
|
||||
else if (flag == "STUCK")
|
||||
stuck = true;
|
||||
}
|
||||
AutoKick *ak;
|
||||
if (nc)
|
||||
ak = ci->AddAkick(SQLAssign(qres[i]["creator"]), nc, SQLAssign(qres[i]["reason"]), atol(qres[i]["created"].c_str()), atol(qres[i]["last_used"].c_str()));
|
||||
@@ -442,14 +393,12 @@ static void LoadDatabase()
|
||||
if (nc)
|
||||
ak->SetFlag(AK_ISNICK);
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_cs_levels`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
|
||||
if (!ci)
|
||||
@@ -459,14 +408,12 @@ static void LoadDatabase()
|
||||
}
|
||||
ci->levels[atoi(qres[i]["position"])] = atoi(qres[i]["level"]);
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_cs_info_metadata`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
|
||||
if (!ci)
|
||||
@@ -474,19 +421,17 @@ static void LoadDatabase()
|
||||
Alog() << "MySQL: Channel metadata for nonexistant channel " << qres[i]["channel"];
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
std::vector<std::string> Params = MakeVector(SQLAssign(qres[i]["value"]));
|
||||
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(ci, SQLAssign(qres[i]["name"]), Params));
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_ns_request`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
NickRequest *nr = new NickRequest(qres[i]["nick"].c_str());
|
||||
nr->passcode = SQLAssign(qres[i]["passcode"]);
|
||||
@@ -494,27 +439,23 @@ static void LoadDatabase()
|
||||
nr->email = sstrdup(qres[i]["email"].c_str());
|
||||
nr->requested = atol(qres[i]["requested"].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
EventReturn MOD_RESULT;
|
||||
query << "SELECT * FROM `anope_extra`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
std::vector<std::string> params = MakeVector(SQLAssign(qres[i]["data"]));
|
||||
FOREACH_RESULT(I_OnDatabaseRead, OnDatabaseRead(params));
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_ns_core_metadata`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
NickCore *nc = findcore(qres[i]["nick"].c_str());
|
||||
if (nc)
|
||||
@@ -523,14 +464,12 @@ static void LoadDatabase()
|
||||
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(nc, SQLAssign(qres[i]["name"]), params));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_ns_alias_metadata`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
NickAlias *na = findnick(SQLAssign(qres[i]["nick"]));
|
||||
if (na)
|
||||
@@ -539,14 +478,12 @@ static void LoadDatabase()
|
||||
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(na, SQLAssign(qres[i]["name"]), params));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_cs_info_metadata`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(SQLAssign(qres[i]["channel"]));
|
||||
if (ci)
|
||||
@@ -555,14 +492,12 @@ static void LoadDatabase()
|
||||
FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(ci, SQLAssign(qres[i]["name"]), params));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_ms_info`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.num_rows(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
MemoInfo *mi = NULL;
|
||||
if (qres[i]["serv"] == "NICK")
|
||||
@@ -592,37 +527,27 @@ static void LoadDatabase()
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m->number = 1;
|
||||
}
|
||||
m->time = atol(qres[i]["time"].c_str());
|
||||
m->text = sstrdup(qres[i]["text"].c_str());
|
||||
|
||||
|
||||
if (qres[i]["flags"].size())
|
||||
{
|
||||
spacesepstream sep(SQLAssign(qres[i]["flags"]));
|
||||
std::string buf;
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
for (unsigned j = 0; MemoFlags[j].Flag != -1; ++j)
|
||||
{
|
||||
if (MemoFlags[j].Name == buf)
|
||||
{
|
||||
m->SetFlag(MemoFlags[j].Flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_os_akills`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres && SGLine)
|
||||
{
|
||||
for (size_t i = 0; i < qres.size(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
ci::string user = qres[i]["user"].c_str();
|
||||
ci::string host = qres[i]["host"].c_str();
|
||||
@@ -638,14 +563,12 @@ static void LoadDatabase()
|
||||
x->Created = seton;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query << "SELECT * FROM `anope_os_xlines`";
|
||||
qres = StoreQuery(query);
|
||||
|
||||
if (qres)
|
||||
{
|
||||
for (size_t i = 0; i < qres.size(); ++i)
|
||||
for (size_t i = 0, end = qres.num_rows(); i < end; ++i)
|
||||
{
|
||||
ci::string mask = qres[i]["mask"].c_str();
|
||||
ci::string by = qres[i]["xby"].c_str();
|
||||
@@ -666,7 +589,6 @@ static void LoadDatabase()
|
||||
x->Created = seton;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DBMySQLRead : public DBMySQL
|
||||
|
||||
@@ -7,12 +7,8 @@ static std::string BuildFlagsList(ChannelInfo *ci)
|
||||
std::string ret;
|
||||
|
||||
for (int i = 0; ChannelFlags[i].Flag != -1; ++i)
|
||||
{
|
||||
if (ci->HasFlag(ChannelFlags[i].Flag))
|
||||
{
|
||||
ret += " " + ChannelFlags[i].Name;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ret.empty())
|
||||
ret.erase(ret.begin());
|
||||
@@ -25,12 +21,8 @@ static std::string BuildFlagsList(NickAlias *na)
|
||||
std::string ret;
|
||||
|
||||
for (int i = 0; NickAliasFlags[i].Flag != -1; ++i)
|
||||
{
|
||||
if (na->HasFlag(NickAliasFlags[i].Flag))
|
||||
{
|
||||
ret += " " + NickAliasFlags[i].Name;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ret.empty())
|
||||
ret.erase(ret.begin());
|
||||
@@ -43,12 +35,8 @@ static std::string BuildFlagsList(NickCore *nc)
|
||||
std::string ret;
|
||||
|
||||
for (int i = 0; NickCoreFlags[i].Flag != -1; ++i)
|
||||
{
|
||||
if (nc->HasFlag(NickCoreFlags[i].Flag))
|
||||
{
|
||||
ret += " " + NickCoreFlags[i].Name;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ret.empty())
|
||||
ret.erase(ret.begin());
|
||||
@@ -61,16 +49,12 @@ static std::string BuildFlagsList(Memo *m)
|
||||
std::string ret;
|
||||
|
||||
for (int i = 0; MemoFlags[i].Flag != -1; ++i)
|
||||
{
|
||||
if (m->HasFlag(MemoFlags[i].Flag))
|
||||
{
|
||||
ret += " " + MemoFlags[i].Name;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ret.empty())
|
||||
ret.erase(ret.begin());
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -78,16 +62,14 @@ static std::string MakeMLock(ChannelInfo *ci, bool status)
|
||||
{
|
||||
std::string ret;
|
||||
|
||||
for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it)
|
||||
for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(), it_end = ModeManager::Modes.end(); it != it_end; ++it)
|
||||
{
|
||||
if ((*it)->Class == MC_CHANNEL)
|
||||
{
|
||||
ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
|
||||
|
||||
if (ci->HasMLock(cm->Name, status))
|
||||
{
|
||||
ret += " " + cm->NameAsString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,17 +93,15 @@ static std::string GetMLockParams(ChannelInfo *ci)
|
||||
{
|
||||
std::string ret;
|
||||
|
||||
for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(); it != ModeManager::Modes.end(); ++it)
|
||||
for (std::list<Mode *>::iterator it = ModeManager::Modes.begin(), it_end = ModeManager::Modes.end(); it != it_end; ++it)
|
||||
{
|
||||
if ((*it)->Class == MC_CHANNEL)
|
||||
{
|
||||
ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
|
||||
|
||||
|
||||
std::string param;
|
||||
if (ci->GetParam(cm->Name, param))
|
||||
{
|
||||
ret += " " + cm->NameAsString + " " + param;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,12 +116,8 @@ static std::string GetBotFlags(Flags<BotServFlag>& Flags)
|
||||
std::string buf;
|
||||
|
||||
for (int i = 0; BotFlags[i].Flag != -1; ++i)
|
||||
{
|
||||
if (Flags.HasFlag(BotFlags[i].Flag))
|
||||
{
|
||||
buf += " " + BotFlags[i].Name;
|
||||
}
|
||||
}
|
||||
|
||||
if (!buf.empty())
|
||||
buf.erase(buf.begin());
|
||||
@@ -154,16 +130,12 @@ static std::string GetBotServFlags(BotInfo *bi)
|
||||
std::string buf;
|
||||
|
||||
for (int i = 0; BotServFlags[i].Flag != -1; ++i)
|
||||
{
|
||||
if (bi->HasFlag(BotServFlags[i].Flag))
|
||||
{
|
||||
buf += " " + BotServFlags[i].Name;
|
||||
}
|
||||
}
|
||||
|
||||
if (!buf.empty())
|
||||
buf.erase(buf.begin());;
|
||||
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -200,7 +172,7 @@ void WriteCoreMetadata(const std::string &key, const std::string &data)
|
||||
{
|
||||
if (!CurCore)
|
||||
throw CoreException("WritCoreMetadata without a core to write");
|
||||
|
||||
|
||||
mysqlpp::Query query(me->Con);
|
||||
query << "INSERT DELAYED INTO `anope_ns_core_metadata` (nick, name, value) VALUES(" << mysqlpp::quote << CurCore->display << ", " << mysqlpp::quote << key << ", " << mysqlpp::quote << data << ")";
|
||||
ExecuteQuery(query);
|
||||
@@ -220,7 +192,7 @@ void WriteBotMetadata(const std::string &key, const std::string &data)
|
||||
{
|
||||
if (!CurBot)
|
||||
throw CoreException("WriteBotMetadata without a bot to write");
|
||||
|
||||
|
||||
mysqlpp::Query query(me->Con);
|
||||
query << "INSERT DELAYED INTO `anope_bs_info_metadata` (botname, name, value) VALUES(" << mysqlpp::quote << CurBot->nick << ", " << mysqlpp::quote << key << ", " << mysqlpp::quote << data << ")";
|
||||
ExecuteQuery(query);
|
||||
@@ -233,27 +205,25 @@ static void SaveDatabases()
|
||||
query << "TRUNCATE TABLE `anope_ns_alias`";
|
||||
ExecuteQuery(query);
|
||||
|
||||
for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it)
|
||||
{
|
||||
for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end; ++it)
|
||||
me->OnNickRegister(it->second);
|
||||
}
|
||||
|
||||
query << "TRUNCATE TABLE `anope_ns_core`";
|
||||
ExecuteQuery(query);
|
||||
query << "TRUNCATE TABLE `anope_ms_info`";
|
||||
ExecuteQuery(query);
|
||||
|
||||
for (nickcore_map::const_iterator nit = NickCoreList.begin(); nit != NickCoreList.end(); ++nit)
|
||||
|
||||
for (nickcore_map::const_iterator nit = NickCoreList.begin(), nit_end = NickCoreList.end(); nit != nit_end; ++nit)
|
||||
{
|
||||
NickCore *nc = nit->second;
|
||||
|
||||
for (std::vector<std::string>::iterator it = nc->access.begin(); it != nc->access.end(); ++it)
|
||||
|
||||
for (std::vector<std::string>::iterator it = nc->access.begin(), it_end = nc->access.end(); it != it_end; ++it)
|
||||
{
|
||||
query << "INSERT DELAYED INTO `anope_ns_access` (display, access) VALUES(" << mysqlpp::quote << nc->display << ", " << mysqlpp::quote << *it << ")";
|
||||
ExecuteQuery(query);
|
||||
}
|
||||
|
||||
for (unsigned j = 0; j < nc->memos.memos.size(); ++j)
|
||||
for (unsigned j = 0, end = nc->memos.memos.size(); j < end; ++j)
|
||||
{
|
||||
Memo *m = nc->memos.memos[j];
|
||||
|
||||
@@ -264,11 +234,9 @@ static void SaveDatabases()
|
||||
|
||||
query << "TRUNCATE TABLE `anope_bs_core`";
|
||||
ExecuteQuery(query);
|
||||
|
||||
for (botinfo_map::const_iterator it = BotListByNick.begin(); it != BotListByNick.end(); ++it)
|
||||
{
|
||||
|
||||
for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
|
||||
me->OnBotCreate(it->second);
|
||||
}
|
||||
|
||||
query << "TRUNCATE TABLE `anope_cs_info`";
|
||||
ExecuteQuery(query);
|
||||
@@ -281,20 +249,20 @@ static void SaveDatabases()
|
||||
query << "TRUNCATE TABLE `anope_cs_levels`";
|
||||
ExecuteQuery(query);
|
||||
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
|
||||
{
|
||||
ChannelInfo *ci = it->second;
|
||||
|
||||
|
||||
me->OnChanRegistered(ci);
|
||||
|
||||
for (unsigned j = 0; j < ci->GetBadWordCount(); ++j)
|
||||
for (unsigned j = 0, end = ci->GetBadWordCount(); j < end; ++j)
|
||||
{
|
||||
BadWord *bw = ci->GetBadWord(j);
|
||||
|
||||
me->OnBadWordAdd(ci, bw);
|
||||
}
|
||||
|
||||
for (unsigned j = 0; j < ci->GetAccessCount(); ++j)
|
||||
for (unsigned j = 0, end = ci->GetAccessCount(); j < end; ++j)
|
||||
{
|
||||
ChanAccess *access = ci->GetAccess(j);
|
||||
|
||||
@@ -302,20 +270,20 @@ static void SaveDatabases()
|
||||
ExecuteQuery(query);
|
||||
}
|
||||
|
||||
for (unsigned j = 0; j < ci->GetAkickCount(); ++j)
|
||||
for (unsigned j = 0, end = ci->GetAkickCount(); j < end; ++j)
|
||||
{
|
||||
AutoKick *ak = ci->GetAkick(j);
|
||||
|
||||
me->OnAkickAdd(NULL, ci, ak);
|
||||
}
|
||||
|
||||
|
||||
for (int k = 0; k < CA_SIZE; ++k)
|
||||
{
|
||||
query << "INSERT DELAYED INTO `anope_cs_levels` (channel, position, level) VALUES(" << mysqlpp::quote << ci->name << ", '" << k << "', '" << ci->levels[k] << "') ON DUPLICATE KEY UPDATE position=VALUES(position), level=VALUES(level)";
|
||||
ExecuteQuery(query);
|
||||
}
|
||||
|
||||
for (unsigned j = 0; j < ci->memos.memos.size(); ++j)
|
||||
for (unsigned j = 0, end = ci->memos.memos.size(); j < end; ++j)
|
||||
{
|
||||
Memo *m = ci->memos.memos[j];
|
||||
|
||||
@@ -326,42 +294,24 @@ static void SaveDatabases()
|
||||
query << "TRUNCATE TABLE `anope_ns_request`";
|
||||
ExecuteQuery(query);
|
||||
|
||||
for (nickrequest_map::const_iterator it = NickRequestList.begin(); it != NickRequestList.end(); ++it)
|
||||
{
|
||||
for (nickrequest_map::const_iterator it = NickRequestList.begin(), it_end = NickRequestList.end(); it != it_end; ++it)
|
||||
me->OnMakeNickRequest(it->second);
|
||||
}
|
||||
|
||||
if (SGLine)
|
||||
{
|
||||
for (unsigned i = 0; i < SGLine->GetCount(); ++i)
|
||||
{
|
||||
for (unsigned i = 0, end = SGLine->GetCount(); i < end; ++i)
|
||||
me->OnAddAkill(NULL, SGLine->GetEntry(i));
|
||||
}
|
||||
}
|
||||
|
||||
if (SZLine)
|
||||
{
|
||||
for (unsigned i = 0; i < SZLine->GetCount(); ++i)
|
||||
{
|
||||
for (unsigned i = 0, end = SZLine->GetCount(); i < end; ++i)
|
||||
me->OnAddXLine(NULL, SZLine->GetEntry(i), X_SZLINE);
|
||||
}
|
||||
}
|
||||
|
||||
if (SQLine)
|
||||
{
|
||||
for (unsigned i = 0; i < SQLine->GetCount(); ++i)
|
||||
{
|
||||
for (unsigned i = 0, end = SQLine->GetCount(); i < end; ++i)
|
||||
me->OnAddXLine(NULL, SQLine->GetEntry(i), X_SQLINE);
|
||||
}
|
||||
}
|
||||
|
||||
if (SNLine)
|
||||
{
|
||||
for (unsigned i = 0; i < SNLine->GetCount(); ++i)
|
||||
{
|
||||
for (unsigned i = 0, end = SNLine->GetCount(); i < end; ++i)
|
||||
me->OnAddXLine(NULL, SNLine->GetEntry(i), X_SNLINE);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < nexceptions; ++i)
|
||||
{
|
||||
@@ -408,7 +358,7 @@ class DBMySQLWrite : public DBMySQL
|
||||
ModuleManager::Attach(I_OnServerConnect, this);
|
||||
|
||||
this->AddCommand(OperServ, new CommandSyncSQL("SQLSYNC"));
|
||||
|
||||
|
||||
if (uplink_server)
|
||||
OnServerConnect();
|
||||
}
|
||||
@@ -454,25 +404,25 @@ class DBMySQLWrite : public DBMySQL
|
||||
query << maxusercnt << ", " << maxusertime << ", " << (SGLine ? SGLine->GetCount() : 0) << ", " << (SQLine ? SQLine->GetCount() : 0) << ", " << (SNLine ? SNLine->GetCount() : 0) << ", " << (SZLine ? SZLine->GetCount() : 0) << ")";
|
||||
ExecuteQuery(query);
|
||||
|
||||
for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it)
|
||||
for (nickcore_map::const_iterator it = NickCoreList.begin(), it_end = NickCoreList.end(); it != end; ++it)
|
||||
{
|
||||
CurCore = it->second;
|
||||
FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteCoreMetadata, CurCore));
|
||||
}
|
||||
|
||||
for (nickalias_map::const_iterator it = NickAliasList.begin(); it != NickAliasList.end(); ++it)
|
||||
for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end; ++it)
|
||||
{
|
||||
CurNick = it->second;
|
||||
FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteNickMetadata, CurNick));
|
||||
}
|
||||
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChanelList.end(); it != it_end; ++it)
|
||||
{
|
||||
CurChannel = it->second;
|
||||
FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteChannelMetadata, CurChannel));
|
||||
}
|
||||
|
||||
for (botinfo_map::const_iterator it = BotListByNick.begin(); it != BotListByNick.end(); ++it)
|
||||
|
||||
for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
|
||||
{
|
||||
CurBot = it->second;
|
||||
FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteBotMetadata, CurBot));
|
||||
@@ -608,8 +558,7 @@ class DBMySQLWrite : public DBMySQL
|
||||
return;
|
||||
if (!check_access(u, ci, CA_SET) && !u->Account()->HasPriv("botserv/administration"))
|
||||
return;
|
||||
if (params[1] == "BADWORDS" || params[1] == "BOLDS" || params[1] == "CAPS" || params[1] == "COLORS"
|
||||
|| params[1] == "FLOOD" || params[1] == "REPEAT" || params[1] == "REVERSES" || params[1] == "UNDERLINES")
|
||||
if (params[1] == "BADWORDS" || params[1] == "BOLDS" || params[1] == "CAPS" || params[1] == "COLORS" || params[1] == "FLOOD" || params[1] == "REPEAT" || params[1] == "REVERSES" || params[1] == "UNDERLINES")
|
||||
{
|
||||
if (params[2] == "ON" || params[2] == "OFF")
|
||||
{
|
||||
@@ -654,8 +603,7 @@ class DBMySQLWrite : public DBMySQL
|
||||
}
|
||||
else if (!ci)
|
||||
return;
|
||||
else if (params[1] == "DONTKICKOPS" || params[1] == "DONTKICKVOICES" || params[1] == "FANTASY" || params[1] == "GREET"
|
||||
|| params[1] == "SYMBIOSIS" || params[1] == "NOBOT")
|
||||
else if (params[1] == "DONTKICKOPS" || params[1] == "DONTKICKVOICES" || params[1] == "FANTASY" || params[1] == "GREET" || params[1] == "SYMBIOSIS" || params[1] == "NOBOT")
|
||||
{
|
||||
query << "UPDATE `anope_cs_info` SET `botflags` = '" << GetBotFlags(ci->botflags) << "' WHERE `name` = " << mysqlpp::quote << ci->name;
|
||||
ExecuteQuery(query);
|
||||
@@ -714,7 +662,7 @@ class DBMySQLWrite : public DBMySQL
|
||||
{
|
||||
OnNickRegister(findnick(u->nick));
|
||||
}
|
||||
|
||||
|
||||
void OnMakeNickRequest(NickRequest *nr)
|
||||
{
|
||||
mysqlpp::Query query(me->Con);
|
||||
@@ -784,7 +732,7 @@ class DBMySQLWrite : public DBMySQL
|
||||
void OnAccessAdd(ChannelInfo *ci, User *u, NickAlias *na, int level)
|
||||
{
|
||||
mysqlpp::Query query(me->Con);
|
||||
query << "INSERT DELAYED INTO `anope_cs_access` (level, display, channel, last_seen, creator) VALUES (" << level << ", " << mysqlpp::quote << na->nc->display << ", " << mysqlpp::quote << ci->name << ", " << time(NULL) << ", " << mysqlpp::quote << u->nick << ")";
|
||||
query << "INSERT DELAYED INTO `anope_cs_access` (level, display, channel, last_seen, creator) VALUES (" << level << ", " << mysqlpp::quote << na->nc->display << ", " << mysqlpp::quote << ci->name << ", " << time(NULL) << ", " << mysqlpp::quote << u->nick << ")";
|
||||
ExecuteQuery(query);
|
||||
}
|
||||
|
||||
@@ -819,13 +767,11 @@ class DBMySQLWrite : public DBMySQL
|
||||
ExecuteQuery(query);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < CA_SIZE; ++i)
|
||||
{
|
||||
query << "UPDATE `anope_cs_levels` SET `level` = " << ci->levels[i] << " WHERE `channel` = " << mysqlpp::quote << ci->name << " AND `position` = " << i;
|
||||
ExecuteQuery(query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnChanForbidden(ChannelInfo *ci)
|
||||
@@ -852,7 +798,7 @@ class DBMySQLWrite : public DBMySQL
|
||||
query << "DELETE FROM `anope_bs_badwords` WHERE `channel` = " << mysqlpp::quote << ci->name;
|
||||
ExecuteQuery(query);
|
||||
}
|
||||
|
||||
|
||||
void OnChanRegistered(ChannelInfo *ci)
|
||||
{
|
||||
mysqlpp::Query query(me->Con);
|
||||
@@ -1092,4 +1038,3 @@ class DBMySQLWrite : public DBMySQL
|
||||
};
|
||||
|
||||
MODULE_INIT(DBMySQLWrite)
|
||||
|
||||
|
||||
@@ -23,9 +23,12 @@ bool check_email_limit_reached(const char *email, User * u);
|
||||
|
||||
int NSEmailMax = 0;
|
||||
|
||||
#define LNG_NUM_STRINGS 2
|
||||
#define LNG_NSEMAILMAX_REACHED 0
|
||||
#define LNG_NSEMAILMAX_REACHED_ONE 1
|
||||
enum
|
||||
{
|
||||
LNG_NSEMAILMAX_REACHED,
|
||||
LNG_NSEMAILMAX_REACHED_ONE,
|
||||
LNG_NUM_STRINGS
|
||||
};
|
||||
|
||||
static Module *me;
|
||||
|
||||
@@ -122,7 +125,6 @@ class NSMaxEmail : public Module
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int count_email_in_use(const char *email, User * u)
|
||||
{
|
||||
int count = 0;
|
||||
@@ -130,7 +132,7 @@ int count_email_in_use(const char *email, User * u)
|
||||
if (!email)
|
||||
return 0;
|
||||
|
||||
for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it)
|
||||
for (nickcore_map::const_iterator it = NickCoreList.begin(), it_end = NickCoreList.end(); it != it_end; ++it)
|
||||
{
|
||||
NickCore *nc = it->second;
|
||||
|
||||
|
||||
+17
-16
@@ -12,7 +12,6 @@
|
||||
* Send bug reports to the Anope Coder instead of the module
|
||||
* author, because any changes since the inclusion into anope
|
||||
* are not supported by the original author.
|
||||
*
|
||||
*/
|
||||
/*************************************************************************/
|
||||
|
||||
@@ -21,18 +20,20 @@
|
||||
#define AUTHOR "Rob"
|
||||
|
||||
/* Multi-language stuff */
|
||||
#define LANG_NUM_STRINGS 10
|
||||
|
||||
#define OINFO_SYNTAX 0
|
||||
#define OINFO_ADD_SUCCESS 1
|
||||
#define OINFO_DEL_SUCCESS 2
|
||||
#define OCINFO_SYNTAX 3
|
||||
#define OCINFO_ADD_SUCCESS 4
|
||||
#define OCINFO_DEL_SUCCESS 5
|
||||
#define OINFO_HELP 6
|
||||
#define OCINFO_HELP 7
|
||||
#define OINFO_HELP_CMD 8
|
||||
#define OCINFO_HELP_CMD 9
|
||||
enum
|
||||
{
|
||||
OINFO_SYNTAX,
|
||||
OINFO_ADD_SUCCESS,
|
||||
OINFO_DEL_SUCCESS,
|
||||
OCINFO_SYNTAX,
|
||||
OCINFO_ADD_SUCCESS,
|
||||
OCINFO_DEL_SUCCESS,
|
||||
OINFO_HELP,
|
||||
OCINFO_HELP,
|
||||
OINFO_HELP_CMD,
|
||||
OCINFO_HELP_CMD,
|
||||
LANG_NUM_STRINGS
|
||||
};
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
@@ -425,14 +426,14 @@ class OSInfo : public Module
|
||||
{
|
||||
OnSaveDatabase();
|
||||
|
||||
for (nickcore_map::const_iterator it = NickCoreList.begin(); it != NickCoreList.end(); ++it)
|
||||
for (nickcore_map::const_iterator it = NickCoreList.begin(), it_end = NickCoreList.end(); it != it_end; ++it)
|
||||
{
|
||||
NickCore *nc = it->second;
|
||||
|
||||
nc->Shrink("os_info");
|
||||
}
|
||||
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(); it != RegisteredChannelList.end(); ++it)
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
|
||||
{
|
||||
ChannelInfo *ci = it->second;
|
||||
|
||||
@@ -503,7 +504,7 @@ class OSInfo : public Module
|
||||
{
|
||||
ci->Shrink("os_info");
|
||||
ci->Extend("os_info", new ExtensibleItemPointerArray<char>(sstrdup(params[0].c_str())));
|
||||
|
||||
|
||||
return EVENT_STOP;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "module.h"
|
||||
|
||||
#define OPENSSL_NO_SHA512
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
@@ -31,7 +32,7 @@ class SSLSocket : public Socket
|
||||
SSLSocket(const std::string &nTargetHost, int nPort, const std::string &nBindHost = "", bool nIPv6 = false) : Socket(nTargetHost, nPort, nBindHost, nIPv6)
|
||||
{
|
||||
sslsock = SSL_new(ctx);
|
||||
|
||||
|
||||
if (!sslsock)
|
||||
throw CoreException("Unable to initialize SSL socket");
|
||||
|
||||
@@ -62,20 +63,13 @@ class SSLModule : public Module
|
||||
public:
|
||||
SSLModule(const std::string &modname, const std::string &creator) : Module(modname, creator)
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
this->SetVersion("$Id$");
|
||||
this->SetType(SUPPORTED);
|
||||
this->SetPermanent(true);
|
||||
|
||||
SSL_load_error_strings();
|
||||
SSLeay_add_ssl_algorithms();
|
||||
|
||||
ctx = SSL_CTX_new(SSLv23_client_method());
|
||||
|
||||
if (!ctx)
|
||||
{
|
||||
throw ModuleException("Error initializing SSL CTX");
|
||||
}
|
||||
|
||||
if (IsFile(CERTFILE))
|
||||
{
|
||||
@@ -86,9 +80,7 @@ class SSLModule : public Module
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Alog() << "m_ssl: No certificate file found";
|
||||
}
|
||||
|
||||
if (IsFile(KEYFILE))
|
||||
{
|
||||
@@ -106,11 +98,13 @@ class SSLModule : public Module
|
||||
throw ModuleException("Error loading private key - file not found");
|
||||
}
|
||||
else
|
||||
{
|
||||
Alog() << "m_ssl: No private key found";
|
||||
}
|
||||
}
|
||||
|
||||
this->SetAuthor("Anope");
|
||||
this->SetType(SUPPORTED);
|
||||
this->SetPermanent(true);
|
||||
|
||||
SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2);
|
||||
SSL_CTX_set_options(ctx, SSL_OP_TLS_ROLLBACK_BUG | SSL_OP_ALL);
|
||||
|
||||
|
||||
@@ -13,6 +13,10 @@ foreach(SRC ${TOOLS_SRCS})
|
||||
string(REGEX REPLACE "\\.(c|cpp)$" "" EXE ${SRC})
|
||||
# Calculate the header file dependencies for the given source file
|
||||
calculate_depends(${SRC})
|
||||
# For anoptsmtp, we also want hashcomp.cpp included, so we force it into the sources
|
||||
if(SRC STREQUAL anopesmtp.cpp)
|
||||
set(SRC ${SRC} ${Anope_SOURCE_DIR}/src/hashcomp.cpp)
|
||||
endif(SRC STREQUAL anopesmtp.cpp)
|
||||
# Generate the executable and set it's linker flags, also set it to depend on the main Anope executable to be built beforehand
|
||||
add_executable(${EXE} ${SRC})
|
||||
set_target_properties(${EXE} PROPERTIES LINKER_LANGUAGE CXX LINK_FLAGS "${LDFLAGS}")
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
*
|
||||
* Written by Dominick Meglio <codemastr@unrealircd.com>
|
||||
* *nix port by Trystan Scott Lee <trystan@nomadirc.net>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "smtp.h"
|
||||
@@ -20,37 +19,18 @@ static int curday = 0;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*#ifdef _WIN32
|
||||
int strcasecmp(const char *s1, const char *s2)
|
||||
static int get_logname(std::string &name, struct tm *tm = NULL)
|
||||
{
|
||||
register int c;
|
||||
|
||||
while ((c = tolower(*s1)) == tolower(*s2)) {
|
||||
if (c == 0)
|
||||
return 0;
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
if (c < tolower(*s2))
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
#endif*/
|
||||
|
||||
static int get_logname(char *name, int count, struct tm *tm)
|
||||
{
|
||||
|
||||
char timestamp[32];
|
||||
|
||||
if (!tm) {
|
||||
time_t t;
|
||||
|
||||
time(&t);
|
||||
if (!tm)
|
||||
{
|
||||
time_t t = time(NULL);
|
||||
tm = localtime(&t);
|
||||
}
|
||||
|
||||
strftime(timestamp, count, "%Y%m%d", tm);
|
||||
snprintf(name, count, "logs/%s.%s", "anopesmtp", timestamp);
|
||||
strftime(timestamp, sizeof(timestamp), "%Y%m%d", tm);
|
||||
name = std::string("logs/anopesmtp.") + timestamp;
|
||||
curday = tm->tm_yday;
|
||||
|
||||
return 1;
|
||||
@@ -72,18 +52,14 @@ void close_log()
|
||||
|
||||
static void remove_log()
|
||||
{
|
||||
time_t t;
|
||||
struct tm tm;
|
||||
time_t t = time(NULL);
|
||||
t -= 2592000; // 30 days ago
|
||||
struct tm *tm = localtime(&t);
|
||||
|
||||
char name[PATH_MAX];
|
||||
|
||||
time(&t);
|
||||
t -= (60 * 60 * 24 * 30);
|
||||
tm = *localtime(&t);
|
||||
|
||||
if (!get_logname(name, sizeof(name), &tm))
|
||||
std::string name;
|
||||
if (!get_logname(name, tm))
|
||||
return;
|
||||
unlink(name);
|
||||
unlink(name.c_str());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
@@ -93,31 +69,25 @@ static void remove_log()
|
||||
|
||||
int open_log()
|
||||
{
|
||||
char name[PATH_MAX];
|
||||
|
||||
if (logfile)
|
||||
return 0;
|
||||
|
||||
if (!get_logname(name, sizeof(name), NULL))
|
||||
std::string name;
|
||||
if (!get_logname(name))
|
||||
return 0;
|
||||
logfile = fopen(name, "a");
|
||||
|
||||
if (logfile)
|
||||
setbuf(logfile, NULL);
|
||||
return logfile != NULL ? 0 : -1;
|
||||
logfile = fopen(name.c_str(), "w");
|
||||
return logfile ? 0 : -1;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
static void checkday()
|
||||
{
|
||||
time_t t;
|
||||
struct tm tm;
|
||||
time_t t = time(NULL);
|
||||
struct tm *tm = localtime(&t);
|
||||
|
||||
time(&t);
|
||||
tm = *localtime(&t);
|
||||
|
||||
if (curday != tm.tm_yday) {
|
||||
if (curday != tm->tm_yday)
|
||||
{
|
||||
close_log();
|
||||
remove_log();
|
||||
open_log();
|
||||
@@ -132,27 +102,26 @@ static void checkday()
|
||||
|
||||
void alog(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
time_t t;
|
||||
struct tm tm;
|
||||
char buf[256];
|
||||
int errno_save = errno;
|
||||
|
||||
if (!smtp_debug) {
|
||||
if (!smtp_debug)
|
||||
return;
|
||||
}
|
||||
|
||||
checkday();
|
||||
|
||||
if (!fmt) {
|
||||
if (!fmt)
|
||||
return;
|
||||
}
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
time(&t);
|
||||
tm = *localtime(&t);
|
||||
strftime(buf, sizeof(buf) - 1, "[%b %d %H:%M:%S %Y] ", &tm);
|
||||
if (logfile && args) {
|
||||
|
||||
time_t t = time(NULL);
|
||||
struct tm *tm = localtime(&t);
|
||||
|
||||
char buf[256];
|
||||
strftime(buf, sizeof(buf) - 1, "[%b %d %H:%M:%S %Y] ", tm);
|
||||
if (logfile)
|
||||
{
|
||||
fputs(buf, logfile);
|
||||
vfprintf(logfile, fmt, args);
|
||||
fputc('\n', logfile);
|
||||
@@ -164,142 +133,91 @@ void alog(const char *fmt, ...)
|
||||
/*************************************************************************/
|
||||
|
||||
/* Remove a trailing \r\n */
|
||||
char *strip(char *buf)
|
||||
ci::string strip(const ci::string &buf)
|
||||
{
|
||||
char *c;
|
||||
if ((c = strchr(buf, '\n')))
|
||||
*c = 0;
|
||||
if ((c = strchr(buf, '\r')))
|
||||
*c = 0;
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Convert a trailing \n to \r\n
|
||||
* The caller must free the allocated memory
|
||||
*/
|
||||
char *lftocrlf(char *buf)
|
||||
{
|
||||
char *result = (char *)malloc(strlen(buf) + 2);
|
||||
strip(buf);
|
||||
strcpy(result, buf);
|
||||
strcat(result, "\r\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Add a header to the list */
|
||||
void smtp_add_header(char *header)
|
||||
{
|
||||
struct smtp_header *head = (struct smtp_header *)malloc(sizeof(struct smtp_header));
|
||||
|
||||
head->header = lftocrlf(header);
|
||||
head->next = NULL;
|
||||
|
||||
if (!mail.smtp_headers) {
|
||||
mail.smtp_headers = head;
|
||||
ci::string newbuf = buf;
|
||||
char c = newbuf[newbuf.size() - 1];
|
||||
while (c == '\n' || c == '\r')
|
||||
{
|
||||
newbuf.erase(newbuf.end() - 1);
|
||||
c = newbuf[newbuf.size() - 1];
|
||||
}
|
||||
if (mail.smtp_headers_tail) {
|
||||
mail.smtp_headers_tail->next = head;
|
||||
}
|
||||
mail.smtp_headers_tail = head;
|
||||
return newbuf;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Is the buffer a header? */
|
||||
int smtp_is_header(char *buf)
|
||||
bool smtp_is_header(const ci::string &buf)
|
||||
{
|
||||
char *tmp = strchr(buf, ' ');
|
||||
size_t tmp = buf.find(' ');
|
||||
|
||||
if (!tmp)
|
||||
return 0;
|
||||
if (tmp == ci::string::npos)
|
||||
return false;
|
||||
|
||||
if (*(tmp - 1) == ':')
|
||||
return 1;
|
||||
return 0;
|
||||
if (buf[tmp + 1] == ':')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Parse a header into a name and value */
|
||||
void smtp_parse_header(char *buf, char **header, char **value)
|
||||
void smtp_parse_header(const ci::string &buf, ci::string &header, ci::string &value)
|
||||
{
|
||||
strip(buf);
|
||||
ci::string newbuf = strip(buf);
|
||||
|
||||
*header = strtok(buf, " ");
|
||||
*value = strtok(NULL, "");
|
||||
if (*header)
|
||||
(*header)[strlen(*header) - 1] = 0;
|
||||
size_t space = newbuf.find(' ');
|
||||
if (space != ci::string::npos)
|
||||
{
|
||||
header = newbuf.substr(0, space);
|
||||
value = newbuf.substr(space + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
header = newbuf;
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Have we reached the end of input? */
|
||||
int smtp_is_end(char *buf)
|
||||
bool smtp_is_end(const ci::string &buf)
|
||||
{
|
||||
if (*buf == '.')
|
||||
if (*(buf + 1) == '\r' || *(buf + 1) == '\n')
|
||||
return 1;
|
||||
if (buf[0] == '.')
|
||||
if (buf[1] == '\r' || buf[1] == '\n')
|
||||
return true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Set who the email is from */
|
||||
void smtp_set_from(char *from)
|
||||
{
|
||||
mail.from = strdup(from);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Set who the email is to */
|
||||
void smtp_set_to(char *to)
|
||||
void smtp_set_to(const ci::string &to)
|
||||
{
|
||||
char *c;
|
||||
|
||||
if ((c = strrchr(to, '<')) && *(c + 1)) {
|
||||
to = c + 1;
|
||||
to[strlen(to) - 1] = 0;
|
||||
mail.to = to;
|
||||
size_t c = mail.to.rfind('<');
|
||||
if (c != ci::string::npos && c + 1 < mail.to.size())
|
||||
{
|
||||
mail.to = mail.to.substr(c + 1);
|
||||
mail.to.erase(mail.to.end() - 1);
|
||||
}
|
||||
mail.to = strdup(to);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Add a line of body text */
|
||||
void smtp_add_body_line(char *line)
|
||||
{
|
||||
struct smtp_body_line *body;
|
||||
|
||||
body = (struct smtp_body_line *)malloc(sizeof(struct smtp_body_line));
|
||||
|
||||
body->line = lftocrlf(line);
|
||||
body->next = NULL;
|
||||
|
||||
if (!mail.smtp_body)
|
||||
mail.smtp_body = body;
|
||||
if (mail.smtp_body_tail)
|
||||
mail.smtp_body_tail->next = body;
|
||||
mail.smtp_body_tail = body;
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Establish a connection to the SMTP server */
|
||||
int smtp_connect(char *host, unsigned short port)
|
||||
int smtp_connect(const char *host, unsigned short port)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
|
||||
if ((mail.sock = socket(AF_INET, SOCK_STREAM, 0)) == SOCKET_ERROR)
|
||||
return 0;
|
||||
|
||||
if ((addr.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE) {
|
||||
if ((addr.sin_addr.s_addr = inet_addr(host)) == INADDR_NONE)
|
||||
{
|
||||
struct hostent *hent;
|
||||
if (!(hent = gethostbyname(host)))
|
||||
return 0;
|
||||
@@ -307,7 +225,8 @@ int smtp_connect(char *host, unsigned short port)
|
||||
}
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons(port ? port : 25);
|
||||
if (connect(mail.sock, (struct sockaddr *) &addr, sizeof(struct sockaddr_in)) == SOCKET_ERROR) {
|
||||
if (connect(mail.sock, reinterpret_cast<struct sockaddr *>(&addr), sizeof(struct sockaddr_in)) == SOCKET_ERROR)
|
||||
{
|
||||
ano_sockclose(mail.sock);
|
||||
return 0;
|
||||
}
|
||||
@@ -349,14 +268,14 @@ int smtp_read(char *buf, int len)
|
||||
/*************************************************************************/
|
||||
|
||||
/* Retrieve a response code */
|
||||
int smtp_get_code(char *text)
|
||||
int smtp_get_code(const std::string &text)
|
||||
{
|
||||
char *tmp = strtok(text, " ");
|
||||
size_t tmp = text.find(' ');
|
||||
|
||||
if (!tmp)
|
||||
if (tmp == ci::string::npos)
|
||||
return 0;
|
||||
|
||||
return atol(tmp);
|
||||
return atol(text.c_str());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
@@ -365,48 +284,50 @@ int smtp_get_code(char *text)
|
||||
int smtp_send_email()
|
||||
{
|
||||
char buf[1024];
|
||||
struct smtp_header *head;
|
||||
struct smtp_body_line *body;
|
||||
int code;
|
||||
int skip_done = 0;
|
||||
if (!smtp_read(buf, 1024))
|
||||
{
|
||||
alog("SMTP: error reading buffer");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!smtp_read(buf, 1024)) {
|
||||
int code = smtp_get_code(buf);
|
||||
if (code != 220)
|
||||
{
|
||||
alog("SMTP: error expected code 220 got %d",code);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!smtp_send("HELO anope\r\n"))
|
||||
{
|
||||
alog("SMTP: error writting to socket");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!smtp_read(buf, 1024))
|
||||
{
|
||||
alog("SMTP: error reading buffer");
|
||||
return 0;
|
||||
}
|
||||
|
||||
code = smtp_get_code(buf);
|
||||
if (code != 220) {
|
||||
alog("SMTP: error expected code 220 got %d",code);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!smtp_send("HELO anope\r\n")) {
|
||||
alog("SMTP: error writting to socket");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!smtp_read(buf, 1024)) {
|
||||
alog("SMTP: error reading buffer");
|
||||
return 0;
|
||||
}
|
||||
|
||||
code = smtp_get_code(buf);
|
||||
if (code != 250) {
|
||||
if (code != 250)
|
||||
{
|
||||
alog("SMTP: error expected code 250 got %d",code);
|
||||
return 0;
|
||||
}
|
||||
|
||||
strcpy(buf, "MAIL FROM: <");
|
||||
strcat(buf, mail.from);
|
||||
strcat(buf, mail.from.c_str());
|
||||
strcat(buf, ">\r\n");
|
||||
|
||||
if (!smtp_send(buf)) {
|
||||
if (!smtp_send(buf))
|
||||
{
|
||||
alog("SMTP: error writting to socket");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!smtp_read(buf, 1024)) {
|
||||
if (!smtp_read(buf, 1024))
|
||||
{
|
||||
alog("SMTP: error reading buffer");
|
||||
return 0;
|
||||
}
|
||||
@@ -416,65 +337,75 @@ int smtp_send_email()
|
||||
return 0;
|
||||
|
||||
strcpy(buf, "RCPT TO: <");
|
||||
strcat(buf, mail.to);
|
||||
strcat(buf, mail.to.c_str());
|
||||
strcat(buf, ">\r\n");
|
||||
|
||||
if (!smtp_send(buf)) {
|
||||
if (!smtp_send(buf))
|
||||
{
|
||||
alog("SMTP: error writting to socket");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!smtp_read(buf, 1024)) {
|
||||
if (!smtp_read(buf, 1024))
|
||||
{
|
||||
alog("SMTP: error reading buffer");
|
||||
return 0;
|
||||
}
|
||||
|
||||
code = smtp_get_code(buf);
|
||||
if (smtp_get_code(buf) != 250) {
|
||||
if (smtp_get_code(buf) != 250)
|
||||
{
|
||||
alog("SMTP: error expected code 250 got %d",code);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!smtp_send("DATA\r\n")) {
|
||||
if (!smtp_send("DATA\r\n"))
|
||||
{
|
||||
alog("SMTP: error writting to socket");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!smtp_read(buf, 1024)) {
|
||||
if (!smtp_read(buf, 1024))
|
||||
{
|
||||
alog("SMTP: error reading buffer");
|
||||
return 0;
|
||||
}
|
||||
|
||||
code = smtp_get_code(buf);
|
||||
if (code != 354) {
|
||||
if (code != 354)
|
||||
{
|
||||
alog("SMTP: error expected code 354 got %d",code);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (head = mail.smtp_headers; head; head = head->next) {
|
||||
if (!smtp_send(head->header)) {
|
||||
for (std::vector<ci::string>::const_iterator it = mail.smtp_headers.begin(), it_end = mail.smtp_headers.end(); it != it_end; ++it)
|
||||
if (!smtp_send(it->c_str()))
|
||||
{
|
||||
alog("SMTP: error writting to socket");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!smtp_send("\r\n")) {
|
||||
if (!smtp_send("\r\n"))
|
||||
{
|
||||
alog("SMTP: error writting to socket");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (body = mail.smtp_body; body; body = body->next) {
|
||||
if (skip_done) {
|
||||
if (!smtp_send(body->line)) {
|
||||
bool skip_done = false;
|
||||
for (std::vector<ci::string>::const_iterator it = mail.smtp_body.begin(), it_end = mail.smtp_body.end(); it != it_end; ++it)
|
||||
if (skip_done)
|
||||
{
|
||||
if (!smtp_send(it->c_str()))
|
||||
{
|
||||
alog("SMTP: error writting to socket");
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
skip_done = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
skip_done = true;
|
||||
|
||||
if (!smtp_send("\r\n.\r\n")) {
|
||||
if (!smtp_send("\r\n.\r\n"))
|
||||
{
|
||||
alog("SMTP: error writting to socket");
|
||||
return 0;
|
||||
}
|
||||
@@ -494,111 +425,97 @@ void smtp_disconnect()
|
||||
|
||||
void mail_cleanup()
|
||||
{
|
||||
struct smtp_header *headers, *nexth;
|
||||
struct smtp_body_line *body, *nextb;
|
||||
|
||||
if (mail.from)
|
||||
free(mail.from);
|
||||
if (mail.to)
|
||||
free(mail.to);
|
||||
|
||||
headers = mail.smtp_headers;
|
||||
while (headers) {
|
||||
nexth = headers->next;
|
||||
free(headers->header);
|
||||
free(headers);
|
||||
headers = nexth;
|
||||
}
|
||||
|
||||
body = mail.smtp_body;
|
||||
while (body) {
|
||||
nextb = body->next;
|
||||
free(body->line);
|
||||
free(body);
|
||||
body = nextb;
|
||||
}
|
||||
mail.from.clear();
|
||||
mail.to.clear();
|
||||
|
||||
mail.smtp_headers.clear();
|
||||
|
||||
mail.smtp_body.clear();
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char buf[8192];
|
||||
/* These are somehow unused - why are they here? -GD
|
||||
|
||||
struct smtp_body_line *b;
|
||||
struct smtp_header *h;
|
||||
*/
|
||||
int headers_done = 0;
|
||||
/* Win32 stuff */
|
||||
/* Win32 stuff */
|
||||
#ifdef _WIN32
|
||||
WSADATA wsa;
|
||||
#endif
|
||||
char *server, *aport;
|
||||
short port;
|
||||
|
||||
if (argc == 1)
|
||||
return 0;
|
||||
|
||||
server = strtok(argv[1], ":");
|
||||
if ((aport = strtok(NULL, ""))) {
|
||||
char *server = strtok(argv[1], ":"), *aport;
|
||||
short port;
|
||||
if ((aport = strtok(NULL, "")))
|
||||
port = atoi(aport);
|
||||
} else {
|
||||
else
|
||||
port = 25;
|
||||
}
|
||||
|
||||
if (!server) {
|
||||
if (!server)
|
||||
{
|
||||
alog("No Server");
|
||||
/* Bad, bad, bad. This was a eturn from main with no value! -GD */
|
||||
/* Bad, bad, bad. This was a return from main with no value! -GD */
|
||||
return 0;
|
||||
} else {
|
||||
alog("SMTP: server %s port %d",server,port);
|
||||
}
|
||||
else
|
||||
alog("SMTP: server %s port %d",server,port);
|
||||
|
||||
memset(&mail, 0, sizeof(mail));
|
||||
|
||||
/* The WSAStartup function initiates use of WS2_32.DLL by a process. */
|
||||
/* guessing we can skip it under *nix */
|
||||
/* The WSAStartup function initiates use of WS2_32.DLL by a process. */
|
||||
/* guessing we can skip it under *nix */
|
||||
#ifdef _WIN32
|
||||
if (WSAStartup(MAKEWORD(1, 1), &wsa) != 0)
|
||||
if (WSAStartup(MAKEWORD(1, 1), &wsa))
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
char buf[8192];
|
||||
bool headers_done = false;
|
||||
/* Read the message and parse it */
|
||||
while (fgets(buf, 8192, stdin)) {
|
||||
if (smtp_is_header(buf) && !headers_done) {
|
||||
char *header, *value;
|
||||
smtp_add_header(buf);
|
||||
smtp_parse_header(buf, &header, &value);
|
||||
if (!strcasecmp(header, "from")) {
|
||||
alog("SMTP: from: %s",value);
|
||||
smtp_set_from(value);
|
||||
} else if (!strcasecmp(header, "to")) {
|
||||
alog("SMTP: to: %s",value);
|
||||
smtp_set_to(value);
|
||||
} else if (smtp_is_end(buf)) {
|
||||
break;
|
||||
} else {
|
||||
headers_done = 1;
|
||||
smtp_add_body_line(buf);
|
||||
while (fgets(buf, 8192, stdin))
|
||||
{
|
||||
if (smtp_is_header(buf) && !headers_done)
|
||||
{
|
||||
mail.smtp_headers.push_back(strip(buf) + "\r\n");
|
||||
ci::string header, value;
|
||||
smtp_parse_header(buf, header, value);
|
||||
if (header == "from")
|
||||
{
|
||||
alog("SMTP: from: %s", value.c_str());
|
||||
mail.from = value;
|
||||
}
|
||||
else if (header == "to")
|
||||
{
|
||||
alog("SMTP: to: %s", value.c_str());
|
||||
smtp_set_to(value);
|
||||
}
|
||||
else if (smtp_is_end(buf))
|
||||
break;
|
||||
else
|
||||
{
|
||||
headers_done = true;
|
||||
mail.smtp_body.push_back(strip(buf) + "\r\n");
|
||||
}
|
||||
} else {
|
||||
smtp_add_body_line(buf);
|
||||
}
|
||||
else
|
||||
mail.smtp_body.push_back(strip(buf) + "\r\n");
|
||||
}
|
||||
|
||||
if (!smtp_connect(server, port)) {
|
||||
alog("SMTP: failed to connect to %s:%d",server, port);
|
||||
if (!smtp_connect(server, port))
|
||||
{
|
||||
alog("SMTP: failed to connect to %s:%d", server, port);
|
||||
mail_cleanup();
|
||||
return 0;
|
||||
}
|
||||
if (!smtp_send_email()) {
|
||||
if (!smtp_send_email())
|
||||
{
|
||||
alog("SMTP: error during sending of mail");
|
||||
mail_cleanup();
|
||||
return 0;
|
||||
}
|
||||
smtp_disconnect();
|
||||
mail_cleanup();
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ static std::string GetLevelName(int level)
|
||||
return "NOJOIN";
|
||||
case 11:
|
||||
return "CHANGE";
|
||||
case 12:
|
||||
case 12:
|
||||
return "MEMO";
|
||||
case 13:
|
||||
return "ASSIGN";
|
||||
@@ -60,7 +60,7 @@ static std::string GetLevelName(int level)
|
||||
return "GREET";
|
||||
case 19:
|
||||
return "VOICEME";
|
||||
case 20:
|
||||
case 20:
|
||||
return "VOICE";
|
||||
case 21:
|
||||
return "GETKEY";
|
||||
@@ -76,9 +76,9 @@ static std::string GetLevelName(int level)
|
||||
return "HALFOP";
|
||||
case 27:
|
||||
return "PROTECTME";
|
||||
case 28:
|
||||
case 28:
|
||||
return "PROTECT";
|
||||
case 29:
|
||||
case 29:
|
||||
return "KICKME";
|
||||
case 30:
|
||||
return "KICK";
|
||||
@@ -100,57 +100,57 @@ static std::string GetLevelName(int level)
|
||||
void process_mlock_modes(std::ofstream &fs, size_t m, const std::string &ircd)
|
||||
{
|
||||
/* this is the same in all protocol modules */
|
||||
if (m & 0x1) fs << " CMODE_INVITE"; // CMODE_i
|
||||
if (m & 0x2) fs << " CMODE_MODERATED"; // CMODE_m
|
||||
if (m & 0x4) fs << " CMODE_NOEXTERNAL"; // CMODE_n
|
||||
if (m & 0x8) fs << " CMODE_PRIVATE"; // CMODE_p
|
||||
if (m & 0x10) fs << " CMODE_SECRET"; // CMODE_s
|
||||
if (m & 0x20) fs << " CMODE_TOPIC"; // CMODE_t
|
||||
if (m & 0x40) fs << " CMODE_KEY"; // CMODE_k
|
||||
if (m & 0x80) fs << " CMODE_LIMIT"; // CMODE_l
|
||||
if (m & 0x200) fs << " CMODE_REGISTERED"; // CMODE_r
|
||||
if (m & 0x1) fs << " CMODE_INVITE"; // CMODE_i
|
||||
if (m & 0x2) fs << " CMODE_MODERATED"; // CMODE_m
|
||||
if (m & 0x4) fs << " CMODE_NOEXTERNAL"; // CMODE_n
|
||||
if (m & 0x8) fs << " CMODE_PRIVATE"; // CMODE_p
|
||||
if (m & 0x10) fs << " CMODE_SECRET"; // CMODE_s
|
||||
if (m & 0x20) fs << " CMODE_TOPIC"; // CMODE_t
|
||||
if (m & 0x40) fs << " CMODE_KEY"; // CMODE_k
|
||||
if (m & 0x80) fs << " CMODE_LIMIT"; // CMODE_l
|
||||
if (m & 0x200) fs << " CMODE_REGISTERED"; // CMODE_r
|
||||
|
||||
if (ircd == "unreal" || ircd == "inspircd")
|
||||
{
|
||||
if (m & 0x100) fs << " CMODE_REGISTEREDONLY"; // CMODE_R
|
||||
if (m & 0x400) fs << " CMODE_BLOCKCOLOR"; // CMODE_c
|
||||
if (m & 0x2000) fs << " CMODE_NOKNOCK"; // CMODE_K
|
||||
if (m & 0x4000) fs << " CMODE_REDIRECT"; // CMODE_L
|
||||
if (m & 0x8000) fs << " CMODE_OPERONLY"; // CMODE_O
|
||||
if (m & 0x10000) fs << " CMODE_NOKICK"; // CMODE_Q
|
||||
if (m & 0x20000) fs << " CMODE_STRIPCOLOR"; // CMODE_S
|
||||
if (m & 0x80000) fs << " CMODE_FLOOD"; // CMODE_f
|
||||
if (m & 0x100000) fs << " CMODE_FILTER"; // CMODE_G
|
||||
if (m & 0x200000) fs << " CMODE_NOCTCP"; // CMODE_C
|
||||
if (m & 0x400000) fs << " CMODE_AUDITORIUM"; // CMODE_u
|
||||
if (m & 0x800000) fs << " CMODE_SSL"; // CMODE_z
|
||||
if (m & 0x1000000) fs << " CMODE_NONICK"; // CMODE_N
|
||||
if (m & 0x4000000) fs << " CMODE_REGMODERATED"; // CMODE_M
|
||||
if (m & 0x100) fs << " CMODE_REGISTEREDONLY"; // CMODE_R
|
||||
if (m & 0x400) fs << " CMODE_BLOCKCOLOR"; // CMODE_c
|
||||
if (m & 0x2000) fs << " CMODE_NOKNOCK"; // CMODE_K
|
||||
if (m & 0x4000) fs << " CMODE_REDIRECT"; // CMODE_L
|
||||
if (m & 0x8000) fs << " CMODE_OPERONLY"; // CMODE_O
|
||||
if (m & 0x10000) fs << " CMODE_NOKICK"; // CMODE_Q
|
||||
if (m & 0x20000) fs << " CMODE_STRIPCOLOR"; // CMODE_S
|
||||
if (m & 0x80000) fs << " CMODE_FLOOD"; // CMODE_f
|
||||
if (m & 0x100000) fs << " CMODE_FILTER"; // CMODE_G
|
||||
if (m & 0x200000) fs << " CMODE_NOCTCP"; // CMODE_C
|
||||
if (m & 0x400000) fs << " CMODE_AUDITORIUM"; // CMODE_u
|
||||
if (m & 0x800000) fs << " CMODE_SSL"; // CMODE_z
|
||||
if (m & 0x1000000) fs << " CMODE_NONICK"; // CMODE_N
|
||||
if (m & 0x4000000) fs << " CMODE_REGMODERATED"; // CMODE_M
|
||||
}
|
||||
|
||||
if (ircd == "unreal")
|
||||
{
|
||||
if (m & 0x800) fs << " CMODE_ADMINONLY"; // CMODE_A
|
||||
if (m & 0x40000) fs << " CMODE_NOINVITE"; // CMODE_f
|
||||
if (m & 0x2000000) fs << " CMODE_NONOTICE"; // CMODE_T
|
||||
if (m & 0x8000000) fs << " CMODE_JOINFLOOD"; // CMODE_j
|
||||
} // if (unreal)
|
||||
if (m & 0x800) fs << " CMODE_ADMINONLY"; // CMODE_A
|
||||
if (m & 0x40000) fs << " CMODE_NOINVITE"; // CMODE_f
|
||||
if (m & 0x2000000) fs << " CMODE_NONOTICE"; // CMODE_T
|
||||
if (m & 0x8000000) fs << " CMODE_JOINFLOOD"; // CMODE_j
|
||||
}
|
||||
if (ircd == "inspircd" )
|
||||
{
|
||||
if (m & 0x800) fs << " CMODE_ALLINVITE"; // CMODE_A
|
||||
if (m & 0x1000) fs << " CMODE_NONOTICE"; // CMODE_T
|
||||
if (m & 0x800) fs << " CMODE_ALLINVITE"; // CMODE_A
|
||||
if (m & 0x1000) fs << " CMODE_NONOTICE"; // CMODE_T
|
||||
/* for some reason, there is no CMODE_P in 1.8.x and no CMODE_V in the 1.9.1 protocol module
|
||||
we are ignoring this flag until we find a solution for this problem,
|
||||
so the +V/+P mlock mode is lost on convert
|
||||
anope 1.8: if (m & 0x40000) fs << " NOINVITE"; // CMODE_V
|
||||
anope 1.9: if (m & 0x40000) fs << " PERM"; // CMODE_P
|
||||
we are ignoring this flag until we find a solution for this problem,
|
||||
so the +V/+P mlock mode is lost on convert
|
||||
anope 1.8: if (m & 0x40000) fs << " NOINVITE"; // CMODE_V
|
||||
anope 1.9: if (m & 0x40000) fs << " PERM"; // CMODE_P
|
||||
*/
|
||||
if (m & 0x2000000) fs << " CMODE_JOINFLOOD"; // CMODE_j
|
||||
if (m & 0x8000000) fs << " CMODE_BLOCKCAPS"; // CMODE_B
|
||||
if (m & 0x10000000) fs << " CMODE_NICKFLOOD"; // CMODE_F
|
||||
//if (m & 0x20000000) fs << ""; // CMODE_g (mode +g <badword>) ... can't be mlocked in older version
|
||||
//if (m & 0x40000000) fs << ""; // CMODE_J (mode +J [seconds] ... can't be mlocked in older versions
|
||||
} // if (inspircd)
|
||||
if (m & 0x2000000) fs << " CMODE_JOINFLOOD"; // CMODE_j
|
||||
if (m & 0x8000000) fs << " CMODE_BLOCKCAPS"; // CMODE_B
|
||||
if (m & 0x10000000) fs << " CMODE_NICKFLOOD"; // CMODE_F
|
||||
//if (m & 0x20000000) fs << ""; // CMODE_g (mode +g <badword>) ... can't be mlocked in older version
|
||||
//if (m & 0x40000000) fs << ""; // CMODE_J (mode +J [seconds] ... can't be mlocked in older versions
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -168,11 +168,8 @@ int main(int argc, char *argv[])
|
||||
std::cout << "Which hash method did you use? (md5, sha1, oldmd5, plain)" << std::endl << "? ";
|
||||
std::cin >> hashm;
|
||||
}
|
||||
|
||||
while (ircd != "bahamut" && ircd != "charybdis" && ircd != "dreamforge" && ircd != "hybrid"
|
||||
&& ircd != "inspircd" && ircd != "plexus2" && ircd != "plexus3" && ircd != "ptlink"
|
||||
&& ircd != "rageircd" && ircd != "ratbox" && ircd != "shadowircd" && ircd != "solidircd"
|
||||
&& ircd != "ultimate2" && ircd != "ultimate3" && ircd != "unreal" && ircd != "viagra")
|
||||
|
||||
while (ircd != "bahamut" && ircd != "charybdis" && ircd != "dreamforge" && ircd != "hybrid" && ircd != "inspircd" && ircd != "plexus2" && ircd != "plexus3" && ircd != "ptlink" && ircd != "rageircd" && ircd != "ratbox" && ircd != "shadowircd" && ircd != "solidircd" && ircd != "ultimate2" && ircd != "ultimate3" && ircd != "unreal" && ircd != "viagra")
|
||||
{
|
||||
if (!ircd.empty())
|
||||
std::cout << "Select a valid option!" << std::endl;
|
||||
@@ -184,6 +181,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
std::cout << "You selected " << hashm << std::endl;
|
||||
|
||||
fs.clear();
|
||||
fs.open("anope.db");
|
||||
if (!fs.is_open())
|
||||
{
|
||||
@@ -198,7 +196,6 @@ int main(int argc, char *argv[])
|
||||
/* Ia: First database */
|
||||
if ((f = open_db_read("NickServ", "nick.db", 14)))
|
||||
{
|
||||
|
||||
NickAlias *na, **nalast, *naprev;
|
||||
NickCore *nc, **nclast, *ncprev;
|
||||
int16 tmp16;
|
||||
@@ -208,17 +205,20 @@ int main(int argc, char *argv[])
|
||||
printf("Trying to merge nicks...\n");
|
||||
|
||||
/* Nick cores */
|
||||
for (i = 0; i < 1024; i++) {
|
||||
for (i = 0; i < 1024; ++i)
|
||||
{
|
||||
nclast = &nclists[i];
|
||||
ncprev = NULL;
|
||||
|
||||
while ((c = getc_db(f)) == 1) {
|
||||
if (c != 1) {
|
||||
while ((c = getc_db(f)) == 1)
|
||||
{
|
||||
if (c != 1)
|
||||
{
|
||||
printf("Invalid format in nickserv db.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
nc = (NickCore *)calloc(1, sizeof(NickCore));
|
||||
nc = new NickCore;
|
||||
nc->aliascount = 0;
|
||||
nc->unused = 0;
|
||||
|
||||
@@ -236,20 +236,21 @@ int main(int argc, char *argv[])
|
||||
READ(read_uint32(&nc->flags, f));
|
||||
READ(read_uint16(&nc->language, f));
|
||||
READ(read_uint16(&nc->accesscount, f));
|
||||
if (nc->accesscount) {
|
||||
char **access;
|
||||
access = (char **)calloc(sizeof(char *) * nc->accesscount, 1);
|
||||
if (nc->accesscount)
|
||||
{
|
||||
char **access = new char *[nc->accesscount + 1];
|
||||
nc->access = access;
|
||||
for (j = 0; j < nc->accesscount; j++, access++)
|
||||
for (j = 0; j < nc->accesscount; ++j, ++access)
|
||||
READ(read_string(access, f));
|
||||
}
|
||||
READ(read_int16(&nc->memos.memocount, f));
|
||||
READ(read_int16(&nc->memos.memomax, f));
|
||||
if (nc->memos.memocount) {
|
||||
Memo *memos;
|
||||
memos = (Memo *)calloc(sizeof(Memo) * nc->memos.memocount, 1);
|
||||
if (nc->memos.memocount)
|
||||
{
|
||||
Memo *memos = new Memo[nc->memos.memocount];
|
||||
nc->memos.memos = memos;
|
||||
for (j = 0; j < nc->memos.memocount; j++, memos++) {
|
||||
for (j = 0; j < nc->memos.memocount; ++j, ++memos)
|
||||
{
|
||||
READ(read_uint32(&memos->number, f));
|
||||
READ(read_uint16(&memos->flags, f));
|
||||
READ(read_int32(&tmp32, f));
|
||||
@@ -265,19 +266,22 @@ int main(int argc, char *argv[])
|
||||
} /* for() loop */
|
||||
|
||||
/* Nick aliases */
|
||||
for (i = 0; i < 1024; i++) {
|
||||
for (i = 0; i < 1024; ++i)
|
||||
{
|
||||
char *s = NULL;
|
||||
|
||||
nalast = &nalists[i];
|
||||
naprev = NULL;
|
||||
|
||||
while ((c = getc_db(f)) == 1) {
|
||||
if (c != 1) {
|
||||
while ((c = getc_db(f)) == 1)
|
||||
{
|
||||
if (c != 1)
|
||||
{
|
||||
printf("Invalid format in nick db.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
na = (NickAlias *)calloc(1, sizeof(NickAlias));
|
||||
na = new NickAlias;
|
||||
|
||||
READ(read_string(&na->nick, f));
|
||||
READ(read_string(&na->last_usermask, f));
|
||||
@@ -291,8 +295,9 @@ int main(int argc, char *argv[])
|
||||
READ(read_uint16(&na->status, f));
|
||||
READ(read_string(&s, f));
|
||||
na->nc = findcore(s, 0);
|
||||
na->nc->aliascount++;
|
||||
free(s);
|
||||
++na->nc->aliascount;
|
||||
//free(s);
|
||||
delete [] s;
|
||||
|
||||
*nalast = na;
|
||||
nalast = &na->next;
|
||||
@@ -306,11 +311,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* CLEAN THE CORES */
|
||||
int i;
|
||||
for (i = 0; i < 1024; i++) {
|
||||
for (i = 0; i < 1024; ++i)
|
||||
{
|
||||
NickCore *ncnext;
|
||||
for (NickCore *nc = nclists[i]; nc; nc = ncnext) {
|
||||
for (NickCore *nc = nclists[i]; nc; nc = ncnext)
|
||||
{
|
||||
ncnext = nc->next;
|
||||
if (nc->aliascount < 1) {
|
||||
if (nc->aliascount < 1)
|
||||
{
|
||||
printf("Deleting core %s (%s).\n", nc->display, nc->email);
|
||||
delcore(nc);
|
||||
}
|
||||
@@ -325,7 +333,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
while ((c = getc_db(f)) == 1)
|
||||
{
|
||||
hc = (HostCore *)calloc(1, sizeof(HostCore));
|
||||
hc = new HostCore;
|
||||
READ(read_string(&hc->nick, f));
|
||||
READ(read_string(&hc->vIdent, f));
|
||||
READ(read_string(&hc->vHost, f));
|
||||
@@ -340,7 +348,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Nick cores */
|
||||
for (i = 0; i < 1024; i++)
|
||||
for (i = 0; i < 1024; ++i)
|
||||
{
|
||||
NickAlias *na;
|
||||
NickCore *nc;
|
||||
@@ -371,10 +379,10 @@ int main(int argc, char *argv[])
|
||||
len = 20;
|
||||
else if (hashm == "oldmd5")
|
||||
len = 16;
|
||||
else
|
||||
else
|
||||
len = 32;
|
||||
|
||||
b64_encode(nc->pass, len, (char *)cpass, 5000);
|
||||
|
||||
b64_encode(nc->pass, len, cpass, 5000);
|
||||
|
||||
fs << "NC " << nc->display << " " << hashm << ":" << cpass;
|
||||
fs << " " << GetLanguageID(nc->language) << " " << nc->memos.memomax << " " << nc->channelcount << std::endl;
|
||||
@@ -390,34 +398,32 @@ int main(int argc, char *argv[])
|
||||
fs << "MD URL :" << nc->url << std::endl;
|
||||
|
||||
if (nc->accesscount)
|
||||
{
|
||||
for (j = 0, access = nc->access; j < nc->accesscount && *access; j++, access++)
|
||||
for (j = 0, access = nc->access; j < nc->accesscount && *access; ++j, ++access)
|
||||
fs << "MD ACCESS " << *access << std::endl;
|
||||
}
|
||||
|
||||
fs << "MD FLAGS "
|
||||
<< ((nc->flags & NI_KILLPROTECT ) ? "KILLPROTECT " : "")
|
||||
<< ((nc->flags & NI_SECURE ) ? "SECURE " : "")
|
||||
<< ((nc->flags & NI_MSG ) ? "MSG " : "")
|
||||
<< ((nc->flags & NI_MEMO_HARDMAX ) ? "MEMO_HARDMAX " : "")
|
||||
<< ((nc->flags & NI_MEMO_SIGNON ) ? "MEMO_SIGNON " : "")
|
||||
<< ((nc->flags & NI_MEMO_RECEIVE ) ? "MEMO_RECEIVE " : "")
|
||||
<< ((nc->flags & NI_PRIVATE ) ? "PRIVATE " : "")
|
||||
<< ((nc->flags & NI_HIDE_EMAIL ) ? "HIDE_EMAIL " : "")
|
||||
<< ((nc->flags & NI_HIDE_MASK ) ? "HIDE_MASK " : "")
|
||||
<< ((nc->flags & NI_HIDE_QUIT ) ? "HIDE_QUIT " : "")
|
||||
<< ((nc->flags & NI_KILL_QUICK ) ? "KILL_QUICK " : "")
|
||||
<< ((nc->flags & NI_KILL_IMMED ) ? "KILL_IMMED " : "")
|
||||
<< ((nc->flags & NI_MEMO_MAIL ) ? "MEMO_MAIL " : "")
|
||||
<< ((nc->flags & NI_HIDE_STATUS ) ? "HIDE_STATUS " : "")
|
||||
<< ((nc->flags & NI_SUSPENDED ) ? "SUSPENDED " : "")
|
||||
// in 1.8, the AUTOOP flag was set to disable AUTOOP. Now we enable it. --DP
|
||||
<< (!(nc->flags & NI_AUTOOP ) ? "AUTOOP " : "")
|
||||
<< ((nc->flags & NI_FORBIDDEN ) ? "FORBIDDEN " : "") << std::endl;
|
||||
<< (nc->flags & NI_KILLPROTECT ? "KILLPROTECT " : "")
|
||||
<< (nc->flags & NI_SECURE ? "SECURE " : "")
|
||||
<< (nc->flags & NI_MSG ? "MSG " : "")
|
||||
<< (nc->flags & NI_MEMO_HARDMAX ? "MEMO_HARDMAX " : "")
|
||||
<< (nc->flags & NI_MEMO_SIGNON ? "MEMO_SIGNON " : "")
|
||||
<< (nc->flags & NI_MEMO_RECEIVE ? "MEMO_RECEIVE " : "")
|
||||
<< (nc->flags & NI_PRIVATE ? "PRIVATE " : "")
|
||||
<< (nc->flags & NI_HIDE_EMAIL ? "HIDE_EMAIL " : "")
|
||||
<< (nc->flags & NI_HIDE_MASK ? "HIDE_MASK " : "")
|
||||
<< (nc->flags & NI_HIDE_QUIT ? "HIDE_QUIT " : "")
|
||||
<< (nc->flags & NI_KILL_QUICK ? "KILL_QUICK " : "")
|
||||
<< (nc->flags & NI_KILL_IMMED ? "KILL_IMMED " : "")
|
||||
<< (nc->flags & NI_MEMO_MAIL ? "MEMO_MAIL " : "")
|
||||
<< (nc->flags & NI_HIDE_STATUS ? "HIDE_STATUS " : "")
|
||||
<< (nc->flags & NI_SUSPENDED ? "SUSPENDED " : "")
|
||||
// in 1.8, the AUTOOP flag was set to disable AUTOOP. Now we enable it. --DP
|
||||
<< (!(nc->flags & NI_AUTOOP) ? "AUTOOP " : "")
|
||||
<< (nc->flags & NI_FORBIDDEN ? "FORBIDDEN " : "") << std::endl;
|
||||
if (nc->memos.memocount)
|
||||
{
|
||||
memos = nc->memos.memos;
|
||||
for (j = 0; j < nc->memos.memocount; j++, memos++)
|
||||
for (j = 0; j < nc->memos.memocount; ++j, ++memos)
|
||||
{
|
||||
if (!memos->text)
|
||||
break;
|
||||
@@ -433,7 +439,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* we could do this in a seperate loop, I'm doing it here for tidiness. */
|
||||
for (int tmp = 0; tmp < 1024; tmp++)
|
||||
for (int tmp = 0; tmp < 1024; ++tmp)
|
||||
{
|
||||
for (na = nalists[tmp]; na; na = na->next)
|
||||
{
|
||||
@@ -455,27 +461,21 @@ int main(int argc, char *argv[])
|
||||
fs << "MD LAST_REALNAME :" << na->last_realname << std::endl;
|
||||
if (na->last_quit)
|
||||
fs << "MD LAST_QUIT :" << na->last_quit << std::endl;
|
||||
if ((na->status & NS_FORBIDDEN) || (na->status & NS_NO_EXPIRE))
|
||||
{
|
||||
fs << "MD FLAGS"
|
||||
<< ((na->status & NS_FORBIDDEN) ? " FORBIDDEN" : "")
|
||||
<< ((na->status & NS_NO_EXPIRE) ? " NOEXPIRE" : "") << std::endl;
|
||||
}
|
||||
if ((na->status & NS_FORBIDDEN) || (na->status & NS_NO_EXPIRE))
|
||||
fs << "MD FLAGS" << (na->status & NS_FORBIDDEN ? " FORBIDDEN" : "") << (na->status & NS_NO_EXPIRE ? " NOEXPIRE" : "") << std::endl;
|
||||
|
||||
HostCore *hc = findHostCore(na->nick);
|
||||
if (hc)
|
||||
{
|
||||
fs << "MD VHOST " << hc->creator << " " << hc->time << " " << hc->vHost << " :" << (hc->vIdent ? hc->vIdent : "") << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Section II: Bots */
|
||||
/* IIa: First database */
|
||||
if ((f = open_db_read("Botserv", "bot.db", 10))) {
|
||||
if ((f = open_db_read("Botserv", "bot.db", 10)))
|
||||
{
|
||||
std::string input;
|
||||
int c, broken = 0;
|
||||
int32 created;
|
||||
@@ -523,7 +523,8 @@ int main(int argc, char *argv[])
|
||||
fs << "MD FLAGS GLOBAL" << std::endl;
|
||||
}
|
||||
|
||||
while ((c = getc_db(f)) == 1) {
|
||||
while ((c = getc_db(f)) == 1)
|
||||
{
|
||||
READ(read_string(&nick, f));
|
||||
READ(read_string(&user, f));
|
||||
READ(read_string(&host, f));
|
||||
@@ -532,39 +533,39 @@ int main(int argc, char *argv[])
|
||||
READ(read_int32(&created, f));
|
||||
READ(read_int16(&chancount, f));
|
||||
|
||||
if (created == 0)
|
||||
if (!created)
|
||||
created = time(NULL); // Unfortunatley, we forgot to store the created bot time in 1.9.1+
|
||||
|
||||
/* fix for the 1.9.0 broken bot.db */
|
||||
if (broken)
|
||||
{
|
||||
flags = 0;
|
||||
if (!stricmp(nick, "ChanServ"))
|
||||
if (!mystricmp(nick, "ChanServ"))
|
||||
flags |= BI_CHANSERV;
|
||||
if (!stricmp(nick, "BotServ"))
|
||||
if (!mystricmp(nick, "BotServ"))
|
||||
flags |= BI_BOTSERV;
|
||||
if (!stricmp(nick, "HostServ"))
|
||||
if (!mystricmp(nick, "HostServ"))
|
||||
flags |= BI_HOSTSERV;
|
||||
if (!stricmp(nick, "OperServ"))
|
||||
if (!mystricmp(nick, "OperServ"))
|
||||
flags |= BI_OPERSERV;
|
||||
if (!stricmp(nick, "MemoServ"))
|
||||
if (!mystricmp(nick, "MemoServ"))
|
||||
flags |= BI_MEMOSERV;
|
||||
if (!stricmp(nick, "NickServ"))
|
||||
if (!mystricmp(nick, "NickServ"))
|
||||
flags |= BI_NICKSERV;
|
||||
if (!stricmp(nick, "Global"))
|
||||
if (!mystricmp(nick, "Global"))
|
||||
flags |= BI_GLOBAL;
|
||||
} /* end of 1.9.0 broken database fix */
|
||||
std::cout << "Writing Bot " << nick << "!" << user << "@" << host << std::endl;
|
||||
fs << "BI " << nick << " " << user << " " << host << " " << created << " " << chancount << " :" << real << std::endl;
|
||||
fs << "MD FLAGS"
|
||||
<< (( flags & BI_PRIVATE ) ? " PRIVATE" : "" )
|
||||
<< (( flags & BI_CHANSERV ) ? " CHANSERV" : "" )
|
||||
<< (( flags & BI_BOTSERV ) ? " BOTSERV" : "" )
|
||||
<< (( flags & BI_HOSTSERV ) ? " HOSTSERV" : "" )
|
||||
<< (( flags & BI_OPERSERV ) ? " OPERSERV" : "" )
|
||||
<< (( flags & BI_MEMOSERV ) ? " MEMOSERV" : "" )
|
||||
<< (( flags & BI_NICKSERV ) ? " NICKSERV" : "" )
|
||||
<< (( flags & BI_GLOBAL ) ? " GLOBAL" : "" ) << std::endl;
|
||||
<< (flags & BI_PRIVATE ? " PRIVATE" : "")
|
||||
<< (flags & BI_CHANSERV ? " CHANSERV" : "")
|
||||
<< (flags & BI_BOTSERV ? " BOTSERV" : "")
|
||||
<< (flags & BI_HOSTSERV ? " HOSTSERV" : "")
|
||||
<< (flags & BI_OPERSERV ? " OPERSERV" : "")
|
||||
<< (flags & BI_MEMOSERV ? " MEMOSERV" : "")
|
||||
<< (flags & BI_NICKSERV ? " NICKSERV" : "")
|
||||
<< (flags & BI_GLOBAL ? " GLOBAL" : "") << std::endl;
|
||||
}
|
||||
close_db(f);
|
||||
}
|
||||
@@ -578,7 +579,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
printf("Trying to merge channels...\n");
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
for (i = 0; i < 256; ++i)
|
||||
{
|
||||
int16 tmp16;
|
||||
int32 tmp32;
|
||||
@@ -599,7 +600,7 @@ int main(int argc, char *argv[])
|
||||
exit(0);
|
||||
}
|
||||
|
||||
ci = (ChannelInfo *)calloc(sizeof(ChannelInfo), 1);
|
||||
ci = new ChannelInfo;
|
||||
*last = ci;
|
||||
last = &ci->next;
|
||||
ci->prev = prev;
|
||||
@@ -631,8 +632,8 @@ int main(int argc, char *argv[])
|
||||
ci->bantype = tmp16;
|
||||
READ(read_int16(&tmp16, f));
|
||||
n_levels = tmp16;
|
||||
ci->levels = (int16 *)calloc(36 * sizeof(*ci->levels), 1);
|
||||
for (j = 0; j < n_levels; j++)
|
||||
ci->levels = new int16[36];
|
||||
for (j = 0; j < n_levels; ++j)
|
||||
{
|
||||
if (j < 36)
|
||||
READ(read_int16(&ci->levels[j], f));
|
||||
@@ -642,8 +643,8 @@ int main(int argc, char *argv[])
|
||||
READ(read_uint16(&ci->accesscount, f));
|
||||
if (ci->accesscount)
|
||||
{
|
||||
ci->access = (ChanAccess *)calloc(ci->accesscount, sizeof(ChanAccess));
|
||||
for (j = 0; j < ci->accesscount; j++)
|
||||
ci->access = new ChanAccess[ci->accesscount];
|
||||
for (j = 0; j < ci->accesscount; ++j)
|
||||
{
|
||||
READ(read_uint16(&ci->access[j].in_use, f));
|
||||
if (ci->access[j].in_use)
|
||||
@@ -653,7 +654,7 @@ int main(int argc, char *argv[])
|
||||
if (s)
|
||||
{
|
||||
ci->access[j].nc = findcore(s, 0);
|
||||
free(s);
|
||||
delete [] s;
|
||||
}
|
||||
if (ci->access[j].nc == NULL)
|
||||
ci->access[j].in_use = 0;
|
||||
@@ -663,14 +664,12 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ci->access = NULL;
|
||||
}
|
||||
READ(read_uint16(&ci->akickcount, f));
|
||||
if (ci->akickcount)
|
||||
{
|
||||
ci->akick = (AutoKick *)calloc(ci->akickcount, sizeof(AutoKick));
|
||||
for (j = 0; j < ci->akickcount; j++)
|
||||
ci->akick = new AutoKick[ci->akickcount];
|
||||
for (j = 0; j < ci->akickcount; ++j)
|
||||
{
|
||||
SAFE(read_uint16(&ci->akick[j].flags, f));
|
||||
if (ci->akick[j].flags & 0x0001)
|
||||
@@ -681,26 +680,20 @@ int main(int argc, char *argv[])
|
||||
ci->akick[j].u.nc = findcore(s, 0);
|
||||
if (!ci->akick[j].u.nc)
|
||||
ci->akick[j].flags &= ~0x0001;
|
||||
free(s);
|
||||
delete [] s;
|
||||
}
|
||||
else
|
||||
{
|
||||
ci->akick[j].u.mask = s;
|
||||
}
|
||||
SAFE(read_string(&s, f));
|
||||
if (ci->akick[j].flags & 0x0001)
|
||||
ci->akick[j].reason = s;
|
||||
else if (s)
|
||||
free(s);
|
||||
delete [] s;
|
||||
SAFE(read_string(&s, f));
|
||||
if (ci->akick[j].flags & 0x0001)
|
||||
{
|
||||
ci->akick[j].creator = s;
|
||||
}
|
||||
else if (s)
|
||||
{
|
||||
free(s);
|
||||
}
|
||||
delete [] s;
|
||||
SAFE(read_int32(&tmp32, f));
|
||||
if (ci->akick[j].flags & 0x0001)
|
||||
ci->akick[j].addtime = tmp32;
|
||||
@@ -708,9 +701,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ci->akick = NULL;
|
||||
}
|
||||
READ(read_uint32(&ci->mlock_on, f));
|
||||
READ(read_uint32(&ci->mlock_off, f));
|
||||
READ(read_uint32(&ci->mlock_limit, f));
|
||||
@@ -721,10 +712,9 @@ int main(int argc, char *argv[])
|
||||
READ(read_int16(&ci->memos.memomax, f));
|
||||
if (ci->memos.memocount)
|
||||
{
|
||||
Memo *memos;
|
||||
memos = (Memo *)calloc(sizeof(Memo) * ci->memos.memocount, 1);
|
||||
Memo *memos = new Memo[ci->memos.memocount];
|
||||
ci->memos.memos = memos;
|
||||
for (j = 0; j < ci->memos.memocount; j++, memos++)
|
||||
for (j = 0; j < ci->memos.memocount; ++j, ++memos)
|
||||
{
|
||||
READ(read_uint32(&memos->number, f));
|
||||
READ(read_uint16(&memos->flags, f));
|
||||
@@ -742,15 +732,15 @@ int main(int argc, char *argv[])
|
||||
ci->botflags = tmp32;
|
||||
READ(read_int16(&tmp16, f));
|
||||
n_ttb = tmp16;
|
||||
ci->ttb = (int16 *)calloc(2 * 8, 1);
|
||||
for (j = 0; j < n_ttb; j++)
|
||||
ci->ttb = new int16[16];
|
||||
for (j = 0; j < n_ttb; ++j)
|
||||
{
|
||||
if (j < 8)
|
||||
READ(read_int16(&ci->ttb[j], f));
|
||||
else
|
||||
READ(read_int16(&tmp16, f));
|
||||
}
|
||||
for (j = n_ttb; j < 8; j++)
|
||||
for (j = n_ttb; j < 8; ++j)
|
||||
ci->ttb[j] = 0;
|
||||
READ(read_int16(&tmp16, f));
|
||||
ci->capsmin = tmp16;
|
||||
@@ -766,8 +756,8 @@ int main(int argc, char *argv[])
|
||||
READ(read_uint16(&ci->bwcount, f));
|
||||
if (ci->bwcount)
|
||||
{
|
||||
ci->badwords = (BadWord *)calloc(ci->bwcount, sizeof(BadWord));
|
||||
for (j = 0; j < ci->bwcount; j++)
|
||||
ci->badwords = new BadWord[ci->bwcount];
|
||||
for (j = 0; j < ci->bwcount; ++j)
|
||||
{
|
||||
SAFE(read_uint16(&ci->badwords[j].in_use, f));
|
||||
if (ci->badwords[j].in_use)
|
||||
@@ -778,9 +768,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ci->badwords = NULL;
|
||||
}
|
||||
}
|
||||
*last = NULL;
|
||||
}
|
||||
@@ -790,7 +778,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
ChannelInfo *ci;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
for (i = 0; i < 256; ++i)
|
||||
{
|
||||
for (ci = chanlists[i]; ci; ci = ci->next)
|
||||
{
|
||||
@@ -803,36 +791,32 @@ int main(int argc, char *argv[])
|
||||
if (ci->successor)
|
||||
fs << "MD SUCCESSOR " << ci->successor << std::endl;
|
||||
fs << "MD LEVELS";
|
||||
for (j = 0; j < 36; j++)
|
||||
for (j = 0; j < 36; ++j)
|
||||
{
|
||||
/* In 1.8 disabled meant founder only. In 1.9.2 disabled literally means its disabled so, we will set these to ACCESS_QOP */
|
||||
if (ci->levels[j] == -10000)
|
||||
{
|
||||
fs << " " << GetLevelName(j) << " " << 10000;
|
||||
}
|
||||
else
|
||||
{
|
||||
fs << " " << GetLevelName(j) << " " << ci->levels[j];
|
||||
}
|
||||
}
|
||||
fs << std::endl;
|
||||
fs << "MD FLAGS"
|
||||
<< ((ci->flags & CI_KEEPTOPIC ) ? " KEEPTOPIC" : "")
|
||||
<< ((ci->flags & CI_SECUREOPS ) ? " SECUREOPS" : "")
|
||||
<< ((ci->flags & CI_PRIVATE ) ? " PRIVATE" : "")
|
||||
<< ((ci->flags & CI_TOPICLOCK ) ? " TOPICLOCK" : "")
|
||||
<< ((ci->flags & CI_RESTRICTED ) ? " RESTRICTED" : "")
|
||||
<< ((ci->flags & CI_PEACE ) ? " PEACE" : "")
|
||||
<< ((ci->flags & CI_SECURE ) ? " SECURE" : "")
|
||||
<< ((ci->flags & CI_FORBIDDEN ) ? " FORBIDDEN" : "")
|
||||
<< ((ci->flags & CI_NO_EXPIRE ) ? " NO_EXPIRE" : "")
|
||||
<< ((ci->flags & CI_MEMO_HARDMAX ) ? " MEMO_HARDMAX" : "")
|
||||
<< ((ci->flags & CI_OPNOTICE ) ? " OPNOTICE" : "")
|
||||
<< ((ci->flags & CI_SECUREFOUNDER ) ? " SECUREFOUNDER" : "")
|
||||
<< ((ci->flags & CI_SIGNKICK ) ? " SIGNKICK" : "")
|
||||
<< ((ci->flags & CI_SIGNKICK_LEVEL) ? " SIGNKICKLEVEL" : "")
|
||||
<< ((ci->flags & CI_XOP ) ? " XOP" : "")
|
||||
<< ((ci->flags & CI_SUSPENDED ) ? " SUSPENDED" : "") << std::endl;
|
||||
fs << "MD FLAGS"
|
||||
<< (ci->flags & CI_KEEPTOPIC ? " KEEPTOPIC" : "")
|
||||
<< (ci->flags & CI_SECUREOPS ? " SECUREOPS" : "")
|
||||
<< (ci->flags & CI_PRIVATE ? " PRIVATE" : "")
|
||||
<< (ci->flags & CI_TOPICLOCK ? " TOPICLOCK" : "")
|
||||
<< (ci->flags & CI_RESTRICTED ? " RESTRICTED" : "")
|
||||
<< (ci->flags & CI_PEACE ? " PEACE" : "")
|
||||
<< (ci->flags & CI_SECURE ? " SECURE" : "")
|
||||
<< (ci->flags & CI_FORBIDDEN ? " FORBIDDEN" : "")
|
||||
<< (ci->flags & CI_NO_EXPIRE ? " NO_EXPIRE" : "")
|
||||
<< (ci->flags & CI_MEMO_HARDMAX ? " MEMO_HARDMAX" : "")
|
||||
<< (ci->flags & CI_OPNOTICE ? " OPNOTICE" : "")
|
||||
<< (ci->flags & CI_SECUREFOUNDER ? " SECUREFOUNDER" : "")
|
||||
<< (ci->flags & CI_SIGNKICK ? " SIGNKICK" : "")
|
||||
<< (ci->flags & CI_SIGNKICK_LEVEL ? " SIGNKICKLEVEL" : "")
|
||||
<< (ci->flags & CI_XOP ? " XOP" : "")
|
||||
<< (ci->flags & CI_SUSPENDED ? " SUSPENDED" : "") << std::endl;
|
||||
if (ci->desc && *ci->desc)
|
||||
fs << "MD DESC :" << ci->desc << std::endl;
|
||||
if (ci->url)
|
||||
@@ -844,28 +828,24 @@ int main(int argc, char *argv[])
|
||||
if (ci->flags & CI_FORBIDDEN)
|
||||
fs << "MD FORBID " << ci->forbidby << " :" << (ci->forbidreason ? ci->forbidreason : "no reason given") << std::endl;
|
||||
|
||||
for (j = 0; j < ci->accesscount; j++)
|
||||
{ // MD ACCESS <display> <level> <last_seen> <creator> - creator isn't in 1.9.0-1, but is in 1.9.2
|
||||
for (j = 0; j < ci->accesscount; ++j)
|
||||
// MD ACCESS <display> <level> <last_seen> <creator> - creator isn't in 1.9.0-1, but is in 1.9.2
|
||||
if (ci->access[j].in_use)
|
||||
fs << "MD ACCESS "
|
||||
<< ci->access[j].nc->display << " " << ci->access[j].level << " "
|
||||
<< ci->access[j].last_seen << " Unknown" << std::endl;
|
||||
}
|
||||
fs << "MD ACCESS " << ci->access[j].nc->display << " " << ci->access[j].level << " " << ci->access[j].last_seen << " Unknown" << std::endl;
|
||||
|
||||
for (j = 0; j < ci->akickcount; j++)
|
||||
{ // MD AKICK <STUCK/UNSTUCK> <NICK/MASK> <akick> <creator> <addtime> :<reason>
|
||||
for (j = 0; j < ci->akickcount; ++j)
|
||||
// MD AKICK <STUCK/UNSTUCK> <NICK/MASK> <akick> <creator> <addtime> :<reason>
|
||||
if (ci->akick[j].flags & 0x0001)
|
||||
{
|
||||
fs << "MD AKICK "
|
||||
<< ((ci->akick[j].flags & AK_STUCK) ? "STUCK " : "UNSTUCK " )
|
||||
<< ((ci->akick[j].flags & AK_ISNICK) ? "NICK " : "MASK ")
|
||||
<< ((ci->akick[j].flags & AK_ISNICK) ? ci->akick[j].u.nc->display : ci->akick[j].u.mask )
|
||||
<< (ci->akick[j].flags & AK_STUCK ? "STUCK " : "UNSTUCK ")
|
||||
<< (ci->akick[j].flags & AK_ISNICK ? "NICK " : "MASK ")
|
||||
<< (ci->akick[j].flags & AK_ISNICK ? ci->akick[j].u.nc->display : ci->akick[j].u.mask)
|
||||
<< " " << ci->akick[j].creator << " " << ci->akick[j].addtime << " 0 :"; // 0 is for last used, added in 1.9.2
|
||||
if (ci->akick[j].reason)
|
||||
fs << ci->akick[j].reason;
|
||||
fs << std::endl;
|
||||
if (ci->akick[j].reason)
|
||||
fs << ci->akick[j].reason;
|
||||
fs << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (ci->mlock_on)
|
||||
{
|
||||
@@ -894,9 +874,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (ci->memos.memocount)
|
||||
{
|
||||
Memo *memos;
|
||||
memos = ci->memos.memos;
|
||||
for (j = 0; j < ci->memos.memocount; j++, memos++)
|
||||
Memo *memos = ci->memos.memos;
|
||||
for (j = 0; j < ci->memos.memocount; ++j, ++memos)
|
||||
{
|
||||
fs << "MD MI " << memos->number << " " << memos->time << " " << memos->sender;
|
||||
if (memos->flags & MF_UNREAD)
|
||||
@@ -915,20 +894,20 @@ int main(int argc, char *argv[])
|
||||
fs << "MD BI NAME " << ci->bi << std::endl;
|
||||
if (ci->botflags)
|
||||
fs << "MD BI FLAGS"
|
||||
<< (( ci->botflags & BS_DONTKICKOPS ) ? " DONTKICKOPS" : "" )
|
||||
<< (( ci->botflags & BS_DONTKICKVOICES ) ? " DONTKICKVOICES" : "")
|
||||
<< (( ci->botflags & BS_FANTASY ) ? " FANTASY" : "")
|
||||
<< (( ci->botflags & BS_SYMBIOSIS ) ? " SYMBIOSIS" : "")
|
||||
<< (( ci->botflags & BS_GREET ) ? " GREET" : "")
|
||||
<< (( ci->botflags & BS_NOBOT ) ? " NOBOT" : "")
|
||||
<< (( ci->botflags & BS_KICK_BOLDS ) ? " KICK_BOLDS" : "")
|
||||
<< (( ci->botflags & BS_KICK_COLORS ) ? " KICK_COLORS" : "")
|
||||
<< (( ci->botflags & BS_KICK_REVERSES ) ? " KICK_REVERSES" : "")
|
||||
<< (( ci->botflags & BS_KICK_UNDERLINES ) ? " KICK_UNDERLINES" : "")
|
||||
<< (( ci->botflags & BS_KICK_BADWORDS ) ? " KICK_BADWORDS" : "")
|
||||
<< (( ci->botflags & BS_KICK_CAPS ) ? " KICK_CAPS" : "")
|
||||
<< (( ci->botflags & BS_KICK_FLOOD ) ? " KICK_FLOOD" : "")
|
||||
<< (( ci->botflags & BS_KICK_REPEAT ) ? " KICK_REPEAT" : "") << std::endl;
|
||||
<< (ci->botflags & BS_DONTKICKOPS ? " DONTKICKOPS" : "" )
|
||||
<< (ci->botflags & BS_DONTKICKVOICES ? " DONTKICKVOICES" : "")
|
||||
<< (ci->botflags & BS_FANTASY ? " FANTASY" : "")
|
||||
<< (ci->botflags & BS_SYMBIOSIS ? " SYMBIOSIS" : "")
|
||||
<< (ci->botflags & BS_GREET ? " GREET" : "")
|
||||
<< (ci->botflags & BS_NOBOT ? " NOBOT" : "")
|
||||
<< (ci->botflags & BS_KICK_BOLDS ? " KICK_BOLDS" : "")
|
||||
<< (ci->botflags & BS_KICK_COLORS ? " KICK_COLORS" : "")
|
||||
<< (ci->botflags & BS_KICK_REVERSES ? " KICK_REVERSES" : "")
|
||||
<< (ci->botflags & BS_KICK_UNDERLINES ? " KICK_UNDERLINES" : "")
|
||||
<< (ci->botflags & BS_KICK_BADWORDS ? " KICK_BADWORDS" : "")
|
||||
<< (ci->botflags & BS_KICK_CAPS ? " KICK_CAPS" : "")
|
||||
<< (ci->botflags & BS_KICK_FLOOD ? " KICK_FLOOD" : "")
|
||||
<< (ci->botflags & BS_KICK_REPEAT ? " KICK_REPEAT" : "") << std::endl;
|
||||
fs << "MD BI TTB";
|
||||
fs << " BOLDS " << ci->ttb[0];
|
||||
fs << " COLORS " << ci->ttb[1];
|
||||
@@ -949,18 +928,16 @@ int main(int argc, char *argv[])
|
||||
fs << "MD BI FLOODSECS " << ci->floodsecs << std::endl;
|
||||
if (ci->repeattimes)
|
||||
fs << "MD BI REPEATTIMES " << ci->repeattimes << std::endl;
|
||||
for (j = 0; j < ci->bwcount; j++)
|
||||
{
|
||||
for (j = 0; j < ci->bwcount; ++j)
|
||||
if (ci->badwords[j].in_use)
|
||||
{
|
||||
fs << "MD BI BADWORD "
|
||||
<< (( ci->badwords[j].type == 0 ) ? "ANY " : "" )
|
||||
<< (( ci->badwords[j].type == 1 ) ? "SINGLE " : "" )
|
||||
<< (( ci->badwords[j].type == 2 ) ? "START " : "" )
|
||||
<< (( ci->badwords[j].type == 3 ) ? "END " : "" )
|
||||
<< (!ci->badwords[j].type ? "ANY " : "")
|
||||
<< (ci->badwords[j].type == 1 ? "SINGLE " : "")
|
||||
<< (ci->badwords[j].type == 2 ? "START " : "")
|
||||
<< (ci->badwords[j].type == 3 ? "END " : "")
|
||||
<< ":" << ci->badwords[j].word << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
} /* for (chanlists[i]) */
|
||||
} /* for (i) */
|
||||
@@ -983,7 +960,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* AKILLS */
|
||||
read_int16(&capacity, f);
|
||||
for (i = 0; i < capacity; i++)
|
||||
for (i = 0; i < capacity; ++i)
|
||||
{
|
||||
SAFE(read_string(&user, f));
|
||||
SAFE(read_string(&host, f));
|
||||
@@ -992,11 +969,14 @@ int main(int argc, char *argv[])
|
||||
SAFE(read_int32(&seton, f));
|
||||
SAFE(read_int32(&expires, f));
|
||||
fs << "OS AKILL " << user << " " << host << " " << by << " " << seton << " " << expires << " :" << reason << std::endl;
|
||||
free(user); free(host); free(by); free(reason);
|
||||
delete [] user;
|
||||
delete [] host;
|
||||
delete [] by;
|
||||
delete [] reason;
|
||||
}
|
||||
/* SNLINES */
|
||||
read_int16(&capacity, f);
|
||||
for (i = 0; i < capacity; i++)
|
||||
for (i = 0; i < capacity; ++i)
|
||||
{
|
||||
SAFE(read_string(&mask, f));
|
||||
SAFE(read_string(&by, f));
|
||||
@@ -1004,11 +984,13 @@ int main(int argc, char *argv[])
|
||||
SAFE(read_int32(&seton, f));
|
||||
SAFE(read_int32(&expires, f));
|
||||
fs << "OS SNLINE " << mask << " " << by << " " << seton << " " << expires << " :" << reason << std::endl;
|
||||
free(mask); free(by); free(reason);
|
||||
delete [] mask;
|
||||
delete [] by;
|
||||
delete [] reason;
|
||||
}
|
||||
/* SQLINES */
|
||||
read_int16(&capacity, f);
|
||||
for (i = 0; i < capacity; i++)
|
||||
for (i = 0; i < capacity; ++i)
|
||||
{
|
||||
SAFE(read_string(&mask, f));
|
||||
SAFE(read_string(&by, f));
|
||||
@@ -1016,11 +998,13 @@ int main(int argc, char *argv[])
|
||||
SAFE(read_int32(&seton, f));
|
||||
SAFE(read_int32(&expires, f));
|
||||
fs << "OS SQLINE " << mask << " " << by << " " << seton << " " << expires << " :" << reason << std::endl;
|
||||
free(mask); free(by); free(reason);
|
||||
delete [] mask;
|
||||
delete [] by;
|
||||
delete [] reason;
|
||||
}
|
||||
/* SZLINES */
|
||||
read_int16(&capacity, f);
|
||||
for (i = 0; i < capacity; i++)
|
||||
for (i = 0; i < capacity; ++i)
|
||||
{
|
||||
SAFE(read_string(&mask, f));
|
||||
SAFE(read_string(&by, f));
|
||||
@@ -1028,12 +1012,13 @@ int main(int argc, char *argv[])
|
||||
SAFE(read_int32(&seton, f));
|
||||
SAFE(read_int32(&expires, f));
|
||||
fs << "OS SZLINE " << mask << " " << by << " " << seton << " " << expires << " :" << reason << std::endl;
|
||||
free(mask); free(by); free(reason);
|
||||
delete [] mask;
|
||||
delete [] by;
|
||||
delete [] reason;
|
||||
}
|
||||
close_db(f);
|
||||
} // operserv database
|
||||
|
||||
|
||||
/* CONVERTING DONE \o/ HURRAY! */
|
||||
fs.flush();
|
||||
fs.close();
|
||||
+417
-452
File diff suppressed because it is too large
Load Diff
+36
-59
@@ -1,5 +1,4 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2010 Anope Team
|
||||
* Contact us at team@anope.org
|
||||
*
|
||||
@@ -7,27 +6,29 @@
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SMTP_H
|
||||
#define SMTP_H
|
||||
|
||||
#include "sysconf.h"
|
||||
#define CoreExport
|
||||
#include "hashcomp.h"
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Some Linux boxes (or maybe glibc includes) require this for the
|
||||
* prototype of strsignal(). */
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <cerrno>
|
||||
|
||||
/* Windows does not have:
|
||||
* unistd.h, grp.h,
|
||||
@@ -39,34 +40,30 @@
|
||||
*/
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
# include <netdb.h>
|
||||
# include <netinet/in.h>
|
||||
# include <sys/socket.h>
|
||||
# include <arpa/inet.h>
|
||||
#else
|
||||
#include <winsock.h>
|
||||
#include <windows.h>
|
||||
# include <winsock.h>
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <sys/time.h>
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#ifdef _AIX
|
||||
extern int strcasecmp(const char *, const char *);
|
||||
extern int strncasecmp(const char *, const char *, size_t);
|
||||
# if 0 /* These break on some AIX boxes (4.3.1 reported). */
|
||||
# if 0 /* These break on some AIX boxes (4.3.1 reported). */
|
||||
extern int socket(int, int, int);
|
||||
extern int connect(int, struct sockaddr *, int);
|
||||
# endif
|
||||
@@ -77,52 +74,32 @@ extern int connect(int, struct sockaddr *, int);
|
||||
/* Solaris specific code, types that do not exist in Solaris'
|
||||
* * sys/types.h
|
||||
* **/
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE (-1)
|
||||
# ifndef INADDR_NONE
|
||||
# define INADDR_NONE (-1)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*#ifdef _WIN32
|
||||
#define PATH_MAX MAX_PATH
|
||||
#define snprintf _snprintf
|
||||
#endif*/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock.h>
|
||||
typedef SOCKET ano_socket_t;
|
||||
#define ano_sockclose(fd) closesocket(fd)
|
||||
#define ano_sockread(fd, buf, len) recv(fd, buf, len, 0)
|
||||
#define ano_sockwrite(fd, buf, len) send(fd, buf, len, 0)
|
||||
typedef SOCKET ano_socket_t;
|
||||
#define ano_sockclose(fd) closesocket(fd)
|
||||
#define ano_sockread(fd, buf, len) recv(fd, buf, len, 0)
|
||||
#define ano_sockwrite(fd, buf, len) send(fd, buf, len, 0)
|
||||
#else
|
||||
typedef int ano_socket_t;
|
||||
#define ano_sockclose(fd) close(fd)
|
||||
#define ano_sockread(fd, buf, len) read(fd, buf, len)
|
||||
#define ano_sockwrite(fd, buf, len) write(fd, buf, len)
|
||||
typedef int ano_socket_t;
|
||||
#define ano_sockclose(fd) close(fd)
|
||||
#define ano_sockread(fd, buf, len) read(fd, buf, len)
|
||||
#define ano_sockwrite(fd, buf, len) write(fd, buf, len)
|
||||
#define SOCKET_ERROR -1
|
||||
#endif
|
||||
|
||||
|
||||
/* Data structures */
|
||||
struct smtp_header {
|
||||
char *header;
|
||||
struct smtp_header *next;
|
||||
};
|
||||
|
||||
struct smtp_body_line {
|
||||
char *line;
|
||||
struct smtp_body_line *next;
|
||||
};
|
||||
|
||||
struct smtp_message {
|
||||
struct smtp_header *smtp_headers, *smtp_headers_tail;
|
||||
struct smtp_body_line *smtp_body, *smtp_body_tail;
|
||||
char *from;
|
||||
char *to;
|
||||
struct smtp_message
|
||||
{
|
||||
std::vector<ci::string> smtp_headers;
|
||||
std::vector<ci::string> smtp_body;
|
||||
ci::string from, to;
|
||||
ano_socket_t sock;
|
||||
};
|
||||
|
||||
@@ -131,4 +108,4 @@ struct smtp_message mail;
|
||||
/* set this to 1 if you want to get a log otherwise it runs silent */
|
||||
int smtp_debug = 0;
|
||||
|
||||
#endif /* SMTP_H */
|
||||
#endif /* SMTP_H */
|
||||
|
||||
Reference in New Issue
Block a user