Commit initial: GNUWorld servicii IRC cu README.md complet in limba romana - Analiza arhitecturala completa a proiectului - Documentatie ierarhie clase, bucla de evenimente, protocol P10 - Identificare probleme memorie si recomandari modernizare

This commit is contained in:
Underchat committed 2026-03-02 00:51:45 +02:00
commit fcb24f6de9
870 files changed
+311128

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
.deps
.libs
*.la
*.lo
Makefile
.arch-ids
+148
View File
@@ -0,0 +1,148 @@
/**
* ADDFLAGCommand.cc
*
* 08/08/2005 - Jimmy Lipham <music0m@alltel.net>
* Initial Version
*
* Adds this flag to the user
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: ADDFLAGCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "Network.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
RCSTAG("$Id: ADDFLAGCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void ADDFLAGCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
char flag = st[2][0];
if (st[2].size() > 1) {
if (flag == '+')
flag = st[2][1];
else {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::one_flag_per_addflag,
std::string("You may only add one flag per ADDFLAG command.")).c_str());
return;
}
}
if (!bot->getFlagType(flag)) {
Usage(theClient);
return;
}
sqlcfUser* targetUser = bot->isAuthed(st[1]);
if (!targetUser) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_user,
std::string("No such user %s.")).c_str(), st[1].c_str());
return;
}
if (flag == bot->getFlagChar(sqlcfUser::F_OWNER) &&
!theUser->getFlag(sqlcfUser::F_OWNER)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::owner_add_owner_only,
std::string("Only an owner can add the owner flag.")).c_str());
return;
}
if (flag == bot->getFlagChar(sqlcfUser::F_USERMANAGER) &&
!theUser->getFlag(sqlcfUser::F_OWNER)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::user_man_add_owner_only,
std::string("Only an owner can add the user management flag.")).c_str());
return;
}
/* A serveradmin can only add flags to users on his/her own group. */
if (theUser->getFlag(sqlcfUser::F_SERVERADMIN) &&
!theUser->getFlag(sqlcfUser::F_USERMANAGER)) {
if (targetUser->getGroup() != theUser->getGroup()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_add_flag_diff_group,
std::string("You cannot add a flag to a user in a different group.")).c_str());
return;
}
if (flag == bot->getFlagChar(sqlcfUser::F_BLOCK)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_add_block_flag,
std::string("You cannot add a block flag.")).c_str());
return;
}
if (flag == bot->getFlagChar(sqlcfUser::F_SERVERADMIN)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_add_serveradmin_flag,
std::string("You cannot add a serveradmin flag.")).c_str());
return;
}
}
if (targetUser->getFlag(bot->getFlagType(flag))) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::user_already_has_flag,
std::string("User %s already has flag '%c'.")).c_str(),
targetUser->getUserName().c_str(), flag);
return;
}
targetUser->setFlag(bot->getFlagType(flag));
targetUser->setLastUpdated(bot->currentTime());
targetUser->setLastUpdatedBy( std::string( "("
+ theUser->getUserName()
+ ") "
+ theClient->getRealNickUserHost() ) );
targetUser->commit(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::added_flag_to_user,
std::string("Added flag '%c' to user %s.")).c_str(),
flag,
targetUser->getUserName().c_str());
bot->logAdminMessage("%s (%s) ADDFLAG %s %c",
theUser ? theUser->getUserName().c_str() : theClient->getNickName().c_str(),
theClient->getRealNickUserHost().c_str(),
targetUser->getUserName().c_str(), flag);
bot->logLastComMessage(theClient, Message);
} //ADDFLAGCommand::Exec
} //Namespace cf
} //Namespace gnuworld
+136
View File
@@ -0,0 +1,136 @@
/**
* ADDHOSTCommand.cc
*
* 08/26/2005 - Jimmy Lipham <music0m@alltel.net>
* Initial Version
*
* Adds this hostmask to the user's list of hostmasks
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: ADDHOSTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
RCSTAG("$Id: ADDHOSTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void ADDHOSTCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
sqlcfUser* targetUser = bot->isAuthed(st[1]);
if (!targetUser) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_user,
std::string("No such user %s.")).c_str(), st[1].c_str());
return;
}
/* Can't add a host to an owner unless you're an owner. */
if (targetUser->getFlag(sqlcfUser::F_OWNER) && !theUser->getFlag(sqlcfUser::F_OWNER)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_add_host_an_owner,
std::string("You cannot add a host to an owner unless you're an owner.")).c_str());
return;
}
/* Can only add a host to a user manager if you're an owner. */
if (targetUser->getFlag(sqlcfUser::F_USERMANAGER) && !theUser->getFlag(sqlcfUser::F_OWNER)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_add_host_manager,
std::string("You cannot add a host to a user manager unless you're an owner.")).c_str());
return;
}
/* A serveradmin can only add hosts to users on his/her own group. */
if (theUser->getFlag(sqlcfUser::F_SERVERADMIN) &&
!theUser->getFlag(sqlcfUser::F_USERMANAGER)) {
if (targetUser->getGroup() != theUser->getGroup()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_add_host_diff_group,
std::string("You cannot add a host to a user in a different group.")).c_str());
return;
}
}
if (targetUser->matchHost(st[2].c_str())) {
if ((st[2] != "*!*@*") && targetUser->hasHost("*!*@*")) {
targetUser->delHost(bot->getLocalDBHandle(),"*!*@*");
bot->SendTo(theClient,
bot->getResponse(theUser,
language::removed_default_hostmask,
std::string("Removed the default hostmask of *!*@* from user %s.")).c_str(),
targetUser->getUserName().c_str());
} else {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::already_has_hostmask,
std::string("User %s already has hostmask %s.")).c_str(),
targetUser->getUserName().c_str(),
st[2].c_str());
return;
}
}
if (!targetUser->addHost(bot->getLocalDBHandle(),st[2].c_str())) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::failed_adding_hostmask,
std::string("Failed adding hostmask %s to user %s.")).c_str(),
st[2].c_str(), targetUser->getUserName().c_str());
return;
}
targetUser->setLastUpdated(bot->currentTime());
targetUser->setLastUpdatedBy( std::string( "("
+ theUser->getUserName()
+ ") "
+ theClient->getRealNickUserHost() ) );
targetUser->commit(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::adding_hostmask_to_user,
std::string("Added hostmask %s to user %s.")).c_str(),
st[2].c_str(),
targetUser->getUserName().c_str());
bot->logAdminMessage("%s (%s) ADDHOST %s %s",
theUser ? theUser->getUserName().c_str() : theClient->getNickName().c_str(),
theClient->getRealNickUserHost().c_str(),
targetUser->getUserName().c_str(), st[2].c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} //namespace cf
} //namespace gnuworld
+78
View File
@@ -0,0 +1,78 @@
/**
* ADDNOTECommand.cc
*
* 08/18/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Adds a note to a channel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: ADDNOTECommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
RCSTAG("$Id: ADDNOTECommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void ADDNOTECommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
if (st[1][0] != '#') {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::invalid_channel_name,
std::string("%s is an invalid channel name.")).c_str(),
st[1].c_str());
return;
}
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (!theChan) theChan = bot->newChannelRecord(st[1]);
if (!theChan->useSQL())
theChan->Insert(bot->getLocalDBHandle());
theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_NOTE, theClient, st.assemble(2));
bot->SendTo(theClient,
bot->getResponse(theUser,
language::note_recorded,
std::string("Note recorded for channel %s.")).c_str(),
theChan->getChannel().c_str());
bot->logAdminMessage("%s (%s) ADDNOTE %s %s",
theUser ? theUser->getUserName().c_str() : theClient->getNickName().c_str(),
theClient->getRealNickUserHost().c_str(),
theChan->getChannel().c_str(), st.assemble(2).c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+119
View File
@@ -0,0 +1,119 @@
/**
* ADDUSERCommand.cc
*
* 08/08/2005 - Jimmy Lipham <music0m@alltel.net>
* Initial Version
*
* Adds a new user, without flags, and optionally with this hostmask
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: ADDUSERCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "Network.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
RCSTAG("$Id: ADDUSERCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void ADDUSERCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
sqlcfUser* targetUser = bot->isAuthed(st[1]);
if (targetUser) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::user_already_exists,
std::string("User %s already exists.")).c_str(), st[1].c_str());
return;
}
sqlcfUser *newUser = new sqlcfUser(bot->theManager);
assert(newUser != 0);
newUser->setUserName(st[1]);
newUser->setCreated(bot->currentTime());
newUser->setLastSeen(0);
newUser->setLastUpdated(bot->currentTime());
newUser->setLanguageId(1);
newUser->setLastUpdatedBy( std::string( "("
+ theUser->getUserName()
+ ") "
+ theClient->getRealNickUserHost() ) );
/* A user added by a serveradmin automatically has the same group. */
if (theUser->getFlag(sqlcfUser::F_SERVERADMIN) &&
!theUser->getFlag(sqlcfUser::F_USERMANAGER))
newUser->setGroup(theUser->getGroup());
else
newUser->setGroup("undernet.org");
if (!newUser->Insert(bot->getLocalDBHandle())) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::error_creating_user,
std::string("Error creating user %s. (Insertion failed)")).c_str(),
st[1].c_str());
return;
}
bot->usersMap[newUser->getUserName()] = newUser;
if (st.size() > 2) {
if (newUser->addHost(bot->getLocalDBHandle(),st[2].c_str())) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::created_user_w_host,
std::string("Created user %s (%s).")).c_str(),
st[1].c_str(), st[2].c_str());
bot->logAdminMessage("%s (%s) ADDUSER %s %s",
theUser ? theUser->getUserName().c_str() : theClient->getNickName().c_str(),
theClient->getRealNickUserHost().c_str(),
st[1].c_str(), st[2].c_str());
} else {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::failed_adding_hostmask,
std::string("Failed adding hostmask %s to user %s.")).c_str(),
st[2].c_str(), newUser->getUserName().c_str());
return;
}
} else {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::created_user_wo_host,
std::string("Created user %s.")).c_str(), st[1].c_str());
bot->logAdminMessage("%s (%s) ADDUSER %s",
theUser ? theUser->getUserName().c_str() : theClient->getNickName().c_str(),
theClient->getRealNickUserHost().c_str(),
st[1].c_str());
}
bot->logLastComMessage(theClient, Message);
return;
} //ADDUSERCommand::Exec
} //namespace cf
} //namespace gnuworld
+94
View File
@@ -0,0 +1,94 @@
/**
* ALERTCommand.cc
*
* 07/19/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Sets the ALERT flag of this channel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: ALERTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
RCSTAG("$Id: ALERTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void ALERTCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
if (st[1][0] != '#') {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::invalid_channel_name,
std::string("%s is an invalid channel name.")).c_str(),
st[1].c_str());
return;
}
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (!theChan) theChan = bot->newChannelRecord(st[1]);
if (theChan->getFlag(sqlChannel::F_ALERT)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::alert_already_set,
std::string("The channel %s already has the ALERT flag.")).c_str(),
theChan->getChannel().c_str());
return;
}
theChan->setFlag(sqlChannel::F_ALERT);
if (!theChan->useSQL())
theChan->Insert(bot->getLocalDBHandle());
else
theChan->commit(bot->getLocalDBHandle());
/* Add note to the channel about this command */
theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_ALERT, theClient, (st.size() > 2) ? st.assemble(2) : "");
bot->SendTo(theClient,
bot->getResponse(theUser,
language::alert_flag_added,
std::string("ALERT flag added to channel %s")).c_str(),
theChan->getChannel().c_str());
/* Log command */
bot->logAdminMessage("%s (%s) ALERT %s",
theUser ? theUser->getUserName().c_str() : theClient->getNickName().c_str(),
theClient->getRealNickUserHost().c_str(),
theChan->getChannel().c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
View File
Whitespace-only changes.
+129
View File
@@ -0,0 +1,129 @@
/**
* BLOCKCommand.cc
*
* 07/19/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Blocks a channel from being fixed, both automatically and manually
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: BLOCKCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "Network.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
RCSTAG("$Id: BLOCKCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void BLOCKCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
/* Check if channel blocking has been disabled in the config. */
if (!bot->doChanBlocking()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::channel_blocking_disabled,
std::string("Channel blocking is disabled.")).c_str());
return;
}
if (st[1][0] != '#') {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::invalid_channel_name,
std::string("%s is an invalid channel name.")).c_str(),
st[1].c_str());
return;
}
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (!theChan) theChan = bot->newChannelRecord(st[1]);
if (theChan->getFlag(sqlChannel::F_BLOCKED)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::channel_already_blocked,
std::string("The channel %s is already blocked.")).c_str(),
theChan->getChannel().c_str());
return;
}
theChan->setFlag(sqlChannel::F_BLOCKED);
if (!theChan->useSQL())
theChan->Insert(bot->getLocalDBHandle());
else
theChan->commit(bot->getLocalDBHandle());
/* Add note to the channel about this command */
theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_BLOCK, theClient, st.assemble(2));
bot->SendTo(theClient,
bot->getResponse(theUser,
language::channel_has_been_blocked,
std::string("The channel %s has been blocked.")).c_str(),
theChan->getChannel().c_str());
/* Warn and remove from the queue if it is being fixed */
std::string extraLog;
Channel* netChan = Network->findChannel(st[1]);
if (netChan) {
if (bot->isBeingChanFixed(netChan)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::aborting_manual_fix,
std::string("WARNING: Channel %s is being manually fixed; aborting fix as per BLOCK.")).c_str(),
theChan->getChannel().c_str());
bot->stopFixingChan(netChan, true);
extraLog = " (current manual fix aborted)";
}
if (bot->isBeingAutoFixed(netChan)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::aborting_auto_fix,
std::string("WARNING: Channel %s is being automatically fixed; aborting fix as per BLOCK.")).c_str(),
theChan->getChannel().c_str());
bot->stopFixingChan(netChan, true);
extraLog = " (current autofix aborted)";
}
}
/* Log command */
bot->logAdminMessage("%s (%s) BLOCK %s%s",
theUser ? theUser->getUserName().c_str() : theClient->getNickName().c_str(),
theClient->getRealNickUserHost().c_str(),
theChan->getChannel().c_str(),
extraLog.c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+162
View File
@@ -0,0 +1,162 @@
/**
* CANFIXCommand.cc
*
* 03/04/2006 - Neil Spierling <sirvulcan@gmail.com>
* Initial Version
*
* Shows a list of accounts who can issue fixes for their channel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: CANFIXCommand.cc,v 1.2 2010/03/04 04:24:11 hidden1 Exp $
*/
#include "gnuworld_config.h"
#include "Network.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlChannel.h"
#include "sqlChanOp.h"
RCSTAG("$Id: CANFIXCommand.cc,v 1.2 2010/03/04 04:24:11 hidden1 Exp $");
namespace gnuworld
{
namespace cf
{
void CANFIXCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
sqlChanOp* curOp = 0;
chanfix::chanOpsType myOps = bot->getMyOps(st[1]);
int minFix = bot->getMinCanFixScore();
int maxFix = 0;
int maxScore = 0;
bool highscore = false;
unsigned int opCount = 0;
for (chanfix::chanOpsType::iterator opPtr = myOps.begin();
opPtr != myOps.end(); opPtr++) {
curOp = *opPtr;
opCount++;
if ((curOp->getPoints() + curOp->getBonus()) > maxScore)
maxScore = curOp->getPoints() + curOp->getBonus();
if (!strcasecmp(curOp->getAccount(), theClient->getAccount())) {
maxFix = curOp->getPoints() + curOp->getBonus();
if (maxFix < minFix)
highscore = false;
else
highscore = true;
}
}
/* Opers can view the list anyway despite having
* potentially no score. */
if (theClient->isOper())
highscore = true;
if (highscore == false) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::can_fix_not_enough_points,
std::string("You do not have a high enough score for %s to check canfix list.")).c_str(),
st[1].c_str());
return;
}
if (myOps.empty()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_scores_for_chan,
std::string("There are no scores in the database for %s.")).c_str(),
st[1].c_str());
return;
}
unsigned int oCnt = myOps.size();
/**
* Technically, if there are all 0 scores, it will get to this point.
* We don't want a notice saying 0 accounts.
*/
if (oCnt == 0) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_scores_for_chan,
std::string("There are no scores in the database for %s.")).c_str(),
st[1].c_str());
return;
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::canfix_op_accounts,
std::string("Accounts who can issue fixes in channel %s:")).c_str(),
st[1].c_str());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::canfix_rank_score_acc_header,
std::string("Account -- Time first opped / Time last opped")).c_str());
std::string firstop;
std::string lastop;
opCount = 0;
int pScore = 0;
int percent = 0;
int wScore = 0;
for (chanfix::chanOpsType::iterator opPtr = myOps.begin();
opPtr != myOps.end(); opPtr++) {
curOp = *opPtr;
opCount++;
firstop = bot->tsToDateTime(curOp->getTimeFirstOpped(), false);
lastop = bot->tsToDateTime(curOp->getTimeLastOpped(), true);
pScore = curOp->getPoints() + curOp->getBonus();
percent = static_cast<int>((static_cast<float>(pScore) / static_cast<float>(maxScore)) * 100);
/* Config value is within X percent, so we need to minus it from 100 to make sure
its within the X percent specified in the config */
wScore = 100 - percent;
if ((static_cast<float>(wScore) <= bot->getTopOpPercent()) && (static_cast<float>(pScore) >= bot->getMinFixScore())) {
bot->SendTo(theClient, "%s -- %s / %s",
curOp->getAccount().c_str(), firstop.c_str(),
lastop.c_str());
}
pScore = 0;
percent = 0;
wScore = 0;
}
bot->logAdminMessage("%s (%s) CANFIX %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
st[1].c_str());
return;
}
} //namespace cf
} //namespace gnuworld
+226
View File
@@ -0,0 +1,226 @@
/**
* CHANFIXCommand.cc
*
* 01/01/2004 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Manually fix a channel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: CHANFIXCommand.cc,v 1.7 2010/03/04 04:24:11 hidden1 Exp $
*/
#include "gnuworld_config.h"
#include "Network.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
RCSTAG("$Id: CHANFIXCommand.cc,v 1.7 2010/03/04 04:24:11 hidden1 Exp $");
namespace gnuworld
{
namespace cf
{
void CHANFIXCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
bool override = false;
bool alert = false;
if (st.size() > 2) {
unsigned int pos = 2;
while(pos < st.size()) {
if (!strcasecmp(st[pos],"OVERRIDE"))
override = true;
if (!strcasecmp(st[pos],"NOW"))
override = true;
if (!strcasecmp(st[pos],"YES"))
override = true;
if (!strcasecmp(st[pos],"!"))
override = true;
if (!strcasecmp(st[pos],"CONTACT"))
alert = true;
pos++;
}
}
/* Check if manual chanfix has been disabled in the config. */
if (!bot->doChanFix()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::manual_fix_disabled,
std::string("Sorry, manual chanfixes are currently disabled.")).c_str());
return;
}
/* If not enough servers are currently linked, bail out. */
if (bot->getState() != chanfix::RUN) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::not_enough_servers,
std::string("Sorry, chanfix is currently disabled because not enough servers are linked.")).c_str());
return;
}
Channel* netChan = Network->findChannel(st[1]);
if (!netChan) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_channel,
std::string("No such channel %s.")).c_str(), st[1].c_str());
return;
}
if (!bot->canScoreChan(netChan) || netChan->getMode(Channel::MODE_REG)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::registered_channel,
std::string("%s is a registered channel.")).c_str(),
netChan->getName().c_str());
return;
}
/* Only allow chanfixes for channels that are in the database. */
chanfix::chanOpsType myOps = bot->getMyOps(netChan);
if (myOps.empty()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_scores_for_chan,
std::string("There are no scores in the database for %s.")).c_str(),
netChan->getName().c_str());
return;
}
/* Don't fix a channel being chanfixed. */
if (bot->isBeingChanFixed(netChan)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::already_being_man_fixed,
std::string("The channel %s is already being manually fixed.")).c_str(),
netChan->getName().c_str());
return;
}
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (!theChan) theChan = bot->newChannelRecord(st[1]);
/* Check if the highest score is high enough for a fix. */
if (myOps.begin() != myOps.end())
theChan->setMaxScore((*myOps.begin())->getPoints() + (*myOps.begin())->getBonus());
if (theChan->getMaxScore() <=
static_cast<int>(static_cast<float>(FIX_MIN_ABS_SCORE_END) * MAX_SCORE))
{
bot->SendTo(theClient,
bot->getResponse(theUser,
language::highscore_channel,
std::string("The highscore in channel %s is %d which is lower than the minimum score required (%.2f * %d = %d).")).c_str(),
theChan->getChannel().c_str(), theChan->getMaxScore(),
FIX_MIN_ABS_SCORE_END, MAX_SCORE,
static_cast<int>(static_cast<float>(FIX_MIN_ABS_SCORE_END)
* MAX_SCORE));
return;
}
/* Don't fix a channel being autofixed without OVERRIDE flag. */
if (bot->isBeingAutoFixed(netChan)) {
if (!override) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::channel_being_auto_fixed,
std::string("The channel %s is being automatically fixed. Append the OVERRIDE flag to force a manual fix.")).c_str(),
netChan->getName().c_str());
return;
} else {
/* We're going to manually fix this instead of autofixing it,
* so remove this channel from the autofix queue. */
bot->removeFromAutoQ(netChan);
}
}
/* Don't fix a blocked channel. */
if (theChan->getFlag(sqlChannel::F_BLOCKED)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::channel_blocked,
std::string("The channel %s is BLOCKED.")).c_str(),
theChan->getChannel().c_str());
return;
}
/* Don't fix a blocked channel without the OVERRIDE flag. */
if (bot->isTempBlocked(theChan->getChannel()) && !override) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::channel_temp_blocked,
std::string("The channel %s is TEMPBLOCKED. To fix it, please append the OVERRIDE flag.")).c_str(),
theChan->getChannel().c_str());
return;
}
/* Don't fix an alerted channel without the OVERRIDE flag. */
if (theChan->getFlag(sqlChannel::F_ALERT) && !override) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::channel_has_notes,
std::string("Alert: The channel %s has notes. Use \002INFO %s\002 to read them. Append the OVERRIDE flag to force a manual fix.")).c_str(),
theChan->getChannel().c_str(), theChan->getChannel().c_str());
return;
}
/* Add the channel to the SQL database if it hasn't already been added */
if (!theChan->useSQL())
theChan->Insert(bot->getLocalDBHandle());
/* Alert top ops out of the channel if wanted */
if (alert)
bot->msgTopOps(netChan);
/* Fix the channel */
bot->manualFix(netChan);
/* Add note to the channel about this manual fix */
theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_CHANFIX, theClient, (override) ? "[override]" : "");
/* Log the chanfix */
bot->SendTo(theClient,
bot->getResponse(theUser,
language::manual_chanfix_ack,
std::string("Manual chanfix acknowledged for %s")).c_str(),
netChan->getName().c_str());
bot->logAdminMessage("%s (%s) CHANFIX %s%s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
netChan->getName().c_str(),
(override) ? " [override]" : "");
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+74
View File
@@ -0,0 +1,74 @@
/**
* CHECKCommand.cc
*
* 07/19/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Shows the number of ops and total clients in <channel>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: CHECKCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "Network.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
RCSTAG("$Id: CHECKCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void CHECKCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
Channel* netChan = Network->findChannel(st[1]);
if (!netChan) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_channel,
std::string("No such channel %s.")).c_str());
return;
}
/* Reports ops and total clients. */
bot->SendTo(theClient,
bot->getResponse(theUser,
language::check_results,
std::string("I see %d opped out of %d total clients in %s.")).c_str(),
bot->countChanOps(netChan), netChan->size(),
netChan->getName().c_str());
bot->logAdminMessage("%s (%s) CHECK %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
netChan->getName().c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+340
View File
@@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
View File
Whitespace-only changes.
+89
View File
@@ -0,0 +1,89 @@
/**
* DEBUGCommand.cc
*
* 01/16/2006 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Overview command for old ROTATE and UPDATE commands
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: DEBUGCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
*/
#include <string>
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "chanfix.h"
#include "responses.h"
RCSTAG("$Id: DEBUGCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void DEBUGCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
#ifndef CHANFIX_DEBUG
return;
#endif
StringTokenizer st(Message);
std::string option = string_upper(st[1]);
if (option == "ROTATE") {
bot->logDebugMessage("%s (%s) ordered a manual DB rotation.",
theUser ? theUser->getUserName().c_str() : theClient->getNickName().c_str(),
theClient->getRealNickUserHost().c_str());
bot->rotateDB();
return;
}
if (option == "UPDATE") {
if (bot->isUpdateRunning()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::update_in_progress,
std::string("This command cannot proceed while an update is in progress. Please try again later.")).c_str());
return;
}
if ((st.size() > 2) && string_upper(st[2]) == "THREADED") {
bot->logDebugMessage("%s (%s) ordered a manual DB update (threaded).",
theUser ? theUser->getUserName().c_str() : theClient->getNickName().c_str(),
theClient->getRealNickUserHost().c_str());
bot->prepareUpdate(true);
return;
} else {
bot->logDebugMessage("%s (%s) ordered a manual DB update.",
theUser ? theUser->getUserName().c_str() : theClient->getNickName().c_str(),
theClient->getRealNickUserHost().c_str());
bot->prepareUpdate(false);
return;
}
}
bot->logLastComMessage(theClient, Message);
}
} // namespace cf
} // namespace gnuworld
+148
View File
@@ -0,0 +1,148 @@
/**
* DELFLAGCommand.cc
*
* 08/08/2005 - Jimmy Lipham <music0m@alltel.net>
* Initial Version
*
* Removes this flag from the user
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: DELFLAGCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
RCSTAG("$Id: DELFLAGCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void DELFLAGCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
char flag = st[2][0];
if (st[2].size() > 1) {
if (flag == '-')
flag = st[2][1];
else {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::one_flag_per_delflag,
std::string("You may only remove one flag per DELFLAG command.")).c_str());
return;
}
}
if (!bot->getFlagType(flag)) {
Usage(theClient);
return;
}
sqlcfUser* targetUser = bot->isAuthed(st[1]);
if (!targetUser) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_user,
std::string("No such user %s.")).c_str(), st[1].c_str());
return;
}
if (flag == bot->getFlagChar(sqlcfUser::F_OWNER) &&
!theUser->getFlag(sqlcfUser::F_OWNER)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::only_owner_del_owner_flag,
std::string("Only an owner can delete the owner flag.")).c_str());
return;
}
if (flag == bot->getFlagChar(sqlcfUser::F_USERMANAGER) &&
!theUser->getFlag(sqlcfUser::F_OWNER)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::only_owner_del_user_flag,
std::string("Only an owner can delete the user management flag.")).c_str());
return;
}
/* A serveradmin can only delete flags from users on his/her own group. */
if (theUser->getFlag(sqlcfUser::F_SERVERADMIN) &&
!theUser->getFlag(sqlcfUser::F_USERMANAGER)) {
if (targetUser->getGroup() != theUser->getGroup()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_delete_flag_diff_group,
std::string("You cannot delete a flag from a user in a different group.")).c_str());
return;
}
if (flag == bot->getFlagChar(sqlcfUser::F_BLOCK)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_remove_block_flag,
std::string("You cannot remove a block flag.")).c_str());
return;
}
if (flag == bot->getFlagChar(sqlcfUser::F_SERVERADMIN)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_remove_server_flag,
std::string("You cannot remove a serveradmin flag.")).c_str());
return;
}
}
if (!targetUser->getFlag(bot->getFlagType(flag))) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::user_does_not_have_flag,
std::string("User %s does not have flag '%c'.")).c_str(),
targetUser->getUserName().c_str(), flag);
return;
}
targetUser->removeFlag(bot->getFlagType(flag));
targetUser->setLastUpdated(bot->currentTime());
targetUser->setLastUpdatedBy( std::string( "("
+ theUser->getUserName()
+ ") "
+ theClient->getRealNickUserHost() ) );
targetUser->commit(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::deleted_flag,
std::string("Deleted flag '%c' from user %s.")).c_str(), flag,
targetUser->getUserName().c_str());
bot->logAdminMessage("%s (%s) DELFLAG %s %c",
theUser ? theUser->getUserName().c_str() : theClient->getNickName().c_str(),
theClient->getRealNickUserHost().c_str(),
targetUser->getUserName().c_str(), flag);
bot->logLastComMessage(theClient, Message);
} //DELFLAGCommand::Exec
} //Namespace cf
} //Namespace gnuworld
+126
View File
@@ -0,0 +1,126 @@
/**
* DELHOSTCommand.cc
*
* 08/26/2005 - Jimmy Lipham <music0m@alltel.net>
* Initial Version
*
* Deletes this hostmask from the user's list of hostmasks
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: DELHOSTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
RCSTAG("$Id: DELHOSTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void DELHOSTCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
sqlcfUser* targetUser = bot->isAuthed(st[1]);
if (!targetUser) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_user,
std::string("No such user %s.")).c_str(), st[1].c_str());
return;
}
/* Can't delete a host from an owner unless you're an owner. */
if (targetUser->getFlag(sqlcfUser::F_OWNER) && !theUser->getFlag(sqlcfUser::F_OWNER)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_del_host_an_owner,
std::string("You cannot delete a host from an owner unless you're an owner.")).c_str());
return;
}
/* Can only delete a host from a user manager if you're an owner. */
if (targetUser->getFlag(sqlcfUser::F_USERMANAGER) && !theUser->getFlag(sqlcfUser::F_OWNER)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_del_host_manager,
std::string("You cannot delete a host from a user manager unless you're an owner.")).c_str());
return;
}
/* A serveradmin can only add flags to users on his/her own group. */
if (theUser->getFlag(sqlcfUser::F_SERVERADMIN) &&
!theUser->getFlag(sqlcfUser::F_USERMANAGER)) {
if (targetUser->getGroup() != theUser->getGroup()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_del_host_diff_group,
std::string("You cannot delete a host from a user in a different group.")).c_str());
return;
}
}
if (!targetUser->hasHost(st[2].c_str())) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::user_doesnt_have_host,
std::string("User %s doesn't have hostmask %s.")).c_str(),
targetUser->getUserName().c_str(), st[2].c_str());
return;
}
if (!targetUser->delHost(bot->getLocalDBHandle(),st[2].c_str())) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::failed_deleting_host,
std::string("Failed deleting hostmask %s from user %s.")).c_str(),
st[2].c_str(), targetUser->getUserName().c_str());
return;
}
targetUser->setLastUpdated(bot->currentTime());
targetUser->setLastUpdatedBy( std::string( "("
+ theUser->getUserName()
+ ") "
+ theClient->getRealNickUserHost() ) );
targetUser->commit(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::deleted_hostmask,
std::string("Deleted hostmask %s from user %s.")).c_str(),
st[2].c_str(), targetUser->getUserName().c_str());
bot->logAdminMessage("%s (%s) DELHOST %s %s",
theUser ? theUser->getUserName().c_str() : theClient->getNickName().c_str(),
theClient->getRealNickUserHost().c_str(),
targetUser->getUserName().c_str(), st[2].c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} //namespace cf
} //namespace gnuworld
+155
View File
@@ -0,0 +1,155 @@
/**
* DELNOTECommand.cc
*
* 08/18/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Deletes a note from this channel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: DELNOTECommand.cc,v 1.6 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
RCSTAG("$Id: DELNOTECommand.cc,v 1.6 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void DELNOTECommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (!theChan) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_entry_in_db,
std::string("There is no entry in the database for %s.")).c_str(),
st[1].c_str());
return;
}
if (!theChan->useSQL() || (theChan->countNotes(bot->getLocalDBHandle(),0) <= 0)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::chan_has_no_notes,
std::string("The channel %s does not have any notes.")).c_str(),
theChan->getChannel().c_str());
return;
}
unsigned int messageId = atoi(st[2].c_str());
/* Get a connection instance to our backend */
dbHandle* cacheCon = bot->getLocalDBHandle();
/* Retrieve the note */
std::stringstream noteCheckQuery;
noteCheckQuery << "SELECT channelID, user_name, event "
<< "FROM notes "
<< "WHERE id = "
<< messageId
;
if (!cacheCon->Exec(noteCheckQuery.str(),true)) {
elog << "DELNOTECommand> SQL Error: "
<< cacheCon->ErrorMessage()
<< std::endl ;
bot->SendTo(theClient,
bot->getResponse(theUser,
language::error_checking_noteid,
std::string("An unknown error occured while checking the note id.")).c_str());
/* Dispose of our connection instance */
//bot->theManager->removeConnection(cacheCon);
return;
}
if (cacheCon->Tuples() != 1) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_note_with_id,
std::string("There is no such note with that note_id.")).c_str());
return;
}
unsigned int channelID = atoi(cacheCon->GetValue(0,0));
std::string user_name = cacheCon->GetValue(0,1);
unsigned short eventType = atoi(cacheCon->GetValue(0,2));
/* Dispose of our connection instance */
//bot->theManager->removeConnection(cacheCon);
if (channelID != theChan->getID()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_note_id_for_chan,
std::string("No such note #%d for channel %s.")).c_str(),
messageId, theChan->getChannel().c_str());
return;
}
if (string_lower(user_name) != string_lower(theUser->getUserName()) && !theUser->getFlag(sqlcfUser::F_USERMANAGER)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::note_not_added_by_you,
std::string("Note #%d for channel %s was not added by you. You can only delete notes that you added.")).c_str(),
messageId, theChan->getChannel().c_str());
return;
}
if (eventType != sqlChannel::EV_NOTE && !theUser->getFlag(sqlcfUser::F_OWNER)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::note_not_manually_added,
std::string("Note #%d for channel %s is not a manually added note. You can only delete notes that were manually added.")).c_str(),
messageId, theChan->getChannel().c_str());
return;
}
theChan->deleteNote(bot->getLocalDBHandle(),messageId);
bot->SendTo(theClient,
bot->getResponse(theUser,
language::note_deleted,
std::string("Note #%d for channel %s deleted.")).c_str(),
messageId, theChan->getChannel().c_str());
bot->logAdminMessage("%s (%s) DELNOTE %s %d",
theUser ? theUser->getUserName().c_str() : theClient->getNickName().c_str(),
theClient->getRealNickUserHost().c_str(),
theChan->getChannel().c_str(), messageId);
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+108
View File
@@ -0,0 +1,108 @@
/**
* DELUSERCommand.cc
*
* 08/08/2005 - Jimmy Lipham <music0m@alltel.net>
* Initial Version
*
* Deletes a user
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: DELUSERCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
RCSTAG("$Id: DELUSERCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void DELUSERCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
sqlcfUser* targetUser = bot->isAuthed(st[1]);
if (!targetUser) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_user,
std::string("No such user %s.")).c_str(), st[1].c_str());
return;
}
/* Can't delete an owner unless you're an owner. */
if (targetUser->getFlag(sqlcfUser::F_OWNER) && !theUser->getFlag(sqlcfUser::F_OWNER)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_delete_an_owner,
std::string("You cannot delete an owner unless you're an owner.")).c_str());
return;
}
/* Can only delete a user manager if you're an owner. */
if (targetUser->getFlag(sqlcfUser::F_USERMANAGER) && !theUser->getFlag(sqlcfUser::F_OWNER)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_delete_manager,
std::string("You cannot delete a user manager unless you're an owner.")).c_str());
return;
}
/* A serveradmin can only delete users in his/her own group. */
if (theUser->getFlag(sqlcfUser::F_SERVERADMIN) &&
!theUser->getFlag(sqlcfUser::F_USERMANAGER)) {
if (targetUser->getGroup() != theUser->getGroup()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_delete_from_diff_group,
std::string("You cannot delete a user in a different group.")).c_str());
return;
}
}
if (targetUser->Delete(bot->getLocalDBHandle())) {
bot->usersMap.erase(bot->usersMap.find(targetUser->getUserName()));
bot->SendTo(theClient,
bot->getResponse(theUser,
language::deleted_user,
std::string("Deleted user %s.")).c_str(), targetUser->getUserName().c_str());
bot->logAdminMessage("%s (%s) DELUSER %s",
theClient->getAccount().c_str(),
theClient->getRealNickUserHost().c_str(),
targetUser->getUserName().c_str());
delete targetUser; targetUser = 0;
} else {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::error_deleting_user,
std::string("Error deleting user %s.")).c_str(), st[1].c_str());
}
bot->logLastComMessage(theClient, Message);
return;
} //DELUSERCommand::Exec
} //namespace cf
} //namespace gnuworld
+121
View File
@@ -0,0 +1,121 @@
/**
* HELPCommand.cc
*
* 08/08/2005 - Jimmy Lipham <music0m@alltel.net>
* Initial Version
*
* Shows help about <command> or gives a general list of commands
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: HELPCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "chanfixCommands.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
RCSTAG("$Id: HELPCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void HELPCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
if (st.size() < 2) {
if (bot->isAllowingTopFix())
bot->SendTo(theClient, bot->getHelpMessage(theUser, "<INDEXNORMAL>"));
if (theClient->isOper())
bot->SendTo(theClient, bot->getHelpMessage(theUser, "<INDEXOPER>"));
if (!theUser)
return;
bot->SendTo(theClient, bot->getHelpMessage(theUser, "<INDEXLOGGEDIN>"));
if (theUser->getFlag(sqlcfUser::F_SERVERADMIN))
bot->SendTo(theClient, bot->getHelpMessage(theUser, "<INDEXSERVERADMIN>"));
if (theUser->getFlag(sqlcfUser::F_BLOCK))
bot->SendTo(theClient, bot->getHelpMessage(theUser, "<INDEXBLOCK>"));
if (theUser->getFlag(sqlcfUser::F_COMMENT))
bot->SendTo(theClient, bot->getHelpMessage(theUser, "<INDEXCOMMENT>"));
if (theUser->getFlag(sqlcfUser::F_CHANFIX))
bot->SendTo(theClient, bot->getHelpMessage(theUser, "<INDEXCHANFIX>"));
if (theUser->getFlag(sqlcfUser::F_OWNER))
bot->SendTo(theClient, bot->getHelpMessage(theUser, "<INDEXOWNER>"));
if (theUser->getFlag(sqlcfUser::F_USERMANAGER))
bot->SendTo(theClient, bot->getHelpMessage(theUser, "<INDEXUSERADMIN>"));
} else {
std::string msg = bot->getHelpMessage(theUser, string_upper(st.assemble(1)));
if (!msg.empty()) {
bool real = true;
const std::string Command = string_upper(st[1]);
chanfix::commandMapType::iterator commHandler = bot->commandMap.find(Command);
if (commHandler == bot->commandMap.end())
real = false;
bot->SendTo(theClient, "\002%s\002", real ? commHandler->second->getInfo().c_str() : Command.c_str());
bot->SendFmtTo(theClient, msg);
if (real) {
/* If you change this code, remember to change it in chanfix.cc */
sqlcfUser::flagType requiredFlags = commHandler->second->getRequiredFlags();
if (requiredFlags) {
if (requiredFlags == sqlcfUser::F_LOGGEDIN)
bot->SendTo(theClient, "This command requires authentication.");
else {
if (bot->getFlagChar(requiredFlags) != ' ')
bot->SendTo(theClient,
bot->getResponse(theUser,
language::requires_auth_and_flag,
std::string("This command requires authentication and flag '%c'.")).c_str(),
bot->getFlagChar(requiredFlags));
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::requires_auth_and_flags,
std::string("This command requires authentication and one of these flags: \"%s\".")).c_str(),
bot->getFlagsString(requiredFlags).c_str());
}
}
}
} else
bot->SendTo(theClient, "There is no help available for that topic.");
}
} //HELPCommand::Exec
} //namespace cf
} //namespace gnuworld
+129
View File
@@ -0,0 +1,129 @@
/**
* HISTORYCommand.cc
*
* 08/14/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Shows the times that <channel> has been manually fixed
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: HISTORYCommand.cc,v 1.6 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
RCSTAG("$Id: HISTORYCommand.cc,v 1.6 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void HISTORYCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (!theChan || !theChan->useSQL()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::chan_no_manual_fixes,
std::string("Channel %s has never been manually fixed.")).c_str(),
st[1].c_str());
return;
}
/* Get a connection instance to our backend */
dbHandle* cacheCon = bot->getLocalDBHandle();
/*
* Perform a query to list the dates/times this channel was last chanfixed.
*/
std::stringstream chanfixQuery;
chanfixQuery << "SELECT ts "
<< "FROM notes "
<< "WHERE channelID = "
<< theChan->getID()
<< " AND (event = "
<< sqlChannel::EV_CHANFIX
<< " OR event = "
<< sqlChannel::EV_REQUESTOP
<< ") ORDER BY ts DESC"
;
if (!cacheCon->Exec(chanfixQuery.str(),true)) {
elog << "HISTORYCommand> SQL Error: "
<< cacheCon->ErrorMessage()
<< std::endl;
bot->SendTo(theClient,
bot->getResponse(theUser,
language::error_occured_notes,
std::string("An unknown error occurred while reading this channel's notes.")).c_str());
return ;
}
unsigned int noteCount = cacheCon->Tuples();
if (noteCount <= 0) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::chan_no_manual_fixes,
std::string("Channel %s has never been manually fixed.")).c_str(),
theChan->getChannel().c_str());
/* Dispose of our connection instance */
//bot->theManager->removeConnection(cacheCon);
return;
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::chan_manually_fix,
std::string("Channel %s has been manually fixed on:")).c_str(),
theChan->getChannel().c_str());
for (unsigned int i = 0; i < noteCount; i++)
bot->SendTo(theClient, "%s", bot->tsToDateTime(atoi(cacheCon->GetValue(i,0)), true).c_str());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::end_of_list,
std::string("End of list.")).c_str());
/* Dispose of our connection instance */
//bot->theManager->removeConnection(cacheCon);
bot->logAdminMessage("%s (%s) HISTORY %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
theChan->getChannel().c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+223
View File
@@ -0,0 +1,223 @@
/**
* INFOCommand.cc
*
* 07/20/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Shows all notes of this channel, and whether it has been blocked
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: INFOCommand.cc,v 1.7 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "Network.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
RCSTAG("$Id: INFOCommand.cc,v 1.7 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void INFOCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
bool isBlocked = bot->isTempBlocked(st[1]);
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (!theChan) {
if (isBlocked) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::temporarily_blocked,
std::string("%s is temporarily blocked. (Use OVERRIDE to bypass)")).c_str(),
st[1].c_str());
return;
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_info_for_chan,
std::string("No information on %s in the database.")).c_str(),
st[1].c_str());
return;
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::information_on,
std::string("Information on %s:")).c_str(),
theChan->getChannel().c_str());
if (isBlocked)
bot->SendTo(theClient,
bot->getResponse(theUser,
language::temporarily_blocked,
std::string("%s is temporarily blocked. (Use OVERRIDE to bypass)")).c_str(),
st[1].c_str());
if (theChan->getFlag(sqlChannel::F_BLOCKED))
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_chan_blocked,
std::string("%s is BLOCKED.")).c_str(),
theChan->getChannel().c_str());
else if (theChan->getFlag(sqlChannel::F_ALERT))
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_chan_alerted,
std::string("%s is ALERTED.")).c_str(),
theChan->getChannel().c_str());
Channel* netChan = Network->findChannel(st[1]);
if (netChan && bot->isBeingFixed(netChan)) {
if (bot->isBeingChanFixed(netChan))
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_chan_being_fixed,
std::string("%s is being chanfixed.")).c_str(),
theChan->getChannel().c_str());
if (bot->isBeingAutoFixed(netChan))
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_chan_being_autofixed,
std::string("%s is being autofixed.")).c_str(),
theChan->getChannel().c_str());
if (theChan->getFixStart() > 0)
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_fix_started,
std::string("Current fix has been running for %s")).c_str(),
bot->prettyDuration(theChan->getFixStart()).c_str());
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_fix_waiting,
std::string("Current fix is on hold (waiting for ops to join)")).c_str());
}
else
{
unsigned int lastfix = bot->getLastFix(theChan);
std::string dateTimeOfLastFix;
if (lastfix == 0)
dateTimeOfLastFix = "Never";
else
dateTimeOfLastFix = bot->tsToDateTime(lastfix, true);
bot->SendTo(theClient, "Last fix: %s (%s ago)", dateTimeOfLastFix.c_str(), bot->prettyDuration(lastfix).c_str());
}
if (!theChan->useSQL()) {
bot->logAdminMessage("%s (%s) INFO %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
theChan->getChannel().c_str());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::end_of_information,
std::string("End of information.")).c_str());
return;
}
/* Get a connection instance to our backend */
dbHandle* cacheCon = bot->getLocalDBHandle();
/*
* Perform a query to list all notes belonging to this channel.
*/
std::stringstream allNotesQuery;
allNotesQuery << "SELECT notes.id, notes.ts, notes.user_name, notes.event, notes.message "
<< "FROM notes "
<< "WHERE notes.channelID = "
<< theChan->getID()
<< " ORDER BY notes.ts DESC"
;
if (!cacheCon->Exec(allNotesQuery.str(),true)) {
elog << "INFOCommand> SQL Error: "
<< cacheCon->ErrorMessage()
<< std::endl;
bot->SendTo(theClient,
bot->getResponse(theUser,
language::error_occured_notes,
std::string("An unknown error occurred while reading this channel's notes.")).c_str());
/* Dispose of our connection instance */
//bot->theManager->removeConnection(cacheCon);
return ;
}
unsigned int noteCount = cacheCon->Tuples();
if (noteCount > 0) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_notes_count,
std::string("Notes (%d):")).c_str(), noteCount);
for (unsigned int i = 0; i < noteCount; i++) {
unsigned int note_id = atoi(cacheCon->GetValue(i,0));
unsigned int when = atoi(cacheCon->GetValue(i,1));
std::string from = cacheCon->GetValue(i,2);
unsigned short event = atoi(cacheCon->GetValue(i,3));
std::string theMessage = cacheCon->GetValue(i,4);
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_notes,
std::string("[%d:%s] %s \002%s\002%s%s")).c_str(),
note_id, from.c_str(),
bot->tsToDateTime(when, true).c_str(),
bot->getEventName(event).c_str(),
(!theMessage.empty()) ? " " : "", theMessage.c_str());
}
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::end_of_information,
std::string("End of information.")).c_str());
/* Dispose of our connection instance */
//bot->theManager->removeConnection(cacheCon);
bot->logAdminMessage("%s (%s) INFO %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
theChan->getChannel().c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+231
View File
@@ -0,0 +1,231 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004 Free
Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that the
`configure' script does not know about. Run `./configure --help' for
details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not support the `VPATH'
variable, you have to compile the package for one architecture at a
time in the source code directory. After you have installed the
package for one architecture, use `make distclean' before reconfiguring
for another architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PREFIX'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PREFIX', the package will
use PREFIX as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out automatically,
but needs to determine by the type of machine the package will run on.
Usually, assuming the package is built to be run on the _same_
architectures, `configure' can figure that out, but if it prints a
message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the `--target=TYPE' option to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share, you
can create a site shell script called `config.site' that gives default
values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
will cause the specified gcc to be used as the C compiler (unless it is
overridden in the site shell script).
`configure' Invocation
======================
`configure' recognizes the following options to control how it operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.
+94
View File
@@ -0,0 +1,94 @@
/**
* INVITECommand.cc
*
* 18/12/2003 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Invite the user to the console channel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: INVITECommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "Network.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "chanfix.h"
RCSTAG("$Id: INVITECommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void INVITECommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
Channel* theChannel = 0;
if (st.size() == 1)
theChannel = Network->findChannel(bot->consoleChan);
else
theChannel = Network->findChannel(st[1]);
if (!theChannel) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_find_channel,
std::string("Could not find channel %s on the network.")).c_str(),
st[1].c_str());
return;
}
ChannelUser* theBot = theChannel->findUser(bot->getInstance());
if (!theBot) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::chanfix_not_in_chan,
std::string("I am not in %s.")).c_str(),
theChannel->getName().c_str());
return;
}
ChannelUser* theChannelUser = theChannel->findUser(theClient);
if (theChannelUser) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::already_in_channel,
std::string("You are already in %s!")).c_str(),
theChannel->getName().c_str());
return;
}
bot->Invite(theClient, theChannel);
bot->logAdminMessage("%s (%s) INVITE %s [CODER-CHAN]",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
theChannel->getName().c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+139
View File
@@ -0,0 +1,139 @@
/**
* LASTCOMCommand.cc
*
* 18/04/2006 - Neil Spierling <sirvulcan@gmail.com>
* Based on mod.ccontrol LASTCOM command.
*
* Sends a list of the last X commands.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: LASTCOMCommand.cc,v 1.4 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include <sstream>
#include <string>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include "chanfix.h"
#include "chanfixCommands.h"
#include "defs.h"
#include "responses.h"
#include "sqlChanOp.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
#include "Network.h"
#include "iClient.h"
#include "StringTokenizer.h"
#include "ELog.h"
#include "gnuworld_config.h"
RCSTAG( "$Id: LASTCOMCommand.cc,v 1.4 2008/01/16 02:03:37 buzlip01 Exp $" ) ;
namespace gnuworld
{
namespace cf
{
void LASTCOMCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st( Message ) ;
unsigned int NumOfCom;
unsigned int Days = 0;
std::stringstream theQuery;
dbHandle* cacheCon = bot->getLocalDBHandle();
if (st.size() == 1 ) {
NumOfCom = 20;
static const char* queryHeader = "SELECT * FROM comlog ";
theQuery << queryHeader
<< " ORDER BY ts DESC"
<< " LIMIT " << NumOfCom
<< std::ends;
} else {
NumOfCom = atoi(st[1].c_str());
if (st.size() > 2) {
Days = atoi(st[2].c_str());
if (Days > 365) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::lastcom_too_far_back,
std::string("You cannot see logs more than one year ago.")).c_str());
return;
}
static const char* queryHeader = "SELECT * FROM comlog where ts >";
theQuery << queryHeader
<< (::time(0) - Days * 24 * 3600)
<< " ORDER BY ts ASC"
<< " LIMIT " << NumOfCom
<< std::ends;
} else {
static const char* queryHeader = "SELECT * FROM comlog ";
theQuery << queryHeader
<< " ORDER BY ts DESC"
<< " LIMIT " << NumOfCom
<< std::ends;
}
}
elog << "chanfix::LASTCOM> "
<< theQuery.str().c_str()
<< std::endl;
if (!cacheCon->Exec(theQuery.str(),true)) {
elog << "chanfix::LASTCOM> SQL Error: "
<< cacheCon->ErrorMessage()
<< std::endl ;
return;
}
// SQL Query succeeded
bot->SendTo(theClient,
bot->getResponse(theUser,
language::lastcom_listing_messages,
std::string("Listing last %d messages from day %d.")).c_str(),
NumOfCom,Days);
// TODO: Fix this warning
for (int i = (cacheCon->Tuples() - 1) ; i >= 0; i--) {
bot->SendTo(theClient,"[ %s - %s ] %s",
bot->convertToAscTime(atoi(cacheCon->GetValue(i, 0))),
cacheCon->GetValue(i,1).c_str(),
cacheCon->GetValue(i,2).c_str());
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::end_of_log,
std::string("End of LASTCOM report.")).c_str());
/* Dispose of our connection instance */
//bot->theManager->removeConnection(cacheCon);
bot->logLastComMessage(theClient, Message);
return;
}
}
}
+111
View File
@@ -0,0 +1,111 @@
/**
* LISTBLOCKEDCommand.cc
*
* 03/25/2006 - Jimmy Lipham <music0m@alltel.net>
* Initial Version
*
* Lists all blocked chans that chanfix has stored
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: LISTBLOCKEDCommand.cc,v 1.4 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "Network.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
RCSTAG("$Id: LISTBLOCKEDCommand.cc,v 1.4 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void LISTBLOCKEDCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
/* Check if channel blocking has been disabled in the config. */
if (!bot->doChanBlocking()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::channel_blocking_disabled,
std::string("Channel blocking is disabled.")).c_str());
return;
}
/* List blocks */
dbHandle* cacheCon = bot->getLocalDBHandle();
std::stringstream theQuery;
theQuery << "SELECT channel FROM channels WHERE (flags & "
<< sqlChannel::F_BLOCKED
<< ") = "
<< sqlChannel::F_BLOCKED
<< " ORDER BY channel ASC";
if (!cacheCon->Exec(theQuery.str(),true)) {
elog << "chanfix::LISTBLOCKEDCommand> SQL Error: "
<< cacheCon->ErrorMessage()
<< std::endl;
return;
}
// SQL query returned no errors
unsigned int numBlocks = 0;
std::string strBlocks;
bot->SendTo(theClient,
bot->getResponse(theUser,
language::listblocks_blocked_chans,
std::string("List of all blocked channels:")).c_str());
for (unsigned int i = 0 ; i < cacheCon->Tuples(); i++) {
strBlocks += cacheCon->GetValue(i, 0);
strBlocks += " ";
if (strBlocks.size() >= 410) {
bot->SendTo(theClient, strBlocks.c_str());
strBlocks = "";
}
numBlocks++;
}
/* Dispose of our connection instance */
//bot->theManager->removeConnection(cacheCon);
if (strBlocks.size())
bot->SendTo(theClient, strBlocks.c_str());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::listblocked_total_blocked,
std::string("%d channels blocked.")).c_str(),
numBlocks);
bot->logAdminMessage("%s (%s) LISTBLOCKED",
theUser ? theUser->getUserName().c_str() : theClient->getNickName().c_str(),
theClient->getRealNickUserHost().c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+113
View File
@@ -0,0 +1,113 @@
/**
* LISTHOSTSCommand.cc
*
* 12/28/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Shows all the host entries assigned to an oper
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: LISTHOSTSCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
RCSTAG("$Id: LISTHOSTSCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void LISTHOSTSCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
sqlcfUser* targetUser;
if (st.size() == 2)
targetUser = bot->isAuthed(st[1]);
else
targetUser = theUser;
if (!targetUser) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_user,
std::string("No such user %s.")).c_str(),
st[1].c_str());
return;
}
sqlcfUser::flagType requiredFlags = sqlcfUser::F_USERMANAGER | sqlcfUser::F_SERVERADMIN;
if ((targetUser != theUser) && !theUser->getFlag(requiredFlags)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::requires_auth_and_flags,
std::string("This command requires authentication and one of these flags: \"%s\".")).c_str(),
bot->getFlagsString(requiredFlags).c_str());
return;
}
/* A serveradmin can only view hosts of users in his/her own group. */
if (theUser->getFlag(sqlcfUser::F_SERVERADMIN) &&
!theUser->getFlag(sqlcfUser::F_USERMANAGER)) {
if (targetUser->getGroup() != theUser->getGroup()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_view_hosts_diff_group,
std::string("You cannot view hosts of a user in a different group.")).c_str());
return;
}
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::host_list_header,
std::string("Host list for %s:")).c_str(),
targetUser->getUserName().c_str());
sqlcfUser::hostListType sqlHostList = targetUser->getHostList();
if (!sqlHostList.empty()) {
for (sqlcfUser::hostListType::iterator itr = sqlHostList.begin();
itr != sqlHostList.end(); ++itr)
bot->SendTo(theClient, *itr);
} else {
bot->SendTo(theClient, "None.");
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::host_list_footer,
std::string("End of host list.")).c_str());
bot->logAdminMessage("%s (%s) LISTHOSTS %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
targetUser->getUserName().c_str());
bot->logLastComMessage(theClient, Message);
return;
} //LISTHOSTSCommand::Exec
} //namespace cf
} //namespace gnuworld
+72
View File
@@ -0,0 +1,72 @@
## Process this file with automake to produce Makefile.in
# "$Id: Makefile.am,v 1.11 2007/08/28 16:10:21 dan_karrels Exp $"
lib_LTLIBRARIES = libchanfix.la
libchanfix_la_SOURCES = chanfix.cc \
ADDFLAGCommand.cc \
ADDHOSTCommand.cc \
ADDNOTECommand.cc \
ADDUSERCommand.cc \
ALERTCommand.cc \
BLOCKCommand.cc \
CANFIXCommand.cc \
CHANFIXCommand.cc \
CHECKCommand.cc \
DEBUGCommand.cc \
DELFLAGCommand.cc \
DELHOSTCommand.cc \
DELNOTECommand.cc \
DELUSERCommand.cc \
HELPCommand.cc \
HISTORYCommand.cc \
INFOCommand.cc \
INVITECommand.cc \
LASTCOMCommand.cc \
LISTBLOCKEDCommand.cc \
LISTHOSTSCommand.cc \
OPLISTCommand.cc \
OPNICKSCommand.cc \
QUOTECommand.cc \
REHASHCommand.cc \
RELOADCommand.cc \
REQUESTOPCommand.cc \
SCORECommand.cc \
SAYCommand.cc \
SETCommand.cc \
SETGROUPCommand.cc \
SHUTDOWNCommand.cc \
SIMULATECommand.cc \
STATUSCommand.cc \
SUSPENDCommand.cc \
UNALERTCommand.cc \
UNBLOCKCommand.cc \
UNSUSPENDCommand.cc \
USERSCORESCommand.cc \
USETCommand.cc \
WHOFLAGCommand.cc \
WHOGROUPCommand.cc \
WHOISCommand.cc \
sqlChanOp.cc \
sqlChannel.cc \
sqlManager.cc \
sqlcfUser.cc
libchanfix_la_CXXFLAGS = -I$(top_srcdir)db -I${top_srcdir}/include \
-I${top_srcdir}/libgnuworld \
$(threadLib)
libchanfix_la_LDFLAGS = -module -export-dynamic -L$(top_builddir)/db \
-lgnuworldDB @BOOST_THREAD_LIB@
EXTRA_DIST = chanfix.h \
chanfixCommands.h \
chanfix_config.h \
chanfix_misc.h \
responses.h \
sqlChanOp.h \
sqlChannel.h \
sqlManager.h \
sqlcfUser.h \
$(COMMAND_CONF)
File diff suppressed because it is too large. Load diff
View File
Whitespace-only changes.
+270
View File
@@ -0,0 +1,270 @@
/**
* OPLISTCommand.cc
*
* 07/21/2005 - Jimmy Lipham <music0m@alltel.net>
* Initial Version
*
* Shows a list of accounts plus their score of the top ops of this channel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: OPLISTCommand.cc,v 1.8 2010/03/04 04:24:11 hidden1 Exp $
*/
#include "gnuworld_config.h"
#include "Network.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlChannel.h"
#include "sqlChanOp.h"
RCSTAG("$Id: OPLISTCommand.cc,v 1.8 2010/03/04 04:24:11 hidden1 Exp $");
namespace gnuworld
{
namespace cf
{
void OPLISTCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
bool all = false;
bool days = false;
unsigned int pos = 2;
while (pos < st.size()) {
if (!strcasecmp(st[pos],"-all"))
all = true;
if (!strcasecmp(st[pos],"all"))
all = true;
if (!strcasecmp(st[pos],"!"))
all = true;
if (!strcasecmp(st[pos],"-days"))
days = true;
pos++;
}
chanfix::chanOpsType myOps = bot->getMyOps(st[1]);
if (myOps.empty()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_scores_for_chan,
std::string("There are no scores in the database for %s.")).c_str(),
st[1].c_str());
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (theChan) {
bot->SendTo(theClient, "Notes: %d", theChan->countNotes(bot->getLocalDBHandle(),0));
if (bot->isTempBlocked(theChan->getChannel()))
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_chan_temp_blocked,
std::string("%s is TEMPBLOCKED.")).c_str(),
theChan->getChannel().c_str());
else if (theChan->getFlag(sqlChannel::F_BLOCKED))
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_chan_blocked,
std::string("%s is BLOCKED.")).c_str(),
theChan->getChannel().c_str());
else if (theChan->getFlag(sqlChannel::F_ALERT))
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_chan_alerted,
std::string("%s is ALERTED.")).c_str(),
theChan->getChannel().c_str());
}
return;
}
unsigned int oCnt = myOps.size();
/**
* Technically, if there are all 0 scores, it will get to this point.
* We don't want a notice saying 0 accounts.
*/
if (oCnt == 0) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_scores_for_chan,
std::string("There are no scores in the database for %s.")).c_str(),
st[1].c_str());
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (theChan) {
bot->SendTo(theClient, "Notes: %d", theChan->countNotes(bot->getLocalDBHandle(),0));
if (bot->isTempBlocked(theChan->getChannel()))
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_chan_temp_blocked,
std::string("%s is TEMPBLOCKED.")).c_str(),
theChan->getChannel().c_str());
else if (theChan->getFlag(sqlChannel::F_BLOCKED))
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_chan_blocked,
std::string("%s is BLOCKED.")).c_str(),
theChan->getChannel().c_str());
else if (theChan->getFlag(sqlChannel::F_ALERT))
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_chan_alerted,
std::string("%s is ALERTED.")).c_str(),
theChan->getChannel().c_str());
}
return;
}
if (oCnt > OPCOUNT && !all)
bot->SendTo(theClient,
bot->getResponse(theUser,
language::top_unique_op_accounts,
std::string("Top %d unique op accounts in channel %s:")).c_str(),
OPCOUNT, st[1].c_str());
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::found_unique_op_accounts,
std::string("Found %d unique op accounts in channel %s:")).c_str(),
oCnt, st[1].c_str());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::rank_score_acc_header,
std::string("Rank Score Account -- Time first opped / Time last opped / Nick")).c_str());
sqlChanOp* curOp = 0;
unsigned int opCount = 0;
unsigned int percent = 0;
int cScore;
bool inChan = false;
std::string firstop;
std::string lastop;
std::string nickName;
std::stringstream dayString;
time_t oldestTS = bot->currentTime();
for (chanfix::chanOpsType::iterator chOp = myOps.begin();
chOp != myOps.end(); chOp++) {
curOp = *chOp;
if (curOp->getTimeFirstOpped() < oldestTS)
oldestTS = curOp->getTimeFirstOpped();
}
for (chanfix::chanOpsType::iterator opPtr = myOps.begin();
opPtr != myOps.end() && (all || opCount < OPCOUNT); opPtr++) {
curOp = *opPtr;
opCount++;
firstop = bot->tsToDateTime(curOp->getTimeFirstOpped(), false);
lastop = bot->tsToDateTime(curOp->getTimeLastOpped(), true);
inChan = bot->accountIsOnChan(st[1], curOp->getAccount());
if (inChan)
nickName = bot->getChanNickName(st[1], curOp->getAccount());
if (days) {
dayString.str("");
for (int i = 1; i <= DAYSAMPLES; i++) {
cScore = curOp->getDay((currentDay + i) % DAYSAMPLES);
percent = static_cast<unsigned int>(((static_cast<float>(cScore) / static_cast<float>(86400 / POINTS_UPDATE_TIME)) * 100) + 0.5);
if (!cScore)
dayString << "."; // no score (.)
else if (percent <= 10)
dayString << "0"; // 0%-10% (0)
else if ((percent >= 11) && (percent <= 20))
dayString << "1"; // 11%-20% (1)
else if ((percent >= 21) && (percent <= 30))
dayString << "2"; // 21%-30% (2)
else if ((percent >= 31) && (percent <= 40))
dayString << "3"; // 31%-40% (3)
else if ((percent >= 41) && (percent <= 50))
dayString << "4"; // 41%-50% (4)
else if ((percent >= 51) && (percent <= 60))
dayString << "5"; // 51%-60% (5)
else if ((percent >= 61) && (percent <= 70))
dayString << "6"; // 61%-70% (6)
else if ((percent >= 71) && (percent <= 80))
dayString << "7"; // 71%-80% (7)
else if ((percent >= 81) && (percent <= 90))
dayString << "8"; // 81%-90% (8)
else if ((percent >= 91))
dayString << "9"; // 91%-100% (9)
}
dayString << std::ends;
}
bot->SendTo(theClient, "%3d. %4d %s -- %s / %s%s%s%s%s%s",
opCount,
(curOp->getPoints() + curOp->getBonus()),
curOp->getAccount().c_str(), firstop.c_str(),
lastop.c_str(), inChan ? " / " : "",
inChan ? nickName.c_str() : "",
(days) ? " [" : "",
(days) ? dayString.str().c_str() : "",
(days) ? "]" : "");
}
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (theChan) {
bot->SendTo(theClient, "Notes: %d", theChan->countNotes(bot->getLocalDBHandle(), 0));
if (bot->isTempBlocked(theChan->getChannel()))
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_chan_temp_blocked,
std::string("%s is TEMPBLOCKED.")).c_str(),
theChan->getChannel().c_str());
else if (theChan->getFlag(sqlChannel::F_BLOCKED))
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_chan_blocked,
std::string("%s is BLOCKED.")).c_str(),
theChan->getChannel().c_str());
else if (theChan->getFlag(sqlChannel::F_ALERT))
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_chan_alerted,
std::string("%s is ALERTED.")).c_str(),
theChan->getChannel().c_str());
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::end_of_oplist,
std::string("End of OPLIST for %s")).c_str(),
st[1].c_str());
bot->logAdminMessage("%s (%s) OPLIST %s %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
st[1].c_str(),
(st.size() > 2) ? st.assemble(2).c_str() : "");
bot->logLastComMessage(theClient, Message);
return;
}
} //namespace cf
} //namespace gnuworld
+107
View File
@@ -0,0 +1,107 @@
/**
* OPNICKSCommand.cc
*
* 07/18/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Shows the nicks of all ops in <channel>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: OPNICKSCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "Network.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
RCSTAG("$Id: OPNICKSCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void OPNICKSCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
Channel* netChan = Network->findChannel(st[1]);
if (!netChan) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_channel,
std::string("No such channel %s.")).c_str(), st[1].c_str());
return;
}
/* Send list of opped clients. */
bot->SendTo(theClient,
bot->getResponse(theUser,
language::opped_clients_on,
std::string("Opped clients on channel %s:")).c_str(),
netChan->getName().c_str());
ChannelUser* curUser;
std::string oppedUsers;
unsigned int numOppedUsers = 0;
for (Channel::userIterator ptr = netChan->userList_begin(); ptr != netChan->userList_end(); ptr++) {
curUser = ptr->second;
if (curUser->isModeO()) {
if ((oppedUsers.size() + std::string(curUser->getNickName().c_str()).size() + 1) >= 450) {
bot->SendTo(theClient, "%s", oppedUsers.c_str());
oppedUsers.erase(oppedUsers.begin(), oppedUsers.end());
}
if (numOppedUsers++ && !oppedUsers.empty())
oppedUsers += " ";
oppedUsers += curUser->getNickName();
}
}
if (numOppedUsers)
bot->SendTo(theClient, "%s", oppedUsers.c_str());
if (numOppedUsers == 1)
bot->SendTo(theClient,
bot->getResponse(theUser,
language::one_opped_client,
std::string("I see 1 opped client in %s.")).c_str(),
netChan->getName().c_str());
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::opped_clients,
std::string("I see %u opped clients in %s.")).c_str(),
numOppedUsers, netChan->getName().c_str());
/* Log command */
/* ... */
bot->logAdminMessage("%s (%s) OPNICKS %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
netChan->getName().c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+71
View File
@@ -0,0 +1,71 @@
/**
* QUOTECommand.cc
*
* 18/12/2003 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Sends raw P10 code to the server
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: QUOTECommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $
*/
#include <string>
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "chanfix.h"
#include "responses.h"
RCSTAG("$Id: QUOTECommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void QUOTECommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
#ifndef ENABLE_QUOTE
return;
#endif
if (!theUser->getNeedOper()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::unknown_command,
std::string("Unknown command.")).c_str());
return;
}
StringTokenizer st(Message);
bot->Write( st.assemble(1) );
bot->logAdminMessage("%s (%s) QUOTE %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
st.assemble(1).c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
View File
Whitespace-only changes.
+100
View File
@@ -0,0 +1,100 @@
/**
* REHASHCommand.cc
*
* 07/22/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Reload the bot's configuration file
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: REHASHCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "chanfix.h"
#include "responses.h"
RCSTAG("$Id: REHASHCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void REHASHCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
std::string option;
if (st.size() > 1)
option = string_upper(st[1]);
if (option == "CONFIG" || option.empty()) {
bot->readConfigFile(bot->getConfigFileName());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::reloaded_conf,
std::string("Successfully rehashed configuration file.")).c_str());
bot->logDebugMessage("%s (%s) rehashed the chanfix module.",
theUser->getUserName().c_str(),
theClient->getRealNickUserHost().c_str());
return;
}
if (option == "HELP") {
bot->helpTable.clear();
bot->loadHelpTable();
bot->SendTo(theClient,
bot->getResponse(theUser,
language::reloaded_help,
std::string("Successfully reloaded help tables. %i entries in table.", bot->helpTable.size())).c_str());
bot->logDebugMessage("%s (%s) rehashed the chanfix help tables.",
theUser->getUserName().c_str(),
theClient->getRealNickUserHost().c_str());
return;
}
if (option == "TRANSLATIONS") {
bot->languageTable.clear();
bot->translationTable.clear();
bot->loadTranslationTable();
bot->SendTo(theClient, "Successfully reloaded translation tables. %i entries in table.",
bot->translationTable.size());
bot->logDebugMessage("%s (%s) rehashed the chanfix translation tables.",
theUser->getUserName().c_str(),
theClient->getRealNickUserHost().c_str());
return;
}
bot->logAdminMessage("%s (%s) REHASH %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
!option.empty() ? option.c_str() : "");
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+83
View File
@@ -0,0 +1,83 @@
/**
* RELOADCommand.cc
*
* 18/12/2003 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Unloads the bot's module and reloads it
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: RELOADCommand.cc,v 1.5 2006/12/09 00:29:19 buzlip01 Exp $
*/
#include <string>
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "chanfix.h"
#include "responses.h"
RCSTAG("$Id: RELOADCommand.cc,v 1.5 2006/12/09 00:29:19 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void RELOADCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
if (bot->isUpdateRunning()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::update_in_progress,
std::string("This command cannot proceed while an update is in progress. Please try again later.")).c_str());
return;
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::reloading_client,
std::string("Reloading client...see you on the flip side")).c_str());
bot->logDebugMessage("%s (%s) is reloading the chanfix module.",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str());
bot->logAdminMessage("%s (%s) RELOAD %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
(st.size() < 2) ? "" : st.assemble(1).c_str());
if (st.size() < 2)
server->UnloadClient(bot, "Reloading...");
else
server->UnloadClient(bot, st.assemble(1));
server->LoadClient("libchanfix", bot->getConfigFileName());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+301
View File
@@ -0,0 +1,301 @@
/**
* REQUESTOPCommand.cc
*
* 04/04/2006 - Neil Spierling <sirvulcan@gmail.com>
* Initial Version
*
* Allow top ops to fix channels
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: REQUESTOPCommand.cc,v 1.2 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "Network.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
RCSTAG("$Id: REQUESTOPCommand.cc,v 1.2 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
/* 20110830 - Modified the REQUESTOP command to support the new CFV that was passed for criteria on Undernet
* A REQUESTOP succeeds if the following criteria are met:
* 1. The requester has a score of >= 1000
* 2. There is nobody opped on the channel with a high score >= 2000
* 3. There is nobody opped on the channel with a higher score than the requester
* 4. There is nobody opped on the channel with a 'first opped date' within 3 days of the oldest first opped date.
* 5. The requester is in the top 10 high scores for the channel
*/
void REQUESTOPCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
bool isRequesterScoreHighEnough = false;
int pScore, requesterScore = 0;
bool alert = false;
bool inChan = false;
sqlChanOp* curOp = 0;
// If the bot is not allowing top op fixes (REQUESTOP), ignore the request
if (!bot->isAllowingTopFix()) return;
/* Check if manual chanfix has been disabled in the config. */
if (!bot->doChanFix()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::canfix_manual_fix_disabled,
std::string("Sorry, I cant fix channels at the moment.")).c_str());
return;
}
/* If not enough servers are currently linked, bail out. */
if (bot->getState() != chanfix::RUN) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::not_enough_servers_non_oper,
std::string("Sorry, chanfix cannot fix channels at the moment, please try again soon.")).c_str());
return;
}
// Does the channel exist on the network? If not, discontinue the request
Channel* netChan = Network->findChannel(st[1]);
if (!netChan) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_channel,
std::string("No such channel %s.")).c_str(), st[1].c_str());
return;
}
chanfix::chanOpsType myOps = bot->getMyOps(st[1]);
if (!bot->canScoreChan(netChan) || netChan->getMode(Channel::MODE_REG)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::registered_channel,
std::string("%s is a registered channel.")).c_str(),
netChan->getName().c_str());
return;
}
/* Only allow chanfixes for channels that are in the database. */
if (myOps.empty()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_scores_for_chan,
std::string("There are no scores in the database for %s.")).c_str(),
netChan->getName().c_str());
return;
}
// Next lets make sure the requester has a score of >= 1000
for (chanfix::chanOpsType::iterator opPtr = myOps.begin();
opPtr != myOps.end(); opPtr++) {
curOp = *opPtr;
pScore = curOp->getPoints() + curOp->getBonus();
//bot->SendTo(theClient, "Current Op: %s -- You: %s -- pScore: %d", curOp->getAccount().c_str(), theClient->getAccount().c_str(), pScore);
if (string_lower(curOp->getAccount()) == string_lower(theClient->getAccount()) && pScore >= 1000)
{
isRequesterScoreHighEnough = true;
requesterScore = pScore;
break;
}
}
if (!isRequesterScoreHighEnough)
{
bot->SendTo(theClient,
bot->getResponse(theUser,
language::score_not_high_enough,
std::string("You score for %s is not high enough to issue a fix.")).c_str(),
netChan->getName().c_str());
return;
}
// Is there anyone opped on the chan with a score >= 2000?
std:string nickName;
for (chanfix::chanOpsType::iterator opPtr = myOps.begin();
opPtr != myOps.end(); opPtr++) {
curOp = *opPtr;
pScore = curOp->getPoints() + curOp->getBonus();
inChan = bot->accountIsOnChan(st[1], curOp->getAccount());
if (inChan && pScore >= 2000)
{
nickName = bot->getChanNickName(st[1], curOp->getAccount());
// Are they opped?
if (nickName[0] == '@')
{
bot->SendTo(theClient, "Sorry, there is somebody currently opped on %s with a high score.", st[1].c_str());
return;
}
}
}
//Is there anyone opped on the channel with a higher score than the requester?
for (chanfix::chanOpsType::iterator opPtr = myOps.begin();
opPtr != myOps.end(); opPtr++) {
curOp = *opPtr;
pScore = curOp->getPoints() + curOp->getBonus();
inChan = bot->accountIsOnChan(st[1], curOp->getAccount());
if (inChan && pScore >= requesterScore)
{
nickName = bot->getChanNickName(st[1], curOp->getAccount());
// Are they opped?
if (nickName[0] == '@')
{
bot->SendTo(theClient, "Sorry, there is somebody currently opped on %s with a higher score than you.", st[1].c_str());
return;
}
}
}
// Is there anyone opped on the channel with a 'first opped date' within 3 days of the oldest first opped date?
// First, get the oldest first opped TS and add 3 days to it
time_t ts_firstOpped = 0;
for (chanfix::chanOpsType::iterator opPtr = myOps.begin();
opPtr != myOps.end(); opPtr++) {
curOp = *opPtr;
if (curOp->isOldestOp())
{
ts_firstOpped = (curOp->getTimeFirstOpped() + (3 * 86400));
}
}
// Got the first opped TS, now we make sure there's not an op with a first_opped_ts within 3 days of this
for (chanfix::chanOpsType::iterator opPtr = myOps.begin();
opPtr != myOps.end(); opPtr++) {
curOp = *opPtr;
//bot->SendTo(theClient, "curOp: %s Time First Opped: %d ts_firstOpped: %d", curOp->getAccount().c_str(), curOp->getTimeFirstOpped(), ts_firstOpped);
inChan = bot->accountIsOnChan(st[1], curOp->getAccount());
if (inChan)
{
nickName = bot->getChanNickName(st[1], curOp->getAccount());
if (nickName[0] == '@' && !curOp->isOldestOp() && curOp->getTimeFirstOpped() <= ts_firstOpped)
{
bot->SendTo(theClient, "Sorry, there is somebody opped on %s that has been opped longer.", st[1].c_str());
return;
}
}
}
// Make sure the requester is in the top 10 scores list
int opCount = 0;
for (chanfix::chanOpsType::iterator opPtr = myOps.begin();
opPtr != myOps.end(); opPtr++) {
curOp = *opPtr;
opCount++;
if (string_lower(curOp->getAccount()) == string_lower(theClient->getAccount()) && opCount > 10)
{
bot->SendTo(theClient, "Sorry, you are not within the top 10 channel ops in %s.", st[1].c_str());
return;
}
}
/* Don't fix a channel being chanfixed. */
if (bot->isBeingChanFixed(netChan)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::already_being_man_fixed,
std::string("The channel %s is already being fixed.")).c_str(),
netChan->getName().c_str());
return;
}
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (!theChan) theChan = bot->newChannelRecord(st[1]);
unsigned int mintime = 0;
unsigned int curtime = 0;
unsigned int lastfix = 0;
curtime = bot->currentTime();
lastfix = bot->getLastFix(theChan);
mintime = (curtime - lastfix);
if (mintime < bot->getMinRequestOpTime()) {
unsigned int mint = (bot->getMinRequestOpTime() - mintime);
bot->SendTo(theClient,
bot->getResponse(theUser,
language::requestop_must_wait,
std::string("You must wait %s seconds before %s can be fixed again with this command, or contact a help channel.")).c_str(),
bot->prettyDuration(mint).c_str(), netChan->getName().c_str());
return;
}
/* Don't fix a channel being autofixed. */
if (bot->isBeingAutoFixed(netChan)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::channel_being_auto_fixed_noper,
std::string("The channel %s is being automatically fixed. You cannot issue another fix at the moment.")).c_str(),
netChan->getName().c_str());
return;
}
/* Don't fix a blocked or alerted channel. */
if ((bot->isTempBlocked(theChan->getChannel())) || (theChan->getFlag(sqlChannel::F_BLOCKED)) ||
(theChan->getFlag(sqlChannel::F_ALERT))) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::channel_blocked_non_oper,
std::string("The channel %s cannot be fixed, please contact a help channel for further information.")).c_str(),
theChan->getChannel().c_str());
return;
}
/* Add the channel to the SQL database if it hasn't already been added */
if (!theChan->useSQL())
theChan->Insert(bot->getLocalDBHandle());
/* Add the channel to the SQL database if it hasn't already been added */
if (!theChan->useSQL())
theChan->Insert(bot->getLocalDBHandle());
/* Alert top ops out of the channel if wanted */
if (alert)
bot->msgTopOps(netChan);
/* Fix the channel */
bot->manualFix(netChan);
/* Add note to the channel about this manual fix */
theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_REQUESTOP, theClient, "");
/* Log the chanfix */
bot->SendTo(theClient,
bot->getResponse(theUser,
language::requestop_ack,
std::string("Fixing %s, please wait.")).c_str(),
netChan->getName().c_str());
bot->logAdminMessage("%s (%s) REQUESTOP %s %s",
theUser ? theUser->getUserName().c_str() : theClient->getUserName().c_str(),
theClient->getRealNickUserHost().c_str(), netChan->getName().c_str(),
(alert) ? " [alert]" : "");
bot->logLastComMessage(theClient, Message);
}
} // namespace cf
} // namespace gnuworld
+69
View File
@@ -0,0 +1,69 @@
/**
* SAYCommand.cc
*
* 08/16/2006 - Jimmy Lipham <music0m@alltel.net>
* Initial Version
*
* Displays <text> in <#channel>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: SAYCommand.cc,v 1.1 2006/12/09 00:29:19 buzlip01 Exp $
*/
#include <string>
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "chanfix.h"
#include "responses.h"
#include "Network.h"
namespace gnuworld
{
namespace cf
{
void SAYCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
std::string option = st[1];
std::string value = st.assemble(2);
bot->logAdminMessage("%s (%s) SAY %s %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
option.c_str(), value.c_str());
bot->logLastComMessage(theClient, Message);
Channel* thisChan = Network->findChannel(option);
if (!thisChan)
bot->SendTo(theClient,
"The channel %s does not exist on the network.",
option.c_str());
else
bot->Message(thisChan,value);
return;
}
} // namespace cf
} // namespace gnuworld
+366
View File
@@ -0,0 +1,366 @@
/**
* SCORECommand.cc
*
* 07/15/2005 - Jimmy Lipham <music0m@alltel.net>
* Initial Version
*
* Shows the top scores or an individual score of <channel>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: SCORECommand.cc,v 1.7 2010/03/04 04:24:11 hidden1 Exp $
*/
#include <sstream>
#include <vector>
#include "gnuworld_config.h"
#include "Network.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlChannel.h"
#include "sqlChanOp.h"
#include "sqlcfUser.h"
RCSTAG("$Id: SCORECommand.cc,v 1.7 2010/03/04 04:24:11 hidden1 Exp $");
namespace gnuworld
{
namespace cf
{
void SCORECommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
bool compact = (string_upper(st[0]) == "CSCORE");
iClient* curClient = 0;
sqlChanOp* curOp = 0;
Channel* netChan = Network->findChannel(st[1]);
// If netchan is not null, AND either canScoreChan is false or the chan is +R
// reject the request
if ((netChan) && (!bot->canScoreChan(netChan) || netChan->getMode(Channel::MODE_REG))) {
if (compact)
bot->SendTo(theClient, "~! %s", netChan->getName().c_str());
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::registered_channel,
std::string("%s is a registered channel.")).c_str(),
netChan->getName().c_str());
return;
}
chanfix::chanOpsType myOps = bot->getMyOps(st[1]);
if (myOps.empty()) {
if (compact)
bot->SendTo(theClient, "~! %s", st[1].c_str());
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_scores_for_chan,
std::string("There are no scores in the database for %s.")).c_str(),
st[1].c_str());
return;
}
if (st.size() > 2) {
bot->logAdminMessage("%s (%s) %s %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
compact ? "CSCORE" : "SCORE",
st.assemble(1).c_str());
const char* scUser = st[2].c_str();
if (st[2][0] == '=') {
/* Nickname */
scUser++;
curClient = Network->findNick(scUser);
if (!curClient) {
if (compact)
bot->SendTo(theClient,
bot->getResponse(theUser,
language::compact_no_such_nick,
std::string("~U %s no@such.nick 0")).c_str(),
st[1].c_str());
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_nick,
std::string("No such nick %s.")).c_str(),
scUser);
return;
} else {
unsigned int ranking = 0;
size_t numMyOps = bot->countMyOps(netChan);
for (chanfix::chanOpsType::iterator opPtr = myOps.begin();
opPtr != myOps.end(); opPtr++) {
curOp = *opPtr;
ranking++;
if (string_lower(curOp->getAccount()) == string_lower(curClient->getAccount())) {
//Score for "reed@local.host" in channel "#coder-com": 4.
//Do it like they do on OCF, baby.
if (compact) {
//~U #coder-com mc@local.host 176
bot->SendTo(theClient, "~U %s %s %u",
st[1].c_str(),
curOp->getAccount().c_str(),
(curOp->getPoints() + curOp->getBonus()));
} else {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::score_for_channel_nick,
std::string("Score for %s (%s) in channel %s: %u. (Ranked #%u of %d)")).c_str(),
curClient->getNickName().c_str(),
curOp->getAccount().c_str(),
st[1].c_str(),
(curOp->getPoints() + curOp->getBonus()),
ranking,
numMyOps);
}
return;
}
}
if (compact)
bot->SendTo(theClient,
bot->getResponse(theUser,
language::compact_no_score_for_nick,
std::string("~U %s no@score.for.nick 0")).c_str(),
st[1].c_str());
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_score_for_nick,
std::string("No score for %s on %s.")).c_str(),
curClient->getNickName().c_str(),
st[1].c_str());
return;
} // else
} else {
/* Account */
if (st[2][0] == '*')
++scUser;
unsigned int ranking = 0;
size_t numMyOps = bot->countMyOps(netChan);
for (chanfix::chanOpsType::iterator opPtr = myOps.begin();
opPtr != myOps.end(); opPtr++) {
curOp = *opPtr;
ranking++;
if (string_lower(curOp->getAccount()) == string_lower(scUser)) {
if (compact)
bot->SendTo(theClient, "~U %s %s %u", st[1].c_str(), curOp->getAccount().c_str(), curOp->getPoints());
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::score_for_channel_account,
std::string("Score for account %s in channel %s: %u. (Ranked #%u of %d)")).c_str(),
curOp->getAccount().c_str(),
st[1].c_str(),
(curOp->getPoints() + curOp->getBonus()),
ranking,
numMyOps);
return;
}
}
if (compact)
bot->SendTo(theClient,
bot->getResponse(theUser,
language::compact_no_score_for_account,
std::string("~U %s no@score.for.account 0")).c_str(),
st[1].c_str());
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_score_for_account,
std::string("No score for account %s on channel %s.")).c_str(),
scUser,
st[1].c_str());
return;
} // else
} // if
/* Ok, now lets finally give it to em */
unsigned int minScoreReply;
if (bot->getNumTopScores() <= 0)
minScoreReply = 10;
else
minScoreReply = bot->getNumTopScores();
chanfix::acctListType acctToShow;
/* 3 different streams for 3 different output types */
std::stringstream strScoresDB; //For scores in the DB
std::stringstream strScoresOP; //For scores for users currently opped
std::stringstream strScoresNOP; //For scores for users NOT currently opped
unsigned int intDBCount = 0; //Rank counter for DB entries
unsigned int intOPCount = 0; //Rank counter for current OP entries
unsigned int intNOPCount = 0; //Rank counter for current non-ops
for (chanfix::chanOpsType::iterator opPtr = myOps.begin();
opPtr != myOps.end(); opPtr++) {
curOp = *opPtr;
if (intDBCount < minScoreReply) {
if (intDBCount++) {
if (compact)
strScoresDB << " ";
else
strScoresDB << ", ";
}
strScoresDB << (curOp->getPoints() + curOp->getBonus());
}
if (!netChan)
continue;
acctToShow = bot->findAccount(netChan, curOp->getAccount());
std::vector< iClient* >::const_iterator acctPtr = acctToShow.begin();
if (acctPtr == acctToShow.end())
continue;
curClient = *acctPtr;
if (curClient && netChan->findUser(curClient)->isModeO()) {
if (intOPCount < minScoreReply) {
if (intOPCount++) {
if (compact)
strScoresOP << " ";
else
strScoresOP << ", ";
}
strScoresOP << (curOp->getPoints() + curOp->getBonus());
}
} else {
if (!curClient)
continue;
if (intNOPCount < minScoreReply) {
if (intNOPCount++) {
if (compact)
strScoresNOP << " ";
else
strScoresNOP << ", ";
}
strScoresNOP << (curOp->getPoints() + curOp->getBonus());
}
}
acctToShow.clear();
}
if (!compact) {
strScoresDB << ".";
strScoresOP << ".";
strScoresNOP << ".";
}
bot->logAdminMessage("%s (%s) %s %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
compact ? "CSCORE" : "SCORE",
st.assemble(1).c_str());
if (compact) {
bot->SendTo(theClient, "~S %s %s", st[1].c_str(), strScoresDB.str().c_str());
if (!netChan) {
bot->SendTo(theClient, "~? %s", st[1].c_str());
return;
}
bot->SendTo(theClient, "~O %s %s", st[1].c_str(), strScoresOP.str().c_str());
bot->SendTo(theClient, "~N %s %s", st[1].c_str(), strScoresNOP.str().c_str());
} else {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::top_scores_for_chan,
std::string("Top %u scores for channel %s in the database:")).c_str(),
minScoreReply, st[1].c_str());
if (strScoresDB.str() == ".")
bot->SendTo(theClient,
bot->getResponse(theUser,
language::score_none,
std::string("None.")).c_str());
else
bot->SendTo(theClient, strScoresDB.str());
if (!netChan) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_channel,
std::string("No such channel %s.")).c_str(), st[1].c_str());
return;
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::top_scores_for_ops,
std::string("Top %u scores for current ops in %s in the database:")).c_str(),
minScoreReply, st[1].c_str());
if (strScoresOP.str() == ".")
bot->SendTo(theClient,
bot->getResponse(theUser,
language::score_none,
std::string("None.")).c_str());
else
bot->SendTo(theClient, strScoresOP.str());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::top_scores_for_nonops,
std::string("Top %u scores for current non-ops in %s in the database:")).c_str(),
minScoreReply, st[1].c_str());
if (strScoresNOP.str() == ".")
bot->SendTo(theClient,
bot->getResponse(theUser,
language::score_none,
std::string("None.")).c_str());
else
bot->SendTo(theClient, strScoresNOP.str());
}
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (theChan) {
bot->SendTo(theClient, "Notes: %d", theChan->countNotes(bot->getLocalDBHandle(), 0));
if (theChan->getFlag(sqlChannel::F_BLOCKED))
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_chan_blocked,
std::string("%s is BLOCKED.")).c_str(),
theChan->getChannel().c_str());
else if (bot->isTempBlocked(theChan->getChannel()))
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_chan_temp_blocked,
std::string("%s is TEMPBLOCKED.")).c_str(),
theChan->getChannel().c_str());
else if (theChan->getFlag(sqlChannel::F_ALERT))
bot->SendTo(theClient,
bot->getResponse(theUser,
language::info_chan_alerted,
std::string("%s is ALERTED.")).c_str(),
theChan->getChannel().c_str());
}
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+188
View File
@@ -0,0 +1,188 @@
/**
* SETCommand.cc
*
* 07/23/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Sets <option> to value <value>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: SETCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $
*/
#include <string>
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "chanfix.h"
#include "responses.h"
#include "Network.h"
RCSTAG("$Id: SETCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void SETCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
std::string option = string_upper(st[1]);
std::string value = string_upper(st[2]);
/*
* This code removes underscores from the option string.
* Please do NOT add underscores to the if statements below,
* as it will break the checking code. -reed
*/
std::string::size_type pos;
while ((pos = option.find('_', 0)) != std::string::npos)
option.erase(pos, 1);
bot->logAdminMessage("%s (%s) SET %s %s",
theUser->getUserName().c_str(),
theClient->getRealNickUserHost().c_str(),
option.c_str(), value.c_str());
if (option == "NUMSERVERS") {
int setting = atoi(value.c_str());
if (setting < 0) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::num_server_syntax,
std::string("Please use SET NUM_SERVERS <integer number>.")).c_str());
return;
}
bot->setNumServers(setting);
bot->SendTo(theClient,
bot->getResponse(theUser,
language::num_servers_set,
std::string("NUM_SERVERS is now %d.")).c_str(), setting);
bot->logDebugMessage("%s (%s) changed NUM_SERVERS to %d.",
theUser->getUserName().c_str(),
theClient->getRealNickUserHost().c_str(),
setting);
bot->checkNetwork();
return;
}
if (option == "ENABLEAUTOFIX") {
if (value == "ON" || value == "1") {
bot->setDoAutoFix(true);
bot->SendTo(theClient,
bot->getResponse(theUser,
language::enabled_autofix,
std::string("Enabled autofix.")).c_str());
bot->logDebugMessage("%s (%s) enabled autofix.",
theUser->getUserName().c_str(),
theClient->getRealNickUserHost().c_str());
return;
} else if (value == "OFF" || value == "0") {
bot->setDoAutoFix(false);
bot->SendTo(theClient,
bot->getResponse(theUser,
language::disabled_autofix,
std::string("Disabled autofix.")).c_str());
bot->logDebugMessage("%s (%s) disabled autofix.",
theUser->getUserName().c_str(),
theClient->getRealNickUserHost().c_str());
return;
} else {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::enable_autofix_syntax,
std::string("Please use SET ENABLE_AUTOFIX <on/off>.")).c_str());
return;
}
}
if (option == "ENABLECHANFIX") {
if (value == "ON" || value == "1") {
bot->setDoChanFix(true);
bot->SendTo(theClient,
bot->getResponse(theUser,
language::enabled_manual_chanfix,
std::string("Enabled manual chanfix.")).c_str());
bot->logDebugMessage("%s (%s) enabled manual chanfix.",
theUser->getUserName().c_str(),
theClient->getRealNickUserHost().c_str());
return;
} else if (value == "OFF" || value == "0") {
bot->setDoChanFix(false);
bot->SendTo(theClient,
bot->getResponse(theUser,
language::disabled_manual_chanfix,
std::string("Disabled manual chanfix.")).c_str());
bot->logDebugMessage("%s (%s) disabled manual chanfix.",
theUser->getUserName().c_str(),
theClient->getRealNickUserHost().c_str());
return;
} else {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::enable_chanfix_syntax,
std::string("Please use SET ENABLE_CHANFIX <on/off>.")).c_str());
return;
}
}
if (option == "ENABLECHANNELBLOCKING") {
if (value == "ON" || value == "1") {
bot->setDoChanBlocking(true);
bot->SendTo(theClient,
bot->getResponse(theUser,
language::enabled_chan_blocking,
std::string("Enabled channel blocking.")).c_str());
bot->logDebugMessage("%s (%s) enabled channel blocking.",
theUser->getUserName().c_str(),
theClient->getRealNickUserHost().c_str());
return;
} else if (value == "OFF" || value == "0") {
bot->setDoChanBlocking(false);
bot->SendTo(theClient,
bot->getResponse(theUser,
language::disabled_chan_blocking,
std::string("Disabled channel blocking.")).c_str());
bot->logDebugMessage("%s (%s) disabled channel blocking.",
theUser->getUserName().c_str(),
theClient->getRealNickUserHost().c_str());
return;
} else {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::enable_chan_blocking_syntax,
std::string("Please use SET ENABLE_CHANNEL_BLOCKING <on/off>.")).c_str());
return;
}
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::setting_doesnt_exist,
std::string("This setting does not exist.")).c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+90
View File
@@ -0,0 +1,90 @@
/**
* SETGROUPCommand.cc
*
* 08/27/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Sets the group of the user
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: SETGROUPCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
RCSTAG("$Id: SETGROUPCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void SETGROUPCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
sqlcfUser* targetUser = bot->isAuthed(st[1]);
if (!targetUser) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_user,
std::string("No such user %s.")).c_str(), st[1].c_str());
return;
}
std::string group = string_lower(st[2]);
if (targetUser->getGroup() == group) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::user_already_in_group,
std::string("User %s is already in group %s.")).c_str(),
targetUser->getUserName().c_str(), group.c_str());
return;
}
targetUser->setGroup(group);
targetUser->setLastUpdated(bot->currentTime());
targetUser->setLastUpdatedBy( std::string( "("
+ theUser->getUserName()
+ ") "
+ theClient->getRealNickUserHost() ) );
targetUser->commit(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::set_group_for_user,
std::string("Set group %s for user %s.")).c_str(),
group.c_str(), targetUser->getUserName().c_str());
bot->logAdminMessage("%s (%s) SETGROUP %s %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
targetUser->getUserName().c_str(),
group.c_str());
bot->logLastComMessage(theClient, Message);
return;
} //SETGROUPCommand::Exec
} //namespace cf
} //namespace gnuworld
+79
View File
@@ -0,0 +1,79 @@
/**
* SHUTDOWNCommand.cc
*
* 18/12/2003 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Shuts down the bot and squits the server
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: SHUTDOWNCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $
*/
#include <string>
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "chanfix.h"
#include "responses.h"
RCSTAG("$Id: SHUTDOWNCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void SHUTDOWNCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
if (bot->isUpdateRunning()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::update_in_progress,
std::string("This command cannot proceed while an update is in progress. Please try again later.")).c_str());
return;
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::shutting_down,
std::string("Shutting down the server as per your request.")).c_str());
bot->logDebugMessage("%s (%s) is shutting me down.",
theUser->getUserName().c_str(),
theClient->getRealNickUserHost().c_str());
bot->logAdminMessage("%s (%s) SHUTDOWN %s",
theUser->getUserName().c_str(),
theClient->getRealNickUserHost().c_str(),
(st.size() < 2) ? "" : st.assemble(1).c_str());
if (st.size() < 2)
server->Shutdown();
else
server->Shutdown( st.assemble(1) );
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+183
View File
@@ -0,0 +1,183 @@
/**
* SIMULATECommand.cc
*
* 28/09/2006 - Neil Spierling
* Initial Version
*
* Simulate a fix on a channel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: SIMULATECommand.cc,v 1.2 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "Network.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
RCSTAG("$Id: SIMULATECommand.cc,v 1.2 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void SIMULATECommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
bool autof = false;
if (st.size() > 2) {
unsigned int pos = 2;
while(pos < st.size()) {
if (!strcasecmp(st[pos],"AUTO"))
autof = true;
if (!strcasecmp(st[pos],"MANUAL"))
autof = false;
pos++;
}
}
/* If not enough servers are currently linked, bail out. */
if (bot->getState() != chanfix::RUN) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::not_enough_servers,
std::string("Sorry, chanfix is currently disabled because not enough servers are linked.")).c_str());
return;
}
Channel* netChan = Network->findChannel(st[1]);
if (!netChan) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_channel,
std::string("No such channel %s.")).c_str(), st[1].c_str());
return;
}
if (!bot->canScoreChan(netChan) || netChan->getMode(Channel::MODE_REG)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::registered_channel,
std::string("%s is a registered channel.")).c_str(),
netChan->getName().c_str());
return;
}
chanfix::chanOpsType myOps = bot->getMyOps(netChan);
if (myOps.empty()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_scores_for_chan,
std::string("There are no scores in the database for %s.")).c_str(),
netChan->getName().c_str());
return;
}
if (bot->isBeingChanFixed(netChan)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::already_being_man_fixed,
std::string("The channel %s is already being manually fixed.")).c_str(),
netChan->getName().c_str());
return;
}
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (!theChan) theChan = bot->newChannelRecord(st[1]);
if (myOps.begin() != myOps.end())
theChan->setMaxScore((*myOps.begin())->getPoints());
if (theChan->getMaxScore() <=
static_cast<int>(static_cast<float>(FIX_MIN_ABS_SCORE_END) * MAX_SCORE))
{
bot->SendTo(theClient,
bot->getResponse(theUser,
language::highscore_channel,
std::string("The highscore in channel %s is %d which is lower than the minimum score required (%.2f * %d = %d).")).c_str(),
theChan->getChannel().c_str(), theChan->getMaxScore(),
FIX_MIN_ABS_SCORE_END, MAX_SCORE,
static_cast<int>(static_cast<float>(FIX_MIN_ABS_SCORE_END)
* MAX_SCORE));
return;
}
if (theChan->getFlag(sqlChannel::F_BLOCKED)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::channel_blocked,
std::string("The channel %s is BLOCKED.")).c_str(),
theChan->getChannel().c_str());
return;
}
if (bot->isTempBlocked(theChan->getChannel())) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::channel_temp_blocked,
std::string("The channel %s is TEMPBLOCKED.")).c_str(),
theChan->getChannel().c_str());
return;
}
if (!theChan->useSQL())
theChan->Insert(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::manual_simulate_starting,
std::string("Simulate for %s (%s) starting at next fixing round (Current C time %s).")).c_str(),
netChan->getName().c_str(), ((autof == true) ? "AUTO" : "MANUAL"),
bot->tsToDateTime(bot->currentTime(), true).c_str());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::manual_simulate_estimate,
std::string("NOTE: This is only an estimate, if ops with points join or part it could affect who gets opped.")).c_str());
sqlChannel* sqlChan = bot->getChannelRecord(st[1]);
bot->simulateFix(sqlChan, autof, theClient, theUser);
theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_SIMULATE, theClient, (autof) ? "[auto]" : "[manual]");
bot->SendTo(theClient,
bot->getResponse(theUser,
language::manual_simulate_complete,
std::string("Simulate complete for %s")).c_str(),
netChan->getName().c_str());
bot->logAdminMessage("%s (%s) SIMULATE %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
netChan->getName().c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+123
View File
@@ -0,0 +1,123 @@
/**
* STATUSCommand.cc
*
* 04/01/2004 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Display the status of chanfix
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: STATUSCommand.cc,v 1.7 2010/03/04 04:24:11 hidden1 Exp $
*/
#include <string>
#include <sys/resource.h>
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "chanfix.h"
#include "defs.h"
#include "responses.h"
#include "Network.h"
RCSTAG("$Id: STATUSCommand.cc,v 1.7 2010/03/04 04:24:11 hidden1 Exp $");
namespace gnuworld
{
namespace cf
{
void STATUSCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
bot->SendTo(theClient, "[Evilnet Development -- mod.openchanfix v%s]",
CHANFIX_VERSION);
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_uptime,
std::string("Uptime: \002%s\002")).c_str(),
bot->prettyDuration(bot->getUplink()->getStartTime()).c_str());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_auto_fixing,
std::string("Automatic fixing is: \002%s\002")).c_str(),
bot->doAutoFix() ? "ON" : "OFF");
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_manual_fixing,
std::string("Manual fixing is: \002%s\002")).c_str(),
bot->doChanFix() ? "ON" : "OFF");
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_chan_blocking,
std::string("Channel blocking is: \002%s\002")).c_str(),
bot->doChanBlocking() ? "ON" : "OFF");
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_servers_amount,
std::string("Required amount of servers linked is %u%% of %u, which is a minimum of %u servers.")).c_str(),
bot->getMinServersPresent(), bot->getNumServers(),
((bot->getMinServersPresent() * bot->getNumServers()) / 100 + 1));
if (bot->getState() == chanfix::SPLIT)
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_splitmode_enabled,
std::string("Splitmode enabled: only %i servers linked.")).c_str(),
Network->serverList_size());
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_splitmode_disabled,
std::string("Splitmode disabled. There are %i servers linked.")).c_str(),
Network->serverList_size());
if (bot->isChanServLinked())
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_channel_service_linked,
std::string("Channel service linked. New channels will be scored.")).c_str());
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::status_channel_service_not_linked,
std::string("Channel service not linked. New channels will not be scored.")).c_str());
bot->SendTo(theClient,
std::string("Number of channels being autofixed: %i").c_str(),bot->countAutoFixes());
bot->SendTo(theClient,
std::string("Number of channels being manually fixed: %i").c_str(),bot->countManFixes());
int who = RUSAGE_SELF;
struct rusage usage;
int ret;
ret = getrusage(who, &usage);
bot->SendTo(theClient,
std::string("Memory Usage (kB): %ld").c_str(), usage.ru_maxrss);
bot->logAdminMessage("%s (%s) STATUS",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+126
View File
@@ -0,0 +1,126 @@
/**
* SUSPENDCommand.cc
*
* 08/29/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Suspends a user indefinitely
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: SUSPENDCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
RCSTAG("$Id: SUSPENDCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void SUSPENDCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
sqlcfUser* targetUser = bot->isAuthed(st[1]);
if (!targetUser) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_user,
std::string("No such user %s.")).c_str(), st[1].c_str());
return;
}
if (theUser == targetUser) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::user_cant_suspend_self,
std::string("Suspending yourself is not a very wise thing to do.")).c_str());
return;
}
/* Can't suspend an owner unless you're an owner. */
if (targetUser->getFlag(sqlcfUser::F_OWNER) && !theUser->getFlag(sqlcfUser::F_OWNER)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_suspend_an_owner,
std::string("You cannot suspend an owner unless you're an owner.")).c_str());
return;
}
/* Can only suspend a user manager if you're an owner. */
if (targetUser->getFlag(sqlcfUser::F_USERMANAGER) && !theUser->getFlag(sqlcfUser::F_OWNER)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_suspend_manager,
std::string("You cannot suspend a user manager unless you're an owner.")).c_str());
return;
}
/* A serveradmin can only suspend users in his/her own group. */
if (theUser->getFlag(sqlcfUser::F_SERVERADMIN) &&
!theUser->getFlag(sqlcfUser::F_USERMANAGER)) {
if (targetUser->getGroup() != theUser->getGroup()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_suspend_diff_group,
std::string("You cannot suspend a user in a different group.")).c_str());
return;
}
}
if (targetUser->getIsSuspended()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::user_already_suspended,
std::string("User %s is already suspended.")).c_str(),
targetUser->getUserName().c_str());
return;
}
targetUser->setSuspended(true);
targetUser->setLastUpdated(bot->currentTime());
targetUser->setLastUpdatedBy( std::string( "("
+ theUser->getUserName()
+ ") "
+ theClient->getRealNickUserHost() ) );
targetUser->commit(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::user_suspended,
std::string("Suspended user %s indefinitely.")).c_str(),
targetUser->getUserName().c_str());
bot->logAdminMessage("%s (%s) SUSPEND %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
targetUser->getUserName().c_str());
bot->logLastComMessage(theClient, Message);
return;
} //SUSPENDCommand::Exec
} //Namespace cf
} //Namespace gnuworld
+46
View File
@@ -0,0 +1,46 @@
/**
* Timer.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: Timer.h,v 1.2 2006/03/21 23:12:37 buzlip01 Exp $
*/
#ifndef __TIMER_H
#define __TIMER_H "$Id: Timer.h,v 1.2 2006/03/21 23:12:37 buzlip01 Exp $"
#include <sys/time.h>
namespace gnuworld {
class Timer {
public:
inline void Start()
{ gettimeofday(&startTime, 0); }
inline void Stop()
{ gettimeofday(&stopTime, 0); }
inline unsigned int getTimeMS()
{ return (stopTime.tv_sec - startTime.tv_sec) * 1000 +
(stopTime.tv_usec - startTime.tv_usec) / 1000; }
inline unsigned int stopTimeMS()
{ Stop(); return getTimeMS(); }
protected:
struct timeval startTime, stopTime;
}; // class Timer
} // namespace gnuworld
#endif // __TIMER_H
+92
View File
@@ -0,0 +1,92 @@
/**
* UNALERTCommand.cc
*
* 07/19/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Unsets the ALERT flag of this channel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: UNALERTCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
RCSTAG("$Id: UNALERTCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void UNALERTCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (!theChan) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_entry_in_db,
std::string("There is no entry in the database for %s.")).c_str(),
st[1].c_str());
return;
}
if (!theChan->getFlag(sqlChannel::F_ALERT)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_alert_set,
std::string("The channel %s does not have the ALERT flag.")).c_str(),
theChan->getChannel().c_str());
return;
}
theChan->removeFlag(sqlChannel::F_ALERT);
if (!theChan->useSQL())
theChan->Insert(bot->getLocalDBHandle());
else
theChan->commit(bot->getLocalDBHandle());
/* Add note to the channel about this command */
theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_UNALERT, theClient, "");
bot->SendTo(theClient,
bot->getResponse(theUser,
language::alert_removed,
std::string("ALERT flag removed from channel %s")).c_str(),
theChan->getChannel().c_str());
/* Log command */
bot->logAdminMessage("%s (%s) UNALERT %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
theChan->getChannel().c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+101
View File
@@ -0,0 +1,101 @@
/**
* UNBLOCKCommand.cc
*
* 07/19/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Removes the block on a channel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: UNBLOCKCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
RCSTAG("$Id: UNBLOCKCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void UNBLOCKCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
/* Check if channel blocking has been disabled in the config. */
if (!bot->doChanBlocking()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::channel_blocking_disabled,
std::string("Channel blocking is disabled.")).c_str());
return;
}
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (!theChan) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_entry_in_db,
std::string("There is no entry in the database for %s.")).c_str(),
st[1].c_str());
return;
}
if (!theChan->getFlag(sqlChannel::F_BLOCKED)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::channel_not_blocked,
std::string("The channel %s is not blocked.")).c_str(),
theChan->getChannel().c_str());
return;
}
theChan->removeFlag(sqlChannel::F_BLOCKED);
if (!theChan->useSQL())
theChan->Insert(bot->getLocalDBHandle());
else
theChan->commit(bot->getLocalDBHandle());
/* Add note to the channel about this command */
theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_UNBLOCK, theClient, "");
bot->SendTo(theClient,
bot->getResponse(theUser,
language::channel_unblocked,
std::string("Channel %s has been unblocked.")).c_str(),
theChan->getChannel().c_str());
/* Log command */
bot->logAdminMessage("%s (%s) UNBLOCK %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
theChan->getChannel().c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+117
View File
@@ -0,0 +1,117 @@
/**
* UNSUSPENDCommand.cc
*
* 08/29/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Unsuspends a user
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: UNSUSPENDCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
RCSTAG("$Id: UNSUSPENDCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void UNSUSPENDCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
sqlcfUser* targetUser = bot->isAuthed(st[1]);
if (!targetUser) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_user,
std::string("No such user %s.")).c_str(), st[1].c_str());
return;
}
/* Can't unsuspend an owner unless you're an owner. */
if (targetUser->getFlag(sqlcfUser::F_OWNER) && !theUser->getFlag(sqlcfUser::F_OWNER)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_unsuspend_an_owner,
std::string("You cannot unsuspend an owner unless you're an owner.")).c_str());
return;
}
/* Can only unsuspend a user manager if you're an owner. */
if (targetUser->getFlag(sqlcfUser::F_USERMANAGER) && !theUser->getFlag(sqlcfUser::F_OWNER)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_unsuspend_manager,
std::string("You cannot unsuspend a user manager unless you're an owner.")).c_str());
return;
}
/* A serveradmin can only unsuspend users in his/her own group. */
if (theUser->getFlag(sqlcfUser::F_SERVERADMIN) &&
!theUser->getFlag(sqlcfUser::F_USERMANAGER)) {
if (targetUser->getGroup() != theUser->getGroup()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::cant_unsuspend_diff_group,
std::string("You cannot unsuspend a user in a different group.")).c_str());
return;
}
}
if (!targetUser->getIsSuspended()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::user_not_suspended,
std::string("User %s is not currently suspended.")).c_str(),
targetUser->getUserName().c_str());
return;
}
targetUser->setSuspended(false);
targetUser->setLastUpdated(bot->currentTime());
targetUser->setLastUpdatedBy( std::string( "("
+ theUser->getUserName()
+ ") "
+ theClient->getRealNickUserHost() ) );
targetUser->commit(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::user_unsuspended,
std::string("Unsuspended user %s.")).c_str(),
targetUser->getUserName().c_str());
bot->logAdminMessage("%s (%s) UNSUSPEND %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
targetUser->getUserName().c_str());
bot->logLastComMessage(theClient, Message);
return;
} //UNSUSPENDCommand::Exec
} //namespace cf
} //namespace gnuworld
+95
View File
@@ -0,0 +1,95 @@
/**
* USERSCORESCommand.cc
*
* 03/06/2006 - Wouter Coekaerts <wouter@coekaerts.be>
* Initial Version
*
* Shows all the channels that <user> has a score in
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: USERSCORESCommand.cc,v 1.3 2010/03/04 04:24:11 hidden1 Exp $
*/
#include <sstream>
#include <vector>
#include "gnuworld_config.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlChanOp.h"
#include "sqlcfUser.h"
RCSTAG("$Id: USERSCORESCommand.cc,v 1.3 2010/03/04 04:24:11 hidden1 Exp $");
namespace gnuworld
{
namespace cf
{
void USERSCORESCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
sqlChanOp* curOp;
std::string firstop;
std::string lastop;
bool foundOne = false;
for (chanfix::sqlChanOpsType::iterator ptr = bot->sqlChanOps.begin();
ptr != bot->sqlChanOps.end(); ptr++) {
chanfix::sqlChanOpsType::mapped_type::iterator chanOp = ptr->second.find(st[1]);
if (chanOp != ptr->second.end()) {
if (!foundOne) {
// print header
foundOne = true;
bot->SendTo(theClient,
bot->getResponse(theUser,
language::userscores_header,
std::string("Channel Score -- Time first opped / Time last opped")).c_str());
}
curOp = chanOp->second;
firstop = bot->tsToDateTime(curOp->getTimeFirstOpped(), false);
lastop = bot->tsToDateTime(curOp->getTimeLastOpped(), true);
bot->SendTo(theClient, "%s %d -- %s / %s", ptr->first.c_str(),
(curOp->getPoints() + curOp->getBonus()), firstop.c_str(), lastop.c_str());
}
}
if (!foundOne) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::userscores_noscore,
std::string("Account %s doesn't have any scores in the database.")).c_str(),
st[1].c_str());
}
bot->logAdminMessage("%s (%s) USERSCORES %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
st[1].c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+148
View File
@@ -0,0 +1,148 @@
/**
* USETCommand.cc
*
* 08/14/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Sets user <option> to value <value>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: USETCommand.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include <string>
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "chanfix.h"
#include "responses.h"
#include "sqlcfUser.h"
RCSTAG("$Id: USETCommand.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void USETCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
std::string option;
std::string value;
if (st.size() == 4) {
sqlcfUser* targetUser = bot->isAuthed(st[1]);
option = string_upper(st[2]);
value = string_upper(st[3]);
sqlcfUser::flagType requiredFlags;
if (option == "NEEDOPER") {
requiredFlags = sqlcfUser::F_USERMANAGER;
if (!theUser->getFlag(requiredFlags)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::requires_auth_and_flag,
std::string("This command requires authentication and flag '%c'.")).c_str(),
bot->getFlagChar(requiredFlags));
return;
}
if (value == "ON" || value == "YES" || value == "1") {
targetUser->setNeedOper(true);
bot->SendTo(theClient, "%s is now required to be an IRC Operator",
targetUser->getUserName().c_str());
targetUser->commit(bot->getLocalDBHandle());
return;
} else if (value == "OFF" || value == "NO" || value == "0") {
targetUser->setNeedOper(false);
bot->SendTo(theClient, "%s is now not required to be an IRC Operator",
targetUser->getUserName().c_str());
targetUser->commit(bot->getLocalDBHandle());
return;
} else {
bot->SendTo(theClient, "Please use USET <username> NEEDOPER <on/off>.");
return;
}
}
}
option = string_upper(st[1]);
value = string_upper(st[2]);
bot->logAdminMessage("%s (%s) USET %s %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
option.c_str(), value.c_str());
if (option == "NOTICE") {
if (value == "ON" || value == "YES" || value == "1") {
theUser->setNotice(true);
bot->SendTo(theClient,
bot->getResponse(theUser,
language::send_notices,
std::string("I will now send you notices.")).c_str());
theUser->commit(bot->getLocalDBHandle());
return;
} else if (value == "OFF" || value == "NO" || value == "0") {
theUser->setNotice(false);
bot->SendTo(theClient,
bot->getResponse(theUser,
language::send_privmsgs,
std::string("I will now send you privmsgs.")).c_str());
theUser->commit(bot->getLocalDBHandle());
return;
} else {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::uset_notice_on_off,
std::string("Please use USET NOTICE <on/off>.")).c_str());
return;
}
}
if (option == "LANG")
{
chanfix::languageTableType::iterator ptr = bot->languageTable.find(value);
if (ptr != bot->languageTable.end()) {
std::string lang = ptr->second.second;
theUser->setLanguageId(ptr->second.first);
theUser->commit(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::lang_set_to,
std::string("Language is set to %s.")).c_str(), lang.c_str());
return;
}
bot->SendTo(theClient, "ERROR: Invalid language selection.");
return;
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::setting_doesnt_exist,
std::string("This setting does not exist.")).c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} // namespace cf
} // namespace gnuworld
+87
View File
@@ -0,0 +1,87 @@
/**
* WHOFLAGCommand.cc
*
* 12/21/2006 - Jimmy Lipham <music0m@alltel.net>
* Initial Version
*
* Shows the number of opers/users with <flag>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: WHOFLAGCommand.cc,v 1.1 2006/12/22 03:11:44 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "Network.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
RCSTAG("");
namespace gnuworld
{
namespace cf
{
void WHOFLAGCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
char flag = st[1][0];
if (st[1].size() > 1) {
if (flag == '+')
flag = st[1][1];
else {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::one_flag_per_whoflag,
std::string("You may only WHOFLAG one flag.")).c_str());
return;
}
}
if (!bot->getFlagType(flag)) {
Usage(theClient);
return;
}
chanfix::usersIterator ptr = bot->usersMap_begin();
while (ptr != bot->usersMap_end()) {
sqlcfUser* tmpUser = ptr->second;
if (tmpUser->getFlag(bot->getFlagType(flag)))
bot->SendTo(theClient,
std::string("USER: %s FLAGS: %s GROUP: %s").c_str(),
tmpUser->getUserName().c_str(),
(tmpUser->getFlags()) ? std::string("+" + bot->getFlagsString(tmpUser->getFlags())).c_str() : "None",
tmpUser->getGroup().c_str());
ptr++;
}
bot->logAdminMessage("%s (%s) WHOFLAG %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
st[1].c_str());
bot->logLastComMessage(theClient, Message);
return;
}
} //namespace cf
} //namespace gnuworld
+140
View File
@@ -0,0 +1,140 @@
/**
* WHOSERVERCommand.cc
*
* 08/27/2005 - Reed Loden <reed@reedloden.com>
* Initial Version
*
* Shows all users in group <group>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: WHOGROUPCommand.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
RCSTAG("$Id: WHOGROUPCommand.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void WHOGROUPCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
bot->logAdminMessage("%s (%s) WHOGROUP %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
(st.size() > 1) ? st[1].c_str() : "");
if (st.size() == 1) {
/* No parameter supplied, so list all groups */
dbHandle* cacheCon = bot->getLocalDBHandle();
std::stringstream theQuery;
theQuery << "SELECT DISTINCT faction FROM users ORDER BY faction ASC";
if (!cacheCon->Exec(theQuery.str(),true)) {
elog << "chanfix::WHOGROUPCommand> SQL Error: "
<< cacheCon->ErrorMessage()
<< std::endl;
return;
}
// SQL query returned no errors
unsigned int numGroups = 0;
bot->SendTo(theClient,
bot->getResponse(theUser,
language::whogroup_list_groups,
std::string("List of all groups:")).c_str());
for (unsigned int i = 0 ; i < cacheCon->Tuples(); i++) {
bot->SendTo(theClient, cacheCon->GetValue(i, 0));
numGroups++;
}
/* Dispose of our connection instance */
//bot->theManager->removeConnection(cacheCon);
bot->SendTo(theClient,
bot->getResponse(theUser,
language::number_of_groups,
std::string("Number of groups: %d.")).c_str(),
numGroups);
return;
}
/* A serveradmin can only WHOGROUP on his/her own group. */
if (theUser->getFlag(sqlcfUser::F_SERVERADMIN) &&
!theUser->getFlag(sqlcfUser::F_USERMANAGER)) {
if (string_lower(st[1]) != theUser->getGroup()) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::whogroup_your_group,
std::string("You can only WHOGROUP on your group.")).c_str());
return;
}
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::users_with_group,
std::string("Users with group %s [username (flags)]:")).c_str(),
st[1].c_str());
std::string groupUsers;
unsigned int numUsersInGroup = 0;
chanfix::usersIterator ptr = bot->usersMap_begin();
while (ptr != bot->usersMap_end()) {
sqlcfUser* tmpUser = ptr->second;
if (tmpUser->getGroup() == string_lower(st[1])) {
if (numUsersInGroup++ && !groupUsers.empty())
groupUsers += " ";
groupUsers += tmpUser->getUserName();
groupUsers += " (+";
groupUsers += (tmpUser->getFlags()) ? bot->getFlagsString(tmpUser->getFlags()) : "";
groupUsers += ")";
if (groupUsers.size() > 460) {
bot->SendTo(theClient, "%s", groupUsers.c_str());
groupUsers.erase();
}
}
ptr++;
}
if (!groupUsers.empty())
bot->SendTo(theClient, "%s", groupUsers.c_str());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::number_of_users,
std::string("Number of users: %d.")).c_str(),
numUsersInGroup);
bot->logLastComMessage(theClient, Message);
return;
} //WHOGROUPCommand::Exec
} //namespace cf
} //namespace gnuworld
+182
View File
@@ -0,0 +1,182 @@
/**
* WHOISCommand.cc
*
* 08/07/2005 - Jimmy Lipham <music0m@alltel.net>
* Initial Version
*
* Shows information about this user
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: WHOISCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "Network.h"
#include "chanfix.h"
#include "responses.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
RCSTAG("$Id: WHOISCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $");
namespace gnuworld
{
namespace cf
{
void WHOISCommand::Exec(iClient* theClient, sqlcfUser* theUser, const std::string& Message)
{
StringTokenizer st(Message);
bot->logAdminMessage("%s (%s) WHOIS %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
theClient->getRealNickUserHost().c_str(),
st[1].c_str());
if (st[1] == "*") {
unsigned int numUsers = 0;
bot->SendTo(theClient,
bot->getResponse(theUser,
language::list_of_all_users,
std::string("List of all users:")).c_str());
chanfix::usersIterator ptr = bot->usersMap_begin();
while (ptr != bot->usersMap_end()) {
sqlcfUser* tmpUser = ptr->second;
bot->SendTo(theClient,
bot->getResponse(theUser,
language::user_flags_group,
std::string("User: %s, Flags: %s, Group: %s")).c_str(),
tmpUser->getUserName().c_str(),
(tmpUser->getFlags()) ? std::string("+" + bot->getFlagsString(tmpUser->getFlags())).c_str() : "None",
tmpUser->getGroup().c_str());
ptr++;
numUsers++;
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::number_of_users,
std::string("Number of users: %d.")).c_str(),
numUsers);
return;
}
sqlcfUser* theUser2 = bot->isAuthed(st[1]);
const char* username = st[1].c_str();
if (username[0] == '=') {
/* Skip the '='. */
++username;
iClient* theClient2 = Network->findNick(username);
if (theClient2)
theUser2 = bot->isAuthed(theClient2->getAccount());
}
if (!theUser2)
{
bot->SendTo(theClient,
bot->getResponse(theUser,
language::no_such_user,
std::string("No such user %s.")).c_str(),
username);
return;
}
bot->SendTo(theClient, "*** \002%s\002 ***", theUser2->getUserName().c_str());
if (theUser2->getIsSuspended())
bot->SendTo(theClient,
bot->getResponse(theUser,
language::whois_suspended,
std::string("--SUSPENDED--")).c_str());
if (!theUser2->getFlags())
bot->SendTo(theClient,
bot->getResponse(theUser,
language::whois_flags_none,
std::string("Flags: none.")).c_str());
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::whois_flags,
std::string("Flags: +%s")).c_str(),
bot->getFlagsString(theUser2->getFlags()).c_str());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::whois_group,
std::string("Group: %s")).c_str(),
theUser2->getGroup().c_str());
std::string langName = "Unknown";
std::string langCode = "UN";
for( chanfix::languageTableType::iterator ptr = bot->languageTable.begin() ;
ptr != bot->languageTable.end() ; ++ptr )
{
if ((unsigned int)ptr->second.first == theUser2->getLanguageId())
{
langName = ptr->second.second;
langCode = ptr->first;
break;
}
}
bot->SendTo(theClient,
bot->getResponse(theUser,
language::whois_lang,
std::string("Language: %s (%s)")).c_str(),
langName.c_str(), langCode.c_str());
if (theUser2->getNeedOper())
bot->SendTo(theClient,
bot->getResponse(theUser,
language::whois_needoper_yes,
std::string("NeedOper: Yes")).c_str());
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::whois_needoper_no,
std::string("NeedOper: No")).c_str());
if (theUser != theUser2) {
if (theUser2->getLastSeen() > 0)
bot->SendTo(theClient,
bot->getResponse(theUser,
language::whois_lastused,
std::string("Last used the service: %s ago")).c_str(),
bot->prettyDuration(theUser2->getLastSeen()).c_str());
else
bot->SendTo(theClient,
bot->getResponse(theUser,
language::whois_lastused_never,
std::string("Last used the service: Never")).c_str());
}
if (st.size() > 2 && string_upper(st[2]) == "-MODIF")
bot->SendTo(theClient,
bot->getResponse(theUser,
language::whois_modif,
std::string("Last modified: %s (%s ago)")).c_str(),
theUser2->getLastUpdatedBy().c_str(),
bot->prettyDuration(theUser2->getLastUpdated()).c_str());
bot->logLastComMessage(theClient, Message);
return;
} //WHOISCommand::Exec
} //namespace cf
} //namespace gnuworld
+25
View File
@@ -0,0 +1,25 @@
dnl @synopsis AC_CXX_NAMESPACES
dnl
dnl If the compiler can prevent names clashes using namespaces, define
dnl HAVE_NAMESPACES.
dnl
dnl @category Cxx
dnl @author Todd Veldhuizen
dnl @author Luc Maisonobe <luc@spaceroots.org>
dnl @version 2004-02-04
dnl @license AllPermissive
AC_DEFUN([AC_CXX_NAMESPACES],
[AC_CACHE_CHECK(whether the compiler implements namespaces,
ac_cv_cxx_namespaces,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}],
[using namespace Outer::Inner; return i;],
ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no)
AC_LANG_RESTORE
])
if test "$ac_cv_cxx_namespaces" = yes; then
AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces])
fi
])
+7191
View File
File diff suppressed because it is too large. Load diff
+7
View File
@@ -0,0 +1,7 @@
#! /bin/sh
aclocal -I .
autoheader -Wall
automake -a --gnu Makefile
autoconf -Wall
+48
View File
@@ -0,0 +1,48 @@
dnl @synopsis AX_BOOST_THREAD
dnl
dnl This macro checks to see if the Boost.Thread library is installed.
dnl It also attempts to guess the currect library name using several
dnl attempts. It tries to build the library name using a user supplied
dnl name or suffix and then just the raw library.
dnl
dnl If the library is found, HAVE_BOOST_THREAD is defined and
dnl BOOST_THREAD_LIB is set to the name of the library.
dnl
dnl This macro calls AC_SUBST(BOOST_THREAD_LIB).
dnl
dnl @category InstalledPackages
dnl @author Michael Tindal <mtindal@paradoxpoint.com>
dnl @version 2004-09-20
dnl @license GPLWithACException
AC_DEFUN([AX_BOOST_THREAD],
[AC_REQUIRE([AC_CXX_NAMESPACES])dnl
AC_CACHE_CHECK(whether the Boost::Thread library is available,
ax_cv_boost_thread,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
CXXFLAGS_SAVE=$CXXFLAGS
dnl FIXME: need to include a generic way to check for the flag
dnl to turn on threading support.
CXXFLAGS="-pthread $CXXFLAGS"
AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[#include <boost/thread/thread.hpp>]],
[[boost::thread_group thrds; return 0;]]),
ax_cv_boost_thread=yes, ax_cv_boost_thread=no)
CXXFLAGS=$CXXFLAGS_SAVE
AC_LANG_RESTORE
])
if test "$ax_cv_boost_thread" = yes; then
AC_DEFINE(HAVE_BOOST_THREAD,,[define if the Boost::Thread library is available])
dnl Now determine the appropriate file names
AC_ARG_WITH([boost-thread],AS_HELP_STRING([--with-boost-thread],
[specify the boost thread library or suffix to use]),
[if test "x$with_boost_thread" != "xno"; then
ax_thread_lib=$with_boost_thread
ax_boost_thread_lib=boost_thread-$with_boost_thread
fi])
for ax_lib in $ax_thread_lib $ax_boost_thread_lib boost_thread; do
AC_CHECK_LIB($ax_lib, main, [BOOST_THREAD_LIB=-l$ax_lib break])
done
AC_SUBST(BOOST_THREAD_LIB)
fi
])dnl
+173
View File
@@ -0,0 +1,173 @@
dnl @synopsis AX_PREFIX_CONFIG_H [(OUTPUT-HEADER [,PREFIX [,ORIG-HEADER]])]
dnl
dnl This is a new variant from ac_prefix_config_ this one will use a
dnl lowercase-prefix if the config-define was starting with a
dnl lowercase-char, e.g. "#define const", "#define restrict", or
dnl "#define off_t", (and this one can live in another directory, e.g.
dnl testpkg/config.h therefore I decided to move the output-header to
dnl be the first arg)
dnl
dnl takes the usual config.h generated header file; looks for each of
dnl the generated "#define SOMEDEF" lines, and prefixes the defined
dnl name (ie. makes it "#define PREFIX_SOMEDEF". The result is written
dnl to the output config.header file. The PREFIX is converted to
dnl uppercase for the conversions.
dnl
dnl Defaults:
dnl
dnl OUTPUT-HEADER = $PACKAGE-config.h
dnl PREFIX = $PACKAGE
dnl ORIG-HEADER, from AM_CONFIG_HEADER(config.h)
dnl
dnl Your configure.ac script should contain both macros in this order,
dnl and unlike the earlier variations of this prefix-macro it is okay
dnl to place the AX_PREFIX_CONFIG_H call before the AC_OUTPUT
dnl invokation.
dnl
dnl Example:
dnl
dnl AC_INIT(config.h.in) # config.h.in as created by "autoheader"
dnl AM_INIT_AUTOMAKE(testpkg, 0.1.1) # makes #undef VERSION and PACKAGE
dnl AM_CONFIG_HEADER(config.h) # prep config.h from config.h.in
dnl AX_PREFIX_CONFIG_H(mylib/_config.h) # prep mylib/_config.h from it..
dnl AC_MEMORY_H # makes "#undef NEED_MEMORY_H"
dnl AC_C_CONST_H # makes "#undef const"
dnl AC_OUTPUT(Makefile) # creates the "config.h" now
dnl # and also mylib/_config.h
dnl
dnl if the argument to AX_PREFIX_CONFIG_H would have been omitted then
dnl the default outputfile would have been called simply
dnl "testpkg-config.h", but even under the name "mylib/_config.h" it
dnl contains prefix-defines like
dnl
dnl #ifndef TESTPKG_VERSION
dnl #define TESTPKG_VERSION "0.1.1"
dnl #endif
dnl #ifndef TESTPKG_NEED_MEMORY_H
dnl #define TESTPKG_NEED_MEMORY_H 1
dnl #endif
dnl #ifndef _testpkg_const
dnl #define _testpkg_const _const
dnl #endif
dnl
dnl and this "mylib/_config.h" can be installed along with other
dnl header-files, which is most convenient when creating a shared
dnl library (that has some headers) where some functionality is
dnl dependent on the OS-features detected at compile-time. No need to
dnl invent some "mylib-confdefs.h.in" manually. :-)
dnl
dnl Note that some AC_DEFINEs that end up in the config.h file are
dnl actually self-referential - e.g. AC_C_INLINE, AC_C_CONST, and the
dnl AC_TYPE_OFF_T say that they "will define inline|const|off_t if the
dnl system does not do it by itself". You might want to clean up about
dnl these - consider an extra mylib/conf.h that reads something like:
dnl
dnl #include <mylib/_config.h>
dnl #ifndef _testpkg_const
dnl #define _testpkg_const const
dnl #endif
dnl
dnl and then start using _testpkg_const in the header files. That is
dnl also a good thing to differentiate whether some library-user has
dnl starting to take up with a different compiler, so perhaps it could
dnl read something like this:
dnl
dnl #ifdef _MSC_VER
dnl #include <mylib/_msvc.h>
dnl #else
dnl #include <mylib/_config.h>
dnl #endif
dnl #ifndef _testpkg_const
dnl #define _testpkg_const const
dnl #endif
dnl
dnl @category Misc
dnl @author Guido Draheim <guidod@gmx.de>
dnl @author Mårten Svantesson <msv@kth.se>
dnl @version 2005-06-08
dnl @license GPLWithACException
AC_DEFUN([AX_PREFIX_CONFIG_H],[AC_REQUIRE([AC_CONFIG_HEADER])
AC_CONFIG_COMMANDS([ifelse($1,,$PACKAGE-config.h,$1)],[dnl
AS_VAR_PUSHDEF([_OUT],[ac_prefix_conf_OUT])dnl
AS_VAR_PUSHDEF([_DEF],[ac_prefix_conf_DEF])dnl
AS_VAR_PUSHDEF([_PKG],[ac_prefix_conf_PKG])dnl
AS_VAR_PUSHDEF([_LOW],[ac_prefix_conf_LOW])dnl
AS_VAR_PUSHDEF([_UPP],[ac_prefix_conf_UPP])dnl
AS_VAR_PUSHDEF([_INP],[ac_prefix_conf_INP])dnl
m4_pushdef([_script],[conftest.prefix])dnl
m4_pushdef([_symbol],[m4_cr_Letters[]m4_cr_digits[]_])dnl
_OUT=`printf '%s\n' ifelse($1, , $PACKAGE-config.h, $1)`
_DEF=`printf '%s\n' _$_OUT | sed -e "y:m4_cr_letters:m4_cr_LETTERS[]:" -e "s/@<:@^m4_cr_Letters@:>@/_/g"`
_PKG=`printf '%s\n' ifelse($2, , $PACKAGE, $2)`
_LOW=`printf '%s\n' _$_PKG | sed -e "y:m4_cr_LETTERS-:m4_cr_letters[]_:"`
_UPP=`printf '%s\n' $_PKG | sed -e "y:m4_cr_letters-:m4_cr_LETTERS[]_:" -e "/^@<:@m4_cr_digits@:>@/s/^/_/"`
_INP=`printf '%s\n' "ifelse($3,,,$3)" | sed -e 's/ *//'`
if test ".$_INP" = "."; then
for ac_file in : $CONFIG_HEADERS; do test "_$ac_file" = _: && continue
case "$ac_file" in
*.h) _INP=$ac_file ;;
*)
esac
test ".$_INP" != "." && break
done
fi
if test ".$_INP" = "."; then
case "$_OUT" in
*/*) _INP=`basename "$_OUT"`
;;
*-*) _INP=`printf '%s\n' "$_OUT" | sed -e "s/@<:@_symbol@:>@*-//"`
;;
*) _INP=config.h
;;
esac
fi
if test -z "$_PKG" ; then
AC_MSG_ERROR([no prefix for _PREFIX_PKG_CONFIG_H])
else
if test ! -f "$_INP" ; then if test -f "$srcdir/$_INP" ; then
_INP="$srcdir/$_INP"
fi fi
AC_MSG_NOTICE(creating $_OUT - prefix $_UPP for $_INP defines)
if test -f $_INP ; then
printf '%s\n' "s/@%:@undef *\\(@<:@m4_cr_LETTERS[]_@:>@\\)/@%:@undef $_UPP""_\\1/" > _script
printf '%s\n' "s/@%:@undef *\\(@<:@m4_cr_letters@:>@\\)/@%:@undef $_LOW""_\\1/" >> _script
printf '%s\n' "s/@%:@def[]ine *\\(@<:@m4_cr_LETTERS[]_@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_UPP""_\\1 \\" >> _script
printf '%s\n' "@%:@def[]ine $_UPP""_\\1 \\2 \\" >> _script
printf '%s\n' "@%:@endif/" >>_script
printf '%s\n' "s/@%:@def[]ine *\\(@<:@m4_cr_letters@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_LOW""_\\1 \\" >> _script
printf '%s\n' "@%:@define $_LOW""_\\1 \\2 \\" >> _script
printf '%s\n' "@%:@endif/" >> _script
# now executing _script on _DEF input to create _OUT output file
printf '%s\n' "@%:@ifndef $_DEF" >$tmp/pconfig.h
printf '%s\n' "@%:@def[]ine $_DEF 1" >>$tmp/pconfig.h
printf '%s\n' ' ' >>$tmp/pconfig.h
printf '%s\n' /'*' $_OUT. Generated automatically at end of configure. '*'/ >>$tmp/pconfig.h
sed -f _script $_INP >>$tmp/pconfig.h
printf '%s\n' ' ' >>$tmp/pconfig.h
printf '%s\n' '/* once:' $_DEF '*/' >>$tmp/pconfig.h
printf '%s\n' "@%:@endif" >>$tmp/pconfig.h
if cmp -s $_OUT $tmp/pconfig.h 2>/dev/null; then
AC_MSG_NOTICE([$_OUT is unchanged])
else
ac_dir=`AS_DIRNAME(["$_OUT"])`
AS_MKDIR_P(["$ac_dir"])
rm -f "$_OUT"
mv $tmp/pconfig.h "$_OUT"
fi
cp _script _configs.sed
else
AC_MSG_ERROR([input file $_INP does not exist - skip generating $_OUT])
fi
rm -f conftest.*
fi
m4_popdef([_symbol])dnl
m4_popdef([_script])dnl
AS_VAR_POPDEF([_INP])dnl
AS_VAR_POPDEF([_UPP])dnl
AS_VAR_POPDEF([_LOW])dnl
AS_VAR_POPDEF([_PKG])dnl
AS_VAR_POPDEF([_DEF])dnl
AS_VAR_POPDEF([_OUT])dnl
],[PACKAGE="$PACKAGE"])])
File diff suppressed because it is too large. Load diff
+163
View File
@@ -0,0 +1,163 @@
# $Id: chanfix.example.conf.in,v 1.5 2006/12/09 00:29:19 buzlip01 Exp $
# chanfix configuration file
# ---------------------------------------------------------------------
# Nickname of bot
nickname = C
# Username of bot
username = chanfix
# Hostname of bot
hostname = evilnet.development
# Real name (info) of bot
userdescription = Oooh! Oooh! I can fix it!
# User modes bot should set
mode = +idk
# ---------------------------------------------------------------------
# Database specifications
# Host and port of database
sqlHost = 127.0.0.1
sqlPort = 5432
# Name of database
sqlDB = chanfix
# If you don't need user/pass just put "" for option(s) below
sqlcfUser = evilnet
sqlPass = ""
# ---------------------------------------------------------------------
# Channels the bot should join
# Console channel name and initial modes
consoleChan = #coder-com
consoleChanModes = +nst
# Should the bot relay admin messages to the console channel?
# NOTE: This only disables relaying information sent to the
# adminLog. debugLog information is *always* relayed.
sendConsoleNotices = true
# Channel(s) that chanfix should join besides consoleChan (can be multiple)
joinChan = #chanfix
joinChan = #staff
# Initial modes all joinChans should have
joinChanModes = +nt
# ---------------------------------------------------------------------
# Fixing settings
# Should chanfix automatically fix opless channels?
enableAutoFix = true
# Should chanfix be able to manually fix channels?
enableChanFix = true
# Can channels be blocked by admins?
enableChannelBlocking = true
# Should chanfix join the channel its fixing? this avoids the hopping issue
joinChannels = true
# Should chanfix send notices saying the channel is being fixed for auto
# fixes. Also a notice after its finished saying its done?
autoFixNotice = true
# Should chanfix send notices saying the channel is being fixed for manual
# fixes Also a notice after its finished saying its done?
manualFixNotice = true
# Should auto fixes stop if an already reopped user ops another user?
stopAutoFixOnOp = true
# Should manual fixes stop if an already reopped user ops another user?
stopChanFixOnOp = true
# Should the top ops be allowed to perform fixes on their own channels?
allowTopOpFix = false
# Should the top op fixes be able to alert the top 10 ops who are not in
# the channel at the time of the fix automatically? If no/false then the
# database help entry for REQUESTOP will need to be updated.
allowTopOpAlert = true
# How much percentage within the top score should the top ops score be
# before they are allowed to perform fixes. Dont include a %.
topOpPercent = 10
# Minimum score an op has be before they can issue fixes in their own
# channel without requiring an oper to do them.
minFixScore = 1000
# Minimum score an op has to be before they can use the CANFIX command for
# a channel they are ops in.
minCanFixScore = 500
# Minimum time required between REQUESTOP fixes. (In seconds). The last
# fix time is updated at the start of a fix so allow time for the first
# fix aswell as time for a gap.
minRequestOpTime = 720
# ---------------------------------------------------------------------
# Network settings
# Version of IRCu used on the network (11 or 12)
# Use 11 for u2.10.11 and 12 for u2.10.12
# NOTE: You MUST restart GNUWorld for this change to take place.
version = 12
# Should burst be used to fix takeovers (through a manual fix)?
# Burst guarantees that the abusers will not be reopped due to
# a netsplit, but it can cause problems due to lowering timestamp.
# NOTE: You MUST restart GNUWorld for this change to take place.
useBurstToFix = true
# Total number of servers on the network
numServers = 10
# The minimum percentage of servers that need to be linked;
# if there are fewer servers linked, chanfix will not fix
# any channels, be it automatic or manual.
minServersPresent = 75
# The full server name of the channel service. This is used in
# checking whether the channel service is currently linked or
# not to the network.
chanServName = channels.undernet.org
# ---------------------------------------------------------------------
# Interface settings
# The amount of scores to report when issuing the SCORE #channel
# command. Do not set this to a higher value than 10.
numTopScores = 10
# ---------------------------------------------------------------------
# Database settings
# Minimum clients needed in a channel for it to be scored
minClients = 4
# Which clients score a point if they are opped?
# Client needs to be idented (no ~ before username)
clientNeedsIdent = false
# ---------------------------------------------------------------------
# Miscellaneous settings
# Frequency (in seconds) between database connection status checks
connectCheckFreq = 10
# File where all admin commands sent to backchan are logged and saved
adminLogFile = chanfix-admin.log
# File where all debug information sent to backchan is logged and saved
debugLogFile = chanfix-debug.log
# End of config file.
# ---------------------------------------------------------------------
+581
View File
@@ -0,0 +1,581 @@
/**
* chanfix.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: chanfix.h,v 1.10 2010/03/04 04:24:12 hidden1 Exp $
*/
#ifndef __CHANFIX_H
#define __CHANFIX_H "$Id: chanfix.h,v 1.10 2010/03/04 04:24:12 hidden1 Exp $"
#include <string>
#include <vector>
#include <map>
#include <list>
#include <sstream>
#include "client.h"
#include "EConfig.h"
#include "ELog.h"
#include "Timer.h"
#include "chanfixCommands.h"
#include "chanfix_config.h"
#include "sqlChannel.h"
/* This must be declared before sqlChanOp.h is #include'd */
namespace gnuworld
{
namespace cf
{
extern short currentDay;
}
}
#include "sqlChanOp.h"
#include "sqlManager.h"
#include "sqlcfUser.h"
namespace gnuworld
{
class Timer;
namespace cf
{
class chanfix : public xClient {
public:
/**
* Current network state.
*/
enum STATE {
BURST,
RUN,
SPLIT,
INIT
};
/**
* Constructor receives a configuration file name.
*/
chanfix( const std::string& ) ;
/**
* Destructor does normal stuff.
*/
virtual ~chanfix() ;
virtual void OnTimer(const gnuworld::xServer::timerID&, void*) ;
/**
* This method is called when a network client sends
* a private message (PRIVMSG or NOTICE) to this xClient.
* The first argument is a pointer to the source client,
* and the second argument is the actual message (minus
* all of the server command stuff).
*/
virtual void OnPrivateMessage( iClient*, const std::string&,
bool secure = false ) ;
/**
* This method is called by the server when a server connection
* is established. The purpose of this method is to inform
* the xServer of the channels this client wishes to burst.
*/
virtual void BurstChannels() ;
/**
* This method is invoked when the server has been requested
* to shutdown. If currently connected to the network, this
* method gives xClient's a chance to gracefully QUIT from
* the network, or whatever other processing is useful.
* To force data to be written before final shutdown (again,
* if connected), set xServer::FlushData().
* Timers will be executed after this method is invoked, once,
* depending upon target time of course :)
*/
virtual void OnShutdown( const std::string& reason ) ;
/**
* This method is invoked when this module is first loaded.
* This is a good place to setup timers, connect to DB, etc.
* At this point, the server may not yet be connected to the
* network, so please do not issue join/nick requests.
*/
virtual void OnAttach() ;
/**
* This method is called when this module is being unloaded from
* the server. This is a good place to cleanup, including
* deallocating timers, closing connections, closing log files,
* and deallocating private data stored in iClients.
*/
virtual void OnDetach( const std::string& =
std::string( "Shutting down" ) ) ;
/**
* This method is called when the server connects to the network.
* Note that if this module is attached while already connected
* to a network, this method is still invoked.
*/
virtual void OnConnect() ;
/**
* This method is invoked when the server disconnects from
* its uplink.
*/
virtual void OnDisconnect() ;
/**
* This method will register a given command handler, removing
* (and deallocating) the existing handler for this command,
* should one exist.
*/
virtual bool RegisterCommand( Command* ) ;
/**
* This method will unregister the command handler for the command
* of the given command name, deallocating the object from the
* heap as well.
*/
virtual bool UnRegisterCommand( const std::string& ) ;
/**
* This method is invoked each time a channel event occurs
* for one of the channels for which this client has registered
* to receive channel events.
*/
virtual void OnChannelEvent( const channelEventType&, Channel*,
void* data1 = 0, void* data2 = 0,
void* data3 = 0, void* data4 = 0 ) ;
/**
* This method is invoked when a user sets or removes
* one or more channel mode (o). Keep in mind that the
* source ChannelUser may be NULL if a server is
* setting the mode.
*/
virtual void OnChannelModeO( Channel*, ChannelUser*,
const xServer::opVectorType& ) ;
/**
* This method is invoked each time a network event occurs.
*/
virtual void OnEvent( const eventType& theEvent,
void* data1 = 0, void* data2 = 0,
void* data3 = 0, void* data4 = 0 ) ;
virtual void OnCTCP( iClient*, const std::string&, const std::string&, bool ) ;
virtual void OnSignal( int sig ) ;
/**
* Our functions.
*/
void readConfigFile(const std::string&);
sqlChanOp* newChanOp(const std::string&, const std::string&);
sqlChanOp* newChanOp(Channel*, iClient*);
sqlChanOp* findChanOp(const std::string&, const std::string&);
sqlChanOp* findChanOp(Channel*, iClient*);
dbHandle* getLocalDBHandle() { return localDBHandle; }
size_t countMyOps(const std::string&);
size_t countMyOps(Channel*);
sqlcfUser* isAuthed(const std::string);
void precacheChanOps();
void precacheChannels();
void precacheUsers();
void printResourceStats();
void changeState(STATE);
time_t currentTime() { return ::time(0); }
time_t getSecsTilMidnight() { return 86400 - (currentTime() % 86400); }
size_t countAutoFixes() { return autoFixQ.size(); }
size_t countManFixes() { return manFixQ.size(); }
void updatePoints();
void giveAllOpsPoints();
void givePoints(Channel*, iClient*);
void gotOpped(Channel*, iClient*);
bool hasIdent(iClient*);
void JoinChan(Channel* theChan);
void PartChan(Channel* theChan);
void checkNetwork();
void checkChannelServiceLink(iServer*, const eventType&);
void findChannelService();
const int getLastFix(sqlChannel*);
void insertop(sqlChanOp*, sqlChannel*);
bool findop(sqlChanOp*, sqlChannel*);
void removechan(sqlChannel*);
bool simFix(sqlChannel*, bool, time_t, iClient*, sqlcfUser*);
bool simulateFix(sqlChannel*, bool, iClient*, sqlcfUser*);
bool shouldCJoin(sqlChannel*, bool);
void autoFix();
void manualFix(Channel*);
bool logLastComMessage(iClient*, const std::string&);
bool msgTopOps(Channel*);
bool fixChan(sqlChannel*, bool);
void stopFixingChan(Channel*, bool);
bool accountIsOnChan(const std::string&, const std::string&);
sqlChannel* getChannelRecord(const std::string&);
sqlChannel* getChannelRecord(Channel*);
sqlChannel* newChannelRecord(const std::string&);
sqlChannel* newChannelRecord(Channel*);
bool deleteChannelRecord(sqlChannel*);
static size_t countChanOps(const Channel*);
bool needsModesRemoved(Channel*);
bool canScoreChan(Channel*);
void startTimers();
void processQueue();
void rotateDB();
void expireTempBlocks();
void prepareUpdate(bool);
void updateDB();
#ifdef ENABLE_NEWSCORES
int getNewScore(sqlChanOp*, time_t);
#endif
bool isBeingFixed(Channel*);
bool isBeingAutoFixed(Channel*);
bool isBeingChanFixed(Channel*);
bool isTempBlocked(const std::string&);
bool removeFromAutoQ(Channel*);
bool removeFromManQ(Channel*);
char getFlagChar(const sqlcfUser::flagType&);
const std::string getFlagsString(const sqlcfUser::flagType&);
sqlcfUser::flagType getFlagType(const char);
const std::string getEventName(const int);
const std::string prettyDuration( int );
const std::string tsToDateTime(time_t, bool);
const std::string getHostList( sqlcfUser* );
const std::string getChanNickName(const std::string&, const std::string&);
const int getCurrentGMTHour(); /* returns the current hour in GMT (00-23) */
char *convertToAscTime(time_t);
/* Server notices */
bool serverNotice( Channel*, const char*, ... );
bool serverNotice( Channel*, const std::string& );
/*
* Send private messages or notices to authenticated users
* By default, send notices
*/
void SendTo( iClient*, const char*, ... );
void SendTo( iClient*, const std::string& );
void SendFmtTo(iClient*, const std::string&);
/* Admin message logs */
bool logAdminMessage(const char*, ... );
bool logDebugMessage(const char*, ... );
void doSqlError(const std::string&, const std::string&);
/**
* Our sqlManager instance for DB communication
*/
sqlManager* theManager;
/**
* Commands map
*/
typedef std::map <std::string, Command*, noCaseCompare> commandMapType;
commandMapType commandMap;
/**
* ChannelOp map
*/
// map contents: channel string (account string, sqlChanOp object)
typedef std::map <std::string, std::map <std::string, sqlChanOp*, noCaseCompare>, noCaseCompare> sqlChanOpsType;
sqlChanOpsType sqlChanOps;
typedef std::map <std::string, sqlChannel*, noCaseCompare> sqlChannelCacheType;
sqlChannelCacheType sqlChanCache;
typedef std::set <std::string> clientOpsType;
clientOpsType* findMyOps(iClient*);
void lostOp(const std::string&, iClient*, clientOpsType*);
typedef std::list <sqlChanOp*> chanOpsType;
chanOpsType getMyOps(Channel*);
chanOpsType getMyOps(const std::string&);
chanOpsType getMyOps(const std::string&, bool);
typedef std::map <std::string, time_t, noCaseCompare> tempBlockType;
tempBlockType tempBlockList;
typedef struct {
std::string account;
std::string channel;
} simOppedStruct;
typedef std::multimap<std::string, simOppedStruct> SimMapType;
SimMapType simMap;
/**
* The snapshot map for updating the SQL database
*/
typedef struct {
std::string account;
std::string lastSeenAs;
time_t firstOpped;
time_t lastOpped;
short day[DAYSAMPLES];
} snapShotStruct;
typedef std::multimap<std::string, snapShotStruct> DBMapType;
DBMapType snapShot;
/**
* The db clients map
*/
typedef std::map <std::string, sqlcfUser*, noCaseCompare> usersMapType;
/**
* Holds the authenticated user list
*/
usersMapType usersMap;
typedef usersMapType::iterator usersIterator;
usersIterator usersMap_begin()
{ return usersMap.begin(); }
usersIterator usersMap_end()
{ return usersMap.end(); }
/**
* Channels that chanfix should join
*/
typedef std::vector <std::string> joinChansType;
joinChansType chansToJoin;
/**
* Queues to process.
*/
typedef std::map <std::string, time_t, noCaseCompare> fixQueueType;
fixQueueType autoFixQ;
fixQueueType manFixQ;
typedef std::vector< iClient* > acctListType; //For reopping all logged in users to an acct.
acctListType findAccount(Channel*, const std::string&);
typedef std::map < std::pair <int, std::string>, std::string > helpTableType;
helpTableType helpTable;
void loadHelpTable();
const std::string getHelpMessage(sqlcfUser*, std::string);
typedef std::map < std::string, std::pair <int, std::string> > languageTableType;
languageTableType languageTable;
typedef std::map < std::pair <int, int>, std::string > translationTableType ;
translationTableType translationTable;
typedef std::map < std::string, std::list< iClient* >, noCaseCompare > authMapType;
authMapType authMap;
void loadTranslationTable();
const std::string getResponse(sqlcfUser*, int, std::string = std::string());
/**
* Configuration variables
*/
std::string consoleChan;
std::string consoleChanModes;
bool sendConsoleNotices;
std::string joinChanModes;
bool enableAutoFix;
bool enableChanFix;
bool enableChannelBlocking;
bool joinChannels;
bool autoFixNotice;
bool manualFixNotice;
bool stopAutoFixOnOp;
bool stopChanFixOnOp;
bool allowTopOpFix;
bool allowTopOpAlert;
int topOpPercent;
int minFixScore;
int minCanFixScore;
int minRequestOpTime;
unsigned int version;
bool useBurstToFix;
unsigned int nextFix;
unsigned int numServers;
unsigned int minServersPresent;
std::string chanServName;
unsigned int numTopScores;
unsigned int minClients;
bool clientNeedsIdent;
unsigned int connectCheckFreq;
std::string adminLogFile;
std::string debugLogFile;
std::string sqlHost;
std::string sqlPort;
std::string sqlcfUsername;
std::string sqlPass;
std::string sqlDB;
protected:
/**
* Configuration file.
*/
EConfig* chanfixConfig;
/**
* State variable
*/
STATE currentState;
/**
* Channel service currently linked variable
*/
bool chanServLinked;
/**
* Update status variable
*/
bool updateInProgress;
/**
* Timer declarations
*/
xServer::timerID tidCheckDB;
xServer::timerID tidAutoFix;
xServer::timerID tidFixQ;
xServer::timerID tidGivePoints;
xServer::timerID tidRotateDB;
xServer::timerID tidUpdateDB;
xServer::timerID tidTempBlocks;
/**
* Internal timer
*/
Timer *theTimer;
/**
* Log-to-file streams
*/
std::ofstream adminLog;
std::ofstream debugLog;
/**
* DB Handle
*/
dbHandle* localDBHandle;
public:
/*
* Methods to get data attributes.
*/
bool doAutoFix() { return enableAutoFix; }
bool doChanFix() { return enableChanFix; }
bool doChanBlocking() { return enableChannelBlocking; }
bool doJoinChannels() { return joinChannels; }
bool doAutoFixNotice() { return autoFixNotice; }
bool doManualFixNotice() { return manualFixNotice; }
STATE getState() { return currentState; }
bool isChanServLinked() { return chanServLinked; }
bool isUpdateRunning() { return updateInProgress; }
bool isAllowingTopFix() { return allowTopOpFix; }
bool isAllowingTopOpAlert() { return allowTopOpAlert; }
unsigned int getTopOpPercent() { return topOpPercent; }
unsigned int getMinFixScore() { return minFixScore; }
unsigned int getMinCanFixScore() { return minCanFixScore; }
unsigned int getMinRequestOpTime() { return minRequestOpTime; }
unsigned int getNumServers() { return numServers; }
unsigned int getMinServersPresent() { return minServersPresent; }
unsigned int getNumTopScores() { return numTopScores; }
unsigned int getMinClients() { return minClients; }
unsigned int getNextFix() { return nextFix; }
short getCurrentDay() { return currentDay; }
/*
* Methods to set data attributes.
*/
inline void setNextFix(int _nextFix)
{ nextFix = _nextFix; }
inline void setNumServers(int _numServers)
{ numServers = _numServers; }
inline void setDoAutoFix(bool _enableAutoFix)
{ enableAutoFix = _enableAutoFix; }
inline void setDoChanFix(bool _enableChanFix)
{ enableChanFix = _enableChanFix; }
inline void setDoChanBlocking(bool _enableChannelBlocking)
{ enableChannelBlocking = _enableChannelBlocking; }
inline void setCurrentDay()
{ currentDay = currentTime() / 86400 % DAYSAMPLES; }
}; // class chanfix
const std::string escapeSQLChars(const std::string&);
bool atob(std::string);
} // namespace cf
} // namespace gnuworld
#endif // __CHANFIX_H
+153
View File
@@ -0,0 +1,153 @@
/**
* chanfixCommands.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: chanfixCommands.h,v 1.5 2006/12/22 03:00:02 buzlip01 Exp $
*/
#ifndef __CHANFIXCOMMANDS_H
#define __CHANFIXCOMMANDS_H "$Id: chanfixCommands.h,v 1.5 2006/12/22 03:00:02 buzlip01 Exp $"
namespace gnuworld {
namespace cf {
class chanfix;
class sqlcfUser;
class Command {
public:
Command( chanfix* _bot, const std::string& _commandName, const std::string& _help, std::string::size_type _numParams, unsigned short int _requiredFlags ) :
bot(_bot), server(0), commandName(_commandName), help(_help),
numParams(_numParams), requiredFlags(_requiredFlags)
{ }
virtual ~Command() { }
virtual void Exec(iClient*, sqlcfUser*, const std::string&) = 0;
void setServer(xServer *_server)
{ server = _server; }
virtual inline std::string getInfo() const
{ return commandName + ' ' + help; }
virtual void Usage(iClient*);
inline const std::string& getName() const
{ return commandName; }
inline const std::string& getHelp() const
{ return help; }
inline const std::string::size_type getNumParams() const
{ return numParams; }
inline const unsigned short int getRequiredFlags() const
{ return requiredFlags; }
protected:
chanfix *bot;
xServer *server;
std::string commandName;
std::string help;
std::string::size_type numParams;
unsigned short int requiredFlags;
};
#define DECLARE_COMMAND(commandName) \
class commandName##Command : public Command \
{ \
public: \
commandName##Command(chanfix* _bot, \
const std::string& _commandName, \
const std::string& _help, \
std::string::size_type _numParams, \
unsigned short int _requiredFlags) : \
Command(_bot, _commandName, _help, _numParams, _requiredFlags) {} \
virtual ~commandName##Command() {} \
virtual void Exec(iClient*, sqlcfUser*, const std::string&); \
};
/* Normal user commands */
DECLARE_COMMAND( CANFIX )
DECLARE_COMMAND( REQUESTOP )
/* Oper commands */
DECLARE_COMMAND( HELP )
DECLARE_COMMAND( HISTORY )
DECLARE_COMMAND( INFO )
DECLARE_COMMAND( SCORE )
DECLARE_COMMAND( STATUS )
/* Logged-in commands */
DECLARE_COMMAND( CHECK )
DECLARE_COMMAND( LISTHOSTS )
DECLARE_COMMAND( USERSCORES )
DECLARE_COMMAND( USET )
DECLARE_COMMAND( WHOIS )
DECLARE_COMMAND( WHOFLAG )
/* User management commands */
DECLARE_COMMAND( ADDFLAG )
DECLARE_COMMAND( ADDHOST )
DECLARE_COMMAND( ADDUSER )
DECLARE_COMMAND( DELFLAG )
DECLARE_COMMAND( DELHOST )
DECLARE_COMMAND( DELUSER )
DECLARE_COMMAND( SETGROUP )
DECLARE_COMMAND( SUSPEND )
DECLARE_COMMAND( UNSUSPEND )
DECLARE_COMMAND( WHOGROUP )
/* Block commands */
DECLARE_COMMAND( BLOCK )
DECLARE_COMMAND( UNBLOCK )
DECLARE_COMMAND( LISTBLOCKED )
DECLARE_COMMAND( TEMPBLOCK )
DECLARE_COMMAND( UNTEMPBLOCK )
DECLARE_COMMAND( LISTTEMPBLOCKED )
/* Comment commands */
DECLARE_COMMAND( ADDNOTE )
DECLARE_COMMAND( ALERT )
DECLARE_COMMAND( DELNOTE )
DECLARE_COMMAND( UNALERT )
/* Chanfix commands */
DECLARE_COMMAND( CHANFIX )
DECLARE_COMMAND( OPLIST )
DECLARE_COMMAND( OPNICKS )
DECLARE_COMMAND( SIMULATE )
/* Owner commands */
DECLARE_COMMAND( DEBUG )
DECLARE_COMMAND( INVITE )
DECLARE_COMMAND( LASTCOM )
DECLARE_COMMAND( QUOTE )
DECLARE_COMMAND( REHASH )
DECLARE_COMMAND( RELOAD )
DECLARE_COMMAND( SAY )
DECLARE_COMMAND( SET )
DECLARE_COMMAND( SHUTDOWN )
} // namespace cf
} // namespace gnuworld
#endif
+206
View File
@@ -0,0 +1,206 @@
/**
* chanfix_config.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: chanfix_config.h,v 1.7 2010/03/04 04:24:12 hidden1 Exp $
*/
#ifndef __CHANFIX_CONFIG_H
#define __CHANFIX_CONFIG_H "$Id: chanfix_config.h,v 1.7 2010/03/04 04:24:12 hidden1 Exp $"
#define CHANFIX_DEBUG 1
#define CHANFIX_VERSION "1.3"
/**
* Defines that deal with fixing channels, both manually and
* automatically. All the below times are in seconds.
*/
/**
* The time between consecutive attempts to fix an opless channel
*/
#define AUTOFIX_INTERVAL 600
/**
* The maximum time to try to fix an opless channel
*/
#define AUTOFIX_MAXIMUM 3600
/**
* The max number of clients opped by chanfix during an autofix.
*/
#define AUTOFIX_NUM_OPPED 5
/**
* The time to wait between the removal of modes and the first
* attempt to give ops to people.
*/
#define CHANFIX_DELAY 30
/**
* The time between consecutive attempts to manually fix a channel
*/
#define CHANFIX_INTERVAL 300
/**
* The maximum time to try to manually fix a channel
*/
#define CHANFIX_MAXIMUM 3600
/**
* The max number of clients opped by chanfix during a manual fix.
*/
#define CHANFIX_NUM_OPPED 5
/**
* Score values
* The first 2 values are the minimum scores required at the beginning
* of a chanfix; the last 2 values are the minimum scores at the very
* end of the fix. Between these times, there is a linear decrease from
* the high to the low values.
*/
/**
* Minimum absolute score required for chanfix to op, relative to
* the maximum score possible (default: 0.20 * 4032).
*/
#define FIX_MIN_ABS_SCORE_BEGIN 0.20
/**
* Minimum score required for chanfix to op, relative to the maximum
* score for this channel in the database, at the beginning of the
* fix.
*/
#define FIX_MIN_REL_SCORE_BEGIN 0.90
/**
* Minimum absolute score required for chanfix to op, relative to
* the maximum score possible (default: 0.04 * 4032).
*/
#define FIX_MIN_ABS_SCORE_END 0.04
/**
* Minimum score required for chanfix to op, relative to the maximum
* score for this channel in the database. So, if you have less than
* 30% of the maximum score, chanfix will never op you.
*/
#define FIX_MIN_REL_SCORE_END 0.30
/**
* Other various settings that really should not be changed.
*/
/**
* Interval between two consecutive points updates.
*/
#define POINTS_UPDATE_TIME 300
/**
* Interval between two consecutive checks of the time.
* How often should we check to see if its 00 GMT and rotate the DB
* (suggested hourly: 3600)
*/
#define DBROTATE_CHECK_TIME 3600
/**
* Interval between two consecutive SQL updates.
* Default: every 12 hours
*/
#define SQL_UPDATE_TIME 86400
/**
* Interval between two consecutive checks for opless channels.
*/
#define CHECK_CHANS_TIME 60
/**
* Interval between two consecutive processing of the queues.
*/
#define PROCESS_QUEUE_TIME 30
/**
* Interval between checks for expired tempblocks
*/
#define TEMPBLOCKS_CHECK_TIME 30
/**
* Duration that temp blocks should last
* (Default is 1hr 3600)
*/
#define TEMPBLOCK_DURATION_TIME 3600
/**
* Maximum score a client can obtain.
*/
//#define MAX_SCORE (static_cast<int>(DAYSAMPLES) * 86400 / POINTS_UPDATE_TIME)
#define MAX_SCORE 7032
/**
* The maximum number of days to keep track of per channel -1,
* e.g. a value of 15 means we track 14.00-14.99 days.
*/
#define DAYSAMPLES 14
/**
* The maximum number of top ops to return to the user on
* an OPLIST query. (default: 10)
*/
#define OPCOUNT 10
/**
* The maximum number of top ops to keep track of per channel.
* (default: 256)
*/
#define MAXOPCOUNT 256
/**
* The maximum number of notes allowed per channel.
* (default: 50)
*/
#define MAXNOTECOUNT 50
/**
* Do you want to remember (and never expire) old channel entries that
* have notes or flags associated with them?
*/
#define REMEMBER_CHANNELS_WITH_NOTES_OR_FLAGS
/**
* Should the QUOTE command be enabled?
* This command allows raw P10 traffic to be sent to the network.
*/
#define ENABLE_QUOTE
/**
* Should new scoring be enabled?
* NOTE: New scores weigh the time first opped into users scores
*/
#define ENABLE_NEWSCORES
/**
* Should host checking be enabled?
* NOTE: Host checking checks to make sure that the hosts assigned to staff accounts match before
* any staff command can be issued. This is for paranoid sysadmins.
*/
#undef ENABLE_HOST_CHECKING
#undef USERADMIN
#endif // __CHANFIX_CONFIG_H
+48
View File
@@ -0,0 +1,48 @@
/**
* chanfix_misc.h
*
* 17/12/2003 - Matthias Crauwels <ultimate_@wol.be>
* Initial Version
*
* Miscellaneous functions
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: chanfix_misc.h,v 1.5 2010/03/04 04:24:12 hidden1 Exp $
*/
#ifndef __CHANFIX_MISC_H
#define __CHANFIX_MISC_H "$Id: chanfix_misc.h,v 1.5 2010/03/04 04:24:12 hidden1 Exp $"
namespace gnuworld
{
namespace cf
{
bool compare_points_new(sqlChanOp* a, sqlChanOp* b) {
return (a->getPoints() + a->getBonus()) > (b->getPoints() + b->getBonus());
}
bool compare_points(sqlChanOp* a, sqlChanOp* b) {
return a->getPoints() > b->getPoints();
}
} //namespace cf
} //namespace gnuworld
#endif // __CHANFIX_MISC_H
+118
View File
@@ -0,0 +1,118 @@
/* defs_chanfix.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <asm/ioctls.h> header file. */
#undef HAVE_ASM_IOCTLS_H
/* define if the Boost::Thread library is available */
#undef HAVE_BOOST_THREAD
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <getopt.h> header file. */
#undef HAVE_GETOPT_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* define if the compiler implements namespaces */
#undef HAVE_NAMESPACES
/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
/* Define to 1 if you have the <pthread.h> header file. */
#undef HAVE_PTHREAD_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/file.h> header file. */
#undef HAVE_SYS_FILE_H
/* Define to 1 if you have the <sys/filio.h> header file. */
#undef HAVE_SYS_FILIO_H
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#undef HAVE_SYS_IOCTL_H
/* Define to 1 if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H
/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <sys/un.h> header file. */
#undef HAVE_SYS_UN_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the <xti_inet.h> header file. */
#undef HAVE_XTI_INET_H
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Version number of package */
#undef VERSION
/* Define to `int' if <sys/types.h> doesn't define. */
#undef gid_t
/* Define to `int' if <sys/types.h> does not define. */
#undef mode_t
/* Define to `int' if <sys/types.h> does not define. */
#undef pid_t
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t
+48
View File
@@ -0,0 +1,48 @@
Introduction
--------------------------------------------------------------------------------------
* What is mod.Chanfix exactly?
mod.ChanFix is an open source port of OpenChanfix for IRCu 2.10.11.X+ oompatible networks.
Designed as a module for GNUWorld. The service creates a continuous dynamic database of
channel operators, automatically reopping channels which lose channel ops. Furthermore,
the service can be manually invoked by mod.Chanfix administrators to reverse recent
channel takeovers.
By default, mod.Chanfix observes channels with at least 4 clients, and retains channel
op score records for 2 weeks.
* How does it keep track of which people have been opped?
mod.Chanfix makes a temporary list of all unique AC accounts in a given channel.
Thereafter, the account is registered in the database as channel operators. For every
scored round, a given account will receive one point. Channel ops are scored whenever
the IRC network is judged to be intact (i.e. not split), and by default every channel
is scored once every 5 minutes. Thus, assuming no large network splits, a given account
can achieve a maximum of 288 points per 24 hour period.
* When does mod.Chanfix take action?
There are two cases in which mod.Chanfix will take action.
The first is whenever a channel with scores in the database becomes opless. mod.Chanfix
will look at the scores in the database and match those against the clients currently
present on the channel, and give ops to the clients with the highest scores.
This is called an automatic fix; whenever a channel becomes opless, mod.Chanfix will
attempt to fix it automatically.
The second is when a channel has been taken over. An IRC Operator with an account on
mod.Chanfix with the right flag can issue a manual fix. If this is issued, all clients
on the channel are deopped, and mod.Chanfix will join the channel and remove all bans
and modes. This allows the channel regulars to rejoin the channel. Then, after a short
while, mod.Chanfix will join the channel again and will reop the channel using the same
autofix logic.
For more information about the exact algorithm used, see the opping logic section.
* How does one interface with mod.Chanfix?
When loading the mod.Chanfix module into your GNUWorld, a client is connected. By default,
its nickname is C. All oper <-> mod.Chanfix interaction goes via NOTICE to C, this can be
changed to PRIVMSG's if desired.
+51
View File
@@ -0,0 +1,51 @@
Example:
Let's look at an example channel, #mod.Chanfix. Currently, the following people
are on #mod.Chanfix:
Users on #mod.Chanfix:
[@Beige ] [@cryogen] [@sabre2th] [+cfan ] [morfie]
[@cfgaar] [@Garion ] [@smurf ] [+Domilijn] [as4 ]
#mod.Chanfix: Total of 10 nicks [6 ops, 2 voices, 2 normal]
Here is a list of all the hostmasks of the users on #mod.Chanfix:
@ Beige beige@oper.suid.sh
@ cfgaar garion@open.chanfix
@ cryogen ~cryogen@bin.bash.sh
@ Garion garion@hub.nl
@ sabre2th sabre2th@feed.your.supermind
@ smurf smurf@80.60.12.241
+ cfan cfan@jd-163-76.doc.aca.mmu.ac.uk
+ Domilijn domilijn@kansloos.carnique.nl
morfie morf@217-195-236-172.dsl.esined.net
as4 as@CPE-65-28-140-90.neb.rr.com
Now, #mod.Chanfix has existed for several weeks now, so there are scores for
the channel in the mod.Chanfix database. These scores are:
1. 3651 garion@open.chanfix
2. 3548 beige@oper.suid.sh
3. 3498 domilijn@kansloos.carnique.nl
4. 3289 garion@hub.nl
5. 3176 ivo@echelon.schaapje.org
6. 3006 sabre2th@feed.your.supermind
7. 1252 smurf@80.60.12.241
As you can see, cryogen, whilst being opped, doesn't have a record in the
database. The reason that he doesn't have a score is that he is not idented;
you can see this because he has a tilde (~) before his username.
Let's ask C what he thinks about the status of the channel as it is now.
<Garion> score #mod.Chanfix
<C> Top 10 scores for channel "#mod.Chanfix" in the database:
<C> 3651, 3548, 3498, 3289, 3176, 3006, 1252.
<C> Top 10 scores for ops in channel "#mod.Chanfix" in the database:
<C> 3651, 3548, 3289, 3006, 1252.
<C> Top 10 scores for non-ops in channel "#mod.Chanfix" in the database:
<C> 3498.
From these scores you can see that the scores of the opped people are the same
as the top scores in the database, so the channel is currently with the
"rightful" owners.
+40
View File
@@ -0,0 +1,40 @@
Example:
Users on #mod.Chanfix:
[@Beige ] [as4 ] [cryogen ] [Garion] [sabre2th]
[+cfgaar] [cfan] [Domilijn] [morfie] [smurf ]
#mod.Chanfix: Total of 10 nicks [1 ops, 1 voices, 8 normal]
Beige's connection has some problems:
* Beige (beige@oper.suid.sh) has quit [Connection reset by peer]
* Beige (beige@oper.suid.sh) has joined #mod.Chanfix
The situation is now like this:
Users on #mod.Chanfix:
[+cfgaar] [as4 ] [cryogen ] [Garion] [sabre2th]
[ Beige ] [cfan] [Domilijn] [morfie] [smurf ]
#mod.Chanfix: Total of 10 nicks [0 ops, 1 voices, 9 normal]
mod.Chanfix will detect that #mod.Chanfix has become opless. Then it will look
in the database if there are scores known for #mod.Chanfix, and it will check
if there are currently clients with high enough scores present in the channel.
If that is the case, and here that certainly is, C will join the channel and op
a few clients:
* C (chanfix@open.chanfix) has joined #mod.Chanfix
* irc.open.chanfix sets mode #mod.Chanfix: +o C
* C sets mode #mod.Chanfix: +oooo cfgaar Beige Domilijn Garion
* <C> 4 clients should have been opped.
* C (chanfix@open.chanfix) has left #mod.Chanfix []
After the fix, the channel looks like this:
Users on #mod.Chanfix:
[@Beige ] [@Domilijn] [as4 ] [cryogen] [sabre2th]
[@cfgaar] [@Garion ] [cfan] [morfie ] [smurf ]
#mod.Chanfix: Total of 10 nicks [4 ops, 0 voices, 6 normal]
In OPLOGIC you can find out why these 4 clients have been opped and not any others.
+77
View File
@@ -0,0 +1,77 @@
Example:
Someone has taken over #mod.Chanfix, set it invite-only and kicked and banned
almost all the regulars. The situation:
Users on #mod.Chanfix:
[@IHateC ] [@takebot2] [as4 ] [henkje]
[@takebot] [@v ] [Domilijn] [p33n ]
#mod.Chanfix: Total of 8 nicks [4 ops, 0 voices, 4 normal]
The modes on the channel are as follows:
+iknmst closed
+b *!chanfix@open.chanfix
+b *!beige@oper.suid.sh
+b *!garion@*
Asking mod.Chanfix about the scores gives the following result:
<Garion> score #mod.Chanfix
<C> Top 10 scores for channel "#mod.Chanfix" in the database:
<C> 3651, 3548, 3498, 3289, 3176, 3006, 1252, 7, 6, 6.
<C> Top 10 scores for ops in channel "#mod.Chanfix" in the database:
<C> 7, 6, 6, 3.
<C> Top 10 scores for non-ops in channel "#mod.Chanfix" in the database:
<C> 3498.
From these scores, it is clear that the channel has been taken over. Nobody
with high scores is currently opped. So, time for a manual chanfix:
<Garion> chanfix #mod.Chanfix
<C> Manual chanfix acknowledged for channel "#mod.Chanfix".
This manual chanfix occurs in two stages. First, all modes of the channel are
cleared:
* TS for #mod.Chanfix changed from 1029226431 to 1029226430
* irc.open.chanfix sets mode #mod.Chanfix: -ik
* irc.open.chanfix sets mode #mod.Chanfix: -oooo IHateC takebot takebot2 v
* C (chanfix@open.chanfix) has joined #mod.Chanfix
* irc.open.chanfix sets mode #mod.Chanfix: +o C
<C> Channel fix in progress, please stand by.
* C sets mode #mod.Chanfix: -bbb *!chanfix@open.chanfix *!beige@oper.suid.sh
*!garion@*
* C (chanfix@open.chanfix) has left #mod.Chanfix
The channel is clear and open again:
Users on #mod.Chanfix:
[as4 ] [henkje] [p33n ] [takebot2]
[Domilijn] [IHateC] [takebot] [v ]
#mod.Chanfix: Total of 8 nicks [0 ops, 0 voices, 8 normal]
Now, mod.Chanfix will wait a while to allow the channel regulars to rejoin the
channel:
* Beige (beige@oper.suid.sh) has joined #mod.Chanfix
* Garion (garion@hub.nl) has joined #mod.Chanfix
* cfgaar (garion@open.chanfix) has joined #mod.Chanfix
* cryogen (~cryogen@bin.bash.sh) has joined #mod.Chanfix
* sabre2th (sabre2th@feed.your.supermind) has joined #mod.Chanfix
* henkje (henk@i.aml33t.cx) has parted #mod.Chanfix
And after that pause, C will enter to give ops to the people who deserve it:
* C (chanfix@open.chanfix) has joined #mod.Chanfix
* irc.open.chanfix sets mode #mod.Chanfix: +o C
* C sets mode #mod.Chanfix: +oooo cfgaar Beige Domilijn Garion
* <C> 4 clients should have been opped.
* C (chanfix@open.chanfix) has left #mod.Chanfix []
This leaves the channel in the following state:
Users on #mod.Chanfix:
[@Beige ] [@Domilijn] [as4 ] [IHateC] [sabre2th] [takebot2]
[@cfgaar] [@Garion ] [cryogen] [p33n ] [takebot ] [v ]
#mod.Chanfix: Total of 12 nicks [4 ops, 0 voices, 8 normal]
Back with its rightful owners.
+8
View File
@@ -0,0 +1,8 @@
Examples
Here are some examples to help understand what mod.Chanfix does.
* #mod.Chanfix - users and their scores - EXAMPLE.01
* opless - shows what happens if #mod.Chanfix becomes opless - EXAMPLE.02
* takeover - shows what happens if #mod.Chanfix is taken over - EXAMPLE.03
+34
View File
@@ -0,0 +1,34 @@
Admin FAQ
--------------------------------------------------------------------------------------
* I want to run mod.Chanfix on my network, anything I need to be aware of?
If you are just starting with mod.Chanfix, you should run it in no-fix mode for 1-2 weeks.
This allows it to gather scores of channels and avoids people complaining that mod.Chanfix
is not fixing their 20-point channel. Furthermore, explain to your users that mod.Chanfix
is not similar to channel registration at all, but a last resort service. Point them to
the User FAQ if they have questions.
* Can more than one mod.Chanfix run on the same network?
Yes. However, you should make sure that never more than one mod.Chanfix has fixing enabled.
Having two mod.Chanfix servers both set to perform automatic and manual fixes could lead to
confusing or even damaging situations, for example:
- oper1 tells chanfix1 to manually fix #channel
- chanfix1 enters #channel, removing all ops
- chanfix2 sees an opless #channel and tries to fix it
- oper1 tells chanfix1 to manually fix #channel
- a few minutes later, oper2 tells chanfix2 to manually fix #channel
Until a mechanism to communicate between mod.Chanfix servers has been devised, be careful
while running more than a single mod.Chanfix instance.
* I'm running mod.Chanfix but i'm not seeing any scores! What's wrong?
Make sure that enough servers are linked. You can confirm that via the STATUS command. If
chanfix has disabled fixing because not enough servers are linked, it is also not scoring
any channels. Second, a channel won't get scores unless it has 4 or more clients in it.
+13
View File
@@ -0,0 +1,13 @@
Oper FAQ
--------------------------------------------------------------------------------------
* How does mod.Chanfix keep track of who is logged in?
Whenever you LOGIN to X you will get an account, mod.Chanfix has a list of all accounts
with access in its database.
* What happens in case of a netsplit? Or when my connection drops and I reconnect?
IRCu will burst your account in a netsplit, so mod.Chanfix will know you are still logged
in. However if you reconnect or quit you will be logged out. Thus you will need to relogin
to X, or whichever service you use to get an account.
+37
View File
@@ -0,0 +1,37 @@
User FAQ
--------------------------------------------------------------------------------------
* Is mod.Chanfix like channel registration?
No. Not all all. mod.Chanfix is a neutral entity which can fix a stable channel (this
means that it has existed for at least several days, and has had a group of stable ops)
in emergencies. The two emergencies when mod.Chanfix can help are if the channel becomes
opless, or if the channel is taken over.
* When does my channel qualify for mod.Chanfix?
Every channel with at least 4 clients in it will get points.
* How do I get a score?
Every 5 minutes mod.Chanfix will look at the opped clients in each channel that have
enough clients. All of the clients that are idented (no ~ in front of their username)
will get a point. See the examples for more information.
* How many points do I need?
You need at least 163 points (4% of the maximum) for mod.Chanfix to reop you. Below that,
mod.Chanfix doesn't do anything. This means your channel must be at least 163 / 12 = 13.6
hours old.
* My channel is opless and I have a score, why isn't mod.Chanfix opping me?
mod.Chanfix can take up to an hour to fix an opless channel. The higher your score, the
faster you are opped. So be patient. Oh, and if your score is below 163, well, you won't
be opped.
* After 2 hours, mod.Chanfix has still not been to my channel! What's going on?
The most probable explanation is that you have fewer than 3 clients in your channel. You
must have at least 4 clients in your opless channel before mod.Chanfix will come to fix it.
+75
View File
@@ -0,0 +1,75 @@
Opping logic
--------------------------------------------------------------------------------------
* Automatic fix
If a channel becomes opless, and there are scores in mod.Chanfix's database for this
channel, mod.Chanfix will try to fix this channel. In other words, it will give ops
to the clients it thinks deserve it the most.
For each automatic opless channel fix (autofix), a time window of 60 minutes is
reserved. During this window, mod.Chanfix will join zero or more times, opping at
least one client each time.
There are, of course, requirements to the minimum score that you need to have before
mod.Chanfix will op you. This minimum score is determined both from the absolute
maximum score that can be obtained, and from the maximum score available in the
channel that is being fixed.
The first time that mod.Chanfix joins, it will only op clients with:
- at least 90% of channel_max_score (variable)
- and at least 40% of max_score (default: 0.4 * 4032 = 1613)
The last time that mod.Chanfix can possibly join (which is after the
autofix_time_maximum has passed), it will only op clients with:
- at least 30% of channel_max_score (variable)
- and at least min_score (default: 0.04 * 4032 = 162)
In between, mod.Chanfix will use a linear formula to determine the decrease of
these values over time.
Channel #a has a maximum score of 2400. The last opped client leaves.
When mod.Chanfix first joins, only clients with at least 0.9 * 2400 = 2160 and
at least 0.4 * 4032 = 1613 will be opped, so only clients with more than 2159
points will be opped.
If mod.Chanfix would join a last time at the end of the 60 minutes, it would op
clients with at least 0.33 * 2400 = 800 points. Lower scores will never be opped.
When mod.Chanfix joins after 20 minutes (which is 1/3rd of the total window for
fixing), it will only op clients with
at least 2160 - 0.33 * (0.9-0.3) * 2160 = 1728
and at least 1613 - 0.33 * (1613-100) = 1109
points, i.e. at least 1728 points.
* Determining the end of a fix
As soon as autofix_num_opped clients are opped in the channel, either by mod.Chanfix
or by the clients which were opped earlier, the fix is considered complete.
If the channel has fewer than autofix_num_opped clients, then the fix is considered
complete as soon as all clients are opped.
As soon as mod.Chanfix can see that there is at least 1 opped client and no more
clients have a score that is high enough to get opped, the fix is considered complete.
Under no circumstances will mod.Chanfix give ops if that would result in having
more than autofix_num_opped opped clients (mod.Chanfix itself excluded).
Under no circumstances will mod.Chanfix give ops to any client with a score lower than
min_score.
Under no circumstances will mod.Chanfix give ops to any client with a score lower than
0.3 * channel_max_score.
* Manual fix
Now, for a manual mod.Chanfix the procedure is as follows:
- First, C joins with TS-1 and removes all modes and bans.
- Then, C waits chanfix_initial_interval minutes.
- After that, autofixing starts with exactly the same algorithms as described above.
+17
View File
@@ -0,0 +1,17 @@
-- "$Id: chanfix.addme.sql,v 1.4 2006/12/09 00:29:20 buzlip01 Exp $"
-- 2005-08-13 : reed
--
-- This script will add an account for user "Admin" with owner (+o) access.
-- Please modify the default user ("Admin") to your account name.
--
-- This script may be used to create (not modify) multiple owner
-- accounts provided that the account name is changed each time.
--
INSERT INTO users (user_name,created,last_updated,last_updated_by,language_id,flags)
VALUES ('Admin',extract(epoch FROM now())::int,extract(epoch FROM now())::int,'(added via addme script)',1,16);
INSERT INTO hosts (user_id,host)
VALUES (1,'*!*@*');
-- END HERE
+60
View File
@@ -0,0 +1,60 @@
-- Help information.
--
-- $Id: chanfix.help.sql,v 1.5 2006/12/26 14:36:08 buzlip01 Exp $
DELETE FROM help;
COPY "help" FROM stdin;
ADDFLAG 1 Adds the specified flag to the specified user. Possible flags:\na - Can manage users for local server/group\nb - Can block/unblock channels\nc - Can add/delete notes for channels\nf - Can perform manual chanfix\no - Can do anything\nu - Can manage users globally\nNote: You can only add one flag at a time.
ADDHOST 1 Adds the specified hostmask to the user's list of hostmasks.
ADDNOTE 1 Adds a note to the specified channel.
ADDUSER 1 Adds a new user, without flags, and optionally with the specified hostmask.
ALERT 1 Puts a channel on ALERT status\nChannels in alert status have information contained in notes that should be considered before fixing the channel. These channels also require the OVERRIDE flag to manually fix them.
BLOCK 1 Blocks a channel from being fixed, both automatically and manually.\nThe reason will be shown when doing INFO <channel>.
CANFIX 1 Lists the ops that can fix the specified channel without requiring oper assistance.
CHECK 1 Shows the number of ops and total clients in the specified channel.
CSCORE 1 Shows the same as SCORE, but in a compact output. See /msg C HELP SCORE.
CHANFIX 1 Performs a manual fix on the specified channel. Append OVERRIDE, YES, or an exclamation mark (!) to force a manual fix. Append CONTACT if you wish that the top 10 ops for the channel be noticed about the fix before the fix happens.
DELFLAG 1 Removes the specified flag from a user. See /msg C HELP ADDFLAG.
DELHOST 1 Deletes the specified hostmask from a user's list of hostmasks.
DELNOTE 1 Deletes a note matching the specified id from the specified channel. You can only delete the notes you have added.
DELUSER 1 Deletes the specified user.
QUOTE 1 This command should never be used.\nUsing it would be bad.\nHow bad?\nTry to imagine all life stopping instantaneously, and every molecule in your body exploding at the speed of light.
HELP 1 Shows help about the specified command. With no command specified, all commands that you have access to use are listed.
HISTORY 1 Shows the times that the specified channel has been manually fixed.
INFO 1 Shows all notes of the specified channel and whether the channel is actively blocked.
LASTCOM 1 Shows all the last commands which where issued to the bot.
LISTBLOCKED 1 Lists all of the channels that chanfix will not score.
LISTHOSTS 1 With no username specified, it lists the hostmasks chanfix recognizes you by. Otherwise, it views the specified username's host list.\nNOTE: Server admins (+a) can only view host lists of users within their own server group. Users lower than server admin status can only view their own host lists.
LISTTEMPBLOCKED 1 Lists all of the channels that chanfix will not score temporarly.
OPLIST 1 Shows the top 10 op accounts and their scores for the specified channel. Possible flags\n-all (or ALL or !) - Lists all scores.\n-days - Displays a small bar of the 2 week scoring period showing when a person was opped (. means never opped, 0 means 0-10%, 9 means 91-100%)
OPNICKS 1 Shows the nicknames currently opped on the specified channel.
REHASH 1 Reloads the translations, configuration, or help values based on the specified target.
RELOAD 1 Completely reloads chanfix.\nNOTE: This will subject chanfix to a reconnection which will also include a large netburst that takes time to process, so use with caution.
REQUESTOP 1 Performs a fix on the specified channel. Append CONTACT if you wish that the top 10 ops for the channel be noticed about the fix before the fix happens.
SCORE 1 Without extra arguments, shows the top scores of <channel>.\nOtherwise, it shows the score of either an <account> or a currently online client <=nick> for <channel>.
SET 1 Sets various configuration options to the specified values.\nBoolean settings: ENABLE_AUTOFIX, ENABLE_CHANFIX, ENABLE_CHANNEL_BLOCKING.\nInteger settings: NUM_SERVERS.
SIMULATE 1 Performs a simulated fix on the specified channel. Append AUTO or MANUAL to choose what type of fix to simulate upon the channel.
STATUS 1 Shows current statistics such as: uptime, percentage network presence, fix and block settings.
SUSPEND 1 Suspends the specified user.
TEMPBLOCK 1 Temporary blocks a channel from being fixed, both automatically and manually.\nThe reason will be shown when doing INFO <channel>.
UNALERT 1 Removes a channel from alert status.
UNBLOCK 1 Removes a channel from the blocklist causing it to be fixable again.
UNTEMPBLOCK 1 Removes a channel from the temporary blocklist causing it to be fixable again.
USET 1 Sets options on your account. Possible settings:\nNOTICE - receive notices, if no then PRIVMSG's will be sent.\nLANG - What language chanfix will communicate with you in; available languages: EN - English.
WHOIS 1 Shows account information for the specified user.
SETGROUP 1 Sets the group for the specified user.
SHUTDOWN 1 Saves the database and shuts GNUWorld down.
UNSUSPEND 1 Unsuspends the specified user.
USERSCORES 1 Shows all scores for the given account over all channels.
WHOGROUP 1 Shows all users in the specified group along with their flags. If no argument is given, all groups are listed.
<INDEXNORMAL> 1 \002Normal User\002: CANFIX REQUESTOP
<INDEXOPER> 1 \002Oper Level\002: CHANFIX SIMULATE SCORE CSCORE CHECK HISTORY INFO OPLIST OPNICKS STATUS
<INDEXLOGGEDIN> 1 \002Logged In\002: LISTHOSTS USET USERSCORES WHOIS WHOFLAG
<INDEXBLOCK> 1 \002Blocker (+b)\002: BLOCK UNBLOCK LISTBLOCKED
<INDEXCOMMENT> 1 \002Commenter (+c)\002: ADDNOTE DELNOTE ALERT UNALERT
<INDEXCHANFIX> 1 \002Chanfixer (+f)\002: CHANFIX SIMULATE
<INDEXOWNER> 1 \002Owner (+o)\002: LASTCOM REHASH RELOAD SET SHUTDOWN
<INDEXSERVERADMIN> 1 \002Server Admin (+a)\002: ADDUSER DELUSER ADDHOST DELHOST ADDFLAG DELFLAG WHOGROUP SUSPEND UNSUSPEND
<INDEXUSERADMIN> 1 \002User Manager (+u)\002: ADDUSER DELUSER ADDHOST DELHOST ADDFLAG DELFLAG SETGROUP WHOGROUP SUSPEND UNSUSPEND
\.
@@ -0,0 +1,225 @@
-- Language Definition Table for chanfix.
--
-- Language: English (1)
-- Author: evilnet development <http://evilnet.sourceforge.net>
--
-- $Id: chanfix.language.english.sql,v 1.7 2007/02/01 14:11:17 buzlip01 Exp $
DELETE FROM translations;
COPY "translations" FROM stdin;
1 1 You may only add one flag per ADDFLAG command. 31337 0
1 2 No such user %s. 31337 0
1 3 Only an owner can add the owner flag. 31337 0
1 4 Only an owner can add the user management flag. 31337 0
1 5 You cannot add a flag to a user in a different group. 31337 0
1 6 You cannot add a block flag. 31337 0
1 7 You cannot add a serveradmin flag. 31337 0
1 8 User %s already has flag '%c'. 31337 0
1 9 Added flag '%c' to user %s. 31337 0
1 10 You cannot add a host to a user in a different group. 31337 0
1 11 User %s already has hostmask %s. 31337 0
1 12 Failed adding hostmask %s to user %s. 31337 0
1 13 Added hostmask %s to user %s. 31337 0
1 14 %s is an invalid channel name. 31337 0
1 15 Note recorded for channel %s. 31337 0
1 16 User %s already exists. 31337 0
1 17 Created user %s (%s). 31337 0
1 18 Created user %s. 31337 0
1 19 Error creating user %s. (Insertion failed) 31337 0
1 20 The channel %s already has the ALERT flag. 31337 0
1 21 ALERT flag added to channel %s 31337 0
1 22 Channel blocking is disabled. 31337 0
1 23 The channel %s is already blocked. 31337 0
1 24 The channel %s has been blocked. 31337 0
1 25 Sorry, manual chanfixes are currently disabled. 31337 0
1 26 Sorry, chanfix is currently disabled because not enough servers are linked. 31337 0
1 27 No such channel %s. 31337 0
1 28 %s cannot be chanfixed as it uses oplevels (+A/+U). If this channel has been taken over and needs to be returned to the original owners, use \002OPLIST %s\002 to see the real owners and then use an appropriate oper service to fix the channel manually. 31337 0
1 29 %s is a registered channel. 31337 0
1 30 There are no scores in the database for %s. 31337 0
1 31 The channel %s is already being manually fixed. 31337 0
1 32 The highscore in channel %s is %d which is lower than the minimum score required (%.2f * %d = %d). 31337 0
1 33 The channel %s is being automatically fixed. Append the OVERRIDE flag to force a manual fix. 31337 0
1 34 The channel %s is BLOCKED. 31337 0
1 35 Alert: The channel %s has notes. Use \002INFO %s\002 to read them. Append the OVERRIDE flag to force a manual fix. 31337 0
1 36 Manual chanfix acknowledged for %s 31337 0
1 37 I see %d opped out of %d total clients in %s. 31337 0
1 38 You may only remove one flag per DELFLAG command. 31337 0
1 39 Only an owner can delete the owner flag. 31337 0
1 40 Only an owner can delete the user management flag. 31337 0
1 41 You cannot delete a flag from a user in a different group. 31337 0
1 42 You cannot remove a block flag. 31337 0
1 43 You cannot remove a serveradmin flag. 31337 0
1 44 User %s does not have flag '%c'. 31337 0
1 45 Deleted flag '%c' from user %s. 31337 0
1 46 You cannot delete a host from a user in a different group. 31337 0
1 47 User %s doesn't have hostmask %s. 31337 0
1 48 Failed deleting hostmask %s from user %s. 31337 0
1 49 Deleted hostmask %s from user %s. 31337 0
1 50 There is no entry in the database for %s. 31337 0
1 51 The channel %s does not have any notes. 31337 0
1 52 An unknown error occured while checking the note id. 31337 0
1 53 There is no such note with that note_id. 31337 0
1 54 No such note #%d for channel %s. 31337 0
1 55 Note #%d for channel %s was not added by you. You can only delete notes that you added. 31337 0
1 56 Note #%d for channel %s is not a manually added note. You can only delete notes that were manually added. 31337 0
1 57 Note #%d for channel %s deleted. 31337 0
1 58 You cannot delete an owner unless you're an owner. 31337 0
1 59 You cannot delete a user manager unless you're an owner. 31337 0
1 60 You cannot delete a user in a different group. 31337 0
1 61 Deleted user %s. 31337 0
1 62 Error deleting user %s. 31337 0
1 63 Channel %s has never been manually fixed. 31337 0
1 64 An unknown error occurred while reading this channel's notes. 31337 0
1 65 Channel %s has been manually fixed on: 31337 0
1 67 End of list. 31337 0
1 68 No information on %s in the database. 31337 0
1 69 Information on %s: 31337 0
1 70 %s is BLOCKED. 31337 0
1 71 %s is being chanfixed. 31337 0
1 72 %s is being autofixed. 31337 0
1 73 Notes (%d): 31337 0
1 74 End of information. 31337 0
1 75 %s is ALERTED. 31337 0
1 76 [%d:%s] %s \002%s\002%s%s 31337 0
1 77 Could not find channel %s on the network. 31337 0
1 78 I am not in %s. 31337 0
1 79 You are already in %s! 31337 0
1 80 Top %d unique op accounts in channel %s: 31337 0
1 81 Found %d unique op accounts in channel %s: 31337 0
1 82 Rank Score Account -- Time first opped / Time last opped / Nick 31337 0
1 83 Opped clients on channel %s: 31337 0
1 84 I see 1 opped client in %s. 31337 0
1 85 I see %u opped clients in %s. 31337 0
1 86 Successfully reloaded help tables. %i entries in table. 31337 0
1 87 Successfully rehashed configuration file. 31337 0
1 88 Reloading client...see you on the flip side 31337 0
1 89 Score for %s (%s) in channel %s: %u. (Ranked #%u of %d) 31337 0
1 90 ~U %s no@such.nick 0 31337 0
1 91 No such nick %s. 31337 0
1 92 None. 31337 0
1 93 Top %u scores for channel %s in the database: 31337 0
1 94 Top %u scores for current ops in %s in the database: 31337 0
1 95 Top %u scores for current non-ops in %s in the database: 31337 0
1 96 Please use SET NUM_SERVERS <integer number>. 31337 0
1 97 NUM_SERVERS is now %d. 31337 0
1 98 Enabled autofix. 31337 0
1 99 Disabled autofix. 31337 0
1 100 Please use SET ENABLE_AUTOFIX <on/off>. 31337 0
1 101 Enabled manual chanfix. 31337 0
1 102 Disabled manual chanfix. 31337 0
1 103 Please use SET ENABLE_CHANFIX <on/off>. 31337 0
1 104 Enabled channel blocking. 31337 0
1 105 Disabled channel blocking. 31337 0
1 106 Please use SET ENABLE_CHANNEL_BLOCKING <on/off>. 31337 0
1 107 This setting does not exist. 31337 0
1 108 User %s is already in group %s. 31337 0
1 109 Set group %s for user %s. 31337 0
1 110 Shutting down the server as per your request. 31337 0
1 111 Uptime: \002%s\002 31337 0
1 112 Automatic fixing is: \002%s\002 31337 0
1 113 Manual fixing is: \002%s\002 31337 0
1 114 Channel blocking is: \002%s\002 31337 0
1 115 Required amount of servers linked is %u%% of %u, which is a minimum of %u servers. 31337 0
1 116 Splitmode enabled: only %i servers linked. 31337 0
1 117 Splitmode disabled. There are %i servers linked. 31337 0
1 118 You cannot suspend a user in a different group. 31337 0
1 119 User %s is already suspended. 31337 0
1 120 Suspended user %s indefinitely. 31337 0
1 121 The channel %s does not have the ALERT flag. 31337 0
1 122 ALERT flag removed from channel %s 31337 0
1 123 The channel %s is not blocked. 31337 0
1 124 Channel %s has been unblocked. 31337 0
1 125 You cannot unsuspend a user in a different group. 31337 0
1 126 User %s is not currently suspended. 31337 0
1 127 Unsuspended user %s. 31337 0
1 128 Language is set to %s. 31337 0
1 129 I will now send you notices. 31337 0
1 130 I will now send you privmsgs. 31337 0
1 131 Please use USET NOTICE <on/off>. 31337 0
1 134 You can only WHOGROUP on your group. 31337 0
1 135 Users with group %s [username (flags)]: 31337 0
1 136 Number of users: %d. 31337 0
1 137 List of all users: 31337 0
1 138 User: %s, Flags: %s, Group: %s 31337 0
1 140 --SUSPENDED-- 31337 0
1 142 Group: %s 31337 0
1 143 Flags: none. 31337 0
1 144 Flags: +%s 31337 0
1 145 Sorry, I do not accept commands during a burst. 31337 0
1 146 Unknown command. 31337 0
1 147 Your access to this service is suspended. 31337 0
1 148 Your current host does not match any registered hosts for your username. 31337 0
1 149 You need to authenticate to use this command. 31337 0
1 150 This command requires flag '%c'. 31337 0
1 151 This command requires one of these flags: \"%s\". 31337 0
1 152 This command requires authentication and flag '%c'. 31337 0
1 153 This command requires authentication and one of these flags: \"%s\". 31337 0
1 154 SYNTAX: 31337 0
1 155 Language: %s (%s) 31337 0
1 156 ~U %s no@score.for.account 0 31337 0
1 157 No score for account %s on channel %s. 31337 0
1 158 Score for account %s in channel %s: %u. (Ranked #%u of %d) 31337 0
1 159 Suspending yourself is not a very wise thing to do. 31337 0
1 160 Last modified: %s (%s ago) 31337 0
1 161 NeedOper: Yes 31337 0
1 162 NeedOper: No 31337 0
1 163 You cannot view hosts of a user in a different group. 31337 0
1 164 Host list for %s: 31337 0
1 165 End of host list. 31337 0
1 166 No score for %s on %s. 31337 0
1 167 ~U %s no@score.for.nick 0 31337 0
1 168 List of all groups: 31337 0
1 169 Number of groups: %d. 31337 0
1 170 Removed the default hostmask of *!*@* from user %s. 31337 0
1 171 Channel service linked. New channels will be scored. 31337 0
1 172 Channel service not linked. New channels will not be scored. 31337 0
1 173 This command cannot proceed while an update is in progress. Please try again later. 31337 0
1 174 Total number of channels recorded: %u 31337 0
1 175 Total number of channel ops recorded: %u 31337 0
1 176 Last used the service: %s ago 31337 0
1 177 Last used the service: Never 31337 0
1 178 WARNING: Channel %s is being manually fixed; aborting fix as per BLOCK. 31337 0
1 179 WARNING: Channel %s is being automatically fixed; aborting fix as per BLOCK. 31337 0
1 180 You cannot suspend an owner unless you're an owner. 31337 0
1 181 You cannot suspend a user manager unless you're an owner. 31337 0
1 182 You cannot unsuspend an owner unless you're an owner. 31337 0
1 183 You cannot unsuspend a user manager unless you're an owner. 31337 0
1 184 You cannot delete a host from an owner unless you're an owner. 31337 0
1 185 You cannot delete a host from a user manager unless you're an owner. 31337 0
1 186 You cannot add a host to an owner unless you're an owner. 31337 0
1 187 You cannot add a host to a user manager unless you're an owner. 31337 0
1 188 %s is temporarily blocked. (Use OVERRIDE to bypass) 31337 0
1 189 %s is temporarily blocked due to oper intervention via EUWorld within the last hour. Please append the OVERRIDE flag to force a manual fix. 31337 0
1 190 List of all blocked channels: 31337 0
1 191 %d channels blocked. 31337 0
1 192 Current fix has been running for %s 31337 0
1 193 Current fix is on hold (waiting for ops to join) 31337 0
1 194 Channel Score -- Time first opped / Time last opped 31337 0
1 195 Account %s doesn't have any scores in the database. 31337 0
1 196 You score for %s is not high enough to issue a fix. 31337 0
1 197 Accounts who can issue fixes in channel %s: 31337 0
1 198 Account -- Time first opped / Time last opped 31337 0
1 199 You do not have a high enough score for %s to check canfix list. 31337 0
1 200 Sorry, chanfix cannot fix channels at the moment, please try again soon. 31337 0
1 201 The channel %s is being automatically fixed. You cannot issue another fix at the moment. 31337 0
1 202 The channel %s cannot be fixed, please contact a help channel for further information. 31337 0
1 203 Sorry, I'm too busy at the moment. Please try again soon. 31337 0
1 204 Sorry, I cant fix channels at the moment. 31337 0
1 205 Fixing %s, please wait. 31337 0
1 206 You must wait %s seconds before %s can be fixed again with this command, or contact a help channel. 31337 0
1 207 End of OPLIST for %s 31337 0
1 208 You cannot see logs more than one year ago. 31337 0
1 209 Listing last %d messages from day %d. 31337 0
1 210 End of LASTCOM report. 31337 0
1 211 The channel %s is TEMPBLOCKED. To fix it, please append the OVERRIDE flag. 31337 0
1 214 %s is TEMPBLOCKED. (Use OVERRIDE to bypass) 31337 0
1 221 Simulate complete for %s 31337 0
1 222 (%s) Opping: %s (%d Clients) 31337 0
1 223 (%s) Channel modes have been removed. 31337 0
1 224 Simulate for %s (%s) starting at next fixing round (Current C time %s). 31337 0
1 225 NOTE: This is only an estimate, if ops with points join or part it could affect who gets opped. 31337 0
1 226 You may only WHOFLAG one flag. 31337 0
\.
@@ -0,0 +1,8 @@
-- Use this file to populate the 'languages' table.
--
-- $Id: chanfix.languages.sql,v 1.4 2006/12/09 00:29:20 buzlip01 Exp $
DELETE FROM languages;
COPY "languages" FROM stdin;
1 EN English 31337 0
\.
+128
View File
@@ -0,0 +1,128 @@
-- mod.chanfix SQL Database Script
-- (c) 2003 Matthias Crauwels <ultimate_@wol.be>
-- (c) 2005 Reed Loden <reed@reedloden.com>
-- $Id: chanfix.sql,v 1.4 2006/12/09 00:29:20 buzlip01 Exp $
CREATE TABLE languages (
id SERIAL,
code VARCHAR( 16 ) UNIQUE,
name VARCHAR( 16 ),
last_updated INT4 NOT NULL,
deleted INT2 DEFAULT '0',
PRIMARY KEY(id)
);
CREATE TABLE translations (
language_id INT4 CONSTRAINT translations_language_id_ref REFERENCES languages ( id ),
response_id INT4 NOT NULL DEFAULT '0',
text TEXT,
last_updated INT4 NOT NULL,
deleted INT2 DEFAULT '0',
PRIMARY KEY (language_id, response_id)
);
CREATE TABLE help (
topic VARCHAR(20) NOT NULL,
language_id INT4 CONSTRAINT help_language_id_ref REFERENCES languages ( id ),
contents TEXT
);
CREATE INDEX help_topic_idx ON help (topic);
CREATE INDEX help_language_id_idx ON help (language_id);
CREATE TABLE chanOps (
channel VARCHAR(200) NOT NULL,
account VARCHAR(24) NOT NULL,
last_seen_as VARCHAR(128),
ts_firstopped INT4 DEFAULT 0,
ts_lastopped INT4 DEFAULT 0,
day0 INT2 NOT NULL DEFAULT 0,
day1 INT2 NOT NULL DEFAULT 0,
day2 INT2 NOT NULL DEFAULT 0,
day3 INT2 NOT NULL DEFAULT 0,
day4 INT2 NOT NULL DEFAULT 0,
day5 INT2 NOT NULL DEFAULT 0,
day6 INT2 NOT NULL DEFAULT 0,
day7 INT2 NOT NULL DEFAULT 0,
day8 INT2 NOT NULL DEFAULT 0,
day9 INT2 NOT NULL DEFAULT 0,
day10 INT2 NOT NULL DEFAULT 0,
day11 INT2 NOT NULL DEFAULT 0,
day12 INT2 NOT NULL DEFAULT 0,
day13 INT2 NOT NULL DEFAULT 0
);
CREATE TABLE channels (
id SERIAL,
channel TEXT NOT NULL UNIQUE,
flags INT4 NOT NULL DEFAULT 0,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX channels_name_idx ON channels(LOWER(channel));
CREATE TABLE users (
id SERIAL,
user_name TEXT NOT NULL UNIQUE,
created INT4 NOT NULL DEFAULT 0,
last_seen INT4 NOT NULL DEFAULT 0,
last_updated INT4 NOT NULL DEFAULT 0,
last_updated_by VARCHAR(128),
language_id INT4 CONSTRAINT language_id_ref REFERENCES languages (id) NOT NULL DEFAULT 1,
faction VARCHAR(128) NOT NULL DEFAULT 'undernet.org',
flags INT2 NOT NULL DEFAULT 0,
-- 0x01 - server admin (limited access to +u commands)
-- 0x02 - can block/unblock channels
-- 0x04 - can add/del notes/alerts to channels
-- 0x08 - can manual chanfix
-- 0x10 - oper not required
-- 0x20 - owner
-- 0x40 - user management rights
-- 0x80 - requires authentication
isSuspended BOOLEAN NOT NULL DEFAULT FALSE,
-- currently suspended
useNotice BOOLEAN NOT NULL DEFAULT TRUE,
-- use notice instead of privmsg
needOper BOOLEAN NOT NULL DEFAULT TRUE,
-- require operator privileges from staff
PRIMARY KEY (id)
);
CREATE INDEX users_username_idx ON users( lower(user_name) );
CREATE TABLE hosts (
user_id INT4 CONSTRAINT hosts_user_id_ref REFERENCES users ( id ),
host VARCHAR(128) NOT NULL
);
CREATE INDEX hosts_user_id_idx ON hosts(user_id);
CREATE TABLE notes (
id SERIAL,
ts INT4,
channelID INT4 CONSTRAINT notes_channelID_ref REFERENCES channels ( id ),
user_name VARCHAR(128),
event INT2 DEFAULT 0,
-- Defines the note event type, so we can filter nice reports.
-- 1 -- EV_MISC - Uncategorised event.
-- 2 -- EV_NOTE - Miscellaneous notes about a channel.
-- 3 -- EV_CHANFIX - When someone manual chanfixes a channel.
-- 4 -- EV_BLOCK - When someone blocks a channel.
-- 5 -- EV_UNBLOCK - When somebody unblocks a channel.
-- 6 -- EV_ALERT - When someone sets alert flag on a channel.
-- 7 -- EV_UNALERT - When somebody removes alert flag from a channel.
-- 8 -- EV_REQUESTOPS - When a normal client requestops a channel.
message TEXT,
PRIMARY KEY(id, channelID)
);
CREATE TABLE comlog (
ts INT4 NOT NULL,
user_name text,
command VARCHAR(512)
);
CREATE INDEX notes_channelID_idx ON notes(channelID);
CREATE INDEX notes_event_idx ON notes(event);
+78
View File
@@ -0,0 +1,78 @@
#!/usr/bin/env python
#
# Script to check GNUWorld's mod.chanfix translations for mismatched
# variable arguments
# (C) 2001 Alex Badea <vampire@go.ro>
# (C) 2005 Neil Spierling <sirvulcan@gmail.com> (mod.chanfix modifications)
#
# $Id: checkvarargs.py,v 1.4 2006/12/09 00:29:20 buzlip01 Exp $
# Change this to suit your system
gnuworld_home = "../../"
# English language ID (or, any language ID that is known to have
# valid translated strings)
english_id = 1
# Regular expression (don't ask me how I got to it)
regstr = "(%([0123456789]+\\$)?[-\\+ #'0]*[0123456789]*(\\.[0123456789]+)?([hjlLqtzZ]|hh|ll)?[diouxXfeEgGaAcspnm])"
# ---------------------------------------------------------------------------
import sys
import os
import re
from string import *
trans = {}
def read_language_table(fname):
print "* Reading translations from %s" % fname
f = open(fname, "r")
for line in f.readlines():
line = strip(line)
if len(line) < 2: continue
if line[0][:1] == "--": continue
if line[0][:1] == "\.": continue
toks = split(line, '\t')
if len(toks) < 4: continue
if toks[0] == "DELETE": continue
if toks[0] == "COPY": continue
try:
pk = (int(toks[0]), int(toks[1]))
except ValueError:
print "* Non-numeric IDs, line: %s" % `toks`
continue
if toks[len(toks)-2] != "31337":
print "* Translation ID (%d,%d) doesn't have a '31337' timestamp" % pk
if toks[len(toks)-1] != "0":
print "* Translation ID (%d,%d) doesn't have a '0' deleted flag" % pk
if trans.has_key(pk):
print "* Duplicate translation ID (%d,%d) Text: '%s' conflicts with '%s'" % (pk[0], pk[1], toks[2], trans[toks[1]])
trans[pk] = toks[2]
f.close()
print "* Read %d translations" % len(trans)
read_language_table(os.path.join(gnuworld_home, "mod.ocf", "doc", "chanfix.language.english.sql"))
r = re.compile(regstr)
print "* Checking varargs..."
for (lang, tr) in trans.keys():
if lang == english_id: continue
ctext = trans[(lang, tr)]
cva_list = r.findall(ctext)
if not len(cva_list):
if count(ctext, '%'): print '* Possible missed vararg:', ctext
etext = trans[(english_id, tr)]
eva_list = r.findall(etext)
if cva_list != eva_list:
print "* Mismatched vararg list, translation ID %d:" % tr
print " %d> %s" % (lang, ctext)
print " %d> %s" % (english_id, etext)
print "* Done"
+129
View File
@@ -0,0 +1,129 @@
#!/usr/bin/env python
#
# Script to check GNUWorld's mod.chanfix translations
# (C) 2001 Alex Badea <vampire@go.ro>
# (C) 2005 Neil Spierling <sirvulcan@gmail.com> (mod.chanfix modifications)
#
# $Id: chktrans.py,v 1.4 2006/12/09 00:29:20 buzlip01 Exp $
# Change this to suit your system
gnuworld_home = "../../"
# Language ID to check
language_id = "1"
# The maximum distance, in lines, between a bot->Notice and a getResponse
notice_thresh = 2
# ---------------------------------------------------------------------------
import sys
import os
from string import *
responses = {}
resp_used = {}
trans = {}
trans_r = {}
alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"
def read_language_table(fname):
f = open(fname, "r")
for line in f.readlines():
line = strip(line)
toks = split(line, '\t')
if len(toks) < 4: continue
if toks[0] != language_id: continue
if toks[len(toks)-2] != "31337": continue
if trans.has_key(toks[1]):
print "* Duplicate translation ID (%s) Text: '%s' conflicts with '%s' defined by ID %d" % (toks[1], toks[2], trans[toks[1]], trans_r[toks[2]])
if trans_r.has_key(toks[2]):
print "* Duplicate translation text '%s', ID %s already defined by ID %s" % (toks[2], toks[1], trans_r[toks[2]])
trans[toks[1]] = toks[2]
trans_r[toks[2]] = toks[1]
f.close()
print "* Read %d translations from %s" % (len(trans), fname)
def read_response_table(fname):
f = open(fname, "r")
for line in f.readlines():
line = strip(line)
toks = split(line)
if len(toks) < 2: continue
if toks[0] != "const": continue
if toks[1] != "int": continue
if responses.has_key(toks[2]):
print "* Duplicate response name (%s) ID: %s" % (toks[2], toks[4])
responses[toks[2]] = toks[4][:-1]
resp_used[toks[2]] = 0
f.close()
print "* Read %d responses from %s" % (len(responses), fname)
def parse_file(fname):
f = open(os.path.join(gnuworld_home, "mod.ocf", fname), "r")
line = f.readline()
lineno = 1
last_notice = 0
while line:
# Check the integrity of language:: references
try: start = index(line, "language::")
except ValueError: start = -1
if start >= 0:
start = start + 10
end = start
while (line[end] in alpha) and (end < len(line)):
end = end + 1
id = line[start:end]
numeric = 'UNDEFINED'
text = '[UNASSIGNED]'
if responses.has_key(id):
numeric = responses[id]
if trans.has_key(numeric):
text = trans[numeric]
resp_used[id] = 1
print "%s(%d): language::%s (%s) = '%s'" % (fname, lineno, id, numeric, text)
#print "%-25s (%4d): %-30s (%4s) -> %s" % (fname, lineno, id, numeric, text)
# Check for unlisted translations
try: start = index(line, "Notice")
except ValueError: start = -1
notice_done = 0
if (start >= 0) and (start == 0 or not line[start-1] in alpha):
last_notice = lineno
notice_line = strip(line[:-1])
if line[-2] == ";": notice_done = 1
try: start = index(line, "getResponse")
except ValueError: start = -1
if start >= 0:
last_notice = 0
if last_notice and (lineno > last_notice + notice_thresh or notice_done):
print "* Possible untranslated string in %s(%d): %s" % (fname, last_notice, notice_line)
last_notice = 0
lineno = lineno + 1
line = f.readline()
f.close()
read_language_table(os.path.join(gnuworld_home, "mod.ocf", "doc", "chanfix.language.english.sql"))
read_response_table(os.path.join(gnuworld_home, "mod.ocf", "responses.h"))
files = os.listdir(os.path.join(gnuworld_home, "mod.ocf"))
for file in files:
if len(file) < 4: continue
if file[-3:] != ".cc": continue
parse_file(file)
for resp in resp_used.keys():
if not resp_used[resp]:
numeric = 'UNDEFINED'
text = '[UNASSIGNED]'
if responses.has_key(resp):
numeric = responses[resp]
if trans.has_key(numeric):
text = trans[numeric]
print "* Unused response language::%s (%s) = '%s'" % (resp, numeric, text)
print "* Done"
+142
View File
@@ -0,0 +1,142 @@
#!/usr/bin/env python
#
# Script to check GNUWorld's mod.chanfix translations
# Episode 2 - Check for inconsistent translation strings
#
# (C) 2001 Alex Badea <vampire@go.ro>
# (C) 2005 Neil Spierling <sirvulcan@gmail.com> (mod.chanfix modifications)
#
# $Id: cparse.py,v 1.4 2006/12/09 00:29:20 buzlip01 Exp $
# Change this to suit your system
gnuworld_home = "../../"
# Language ID to check
language_id = "1"
# ---------------------------------------------------------------------------
import sys
import os
from string import *
responses = {}
resp_used = {}
trans = {}
trans_r = {}
alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"
def read_language_table(fname):
f = open(fname, "r")
for line in f.readlines():
line = strip(line)
toks = split(line, '\t')
if len(toks) < 4: continue
if toks[0] != language_id: continue
if toks[len(toks)-2] != "31337": continue
if trans.has_key(toks[1]):
print "* Duplicate translation ID (%s) Text: '%s' conflicts with '%s' defined by ID %d" % (toks[1], toks[2], trans[toks[1]], trans_r[toks[2]])
if trans_r.has_key(toks[2]):
print "* Duplicate translation text '%s', ID %s already defined by ID %s" % (toks[2], toks[1], trans_r[toks[2]])
trans[toks[1]] = toks[2]
trans_r[toks[2]] = toks[1]
f.close()
print "* Read %d translations from %s" % (len(trans), fname)
def read_response_table(fname):
f = open(fname, "r")
for line in f.readlines():
line = strip(line)
toks = split(line)
if len(toks) < 2: continue
if toks[0] != "const": continue
if toks[1] != "int": continue
if responses.has_key(toks[2]):
print "* Duplicate response name (%s) ID: %s" % (toks[2], toks[4])
responses[toks[2]] = toks[4][:-1]
resp_used[toks[2]] = 0
f.close()
print "* Read %d responses from %s" % (len(responses), fname)
class Parser:
def __init__(self, fname):
self.fname = fname
f = open(os.path.join(gnuworld_home, "mod.ocf", fname), "r")
self.buf = f.read()
f.close()
def pos(self, sub, start=0):
try: return index(self.buf, sub, start)
except ValueError: return -1
def run(self):
idx = self.pos("getResponse", 0)
while idx != -1:
lineno = count(self.buf[:idx], '\n') + 1
idx = idx + len("getResponse")
while self.buf[idx] != "(":
idx = idx + 1
idx = idx + 1
para = 1
quote = 0
tok = ""
tokens = []
while 1:
ch = self.buf[idx]
if quote:
if ch == '"':
tok = replace(tok, '""', '')
quote = 0
else:
if ch == "(":
para = para + 1
elif ch == ")":
para = para - 1
if para == 0:
tokens.append(tok)
break
elif ch == "\"":
quote = 1
elif ch in " \n\t\r":
idx = idx + 1
continue
elif ch == ",":
tokens.append(tok)
tok = ""
idx = idx + 1
continue
elif ch == ";":
tokens.append(tok)
break
tok = tok + ch
idx = idx + 1
if len(tokens) < 3:
print "%s(%d): getResponse has less than 3 arguments" % (self.fname, lineno)
pass
elif len(tokens[1]) < 10 or tokens[1][:10] != "language::":
print "%s(%d): Second argument to getResponse doesn't start with 'language::'" % (self.fname, lineno)
else:
id = tokens[1][10:]
numeric = responses[id]
trans_text = trans[numeric]
text = tokens[2]
if text[:12] == "std::string(": text = text[12:]
if text[-1] == ")": text = text[:-1]
if text[0] == '"': text = text[1:]
if text[-1] == '"': text = text[:-1]
if len(tokens) > 2 and trans_text != text:
print "%s(%d): Default response doesn't match with translation:\n Def: %s\n Trans: %s" % (self.fname, lineno, text, trans_text)
idx = self.pos("getResponse", idx)
read_language_table(os.path.join(gnuworld_home, "mod.ocf", "doc", "chanfix.language.english.sql"))
read_response_table(os.path.join(gnuworld_home, "mod.ocf", "responses.h"))
files = os.listdir(os.path.join(gnuworld_home, "mod.ocf"))
for file in files:
if len(file) < 4: continue
if file[-3:] != ".cc": continue
Parser(file).run()
print "* Note: The chanfix.cc error is safe to ignore."
print "* Done"
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/perl
# logrotator.pl
#
# (C) 2006 Jonathan Disher <funjon@undernet.org>
#
# Threaded application to read chanfix log files from FIFO's, rotate them daily,
# and email them to the appropriate destinations.
#
# Requires: perl 5.8.0 or higher with ithreads, Net::SMTP
require 5.8.0;
use Net::SMTP;
use strict;
##########################
##### FILE LOCATIONS #####
##########################
# Chanfix admin log
our $adminlog = "/home/chanfix/gnuworld/bin/chanfix-admin.log";
###########################
##### EMAIL ADDRESSES #####
###########################
# admin log destination
our $adminemail = 'abuse@mynet.org';
# Mail exchanger
our $MX = "mx.mynet.org";
#################################
##### OTHER IMPORTANT STUFF #####
#################################
our $pid = $$;
our $logdir = "/home/chanfix/gnuworld/bin";
system("mv $adminlog $adminlog.roll");
system("kill -HUP `pidof gnuworld`");
$adminlog .= ".roll";
&maillog($adminlog,$adminemail);
sub maillog($$)
{
my ($logfile,$email) = @_;
my ($line,$log);
open(IN, "<$logfile") || die "Cannot open $logfile: $!\n";
while ($line = <IN>) { $log .= $line; }
close IN;
my $smtp = new Net::SMTP($MX);
$smtp->mail('chanfix@mynet.org');
$smtp->to($email);
$smtp->data($log);
$smtp->quit;
}
+381
View File
@@ -0,0 +1,381 @@
include/events.h | 2 +
include/iServer.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++-
libircu/msg_CM.cc | 18 +++++++++++++++
libircu/msg_M.cc | 13 +++++++++++
libircu/msg_S.cc | 9 +++++--
libircu/msg_Server.cc | 3 ++
src/Network.cc | 10 +++-----
src/iServer.cc | 37 ++++++++++++++++++++++++++++++++
src/main.cc | 4 +--
src/server.cc | 2 -
src/server_connection.cc | 3 ++
11 files changed, 142 insertions(+), 13 deletions(-)
Index: include/events.h
===================================================================
RCS file: /cvsroot/gnuworld/gnuworld/include/events.h,v
retrieving revision 1.19
diff -u -r1.19 events.h
--- include/events.h 29 Sep 2005 17:40:06 -0000 1.19
+++ include/events.h 27 Sep 2006 02:56:56 -0000
@@ -74,6 +74,7 @@
{
EVT_JOIN = EVT_NOOP,
EVT_PART,
+ EVT_SERVERMODE, // when servers perform modes.
EVT_TOPIC, // passed even if TRACK_TOPIC is disabled
EVT_KICK, // moved to xClient::OnNetworkKick()
EVT_CREATE
@@ -150,6 +151,7 @@
"Channel Topic Change", /* EVT_TOPIC */
"Channel Kick", /* EVT_KICK */
"Channel Create" /* EVT_CREATE */
+ "Channel Mode By Server" /* EVT_SERVERMODE */
} ;
} // namespace gnuworld
Index: include/iServer.h
===================================================================
RCS file: /cvsroot/gnuworld/gnuworld/include/iServer.h,v
retrieving revision 1.14
diff -u -r1.14 iServer.h
--- include/iServer.h 29 Dec 2003 23:59:36 -0000 1.14
+++ include/iServer.h 27 Sep 2006 02:56:57 -0000
@@ -60,8 +60,17 @@
/// Type used to hold flags
typedef unsigned int flagType ;
- /// Set if this iServer is juped, false otherwise
+ /**
+ * Flags that iServers may have.
+ */
+ /* Set if this iServer is juped, false otherwise */
static const flagType FLAG_JUPE ;
+ /* Set if this iServer is a hub (+h) */
+ static const flagType FLAG_HUB ;
+ /* Set if this iServer is a service (+s) */
+ static const flagType FLAG_SERVICE ;
+ /* Set if this iServer is IPv6-compatible (+6) */
+ static const flagType FLAG_IPV6 ;
/**
* Construct an iServer given its vital state variables
@@ -117,6 +126,42 @@
{ setFlag( FLAG_JUPE ) ; }
/**
+ * Return true if this server is a hub.
+ */
+ inline bool isHub() const
+ { return getFlag( FLAG_HUB ) ; }
+
+ /**
+ * Set this iServer as a hub.
+ */
+ inline void setHub()
+ { setFlag( FLAG_HUB ) ; }
+
+ /**
+ * Return true if this server is a service.
+ */
+ inline bool isService() const
+ { return getFlag( FLAG_SERVICE ) ; }
+
+ /**
+ * Set this iServer as a service.
+ */
+ inline void setService()
+ { setFlag( FLAG_SERVICE ) ; }
+
+ /**
+ * Return true if this server is IPv6-compatible.
+ */
+ inline bool isIPv6() const
+ { return getFlag( FLAG_IPV6 ) ; }
+
+ /**
+ * Set this iServer as IPv6-compatible.
+ */
+ inline void setIPv6()
+ { setFlag( FLAG_IPV6 ) ; }
+
+ /**
* Return the server numeric of this server's uplink.
*/
inline const unsigned int& getUplinkIntYY() const
@@ -212,6 +257,13 @@
return out ;
}
+ /* Mutator methods */
+
+ /**
+ * Interpret a server's flags.
+ */
+ void setFlags( const std::string& ) ;
+
protected:
/**
Index: libircu/msg_CM.cc
===================================================================
RCS file: /cvsroot/gnuworld/gnuworld/libircu/msg_CM.cc,v
retrieving revision 1.9
diff -u -r1.9 msg_CM.cc
--- libircu/msg_CM.cc 24 Jun 2005 22:48:59 -0000 1.9
+++ libircu/msg_CM.cc 27 Sep 2006 02:56:57 -0000
@@ -81,6 +81,24 @@
bool clearVoice = false ;
bool clearBans = false ;
+// Go ahead and post the server mode event
+iServer* serverSource = 0 ;
+
+if( NULL != strchr( Param[ 0 ], '.' ) )
+ {
+ // Server, by name
+ serverSource = Network->findServerName( Param[ 0 ] ) ;
+ }
+else if( strlen( Param[ 0 ] ) < 3 )
+ {
+ // 1 or 2 char numeric, server
+ serverSource = Network->findServer( Param[ 0 ] ) ;
+ }
+
+if (serverSource != 0)
+ theServer->PostChannelEvent( EVT_SERVERMODE, tmpChan,
+ static_cast< void* >( serverSource ));
+
xServer::modeVectorType modeVector ;
for( std::string::size_type i = 0 ; i < Modes.size() ; i++ )
Index: libircu/msg_M.cc
===================================================================
RCS file: /cvsroot/gnuworld/gnuworld/libircu/msg_M.cc,v
retrieving revision 1.12
diff -u -r1.12 msg_M.cc
--- libircu/msg_M.cc 29 Sep 2005 17:40:06 -0000 1.12
+++ libircu/msg_M.cc 27 Sep 2006 02:56:58 -0000
@@ -129,6 +129,19 @@
return false ;
}
+if( serverSource != 0 )
+ {
+// elog << "msg_M ("
+// << theChan->getName()
+// << ") server "
+// << serverSource->getName()
+// << " performed a mode"
+// << endl;
+ theServer->PostChannelEvent( EVT_SERVERMODE, theChan,
+ static_cast< void* >( serverSource ));
+ }
+
+/* XXX OPMODE FAILS HERE */
// Find the ChannelUser of the source client
// It is possible that the ChannelUser will be NULL, in the
// case that a server is setting the mode(s)
Index: libircu/msg_S.cc
===================================================================
RCS file: /cvsroot/gnuworld/gnuworld/libircu/msg_S.cc,v
retrieving revision 1.5
diff -u -r1.5 msg_S.cc
--- libircu/msg_S.cc 25 Mar 2005 03:07:29 -0000 1.5
+++ libircu/msg_S.cc 27 Sep 2006 02:56:58 -0000
@@ -47,10 +47,10 @@
/**
* New server joined the network.
- * Q S irc.dynmc.net 2 0 948159347 P10 BD] 0 :[209.0.37.10]
+ * Q S irc.dynmc.net 2 0 948159347 P10 BD] +h :[209.0.37.10]
* [209.0.37.10] Dynamic Networking Solutions
*
- * B S EUWorld1.test.net 3 0 947284938 P10 OD] 0 :[128.227.184.152]
+ * B S EUWorld1.test.net 3 0 947284938 P10 OD] +s :[128.227.184.152]
* EUWorld Undernet Service
* B: Uplink Server numeric
* S: SERVER message
@@ -61,7 +61,7 @@
* P10: Protocol
* B: Server numeric
* D]: Last used nick number for clients
- * 0: Unused
+ * +h/+s: server flags
* EUWorld Undernet Server: description
* As always, the second token, the command, is not
* included in the xParameters passed here.
@@ -128,6 +128,9 @@
newServer->setBursting( true ) ;
}
+// Set any appropriate server flags
+newServer->setFlags( params[ 7 ] ) ;
+
Network->addServer( newServer ) ;
//elog << "msg_S> Added server: "
// << *newServer
Index: libircu/msg_Server.cc
===================================================================
RCS file: /cvsroot/gnuworld/gnuworld/libircu/msg_Server.cc,v
retrieving revision 1.6
diff -u -r1.6 msg_Server.cc
--- libircu/msg_Server.cc 25 Mar 2005 03:07:29 -0000 1.6
+++ libircu/msg_Server.cc 27 Sep 2006 02:56:58 -0000
@@ -107,6 +107,9 @@
tmpUplink->setBursting( true ) ;
}
+ // Set any appropriate server flags
+ tmpUplink->setFlags( Param[ 6 ] ) ;
+
theServer->setUplink( tmpUplink ) ;
// Find this server (me)
Index: src/Network.cc
===================================================================
RCS file: /cvsroot/gnuworld/gnuworld/src/Network.cc,v
retrieving revision 1.73
diff -u -r1.73 Network.cc
--- src/Network.cc 4 Oct 2005 17:45:01 -0000 1.73
+++ src/Network.cc 27 Sep 2006 02:57:03 -0000
@@ -1040,8 +1040,6 @@
bool xNetwork::allocateClientNumeric( unsigned int intYY,
unsigned int& newIntXXX )
{
-newIntXXX = 0 ;
-
// First verify that the given intYY corresponds to a
// fake server (including the xServer).
reservedNumeric_iterator rsItr = reservedNumericMap.find( intYY ) ;
@@ -1060,7 +1058,8 @@
// If the for loop traverses all possible values of
// unsigned int, it will eventually hit 0 again, and
// the loop will terminate.
-for( newIntXXX = 1 ; newIntXXX != 0 ; ++newIntXXX )
+unsigned int maxIntXXX = base64toint("]]]", 3);
+for( newIntXXX = 0 ; newIntXXX <= maxIntXXX ; ++newIntXXX )
{
// elog << "xNetwork::allocateClientNumeric> Checking: "
// << newIntXXX
@@ -1079,10 +1078,9 @@
}
// Check if all values were examined
-if( 0 == newIntXXX )
+if( newIntXXX > maxIntXXX )
{
- elog << "xNetwork::allocateClientNumeric> Looped unsigned "
- << "int"
+ elog << "xNetwork::allocateClientNumeric> Exceeded maxIntXXX"
<< endl ;
return false ;
}
Index: src/iServer.cc
===================================================================
RCS file: /cvsroot/gnuworld/gnuworld/src/iServer.cc,v
retrieving revision 1.10
diff -u -r1.10 iServer.cc
--- src/iServer.cc 12 Jan 2005 03:50:38 -0000 1.10
+++ src/iServer.cc 27 Sep 2006 02:57:05 -0000
@@ -38,6 +38,9 @@
using std::string ;
const iServer::flagType iServer::FLAG_JUPE = 0x01 ;
+const iServer::flagType iServer::FLAG_HUB = 0x02 ;
+const iServer::flagType iServer::FLAG_SERVICE = 0x04 ;
+const iServer::flagType iServer::FLAG_IPV6 = 0x08 ;
iServer::iServer( const unsigned int& _uplink,
const string& _yyxxx,
@@ -57,4 +60,38 @@
iServer::~iServer()
{}
+/**
+ * Interpret a server's flags.
+ *
+ * @param[in] newFlags String listing server's P10 flags.
+ */
+void iServer::setFlags( const string& newFlags )
+{
+for( string::size_type i = 0 ; i < newFlags.size() ; i++ )
+ {
+ switch( newFlags[ i ] )
+ {
+ case 'h':
+ setHub() ;
+ break ;
+ case 's':
+ setService() ;
+ break ;
+ case '6':
+ setIPv6() ;
+ break ;
+ case '+':
+ break ;
+ default:
+ // Unknown flag
+ elog << "iServer> Unknown server flag: "
+ << newFlags[ i ]
+ << ", in flags string: "
+ << newFlags
+ << std::endl ;
+ break ;
+ } // switch
+ } // for
+} // setFlags()
+
} // namespace gnuworld
Index: src/main.cc
===================================================================
RCS file: /cvsroot/gnuworld/gnuworld/src/main.cc,v
retrieving revision 1.65
diff -u -r1.65 main.cc
--- src/main.cc 12 Jan 2005 03:50:38 -0000 1.65
+++ src/main.cc 27 Sep 2006 02:57:06 -0000
@@ -369,9 +369,9 @@
// All output for the xClients should be in the
// output buffer by now, go ahead and put the
// server's SQ message there as well
- Write( "%s SQ %s :%s",
- getCharYY().c_str(),
+ Write( "%s SQ %s 0 :%s",
getCharYY().c_str(),
+ getName().c_str(),
getShutDownReason().c_str() ) ;
// Make sure the SQ and all previous data are flushed
Index: src/server.cc
===================================================================
RCS file: /cvsroot/gnuworld/gnuworld/src/server.cc,v
retrieving revision 1.219
diff -u -r1.219 server.cc
--- src/server.cc 2 Jan 2006 22:29:33 -0000 1.219
+++ src/server.cc 27 Sep 2006 02:57:08 -0000
@@ -2899,7 +2899,7 @@
{
Write( "%s SQ %s %d :Unloading server",
getCharYY().c_str(),
- fakeServer->getCharYY().c_str(),
+ fakeServer->getName().c_str(),
fakeServer->getConnectTime() ) ;
}
Index: src/server_connection.cc
===================================================================
RCS file: /cvsroot/gnuworld/gnuworld/src/server_connection.cc,v
retrieving revision 1.3
diff -u -r1.3 server_connection.cc
--- src/server_connection.cc 25 Mar 2005 03:07:30 -0000 1.3
+++ src/server_connection.cc 27 Sep 2006 02:57:08 -0000
@@ -91,6 +91,9 @@
// P10 version information, bogus.
Version = 10 ;
+// Set ourselves as a service.
+me->setService() ;
+
// Initialize the connection time variable to current time.
ConnectionTime = ::time( NULL ) ;
+329
View File
@@ -0,0 +1,329 @@
/**
* responses.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: responses.h,v 1.6 2006/12/26 14:36:08 buzlip01 Exp $
*/
#ifndef __RESPONSES_H
#define __RESPONSES_H "$Id: responses.h,v 1.6 2006/12/26 14:36:08 buzlip01 Exp $"
namespace gnuworld
{
namespace cf
{
namespace language
{
/* ADDFLAG */
const int one_flag_per_addflag = 1;
const int no_such_user = 2;
const int owner_add_owner_only = 3;
const int user_man_add_owner_only = 4;
const int cant_add_flag_diff_group = 5;
const int cant_add_block_flag = 6;
const int cant_add_serveradmin_flag = 7;
const int user_already_has_flag = 8;
const int added_flag_to_user = 9;
const int norm_user_add_owner_only = 155;
/* ADDHOST */
const int cant_add_host_an_owner = 186;
const int cant_add_host_manager = 187;
const int cant_add_host_diff_group = 10;
const int already_has_hostmask = 11;
const int failed_adding_hostmask = 12;
const int adding_hostmask_to_user = 13;
const int removed_default_hostmask = 170;
/* ADDNOTE */
const int invalid_channel_name = 14;
const int note_recorded = 15;
/* ADDUSER */
const int user_already_exists = 16;
const int created_user_w_host = 17;
const int created_user_wo_host = 18;
const int error_creating_user = 19;
/* ALERT */
const int alert_already_set = 20;
const int alert_flag_added = 21;
/* BLOCK */
const int channel_blocking_disabled = 22;
const int channel_already_blocked = 23;
const int channel_has_been_blocked = 24;
const int aborting_manual_fix = 178;
const int aborting_auto_fix = 179;
/* CANFIX */
const int canfix_op_accounts = 197;
const int canfix_rank_score_acc_header = 198;
const int can_fix_not_enough_points = 199;
const int canfix_manual_fix_disabled = 204;
/* CHANFIX */
const int manual_fix_disabled = 25;
const int not_enough_servers = 26;
const int no_such_channel = 27;
const int registered_channel = 29;
const int no_scores_for_chan = 30;
const int already_being_man_fixed = 31;
const int highscore_channel = 32;
const int channel_being_auto_fixed = 33;
const int channel_blocked = 34;
const int channel_has_notes = 35;
const int manual_chanfix_ack = 36;
const int temporarily_blocked_override = 189;
const int score_not_high_enough = 196;
const int not_enough_servers_non_oper = 200;
const int channel_being_auto_fixed_noper = 201;
const int channel_blocked_non_oper = 202;
const int channel_temp_blocked = 211;
/* CHECK */
const int check_results = 37;
/* DELFLAG */
const int one_flag_per_delflag = 38;
const int only_owner_del_owner_flag = 39;
const int only_owner_del_user_flag = 40;
const int cant_delete_flag_diff_group = 41;
const int cant_remove_block_flag = 42;
const int cant_remove_server_flag = 43;
const int user_does_not_have_flag = 44;
const int deleted_flag = 45;
const int only_owner_del_norm_flag = 156;
/* DELHOST */
const int cant_del_host_an_owner = 184;
const int cant_del_host_manager = 185;
const int cant_del_host_diff_group = 46;
const int user_doesnt_have_host = 47;
const int failed_deleting_host = 48;
const int deleted_hostmask = 49;
/* DELNOTE */
const int no_entry_in_db = 50;
const int chan_has_no_notes = 51;
const int error_checking_noteid = 52;
const int no_note_with_id = 53;
const int no_note_id_for_chan = 54;
const int note_not_added_by_you = 55;
const int note_not_manually_added = 56;
const int note_deleted = 57;
/* DELUSER */
const int cant_delete_an_owner = 58;
const int cant_delete_manager = 59;
const int cant_delete_from_diff_group = 60;
const int deleted_user = 61;
const int error_deleting_user = 62;
/* HISTORY */
const int chan_no_manual_fixes = 63;
const int error_occured_notes = 64;
const int chan_manually_fix = 65;
const int end_of_list = 67;
/* INFO */
const int no_info_for_chan = 68;
const int information_on = 69;
const int info_chan_blocked = 70;
const int info_chan_being_fixed = 71;
const int info_chan_being_autofixed = 72;
const int info_notes_count = 73;
const int end_of_information = 74;
const int info_chan_alerted = 75;
const int info_notes = 76;
const int temporarily_blocked = 188;
const int info_fix_started = 192;
const int info_fix_waiting = 193;
const int info_chan_temp_blocked = 214;
/* INVITE */
const int cant_find_channel = 77;
const int chanfix_not_in_chan = 78;
const int already_in_channel = 79;
/* LASTCOM */
const int lastcom_too_far_back = 208;
const int lastcom_listing_messages = 209;
const int end_of_log = 210;
/* LISTBLOCKED */
const int listblocks_blocked_chans = 190;
const int listblocked_total_blocked = 191;
/* LISTHOSTS */
const int cant_view_hosts_diff_group = 163;
const int host_list_header = 164;
const int host_list_footer = 165;
/* OPLIST */
const int top_unique_op_accounts = 80;
const int found_unique_op_accounts = 81;
const int rank_score_acc_header = 82;
const int end_of_oplist = 207;
/* OPNICKS */
const int opped_clients_on = 83;
const int one_opped_client = 84;
const int opped_clients = 85;
/* REHASH */
const int reloaded_help = 86;
const int reloaded_conf = 87;
/* RELOAD */
const int reloading_client = 88;
/* REQUESTOP */
const int requestop_ack = 205;
const int requestop_must_wait = 206;
/* SCORE */
const int score_for_channel_nick = 89;
const int score_for_channel_account = 158;
const int compact_no_such_nick = 90;
const int no_such_nick = 91;
const int compact_no_score_for_account = 156;
const int no_score_for_account = 157;
const int score_none = 92;
const int top_scores_for_chan = 93;
const int top_scores_for_ops = 94;
const int top_scores_for_nonops = 95;
const int no_score_for_nick = 166;
const int compact_no_score_for_nick = 167;
/* SET */
const int num_server_syntax = 96;
const int num_servers_set = 97;
const int enabled_autofix = 98;
const int disabled_autofix = 99;
const int enable_autofix_syntax = 100;
const int enabled_manual_chanfix = 101;
const int disabled_manual_chanfix = 102;
const int enable_chanfix_syntax = 103;
const int enabled_chan_blocking = 104;
const int disabled_chan_blocking = 105;
const int enable_chan_blocking_syntax = 106;
const int setting_doesnt_exist = 107;
/* SETGROUP */
const int user_already_in_group = 108;
const int set_group_for_user = 109;
/* SHUTDOWN */
const int shutting_down = 110;
const int update_in_progress = 173;
/* SIMULATE */
const int manual_simulate_complete = 221;
const int manual_simulate_starting = 224;
const int manual_simulate_estimate = 225;
/* STATUS */
const int status_uptime = 111;
const int status_auto_fixing = 112;
const int status_manual_fixing = 113;
const int status_chan_blocking = 114;
const int status_servers_amount = 115;
const int status_splitmode_enabled = 116;
const int status_splitmode_disabled = 117;
const int status_channel_service_linked = 171;
const int status_channel_service_not_linked = 172;
const int status_total_channels = 174;
const int status_total_channels_with_extra = 175;
/* SUSPEND */
const int cant_suspend_an_owner = 180;
const int cant_suspend_manager = 181;
const int cant_suspend_diff_group = 118;
const int user_already_suspended = 119;
const int user_suspended = 120;
const int user_cant_suspend_self = 159;
/* UNALERT */
const int no_alert_set = 121;
const int alert_removed = 122;
/* UNBLOCK */
const int channel_not_blocked = 123;
const int channel_unblocked = 124;
/* UNSUSPEND */
const int cant_unsuspend_an_owner = 182;
const int cant_unsuspend_manager = 183;
const int cant_unsuspend_diff_group = 125;
const int user_not_suspended = 126;
const int user_unsuspended = 127;
/* USERSCORES */
const int userscores_header = 194;
const int userscores_noscore = 195;
/* USET */
const int lang_set_to = 128;
const int send_notices = 129;
const int send_privmsgs = 130;
const int uset_notice_on_off = 131;
/* WHOFLAG */
const int one_flag_per_whoflag = 226;
/* WHOGROUP */
const int whogroup_your_group = 134;
const int users_with_group = 135;
const int number_of_users = 136;
const int whogroup_list_groups = 168;
const int number_of_groups = 169;
/* WHOIS */
const int list_of_all_users = 137;
const int user_flags_group = 138;
const int whois_suspended = 140;
const int whois_group = 142;
const int whois_flags_none = 143;
const int whois_flags = 144;
const int whois_lang = 155;
const int whois_modif = 160;
const int whois_needoper_yes = 161;
const int whois_needoper_no = 162;
const int whois_lastused = 176;
const int whois_lastused_never = 177;
/* chanfix.cc */
const int no_commands_during_burst = 145;
const int unknown_command = 146;
const int access_suspended = 147;
const int host_not_matching = 148;
const int need_to_auth = 149;
const int requires_flag = 150;
const int requires_flags = 151;
const int requires_auth_and_flag = 152;
const int requires_auth_and_flags = 153;
const int syntax = 154;
const int no_commands_during_burst_noper = 203;
const int sim_opping = 222;
const int sim_modes_removed = 223;
} // namespace language
} // namespace cf
} // namespace gnuworld
#endif /* __RESPONSES_H */
+94
View File
@@ -0,0 +1,94 @@
/**
* sqlChanOp.cc
*
* Author: Matthias Crauwels <ultimate_@wol.be>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: sqlChanOp.cc,v 1.6 2010/03/04 04:24:12 hidden1 Exp $
*/
#include <sstream>
#include <string>
#include "dbHandle.h"
#include "ELog.h"
#include "misc.h"
#include "chanfix.h"
#include "sqlChanOp.h"
namespace gnuworld
{
namespace cf
{
sqlChanOp::sqlChanOp(sqlManager* _myManager) :
channel(""),
account(""),
nickUserHost(""),
points(0),
ts_firstopped(0),
ts_lastopped(0),
day()
{
myManager = _myManager;
OldestOp = false;
}
void sqlChanOp::setAllMembers(dbHandle* theDB, int row)
{
channel = theDB->GetValue(row, 0);
account = theDB->GetValue(row, 1);
nickUserHost = theDB->GetValue(row, 2);
ts_firstopped = atoi(theDB->GetValue(row, 3));
ts_lastopped = atoi(theDB->GetValue(row, 4));
day[0] = atoi(theDB->GetValue(row, 5));
day[1] = atoi(theDB->GetValue(row, 6));
day[2] = atoi(theDB->GetValue(row, 7));
day[3] = atoi(theDB->GetValue(row, 8));
day[4] = atoi(theDB->GetValue(row, 9));
day[5] = atoi(theDB->GetValue(row, 10));
day[6] = atoi(theDB->GetValue(row, 11));
day[7] = atoi(theDB->GetValue(row, 12));
day[8] = atoi(theDB->GetValue(row, 13));
day[9] = atoi(theDB->GetValue(row, 14));
day[10] = atoi(theDB->GetValue(row, 15));
day[11] = atoi(theDB->GetValue(row, 16));
day[12] = atoi(theDB->GetValue(row, 17));
day[13] = atoi(theDB->GetValue(row, 18));
calcTotalPoints();
}
void sqlChanOp::calcTotalPoints()
{
int i;
points = 0;
for (i = 0; i < DAYSAMPLES; i++) {
points += day[i];
}
}
sqlChanOp::~sqlChanOp()
{
// No heap space allocated
}
} // namespace cf
} // namespace gnuworld
+138
View File
@@ -0,0 +1,138 @@
/**
* sqlChanOp.h
*
* Author: Matthias Crauwels <ultimate_@wol.be>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: sqlChanOp.h,v 1.6 2010/03/04 04:24:12 hidden1 Exp $
*/
#ifndef __SQLCHANOP_H
#define __SQLCHANOP_H "$Id: sqlChanOp.h,v 1.6 2010/03/04 04:24:12 hidden1 Exp $"
#include <string>
#include "dbHandle.h"
#include "chanfix_config.h"
namespace gnuworld
{
namespace cf
{
class sqlManager;
class sqlChanOp {
public:
sqlChanOp(sqlManager*);
virtual ~sqlChanOp();
/*
* Methods to get data attributes.
*/
inline const std::string& getChannel() const
{ return channel ; }
inline const std::string& getAccount() const
{ return account ; }
inline const int& getPoints() const
{ return points ; }
#ifdef ENABLE_NEWSCORES
inline const int& getBonus() const
{ return bonus; }
#endif
inline const std::string& getLastSeenAs() const
{ return nickUserHost ; }
inline const time_t getTimeFirstOpped() const
{ return ts_firstopped ; }
inline const time_t getTimeLastOpped() const
{ return ts_lastopped ; }
inline const short& getDay(int _dayval) const
{ return day[_dayval] ; }
inline const bool isOldestOp() const
{ return OldestOp; }
/*
* Methods to set data attributes.
*/
inline void setChannel(std::string _channel)
{ channel = _channel ; }
inline void setAccount(std::string _account)
{ account = _account ; }
#ifdef ENABLE_NEWSCORES
inline void setBonus(int _bonus)
{ bonus = _bonus; }
#endif
inline void setPoints(short _points)
{ day[currentDay] = _points; calcTotalPoints(); }
inline void addPoint()
{ day[currentDay]++; calcTotalPoints(); }
inline void setLastSeenAs(std::string _nickUserHost)
{ nickUserHost = _nickUserHost ; }
inline void setTimeFirstOpped(time_t _ts_firstopped)
{ ts_firstopped = _ts_firstopped ; }
inline void setTimeLastOpped(time_t _ts_lastopped)
{ ts_lastopped = _ts_lastopped ; }
inline void setDay(int _dayval, short _pointsval)
{ day[_dayval] = _pointsval ; }
inline void setIsOldestOp( bool _oldestOp )
{ OldestOp = _oldestOp; }
void setAllMembers(dbHandle*, int);
void calcTotalPoints();
private:
std::string channel;
std::string account;
std::string nickUserHost;
int points;
#ifdef ENABLE_NEWSCORES
int bonus;
#endif
time_t ts_firstopped;
time_t ts_lastopped;
short day[DAYSAMPLES];
bool OldestOp;
sqlManager* myManager;
}; // class
} // namespace cf
} // namespace gnuworld
#endif // __SQLCHANOP_H
+379
View File
@@ -0,0 +1,379 @@
/**
* sqlChannel.cc
*
* Author: Matthias Crauwels <ultimate_@wol.be>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: sqlChannel.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include <sstream>
#include <string>
#include "dbHandle.h"
#include "ELog.h"
#include "misc.h"
#include "sqlChannel.h"
#include "chanfix.h"
namespace gnuworld
{
namespace cf
{
const sqlChannel::flagType sqlChannel::F_BLOCKED = 0x00000001 ;
const sqlChannel::flagType sqlChannel::F_ALERT = 0x00000002 ;
const int sqlChannel::EV_MISC = 1 ; /* Uncategorized event */
const int sqlChannel::EV_NOTE = 2 ; /* Miscellaneous notes */
const int sqlChannel::EV_CHANFIX = 3 ; /* Manual chanfixes */
const int sqlChannel::EV_BLOCK = 4 ; /* Channel block */
const int sqlChannel::EV_UNBLOCK = 5 ; /* Channel unblock */
const int sqlChannel::EV_ALERT = 6 ; /* Channel alert */
const int sqlChannel::EV_UNALERT = 7 ; /* Channel unalert */
const int sqlChannel::EV_REQUESTOP = 8 ; /* Requestops */
const int sqlChannel::EV_TEMPBLOCK = 9 ; /* Temp channel block */
const int sqlChannel::EV_UNTEMPBLOCK = 10 ; /* Temp channel unblock */
const int sqlChannel::EV_SIMULATE = 11 ; /* Fix simulation */
unsigned long int sqlChannel::maxUserId = 0;
sqlChannel::sqlChannel(sqlManager* _myManager) :
id(0),
channel(),
user_name(),
last(0),
start(0),
maxScore(0),
modesRemoved(false),
flags(0),
inSQL(false)
{
myManager = _myManager;
}
void sqlChannel::setAllMembers(dbHandle* theDB, int row)
{
id = atoi(theDB->GetValue(row, 0));
channel = theDB->GetValue(row, 1);
flags = atoi(theDB->GetValue(row, 2));
inSQL = true;
if (id > maxUserId) maxUserId = id;
}
/**
* This function inserts a brand new channel into the DB.
*/
bool sqlChannel::Insert(dbHandle* cacheCon)
{
/* Get a connection instance to our backend */
//dbHandle* cacheCon = myManager->getConnection();
/* Grab the next available user id */
id = ++maxUserId;
/* Create the INSERT statement */
std::stringstream insertString;
insertString << "INSERT INTO channels "
<< "(id, channel, flags) "
<< "VALUES "
<< "("
<< id << ", "
<< "'" << escapeSQLChars(channel) << "', "
<< flags
<< ")"
;
if (!cacheCon->Exec(insertString.str())) {
elog << "sqlChannel::Insert> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
inSQL = false;
maxUserId--;
} else {
inSQL = true;
}
/* Dispose of our connection instance */
//myManager->removeConnection(cacheCon);
return inSQL;
} // sqlChannel::Insert()
bool sqlChannel::Delete(dbHandle* cacheCon)
{
bool retval = false;
/* Get a connection instance to our backend */
//dbHandle* cacheCon = myManager->getConnection();
/* Create the DELETE statement */
std::stringstream deleteString;
deleteString << "DELETE FROM channels "
<< "WHERE id = '" << id << "'"
;
if (!cacheCon->Exec(deleteString.str())) {
elog << "sqlChannel::Delete> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = false;
} else
retval = true;
/* Dispose of our connection instance */
//myManager->removeConnection(cacheCon);
return retval;
}
bool sqlChannel::commit(dbHandle* cacheCon)
{
bool retval = false;
/* Get a connection instance to our backend */
//dbHandle* cacheCon = myManager->getConnection();
/* Create the UPDATE statement */
std::stringstream chanCommit;
chanCommit << "UPDATE channels SET "
<< "flags = " << flags
<< " WHERE "
<< "id = " << id
;
if (!cacheCon->Exec(chanCommit.str())) {
elog << "sqlChannel::commit> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = false;
} else
retval = true;
/* Dispose of our connection instance */
//myManager->removeConnection(cacheCon);
return retval;
}
/**
* This method writes a 'notes' record, recording an event that has
* occured in this channel.
*/
void sqlChannel::addNote(dbHandle* cacheCon, unsigned short eventType, iClient* theUser,
const std::string& theMessage)
{
unsigned int num_notes = countNotes(cacheCon, 0);
while (num_notes >= MAXNOTECOUNT) {
if (!deleteOldestNote(cacheCon))
return;
num_notes--;
}
/* Get a connection instance to our backend */
//dbHandle* cacheCon = myManager->getConnection();
/* Create the INSERT statement */
std::stringstream theLog;
theLog << "INSERT INTO notes (ts, channelID, user_name, event, message) "
<< "VALUES ("
<< "date_part('epoch', CURRENT_TIMESTAMP)::int"
<< ", "
<< id
<< ", '"
<< theUser->getAccount()
<< "', "
<< eventType
<< ", "
<< "'"
<< escapeSQLChars(theMessage)
<< "')"
;
if (!cacheCon->Exec(theLog.str())) {
elog << "sqlChannel::addNote> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
}
/* Dispose of our connection instance */
//myManager->removeConnection(cacheCon);
return;
}
const std::string sqlChannel::getLastNote(dbHandle* cacheCon, unsigned short eventType, time_t& eventTime)
{
std::string retval;
/* Get a connection instance to our backend */
//dbHandle* cacheCon = myManager->getConnection();
/* Retrieve the last note */
std::stringstream queryString;
queryString << "SELECT message,ts"
<< " FROM notes WHERE channelID = "
<< id
<< " AND event = "
<< eventType
<< " ORDER BY ts DESC LIMIT 1"
;
if (cacheCon->Exec(queryString.str(),true)) {
if (cacheCon->Tuples() > 0) {
std::string note = cacheCon->GetValue(0, 0);
eventTime = atoi(cacheCon->GetValue(0, 1));
retval = note;
}
}
/* Dispose of our connection instance */
//myManager->removeConnection(cacheCon);
return retval;
}
bool sqlChannel::deleteNote(dbHandle* cacheCon, unsigned int messageId)
{
bool retval = false;
/* Get a connection instance to our backend */
//dbHandle* cacheCon = myManager->getConnection();
/* Create the DELETE statement */
std::stringstream deleteString;
deleteString << "DELETE FROM notes WHERE channelID = "
<< id
<< " AND id = "
<< messageId
;
if (!cacheCon->Exec(deleteString.str())) {
elog << "sqlChannel::deleteNote> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = false;
} else
retval = true;
/* Dispose of our connection instance */
//myManager->removeConnection(cacheCon);
return retval;
}
bool sqlChannel::deleteOldestNote(dbHandle* cacheCon)
{
bool retval = false;
/* Get a connection instance to our backend */
//dbHandle* cacheCon = myManager->getConnection();
/* Retrieve the id of the oldest note */
std::stringstream selectString;
selectString << "SELECT id FROM notes WHERE channelID = "
<< id
<< " ORDER BY ts ASC LIMIT 1"
;
if (cacheCon->Exec(selectString.str(),true)) {
if (cacheCon->Tuples() > 0) {
unsigned int note_id = atoi(cacheCon->GetValue(0, 0));
std::stringstream deleteString;
deleteString << "DELETE FROM notes WHERE id = "
<< note_id
;
if (cacheCon->Exec(deleteString.str(),true))
retval = true;
}
}
/* Dispose of our connection instance */
//myManager->removeConnection(cacheCon);
return retval;
}
bool sqlChannel::deleteAllNotes(dbHandle* cacheCon)
{
bool retval = false;
/* Get a connection instance to our backend */
//dbHandle* cacheCon = myManager->getConnection();
/* Create the DELETE statement */
std::stringstream deleteString;
deleteString << "DELETE FROM notes WHERE channelID = "
<< id
;
if (!cacheCon->Exec(deleteString.str())) {
elog << "sqlChannel::deleteAllNotes> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = false;
} else
retval = true;
/* Dispose of our connection instance */
//myManager->removeConnection(cacheCon);
return retval;
}
size_t sqlChannel::countNotes(dbHandle* cacheCon, unsigned short eventType)
{
/* Get a connection instance to our backend */
//dbHandle* cacheCon = myManager->getConnection();
/* Count the notes */
std::stringstream queryString;
queryString << "SELECT count(id) FROM notes WHERE channelID = "
<< id
;
if (eventType) {
queryString << " AND event = "
<< eventType
;
}
size_t num_notes = 0;
if (cacheCon->Exec(queryString.str(),true))
num_notes = atoi(cacheCon->GetValue(0, 0));
/* Dispose of our connection instance */
//myManager->removeConnection(cacheCon);
return num_notes;
}
sqlChannel::~sqlChannel()
{
// No heap space allocated
}
} // namespace cf
} // namespace gnuworld
+205
View File
@@ -0,0 +1,205 @@
/**
* sqlChannel.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: sqlChannel.h,v 1.7 2008/01/16 02:03:39 buzlip01 Exp $
*/
#ifndef __SQLCHANNEL_H
#define __SQLCHANNEL_H "$Id: sqlChannel.h,v 1.7 2008/01/16 02:03:39 buzlip01 Exp $"
#include <string>
#include <ctime>
#include "client.h"
#include "dbHandle.h"
namespace gnuworld
{
namespace cf
{
class sqlcfUser;
class sqlManager;
class sqlChannel
{
public:
sqlChannel(sqlManager*);
virtual ~sqlChannel();
typedef unsigned int flagType ;
static const flagType F_BLOCKED;
static const flagType F_ALERT;
/*
* Channel 'Event' Flags, used in the channelog table.
* These flags are used to filter channel log records.
* in reports.
*/
static const int EV_MISC; /* Uncategorised event */
static const int EV_NOTE; /* Miscellaneous notes */
static const int EV_CHANFIX; /* Manual chanfixes */
static const int EV_SIMULATE; /* Fix simulation */
static const int EV_BLOCK; /* Channel block */
static const int EV_TEMPBLOCK; /* Temp channel block */
static const int EV_UNTEMPBLOCK; /* Temp channel block */
static const int EV_UNBLOCK; /* Channel unblock */
static const int EV_ALERT; /* Channel alert */
static const int EV_UNALERT; /* Channel unalert */
static const int EV_REQUESTOP; /* Requestops */
/*
* Methods to get data atrributes.
*/
inline const unsigned int& getID() const
{ return id ; }
inline const std::string& getChannel() const
{ return channel ; }
inline const flagType& getFlags() const
{ return flags ; }
inline bool getFlag( const flagType& whichFlag ) const
{ return (flags & whichFlag) ; }
inline time_t getLastAttempt() const
{ return last ; }
inline time_t getLastSimAttempt() const
{ return simlast ; }
inline time_t getFixStart() const
{ return start ; }
inline time_t getSimStart() const
{ return simstart ; }
inline int getMaxScore() const
{ return maxScore ; }
inline int getAmountSimOpped() const
{ return amtopped ; }
inline int getTMaxScore() const
{ return tmaxScore ; }
inline bool getModesRemoved() const
{ return modesRemoved ; }
inline bool getSimModesRemoved() const
{ return simModesRemoved ; }
inline bool useSQL() const
{ return inSQL ; }
/*
* Methods to set data atrributes.
*/
// 'ID' is a primary key and cannot be altered.
inline void setID( const unsigned int& _id )
{ id = _id; }
inline void setChannel(const std::string& _channel)
{ channel = _channel; }
inline void setFlag( const flagType& whichFlag )
{ flags |= whichFlag; }
inline void removeFlag( const flagType& whichFlag )
{ flags &= ~whichFlag; }
inline void clearFlags()
{ flags = 0; }
inline void setLastAttempt (time_t _last)
{ last = _last; }
inline void setLastSimAttempt (time_t _simlast)
{ simlast = _simlast; }
inline void setFixStart(time_t _start)
{ start = _start; }
inline void setSimStart(time_t _simstart)
{ simstart = _simstart; }
inline void setAmountSimOpped(unsigned int _amtopped)
{ amtopped = _amtopped; }
inline void setMaxScore(unsigned int _maxScore)
{ maxScore = _maxScore; }
inline void setTMaxScore(unsigned int _tmaxScore)
{ tmaxScore = _tmaxScore; }
inline void setModesRemoved(bool _modesRemoved)
{ modesRemoved = _modesRemoved; }
inline void setSimModesRemoved(bool _simModesRemoved)
{ simModesRemoved = _simModesRemoved; }
inline void setUseSQL(bool _inSQL)
{ inSQL = _inSQL; }
bool Insert(dbHandle*);
bool Delete(dbHandle*);
bool commit(dbHandle*);
void setAllMembers(dbHandle*, int);
/** Static member for keeping track of max user id */
static unsigned long int maxUserId;
void addNote(dbHandle*, unsigned short, iClient*, const std::string&);
bool deleteNote(dbHandle*, unsigned int);
bool deleteOldestNote(dbHandle*);
bool deleteAllNotes(dbHandle*);
size_t countNotes(dbHandle*, unsigned short);
const std::string getLastNote(dbHandle*, unsigned short, time_t&);
protected:
unsigned int id;
std::string channel;
std::string user_name;
time_t last;
time_t simlast;
time_t start;
time_t simstart;
unsigned int amtopped;
unsigned int maxScore;
unsigned int tmaxScore;
bool modesRemoved;
bool simModesRemoved;
flagType flags;
bool inSQL;
sqlManager* myManager;
}; // class sqlChannel
} // namespace cf
} // namespace gnuworld
#endif // __SQLCHANNEL_H
+144
View File
@@ -0,0 +1,144 @@
/**
* sqlManager.cc
*
* Author: Rasmus Hansen <jeekay@netgamers.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: sqlManager.cc,v 1.6 2009/01/15 08:31:07 denspike Exp $
*/
#include <new>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include "gnuworld_config.h"
#include "ELog.h"
#include "sqlManager.h"
namespace gnuworld
{
namespace cf
{
/* Initialize our static data members */
sqlManager* sqlManager::theManager = 0;
/*********************************
** S T A T I C M E T H O D S **
*********************************/
/**
* Implementation of singleton - this is the only way to get a reference to
* the sqlManager instance, and it does not allow modification.
* initialise must be called prior to attempted to obtain an instance.
* This method is static.
*/
sqlManager* sqlManager::getInstance(const std::string& _dbString)
{
if(theManager) return theManager;
/* There is currently no sqlManager instance */
return new sqlManager(_dbString);
} // static sqlManager* sqlManager::getInstance(const std::string&)
/*********************************
** P U B L I C M E T H O D S **
*********************************/
/**
* This method creates and returns a connection to the database.
* It will use the stored dbString to create the connection.
*/
dbHandle* sqlManager::getConnection()
{
elog << "*** [sqlManager:getConnection] Attempting DB connection to: "
<< dbString << std::endl;
dbHandle* tempCon = new (std::nothrow) dbHandle(dbString);
assert(tempCon != 0);
if(tempCon->ConnectionBad()) {
elog << "*** [sqlManager:getConnection] Unable to connect to DB: "
<< tempCon->ErrorMessage() << std::endl;
::exit(0);
} else {
elog << "*** [sqlManager:getConnection] Connection established to DB."
<< std::endl;
}
return tempCon;
}
/**
* This method will disconnect and destroy a database connection.
* This method should never be passed a null pointer.
*/
void sqlManager::removeConnection(dbHandle* tempCon)
{
assert(tempCon != 0);
elog << "*** [sqlManager:removeConnection] Removing DB connection." << std::endl;
delete tempCon; tempCon = 0;
}
/**
* This is our destructor that ensures the proper teardown of
* our DB link and clears out any memory currently in use by
* objects
*/
void sqlManager::removeManager()
{
/* Destruct our DB object */
elog << "*** [sqlManager] Shutting down DB communications." << std::endl;
removeConnection(SQLDb);
delete theManager; theManager = 0;
} // sqlManager::removeManager()
/*****************************************************
** C O N S T R U C T O R & D E S T R U C T O R **
*****************************************************/
/**
* This is our constructor that initialises DB communications.
* It is only ever called from initialize().
*/
sqlManager::sqlManager(const std::string& _dbString)
{
/* Construct our DB object */
dbString = _dbString;
SQLDb = getConnection();
} // sqlManager::sqlManager(const std::string&)
/**
* This is a dummy destructor.
* The real code is in sqlManager::removeManager().
*/
sqlManager::~sqlManager()
{
} // sqlManager::~sqlManager()
} // namespace cf
} // namespace gnuworld
+84
View File
@@ -0,0 +1,84 @@
/**
* sqlManager.h
*
* Author: Rasmus Hansen <jeekay@netgamers.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: sqlManager.h,v 1.5 2007/08/28 16:10:25 dan_karrels Exp $
*/
#ifndef __SQLMANAGER_H
#define __SQLMANAGER_H "$Id: sqlManager.h,v 1.5 2007/08/28 16:10:25 dan_karrels Exp $"
#include <string>
#include <vector>
#include "dbHandle.h"
namespace gnuworld
{
namespace cf
{
class sqlManager {
public:
/**
* Implement sqlManager as a singleton
* Only way to get a reference to the manager is through this method
*/
static sqlManager* getInstance(const std::string&);
/** Allow checking out of database connections */
dbHandle* getConnection();
/** Allow checking in of database connections */
void removeConnection(dbHandle*);
/** Allow removal of theManager */
void removeManager();
protected:
/**
* Disable the default constructor so that instances can only be gotten
* through getInstance()
* @see #getInstance
*/
sqlManager(const std::string&);
/**
* Disable the default destructor so that other objects cannot destruct
* the instance they have a reference to.
*/
~sqlManager();
/** The string storing our DB connection path */
std::string dbString;
/** Our PgDatabase instance */
dbHandle* SQLDb;
/** The current instance of sqlManager */
static sqlManager* theManager;
}; // class sqlManager
} // namespace cf
} // namespace gnuworld
#endif // __SQLMANAGER_H
+179
View File
@@ -0,0 +1,179 @@
/**
* sqlUser.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: sqlUser.h,v 1.4 2006/12/09 00:29:20 buzlip01 Exp $
*/
#ifndef __SQLUSER_H
#define __SQLUSER_H "$Id: sqlUser.h,v 1.4 2006/12/09 00:29:20 buzlip01 Exp $"
#include <string>
#include <vector>
#include <ctime>
#include "libpq++.h"
namespace gnuworld
{
class iClient;
namespace cf
{
class sqlManager;
class sqlUser
{
public:
sqlUser(sqlManager*);
virtual ~sqlUser();
typedef unsigned short int flagType ;
static const flagType F_SERVERADMIN; /* +a */
static const flagType F_BLOCK; /* +b */
static const flagType F_COMMENT; /* +c */
static const flagType F_CHANFIX; /* +f */
static const flagType F_OWNER; /* +o */
static const flagType F_USERMANAGER; /* +u */
static const flagType F_LOGGEDIN;
typedef std::list< std::string > hostListType;
/* Methods to get data attributes. */
inline const unsigned int& getID() const
{ return id ; }
inline const std::string& getUserName() const
{ return user_name; }
inline const int getCreated() const
{ return created; }
inline const time_t getLastSeen() const
{ return last_seen; }
inline const time_t getLastUpdated() const
{ return last_updated; }
inline const std::string& getLastUpdatedBy() const
{ return last_updated_by; }
inline const unsigned int& getLanguageId() const
{ return language_id ; }
inline const std::string& getGroup() const
{ return group; }
inline bool getFlag( const flagType& whichFlag ) const
{ return ((flags & F_OWNER) || (flags & whichFlag)) ; }
inline const flagType& getFlags() const
{ return flags ; }
inline const bool getIsSuspended() const
{ return isSuspended; }
inline const bool getUseNotice() const
{ return useNotice; }
inline const bool getNeedOper() const
{ return needOper; }
inline const hostListType& getHostList() const
{ return hostList; }
/* Mutators */
inline void setUserName(const std::string& _user_name)
{ user_name = _user_name; }
inline void setCreated(const unsigned int _created)
{ created = _created; }
inline void setLastSeen(const unsigned int _last_seen)
{ last_seen = _last_seen; }
inline void setLastUpdated(const unsigned int _last_updated)
{ last_updated = _last_updated; }
inline void setLastUpdatedBy(const std::string& _last_updated_by)
{ last_updated_by = _last_updated_by; }
inline void setLanguageId(const unsigned int _language_id)
{ language_id = _language_id; }
inline void setGroup(const std::string& _group)
{ group = string_lower(_group); }
inline void setFlag(const flagType& whichFlag)
{ flags |= whichFlag; }
inline void removeFlag(const flagType& whichFlag)
{ flags &= ~whichFlag; }
inline void setSuspended(const bool _isSuspended)
{ isSuspended = _isSuspended; }
inline void setNotice(const bool _useNotice)
{ useNotice = _useNotice; }
inline void setNeedOper(const bool _needOper)
{ needOper = _needOper; }
/* Methods to alter our SQL status */
void setAllMembers(PgDatabase*, int);
bool commit();
bool Insert();
bool Delete();
/** Static member for keeping track of max user id */
static unsigned long int maxUserId;
void loadHostList();
bool addHost(const std::string&);
bool delHost(const std::string&);
bool matchHost(const std::string&);
bool hasHost(const std::string&);
private:
unsigned int id;
std::string user_name;
unsigned int created;
unsigned int last_seen;
unsigned int last_updated;
std::string last_updated_by;
unsigned int language_id;
std::string group;
flagType flags;
bool isSuspended;
bool useNotice;
bool needOper;
hostListType hostList;
sqlManager* myManager;
}; // class sqlUser
} // namespace cf
} // namespace gnuworld
#endif // __SQLUSER_H
+338
View File
@@ -0,0 +1,338 @@
/**
* sqlcfUser.cc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: sqlcfUser.cc,v 1.4 2008/01/16 02:03:40 buzlip01 Exp $
*/
#include <sstream>
#include <string>
#include "dbHandle.h"
#include "ELog.h"
#include "misc.h"
#include "chanfix.h"
#include "sqlcfUser.h"
using namespace std;
namespace gnuworld
{
using std::stringstream;
using std::string;
namespace cf
{
const sqlcfUser::flagType sqlcfUser::F_SERVERADMIN = 0x01; /* +a */
const sqlcfUser::flagType sqlcfUser::F_BLOCK = 0x02; /* +b */
const sqlcfUser::flagType sqlcfUser::F_COMMENT = 0x04; /* +c */
const sqlcfUser::flagType sqlcfUser::F_CHANFIX = 0x08; /* +f */
const sqlcfUser::flagType sqlcfUser::F_OWNER = 0x10; /* +o */
const sqlcfUser::flagType sqlcfUser::F_USERMANAGER = 0x20; /* +u */
const sqlcfUser::flagType sqlcfUser::F_PERMBLOCKER = 0x80; /* +p */
const sqlcfUser::flagType sqlcfUser::F_LOGGEDIN = 0x40;
unsigned long int sqlcfUser::maxUserId = 0;
sqlcfUser::sqlcfUser(sqlManager* _myManager) :
id(0),
user_name(),
created(0),
last_seen(0),
last_updated(0),
last_updated_by(),
language_id(0),
group(),
flags(0),
isSuspended(false),
useNotice(true),
needOper(true)
{
myManager = _myManager;
}
void sqlcfUser::setAllMembers(dbHandle* theDB, int row)
{
id = atoi(theDB->GetValue(row, 0));
user_name = theDB->GetValue(row, 1);
created = atoi(theDB->GetValue(row, 2));
last_seen = atoi(theDB->GetValue(row, 3));
last_updated = atoi(theDB->GetValue(row, 4));
last_updated_by = theDB->GetValue(row, 5);
language_id = atoi(theDB->GetValue(row, 6));
group = theDB->GetValue(row, 7);
flags = atoi(theDB->GetValue(row, 8));
isSuspended = (!strcasecmp(theDB->GetValue(row,9),"t") ? true : false);
useNotice = (!strcasecmp(theDB->GetValue(row,10),"t") ? true : false);
needOper = (!strcasecmp(theDB->GetValue(row,11),"t") ? true : false);
if (id > maxUserId) maxUserId = id;
}
bool sqlcfUser::commit(dbHandle* cacheCon)
{
bool retval = false;
/* Get a connection instance to our backend */
//dbHandle* cacheCon = myManager->getConnection();
/* Create the UPDATE statement */
std::stringstream userCommit;
userCommit << "UPDATE users SET "
<< "last_seen = " << last_seen << ", "
<< "last_updated = " << last_updated << ", "
<< "last_updated_by = '" << escapeSQLChars(last_updated_by) << "', "
<< "language_id = " << language_id << ", "
<< "faction = '" << escapeSQLChars(group) << "', "
<< "flags = " << flags << ", "
<< "issuspended = " << (isSuspended ? "'t'" : "'f'") << ", "
<< "usenotice = " << (useNotice ? "'t'" : "'f'") << ", "
<< "needoper = " << (needOper ? "'t'" : "'f'")
<< " WHERE "
<< "id = " << id
;
if (!cacheCon->Exec(userCommit.str())) {
elog << "sqlcfUser::commit> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = false;
} else
retval = true;
/* Dispose of our connection instance */
//myManager->removeConnection(cacheCon);
return retval;
}
/**
* This function inserts a brand new user into the DB.
* It is a slight fudge, in that it first creates a blank record then
* calls commit() to update the data fields for that record. This is done
* so that any new fields added will automatically be dealt with in commit()
* instead of in 50 different functions.
*/
bool sqlcfUser::Insert(dbHandle* cacheCon)
{
bool retval = false;
/* Get a connection instance to our backend */
//dbHandle* cacheCon = myManager->getConnection();
/* Grab the next available user id */
id = ++maxUserId;
/* Create the INSERT statement */
std::stringstream insertString;
insertString << "INSERT INTO users "
<< "(id, user_name) "
<< "VALUES "
<< "("
<< id << ", "
<< "'" << escapeSQLChars(user_name) << "'"
<< ")"
;
if (!cacheCon->Exec(insertString.str())) {
elog << "sqlcfUser::Insert> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = false;
maxUserId--;
} else
retval = true;
/* Dispose of our connection instance */
//myManager->removeConnection(cacheCon);
if (retval)
commit(cacheCon);
return retval;
} // sqlcfUser::Insert()
bool sqlcfUser::Delete(dbHandle* cacheCon)
{
bool retval = false;
/* Get a connection instance to our backend */
//dbHandle* cacheCon = myManager->getConnection();
/* Create the DELETE statement */
std::stringstream hostString;
hostString << "DELETE FROM hosts "
<< "WHERE user_id = " << id
;
if (!cacheCon->Exec(hostString.str())) {
elog << "sqlcfUser::Delete> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = false;
} else
retval = true;
/* Create the DELETE statement */
std::stringstream deleteString;
deleteString << "DELETE FROM users "
<< "WHERE id = '" << id << "'"
;
if (!cacheCon->Exec(deleteString.str())) {
elog << "sqlcfUser::Delete> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = false;
} else
retval = true;
/* Dispose of our connection instance */
//myManager->removeConnection(cacheCon);
return retval;
}
void sqlcfUser::loadHostList(dbHandle* cacheCon)
{
/* Get a connection instance to our backend */
// dbHandle* cacheCon = myManager->getConnection();
// if (!cacheCon)
// elog << "[sqlcfUser::loadHostList() Could not get a connection to the database from the manager." << std::endl;
/* Retrieve the hosts */
std::stringstream theQuery;
theQuery << "SELECT host FROM hosts WHERE user_id = "
<< id
<< ends ;
if (cacheCon->Exec(theQuery.str(),true)) {
// SQL Query succeeded
for (unsigned int i = 0 ; i < cacheCon->Tuples(); i++) {
hostList.push_back(cacheCon->GetValue(i, 0));
}
}
/* Dispose of our connection instance */
// myManager->removeConnection(cacheCon);
return;
}
bool sqlcfUser::addHost(dbHandle* cacheCon, const std::string& _theHost)
{
bool retval = false;
/* Get a connection instance to our backend */
//dbHandle* cacheCon = myManager->getConnection();
/* Create the INSERT statement */
std::stringstream insertString;
insertString << "INSERT INTO hosts "
<< "(user_id, host) VALUES "
<< "("
<< id
<< ", '"
<< escapeSQLChars(_theHost).c_str()
<< "')"
;
if (!cacheCon->Exec(insertString.str())) {
elog << "sqlcfUser::addHost> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = false;
} else
retval = true;
/* Dispose of our connection instance */
//myManager->removeConnection(cacheCon);
hostList.push_back(_theHost);
return retval;
}
bool sqlcfUser::delHost(dbHandle* cacheCon, const std::string& _theHost)
{
bool retval = false;
/* Get a connection instance to our backend */
//dbHandle* cacheCon = myManager->getConnection();
/* Create the DELETE statement */
std::stringstream deleteString;
deleteString << "DELETE FROM hosts "
<< "WHERE user_id = "
<< id
<< " AND lower(host) = '"
<< escapeSQLChars(string_lower(_theHost)).c_str()
<< "'"
;
if (!cacheCon->Exec(deleteString.str())) {
elog << "sqlcfUser::delHost> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = false;
} else
retval = true;
/* Dispose of our connection instance */
//myManager->removeConnection(cacheCon);
if (hostList.size() < 1) return false;
hostListType::iterator ptr = find( hostList.begin(), hostList.end(), string_lower(_theHost) );
if (ptr == hostList.end()) return false;
hostList.erase(ptr);
return retval;
}
bool sqlcfUser::matchHost(const std::string& _host)
{
if (hostList.size() < 1) return false;
for(hostListType::iterator itr = hostList.begin() ;
itr != hostList.end() ; ++itr) {
if (match(*itr,_host) == 0) return true;
}
return false;
}
bool sqlcfUser::hasHost(const std::string& _host)
{
if (hostList.size() < 1) return false;
hostListType::iterator ptr = find( hostList.begin(), hostList.end(), string_lower(_host) );
if ( ptr == hostList.end() ) return false;
return true;
}
sqlcfUser::~sqlcfUser()
{
// No heap space allocated
}
} // namespace cf
} // namespace gnuworld
+183
View File
@@ -0,0 +1,183 @@
/**
* sqlcfUser.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: sqlcfUser.h,v 1.4 2008/01/16 02:03:40 buzlip01 Exp $
*/
#ifndef __sqlcfUser_H
#define __sqlcfUser_H "$Id: sqlcfUser.h,v 1.4 2008/01/16 02:03:40 buzlip01 Exp $"
#include <string>
#include <vector>
#include <ctime>
#include <sstream>
#include "dbHandle.h"
using namespace std;
namespace gnuworld
{
class iClient;
namespace cf
{
class sqlManager;
class sqlcfUser
{
public:
sqlcfUser(sqlManager*);
virtual ~sqlcfUser();
typedef unsigned short int flagType ;
static const flagType F_SERVERADMIN; /* +a */
static const flagType F_BLOCK; /* +b */
static const flagType F_COMMENT; /* +c */
static const flagType F_CHANFIX; /* +f */
static const flagType F_OWNER; /* +o */
static const flagType F_USERMANAGER; /* +u */
static const flagType F_PERMBLOCKER; /* +p */
static const flagType F_LOGGEDIN;
typedef std::list< std::string > hostListType;
/* Methods to get data attributes. */
inline const unsigned int& getID() const
{ return id ; }
inline const std::string& getUserName() const
{ return user_name; }
inline const int getCreated() const
{ return created; }
inline const time_t getLastSeen() const
{ return last_seen; }
inline const time_t getLastUpdated() const
{ return last_updated; }
inline const std::string& getLastUpdatedBy() const
{ return last_updated_by; }
inline const unsigned int& getLanguageId() const
{ return language_id ; }
inline const std::string& getGroup() const
{ return group; }
inline bool getFlag( const flagType& whichFlag ) const
{ return ((flags & F_OWNER) || (flags & whichFlag)) ; }
inline const flagType& getFlags() const
{ return flags ; }
inline const bool getIsSuspended() const
{ return isSuspended; }
inline const bool getUseNotice() const
{ return useNotice; }
inline const bool getNeedOper() const
{ return needOper; }
inline const hostListType& getHostList() const
{ return hostList; }
/* Mutators */
inline void setUserName(const std::string& _user_name)
{ user_name = _user_name; }
inline void setCreated(const unsigned int _created)
{ created = _created; }
inline void setLastSeen(const unsigned int _last_seen)
{ last_seen = _last_seen; }
inline void setLastUpdated(const unsigned int _last_updated)
{ last_updated = _last_updated; }
inline void setLastUpdatedBy(const std::string& _last_updated_by)
{ last_updated_by = _last_updated_by; }
inline void setLanguageId(const unsigned int _language_id)
{ language_id = _language_id; }
inline void setGroup(const std::string& _group)
{ group = string_lower(_group); }
inline void setFlag(const flagType& whichFlag)
{ flags |= whichFlag; }
inline void removeFlag(const flagType& whichFlag)
{ flags &= ~whichFlag; }
inline void setSuspended(const bool _isSuspended)
{ isSuspended = _isSuspended; }
inline void setNotice(const bool _useNotice)
{ useNotice = _useNotice; }
inline void setNeedOper(const bool _needOper)
{ needOper = _needOper; }
/* Methods to alter our SQL status */
void setAllMembers(dbHandle*, int);
bool commit(dbHandle*);
bool Insert(dbHandle*);
bool Delete(dbHandle*);
/** Static member for keeping track of max user id */
static unsigned long int maxUserId;
void loadHostList(dbHandle*);
bool addHost(dbHandle*, const std::string&);
bool delHost(dbHandle*, const std::string&);
bool matchHost(const std::string&);
bool hasHost(const std::string&);
private:
unsigned int id;
std::string user_name;
unsigned int created;
unsigned int last_seen;
unsigned int last_updated;
std::string last_updated_by;
unsigned int language_id;
std::string group;
flagType flags;
bool isSuspended;
bool useNotice;
bool needOper;
hostListType hostList;
sqlManager* myManager;
}; // class sqlcfUser
} // namespace cf
} // namespace gnuworld
#endif // __sqlcfUser_H