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:
commit
fcb24f6de9
870 files changed
+311128
No files matched your search
@@ -0,0 +1,6 @@
|
||||
.deps
|
||||
.libs
|
||||
*.la
|
||||
*.lo
|
||||
Makefile
|
||||
.arch-ids
|
||||
@@ -0,0 +1,355 @@
|
||||
/**
|
||||
* ADDCOMMANDCommand.cc
|
||||
* Adds a new command 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: ADDCOMMANDCommand.cc,v 1.31 2009/07/25 18:12:34 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "ccUser.h"
|
||||
#include "misc.h"
|
||||
|
||||
RCSTAG( "$Id: ADDCOMMANDCommand.cc,v 1.31 2009/07/25 18:12:34 hidden1 Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool ADDCOMMANDCommand::Exec( iClient* theClient, const string& Message)
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if( st.size() < 3 )
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
StringTokenizer::size_type pos = 1;
|
||||
ccUser *AClient = bot->IsAuth( theClient );
|
||||
|
||||
if( NULL == AClient )
|
||||
{
|
||||
bot->Notice( theClient, "You must be authenticated to use this command." ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool Forced = false;
|
||||
if(!strcasecmp(st[pos],"-fr"))
|
||||
{
|
||||
Forced = true;
|
||||
pos++;
|
||||
if(st.size() < 4)
|
||||
{
|
||||
Usage(theClient);
|
||||
}
|
||||
}
|
||||
|
||||
bool AllOpers = false;
|
||||
bool AllAdmins = false;
|
||||
bool AllSmts = false;
|
||||
bool AllCoders = false;
|
||||
while ((!strcasecmp(st[pos],"-allopers")) || (!strcasecmp(st[pos],"-alladmins")) || (!strcasecmp(st[pos],"-allsmts")) || (!strcasecmp(st[pos],"-allcoders"))) {
|
||||
if(!strcasecmp(st[pos],"-allopers"))
|
||||
{
|
||||
if (AClient->getType() < operLevel::CODERLEVEL)
|
||||
{
|
||||
bot->Notice(theClient, "-allopers: This is coder level");
|
||||
return true;
|
||||
}
|
||||
pos++;
|
||||
AllOpers = true;
|
||||
if ((st.size() - pos) < 1)
|
||||
{
|
||||
Usage(theClient);
|
||||
}
|
||||
}
|
||||
|
||||
if(!strcasecmp(st[pos],"-alladmins"))
|
||||
{
|
||||
if (AClient->getType() < operLevel::CODERLEVEL)
|
||||
{
|
||||
bot->Notice(theClient, "-alladmins: This is coder level");
|
||||
return true;
|
||||
}
|
||||
pos++;
|
||||
AllAdmins = true;
|
||||
if ((st.size() - pos) < 1)
|
||||
{
|
||||
Usage(theClient);
|
||||
}
|
||||
}
|
||||
|
||||
if(!strcasecmp(st[pos],"-allsmts"))
|
||||
{
|
||||
if (AClient->getType() < operLevel::CODERLEVEL)
|
||||
{
|
||||
bot->Notice(theClient, "-allsmts: This is coder level");
|
||||
return true;
|
||||
}
|
||||
pos++;
|
||||
AllSmts = true;
|
||||
if ((st.size() - pos) < 1)
|
||||
{
|
||||
Usage(theClient);
|
||||
}
|
||||
}
|
||||
|
||||
if(!strcasecmp(st[pos],"-allcoders"))
|
||||
{
|
||||
if (AClient->getType() < operLevel::CODERLEVEL)
|
||||
{
|
||||
bot->Notice(theClient, "-allcoders: This is coder level");
|
||||
return true;
|
||||
}
|
||||
pos++;
|
||||
AllCoders = true;
|
||||
if ((st.size() - pos) < 1)
|
||||
{
|
||||
Usage(theClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch the oper record from the db
|
||||
ccUser* theUser;
|
||||
if (!AllOpers && !AllAdmins && !AllSmts && !AllCoders)
|
||||
{
|
||||
if (st[pos].size() > 64)
|
||||
{
|
||||
bot->Notice(theClient,"Oper name can't be more than 64 characters in length.");
|
||||
return false;
|
||||
}
|
||||
|
||||
theUser = bot->GetOper(st[pos]);
|
||||
if( !theUser )
|
||||
{
|
||||
bot->Notice( theClient,
|
||||
"I can't find oper %s",
|
||||
st[pos].c_str());
|
||||
return false;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
else
|
||||
theUser = 0;
|
||||
|
||||
//int CommandLevel = bot->getCommandLevel(st[pos]);
|
||||
if(st[pos].size() > 128)
|
||||
{
|
||||
bot->Notice(theClient,"Command name can't be more than 128 characters in length.");
|
||||
return false;
|
||||
}
|
||||
Command* Comm = bot->findCommandInMem(st[pos]);
|
||||
if( !Comm )
|
||||
{
|
||||
bot->Notice( theClient,
|
||||
"Command '%s' does not exist!",
|
||||
st[pos].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
bot->MsgChanLog("ADDCOMMAND %s\n",st.assemble(1).c_str());
|
||||
|
||||
// Only allow opers who have access to that command to add it to new opers
|
||||
if (!AClient->gotAccess(Comm) && AClient->getType() != operLevel::CODERLEVEL) // Coders can add any command
|
||||
{
|
||||
bot->Notice( theClient,
|
||||
"You must have access to a command in order to add it.");
|
||||
return false;
|
||||
}
|
||||
|
||||
list<ccUser*> ccList;
|
||||
if (!AllOpers && !AllAdmins && !AllSmts && !AllCoders)
|
||||
{
|
||||
ccList.push_back(theUser);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AllOpers)
|
||||
{
|
||||
if (AllAdmins)
|
||||
{
|
||||
bot->Notice(theClient, "No need to specify -alladmins if you specified -allopers");
|
||||
AllAdmins = false;
|
||||
}
|
||||
if (AllSmts)
|
||||
{
|
||||
bot->Notice(theClient, "No need to specify -allsmts if you specified -allopers");
|
||||
AllSmts = false;
|
||||
}
|
||||
if (AllCoders)
|
||||
{
|
||||
bot->Notice(theClient, "No need to specify -allcoders if you specified -allopers");
|
||||
AllCoders = false;
|
||||
}
|
||||
}
|
||||
if (AllAdmins)
|
||||
{
|
||||
if (AllSmts)
|
||||
{
|
||||
bot->Notice(theClient, "No need to specify -allsmts if you specified -alladmins");
|
||||
AllSmts = false;
|
||||
}
|
||||
if (AllCoders)
|
||||
{
|
||||
bot->Notice(theClient, "No need to specify -allcoders if you specified -alladmins");
|
||||
AllCoders = false;
|
||||
}
|
||||
}
|
||||
if (AllSmts)
|
||||
{
|
||||
if (AllCoders)
|
||||
{
|
||||
bot->Notice(theClient, "No need to specify -allcoders if you specified -allsmts");
|
||||
AllCoders = false;
|
||||
}
|
||||
}
|
||||
|
||||
ccontrol::usersConstIterator uItr = bot->usersMap_begin();
|
||||
for (; uItr != bot->usersMap_end(); uItr++)
|
||||
{
|
||||
if (AllOpers)
|
||||
{
|
||||
ccList.push_back(uItr->second);
|
||||
}
|
||||
else if ((AllAdmins) && (uItr->second->getType() >= operLevel::ADMINLEVEL))
|
||||
{
|
||||
ccList.push_back(uItr->second);
|
||||
}
|
||||
else if ((AllSmts) && (uItr->second->getType() >= operLevel::SMTLEVEL))
|
||||
{
|
||||
ccList.push_back(uItr->second);
|
||||
}
|
||||
else if ((AllCoders) && (uItr->second->getType() >= operLevel::CODERLEVEL))
|
||||
{
|
||||
ccList.push_back(uItr->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool sentOnce = false;
|
||||
int count = 0;
|
||||
for (list<ccUser*>::iterator Itr = ccList.begin(); Itr != ccList.end(); Itr++)
|
||||
{
|
||||
theUser = *Itr;
|
||||
|
||||
bool Admin = false ;
|
||||
if(AClient->getType() < operLevel::SMTLEVEL)
|
||||
Admin = true;
|
||||
else
|
||||
Admin = false;
|
||||
|
||||
if((Admin) && (AClient->getType() <= theUser->getType()))
|
||||
{
|
||||
bot->Notice(theClient,"You can't modify a user who has an "
|
||||
"equal or higher access level than you");
|
||||
return false;
|
||||
}
|
||||
else if(!(Admin) && (AClient->getType() < theUser->getType()))
|
||||
{
|
||||
bot->Notice(theClient,"You can't modify a user who has a higher "
|
||||
"access level than you");
|
||||
return false;
|
||||
}
|
||||
if((Admin) && (strcasecmp(AClient->getServer(),theUser->getServer())))
|
||||
{
|
||||
bot->Notice(theClient,"You can only modify a user who is "
|
||||
"associated with the same server as you");
|
||||
return false;
|
||||
}
|
||||
if(Forced)
|
||||
{
|
||||
if((AClient->getType() < operLevel::SMTLEVEL) && ((bot->findCommandInMem(st[pos]))->getMinLevel() > theUser->getType()))
|
||||
{
|
||||
bot->Notice(theClient,"Only SMT+ can force the addition of a command");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (Comm->getMinLevel() > theUser->getType())
|
||||
{
|
||||
if (!sentOnce)
|
||||
{
|
||||
if (AClient->getType() >= operLevel::SMTLEVEL)
|
||||
bot->Notice(theClient,
|
||||
"The minimum level required to use this command "
|
||||
"is higher than the one the oper has, use "
|
||||
"\002-fr\002 if you still want to add it");
|
||||
else
|
||||
bot->Notice(theClient,
|
||||
"The minimum level required to use this command "
|
||||
"is higher than the one the oper has");
|
||||
sentOnce = true;
|
||||
}
|
||||
if (!AllOpers && !AllAdmins && !AllSmts && !AllCoders)
|
||||
return false;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
if (theUser->gotAccess(Comm))
|
||||
{
|
||||
if (!AllOpers && !AllAdmins && !AllSmts && !AllCoders)
|
||||
{
|
||||
bot->Notice( theClient,
|
||||
"%s already has access to '%s'",
|
||||
theUser->getUserName().c_str(),
|
||||
st[pos].c_str());
|
||||
return false;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
//Add the command and update the user db record
|
||||
theUser->addCommand(Comm);
|
||||
theUser->setLast_Updated_By(theClient->getRealNickUserHost());
|
||||
if(theUser->Update())
|
||||
{
|
||||
bot->Notice( theClient,
|
||||
"Successfully added the command for %s",
|
||||
theUser->getUserName().c_str());
|
||||
if(Forced)
|
||||
bot->MsgChanLog("%s is using -fr to add '%s' to %s"
|
||||
,theClient->getNickName().c_str(),st[pos].c_str()
|
||||
,theUser->getUserName().c_str());
|
||||
// If the user is authenticated update his authenticate entry
|
||||
count++;
|
||||
if (!AllOpers && !AllAdmins && !AllSmts && !AllCoders)
|
||||
return true;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
bot->Notice( theClient, "Error while adding command for %s",
|
||||
theUser->getUserName().c_str());
|
||||
return false;
|
||||
}
|
||||
bot->Notice(theClient, "Gave %s access to %d users", Comm->getName().c_str(), count);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* ADDOPERCHANCommand.cc
|
||||
* Add a new irc operator 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: ADDOPERCHANCommand.cc,v 1.12 2006/09/26 17:35:57 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Constants.h"
|
||||
|
||||
RCSTAG( "$Id: ADDOPERCHANCommand.cc,v 1.12 2006/09/26 17:35:57 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
bool ADDOPERCHANCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
string chanName = st[ 1 ] ;
|
||||
if( '#' != chanName[ 0 ] )
|
||||
{
|
||||
bot->Notice( theClient, "Invalid channel name" ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if(chanName.length() > channel::MaxName)
|
||||
{
|
||||
bot->Notice( theClient,"Channel name too long" );
|
||||
return true;
|
||||
}
|
||||
|
||||
if( bot->addOperChan( chanName ) )
|
||||
{
|
||||
bot->Notice( theClient, "Addition of %s as oper chan has SUCCEEDED",
|
||||
chanName.c_str() ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice( theClient, "Addition of %s as oper chan has FAILED",
|
||||
chanName.c_str() ) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* ADDSERVERCommand.cc
|
||||
* Add a new server for the bot database
|
||||
*
|
||||
* 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: ADDSERVERCommand.cc,v 1.17 2006/09/26 17:35:58 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "Constants.h"
|
||||
|
||||
RCSTAG( "$Id: ADDSERVERCommand.cc,v 1.17 2006/09/26 17:35:58 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool ADDSERVERCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if(st[1].size() > server::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Server name can't be more than %d "
|
||||
"characters in length.",
|
||||
server::MaxName);
|
||||
return false;
|
||||
}
|
||||
|
||||
string SName;
|
||||
if(string::npos != st[1].find_first_of('*'))
|
||||
{
|
||||
iServer* tServer = Network->findExpandedServerName(st[1]);
|
||||
|
||||
if(!tServer)
|
||||
{
|
||||
bot->Notice(theClient,"I can't find a linked server "
|
||||
"that matches %s",
|
||||
st[1].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
SName = tServer->getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
SName = st[1];
|
||||
}
|
||||
bot->MsgChanLog("ADDSERVER %s\n",SName.c_str());
|
||||
|
||||
ccServer* NewServer = new ccServer(bot->SQLDb);
|
||||
if(NewServer->loadData(SName))
|
||||
{
|
||||
bot->Notice(theClient, "Server '%s' is already in my database!",
|
||||
SName.c_str());
|
||||
delete NewServer;
|
||||
return false;
|
||||
}
|
||||
NewServer->setName(SName);
|
||||
bool Report = true;
|
||||
if(st.size() > 2)
|
||||
{
|
||||
if(!strcasecmp(st[2],"-nr"))
|
||||
{
|
||||
Report = false;
|
||||
}
|
||||
}
|
||||
|
||||
//We need to check if the server is currently connected ,
|
||||
//if so update all the data
|
||||
iServer* CurServer = Network->findServerName(SName);
|
||||
if(CurServer)
|
||||
{
|
||||
NewServer->setLastNumeric(CurServer->getCharYY());
|
||||
NewServer->setLastConnected(CurServer->getConnectTime());
|
||||
NewServer->setUplink(
|
||||
(Network->findServer(CurServer->getIntYY()))->getName());
|
||||
NewServer->setNetServer(CurServer);
|
||||
bot->Write("%s V :%s\n",bot->getCharYYXXX().c_str(),
|
||||
CurServer->getCharYY().c_str());
|
||||
}
|
||||
NewServer->setReportMissing(Report);
|
||||
if(!Report)
|
||||
{
|
||||
NewServer->setVersion("Virtual Server V1.0123B3");
|
||||
}
|
||||
NewServer->setAddedOn(::time(0));
|
||||
NewServer->setLastUpdated(::time(0));
|
||||
if(NewServer->Insert())
|
||||
bot->Notice(theClient,"Server '%s' has been added successfully\n",SName.c_str());
|
||||
else
|
||||
bot->Notice(theClient,"Database error while adding server '%s'\n",
|
||||
SName.c_str());
|
||||
|
||||
bot->addServer(NewServer);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} // namespace gnuworld
|
||||
@@ -0,0 +1,207 @@
|
||||
/**
|
||||
* ADDUSERCommand.cc
|
||||
* Adds a new oper to the bot database
|
||||
* when adding a new oper one must specify access flags
|
||||
* the oper initial commands is defined by these flags
|
||||
* the defualt flags can be found in CControlCommands.h 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: ADDUSERCommand.cc,v 1.21 2006/09/26 17:35:58 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "ccUser.h"
|
||||
#include "misc.h"
|
||||
#include "commLevels.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: ADDUSERCommand.cc,v 1.21 2006/09/26 17:35:58 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool ADDUSERCommand::Exec( iClient* theClient, const string& Message)
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 4 )
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(st[1].size() > User::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Oper name can't be more than %d "
|
||||
"characters in length.",
|
||||
User::MaxName);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Try fetching the user data from the database, note this is
|
||||
// the new user handle
|
||||
ccUser* theUser = bot->GetOper(st[1]);
|
||||
if (theUser)
|
||||
{
|
||||
bot->Notice(theClient,"Oper '%s' already exsits in my database, "
|
||||
"please change the oper handle and try again.",
|
||||
theUser->getUserName().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned long int NewAccess = 0 ;
|
||||
unsigned long int NewSAccess = 0 ;
|
||||
|
||||
unsigned int NewFlags = 0 ;
|
||||
|
||||
if(!strcasecmp(st[2],"coder"))
|
||||
{
|
||||
NewAccess = commandLevel::CODER;
|
||||
NewSAccess = commandLevel::SCODER;
|
||||
NewFlags = operLevel::CODERLEVEL;
|
||||
}
|
||||
else if(!strcasecmp(st[2],"smt"))
|
||||
{
|
||||
NewAccess = commandLevel::SMT;
|
||||
NewSAccess = commandLevel::SSMT;
|
||||
NewFlags = operLevel::SMTLEVEL;
|
||||
}
|
||||
|
||||
else if(!strcasecmp(st[2],"admin"))
|
||||
{
|
||||
if(st.size() < 5)
|
||||
{
|
||||
bot->Notice(theClient,"When adding a new admin, you "
|
||||
"must specify a server.");
|
||||
return false;
|
||||
}
|
||||
NewAccess = commandLevel::ADMIN;
|
||||
NewSAccess = commandLevel::SADMIN;
|
||||
NewFlags = operLevel::ADMINLEVEL;
|
||||
}
|
||||
else if(!strcasecmp(st[2],"oper"))
|
||||
{
|
||||
NewAccess = commandLevel::OPER;
|
||||
NewSAccess = commandLevel::SOPER;
|
||||
NewFlags = operLevel::OPERLEVEL;
|
||||
} else if (!strcasecmp(st[2], "uhs")) {
|
||||
NewAccess = commandLevel::UHS;
|
||||
NewSAccess = commandLevel::SUHS;
|
||||
NewFlags = operLevel::UHSLEVEL;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,
|
||||
"Illegal oper type; types are: oper, admin, smt and coder");
|
||||
return false;
|
||||
}
|
||||
|
||||
ccUser *tOper = bot->IsAuth( theClient );
|
||||
if( NULL == tOper )
|
||||
{
|
||||
bot->Notice( theClient,
|
||||
"You must be authenticated to use this command." ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
bot->MsgChanLog("ADDUSER %s %s\n",st[1].c_str(),st[2].c_str());
|
||||
|
||||
//Make sure the new oper wont have a command the old one doesnt have enabled
|
||||
NewAccess &= tOper->getAccess();
|
||||
//NewAccess = bot->getTrueAccess(NewAccess);
|
||||
|
||||
//Check if the user doesnt try to add an oper with higher flag than he is
|
||||
unsigned int OperFlags = tOper->getType();
|
||||
if(OperFlags < operLevel::ADMINLEVEL)
|
||||
{
|
||||
bot->Notice(theClient,
|
||||
"Sorry, but only admins+ can add new opers");
|
||||
return false;
|
||||
}
|
||||
|
||||
if((OperFlags < operLevel::SMTLEVEL) && (OperFlags <= NewFlags))
|
||||
{
|
||||
bot->Notice(theClient,
|
||||
"Sorry, but you can't add an oper with a higher or "
|
||||
"equal access to your own");
|
||||
return false;
|
||||
}
|
||||
else if(OperFlags < NewFlags)
|
||||
{
|
||||
bot->Notice(theClient,
|
||||
"Sorry, but you can't add an oper with a higher "
|
||||
"access than your own");
|
||||
return false;
|
||||
}
|
||||
|
||||
//Create the new user and update the database
|
||||
theUser = new ccUser(bot->SQLDb);
|
||||
theUser->setUserName(st[1]);
|
||||
if(st.size() < 5)
|
||||
{
|
||||
theUser->setPassword(bot->CryptPass(st[3]));
|
||||
theUser->setServer(tOper->getServer());
|
||||
}
|
||||
else
|
||||
{
|
||||
if(OperFlags < operLevel::SMTLEVEL)
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, only SMT+ can specify "
|
||||
"a server name");
|
||||
return false;
|
||||
}
|
||||
|
||||
string Server( bot->expandDbServer(st[3]) ) ;
|
||||
if( Server.empty() )
|
||||
{
|
||||
bot->Notice(theClient,"I can't find a server that "
|
||||
"matches '%s' in the database",
|
||||
st[3].c_str());
|
||||
return false;
|
||||
}
|
||||
theUser->setPassword(bot->CryptPass(st[4]));
|
||||
theUser->setServer(Server);
|
||||
}
|
||||
|
||||
theUser->setAccess(NewAccess);
|
||||
theUser->setSAccess(NewSAccess);
|
||||
theUser->setType(NewFlags);
|
||||
theUser->setLast_Updated_By(theClient->getRealNickUserHost());
|
||||
theUser->setNeedOp(true);
|
||||
theUser->setNotice(true); //default to notice
|
||||
|
||||
if(bot->AddOper(theUser) == true)
|
||||
{
|
||||
bot->Notice(theClient, "Oper successfully added.");
|
||||
theUser->loadData(theUser->getUserName());
|
||||
bot->AddHost(theUser,"*!*@*");
|
||||
}
|
||||
else
|
||||
bot->Notice(theClient, "Error while adding the new oper.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* ANNOUNCECommand.cc
|
||||
* Send global messages
|
||||
*
|
||||
* 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: ANNOUNCECommand.cc,v 1.2 2009/06/13 06:43:34 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: ANNOUNCECommand.cc,v 1.2 2009/06/13 06:43:34 hidden1 Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool ANNOUNCECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
bot->MsgChanLog("ANNOUNCE %s\n",st.assemble(1).c_str());
|
||||
|
||||
if(st.size() < 2)
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!strcasecmp(st[1],"-p"))
|
||||
bot->privAnnounce(theClient, st.assemble(2));
|
||||
else
|
||||
bot->announce(theClient, st.assemble(1));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* CControlCommands.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: CControlCommands.cc,v 1.16 2005/01/12 03:50:28 dan_karrels Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "iClient.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: CControlCommands.cc,v 1.16 2005/01/12 03:50:28 dan_karrels Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
void Command::Usage( iClient* theClient )
|
||||
{
|
||||
bot->Notice( theClient, string( "Usage: " ) + ' ' + getInfo() ) ;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* CControlCommands.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: CControlCommands.h,v 1.34 2009/07/26 18:30:37 mrbean_ Exp $
|
||||
*/
|
||||
|
||||
#ifndef __CCONTROLCOMMANDS_H
|
||||
#define __CCONTROLCOMMANDS_H "$Id: CControlCommands.h,v 1.34 2009/07/26 18:30:37 mrbean_ Exp $"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "iClient.h"
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
class xServer ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
class ccontrol ;
|
||||
|
||||
class Command
|
||||
{
|
||||
|
||||
public:
|
||||
Command( ccontrol* _bot, const string& _commName,
|
||||
const bool _needsDB,
|
||||
const string& _help, const unsigned long _flags,
|
||||
const bool _disabled, const bool _needOp,
|
||||
const bool _noLog,const int unsigned _minLevel,
|
||||
const bool _secondAccess)
|
||||
: bot( _bot ),
|
||||
server( 0 ),
|
||||
commName( _commName ),
|
||||
commRealName( _commName ),
|
||||
needDB ( _needsDB ),
|
||||
help( _help ),
|
||||
flags ( _flags ),
|
||||
isDisabled ( _disabled ),
|
||||
needOp ( _needOp),
|
||||
noLog ( _noLog ),
|
||||
minLevel ( _minLevel ),
|
||||
secondAccess ( _secondAccess )
|
||||
{}
|
||||
virtual ~Command() {}
|
||||
|
||||
/// Exec returns true if the command was successfully
|
||||
/// executed, false otherwise.
|
||||
virtual bool Exec( iClient*, const string&) = 0 ;
|
||||
|
||||
void setServer( xServer* _server )
|
||||
{ server = _server ; }
|
||||
virtual string getInfo() const
|
||||
{ return commName + ' ' + help ; }
|
||||
virtual void Usage( iClient* theClient ) ;
|
||||
|
||||
void setName( const string& _name )
|
||||
{ commName = string_upper( _name ); }
|
||||
|
||||
void Disable()
|
||||
{ isDisabled = true ; }
|
||||
|
||||
void Enable()
|
||||
{ isDisabled = false ; }
|
||||
|
||||
void setNeedOp ( const bool _needOp )
|
||||
{ needOp = _needOp ; }
|
||||
|
||||
void setNoLog ( const bool _noLog )
|
||||
{ noLog = _noLog ; }
|
||||
|
||||
void setMinLevel ( const int unsigned _minLevel )
|
||||
{ minLevel = _minLevel ; }
|
||||
|
||||
inline const string& getName() const
|
||||
{ return commName ; }
|
||||
|
||||
inline const string& getRealName() const
|
||||
{ return commRealName ; }
|
||||
|
||||
inline const bool& needsDB() const
|
||||
{ return needDB ; }
|
||||
|
||||
inline const string& getHelp() const
|
||||
{ return help ; }
|
||||
|
||||
inline const unsigned long& getFlags() const
|
||||
{ return flags ; }
|
||||
|
||||
inline const bool& getIsDisabled() const
|
||||
{ return isDisabled ; }
|
||||
|
||||
inline const bool& getNeedOp() const
|
||||
{ return needOp ; }
|
||||
|
||||
inline const bool& getNoLog() const
|
||||
{ return noLog ; }
|
||||
|
||||
inline const unsigned int& getMinLevel() const
|
||||
{ return minLevel ; }
|
||||
|
||||
inline const bool& getSecondAccess() const
|
||||
{ return secondAccess ; }
|
||||
protected:
|
||||
ccontrol* bot ;
|
||||
xServer* server ;
|
||||
string commName ;
|
||||
string commRealName ;
|
||||
bool needDB;
|
||||
string help ;
|
||||
unsigned long flags;
|
||||
bool isDisabled;
|
||||
bool needOp;
|
||||
bool noLog;
|
||||
unsigned int minLevel;
|
||||
bool secondAccess;
|
||||
} ;
|
||||
}
|
||||
|
||||
} // namespace gnuworld
|
||||
|
||||
#endif // __CCONTROLCOMMANDS_H
|
||||
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* CHANINFOCommand.cc
|
||||
* Shows information about 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: CHANINFOCommand.cc,v 1.20 2007/11/05 10:04:23 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Network.h"
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Constants.h"
|
||||
#include "ccontrol_generic.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: CHANINFOCommand.cc,v 1.20 2007/11/05 10:04:23 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool CHANINFOCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if(st[1].size() > channel::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Channel name can't be more than %d characters",
|
||||
channel::MaxName);
|
||||
return false;
|
||||
}
|
||||
|
||||
ccUser* tmpAuth = bot->IsAuth(theClient);
|
||||
if (!tmpAuth)
|
||||
return false;
|
||||
unsigned int OpFlag = tmpAuth->getType();
|
||||
|
||||
bot->MsgChanLog("CHANINFO %s\n",st[1].c_str());
|
||||
|
||||
Channel* theChan = Network->findChannel( st[ 1 ] ) ;
|
||||
if( NULL == theChan )
|
||||
{
|
||||
bot->Notice( theClient, "Unable to find channel %s",
|
||||
st[ 1 ].c_str() ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
bot->Notice( theClient, "Channel %s is mode %s",
|
||||
st[ 1 ].c_str(),
|
||||
theChan->getModeString().c_str() ) ;
|
||||
bot->Notice( theClient, "Created at time: %d (%s ago)",
|
||||
theChan->getCreationTime(), Ago(theChan->getCreationTime()));
|
||||
|
||||
/* iterate the channel user list to get statistics on each mode
|
||||
and possibly a user list in future */
|
||||
int totalOps = 0;
|
||||
int totalVoice = 0;
|
||||
string tmpMode;
|
||||
|
||||
for (Channel::userIterator userItr = theChan->userList_begin();
|
||||
userItr != theChan->userList_end(); ++userItr)
|
||||
{
|
||||
ChannelUser* theUser = userItr->second;
|
||||
|
||||
if (theUser->isModeO())
|
||||
totalOps++;
|
||||
if (theUser->isModeV())
|
||||
totalVoice++;
|
||||
if (OpFlag == operLevel::CODERLEVEL)
|
||||
{
|
||||
/* show full info to coders - make it format for easy viewing */
|
||||
if (theUser->isModeO() && theUser->isModeV())
|
||||
tmpMode = "+o+v: ";
|
||||
else if (theUser->isModeO())
|
||||
tmpMode = "+o: ";
|
||||
else if (theUser->isModeV())
|
||||
tmpMode = "+v: ";
|
||||
else
|
||||
tmpMode = "none: ";
|
||||
bot->Notice(theClient, "%s%s!%s@%s",
|
||||
tmpMode.c_str(),
|
||||
theUser->getNickName().c_str(),
|
||||
theUser->getUserName().c_str(),
|
||||
theUser->getHostName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
bot->Notice( theClient, "Number of channel users: %d (%d ops, %d voice)",
|
||||
theChan->size(), totalOps, totalVoice);
|
||||
|
||||
#ifdef TOPIC_TRACK
|
||||
bot->Notice(theClient,"Topic: %s",
|
||||
theChan->getTopic().c_str());
|
||||
if (theChan->getTopicTS() != 0)
|
||||
{
|
||||
bot->Notice(theClient, "Topic set %s ago [%ld] by %s",
|
||||
Ago(theChan->getTopicTS()),
|
||||
theChan->getTopicTS(),
|
||||
theChan->getTopicWhoSet().c_str());
|
||||
}
|
||||
#endif
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* CHECKNETCommand.cc
|
||||
* Check the network stauts
|
||||
*
|
||||
* 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: CHECKNETCommand.cc,v 1.20 2009/07/26 23:55:52 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "ccServer.h"
|
||||
#include "ccontrol_generic.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: CHECKNETCommand.cc,v 1.20 2009/07/26 23:55:52 hidden1 Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool CHECKNETCommand::Exec( iClient* theClient, const string& )
|
||||
{
|
||||
unsigned int TServers = 0;
|
||||
|
||||
bot->Notice(theClient,"Checking network status as at %ld\n",::time(NULL));
|
||||
bot->MsgChanLog("CHECKNET\n");
|
||||
|
||||
ccServer* CurServer = 0;
|
||||
string Msg;
|
||||
char tNum[512];
|
||||
std::stringstream s;
|
||||
int count = 0;
|
||||
|
||||
for (ccontrol::serversConstIterator ptr = bot->serversMap_begin() ;
|
||||
ptr != bot->serversMap_end();++ptr)
|
||||
{
|
||||
//For each server on the database check if its connetcted
|
||||
CurServer = ptr->second;
|
||||
|
||||
//If the server isnt connected
|
||||
if(CurServer->getReportMissing() && !CurServer->getNetServer())
|
||||
{
|
||||
Msg = "Server \002";
|
||||
Msg += CurServer->getName();
|
||||
Msg +="\002 Is missing, ";
|
||||
Msg += "Last split: ";
|
||||
if(CurServer->getLastSplitted() != 0)
|
||||
{
|
||||
sprintf(tNum, "%ld", (long)CurServer->getLastSplitted());
|
||||
Msg += "[";
|
||||
Msg += tNum;
|
||||
Msg += "] ";
|
||||
Msg += Ago(CurServer->getLastSplitted());
|
||||
Msg += " ago, Split Reason:";
|
||||
Msg += CurServer->getSplitReason();
|
||||
}
|
||||
else
|
||||
Msg += " unknown ";
|
||||
|
||||
Msg += " Last connected: ";
|
||||
|
||||
if(CurServer->getLastConnected() != 0)
|
||||
{
|
||||
sprintf(tNum, "%ld", (long)CurServer->getLastConnected());
|
||||
Msg += "[";
|
||||
Msg += tNum;
|
||||
Msg += "] ";
|
||||
Msg += Ago(CurServer->getLastConnected());
|
||||
Msg += " ago";
|
||||
}
|
||||
else
|
||||
Msg += " unknown ";
|
||||
bot->Notice(theClient,"%s",Msg.c_str());
|
||||
TServers++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
for (ccontrol::serversConstIterator ptr = bot->serversMap_begin() ;
|
||||
ptr != bot->serversMap_end();++ptr)
|
||||
{
|
||||
//For each server on the database check if its connetcted
|
||||
CurServer = ptr->second;
|
||||
|
||||
//If the server isnt connected
|
||||
if (!CurServer->getReportMissing() || CurServer->getNetServer())
|
||||
{
|
||||
if (s.str().size() > 400)
|
||||
{
|
||||
bot->Notice(theClient, "Server RPINGS: %s", s.str().c_str());
|
||||
s.str("");
|
||||
count = 0;
|
||||
}
|
||||
count++;
|
||||
if (count > 1)
|
||||
s << ", ";
|
||||
s << CurServer->getName() << " (";
|
||||
if (CurServer->getLagTime() > 10000)
|
||||
{
|
||||
s << "\002" << (int) (CurServer->getLagTime() / 1000) << "seconds\002)";
|
||||
}
|
||||
else if (CurServer->getLagTime() > 5000)
|
||||
{
|
||||
s << "\002" << CurServer->getLagTime() << "ms\002)";
|
||||
}
|
||||
else
|
||||
{
|
||||
s << CurServer->getLagTime() << "ms)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bot->Notice(theClient, "Server RPINGS: %s", s.str().c_str());
|
||||
*/
|
||||
bot->Notice(theClient,"Finished checking the status of the network.\n");
|
||||
bot->Notice(theClient,"Found a total of %d missing servers\n",TServers);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
/**
|
||||
* CLEARCHANCommand.cc
|
||||
* Clears all/some channel modes
|
||||
*
|
||||
* 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: CLEARCHANCommand.cc,v 1.26 2006/09/26 17:35:58 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
#include <iomanip>
|
||||
#include "Network.h"
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Constants.h"
|
||||
#include "ccBadChannel.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: CLEARCHANCommand.cc,v 1.26 2006/09/26 17:35:58 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
using std::vector ;
|
||||
using gnuworld::iClient;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool CLEARCHANCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
bool Desynch = false;
|
||||
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if(st[1].size() > channel::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Channel name can't be more than %d characters.",
|
||||
channel::MaxName);
|
||||
return false;
|
||||
}
|
||||
|
||||
Channel* theChan = Network->findChannel( st[ 1 ] ) ;
|
||||
if( NULL == theChan )
|
||||
{
|
||||
bot->Notice( theClient, "Unable to find channel %s",
|
||||
st[ 1 ].c_str() ) ;
|
||||
return true ;
|
||||
}
|
||||
if(bot->isOperChan(theChan))
|
||||
{
|
||||
bot->Notice(theClient,"C'mon, you know you can't clear an oper channel.");
|
||||
return false;
|
||||
}
|
||||
|
||||
string doModes; //This holds the modes the user asked to be removed
|
||||
string remModes = ""; //Holds the modes that we are removing
|
||||
string args = ""; //Holds the arguments for the remModes
|
||||
|
||||
bot->MsgChanLog("CLEARCHAN %s\n",st.assemble(1).c_str());
|
||||
ccBadChannel* Chan = bot->isBadChannel(st[1]);
|
||||
if(Chan)
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, you can't change modes in "
|
||||
"this channel because: %s",
|
||||
Chan->getReason().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
//Check if the user specified the modes, if not assume he ment all of the modes
|
||||
if(st.size() == 2)
|
||||
doModes = "obklim";
|
||||
else if(!strcasecmp(string_upper(st[ 2 ]),"ALL"))
|
||||
doModes = "obklimnspt";
|
||||
else if(!strcasecmp(string_upper(st [ 2]),"-d"))
|
||||
Desynch = true;
|
||||
else
|
||||
doModes = st [ 2 ];
|
||||
|
||||
if(Desynch)
|
||||
{
|
||||
vector<iClient*> KickVec;
|
||||
bot->Join(theChan->getName(),"+i",0,true);
|
||||
for( Channel::const_userIterator ptr = theChan->userList_begin();
|
||||
ptr != theChan->userList_end() ; ++ptr )
|
||||
{
|
||||
|
||||
if ( !ptr->second->getClient()->getMode(iClient::MODE_SERVICES) )
|
||||
{
|
||||
KickVec.push_back(ptr->second->getClient());
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
its a +k user, need to make sure its not us
|
||||
*/
|
||||
if(strcmp(ptr->second->getClient()->getCharYYXXX().c_str(),
|
||||
bot->getCharYYXXX().c_str()))
|
||||
{
|
||||
bot->Message(ptr->second->getClient(),"OPERPART %s"
|
||||
,theChan->getName().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(KickVec.size() > 0)
|
||||
{
|
||||
string reason = "Desynch clearing";
|
||||
bot->Kick(theChan,KickVec,reason);
|
||||
}
|
||||
bot->Part(theChan->getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
bot->ClearMode( theChan, doModes, true ) ;
|
||||
return true ;
|
||||
|
||||
/*
|
||||
for( string::size_type modePos = 0 ; modePos < doModes.size() ; ++modePos )
|
||||
{
|
||||
switch( doModes[ modePos ] )
|
||||
{
|
||||
case 'B': //Ban?
|
||||
{
|
||||
string ban;
|
||||
string modes = "-";
|
||||
string args = "";
|
||||
Channel::banListSizeType end = theChan->banList_size();
|
||||
Channel::banIterator ptr = theChan->banList_begin() ;
|
||||
for(Channel::banListSizeType i=0; i != end ;i++)
|
||||
{
|
||||
ban = *ptr;
|
||||
ptr++;
|
||||
args += ban + ' ';
|
||||
modes+= "b";
|
||||
theChan->removeBan(ban);
|
||||
if(modes.size() > 5) //if we got more than 5 , set the mode and continue
|
||||
{
|
||||
bot->ModeAsServer( theChan, modes + ' ' + args ) ;
|
||||
modes = "-";
|
||||
args = "";
|
||||
}
|
||||
}
|
||||
if(!args.empty())
|
||||
bot->ModeAsServer( theChan, modes + ' ' + args ) ;
|
||||
break;
|
||||
}
|
||||
case 'O': //Chanops?
|
||||
{
|
||||
string modes = "-";
|
||||
string args = "";
|
||||
for( Channel::const_userIterator ptr = theChan->userList_begin();
|
||||
ptr != theChan->userList_end() ; ++ptr )
|
||||
{
|
||||
if( ptr->second->getMode(ChannelUser::MODE_O))
|
||||
{
|
||||
// Don't deop +k things
|
||||
if ( !ptr->second->getClient()->getMode(iClient::MODE_SERVICES) )
|
||||
{
|
||||
modes+= 'o';
|
||||
args+= ptr->second->getCharYYXXX() + " ";
|
||||
ptr->second->removeMode(ChannelUser::MODE_O);
|
||||
}
|
||||
} // If opped.
|
||||
if(modes.size() > 5) //if we got more than 5 , set the mode and continue
|
||||
{
|
||||
bot->ModeAsServer( theChan, modes + ' ' + args ) ;
|
||||
modes = "-";
|
||||
args = "";
|
||||
}
|
||||
}
|
||||
if(!args.empty())
|
||||
bot->ModeAsServer(theChan,modes + " " + args);
|
||||
}
|
||||
break;
|
||||
case 'K': //Key?
|
||||
if(theChan->getMode(Channel::MODE_K))
|
||||
{
|
||||
theChan->removeMode(Channel::MODE_K);
|
||||
remModes+= "k";
|
||||
args+= theChan->getKey() + " ";
|
||||
theChan->setKey("");
|
||||
}
|
||||
break;
|
||||
case 'I': //Invite?
|
||||
if(theChan->getMode(Channel::MODE_I))
|
||||
{
|
||||
theChan->removeMode(Channel::MODE_I);
|
||||
remModes+= "i";
|
||||
}
|
||||
break;
|
||||
case 'L': //Limit?
|
||||
if(theChan->getMode(Channel::MODE_L))
|
||||
{
|
||||
theChan->removeMode(Channel::MODE_L);
|
||||
remModes+= "l";
|
||||
//args+= theChan->getLimit() + " ";
|
||||
}
|
||||
break;
|
||||
case 'P': //Private?
|
||||
if(theChan->getMode(Channel::MODE_P))
|
||||
{
|
||||
theChan->removeMode(Channel::MODE_P);
|
||||
remModes+= "p";
|
||||
}
|
||||
break;
|
||||
case 'S': //Secret?
|
||||
if(theChan->getMode(Channel::MODE_S))
|
||||
{
|
||||
theChan->removeMode(Channel::MODE_S);
|
||||
remModes+= "s";
|
||||
}
|
||||
break;
|
||||
case 'M': //Moderated?
|
||||
if(theChan->getMode(Channel::MODE_M))
|
||||
{
|
||||
theChan->removeMode(Channel::MODE_M);
|
||||
remModes+= "m";
|
||||
}
|
||||
break;
|
||||
case 'N': //No External Messages?
|
||||
if(theChan->getMode(Channel::MODE_N))
|
||||
{
|
||||
theChan->removeMode(Channel::MODE_N);
|
||||
remModes+= "n";
|
||||
}
|
||||
break;
|
||||
case 'T': //Topic?
|
||||
if(theChan->getMode(Channel::MODE_T))
|
||||
{
|
||||
theChan->removeMode(Channel::MODE_T);
|
||||
remModes+= "t";
|
||||
}
|
||||
break;
|
||||
default:;
|
||||
} }
|
||||
if(!remModes.empty())
|
||||
bot->ModeAsServer(theChan,"-" + remModes + " " + args);
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
/**
|
||||
* COMMANDSCommand.cc
|
||||
* Changes all kind of commands options
|
||||
*
|
||||
* 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: COMMANDSCommand.cc,v 1.15 2006/09/26 17:35:58 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "ccUser.h"
|
||||
#include "misc.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: COMMANDSCommand.cc,v 1.15 2006/09/26 17:35:58 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool COMMANDSCommand::Exec( iClient* theClient, const string& Message)
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if( st.size() < 3 )
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(st[1].size() > 128)
|
||||
{
|
||||
bot->Notice(theClient,"Command name can't be more than 128 characters.");
|
||||
return false;
|
||||
}
|
||||
|
||||
bot->MsgChanLog("COMMANDS %s\n",st.assemble(1).c_str());
|
||||
|
||||
Command* Comm = bot->findCommandInMem(st[2]);
|
||||
if(!Comm)
|
||||
{
|
||||
bot->Notice(theClient,"Can't find command name '%s'",st[2].c_str());
|
||||
return false;
|
||||
}
|
||||
if(!strcasecmp(st[1],"-ds"))
|
||||
{
|
||||
Comm->Disable();
|
||||
if(!bot->updateCommand(Comm))
|
||||
{
|
||||
bot->Notice(theClient,"Error while disabling command");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Command has been disabled");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(!strcasecmp(st[1],"-en"))
|
||||
{
|
||||
Comm->Enable();
|
||||
if(!bot->updateCommand(Comm))
|
||||
{
|
||||
bot->Notice(theClient,"Error while enabling command");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Command has been enabled");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(!strcasecmp(st[1],"-no"))
|
||||
{
|
||||
if(st.size() < 4)
|
||||
{
|
||||
bot->Notice(theClient,"-no must get a on/off option");
|
||||
return false;
|
||||
}
|
||||
if(!strcasecmp(st[3],"on"))
|
||||
{
|
||||
Comm->setNeedOp(true);
|
||||
if(!bot->updateCommand(Comm))
|
||||
{
|
||||
bot->Notice(theClient,"error while setting need op");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"needop has been enabled");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
else if(!strcasecmp(st[3],"off"))
|
||||
{
|
||||
Comm->setNeedOp(false);
|
||||
if(!bot->updateCommand(Comm))
|
||||
{
|
||||
bot->Notice(theClient,"error while removing need op");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"needop has been disabled");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"unknown option for -no must be on/off");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(!strcasecmp(st[1],"-nl"))
|
||||
{
|
||||
if(st.size() < 4)
|
||||
{
|
||||
bot->Notice(theClient,"-nl must get a on/off option");
|
||||
return false;
|
||||
}
|
||||
if(!strcasecmp(st[3],"on"))
|
||||
{
|
||||
Comm->setNoLog(true);
|
||||
if(!bot->updateCommand(Comm))
|
||||
{
|
||||
bot->Notice(theClient,"error while setting no log");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"no log has been enabled");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
else if(!strcasecmp(st[3],"off"))
|
||||
{
|
||||
Comm->setNoLog(false);
|
||||
if(!bot->updateCommand(Comm))
|
||||
{
|
||||
bot->Notice(theClient,"error while removing no log");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"no log has been disabled");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"unknown option for -nl must be on/off");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
else if(!strcasecmp(st[1],"-na"))
|
||||
{
|
||||
if(st.size() < 4)
|
||||
{
|
||||
bot->Notice(theClient,"-na must get a new command name");
|
||||
return false;
|
||||
}
|
||||
if(st[3].size() > 128)
|
||||
{
|
||||
bot->Notice(theClient,"Command name can't be more than 128 characters");
|
||||
return false;
|
||||
}
|
||||
if(!strcasecmp(Comm->getName(),st[3]))
|
||||
{
|
||||
bot->Notice(theClient,"the command is already called like that");
|
||||
return false;
|
||||
}
|
||||
Comm->setName(string_upper(st[3]));
|
||||
if(!bot->updateCommand(Comm))
|
||||
{
|
||||
bot->Notice(theClient,"error while changing command name");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"command name has been changed");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(!strcasecmp(st[1],"-ml"))
|
||||
{
|
||||
unsigned int MINLEVEL;
|
||||
if(st.size() < 4)
|
||||
{
|
||||
bot->Notice(theClient,"-ml must get a new min level");
|
||||
return false;
|
||||
}
|
||||
if(!strcasecmp(st[3],"CODER"))
|
||||
{
|
||||
MINLEVEL = operLevel::CODERLEVEL;
|
||||
}
|
||||
else if(!strcasecmp(st[3],"SMT"))
|
||||
{
|
||||
MINLEVEL = operLevel::SMTLEVEL;
|
||||
}
|
||||
else if(!strcasecmp(st[3],"ADMIN"))
|
||||
{
|
||||
MINLEVEL = operLevel::ADMINLEVEL;
|
||||
}
|
||||
else if(!strcasecmp(st[3],"OPER"))
|
||||
{
|
||||
MINLEVEL = operLevel::OPERLEVEL;
|
||||
}
|
||||
else if(!strcasecmp(st[3],"UHS"))
|
||||
{
|
||||
MINLEVEL = operLevel::UHSLEVEL;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Unknown level, must be CODER,SMT,ADMIN,OPER or UHS");
|
||||
return false;
|
||||
}
|
||||
Comm->setMinLevel(MINLEVEL);
|
||||
if(!bot->updateCommand(Comm))
|
||||
{
|
||||
bot->Notice(theClient,"error while changing command min level");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"command min level has been changed");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Unknown option for commands, must be -en,-ds,-no,-nl");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
/**
|
||||
* CONFIGCommand.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: CONFIGCommand.cc,v 1.14 2008/01/03 04:26:22 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "StringTokenizer.h"
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "gnuworld_config.h"
|
||||
#include "ccontrol_generic.h" /* for Duration() and Ago() */
|
||||
|
||||
RCSTAG( "$Id: CONFIGCommand.cc,v 1.14 2008/01/03 04:26:22 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
using std::endl ;
|
||||
using std::ends ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool CONFIGCommand::Exec( iClient* theClient, const string& Message)
|
||||
{
|
||||
StringTokenizer st(Message);
|
||||
|
||||
if(st.size() < 3)
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
bot->MsgChanLog("CONFIG %s",st.assemble(1).c_str());
|
||||
|
||||
for(unsigned int pos =1; pos < st.size() ;)
|
||||
{
|
||||
if(!strcasecmp(st[pos],"-VClones"))
|
||||
{
|
||||
if(st.size() < pos +2)
|
||||
{
|
||||
bot->Notice(theClient,"-VClones must get the number of virtual clones");
|
||||
return true;
|
||||
}
|
||||
if(!bot->updateMisc("VClones",atoi(st[pos+1].c_str())))
|
||||
{
|
||||
bot->MsgChanLog("Error while updating the max virtual clones in the db!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"%s was successfully updated to %s",
|
||||
st[pos].c_str(),st[pos+1].c_str());
|
||||
}
|
||||
pos+=2;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-IClones"))
|
||||
{
|
||||
if(st.size() < pos +2)
|
||||
{
|
||||
bot->Notice(theClient,"-IClones must get the number of ident clones");
|
||||
return true;
|
||||
}
|
||||
if(!bot->updateMisc("IClones",atoi(st[pos+1].c_str())))
|
||||
{
|
||||
bot->MsgChanLog("Error while updating the max ident clones in the db!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"%s was successfully updated to %s",
|
||||
st[pos].c_str(),st[pos+1].c_str());
|
||||
}
|
||||
pos+=2;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-CClonesCIDR"))
|
||||
{
|
||||
if(st.size() < pos +2)
|
||||
{
|
||||
bot->Notice(theClient,"-CClonesCIDR must get the CIDR Size");
|
||||
return true;
|
||||
}
|
||||
if((atoi(st[pos+1].c_str())<16) || (atoi(st[pos+1].c_str())>31))
|
||||
{
|
||||
bot->Notice(theClient,"-CClonesCIDR must have a CIDR Size in the range 16-32");
|
||||
return true;
|
||||
}
|
||||
if(!bot->updateMisc("CClonesCIDR",atoi(st[pos+1].c_str())))
|
||||
{
|
||||
bot->MsgChanLog("Error while updating the CIDR size for clones in the db!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"%s was successfully updated to %s",
|
||||
st[pos].c_str(),st[pos+1].c_str());
|
||||
bot->Notice(theClient,"This change requires you to restart the service IMMEDIATELY or "
|
||||
"unexpected results will occur!");
|
||||
}
|
||||
pos+=2;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-CClonesTime"))
|
||||
{
|
||||
if(st.size() < pos +2)
|
||||
{
|
||||
bot->Notice(theClient,"-CClonesTime must get the duration between announcements per netblock.");
|
||||
return true;
|
||||
}
|
||||
if (!IsTimeSpec(st[pos+1]))
|
||||
{
|
||||
bot->Notice(theClient,"-CClonesTime must have a valid time specified, e.g. 60s or 1m");
|
||||
return true;
|
||||
}
|
||||
int g = extractTime(st[pos+1], 1);
|
||||
if (g < 0 || g > 300)
|
||||
{
|
||||
bot->Notice(theClient,"-CClonesTime value must be between 0s and 5m.");
|
||||
return true;
|
||||
}
|
||||
if(!bot->updateMisc("CClonesTime",g))
|
||||
{
|
||||
bot->MsgChanLog("Error while updating the Duration time.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"%s was successfully updated to %s",
|
||||
st[pos].c_str(),Duration((long)g));
|
||||
}
|
||||
pos+=2;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-CClonesGTime"))
|
||||
{
|
||||
if (st.size() < pos +2)
|
||||
{
|
||||
bot->Notice(theClient,"-CClonesGTime must get the duration of the gline in seconds.");
|
||||
return true;
|
||||
}
|
||||
if (!IsTimeSpec(st[pos+1]))
|
||||
{
|
||||
bot->Notice(theClient,"Invalid CIDR Clones Gline Time specified.");
|
||||
return true;
|
||||
}
|
||||
int g = extractTime(st[pos+1], 1);
|
||||
if (g < 1800 || g > 172800)
|
||||
{
|
||||
bot->Notice(theClient,"-CClonesGTime value must be between 1800 and 172800 seconds (30 mins - 2 days).");
|
||||
return true;
|
||||
}
|
||||
if (!bot->updateMisc("CClonesGTime",g))
|
||||
{
|
||||
bot->MsgChanLog("Error while updating the CIDR Clones Gline Time.\n");
|
||||
} else {
|
||||
bot->Notice(theClient,"%s was successfully updated to %s",
|
||||
st[pos].c_str(),Duration((long)g));
|
||||
}
|
||||
pos += 2;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-CClones"))
|
||||
{
|
||||
if(st.size() < pos +2)
|
||||
{
|
||||
bot->Notice(theClient,"-CClones must be the number of CIDR clones");
|
||||
return true;
|
||||
}
|
||||
if(!bot->updateMisc("CClones",atoi(st[pos+1].c_str())))
|
||||
{
|
||||
bot->MsgChanLog("Error while updated the max CIDR clones in the db!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"%s was successfully updated to %s",
|
||||
st[pos].c_str(),st[pos+1].c_str());
|
||||
}
|
||||
pos+=2;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-Clones"))
|
||||
{
|
||||
if(st.size() < pos +2)
|
||||
{
|
||||
bot->Notice(theClient,"-Clones must get the number of virtual clones");
|
||||
return true;
|
||||
}
|
||||
if(!bot->updateMisc("Clones",atoi(st[pos+1].c_str())))
|
||||
{
|
||||
bot->MsgChanLog("Error while updating the max clones in the db!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"%s was successfully updated to %s",
|
||||
st[pos].c_str(),st[pos+1].c_str());
|
||||
}
|
||||
pos+=2;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-GBCount"))
|
||||
{
|
||||
if(st.size() < pos +2)
|
||||
{
|
||||
bot->Notice(theClient,"-GBCount must get the number glines to burst");
|
||||
return true;
|
||||
}
|
||||
if(!bot->updateMisc("GlineBurstCount",atoi(st[pos+1].c_str())))
|
||||
{
|
||||
bot->MsgChanLog("Error while updating the gline burst count in the db!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"%s was successfully updated to %s",
|
||||
st[pos].c_str(),st[pos+1].c_str());
|
||||
}
|
||||
pos+=2;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-GBInterval"))
|
||||
{
|
||||
if(st.size() < pos +2)
|
||||
{
|
||||
bot->Notice(theClient,"-GBInterval must get the number of seconds between each burst");
|
||||
return true;
|
||||
}
|
||||
if (!IsTimeSpec(st[pos+1]))
|
||||
{
|
||||
bot->Notice(theClient,"-GBInterval must get the number of seconds between each burst - e.g. 3 or 3s");
|
||||
return true;
|
||||
}
|
||||
int g = extractTime(st[pos+1], 1);
|
||||
if (g < 0 || g > 10)
|
||||
{
|
||||
bot->Notice(theClient,"-GBInterval must be between 0 and 10 seconds inclusive.");
|
||||
return true;
|
||||
}
|
||||
if(!bot->updateMisc("GlineBurstInterval",g))
|
||||
{
|
||||
bot->MsgChanLog("Error while updating the gline burst interval in the db!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"%s was successfully updated to %s",
|
||||
st[pos].c_str(),Duration((long)g));
|
||||
}
|
||||
pos+=2;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-GTime"))
|
||||
{
|
||||
if(st.size() < pos +2)
|
||||
{
|
||||
bot->Notice(theClient,"-GTime must get the duration for the excessive connections gline - e.g. 900s, 30m, 1h or 1d.");
|
||||
return true;
|
||||
}
|
||||
if (!IsTimeSpec(st[pos+1]))
|
||||
{
|
||||
bot->Notice(theClient,"-GTime must get a valid duration - e.g. 900s, 30m, 1h or 1d.");
|
||||
return true;
|
||||
}
|
||||
int g = extractTime(st[pos+1], 1);
|
||||
if (g < 300 || g > 172800)
|
||||
{
|
||||
bot->Notice(theClient,"-GTime must get a duration between 300s and 2d");
|
||||
return true;
|
||||
}
|
||||
if(!bot->updateMisc("GTime",g))
|
||||
{
|
||||
bot->MsgChanLog("Error while updating the gline duration in the db!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"%s was successfully updated to %s",
|
||||
st[pos].c_str(),Duration((long)g));
|
||||
}
|
||||
|
||||
pos+=2;
|
||||
}
|
||||
|
||||
else if(!strcasecmp(st[pos],"-SGline"))
|
||||
{
|
||||
if(st.size() < pos +2)
|
||||
{
|
||||
bot->Notice(theClient,"-SGline must get a yes/no answer indicating whether or not to save glines");
|
||||
return true;
|
||||
}
|
||||
if(!bot->updateMisc("SGLine",(strcasecmp(st[pos+1],"YES") == 0) ? 1 : 0))
|
||||
{
|
||||
bot->MsgChanLog("Error while updating the save gline flag in the db\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"%s was successfully updated to %s",
|
||||
st[pos].c_str(),st[pos+1].c_str());
|
||||
}
|
||||
pos+=2;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-CClonesGline"))
|
||||
{
|
||||
if(st.size() < pos +2)
|
||||
{
|
||||
bot->Notice(theClient,"-CClonesGline must get a yes/no answer indicating whether or not to auto-gline");
|
||||
return true;
|
||||
}
|
||||
if(!bot->updateMisc("CClonesGline",(strcasecmp(st[pos+1],"YES") == 0) ? 1 : 0))
|
||||
{
|
||||
bot->MsgChanLog("Error while updating the CIDR auto-gline flag in the db\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"%s was successfully updated to %s",
|
||||
st[pos].c_str(),st[pos+1].c_str());
|
||||
}
|
||||
pos+=2;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-IClonesGline"))
|
||||
{
|
||||
if(st.size() < pos +2)
|
||||
{
|
||||
bot->Notice(theClient,"-IClonesGline must get a yes/no answer indicating whether or not to auto-gline");
|
||||
return true;
|
||||
}
|
||||
if(!bot->updateMisc("IClonesGline",(strcasecmp(st[pos+1],"YES") == 0) ? 1 : 0))
|
||||
{
|
||||
bot->MsgChanLog("Error while updating the CIDR ident auto-gline flag in the db\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"%s was successfully updated to %s",
|
||||
st[pos].c_str(),st[pos+1].c_str());
|
||||
}
|
||||
pos+=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, i am not familiar with option %s",st[pos].c_str());
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace gnuworld
|
||||
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* CommandsDec.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: CommandsDec.h,v 1.22 2009/06/13 06:43:34 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#ifndef __COMMANDSDEC_H
|
||||
#define __COMMANDSDEC_H "$Id: CommandsDec.h,v 1.22 2009/06/13 06:43:34 hidden1 Exp $"
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
class Command;
|
||||
|
||||
#define DECLARE_COMMAND(commName) \
|
||||
class commName##Command : public Command \
|
||||
{ \
|
||||
public: \
|
||||
commName##Command( ccontrol* _bot, \
|
||||
const string& _commName, \
|
||||
const string& _help, \
|
||||
const bool _needDB, \
|
||||
int _flags , bool isDisabled, \
|
||||
bool needOp, bool noLog, \
|
||||
int minLevel , bool secondAccess ) \
|
||||
: Command( _bot, _commName, _needDB, _help,_flags, \
|
||||
isDisabled,needOp,noLog,minLevel,secondAccess) \
|
||||
{} \
|
||||
virtual bool Exec( iClient*, const string&) ; \
|
||||
virtual ~commName##Command() {} \
|
||||
} ;
|
||||
|
||||
DECLARE_COMMAND( INVITE )
|
||||
DECLARE_COMMAND( HELP )
|
||||
DECLARE_COMMAND( JUPE )
|
||||
DECLARE_COMMAND( MODE )
|
||||
DECLARE_COMMAND( GLINE )
|
||||
DECLARE_COMMAND( SCHANGLINE )
|
||||
DECLARE_COMMAND( SCANGLINE )
|
||||
DECLARE_COMMAND( REMGLINE )
|
||||
DECLARE_COMMAND( TRANSLATE )
|
||||
DECLARE_COMMAND( WHOIS )
|
||||
DECLARE_COMMAND( KICK )
|
||||
DECLARE_COMMAND( ADDOPERCHAN )
|
||||
DECLARE_COMMAND( REMOPERCHAN )
|
||||
DECLARE_COMMAND( LISTOPERCHANS )
|
||||
DECLARE_COMMAND( CHANINFO )
|
||||
DECLARE_COMMAND( LOGIN )
|
||||
DECLARE_COMMAND( DEAUTH )
|
||||
DECLARE_COMMAND( ADDUSER )
|
||||
DECLARE_COMMAND( REMUSER )
|
||||
DECLARE_COMMAND( ADDCOMMAND )
|
||||
DECLARE_COMMAND( REMCOMMAND )
|
||||
DECLARE_COMMAND( NEWPASS )
|
||||
DECLARE_COMMAND( SUSPEND )
|
||||
DECLARE_COMMAND( UNSUSPEND )
|
||||
DECLARE_COMMAND( MODUSER )
|
||||
DECLARE_COMMAND( MODERATE )
|
||||
DECLARE_COMMAND( UNMODERATE )
|
||||
DECLARE_COMMAND( OP )
|
||||
DECLARE_COMMAND( DEOP )
|
||||
DECLARE_COMMAND( LISTHOSTS )
|
||||
DECLARE_COMMAND( CLEARCHAN )
|
||||
DECLARE_COMMAND( ADDSERVER )
|
||||
DECLARE_COMMAND( LEARNNET )
|
||||
DECLARE_COMMAND( REMSERVER )
|
||||
DECLARE_COMMAND( CHECKNET )
|
||||
DECLARE_COMMAND( LASTCOM )
|
||||
DECLARE_COMMAND( FORCEGLINE )
|
||||
DECLARE_COMMAND( EXCEPTION )
|
||||
DECLARE_COMMAND( LISTIGNORES )
|
||||
DECLARE_COMMAND( REMOVEIGNORE )
|
||||
DECLARE_COMMAND( LIST )
|
||||
DECLARE_COMMAND( COMMANDS )
|
||||
DECLARE_COMMAND( GCHAN )
|
||||
DECLARE_COMMAND( REMGCHAN )
|
||||
DECLARE_COMMAND( USERINFO )
|
||||
DECLARE_COMMAND( STATUS )
|
||||
DECLARE_COMMAND( SHUTDOWN )
|
||||
DECLARE_COMMAND( SCAN )
|
||||
DECLARE_COMMAND( MAXUSERS )
|
||||
DECLARE_COMMAND( CONFIG )
|
||||
DECLARE_COMMAND( SAY )
|
||||
DECLARE_COMMAND( NOMODE )
|
||||
DECLARE_COMMAND( REOP )
|
||||
DECLARE_COMMAND( SGLINE )
|
||||
DECLARE_COMMAND( REMSGLINE )
|
||||
DECLARE_COMMAND( UNJUPE )
|
||||
DECLARE_COMMAND ( FORCECHANGLINE )
|
||||
DECLARE_COMMAND ( SHELLS )
|
||||
DECLARE_COMMAND ( ANNOUNCE )
|
||||
DECLARE_COMMAND (LISTUSERS)
|
||||
} // namespace uworld
|
||||
|
||||
} // namespace gnuworld
|
||||
|
||||
#endif // __COMMANDSDEC_H
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* Constants.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: Constants.h,v 1.17 2009/07/25 18:12:34 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#ifndef __CONSTANTS_H_
|
||||
#define __CONSTANTS_H_
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
namespace channel
|
||||
{
|
||||
|
||||
const unsigned int MaxName = 300;
|
||||
|
||||
}
|
||||
|
||||
namespace server
|
||||
{
|
||||
const unsigned int MaxName = 63;
|
||||
static const char Query[] = "SELECT name,lastuplink,lastconnected,"
|
||||
"splitedon,lastnumeric,splitreason,version,addedon,lastupdated,reportmissing"
|
||||
" FROM servers ";
|
||||
}
|
||||
|
||||
namespace User
|
||||
{
|
||||
const unsigned int MaxName = 32;
|
||||
static const char Query[] = "SELECT user_id,user_name,password,access,saccess,flags,suspend_expires,suspended_by,server,isSuspended,IsUhs,IsOper,IsAdmin,IsSmt,IsCoder,GetLogs,NeedOp,Email,Suspend_Level,Suspend_Reason,notice,GetLag,LastPassChangeTS FROM opers";
|
||||
}
|
||||
|
||||
namespace gline
|
||||
{
|
||||
const unsigned int GLINE_OK =0x01;
|
||||
const unsigned int FORCE_NEEDED_HOST = 0x02;
|
||||
const unsigned int FORCE_NEEDED_TIME = 0x04;
|
||||
const unsigned int FU_NEEDED_USERS = 0x08;
|
||||
const unsigned int HUH_NO_HOST = 0x10;
|
||||
const unsigned int HUH_NO_USERS = 0x20;
|
||||
const unsigned int BAD_HOST = 0x40;
|
||||
const unsigned int BAD_TIME = 0x80;
|
||||
const unsigned int FORCE_NEEDED_WILDTIME = 0x100;
|
||||
const unsigned int FU_NEEDED_TIME = 0x200;
|
||||
const unsigned int NEG_TIME = 0x400;
|
||||
const unsigned int BAD_CIDRLEN = 0x800;
|
||||
const unsigned int BAD_CIDRMASK = 0x1000;
|
||||
const unsigned int BAD_CIDROVERRIDE = 0x2000;
|
||||
const unsigned int HUH_IS_EXCEPTION = 0x4000;
|
||||
const unsigned int HUH_IS_IP_OF_OPER = 0x8000;
|
||||
const unsigned int MGLINE_TIME = 3*24*3600;
|
||||
const unsigned int MGLINE_WILD_NOID_TIME = 7200;
|
||||
const unsigned int MGLINE_WILD_TIME = 24*3600;
|
||||
const unsigned int MFGLINE_USERS = 255;
|
||||
const unsigned int MFGLINE_TIME = 100*3600*24; //14*3600*24;
|
||||
const unsigned int PERM_TIME = 730*3600*24;
|
||||
const unsigned int MFU_TIME = 100*3600*24;
|
||||
const unsigned int NOLOGIN_TIME = 3600;
|
||||
const unsigned int MAX_REASON_LENGTH = 255;
|
||||
}
|
||||
|
||||
namespace flood
|
||||
{
|
||||
const unsigned int MESSAGE_POINTS = 4;
|
||||
const unsigned int CTCP_POINTS = 5;
|
||||
const unsigned int RESET_TIME = 5;
|
||||
const unsigned int FLOOD_POINTS = 20;
|
||||
const int IGNORE_TIME = 15*60;
|
||||
}
|
||||
|
||||
namespace password
|
||||
{
|
||||
const unsigned int MIN_SIZE = 5;
|
||||
const unsigned int TOO_SHORT = 1;
|
||||
const unsigned int LIKE_UNAME = 2;
|
||||
const unsigned int PASS_OK = 3;
|
||||
}
|
||||
|
||||
namespace badChannels
|
||||
{
|
||||
static const char Query[] = "SELECT Name,Reason,AddedBy FROM BadChannels";
|
||||
}
|
||||
|
||||
namespace scan
|
||||
{
|
||||
static const unsigned int MAX_SHOW = 15;
|
||||
}
|
||||
|
||||
namespace exceptions
|
||||
{
|
||||
static const char Query[] = "SELECT Host,Connections,AddedBy,AddedOn,Reason FROM Exceptions WHERE lower(Host)='";
|
||||
const unsigned int MAX_REASON = 449;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
|
||||
Following are the ppl who helped out in bringing ccontrol to what
|
||||
it is today, (hopefully i didnt forget anyone)
|
||||
|
||||
Developers team/helpers:
|
||||
-------------------------
|
||||
|
||||
MrBean - Tomer cohen <MrBean@Undernet.org>
|
||||
|
||||
Lead developer of project ccontrol. He has completely rewritten
|
||||
ccontrol, taking it from a small and barely functional oper service, and
|
||||
transforming it into fully developed and mature software project. All
|
||||
the credit goes to you bean :)
|
||||
|
||||
ripper_ - Dan Karrels <dan@karrels.com>
|
||||
|
||||
Without whom we didnt even have the Gnuworld API Server,
|
||||
you helped out in every espect there is, suggestions, bugs hunting
|
||||
and core related support.
|
||||
|
||||
nextie - Orlando Bassotto <next@mediabit.net>
|
||||
|
||||
For your help in writing the Gnuworld API server,
|
||||
i am sure you are keeping up your great work wherever you are.
|
||||
|
||||
Isomer - Perry Lorier <perry@coders.net>
|
||||
|
||||
For a lot of suggestions and help regarding undernet.
|
||||
|
||||
Gte- - Greg Sikorski <gte@atomicrevs.demon.co.uk>
|
||||
|
||||
For the help with my SQL/database questions.
|
||||
|
||||
notnet - Tim Vogelsang <net@astrolink.org>
|
||||
|
||||
For your help in bug hunting, and for being there when
|
||||
i was about to loose my mind from em .. :)
|
||||
|
||||
Dintn -
|
||||
|
||||
For helping with the undernet policy, alot of great ideas
|
||||
and running after the admins so that they'll finally approve
|
||||
a testlink :)
|
||||
|
||||
Omnidymnc -
|
||||
|
||||
For alot of bug reporting, only god knows how you tracked them
|
||||
|
||||
|
||||
Special Thanks:
|
||||
---------------
|
||||
|
||||
GenericNet irc network administration,
|
||||
For being my ginny pigs as testers of new features, and bugs reporting.
|
||||
|
||||
And of course to all of the great users out there who reported bugs
|
||||
and suggested new ideas, THANK YOU.
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* DEAUTHCommand.cc
|
||||
* Deauthenticates 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: DEAUTHCommand.cc,v 1.14 2006/09/26 17:35:58 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
#include <iomanip>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: DEAUTHCommand.cc,v 1.14 2006/09/26 17:35:58 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool DEAUTHCommand::Exec( iClient* theClient, const string& )
|
||||
{
|
||||
//Fetch the user authenticate entry
|
||||
ccUser* tmpUser = bot->IsAuth(theClient->getCharYYXXX());
|
||||
if (!tmpUser)
|
||||
{
|
||||
bot->Notice(theClient,"You are not currently authenticated");
|
||||
return false;
|
||||
}
|
||||
if(bot->deAuthUser(tmpUser))
|
||||
{
|
||||
bot->Notice(theClient,"DeAuthentication successfull");
|
||||
bot->MsgChanLog("(%s) - %s : Deauthenticated\n",tmpUser->getUserName().c_str()
|
||||
,theClient->getRealNickUserHost().c_str());
|
||||
/* forget their details to stop them getting auto-authenticated after netsplit */
|
||||
tmpUser->setLastAuthTS(1); /* if uninitialised, this would be 0 - so 1 should be a safe figure! */
|
||||
tmpUser->setLastAuthNumeric("");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"DeAuthentication failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* DEOPCommand.cc
|
||||
* Cause the bot to deop users on a specific 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: DEOPCommand.cc,v 1.16 2006/09/26 17:35:58 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "Constants.h"
|
||||
#include "ccBadChannel.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: DEOPCommand.cc,v 1.16 2006/09/26 17:35:58 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool DEOPCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
bool foundUser = false;
|
||||
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 3 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if(st[1].size() > channel::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Channel name can't be more than %d characters",
|
||||
channel::MaxName);
|
||||
return false;
|
||||
}
|
||||
Channel* theChan = Network->findChannel( st[ 1 ] ) ;
|
||||
if( NULL == theChan )
|
||||
{
|
||||
bot->Notice( theClient, "Unable to find channel %s\n",
|
||||
st[ 1 ].c_str() ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
ccBadChannel* Chan = bot->isBadChannel(st[1]);
|
||||
if(Chan)
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, but you can not change modes in "
|
||||
"this channel because: %s",
|
||||
Chan->getReason().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
iClient* Target = 0;
|
||||
|
||||
|
||||
bot->MsgChanLog("DEOP %s\n",st.assemble(1).c_str());
|
||||
string modes = "-";
|
||||
string args = "";
|
||||
|
||||
for( StringTokenizer::size_type i = 2 ; i < st.size() ; ++i )
|
||||
{
|
||||
if(st[i].size() > 64)
|
||||
{
|
||||
bot->Notice(theClient,"Nick can't be more than 64 characters");
|
||||
return false;
|
||||
}
|
||||
|
||||
Target = Network->findNick( st[ i ] ) ;
|
||||
if( 0 == Target )
|
||||
{
|
||||
continue ;
|
||||
}
|
||||
|
||||
// Check if the user is in the channel and he's not already opped
|
||||
ChannelUser* tmpChanUser = theChan->findUser(Target) ;
|
||||
if( !tmpChanUser )
|
||||
{
|
||||
continue ;
|
||||
}
|
||||
|
||||
if( Target->getMode( iClient::MODE_SERVICES ) )
|
||||
{
|
||||
// Don't op services clients, they can op themselves.
|
||||
continue ;
|
||||
}
|
||||
/* ok, the user is in the channel, flag it */
|
||||
foundUser = true;
|
||||
modes += "o";
|
||||
args += st[i] + " ";
|
||||
} // for
|
||||
|
||||
if (!foundUser)
|
||||
{
|
||||
bot->Notice(theClient, "I couldn't find anyone to deop in %s!",
|
||||
st[1].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !args.empty() )
|
||||
{
|
||||
bot->Mode(theChan,modes,args,true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* EXCEPTIONCommand.cc
|
||||
* Modify the exceptions list
|
||||
*
|
||||
* 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: EXCEPTIONCommand.cc,v 1.18 2006/09/26 17:35:58 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: EXCEPTIONCommand.cc,v 1.18 2006/09/26 17:35:58 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool EXCEPTIONCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if(st.size() < 2)
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
bot->MsgChanLog("EXCEPTIONS %s\n",st.assemble(1).c_str());
|
||||
if(!strcasecmp(st[1].c_str(),"list")) //Trying to list all exceptions?
|
||||
{
|
||||
bot->listExceptions(theClient);
|
||||
return true;
|
||||
}
|
||||
else if(!strcasecmp(st[1].c_str(),"add")) //Trying to add an exception?
|
||||
{
|
||||
if(st.size() < 5)
|
||||
{
|
||||
bot->Notice(theClient,"you must specify the host you want to add, the connection count and the reason\n");
|
||||
return false;
|
||||
}
|
||||
if(st[2].size() > 128)
|
||||
{
|
||||
bot->Notice(theClient,"Hostname can't be more than 128 characters");
|
||||
return false;
|
||||
}
|
||||
else if(st[4].size() > exceptions::MAX_REASON)
|
||||
{
|
||||
bot->Notice(theClient,"Reason can't be more than %d characters",
|
||||
exceptions::MAX_REASON);
|
||||
return false;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!bot->insertException(theClient,st[2],atoi(st[3].c_str()),st.assemble(4)))
|
||||
{
|
||||
bot->Notice(theClient,"Error while adding exception\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Successfully added an exception on host '%s' for %d connections"
|
||||
,st[2].c_str(),atoi(st[3].c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!strcasecmp(st[1].c_str(),"del")) //Trying to add an exception?
|
||||
{
|
||||
if(st.size() < 3)
|
||||
{
|
||||
bot->Notice(theClient,"you must specify the host you want to delete");
|
||||
return false;
|
||||
}
|
||||
if(st[2].size() > 128)
|
||||
{
|
||||
bot->Notice(theClient,"Hostname can't be more than 128 characters");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!bot->delException(theClient,st[2]))
|
||||
{
|
||||
bot->Notice(theClient,"Error while deleting exception for host '%s'",st[2].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Successfully deleted exception for host '%s'",st[2].c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
/* unknown command */
|
||||
bot->Notice(theClient, "You must use 'add', 'del' or 'list'!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* FORCECHANGLINECommand.cc
|
||||
* Glines a specific 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: FORCECHANGLINECommand.cc,v 1.5 2009/06/06 07:53:34 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "misc.h"
|
||||
#include "Gline.h"
|
||||
#include "ip.h"
|
||||
#include "ELog.h"
|
||||
#include "Gline.h"
|
||||
//#include "gline.h"
|
||||
#include "time.h"
|
||||
#include "ccUser.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: FORCECHANGLINECommand.cc,v 1.5 2009/06/06 07:53:34 hidden1 Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string;
|
||||
|
||||
// Input: changline #blah reason
|
||||
//
|
||||
// Output: C GL * +*@lamer.net 3600 :Banned (*@lamer) ...
|
||||
//
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool FORCECHANGLINECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
const int MAX_CHANGLINE_LENGTH = 24*3600;
|
||||
StringTokenizer st(Message);
|
||||
unsigned int ResStart = 2;
|
||||
int uParam = 0; // if the -u paramter is used in the command, it will only gline unidented connections
|
||||
|
||||
if (st.size() < 4)
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (st[1] == "-u") {
|
||||
if (st.size() < 5) {
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
uParam = 1;
|
||||
}
|
||||
|
||||
StringTokenizer::size_type pos = 1;
|
||||
time_t gLength = bot->getDefaultGlineLength();
|
||||
ccUser* tmpUser = bot->IsAuth(theClient);
|
||||
|
||||
/* log use of the command */
|
||||
bot->MsgChanLog("FORCECHANGLINE %s\n",st.assemble(1).c_str());
|
||||
|
||||
/* make sure they're trying a channel gline! */
|
||||
if (st[pos+uParam].substr(0,1) != "#")
|
||||
{
|
||||
bot->Notice(theClient,"Umm... this is CHANGLINE, not GLINE - Try "
|
||||
"glining a channel maybe?");
|
||||
return true;
|
||||
}
|
||||
if (IsTimeSpec(st[2+uParam]))
|
||||
{
|
||||
gLength = extractTime( st[2+uParam], 1 );
|
||||
} else {
|
||||
gLength = bot->getDefaultGlineLength();
|
||||
ResStart = 1;
|
||||
}
|
||||
if (gLength > MAX_CHANGLINE_LENGTH)
|
||||
{
|
||||
bot->Notice(theClient,"FORCECHANGLINE is limited for maximum %d seconds, "
|
||||
"please use the CHANGLINE command instead",MAX_CHANGLINE_LENGTH);
|
||||
return false;
|
||||
}
|
||||
string nickUserHost = theClient->getRealNickUserHost();
|
||||
|
||||
if (!tmpUser)
|
||||
{
|
||||
bot->Notice(theClient,"You must login to issue this channel gline!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (st[1+uParam].size() > channel::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Channel name can't be more than %d "
|
||||
"characters", channel::MaxName);
|
||||
return false;
|
||||
}
|
||||
if(bot->isBadChannel(st[1+uParam]) != NULL)
|
||||
{
|
||||
bot->Notice(theClient,"You cant gline a nomode channel");
|
||||
return false;
|
||||
}
|
||||
Channel* theChan = Network->findChannel(st[1+uParam]);
|
||||
if (NULL == theChan)
|
||||
{
|
||||
bot->Notice(theClient, "Unable to find channel %s",
|
||||
st[1+uParam].c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
StringTokenizer reason(st.assemble(pos + ResStart + uParam), '|');
|
||||
|
||||
if(!bot->glineChannelUsers(theClient, theChan, reason[0], gLength, nickUserHost,true,uParam))
|
||||
{
|
||||
bot->Notice(theClient, "You cant gline a channel which has an oper in it");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
/**
|
||||
* FORCECommand.cc
|
||||
* Glines a specific mask
|
||||
* 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: FORCEGLINECommand.cc,v 1.39 2009/06/09 05:55:55 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "misc.h"
|
||||
#include "Gline.h"
|
||||
#include "ip.h"
|
||||
#include "ELog.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: FORCEGLINECommand.cc,v 1.39 2009/06/09 05:55:55 hidden1 Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
// Input: forcegline *@blah.net reason
|
||||
// Input: forcegline 3600 *@blah.net reason
|
||||
//
|
||||
// Output: C GL * +*@lamer.net 3600 :Banned (*@lamer) ...
|
||||
//
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool FORCEGLINECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if( st.size() < 3 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
StringTokenizer::size_type pos = 1 ;
|
||||
|
||||
bool Forced = false;
|
||||
|
||||
ccUser* tmpUser = bot->IsAuth(theClient);
|
||||
bot->MsgChanLog("FORCEGLINE %s\n",st.assemble(1).c_str());
|
||||
if(!strcasecmp(st[pos],"-fu"))
|
||||
{
|
||||
Forced = true;
|
||||
pos++;
|
||||
if( st.size() < 4 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
time_t gLength = bot->getDefaultGlineLength() ;
|
||||
|
||||
// (pos) is the index of the next token, the user@host mask.
|
||||
|
||||
if(string::npos != st[pos].find_first_of('#'))
|
||||
{
|
||||
bot->Notice(theClient,"I don't think glining that host is such a good idea, lose the #");
|
||||
return true;
|
||||
}
|
||||
if(st[pos].substr(0,1) == "$")
|
||||
{
|
||||
bot->Notice(theClient,"Please use SGLINE to set that gline");
|
||||
return true;
|
||||
}
|
||||
string::size_type atPos = st[ pos ].find_first_of( '@' ) ;
|
||||
if( string::npos == atPos )
|
||||
{
|
||||
// User has only specified hostname, not a user name
|
||||
bot->Notice( theClient, "GLINE: Please specify gline mask in the "
|
||||
"format: user@host" ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
string userName = st[ pos ].substr( 0, pos ) ;
|
||||
string hostName = st[ pos ].substr( pos + 1 ) ;
|
||||
string Length;
|
||||
Length.assign(st[pos+1]);
|
||||
unsigned int ResStart = 2;
|
||||
bool Ok = true;
|
||||
if (IsTimeSpec(st[2]))
|
||||
{
|
||||
gLength = extractTime( st[2], 1 );
|
||||
} else {
|
||||
gLength = bot->getDefaultGlineLength() ;
|
||||
ResStart = 1;
|
||||
}
|
||||
//ccUser *tmpAuth = bot->IsAuth(theClient);
|
||||
if(!tmpUser)
|
||||
{ // We shouldnt have got here in the first place, but check it anyway
|
||||
return false;
|
||||
}
|
||||
if((Forced) && (tmpUser->getType() < operLevel::SMTLEVEL))
|
||||
{
|
||||
bot->Notice(theClient,"Only SMT+ can use the -fu option");
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int Users;
|
||||
int gCheck = bot->checkGline(st[pos],gLength,Users);
|
||||
|
||||
if(gCheck & gline::NEG_TIME)
|
||||
{
|
||||
bot->Notice(theClient,"You can't gline for a negative amount of time!");
|
||||
Ok = false;
|
||||
}
|
||||
|
||||
if(gCheck & gline::HUH_NO_HOST)
|
||||
{
|
||||
bot->Notice(theClient,"I don't think glining that host is such a good idea, do you?");
|
||||
Ok = false;
|
||||
}
|
||||
if(gCheck & gline::BAD_HOST)
|
||||
{
|
||||
bot->Notice(theClient,"illegal host");
|
||||
Ok = false;
|
||||
}
|
||||
if(gCheck & gline::BAD_CIDRMASK)
|
||||
{
|
||||
bot->Notice(theClient,"The IP listed is not on a bit boundary for the CIDR mask specified.");
|
||||
Ok = false;
|
||||
}
|
||||
if(gCheck & gline::BAD_CIDRLEN)
|
||||
{
|
||||
bot->Notice(theClient,"Bad CIDR length - try something more specific.");
|
||||
Ok = false;
|
||||
}
|
||||
if(gCheck & gline::BAD_CIDROVERRIDE)
|
||||
{
|
||||
bot->Notice(theClient,"For CIDR glines, you must enter all 4 parts of the IP.");
|
||||
Ok = false;
|
||||
}
|
||||
if(gCheck & gline::BAD_TIME)
|
||||
{
|
||||
bot->Notice(theClient,"Glining for more than %d seconds is not allowed",gline::MFGLINE_TIME);
|
||||
Ok = false;
|
||||
}
|
||||
if((gCheck & gline::FU_NEEDED_USERS) && (Ok))
|
||||
{
|
||||
if(!Forced)
|
||||
{
|
||||
Ok = false;
|
||||
if(tmpUser->getFlags() < operLevel::SMTLEVEL)
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, you can't set a gline which affects more than %d users",
|
||||
gline::MFGLINE_USERS);
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"This gline affects more than %d users, please use the -fu flag",
|
||||
gline::MFGLINE_USERS);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if((gCheck & gline::FU_NEEDED_TIME) && (Ok))
|
||||
{
|
||||
if(!Forced)
|
||||
{
|
||||
Ok = false;
|
||||
if(tmpUser->getFlags() < operLevel::SMTLEVEL)
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, you can't set a gline for more than %d seconds",
|
||||
gline::MFGLINE_TIME);
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"This gline is for more than %d seconds, please use the -fu flag",
|
||||
gline::MFGLINE_TIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
if((gCheck & gline::HUH_IS_IP_OF_OPER) && (Ok))
|
||||
{
|
||||
if (bot->isGlinedException(userName + "@" + hostName) > 0) {
|
||||
bot->Notice(theClient,"There is someone who previously opered from that host. G-line sent (forced)");
|
||||
}
|
||||
else {
|
||||
bot->Notice(theClient,"There is someone who previously opered from that host (%s). Send the gline again to force.", bot->getLastNUHOfOperFromIP(hostName).c_str());
|
||||
bot->addGlinedException(userName + "@" + hostName);
|
||||
Ok = false;
|
||||
}
|
||||
}
|
||||
if((gCheck & gline::HUH_IS_EXCEPTION) && (Ok))
|
||||
{
|
||||
if (bot->isGlinedException(userName + "@" + hostName) > 0) {
|
||||
bot->Notice(theClient,"There is an exception for that host. G-line sent (forced)");
|
||||
}
|
||||
else {
|
||||
bot->Notice(theClient,"There is an exception for that host. Send the gline again to force.");
|
||||
bot->addGlinedException(userName + "@" + hostName);
|
||||
Ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*if((gCheck & gline::FORCE_NEEDED_HOST) && (Ok))
|
||||
{
|
||||
bot->MsgChanLog("%s is using forcegline to gline a wildcard host (%s@%s)"
|
||||
,theClient->getNickName().c_str()
|
||||
,userName.c_str(),hostName.c_str());
|
||||
}
|
||||
|
||||
|
||||
if((gCheck & gline::FORCE_NEEDED_TIME) && (Ok))
|
||||
{
|
||||
bot->MsgChanLog("%s is using forcegline to gline for %d seconds"
|
||||
,theClient->getNickName().c_str(),gLength);
|
||||
}
|
||||
|
||||
if(gCheck & gline::FORCE_NEEDED_WILDTIME)
|
||||
{
|
||||
bot->MsgChanLog("%s is using forcegline to gline a wildcard host for more than %d seconds"
|
||||
,theClient->getNickName().c_str()
|
||||
,gline::MGLINE_WILD_TIME);
|
||||
}*/
|
||||
if(!Ok)
|
||||
{
|
||||
bot->Notice(theClient,"Please fix all of the above, and try again");
|
||||
return false;
|
||||
|
||||
}
|
||||
if(gCheck & gline::GLINE_OK)
|
||||
{
|
||||
bot->Notice(theClient,"Please use the GLINE command to set that gline");
|
||||
return false;
|
||||
}
|
||||
// Avoid passing a reference to a temporary variable.
|
||||
string nickUserHost = theClient->getRealNickUserHost() ;
|
||||
char Us[100];
|
||||
Us[0] = '\0';
|
||||
sprintf(Us,"%d",Users);
|
||||
string Reason = st.assemble( pos + ResStart );
|
||||
StringTokenizer ReasonTokenizer(Reason,'|');
|
||||
Reason = string("[") + Us + "] " + ReasonTokenizer[0];
|
||||
if(Reason.size() > gline::MAX_REASON_LENGTH)
|
||||
{
|
||||
bot->Notice(theClient,"Gline reason can't be more than %d characters",
|
||||
gline::MAX_REASON_LENGTH);
|
||||
return false;
|
||||
}
|
||||
/*server->setGline( nickUserHost,
|
||||
st[ pos ],
|
||||
string("[") + Us + "] " + Reason,
|
||||
//st.assemble( pos + ResStart ) + "[" + Us + "]",
|
||||
gLength , bot) ;*/
|
||||
|
||||
ccGline *TmpGline = bot->findGline(st[pos]);
|
||||
bool Up = false;
|
||||
|
||||
if(TmpGline)
|
||||
Up = true;
|
||||
else TmpGline = new ccGline(bot->SQLDb);
|
||||
TmpGline->setHost(st [ pos ]);
|
||||
TmpGline->setExpires(unsigned(::time(0) + gLength));
|
||||
TmpGline->setAddedBy(nickUserHost);
|
||||
TmpGline->setReason(Reason);
|
||||
TmpGline->setAddedOn(::time(0));
|
||||
TmpGline->setLastUpdated(::time(0));
|
||||
bot->addGlineToUplink(TmpGline);
|
||||
if(Up)
|
||||
{
|
||||
TmpGline->Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
TmpGline->Insert();
|
||||
//We need to update the Id
|
||||
TmpGline->loadData(TmpGline->getHost());
|
||||
bot->addGline(TmpGline);
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
/**
|
||||
* GCHANCommand.cc
|
||||
*
|
||||
* close down 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: GCHANCommand.cc,v 1.17 2006/09/26 17:35:58 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "misc.h"
|
||||
#include "Gline.h"
|
||||
#include "ip.h"
|
||||
#include "ELog.h"
|
||||
#include "Gline.h"
|
||||
//#include "gline.h"
|
||||
#include "time.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: GCHANCommand.cc,v 1.17 2006/09/26 17:35:58 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool GCHANCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if( st.size() < 4 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
StringTokenizer::size_type pos = 1 ;
|
||||
|
||||
bot->MsgChanLog("GCHAN %s\n",st.assemble(1).c_str());
|
||||
time_t gLength = bot->getDefaultGlineLength() ;
|
||||
|
||||
// (pos) is the index of the next token, the user@host mask.
|
||||
|
||||
if( (st[pos].substr(0,1) != "#" ) || (st[pos].size() > channel::MaxName))
|
||||
{
|
||||
// Channel name must start with #
|
||||
bot->Notice( theClient, "GCHAN: Please specify a legal channel name "
|
||||
"(must start with # and no longer than %d characters)",
|
||||
channel::MaxName ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
string Length;
|
||||
Length.assign(st[pos+1]);
|
||||
unsigned int Units = 1; //Defualt for seconds
|
||||
unsigned int ResStart = 2;
|
||||
bool isPerm = false;
|
||||
if(!strcasecmp(Length.substr(Length.length()-1).c_str(),"d"))
|
||||
{
|
||||
Units = 24*3600;
|
||||
Length.resize(Length.length()-1);
|
||||
//ResStart = 2;
|
||||
}
|
||||
else if(!strcasecmp(Length.substr(Length.length()-1).c_str(),"h"))
|
||||
{
|
||||
Units = 3600;
|
||||
Length.resize(Length.length()-1);
|
||||
// ResStart = 2;
|
||||
}
|
||||
else if(!strcasecmp(Length.substr(Length.length()-1).c_str(),"m"))
|
||||
{
|
||||
Units = 60;
|
||||
Length.resize(Length.length()-1);
|
||||
// ResStart = 2;
|
||||
}
|
||||
|
||||
else if(!strcasecmp(Length.substr(Length.length()-1).c_str(),"s"))
|
||||
{
|
||||
Units = 1;
|
||||
Length.resize(Length.length()-1);
|
||||
// ResStart = 2;
|
||||
}
|
||||
gLength = atoi(Length.c_str()) * Units;
|
||||
if(gLength == 0)
|
||||
{ //ok its a string, check if it marks permanent gline
|
||||
if(!strcasecmp(Length,"-per"))
|
||||
{
|
||||
isPerm = true;
|
||||
gLength = gline::PERM_TIME; //Set for two years , its long enough
|
||||
if(st.size() < 4)
|
||||
{
|
||||
Usage(theClient);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gLength = bot->getDefaultGlineLength() ;
|
||||
bot->Notice(theClient,"No duration was set, using %d seconds by default",
|
||||
gLength);
|
||||
ResStart = 1;
|
||||
}
|
||||
}
|
||||
else if(st.size() < 4)
|
||||
{
|
||||
Usage(theClient);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Avoid passing a reference to a temporary variable.
|
||||
string nickUserHost = theClient->getRealNickUserHost() ;
|
||||
string Reason = st.assemble( pos + ResStart );
|
||||
if(Reason.size() > 255)
|
||||
{
|
||||
bot->Notice(theClient,"Gline reason can't be more than 255 characters");
|
||||
return false;
|
||||
}
|
||||
|
||||
/*server->setGline( nickUserHost,
|
||||
st[ pos ],
|
||||
Reason ,
|
||||
gLength , bot) ;*/
|
||||
ccGline *TmpGline = bot->findGline(st[pos]);
|
||||
bool Up = false;
|
||||
if(TmpGline)
|
||||
Up = true;
|
||||
else TmpGline = new ccGline(bot->SQLDb);
|
||||
TmpGline->setHost(st [ pos ]);
|
||||
if(!isPerm)
|
||||
TmpGline->setExpires(::time(0) + gLength);
|
||||
else
|
||||
TmpGline->setExpires(0);
|
||||
TmpGline->setAddedBy(nickUserHost);
|
||||
TmpGline->setReason(st.assemble( pos + ResStart ));
|
||||
TmpGline->setAddedOn(::time(0));
|
||||
TmpGline->setLastUpdated(::time(0));
|
||||
bot->addGlineToUplink(TmpGline);
|
||||
if(Up)
|
||||
{
|
||||
TmpGline->Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
TmpGline->Insert();
|
||||
//We need to update the Id
|
||||
TmpGline->loadData(TmpGline->getHost());
|
||||
bot->addGline(TmpGline);
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,321 @@
|
||||
/**
|
||||
* GLINECommand.cc
|
||||
* Glines a specific mask
|
||||
* 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: GLINECommand.cc,v 1.64 2009/06/09 05:55:55 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "misc.h"
|
||||
#include "Gline.h"
|
||||
#include "ip.h"
|
||||
#include "ELog.h"
|
||||
#include "Gline.h"
|
||||
//#include "gline.h"
|
||||
#include "time.h"
|
||||
#include "ccUser.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: GLINECommand.cc,v 1.64 2009/06/09 05:55:55 hidden1 Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
// Input: gline *@blah.net reason
|
||||
// Input: gline 3600 *@blah.net reason
|
||||
//
|
||||
// Output: C GL * +*@lamer.net 3600 :Banned (*@lamer) ...
|
||||
//
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool GLINECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
bool Ok = true;
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if( st.size() < 4 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
StringTokenizer::size_type pos = 1 ;
|
||||
|
||||
|
||||
time_t gLength = bot->getDefaultGlineLength() ;
|
||||
|
||||
ccUser* tmpUser = bot->IsAuth(theClient);
|
||||
|
||||
bot->MsgChanLog("GLINE %s\n",st.assemble(1).c_str());
|
||||
|
||||
if(st[pos].substr(0,1) == "#")
|
||||
{
|
||||
bot->Notice(theClient, "Please use the CHANGLINE command to gline channels");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(st[pos].find_first_of('#') != string::npos)
|
||||
{
|
||||
bot->Notice(theClient,"Nice try, but i dont think glining that host is such a good idea");
|
||||
return true;
|
||||
}
|
||||
string userName;
|
||||
string hostName;
|
||||
if(st[pos].substr(0,1) == "$")
|
||||
{
|
||||
bot->Notice(theClient,"Please use SGLINE to set this gline");
|
||||
return true;
|
||||
}
|
||||
string::size_type atPos = st[ pos ].find_first_of( '@' ) ;
|
||||
if( string::npos == atPos )
|
||||
{
|
||||
|
||||
if((atPos = st [ pos ].find_first_of('.')) == string::npos)
|
||||
{
|
||||
// user has probably specified a nickname (asked by isomer:P)
|
||||
iClient* tClient = Network->findNick(st[pos]);
|
||||
if(!tClient)
|
||||
{
|
||||
bot->Notice( theClient, "i can't find '%s' online, "
|
||||
"please specify a host instead",
|
||||
st[pos].c_str());
|
||||
return true ;
|
||||
}
|
||||
else //Ohhh neat we found our target, lets grab his ip
|
||||
{
|
||||
userName = tClient->getUserName();
|
||||
if(userName[0] == '~')
|
||||
{
|
||||
userName = "~*";
|
||||
}
|
||||
hostName = xIP(tClient->getIP()).GetNumericIP();
|
||||
string newMsg = "GLINE mask for " + st[pos] + " is " + userName + "@" + hostName;
|
||||
bot->MsgChanLog("%s\n",newMsg.c_str());
|
||||
#ifndef LOGTOHD
|
||||
if(tmpUser)
|
||||
bot->DailyLog(tmpUser,"%s",newMsg.c_str());
|
||||
else
|
||||
bot->DailyLog(theClient,"%s",newMsg.c_str());
|
||||
#else
|
||||
ccLog* newLog = new (std::nothrow) ccLog();
|
||||
newLog->Time = ::time(0);
|
||||
newLog->Desc = newMsg.c_str();
|
||||
newLog->Host = theClient->getRealNickUserHost().c_str();
|
||||
if(tmpUser)
|
||||
newLog->User = tmpUser->getUserName().c_str();
|
||||
else
|
||||
newLog->User = "Unknown";
|
||||
newLog->CommandName = "GLINE";
|
||||
bot->DailyLog(newLog);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//user forgot to add *@ so lets add it for him
|
||||
userName = "*";
|
||||
hostName = st[ pos ];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
userName = st[ pos ].substr( 0, atPos ) ;
|
||||
hostName = st[ pos ].substr( atPos + 1 ) ;
|
||||
}
|
||||
unsigned int ResStart = 2;
|
||||
if (IsTimeSpec(st[2]))
|
||||
{
|
||||
gLength = extractTime( st[2], 1 );
|
||||
} else {
|
||||
gLength = bot->getDefaultGlineLength();
|
||||
ResStart = 1;
|
||||
}
|
||||
|
||||
string nickUserHost = theClient->getRealNickUserHost() ;
|
||||
|
||||
unsigned int Users;
|
||||
if(!tmpUser)
|
||||
{
|
||||
if((string::npos != hostName.find_first_of("*"))
|
||||
|| (string::npos != hostName.find_first_of("?"))
|
||||
|| ((unsigned)gLength > gline::NOLOGIN_TIME))
|
||||
{
|
||||
bot->Notice(theClient,"You must login to issue this gline!");
|
||||
return true;
|
||||
}
|
||||
Users = Network->countMatchingRealUserHost(string(userName + "@" + hostName));
|
||||
}
|
||||
else
|
||||
{
|
||||
int gCheck = bot->checkGline(string(userName + "@" + hostName),gLength,Users);
|
||||
if(gCheck & gline::NEG_TIME)
|
||||
{
|
||||
bot->Notice(theClient,"You can't gline for a negative amount of time.");
|
||||
Ok = false;
|
||||
}
|
||||
if(gCheck & gline::HUH_NO_HOST)
|
||||
{
|
||||
bot->Notice(theClient,"I don't think glining that host is such a good idea, do you?");
|
||||
Ok = false;
|
||||
}
|
||||
if(gCheck & gline::BAD_HOST)
|
||||
{
|
||||
bot->Notice(theClient,"illegal host");
|
||||
Ok = false;
|
||||
}
|
||||
if(gCheck & gline::BAD_CIDRMASK)
|
||||
{
|
||||
bot->Notice(theClient,"The IP listed is not on a bit boundary for the CIDR mask specified.");
|
||||
Ok = false;
|
||||
}
|
||||
if (gCheck & gline::BAD_CIDRLEN)
|
||||
{
|
||||
bot->Notice(theClient,"Bad CIDR length - try something more specific.");
|
||||
Ok = false;
|
||||
}
|
||||
if (gCheck & gline::BAD_CIDROVERRIDE)
|
||||
{
|
||||
bot->Notice(theClient,"For CIDR glines, you must enter all 4 parts of the IP.");
|
||||
Ok = false;
|
||||
}
|
||||
if(gCheck & gline::BAD_TIME)
|
||||
{
|
||||
bot->Notice(theClient,"Glining for more than %d seconds is not allowed.",
|
||||
gline::MFGLINE_TIME);
|
||||
Ok = false;
|
||||
}
|
||||
if((gCheck & gline::FORCE_NEEDED_HOST) && (Ok))
|
||||
{
|
||||
bot->Notice(theClient,"Please use FORCEGLINE to gline that host");
|
||||
Ok = false;
|
||||
}
|
||||
if((gCheck & gline::FORCE_NEEDED_TIME) && (Ok))
|
||||
{
|
||||
bot->Notice(theClient,"Please use FORCEGLINE to gline for that amount of time");
|
||||
Ok = false;
|
||||
}
|
||||
if((gCheck & gline::FU_NEEDED_USERS) && (Ok))
|
||||
{
|
||||
bot->Notice(theClient,"This gline would affect more than %d users, please "
|
||||
"use FORCEGLINE",gline::MFGLINE_USERS);
|
||||
Ok = false;
|
||||
}
|
||||
if((gCheck & gline::FU_NEEDED_TIME) && (Ok))
|
||||
{
|
||||
bot->Notice(theClient,"Please use FORCEGLINE to gline for more than "
|
||||
"%d seconds",gline::MFGLINE_TIME);
|
||||
Ok = false;
|
||||
}
|
||||
if((gCheck & gline::FORCE_NEEDED_WILDTIME) && (Ok))
|
||||
{
|
||||
bot->Notice(theClient,"Wildcard gline for more than %d"
|
||||
" seconds (or more than %d without ident), "
|
||||
"please use FORCEGLINE instead"
|
||||
,gline::MGLINE_WILD_TIME ,
|
||||
gline::MGLINE_WILD_NOID_TIME);
|
||||
Ok = false;
|
||||
}
|
||||
if((gCheck & gline::HUH_IS_IP_OF_OPER) && (Ok))
|
||||
{
|
||||
if (bot->isGlinedException(userName + "@" + hostName) > 0) {
|
||||
bot->Notice(theClient,"There is someone who previously opered from that host. G-line sent (forced)");
|
||||
}
|
||||
else {
|
||||
bot->Notice(theClient,"There is someone who previously opered from that host (%s). Send the gline again to force.", bot->getLastNUHOfOperFromIP(hostName).c_str());
|
||||
bot->addGlinedException(userName + "@" + hostName);
|
||||
Ok = false;
|
||||
}
|
||||
}
|
||||
if((gCheck & gline::HUH_IS_EXCEPTION) && (Ok))
|
||||
{
|
||||
if (bot->isGlinedException(userName + "@" + hostName) > 0) {
|
||||
bot->Notice(theClient,"There is an exception for that host. G-line sent (forced)");
|
||||
}
|
||||
else {
|
||||
bot->Notice(theClient,"There is an exception for that host. Send the gline again to force.");
|
||||
bot->addGlinedException(userName + "@" + hostName);
|
||||
Ok = false;
|
||||
}
|
||||
}
|
||||
if(!Ok)
|
||||
{
|
||||
bot->Notice(theClient,"Please fix all of the above, and try again");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
char Us[100];
|
||||
Us[0] = '\0';
|
||||
sprintf(Us,"%d",Users);
|
||||
StringTokenizer reasonTokenizer(st.assemble( pos + ResStart),'|');
|
||||
string Reason = reasonTokenizer[0];
|
||||
if(Reason.size() > gline::MAX_REASON_LENGTH)
|
||||
{
|
||||
bot->Notice(theClient,"Gline reason can't be more than %d characters",
|
||||
gline::MAX_REASON_LENGTH);
|
||||
return false;
|
||||
}
|
||||
Reason = string("[") + Us + string("] ") + Reason;
|
||||
/* server->setGline( nickUserHost,
|
||||
userName + "@" +hostName,
|
||||
string("[") + Us + "] " + Reason,
|
||||
//Reason + "[" + Us + "]",
|
||||
gLength ,::time(0),bot) ;*/
|
||||
ccGline *TmpGline = bot->findGline(userName + "@" + hostName);
|
||||
bool Up = false;
|
||||
|
||||
if(TmpGline)
|
||||
Up = true;
|
||||
else TmpGline = new ccGline(bot->SQLDb);
|
||||
TmpGline->setHost(userName + "@" + hostName);
|
||||
TmpGline->setExpires(unsigned(::time(0) + gLength));
|
||||
TmpGline->setAddedBy(nickUserHost);
|
||||
TmpGline->setReason(Reason);
|
||||
TmpGline->setAddedOn(::time(0));
|
||||
TmpGline->setLastUpdated(::time(0));
|
||||
bot->addGlineToUplink(TmpGline);
|
||||
if(Up)
|
||||
{
|
||||
TmpGline->Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
TmpGline->Insert();
|
||||
//We need to update the Id
|
||||
TmpGline->loadData(TmpGline->getHost());
|
||||
bot->addGline(TmpGline);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* HELPCommand.cc
|
||||
* Shows help text on 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.23 2006/09/26 17:35:58 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "commLevels.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: HELPCommand.cc,v 1.23 2006/09/26 17:35:58 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
|
||||
// help [command]
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool HELPCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
ccUser *tmpAuth = bot->IsAuth(theClient);
|
||||
//if(!tmpAuth)
|
||||
// return false;
|
||||
string banner = "--- Help Menu for " ;
|
||||
banner += bot->getNickName() + " --- (Showing commands which are available for you)" ;
|
||||
|
||||
bot->Notice( theClient, "%s", banner.c_str() ) ;
|
||||
|
||||
int ComLevel;
|
||||
// Check if the user didnt supply a command
|
||||
if( 1 == st.size() )
|
||||
{
|
||||
// Spit out all commands
|
||||
string Show;
|
||||
int Num = 0;
|
||||
for( ccontrol::constCommandIterator ptr = bot->command_begin() ;
|
||||
ptr != bot->command_end() ; ++ptr )
|
||||
{
|
||||
ComLevel = ptr->second->getFlags();
|
||||
//ComLevel &= ~flg_NOLOG;
|
||||
if((ComLevel & commandLevel::flg_NOLOGIN) || ((tmpAuth) && (tmpAuth->gotAccess(ptr->second))) )
|
||||
{
|
||||
Show += (ptr->second->getName() + " ");
|
||||
++Num;
|
||||
if(Show.size() > 80)
|
||||
{
|
||||
bot->Notice( theClient, "%s", Show.c_str()) ;
|
||||
Num = 0;
|
||||
Show.assign("");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!Show.empty())
|
||||
bot->Notice( theClient, "%s", Show.c_str()) ;
|
||||
bot->Notice(theClient,"End of command list");
|
||||
}
|
||||
else //Supplied a command, show only the help for that command (if it exists)
|
||||
{
|
||||
ccontrol::constCommandIterator ptr =
|
||||
bot->findCommand( string_upper( st[ 1 ] ) ) ;
|
||||
if( ptr == bot->command_end() )
|
||||
{
|
||||
bot->Notice( theClient, "Command not found" ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (st.size()==2)
|
||||
bot->GetHelp(theClient,st[1],static_cast<std::string>(""));
|
||||
else
|
||||
bot->GetHelp(theClient,st[1],st[2]);
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* INVITECommand.cc
|
||||
* Cause the bot to invite you 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: INVITECommand.cc,v 1.21 2006/09/26 17:35:58 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Constants.h"
|
||||
#include "Network.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: INVITECommand.cc,v 1.21 2006/09/26 17:35:58 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
// invite #channel
|
||||
bool INVITECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if( st.size() == 1 )
|
||||
{
|
||||
// send help
|
||||
Usage( theClient ) ;
|
||||
return false ;
|
||||
}
|
||||
if(st[1].size() > channel::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Channel name can't be more than %d characters",
|
||||
channel::MaxName);
|
||||
return false;
|
||||
}
|
||||
ccUser* tmpUser = bot->IsAuth(theClient);
|
||||
bot->MsgChanLog("INVITE %s\n",st.assemble(1).c_str());
|
||||
|
||||
//If the channel doesnt begin with # add it
|
||||
string chanName = st[ 1 ] ;
|
||||
if( chanName[ 0 ] != '#' )
|
||||
{
|
||||
chanName.insert( chanName.begin(), '#' ) ;
|
||||
}
|
||||
|
||||
iClient* inviteClient = 0 ;
|
||||
if(st.size() > 2)
|
||||
{
|
||||
// Invite a different user
|
||||
inviteClient = Network->findNick(st[2]);
|
||||
if( inviteClient == NULL)
|
||||
{
|
||||
bot->Notice(theClient,"I cant find '%s' anywhere",
|
||||
st[2].c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
if( !tmpUser && (inviteClient != theClient))
|
||||
{
|
||||
bot->Notice(theClient,"You must login to invite someone else!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Invite the requesting user
|
||||
inviteClient = theClient ;
|
||||
}
|
||||
|
||||
Channel* theChan = Network->findChannel(st[1]);
|
||||
if (theChan == NULL)
|
||||
{
|
||||
bot->Notice(theClient, "Channel '%s' does not exist!", st[1].c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
// xClient::Invite() will Join/Part the channel if necessary.
|
||||
return bot->Invite( inviteClient, chanName ) ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* JUPECommand.cc
|
||||
* Jupitur a 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: JUPECommand.cc,v 1.23 2006/09/26 17:35:58 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <new>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "iServer.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: JUPECommand.cc,v 1.23 2006/09/26 17:35:58 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool JUPECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 3 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// The server name to be juped must have at least 1 '.'
|
||||
if( st[1].length() > server::MaxName)
|
||||
{
|
||||
bot->Notice( theClient, "Bogus server name" ) ;
|
||||
return false ;
|
||||
}
|
||||
bot->MsgChanLog("JUPE %s\n",st.assemble(1).c_str());
|
||||
|
||||
iServer* Server;
|
||||
string SName;
|
||||
unsigned int contime;
|
||||
if(string::npos != st[ 1 ].find_first_of( '*' ))
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, but you must give a full server name when juping!");
|
||||
return false;
|
||||
}
|
||||
else if(string::npos == st[ 1 ].find_first_of( '.' ))
|
||||
{
|
||||
bot->Notice( theClient, "Bogus server name" ) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
Server = Network->findServerName(st[1]);
|
||||
if(Server)
|
||||
{
|
||||
bot->Notice(theClient,"%s is currently linked to the network"
|
||||
", it will be automatically squit.",
|
||||
st[1].c_str());
|
||||
}
|
||||
SName = st[1];
|
||||
contime = ::time(0);
|
||||
|
||||
if(!strcasecmp(SName,Network->findServer(bot->getUplink()->getUplinkCharYY())->getName()))
|
||||
{
|
||||
bot->Notice(theClient,"What are you trying to do? kill me?");
|
||||
bot->MsgChanLog("%s just tried to jupe my uplink!\n",theClient->getNickName().c_str());
|
||||
return false;
|
||||
}
|
||||
bot->MsgChanLog("%s is asking me to jupe %s because: %s\n",
|
||||
theClient->getNickName().c_str(),
|
||||
SName.c_str(),
|
||||
st.assemble(2).c_str());
|
||||
|
||||
string yyxxx( "00]]]" ) ;
|
||||
iServer* jupeServer = new (std::nothrow) iServer(
|
||||
bot->getUplinkIntYY(), // uplinkIntYY
|
||||
yyxxx,
|
||||
SName,
|
||||
time( 0 ),
|
||||
st.assemble( 2 ) ) ;
|
||||
assert( jupeServer != 0 ) ;
|
||||
jupeServer->setJupe();
|
||||
|
||||
// Attach the new (fake) server.
|
||||
server->AttachServer( jupeServer, bot ) ;
|
||||
|
||||
return true ;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
@@ -0,0 +1,133 @@
|
||||
/**
|
||||
* KICKCommand.cc
|
||||
* Kick a user from 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: KICKCommand.cc,v 1.15 2006/09/26 17:35:58 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "Network.h"
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Constants.h"
|
||||
#include "ccBadChannel.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: KICKCommand.cc,v 1.15 2006/09/26 17:35:58 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
// kick #channel nick reason
|
||||
bool KICKCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 4 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//Check if the channel begins with # , if not add it
|
||||
string chanName = st[ 1 ] ;
|
||||
if( chanName[ 0 ] != '#' )
|
||||
{
|
||||
chanName.insert( chanName.begin(), '#' ) ;
|
||||
}
|
||||
|
||||
if(chanName.size() > channel::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Channel name can't be more than %d characters",
|
||||
channel::MaxName);
|
||||
}
|
||||
|
||||
bot->MsgChanLog("KICK %s\n",st.assemble(1).c_str());
|
||||
|
||||
ccBadChannel* Chan = bot->isBadChannel(st[1]);
|
||||
if(Chan)
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, you can't kick from "
|
||||
"this channel because: %s",
|
||||
Chan->getReason().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
Channel* theChan = Network->findChannel( chanName ) ;
|
||||
if( NULL == theChan )
|
||||
{
|
||||
bot->Notice( theClient, "Unable to find channel: %s",
|
||||
chanName.c_str() ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
iClient* Target = Network->findNick( st[ 2 ] ) ;
|
||||
if( NULL == Target )
|
||||
{
|
||||
bot->Notice( theClient, "Unable to find nick: %s",
|
||||
st[ 2 ].c_str() ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if( NULL == theChan->findUser( Target ) )
|
||||
{
|
||||
bot->Notice( theClient, "User %s was not found "
|
||||
"on channel %s",
|
||||
st[ 1 ].c_str(),
|
||||
theChan->getName().c_str());
|
||||
return true ;
|
||||
}
|
||||
|
||||
if( Target->getMode(iClient::MODE_SERVICES))
|
||||
{
|
||||
bot->Notice(theClient,"Are you trying to get me in trouble with %s?",st[ 2 ].c_str());
|
||||
return false;
|
||||
}
|
||||
bot->Notice( theClient, "Kicking %s from channel %s because %s",
|
||||
Target->getNickName().c_str(),
|
||||
chanName.c_str(),
|
||||
st.assemble( 3 ).c_str() ) ;
|
||||
|
||||
//If its an oper channel , no need to join and part the channel , so just kick the user
|
||||
if( bot->isOperChan( chanName ) )
|
||||
{
|
||||
bot->Kick( theChan, Target, st.assemble( 3 ) ) ;
|
||||
return true ;
|
||||
}
|
||||
//Its not an oper channel
|
||||
bot->Join( chanName, string(), 0, true ) ;
|
||||
|
||||
bot->Kick( theChan, Target, st.assemble( 3 ) ) ;
|
||||
|
||||
bot->Part( chanName ) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/**
|
||||
* LASTCOMCommand.cc
|
||||
*
|
||||
* Sends an oper a list of the last n 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.18 2009/03/17 09:50:58 denspike Exp $
|
||||
*/
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "iClient.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "ELog.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: LASTCOMCommand.cc,v 1.18 2009/03/17 09:50:58 denspike Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::endl ;
|
||||
using std::stringstream ;
|
||||
using std::ends ;
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool LASTCOMCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
bot->MsgChanLog("LASTCOM\n");
|
||||
#ifndef LOGTOHD
|
||||
unsigned int NumOfCom;
|
||||
unsigned int Days = 0;
|
||||
stringstream theQuery;
|
||||
|
||||
if( st.size() == 1 )
|
||||
{
|
||||
NumOfCom = 20;
|
||||
static const char* queryHeader = "SELECT * FROM comlog ";
|
||||
theQuery << queryHeader
|
||||
<< " ORDER BY ts DESC"
|
||||
<< " LIMIT " << NumOfCom
|
||||
<< ends;
|
||||
}
|
||||
else
|
||||
{
|
||||
NumOfCom = atoi(st[1].c_str());
|
||||
if(st.size() > 2)
|
||||
{
|
||||
Days = atoi(st[2].c_str());
|
||||
if(Days > 365)
|
||||
{
|
||||
bot->Notice(theClient,"You can't see the log for more than a year ago");
|
||||
return false;
|
||||
}
|
||||
static const char* queryHeader
|
||||
= "SELECT * FROM comlog where ts >";
|
||||
theQuery << queryHeader
|
||||
<< (::time(0) - Days * 24 * 3600)
|
||||
<< " ORDER BY ts ASC"
|
||||
<< " LIMIT " << NumOfCom
|
||||
<< ends;
|
||||
}
|
||||
else
|
||||
{
|
||||
static const char* queryHeader
|
||||
= "SELECT * FROM comlog ";
|
||||
theQuery << queryHeader
|
||||
<< " ORDER BY ts DESC"
|
||||
<< " LIMIT " << NumOfCom
|
||||
<< ends;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
elog << "LASTCOM> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
|
||||
if (!bot->SQLDb->Exec(theQuery, true))
|
||||
//if( PGRES_TUPLES_OK != status )
|
||||
{
|
||||
elog << "LASTCOM> SQL Error: "
|
||||
<< bot->SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// SQL Query succeeded
|
||||
bot->Notice(theClient,"Listing last %d messages from day %d",NumOfCom,Days);
|
||||
for (int i = (bot->SQLDb->Tuples() - 1) ; i >= 0; i--)
|
||||
{
|
||||
bot->Notice(theClient,"[ %s - %s ] %s",bot->convertToAscTime(atoi(bot->SQLDb->GetValue(i, 0))),bot->SQLDb->GetValue(i,1).c_str(),bot->SQLDb->GetValue(i,2).c_str());
|
||||
}
|
||||
#else
|
||||
if(st.size() > 1)
|
||||
bot->showLogs(theClient,atoi(st[1].c_str()));
|
||||
else
|
||||
bot->showLogs(theClient);
|
||||
#endif
|
||||
bot->Notice(theClient,"End of debug log");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* LEARNNETCommand.cc
|
||||
* Causes the bot to automatically update its server db
|
||||
*
|
||||
* 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: LEARNNETCommand.cc,v 1.16 2006/09/26 17:35:58 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <new>
|
||||
#include <string>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "iServer.h"
|
||||
#include "Network.h"
|
||||
#include "server.h"
|
||||
#include "ccUser.h"
|
||||
#include "misc.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: LEARNNETCommand.cc,v 1.16 2006/09/26 17:35:58 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool LEARNNETCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
|
||||
bot->MsgChanLog("LEARNNET \n");
|
||||
|
||||
unsigned int AddedServers = 0;
|
||||
StringTokenizer st(Message);
|
||||
|
||||
bot->MsgChanLog("Learning network status at the request of: %s\n",
|
||||
theClient->getNickName().c_str());
|
||||
|
||||
xNetwork::serverIterator ptr = Network->servers_begin();
|
||||
xNetwork::serverIterator end = Network->servers_end();
|
||||
|
||||
for( ; ptr != end ; ptr++ )
|
||||
{
|
||||
iServer* CurServer = ptr->second ;
|
||||
if( NULL == CurServer)
|
||||
{
|
||||
continue ;
|
||||
}
|
||||
|
||||
// NOTE: Changed from isJuped()
|
||||
if((0 == Network->findFakeServer(CurServer)) &&
|
||||
(strcmp(CurServer->getName().c_str(),
|
||||
bot->getUplinkName().c_str())))
|
||||
{
|
||||
if(!bot->getServer(CurServer->getName()))
|
||||
{
|
||||
//If the server isnt in the database , update it
|
||||
ccServer* NewServer = new (std::nothrow)
|
||||
ccServer(bot->SQLDb);
|
||||
assert( NewServer != 0 ) ;
|
||||
|
||||
// TODO: Shouldn't all of this be in the
|
||||
// ccServer constructor?
|
||||
NewServer->setName(CurServer->getName());
|
||||
NewServer->setUplink(Network->findServer(CurServer->getUplinkIntYY())->getName());
|
||||
NewServer->setLastNumeric(CurServer->getCharYY());
|
||||
NewServer->setLastConnected(CurServer->getConnectTime());
|
||||
NewServer->setLastSplitted(0);
|
||||
NewServer->setAddedOn(::time(0));
|
||||
NewServer->setLastUpdated(::time(0));
|
||||
NewServer->setNetServer(CurServer);
|
||||
|
||||
bot->addServer(NewServer);
|
||||
bot->Write("%s V :%s\n",
|
||||
bot->getCharYYXXX().c_str(),
|
||||
CurServer->getCharYY().c_str());
|
||||
|
||||
if(NewServer->Insert())
|
||||
{
|
||||
AddedServers++;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->MsgChanLog("Error while learning "
|
||||
"server: %s\n",
|
||||
NewServer->getName().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bot->MsgChanLog( "Finished learning the network. Learned a total of %d "
|
||||
"servers\n", AddedServers ) ;
|
||||
bot->Notice( theClient, "Finished learning the network. Learned a "
|
||||
"total of %d servers\n", AddedServers ) ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace uworld
|
||||
|
||||
} // namespace gnuworld
|
||||
|
||||
@@ -0,0 +1,343 @@
|
||||
/**
|
||||
* LISTCommand.cc
|
||||
* Gives list of all kind of stuff to the 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: LISTCommand.cc,v 1.24 2008/08/06 19:35:58 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "Network.h"
|
||||
#include "Channel.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: LISTCommand.cc,v 1.24 2008/08/06 19:35:58 hidden1 Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool LISTCommand::Exec( iClient* theClient, const string& Message)
|
||||
{
|
||||
typedef list<const Channel*> channelListT;
|
||||
const Channel* curChannel;
|
||||
channelListT channelList;
|
||||
unsigned int count = 0;
|
||||
const char *c;
|
||||
char ch;
|
||||
string Mask;
|
||||
bool isValid = false;
|
||||
|
||||
StringTokenizer st( Message ) ;
|
||||
if(st.size() < 2)
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
bot->MsgChanLog("LIST %s\n",st.assemble(1).c_str());
|
||||
if(!strcasecmp(st[1].c_str(),"glines"))
|
||||
{
|
||||
bot->listGlines(theClient);
|
||||
}
|
||||
else if(!strcasecmp(st[1].c_str(),"suspended"))
|
||||
{
|
||||
bot->listSuspended(theClient);
|
||||
}
|
||||
else if(!strcasecmp(st[1].c_str(),"servers"))
|
||||
{
|
||||
bot->listServers(theClient);
|
||||
}
|
||||
else if(!strcasecmp(st[1].c_str(),"badchannels"))
|
||||
{
|
||||
bot->Notice(theClient,"Please use LIST nomodechannels to get a list of the channels which are marked as no mode");
|
||||
}
|
||||
else if(!strcasecmp(st[1].c_str(),"nomodechannels"))
|
||||
{
|
||||
bot->listBadChannels(theClient);
|
||||
}
|
||||
else if(!strcasecmp(st[1].c_str(),"exceptions"))
|
||||
{
|
||||
bot->listExceptions(theClient);
|
||||
}
|
||||
else if(!strcasecmp(st[1].c_str(),"channels"))
|
||||
{
|
||||
/* new "list channels" command */
|
||||
if (st.size() < 3)
|
||||
{
|
||||
/* not enough parameters */
|
||||
#ifdef TOPIC_TRACK
|
||||
bot->Notice(theClient, "'list channels' requires 'key', 'modes', 'topic' or 'topicby'");
|
||||
#else
|
||||
bot->Notice(theClient, "'list channels' requires 'key' or 'modes'");
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
if (!strcasecmp(st[2].c_str(),"key"))
|
||||
{
|
||||
if (st.size() < 4)
|
||||
{
|
||||
bot->Notice(theClient, "for 'list channels key', you must supply the key to search for!");
|
||||
return false;
|
||||
}
|
||||
/* ok, we have the key to search for in st[3] */
|
||||
channelList = Network->getChannelsWithKey(st[3]);
|
||||
|
||||
if (channelList.empty())
|
||||
{
|
||||
bot->Notice(theClient, "I'm sorry, no channels have a key matching '%s'", st[3].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
bot->Notice(theClient, "--==[ Channels matching key '%s' %s]==--", st[3].c_str(),
|
||||
(channelList.size() > 15)?"- showing first 15 only":"");
|
||||
|
||||
for (channelListT::iterator cptr = channelList.begin(); (cptr != channelList.end()) && (count < 15); cptr++)
|
||||
{
|
||||
curChannel = *cptr;
|
||||
bot->Notice(theClient, "Channel: [%4d] %s",
|
||||
curChannel->size(),
|
||||
curChannel->getName().c_str());
|
||||
count++;
|
||||
}
|
||||
bot->Notice(theClient, "--==[ End of 'list channels key %s' - %d found ]==--",
|
||||
st[3].c_str(), channelList.size());
|
||||
}
|
||||
else if (!strcasecmp(st[2].c_str(),"modes"))
|
||||
{
|
||||
if (st.size() < 4)
|
||||
{
|
||||
bot->Notice(theClient, "for 'list channels modes', you must supply the modes to match against!");
|
||||
bot->Notice(theClient, "e.g. 'list channels modes +tns-m' to require +tns and require not to have +m");
|
||||
bot->Notice(theClient, "(other modes may be set unless explicitly not required as above)");
|
||||
return false;
|
||||
}
|
||||
if ((st.size() > 4) && (string_lower(st[4]) != "-size"))
|
||||
{
|
||||
bot->Notice(theClient, "You supplied too many arguments. arguments such as +k or +l here may not contain the key or limit!");
|
||||
return false;
|
||||
}
|
||||
/* ok, we have the modes to search for in st[3] - validate them */
|
||||
if ((!match("+", st[3].substr(0,1))) && (!match("-", st[3].substr(0,1))))
|
||||
{
|
||||
bot->Notice(theClient, "The modes must start with + or - (e.g. +tns or -s)");
|
||||
return false;
|
||||
}
|
||||
isValid = true;
|
||||
c = st[3].c_str();
|
||||
while ((ch = *c++))
|
||||
{
|
||||
switch (ch) {
|
||||
case '+':
|
||||
case '-':
|
||||
case 'k':
|
||||
case 'l':
|
||||
case 'i':
|
||||
case 'm':
|
||||
case 'n':
|
||||
case 'p':
|
||||
case 's':
|
||||
case 't':
|
||||
case 'r':
|
||||
case 'D': /* acceptable modes */
|
||||
break;
|
||||
default: /* unacceptable modes */
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isValid)
|
||||
{
|
||||
bot->Notice(theClient, "The modes given are invalid (you supplied '%s', valid modes are klimnpstrD)",
|
||||
st[3].c_str());
|
||||
return false;
|
||||
}
|
||||
/* ok, validated them */
|
||||
channelList = Network->getChannelsWithModes(st[3]);
|
||||
|
||||
if (channelList.empty())
|
||||
{
|
||||
bot->Notice(theClient, "I'm sorry, no channels have modes matching '%s'", st[3].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
int maxListChannels = bot->getMaxListChannels();
|
||||
if (maxListChannels > 0)
|
||||
bot->Notice(theClient, "--==[ Channels matching modes '%s' - showing first %i only]==--",
|
||||
st[3].c_str(),maxListChannels);
|
||||
else
|
||||
bot->Notice(theClient, "--==[ Channels matching modes '%s' Showing All]==--", st[3].c_str());
|
||||
|
||||
/*if (string_lower(st[4]) == "-size")
|
||||
{
|
||||
//std::vector<std::pair<size_t, const string> > indexList;
|
||||
std::list<std::pair<size_t, const string> > indexList;
|
||||
for (channelListT::iterator cptr = channelList.begin(); (cptr != channelList.end()); cptr++)
|
||||
{
|
||||
curChannel = *cptr;
|
||||
indexList.push_back(std::make_pair(curChannel->size(),curChannel->getName().c_str()));
|
||||
}
|
||||
//std::sort(indexList.begin(), indexList.end());
|
||||
//for (size_t i = indexList.size() - 1; i >= 0; i--)
|
||||
//for (std::vector<std::pair<size_t, const string> >::iterator it = indexList.end(); it >= indexList.begin(); it--)
|
||||
// bot->Notice(theClient, "Channel: [%4d] %s",
|
||||
// indexList.at(i).first,
|
||||
// indexList.at(i).second.c_str());
|
||||
indexList.sort();
|
||||
//for (list<std::pair<size_t, const string> >::iterator it = indexList.end(); it != indexList.begin(); it--)
|
||||
for (list<std::pair<size_t, const string> >::iterator it = indexList.begin(); it != indexList.end(); it++)
|
||||
bot->Notice(theClient, "Channel: [%4d] %s",
|
||||
it->first,
|
||||
it->second.c_str());
|
||||
}
|
||||
else
|
||||
*/for (channelListT::iterator cptr = channelList.begin(); (cptr != channelList.end()); cptr++)
|
||||
{
|
||||
curChannel = *cptr;
|
||||
bot->Notice(theClient, "Channel: [%4d] %s",
|
||||
curChannel->size(),
|
||||
curChannel->getName().c_str());
|
||||
count++;
|
||||
if ((count >= maxListChannels) && (maxListChannels > 0))
|
||||
break;
|
||||
}
|
||||
bot->Notice(theClient, "--==[ End of 'list channels modes %s' - %d found ]==--",
|
||||
st[3].c_str(), channelList.size());
|
||||
}
|
||||
#ifdef TOPIC_TRACK
|
||||
else if (!strcasecmp(st[2].c_str(),"topic"))
|
||||
{
|
||||
if (st.size() < 4)
|
||||
{
|
||||
bot->Notice(theClient, "for 'list channels topic', you must supply the topic to search for!");
|
||||
return false;
|
||||
}
|
||||
/* ok, we have the topic to search for in st[3] */
|
||||
channelList = Network->getChannelsWithTopic(st[3]);
|
||||
|
||||
if (channelList.empty())
|
||||
{
|
||||
bot->Notice(theClient, "I'm sorry, no channels have a topic matching '%s'", st[3].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
bot->Notice(theClient, "--==[ Channels matching topic '%s' %s]==--", st[3].c_str(),
|
||||
(channelList.size() > 15)?"- showing first 15 only":"");
|
||||
|
||||
for (channelListT::iterator cptr = channelList.begin(); (cptr != channelList.end()) && (count < 15); cptr++)
|
||||
{
|
||||
curChannel = *cptr;
|
||||
bot->Notice(theClient, "Channel: [%4d] %s",
|
||||
curChannel->size(),
|
||||
curChannel->getName().c_str());
|
||||
count++;
|
||||
}
|
||||
bot->Notice(theClient, "--==[ End of 'list channels topic '%s' - %d found ]==--",
|
||||
st[3].c_str(), channelList.size());
|
||||
}
|
||||
else if (!strcasecmp(st[2].c_str(),"topicby"))
|
||||
{
|
||||
if (st.size() < 4)
|
||||
{
|
||||
bot->Notice(theClient, "for 'list channels topicby', you must supply the nick!user@host mask to search for!");
|
||||
return false;
|
||||
}
|
||||
/* validate the nick!user@host */
|
||||
string::size_type atPos = st[3].find_first_of('!');
|
||||
if (string::npos == atPos)
|
||||
{
|
||||
/* not in nick!user@host format */
|
||||
/* assume they want to check nick only, but tell them just in case */
|
||||
Mask = "";
|
||||
Mask += st[3].c_str();
|
||||
Mask += "!*@*";
|
||||
bot->Notice(theClient, "Mask was not in nick!user@host format, re-writing mask to '%s'. This may not be what you want!",
|
||||
Mask.c_str());
|
||||
} else {
|
||||
/* we have nick!..., check for user@host! */
|
||||
string::size_type atPos2 = st[3].find_first_of('@');
|
||||
if ((string::npos == atPos2) || (atPos2 < atPos))
|
||||
{
|
||||
/* either no '@' or it's before the first '!' */
|
||||
/* assume they want to check nick!user only, but tell them just in case */
|
||||
Mask = "";
|
||||
Mask += st[3].c_str();
|
||||
/* if the '!' is at the end of the line, we need to add a * */
|
||||
if (atPos == (st[3].length()-1))
|
||||
Mask += "*";
|
||||
Mask += "@*";
|
||||
bot->Notice(theClient, "Mask was not in nick!user@host format, re-writing mask to '%s'. This may not be what you want!",
|
||||
Mask.c_str());
|
||||
} else {
|
||||
/* we have a full nick!user@host - we dont need to alter it */
|
||||
Mask = st[3].c_str();
|
||||
}
|
||||
}
|
||||
/* ok, we have a valid topicby to search for in Mask */
|
||||
channelList = Network->getChannelsWithTopicBy(Mask);
|
||||
|
||||
if (channelList.empty())
|
||||
{
|
||||
bot->Notice(theClient, "I'm sorry, no channels have a topic matching '%s'", Mask.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
bot->Notice(theClient, "--==[ Channels with topics set by '%s' %s]==--", Mask.c_str(),
|
||||
(channelList.size() > 15)?"- showing first 15 only":"");
|
||||
|
||||
for (channelListT::iterator cptr = channelList.begin(); (cptr != channelList.end()) && (count < 15); cptr++)
|
||||
{
|
||||
curChannel = *cptr;
|
||||
bot->Notice(theClient, "Channel: [%4d] %s",
|
||||
curChannel->size(),
|
||||
curChannel->getName().c_str());
|
||||
count++;
|
||||
}
|
||||
bot->Notice(theClient, "--==[ End of 'list channels topicby '%s' - %d found ]==--",
|
||||
Mask.c_str(), channelList.size());
|
||||
} else {
|
||||
bot->Notice(theClient,"'list channels' requires 'key', 'modes', 'topic' or 'topicby'");
|
||||
return false;
|
||||
#else
|
||||
else {
|
||||
bot->Notice(theClient,"'list channels' requires 'key' or 'modes'");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Unknown list type - see HELP");
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* LISTHOSTSCommand.cc
|
||||
* Get an oper hosts entry
|
||||
*
|
||||
* 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.14 2006/09/26 17:35:59 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: LISTHOSTSCommand.cc,v 1.14 2006/09/26 17:35:59 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool LISTHOSTSCommand::Exec( iClient* theClient, const string& Message)
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
ccUser* tmpUser = bot->IsAuth(theClient);
|
||||
bot->MsgChanLog("LISTHOSTS %s\n",st.assemble(1).c_str());
|
||||
|
||||
tmpUser = bot->GetOper(st[1]);
|
||||
|
||||
if(!tmpUser)
|
||||
{
|
||||
bot->Notice(theClient,"%s isn't on my access list",st[1].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if(bot->listHosts(tmpUser,theClient))
|
||||
{
|
||||
bot->Notice(theClient,"End of hosts for user %s",st[1].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Error while accessing host list for %s",st[1].c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* LISTIGNORESCommand.cc
|
||||
* Shows all ignored masks
|
||||
*
|
||||
* 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: LISTIGNORESCommand.cc,v 1.10 2006/09/26 17:35:59 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: LISTIGNORESCommand.cc,v 1.10 2006/09/26 17:35:59 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
using std::endl ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool LISTIGNORESCommand::Exec( iClient* theClient, const string& )
|
||||
{
|
||||
bot->MsgChanLog("LISTIGNORES \n");
|
||||
bot->listIgnores(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* LISTOPERCHANSCommand.cc
|
||||
* List the channels thare are marked as ircops only
|
||||
*
|
||||
* 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: LISTOPERCHANSCommand.cc,v 1.9 2005/01/12 03:50:29 dan_karrels Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
#include <iomanip>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: LISTOPERCHANSCommand.cc,v 1.9 2005/01/12 03:50:29 dan_karrels Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
// listoperchans
|
||||
bool LISTOPERCHANSCommand::Exec( iClient* theClient, const string& )
|
||||
{
|
||||
|
||||
bot->Notice( theClient, "There are currently %d IRCoperator only channels",
|
||||
bot->operChan_size() ) ;
|
||||
|
||||
if( bot->operChan_empty() )
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
|
||||
string chanList = "" ;
|
||||
ccontrol::const_operChanIterator ptr = bot->operChan_begin() ;
|
||||
|
||||
while( ptr != bot->operChan_end() )
|
||||
{
|
||||
if( !chanList.empty() )
|
||||
{
|
||||
chanList += ", " ;
|
||||
chanList += *ptr ;
|
||||
}
|
||||
else
|
||||
{
|
||||
chanList = *ptr ;
|
||||
}
|
||||
++ptr ;
|
||||
}
|
||||
|
||||
bot->Notice( theClient, chanList ) ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* LISTUSERSCommand.cc
|
||||
* List the users who has access to the bot
|
||||
*
|
||||
* 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: REMCOMMANDCommand.cc,v 1.16 2009/06/13 06:43:34 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "ccUser.h"
|
||||
#include "misc.h"
|
||||
#include "gnuworld_config.h"
|
||||
#include "UserFilter.h"
|
||||
|
||||
namespace gnuworld {
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace uworld {
|
||||
|
||||
bool LISTUSERSCommand::Exec(iClient* theClient, const string& Message) {
|
||||
StringTokenizer st(Message);
|
||||
UserFilterComposite filters;
|
||||
ByLevelsUserFilter levelsFilter;
|
||||
bool wantedLevels = false;
|
||||
unsigned int pos = 1;
|
||||
while(pos < st.size()) {
|
||||
if(!strcmp(st[pos].c_str(),"-l")) {
|
||||
pos++;
|
||||
if(pos == st.size()) {
|
||||
bot->Notice(theClient,"-l option must get the level of the oper to show");
|
||||
return false;
|
||||
}
|
||||
int level = bot->strToLevel(st[pos++]);
|
||||
if(level < 0) {
|
||||
bot->Notice(theClient,"invalid oper level %s, valid options are: coder/smt/admin/oper/uhs",st[pos].c_str());
|
||||
return false;
|
||||
}
|
||||
wantedLevels = true;
|
||||
levelsFilter.addLevel(level);
|
||||
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
|
||||
if(wantedLevels) {
|
||||
filters.addFilter(&levelsFilter);
|
||||
}
|
||||
ccUser* user;
|
||||
ccontrol::usersConstIterator uItr = bot->usersMap_begin();
|
||||
int count = 0;
|
||||
stringstream sstr;
|
||||
for (; uItr != bot->usersMap_end(); uItr++) {
|
||||
user = uItr->second;
|
||||
|
||||
if(filters.filter(user)) {
|
||||
if(sstr.str().size() > 0) {
|
||||
sstr << ",";
|
||||
}
|
||||
sstr << "User: " << user->getUserName() << " Level: " << bot->levelToStr(user->getType());
|
||||
count ++;
|
||||
if(count % 2 == 0) {
|
||||
bot->Notice(theClient,"%s",sstr.str().c_str());
|
||||
sstr.str("");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!sstr.str().empty()) {
|
||||
bot->Notice(theClient, "%s", sstr.str().c_str());
|
||||
}
|
||||
|
||||
bot->Notice(theClient,"Finished listing %d users",count);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* LOGINCommand.cc
|
||||
* Authenticates you with the bot
|
||||
*
|
||||
* 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: LOGINCommand.cc,v 1.32 2009/07/25 18:12:34 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "Network.h"
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "md5hash.h"
|
||||
#include "ccUser.h"
|
||||
#include "ip.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: LOGINCommand.cc,v 1.32 2009/07/25 18:12:34 hidden1 Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
using std::endl ;
|
||||
using std::ends ;
|
||||
using std::stringstream ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool LOGINCommand::Exec( iClient* theClient, const string& Message)
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if( st.size() < 3 )
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
//Try fetching the user authenticate entry
|
||||
ccUser* theUser = bot->IsAuth(theClient);
|
||||
if (theUser)
|
||||
{
|
||||
//Dont let him authenticate under a new name (for now)
|
||||
bot->Notice(theClient, "You are already authenticated! See DEAUTH command.");
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the user record, confirm authorisation and attach the record to this client.
|
||||
*/
|
||||
iServer* targetServer = Network->findServer( theClient->getIntYY() ) ;
|
||||
if( NULL == targetServer )
|
||||
{
|
||||
elog << "LOGINCommand> Unable to find server: "
|
||||
<< theClient->getIntYY() << endl ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
theUser = bot->GetOper(st[1]);
|
||||
if (!theUser)
|
||||
{
|
||||
|
||||
bot->MsgChanLog("[FAILED LOGIN] %s - Bad Username: %s (%s)\n",
|
||||
theClient->getRealNickUserHost().c_str(),
|
||||
st[1].c_str(),
|
||||
targetServer->getName().c_str());
|
||||
if(theClient->isOper())
|
||||
bot->Notice(theClient, "FALSE LOGIN, DENIED");
|
||||
bot->addLogin(theClient);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Check if the user need to be operd to login
|
||||
if((!theClient->isOper()) && (theUser->getNeedOp()))
|
||||
|
||||
{
|
||||
bot->MsgChanLog("[FAILED LOGIN] %s - Not Oper'd\n",theClient->getRealNickUserHost().c_str());
|
||||
bot->addLogin(theClient);
|
||||
return false;
|
||||
}
|
||||
//Check if the users mask is in his access list
|
||||
if((!bot->UserGotMask(theUser,theClient->getRealNickUserHost()))
|
||||
&&(!bot->UserGotMask( theUser,theClient->getNickName() + "!" + theClient->getUserName() + "@" + xIP(theClient->getIP()).GetNumericIP())))
|
||||
{
|
||||
bot->MsgChanLog("[FAILED LOGIN] %s - No HostMask\n",theClient->getRealNickUserHost().c_str());
|
||||
if(theClient->isOper())
|
||||
bot->Notice(theClient, "FALSE LOGIN, DENIED");
|
||||
bot->addLogin(theClient);
|
||||
return false;
|
||||
}
|
||||
|
||||
md5 hash; // MD5 hash algorithm object.
|
||||
md5Digest digest; // MD5Digest algorithm object.
|
||||
stringstream output;
|
||||
string salt = theUser->getPassword().substr(0, 8);
|
||||
string md5Part = theUser->getPassword().substr(8);
|
||||
string guess = salt + st.assemble(2);
|
||||
|
||||
// Build a MD5 hash based on our salt + the guessed password.
|
||||
hash.update( (unsigned char *)guess.c_str(), strlen( guess.c_str() ));
|
||||
hash.report( digest );
|
||||
|
||||
// Convert the digest into an array of int's to output as hex for
|
||||
// comparison with the passwords generated by PHP.
|
||||
int data[ MD5_DIGEST_LENGTH ];
|
||||
int ii;
|
||||
for( ii = 0; ii < MD5_DIGEST_LENGTH; ii++ )
|
||||
{
|
||||
data[ii] = digest[ii];
|
||||
}
|
||||
output << hex;
|
||||
output.fill('0');
|
||||
for( ii = 0; ii < MD5_DIGEST_LENGTH; ii++ ) {
|
||||
output << setw(2) << data[ii];
|
||||
}
|
||||
output << ends;
|
||||
|
||||
if (md5Part != output.str().c_str()) // If the MD5 hash's don't match..
|
||||
{
|
||||
bot->MsgChanLog("[FAILED LOGIN] %s - Bad Password (%s)\n",theClient->getRealNickUserHost().c_str(), targetServer->getName().c_str());
|
||||
if(theClient->isOper())
|
||||
bot->Notice(theClient, "FALSE LOGIN, DENIED");
|
||||
bot->addLogin(theClient);
|
||||
return false;
|
||||
}
|
||||
//Ok the password match , prepare the ccUser data
|
||||
if(theUser->getClient()) //there is already a user authenticated under that nick
|
||||
{
|
||||
const iClient *tClient = theUser->getClient();
|
||||
bot->Notice(tClient,"You have just been deauthenticated");
|
||||
bot->MsgChanLog("Login conflict for user %s from %s and %s (%s)\n",
|
||||
st[1].c_str(),theClient->getNickName().c_str(),
|
||||
tClient->getNickName().c_str(), targetServer->getName().c_str());
|
||||
bot->deAuthUser(theUser);
|
||||
}
|
||||
theUser->setUserName(st[1]);
|
||||
theUser->setNumeric(theClient->getCharYYXXX());
|
||||
//Try creating an authentication entry for the user
|
||||
if(bot->AuthUser(theUser,theClient))
|
||||
if(!(bot->isSuspended(theUser)))
|
||||
bot->Notice(theClient, "Authentication successful as %s! ",theUser->getUserName().c_str());
|
||||
else
|
||||
bot->Notice(theClient, "Authentication successful as %s, "
|
||||
"however you are currently suspended ",
|
||||
theUser->getUserName().c_str());
|
||||
else if(theClient->isOper())
|
||||
bot->Notice(theClient, "Error in authentication as %s",theUser->getUserName().c_str());
|
||||
bot->MsgChanLog("(%s) - %s: AUTHENTICATED (%s)\n",theUser->getUserName().c_str(),
|
||||
theClient->getRealNickUserHost().c_str(), targetServer->getName().c_str());
|
||||
/* record their connection timestamp + numeric */
|
||||
theUser->setLastAuthTS(theClient->getConnectTime());
|
||||
theUser->setLastAuthNumeric(theClient->getCharYYXXX());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* MAXUSERSCommand.cc
|
||||
* Shows the maximum number of online users ever recorded
|
||||
*
|
||||
* 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: MAXUSERSCommand.cc,v 1.7 2006/09/26 17:35:59 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "StringTokenizer.h"
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "ccontrol_generic.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: MAXUSERSCommand.cc,v 1.7 2006/09/26 17:35:59 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool MAXUSERSCommand::Exec( iClient* theClient, const string& )
|
||||
{
|
||||
bot->Notice(theClient,"Current number of users is: %d",bot->getCurUsers());
|
||||
bot->Notice(theClient,"Maximum number of users ever recorded is: %d",bot->getMaxUsers());
|
||||
bot->Notice(theClient,"Recorded on %s (%s ago)",bot->convertToAscTime(bot->getDateMax()),
|
||||
Ago(bot->getDateMax()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace gnuworld
|
||||
@@ -0,0 +1,390 @@
|
||||
/**
|
||||
* MODECommand.cc
|
||||
* Changes a channel mode
|
||||
*
|
||||
* 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: MODECommand.cc,v 1.22 2006/09/26 17:35:59 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "Constants.h"
|
||||
#include "ccBadChannel.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: MODECommand.cc,v 1.22 2006/09/26 17:35:59 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
// LDd P AIAAA :mode #krushnet -o DawgSleep
|
||||
// mode channel modes
|
||||
bool MODECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 3 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if(st[1].size() > channel::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Channel can't be more than %d characters",
|
||||
channel::MaxName);
|
||||
}
|
||||
|
||||
Channel* theChan = Network->findChannel( st[ 1 ] ) ;
|
||||
if( NULL == theChan )
|
||||
{
|
||||
bot->Notice( theClient, "Unable to find channel '%s'\n",
|
||||
st[ 1 ].c_str() ) ;
|
||||
return true ;
|
||||
}
|
||||
bot->MsgChanLog("MODE %s\n",st.assemble(1).c_str());
|
||||
|
||||
ccBadChannel* Chan = bot->isBadChannel(st[1]);
|
||||
if(Chan)
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, but you can't change modes in "
|
||||
"this channel because: %s",
|
||||
Chan->getReason().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// This has been changed to use xServer::Mode(), which will from now
|
||||
// on perform the bulk of the heavy lifting with setting modes.
|
||||
// Note that this will have the negative effect of not telling
|
||||
// the requesting client of this command why something did not succeed.
|
||||
bot->Mode( theChan, st.assemble( 2 ), string(), true ) ;
|
||||
return true ;
|
||||
|
||||
/*
|
||||
|
||||
// Define mode to be any mode, such as +abc-def
|
||||
// Define argument to to be any argument to a particular mode: -o nickArgument
|
||||
|
||||
// index into the st object, location of next mode
|
||||
StringTokenizer::size_type modePos = 2 ;
|
||||
|
||||
// index into the st object, location of next argument
|
||||
StringTokenizer::size_type argPos = 3 ;
|
||||
|
||||
// To be used later
|
||||
iClient* Target = 0 ;
|
||||
ChannelUser* ChanUser = NULL;
|
||||
// Store the command to be sent to the network in two strings
|
||||
// modeString holds the updated modes
|
||||
string modeString = "" ;
|
||||
|
||||
// argString holds the updated arguments, delimited by space (' ')
|
||||
string argString = "" ;
|
||||
|
||||
// Continue while there are more modes to parse
|
||||
while( modePos < st.size() )
|
||||
{
|
||||
|
||||
// modePos could be equal to argPos if a previous iteration of
|
||||
// the while loop found one or more modes with arguments
|
||||
if( modePos == argPos )
|
||||
{
|
||||
argPos++ ;
|
||||
}
|
||||
|
||||
// This it the size of the increment to make to modePos.
|
||||
// This could be greater than 1 if there are more than one mode
|
||||
// arguments at st[ modePos ] that require arguments
|
||||
string::size_type modePosIncrement = 1 ;
|
||||
|
||||
// Keep track of the polarity of the mode change.
|
||||
bool plus = true ;
|
||||
bool Op = false;
|
||||
// Iterate through the characters of the mode at st[ modePos ]
|
||||
for( string::size_type charPos = 0 ; charPos < st[ modePos ].size() ; ++charPos )
|
||||
{
|
||||
switch( toupper(st[ modePos ][ charPos ]) )
|
||||
{
|
||||
case 'O':
|
||||
Op = true;
|
||||
case 'V':
|
||||
|
||||
// Make sure there is an argument for this mode
|
||||
if( argPos >= st.size() )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
// arg needs to be a nickname
|
||||
Target = Network->findNick( st[ argPos ] ) ;
|
||||
|
||||
// Is the argument a valid nickname?
|
||||
if( NULL == Target )
|
||||
{
|
||||
bot->Notice( theClient, "Unable to find '%s'\n",
|
||||
st[ argPos ].c_str() ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
// Make sure the user is in this particular channel
|
||||
if( NULL == (ChanUser = theChan->findUser( Target ) ))
|
||||
{
|
||||
bot->Notice( theClient, "User %s was not found "
|
||||
"on channel %s",
|
||||
st[ argPos ].c_str(),
|
||||
theChan->getName().c_str() ) ;
|
||||
return true ;
|
||||
}
|
||||
//Dont deop +k
|
||||
if((Target->getMode(iClient::MODE_SERVICES)) && (!plus))
|
||||
{
|
||||
Op = false;
|
||||
// Move to next argument
|
||||
argPos++ ;
|
||||
|
||||
// Make sure modePos skips over this argument
|
||||
modePosIncrement++ ;
|
||||
|
||||
continue;
|
||||
}
|
||||
if(plus)
|
||||
if(Op)
|
||||
ChanUser->setModeO() ;
|
||||
else
|
||||
ChanUser->setModeV() ;
|
||||
else
|
||||
|
||||
if(Op)
|
||||
ChanUser->removeModeO() ;
|
||||
else
|
||||
ChanUser->removeModeV() ;
|
||||
// Add the mode to the modeString
|
||||
modeString += st[ modePos ][ charPos ] ;
|
||||
|
||||
// Add this nick's numeric (plus a space) to the end
|
||||
// of the current argument string
|
||||
argString += Target->getCharYYXXX() + ' ' ;
|
||||
|
||||
// Move to next argument
|
||||
argPos++ ;
|
||||
|
||||
// Make sure modePos skips over this argument
|
||||
modePosIncrement++ ;
|
||||
|
||||
//Make sure to turn off op bool for next mode
|
||||
Op = false;
|
||||
|
||||
break ;
|
||||
case 'B':
|
||||
// Each of these modes needs an argument
|
||||
if( argPos >= st.size() )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
// Add this mode to the current modeString
|
||||
modeString += st[ modePos ][ charPos ] ;
|
||||
|
||||
// Add this argument to the current argument string
|
||||
argString += st[ argPos ] + ' ' ;
|
||||
if(!plus)
|
||||
theChan->removeBan(st[ argPos ]);
|
||||
else
|
||||
theChan->setBan(st[ argPos ]);
|
||||
// Mode to next argument
|
||||
argPos++ ;
|
||||
|
||||
// Make sure modePos skips over this argument
|
||||
modePosIncrement++ ;
|
||||
|
||||
break ;
|
||||
|
||||
case 'K':
|
||||
// Each of these modes needs an argument
|
||||
if( argPos >= st.size() )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
// Add this mode to the current modeString
|
||||
modeString += st[ modePos ][ charPos ] ;
|
||||
|
||||
// Add this argument to the current argument string
|
||||
argString += st[ argPos ] + ' ' ;
|
||||
|
||||
if(plus)
|
||||
{
|
||||
theChan->setMode(Channel::MODE_K);
|
||||
theChan->setKey(st [ argPos ]);
|
||||
}
|
||||
else
|
||||
{
|
||||
theChan->removeMode(Channel::MODE_K);
|
||||
theChan->setKey("");
|
||||
}
|
||||
|
||||
// Mode to next argument
|
||||
argPos++ ;
|
||||
|
||||
// Make sure modePos skips over this argument
|
||||
modePosIncrement++ ;
|
||||
|
||||
break ;
|
||||
case 'L':
|
||||
|
||||
// Mode -l requires no argument
|
||||
if( !plus )
|
||||
{
|
||||
// No args needed
|
||||
modeString += st[ modePos ][ charPos ] ;
|
||||
theChan->removeMode(Channel::MODE_L);
|
||||
break ;
|
||||
}
|
||||
|
||||
// Else, the user has specified +l, need an
|
||||
// argument.
|
||||
|
||||
// Each of these modes needs an argument
|
||||
if( argPos >= st.size() )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
theChan->setMode(Channel::MODE_L);
|
||||
|
||||
// Add this mode to the current modeString
|
||||
modeString += st[ modePos ][ charPos ] ;
|
||||
|
||||
// Add this argument to the current argument string
|
||||
argString += st[ argPos ] + ' ' ;
|
||||
|
||||
// Mode to next argument
|
||||
argPos++ ;
|
||||
|
||||
// Make sure modePos skips over this argument
|
||||
modePosIncrement++ ;
|
||||
|
||||
break ;
|
||||
case 'I': //Invite?
|
||||
if(!plus)
|
||||
theChan->removeMode(Channel::MODE_I);
|
||||
else
|
||||
theChan->setMode(Channel::MODE_I);
|
||||
modeString += st[ modePos ][ charPos ] ;
|
||||
|
||||
break;
|
||||
case 'P': //Private?
|
||||
if(!plus)
|
||||
theChan->removeMode(Channel::MODE_P);
|
||||
else
|
||||
theChan->setMode(Channel::MODE_P);
|
||||
modeString += st[ modePos ][ charPos ] ;
|
||||
break;
|
||||
case 'S': //Secret?
|
||||
if(!plus)
|
||||
theChan->removeMode(Channel::MODE_S);
|
||||
else
|
||||
theChan->setMode(Channel::MODE_S);
|
||||
|
||||
modeString += st[ modePos ][ charPos ] ;
|
||||
|
||||
break;
|
||||
case 'M': //Moderated?
|
||||
if(!plus)
|
||||
theChan->removeMode(Channel::MODE_M);
|
||||
else
|
||||
theChan->setMode(Channel::MODE_M);
|
||||
|
||||
modeString += st[ modePos ][ charPos ] ;
|
||||
|
||||
break;
|
||||
case 'N': //No External Messages?
|
||||
if(!plus)
|
||||
theChan->removeMode(Channel::MODE_N);
|
||||
else
|
||||
theChan->setMode(Channel::MODE_N);
|
||||
|
||||
modeString += st[ modePos ][ charPos ] ;
|
||||
|
||||
break;
|
||||
case 'T': //Topic?
|
||||
if(!plus)
|
||||
theChan->removeMode(Channel::MODE_T);
|
||||
else
|
||||
theChan->setMode(Channel::MODE_T);
|
||||
modeString += st[ modePos ][ charPos ] ;
|
||||
break;
|
||||
case '+':
|
||||
if( plus )
|
||||
{
|
||||
// Already plus
|
||||
break ;
|
||||
}
|
||||
plus = true ;
|
||||
modeString += st[ modePos ][ charPos ] ;
|
||||
break ;
|
||||
case '-':
|
||||
if( !plus )
|
||||
{
|
||||
// Already minus
|
||||
break ;
|
||||
}
|
||||
plus = false ;
|
||||
modeString += st[ modePos ][ charPos ] ;
|
||||
break ;
|
||||
default:
|
||||
// Requires no arguments, just add the mode
|
||||
// to the modeString
|
||||
modeString += st[ modePos ][ charPos ] ;
|
||||
break ;
|
||||
|
||||
} // switch()
|
||||
} // for()
|
||||
|
||||
modePos += modePosIncrement ;
|
||||
} // while( modePos < st.size() )
|
||||
|
||||
bot->ModeAsServer( theChan, modeString + ' ' + argString ) ;
|
||||
*/
|
||||
|
||||
// Update internal tables.
|
||||
// This is a cheat, but it makes things so much easier :)
|
||||
// TODO
|
||||
//theChan->OnModeChange( theClient->getCharYYXXX(), modeString, argString
|
||||
//) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* MODERATECommand.cc
|
||||
* Cause the bot to moderate 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: MODERATECommand.cc,v 1.16 2006/09/26 17:35:59 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "Constants.h"
|
||||
#include "ccBadChannel.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: MODERATECommand.cc,v 1.16 2006/09/26 17:35:59 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool MODERATECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if(st[1].size() > channel::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Channel name can't be more than %d characters",
|
||||
channel::MaxName);
|
||||
return false;
|
||||
}
|
||||
Channel* theChan = Network->findChannel( st[ 1 ] ) ;
|
||||
if( NULL == theChan )
|
||||
{
|
||||
bot->Notice( theClient, "Unable to find channel %s\n",
|
||||
st[ 1 ].c_str() ) ;
|
||||
return true ;
|
||||
}
|
||||
bot->MsgChanLog("MODERATE %s\n",st.assemble(1).c_str());
|
||||
|
||||
ccBadChannel* Chan = bot->isBadChannel(st[1]);
|
||||
if(Chan)
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, but you can't change modes in "
|
||||
"this channel because: %s",
|
||||
Chan->getReason().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if(theChan->getMode(Channel::MODE_M))
|
||||
{
|
||||
bot->Notice( theClient,"Channel %s is already moderated",st[ 1 ].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
//theChan->setMode(Channel::MODE_M);
|
||||
bot->Mode( theChan, "+m", string(), true );
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
@@ -0,0 +1,476 @@
|
||||
/**
|
||||
* MODUSERCommand.cc
|
||||
* Modify an oper database entry
|
||||
*
|
||||
* 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: MODUSERCommand.cc,v 1.28 2009/08/28 18:14:44 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "ccUser.h"
|
||||
#include "misc.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: MODUSERCommand.cc,v 1.28 2009/08/28 18:14:44 hidden1 Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool MODUSERCommand::Exec( iClient* theClient, const string& Message)
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if(st.size() < 2)
|
||||
{
|
||||
Usage(theClient);
|
||||
return false;
|
||||
}
|
||||
//Fetch the oper data base entry
|
||||
if(st[1].size() > 64)
|
||||
{
|
||||
bot->Notice(theClient,"Oper name can't be more than 64 characters");
|
||||
return false;
|
||||
}
|
||||
|
||||
ccUser* tmpUser = bot->GetOper(st[1]);
|
||||
|
||||
if(!tmpUser)
|
||||
{
|
||||
bot->Notice(theClient,"%s isn't on my access list",st[1].c_str());
|
||||
return false;
|
||||
}
|
||||
//Check if the user got a higher or equal flags than the one he's trying to edit
|
||||
ccUser* tmpAuth = bot->IsAuth(theClient);
|
||||
if(!tmpAuth)
|
||||
{ //we should never get here
|
||||
return false;
|
||||
}
|
||||
bot->MsgChanLog("MODUSER %s\n",st[1].c_str());
|
||||
|
||||
unsigned int AdFlag = tmpAuth->getType(); //Get the admin flag
|
||||
unsigned int OpFlag = tmpUser->getType(); //Get the oper flag
|
||||
bool Admin = (AdFlag < operLevel::SMTLEVEL);
|
||||
bool Same = (tmpUser->getID() == tmpAuth->getID());
|
||||
|
||||
if((Admin) && (AdFlag <= OpFlag) && (!Same))
|
||||
{
|
||||
bot->Notice(theClient,"You can't modify a user who has a higher or "
|
||||
"equal level to your own.");
|
||||
return false;
|
||||
}
|
||||
else if(AdFlag < OpFlag)
|
||||
{
|
||||
bot->Notice(theClient,"You can't modify a user who has a higher level "
|
||||
"than your own.");
|
||||
return false;
|
||||
}
|
||||
if((Admin) && (strcasecmp(tmpAuth->getServer().c_str(),tmpUser->getServer().c_str())))
|
||||
{
|
||||
bot->Notice(theClient,"You can only modify a user who is associated to "
|
||||
"the same server as you.");
|
||||
return false;
|
||||
}
|
||||
unsigned int pos = 2;
|
||||
while(pos < st.size())
|
||||
{
|
||||
if(!strcasecmp(st[pos],"-p")) //Trying to change the password ?
|
||||
{
|
||||
if((pos + 1) >= st.size())
|
||||
{
|
||||
bot->Notice(theClient,"-p option must get new password");
|
||||
return false;
|
||||
}
|
||||
unsigned int passStat = bot->checkPassword(st[pos+1],tmpUser);
|
||||
switch(passStat)
|
||||
{
|
||||
case password::TOO_SHORT:
|
||||
bot->Notice(theClient,"Password must be atleast %d "
|
||||
"characters",
|
||||
password::MIN_SIZE);
|
||||
pos+=2;
|
||||
break;
|
||||
case password::LIKE_UNAME:
|
||||
bot->Notice(theClient,"Password can't be the same as the username");
|
||||
pos+=2;
|
||||
break;
|
||||
case password::PASS_OK:
|
||||
{
|
||||
tmpUser->setPassword(bot->CryptPass(st[pos+1]));
|
||||
tmpUser->setLast_Updated_By(theClient->getRealNickUserHost());
|
||||
tmpUser->setPassChangeTS(::time(0));
|
||||
if(tmpUser->Update())
|
||||
{
|
||||
bot->Notice(theClient,"Password for %s has been changed to %s",
|
||||
st[1].c_str(),st[pos+1].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Error while changing password for %s",st[1].c_str());
|
||||
}
|
||||
pos+=2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-ah")) //Trying to add a new host ?
|
||||
{
|
||||
if((Same) && (AdFlag < operLevel::CODERLEVEL))
|
||||
{
|
||||
bot->Notice(theClient,"You can't add yourself another host");
|
||||
pos+=2;
|
||||
continue;
|
||||
}
|
||||
|
||||
if((pos + 1) >= st.size())
|
||||
{
|
||||
bot->Notice(theClient,"-ah option must get new hostmask");
|
||||
return false;
|
||||
}
|
||||
if(st[pos + 1].size() > 128)
|
||||
{
|
||||
bot->Notice(theClient,"Hostname can't be more than 128 characters");
|
||||
return false;
|
||||
}
|
||||
if(!bot->validUserMask(st[pos+1]))
|
||||
{
|
||||
bot->Notice(theClient,"Mask '%s' is not a valid mask in the form of *!*@*",
|
||||
st[pos+1].c_str());
|
||||
}
|
||||
else if(bot->UserGotHost(tmpUser,st[pos+1]))
|
||||
{
|
||||
bot->Notice(theClient,"'%s' already has the host (%s) listed.",
|
||||
st[1].c_str(),st[pos+1].c_str());
|
||||
}
|
||||
else if(bot->AddHost(tmpUser,st[pos+1]))
|
||||
{
|
||||
bot->Notice(theClient,"Mask %s added for %s",st[pos+1].c_str(),st[1].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Error while adding the mask (%s) for %s",
|
||||
st[pos+1].c_str(),st[1].c_str());
|
||||
}
|
||||
pos += 2;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-dh")) //Trying to delete an host ?
|
||||
{
|
||||
if((pos + 1) >= st.size())
|
||||
{
|
||||
bot->Notice(theClient,"-dh option must get a host mask");
|
||||
return false;
|
||||
}
|
||||
if(st[pos + 1].size() > 128)
|
||||
{
|
||||
bot->Notice(theClient,"Hostname can't be more than 128 characters");
|
||||
return false;
|
||||
}
|
||||
if(!bot->UserGotHost(tmpUser,bot->removeSqlChars(st[pos+1])))
|
||||
{
|
||||
bot->Notice(theClient,"%s doesn't have the host '%s' in my access list",
|
||||
st[1].c_str(),st[pos+1].c_str());
|
||||
}
|
||||
else if(bot->DelHost(tmpUser,bot->removeSqlChars(st[pos+1])))
|
||||
{
|
||||
bot->Notice(theClient,"Mask '%s' was deleted from %s's access list",
|
||||
st[pos+1].c_str(),st[1].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Error while deleting mask '%s' from %s's access list",
|
||||
st[pos+1].c_str(),st[1].c_str());
|
||||
}
|
||||
pos += 2;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-gl")) //Trying to toggle the get of logs
|
||||
{
|
||||
if((pos + 1) >= st.size())
|
||||
{
|
||||
bot->Notice(theClient,"-gl option must get on/off");
|
||||
return false;
|
||||
}
|
||||
if(!strcasecmp(st[pos+1],"on"))
|
||||
{
|
||||
// Only a smt+ can set getlogs to on for an oper
|
||||
if ((OpFlag < operLevel::ADMINLEVEL) && (AdFlag < operLevel::SMTLEVEL))
|
||||
{
|
||||
bot->Notice(theClient,"-gl can only be set for ADMINS+");
|
||||
return false;
|
||||
}
|
||||
tmpUser->setLogs(true);
|
||||
bot->Notice(theClient,"getLogs have been turned on for %s",st[1].c_str());
|
||||
}
|
||||
else if(!strcasecmp(st[pos+1],"off"))
|
||||
{
|
||||
tmpUser->setLogs(false);
|
||||
bot->Notice(theClient,"getLogs have been turned off for %s",st[1].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"unknown option %s for -gl must be on/off",st[pos+1].c_str());
|
||||
return false;
|
||||
}
|
||||
tmpUser->setLast_Updated_By(bot->removeSqlChars(theClient->getRealNickUserHost()));
|
||||
tmpUser->Update();
|
||||
pos += 2;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-mt")) //Trying to change the message type
|
||||
{
|
||||
if((pos + 1) >= st.size())
|
||||
{
|
||||
bot->Notice(theClient,"-mt option must get message type");
|
||||
return false;
|
||||
}
|
||||
if((!strcasecmp(st[pos+1],"N")) || (!strcasecmp(st[pos+1],"NOTICE")))
|
||||
{
|
||||
tmpUser->setNotice(true);
|
||||
bot->Notice(theClient,"%s will now get NOTICES",st[1].c_str());
|
||||
}
|
||||
else if((!strcasecmp(st[pos+1],"M")) || (!strcasecmp(st[pos+1],"MESSAGE")))
|
||||
{
|
||||
tmpUser->setNotice(false);
|
||||
bot->Notice(theClient,"%s will now get MESSAGES",st[1].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"unknown option %s for -mt must be n/m/notice/message",st[pos+1].c_str());
|
||||
return false;
|
||||
}
|
||||
tmpUser->setLast_Updated_By(bot->removeSqlChars(theClient->getRealNickUserHost()));
|
||||
tmpUser->Update();
|
||||
pos += 2;
|
||||
}
|
||||
|
||||
else if(!strcasecmp(st[pos],"-glag")) //Trying to toggle the get of lag reports
|
||||
{
|
||||
if((pos + 1) >= st.size())
|
||||
{
|
||||
bot->Notice(theClient,"-glag option must get on/off");
|
||||
return false;
|
||||
}
|
||||
if(!strcasecmp(st[pos+1],"on"))
|
||||
{
|
||||
tmpUser->setLag(true);
|
||||
bot->Notice(theClient,"getLag has been turned on for %s",st[1].c_str());
|
||||
}
|
||||
else if(!strcasecmp(st[pos+1],"off"))
|
||||
{
|
||||
tmpUser->setLag(false);
|
||||
bot->Notice(theClient,"getLag has been turned off for %s",st[1].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"unknown option %s for -glag must be on/off",st[pos+1].c_str());
|
||||
return false;
|
||||
}
|
||||
tmpUser->setLast_Updated_By(bot->removeSqlChars(theClient->getRealNickUserHost()));
|
||||
tmpUser->Update();
|
||||
pos += 2;
|
||||
}
|
||||
|
||||
else if(!strcasecmp(st[pos],"-s")) //Trying to change the user server
|
||||
{
|
||||
if((pos + 1) >= st.size())
|
||||
{
|
||||
bot->Notice(theClient,"-s option must get a server");
|
||||
return false;
|
||||
}
|
||||
if(Admin)
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, only SMT+ users can change an admins' server");
|
||||
return false;
|
||||
}
|
||||
if(st[pos + 1].size() > server::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Server name can't be more than 128 characters");
|
||||
return false;
|
||||
}
|
||||
string SName = bot->expandDbServer(st[pos+1]);
|
||||
if(!strcasecmp(SName,""))
|
||||
{
|
||||
bot->Notice(theClient,"I can't see a server in the database that matches %s",
|
||||
st[pos+1].c_str());
|
||||
return false;
|
||||
}
|
||||
if(!strcasecmp(tmpUser->getServer(),SName))
|
||||
{
|
||||
bot->Notice(theClient,"%s already is associated with %s",SName.c_str(),SName.c_str());
|
||||
pos+=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpUser->setServer(bot->removeSqlChars(SName));
|
||||
tmpUser->setLast_Updated_By(bot->removeSqlChars(theClient->getRealNickUserHost()));
|
||||
if(tmpUser->Update())
|
||||
{
|
||||
bot->Notice(theClient,"%s has been associated with %s",st[1].c_str(),SName.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Error while associating %s with %s",st[1].c_str(),SName.c_str());
|
||||
return false;
|
||||
}
|
||||
pos += 2;
|
||||
}
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-op")) //Trying to toggle needop
|
||||
{
|
||||
if(Admin)
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, the needop flag is required.");
|
||||
pos+=2;
|
||||
continue;
|
||||
}
|
||||
if((pos + 1) >= st.size())
|
||||
{
|
||||
bot->Notice(theClient,"-op option must get on/off");
|
||||
return false;
|
||||
}
|
||||
if(!strcasecmp(st[pos+1],"on"))
|
||||
{
|
||||
tmpUser->setNeedOp(true);
|
||||
bot->Notice(theClient,"NeedOp has been turned on for %s",st[1].c_str());
|
||||
}
|
||||
else if(!strcasecmp(st[pos+1],"off"))
|
||||
{
|
||||
tmpUser->setNeedOp(false);
|
||||
bot->Notice(theClient,"NeedOp has been turned off for %s",st[1].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"unknown option %s for -no must be on/off",st[pos+1].c_str());
|
||||
}
|
||||
tmpUser->setLast_Updated_By(bot->removeSqlChars(theClient->getRealNickUserHost()));
|
||||
tmpUser->Update();
|
||||
pos += 2;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-ua")) //Trying to update the access?
|
||||
{
|
||||
if((AdFlag < operLevel::CODERLEVEL) && (AdFlag <= OpFlag))
|
||||
{
|
||||
bot->Notice(theClient,"You can't update an access for a user who has a higher "
|
||||
"or equal level to your own.");
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpUser->updateAccessFromFlags();
|
||||
tmpUser->setLast_Updated_By(bot->removeSqlChars(theClient->getRealNickUserHost()));
|
||||
if(tmpUser->Update())
|
||||
{
|
||||
bot->Notice(theClient,"Successfully updated access level for %s.",st[1].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Error while updating access level for %s.",st[1].c_str());
|
||||
}
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-uf")) //Trying to update the user flags
|
||||
{
|
||||
if((pos + 1) >= st.size())
|
||||
{
|
||||
bot->Notice(theClient,"-uf option must get an argument.");
|
||||
return false;
|
||||
}
|
||||
unsigned int NewF;
|
||||
if(!strcasecmp(st[pos+1],"CODER"))
|
||||
{
|
||||
NewF = operLevel::CODERLEVEL;
|
||||
}
|
||||
else if(!strcasecmp(st[pos+1],"SMT"))
|
||||
{
|
||||
NewF = operLevel::SMTLEVEL;
|
||||
}
|
||||
else if(!strcasecmp(st[pos+1],"ADMIN"))
|
||||
{
|
||||
NewF = operLevel::ADMINLEVEL;
|
||||
}
|
||||
else if(!strcasecmp(st[pos+1],"OPER"))
|
||||
{
|
||||
NewF = operLevel::OPERLEVEL;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Bad option for -uf, must be CODER, SMT, ADMIN or OPER");
|
||||
NewF = 0;
|
||||
}
|
||||
if(NewF > 0)
|
||||
{
|
||||
if((AdFlag < operLevel::CODERLEVEL) && (AdFlag <= NewF))
|
||||
{
|
||||
bot->Notice(theClient,"You can't update the flags to a higher or equal "
|
||||
"level than your own.");
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpUser->setType(NewF);
|
||||
tmpUser->setLast_Updated_By(theClient->getRealNickUserHost());
|
||||
if(tmpUser->Update())
|
||||
{
|
||||
bot->Notice(theClient,"Successfully updated flags for %s.",st[1].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Error while updating flags for %s.",st[1].c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
pos+=2;
|
||||
}
|
||||
|
||||
else if(!strcasecmp(st[pos],"-e")) //Trying to change email
|
||||
{
|
||||
if((pos + 1) >= st.size())
|
||||
{
|
||||
bot->Notice(theClient,"-e option requires an e-mail address.");
|
||||
return false;
|
||||
}
|
||||
tmpUser->setEmail(bot->removeSqlChars(st[pos+1]));
|
||||
tmpUser->setLast_Updated_By(bot->removeSqlChars(theClient->getRealNickUserHost()));
|
||||
if(tmpUser->Update())
|
||||
{
|
||||
bot->Notice(theClient,"Successfully updated e-mail address for %s.",st[1].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Error while updating e-mail address for %s.",st[1].c_str());
|
||||
}
|
||||
pos+=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Unknown option %s",st[pos].c_str());
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
# "$Id: Makefile.am,v 1.59 2009/06/09 05:55:55 hidden1 Exp $"
|
||||
|
||||
lib_LTLIBRARIES = libccontrol.la
|
||||
libccontrol_la_SOURCES = ccontrol.cc \
|
||||
CControlCommands.cc \
|
||||
ADDCOMMANDCommand.cc \
|
||||
ADDOPERCHANCommand.cc \
|
||||
ADDSERVERCommand.cc \
|
||||
ADDUSERCommand.cc \
|
||||
ccBadChannel.cc \
|
||||
ccException.cc \
|
||||
ccFloodData.cc \
|
||||
ccGline.cc \
|
||||
ccLog.cc \
|
||||
ccServer.cc \
|
||||
ccUser.cc \
|
||||
ccontrol_generic.cc \
|
||||
CHANINFOCommand.cc \
|
||||
CHECKNETCommand.cc \
|
||||
CLEARCHANCommand.cc \
|
||||
COMMANDSCommand.cc \
|
||||
CONFIGCommand.cc \
|
||||
DEAUTHCommand.cc \
|
||||
DEOPCommand.cc \
|
||||
EXCEPTIONCommand.cc \
|
||||
FORCECHANGLINECommand.cc \
|
||||
FORCEGLINECommand.cc \
|
||||
GCHANCommand.cc \
|
||||
GLINECommand.cc \
|
||||
HELPCommand.cc \
|
||||
INVITECommand.cc \
|
||||
JUPECommand.cc \
|
||||
KICKCommand.cc \
|
||||
LASTCOMCommand.cc \
|
||||
LEARNNETCommand.cc \
|
||||
LISTCommand.cc \
|
||||
LISTHOSTSCommand.cc \
|
||||
LISTIGNORESCommand.cc \
|
||||
LISTOPERCHANSCommand.cc \
|
||||
LISTUSERSCommand.cc \
|
||||
LOGINCommand.cc \
|
||||
MAXUSERSCommand.cc \
|
||||
MODECommand.cc \
|
||||
MODERATECommand.cc \
|
||||
MODUSERCommand.cc \
|
||||
NEWPASSCommand.cc \
|
||||
NOMODECommand.cc \
|
||||
OPCommand.cc \
|
||||
REMGCHANCommand.cc \
|
||||
REMGLINECommand.cc \
|
||||
REMOPERCHANCommand.cc \
|
||||
REMCOMMANDCommand.cc \
|
||||
REMOVEIGNORECommand.cc \
|
||||
REMSERVERCommand.cc \
|
||||
REMSGLINECommand.cc \
|
||||
REMUSERCommand.cc \
|
||||
REOPCommand.cc \
|
||||
SAYCommand.cc \
|
||||
SCANCommand.cc \
|
||||
SCANGLINECommand.cc \
|
||||
SCHANGLINECommand.cc \
|
||||
SGLINECommand.cc \
|
||||
SHUTDOWNCommand.cc \
|
||||
STATUSCommand.cc \
|
||||
SUSPENDCommand.cc \
|
||||
TRANSLATECommand.cc \
|
||||
UNJUPECommand.cc \
|
||||
UNMODERATECommand.cc \
|
||||
UNSUSPENDCommand.cc \
|
||||
USERINFOCommand.cc \
|
||||
WHOISCommand.cc \
|
||||
ANNOUNCECommand.cc
|
||||
|
||||
libccontrol_la_CXXFLAGS = -I$(top_srcdir)/db -I${top_srcdir}/include \
|
||||
-I${top_srcdir}/libgnuworld
|
||||
libccontrol_la_LDFLAGS = -module -export-dynamic -L$(top_builddir)/db \
|
||||
-lgnuworldDB
|
||||
|
||||
EXTRA_DIST = ccBadChannel.h \
|
||||
ccException.h \
|
||||
ccFloodData.h \
|
||||
ccGline.h \
|
||||
ccLog.h \
|
||||
CControlCommands.h \
|
||||
ccontrol.h \
|
||||
ccServer.h \
|
||||
ccUserData.h \
|
||||
ccUser.h \
|
||||
ccontrol_generic.h \
|
||||
CommandsDec.h \
|
||||
commLevels.h \
|
||||
Constants.h \
|
||||
README
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* NEWPASSCommand.cc
|
||||
* Changes the user password
|
||||
*
|
||||
* 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: NEWPASSCommand.cc,v 1.24 2009/07/25 18:12:34 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: NEWPASSCommand.cc,v 1.24 2009/07/25 18:12:34 hidden1 Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool NEWPASSCommand::Exec( iClient* theClient, const string& Message)
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
//Fetch the user authentication entry
|
||||
ccUser *theUser = bot->IsAuth(theClient);
|
||||
|
||||
if(!theUser)
|
||||
{
|
||||
bot->Notice(theClient,"You have to be logged in to use this command");
|
||||
return false;
|
||||
}
|
||||
unsigned int passRet = bot->checkPassword(st[1],theUser);
|
||||
switch(passRet)
|
||||
{
|
||||
case password::TOO_SHORT:
|
||||
bot->Notice(theClient,"Password must be at least %d characters",
|
||||
password::MIN_SIZE);
|
||||
break;
|
||||
case password::LIKE_UNAME:
|
||||
bot->Notice(theClient,"Password can't be similar to your username");
|
||||
break;
|
||||
case password::PASS_OK:
|
||||
{
|
||||
theUser->setPassword(bot->CryptPass(st[1]));
|
||||
theUser->setPassChangeTS(::time(0));
|
||||
if(theUser->Update())
|
||||
{
|
||||
bot->Notice(theClient,"Password changed!");
|
||||
bot->MsgChanLog("(%s) - %s: Changed Password\n",
|
||||
theUser->getUserName().c_str(),
|
||||
theClient->getRealNickUserHost().c_str());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Error while changing password");
|
||||
bot->MsgChanLog("Error while changing password for (%s) - %s\n",
|
||||
theUser->getUserName().c_str(),
|
||||
theClient->getRealNickUserHost().c_str(),st.assemble(1).c_str());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* NOMODECommand.cc
|
||||
* Adds a channel to the bad channels list
|
||||
*
|
||||
* 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: NOMODECommand.cc,v 1.8 2006/09/26 17:36:00 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Constants.h"
|
||||
#include "ccBadChannel.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: NOMODECommand.cc,v 1.8 2006/09/26 17:36:00 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool NOMODECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 3 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if(st[2].size() > channel::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Channel name can't be more than %d characters",
|
||||
channel::MaxName);
|
||||
return false;
|
||||
}
|
||||
|
||||
bot->MsgChanLog("NOMODE %s\n",bot->removeSqlChars(st.assemble(1)).c_str());
|
||||
|
||||
if(!strcasecmp(st[1],"ADD"))
|
||||
{
|
||||
if( st.size() < 4 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
ccBadChannel* NewChannel = bot->isBadChannel(st[2]);
|
||||
if(NewChannel)
|
||||
{
|
||||
bot->Notice(theClient,"There is already a NOMODE entry for channel %s",st[2].c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
NewChannel = new (std::nothrow) ccBadChannel(bot->removeSqlChars(st[2]),
|
||||
bot->removeSqlChars(st.assemble(3)),
|
||||
theClient->getRealNickUserHost());
|
||||
assert(NewChannel != NULL);
|
||||
if(!NewChannel->Insert(bot->SQLDb))
|
||||
{
|
||||
bot->Notice(theClient,"Error while inserting the NOMODE entry into the database");
|
||||
return false;
|
||||
}
|
||||
bot->addBadChannel(NewChannel);
|
||||
bot->Notice(theClient,"NOMODE for %s added successfully.", st[2].c_str());
|
||||
}
|
||||
else if(!strcasecmp(st[1],"REM"))
|
||||
{
|
||||
ccBadChannel* OldChannel = bot->isBadChannel(st[2]);
|
||||
if(!OldChannel)
|
||||
{
|
||||
bot->Notice(theClient,"There is no NOMODE entry for channel %s",st[2].c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bot->remBadChannel(OldChannel);
|
||||
if(!OldChannel->Delete(bot->SQLDb))
|
||||
{
|
||||
bot->Notice(theClient,"Error while removing the NOMODE entry from the database");
|
||||
return false;
|
||||
}
|
||||
delete OldChannel;
|
||||
bot->Notice(theClient,"NOMODE for %s removed successfully.", st[2].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"NOMODE must get ADD/REM as first parameter");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
} // namepsace uworld
|
||||
|
||||
} // namespace gnuworld
|
||||
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* OPCommand.cc
|
||||
* Cause the bot to op users on a specific 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: OPCommand.cc,v 1.16 2006/09/26 17:36:00 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "Constants.h"
|
||||
#include "ccBadChannel.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: OPCommand.cc,v 1.16 2006/09/26 17:36:00 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool OPCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
bool foundUser = false;
|
||||
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 3 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if(st[1].size() > channel::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Channel name can't be more than %d characters",
|
||||
channel::MaxName);
|
||||
return false;
|
||||
}
|
||||
|
||||
Channel* theChan = Network->findChannel( st[ 1 ] ) ;
|
||||
if( NULL == theChan )
|
||||
{
|
||||
bot->Notice( theClient, "Unable to find channel %s\n",
|
||||
st[ 1 ].c_str() ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
ccBadChannel* Chan = bot->isBadChannel(st[1]);
|
||||
if(Chan)
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, but you can't change modes in "
|
||||
"this channel because: %s",
|
||||
Chan->getReason().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
iClient* Target = 0;
|
||||
|
||||
// Use a std::set<> here to ensure that the same user is not
|
||||
// included more than once.
|
||||
|
||||
bot->MsgChanLog("OP %s\n",st.assemble(1).c_str());
|
||||
string modes = "+";
|
||||
string args="";
|
||||
|
||||
for( StringTokenizer::size_type i = 2 ; i < st.size() ; ++i )
|
||||
{
|
||||
Target = Network->findNick( st[ i ] ) ;
|
||||
if( 0 == Target )
|
||||
{
|
||||
continue ;
|
||||
}
|
||||
|
||||
ChannelUser* tmpChanUser = theChan->findUser(Target) ;
|
||||
if( 0 == tmpChanUser )
|
||||
{
|
||||
continue ;
|
||||
}
|
||||
/* ok, the user is on the channel - flag it */
|
||||
foundUser = true;
|
||||
modes +="o";
|
||||
args +=st[i]+ " ";
|
||||
|
||||
} // for
|
||||
|
||||
if (!foundUser)
|
||||
{
|
||||
bot->Notice(theClient, "I'm sorry, I couldn't find anyone to op in %s!",
|
||||
st[1].c_str());
|
||||
return false;
|
||||
}
|
||||
if( !args.empty() )
|
||||
{
|
||||
bot->Mode(theChan,modes,args,true);
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
Follow these steps to setup the database for the ccontrol module. This
|
||||
file assumes that postgresql is running and configured, and that you have
|
||||
access to add and modify databases within it.
|
||||
|
||||
Create the database
|
||||
-------------------
|
||||
> createdb ccontrol
|
||||
|
||||
Note that this assumes that the ccontrol database does not already exist.
|
||||
|
||||
Load the schema
|
||||
---------------
|
||||
Make sure you are in the gnuworld/doc directory.
|
||||
|
||||
> psql ccontrol < ccontrol.sql
|
||||
> psql ccontrol < ccontrol.help.sql
|
||||
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
/**
|
||||
* REMCOMMANDCommand.cc
|
||||
* Removes a command from oper access list
|
||||
*
|
||||
* 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: REMCOMMANDCommand.cc,v 1.16 2009/06/13 06:43:34 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "ccUser.h"
|
||||
#include "misc.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: REMCOMMANDCommand.cc,v 1.16 2009/06/13 06:43:34 hidden1 Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool REMCOMMANDCommand::Exec( iClient* theClient, const string& Message)
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
ccUser* theUser;
|
||||
if( st.size() < 3 )
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
ccUser *AClient = bot->IsAuth( theClient );
|
||||
|
||||
if( NULL == AClient )
|
||||
{
|
||||
bot->Notice( theClient, "You must be authenticated to use this command." ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if(st[1].size() > 64)
|
||||
{
|
||||
bot->Notice(theClient,"Oper name can't be more than 64 characters");
|
||||
return false;
|
||||
}
|
||||
//Fetch the user record from the database
|
||||
|
||||
bool AllOpers = false;
|
||||
bool AllAdmins = false;
|
||||
bool AllSmts = false;
|
||||
bool AllCoders = false;
|
||||
if(!strcasecmp(st[1],"-allopers"))
|
||||
{
|
||||
if (AClient->getType() < operLevel::CODERLEVEL)
|
||||
{
|
||||
bot->Notice(theClient, "-allopers: This is coder level");
|
||||
return true;
|
||||
}
|
||||
AllOpers = true;
|
||||
}
|
||||
|
||||
else if(!strcasecmp(st[1],"-alladmins"))
|
||||
{
|
||||
if (AClient->getType() < operLevel::CODERLEVEL)
|
||||
{
|
||||
bot->Notice(theClient, "-alladmins: This is coder level");
|
||||
return true;
|
||||
}
|
||||
AllAdmins = true;
|
||||
}
|
||||
|
||||
else if(!strcasecmp(st[1],"-allsmts"))
|
||||
{
|
||||
if (AClient->getType() < operLevel::CODERLEVEL)
|
||||
{
|
||||
bot->Notice(theClient, "-allsmts: This is coder level");
|
||||
return true;
|
||||
}
|
||||
AllSmts = true;
|
||||
}
|
||||
|
||||
else if(!strcasecmp(st[1],"-allcoders"))
|
||||
{
|
||||
if (AClient->getType() < operLevel::CODERLEVEL)
|
||||
{
|
||||
bot->Notice(theClient, "-allcoders: This is coder level");
|
||||
return true;
|
||||
}
|
||||
AllCoders = true;
|
||||
}
|
||||
|
||||
//ccUser* theUser = bot->GetUser(st[1]);
|
||||
else
|
||||
theUser = bot->GetOper(bot->removeSqlChars(st[1]));
|
||||
|
||||
if (!AllOpers && !AllAdmins && !AllSmts && !AllCoders && !theUser)
|
||||
{
|
||||
bot->Notice(theClient,"I can't find oper %s",st[1].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if(st[2].size() > 128)
|
||||
{
|
||||
bot->Notice(theClient,"Command name can't be more than 128 characters");
|
||||
return false;
|
||||
}
|
||||
Command* Comm = bot->findCommandInMem(st[2]);
|
||||
if(!Comm)
|
||||
{
|
||||
bot->Notice(theClient,"Command %s does not exist!",st[2].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
bot->MsgChanLog("REMCOMMAND %s\n",st.assemble(1).c_str());
|
||||
if(!strcasecmp(AClient->getUserName(),st[1]))
|
||||
{
|
||||
bot->Notice(theClient,"You can't remove your own command access!");
|
||||
return false;
|
||||
}
|
||||
|
||||
list<ccUser*> ccList;
|
||||
if (!AllOpers && !AllAdmins && !AllSmts && !AllCoders)
|
||||
{
|
||||
ccList.push_back(theUser);
|
||||
}
|
||||
else
|
||||
{
|
||||
ccontrol::usersConstIterator uItr = bot->usersMap_begin();
|
||||
for (; uItr != bot->usersMap_end(); uItr++)
|
||||
{
|
||||
if (AllCoders)
|
||||
{
|
||||
ccList.push_back(uItr->second);
|
||||
}
|
||||
else if ((AllSmts) && (uItr->second->getType() <= operLevel::SMTLEVEL))
|
||||
{
|
||||
ccList.push_back(uItr->second);
|
||||
}
|
||||
else if ((AllAdmins) && (uItr->second->getType() <= operLevel::ADMINLEVEL))
|
||||
{
|
||||
ccList.push_back(uItr->second);
|
||||
}
|
||||
else if ((AllOpers) && (uItr->second->getType() <= operLevel::OPERLEVEL))
|
||||
{
|
||||
ccList.push_back(uItr->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
bool sentOnce = false;
|
||||
for (list<ccUser*>::iterator Itr = ccList.begin(); Itr != ccList.end(); Itr++)
|
||||
{
|
||||
theUser = *Itr;
|
||||
|
||||
bool Admin = (AClient->getType() < operLevel::SMTLEVEL);
|
||||
|
||||
if((Admin) && (AClient->getType() <= theUser->getType()))
|
||||
{
|
||||
bot->Notice(theClient,"You can't modify a user who has an equal or higher "
|
||||
"access level to your own.");
|
||||
return false;
|
||||
}
|
||||
else if(!(Admin) && (AClient->getType() < theUser->getType()))
|
||||
{
|
||||
bot->Notice(theClient,"You can't modify a user who has a higher access "
|
||||
"level than you.");
|
||||
return false;
|
||||
}
|
||||
if((Admin) && (strcasecmp(AClient->getServer(),theUser->getServer())))
|
||||
{
|
||||
bot->Notice(theClient,"You can only modify a user who is associated with the same server as you");
|
||||
return false;
|
||||
}
|
||||
if ((!strcasecmp(st[2],"ADDCOMMAND")) && (theUser->getType() == operLevel::CODERLEVEL))
|
||||
{
|
||||
if (!sentOnce)
|
||||
bot->Notice(theClient, "You can't remove the ADDCOMMAND command from a coder.");
|
||||
sentOnce = true;
|
||||
if (!AllOpers && !AllAdmins && !AllSmts && !AllCoders)
|
||||
return false;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if(!(theUser->gotAccess(Comm)))
|
||||
{
|
||||
if (!AllOpers && !AllAdmins && !AllSmts && !AllCoders)
|
||||
{
|
||||
bot->Notice(theClient,"%s doesn't have access to %s",theUser->getUserName().c_str(),st[2].c_str());
|
||||
return false;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
//Remove the command
|
||||
theUser->removeCommand(Comm);
|
||||
theUser->setLast_Updated_By(bot->removeSqlChars(theClient->getRealNickUserHost()));
|
||||
if(theUser->Update())
|
||||
{
|
||||
bot->Notice(theClient,"Successfully removed the command from %s",theUser->getUserName().c_str());
|
||||
count++;
|
||||
if (!AllOpers && !AllAdmins && !AllSmts && !AllCoders)
|
||||
return true;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Error while removing command from %s",theUser->getUserName().c_str());
|
||||
if (!AllOpers && !AllAdmins && !AllSmts && !AllCoders)
|
||||
return false;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
bot->Notice(theClient, "Removed %s access from %d users", Comm->getName().c_str(), count);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* REMGCHANCommand.cc
|
||||
* Removes a BADCHAN gline
|
||||
*
|
||||
* 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: REMGCHANCommand.cc,v 1.14 2006/09/26 17:36:00 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: REMGCHANCommand.cc,v 1.14 2006/09/26 17:36:00 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
// remgline user@host
|
||||
bool REMGCHANCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if((st[1].substr(0,1) != "#") || (st[1].size() > channel::MaxName))
|
||||
{
|
||||
bot->Notice(theClient,"Invalid channel name. It must begin with # and can't be "
|
||||
"more than %d characters in length.",
|
||||
channel::MaxName);
|
||||
return false;
|
||||
}
|
||||
bot->MsgChanLog("REMGCHAN %s\n",st.assemble(1).c_str());
|
||||
|
||||
ccGline *tmpGline = bot->findGline(bot->removeSqlChars(st[1]));
|
||||
if(tmpGline != NULL)
|
||||
{
|
||||
if(!tmpGline->Delete())
|
||||
bot->MsgChanLog("Error while removing gline for channel %s from the db\n",st[1].c_str());
|
||||
bot->remGline(tmpGline);
|
||||
delete tmpGline;
|
||||
}
|
||||
//bot->setRemoving(st[1]);
|
||||
server->removeGline( st [ 1 ] ,bot);
|
||||
//bot->unSetRemoving();
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* REMGLINECommand.cc
|
||||
* Removes a gline
|
||||
*
|
||||
* 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: REMGLINECommand.cc,v 1.27 2009/06/14 01:29:54 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: REMGLINECommand.cc,v 1.27 2009/06/14 01:29:54 hidden1 Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
// remgline user@host
|
||||
bool REMGLINECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
bot->MsgChanLog("REMGLINE %s\n",st.assemble(1).c_str());
|
||||
|
||||
if(st[1].substr(0,1) == "#")
|
||||
{
|
||||
bot->Notice(theClient,"Please use REMGCHAN to remove a BADCHAN gline");
|
||||
return false;
|
||||
}
|
||||
if(st[1].substr(0,1) == "$")
|
||||
{
|
||||
bot->Notice(theClient,"Please use REMSGLINE to remove a realname gline");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (st[1].find('@',1) == string::npos)
|
||||
{
|
||||
bot->Notice(theClient, "Invalid G-line. Please specify a user@. i.e: REMGLINE *@ip");
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int dummy;
|
||||
|
||||
if(bot->checkGline(st[1],0,dummy) & gline::HUH_NO_HOST)
|
||||
{
|
||||
bot->Notice(theClient,"Please use REMSGLINE to remove a this gline");
|
||||
return false;
|
||||
}
|
||||
|
||||
ccGline *tmpGline = bot->findGline(st[1]);
|
||||
if(tmpGline != NULL)
|
||||
{
|
||||
if(!tmpGline->Delete())
|
||||
bot->MsgChanLog("Error while removing gline for host %s from the db\n",st[1].c_str());
|
||||
bot->remGline(tmpGline);
|
||||
delete tmpGline;
|
||||
}
|
||||
server->removeGline(st[1],bot);
|
||||
bot->Notice( theClient, "Removal of gline succeeded\n" ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* REMOVEOPERCHANCommand.cc
|
||||
* Removes an ircop only 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: REMOPERCHANCommand.cc,v 1.12 2006/09/26 17:36:00 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: REMOPERCHANCommand.cc,v 1.12 2006/09/26 17:36:00 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
// remoperchan #channel
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool REMOPERCHANCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if(st[1].size() > channel::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Channel name can't be more than %d characters",
|
||||
channel::MaxName);
|
||||
return false;
|
||||
}
|
||||
string chanName = st[ 1 ] ;
|
||||
if( '#' != chanName[ 0 ] )
|
||||
{
|
||||
bot->Notice( theClient, "Invalid channel name" ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if( bot->removeOperChan( chanName ) )
|
||||
{
|
||||
bot->Notice( theClient, "Removal of %s as oper chan SUCCEEDED",
|
||||
chanName.c_str() ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice( theClient, "Removal of %s as oper chan FAILED",
|
||||
chanName.c_str() ) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* REMOVEIGNORECommand.cc
|
||||
* Removes ignored host
|
||||
*
|
||||
* 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: REMOVEIGNORECommand.cc,v 1.11 2006/09/26 17:36:01 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: REMOVEIGNORECommand.cc,v 1.11 2006/09/26 17:36:01 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
// remoperchan #channel
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool REMOVEIGNORECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
bot->MsgChanLog("REMIGNORE %s\n",st.assemble(1).c_str());
|
||||
|
||||
string::size_type atPos = st[ 1 ].find_first_of( '@' ) ;
|
||||
if( string::npos == atPos )
|
||||
{
|
||||
iClient *igClient = Network->findNick(st[1]);
|
||||
if(!igClient)
|
||||
{
|
||||
bot->Notice(theClient,"There is no such user as %s",st[1].c_str());
|
||||
return false;
|
||||
}
|
||||
if(bot->removeIgnore(igClient) == IGNORE_REMOVED)
|
||||
{
|
||||
bot->Notice(theClient,"Successfully removed ignore for user %s",st[1].c_str());
|
||||
bot->MsgChanLog("Removed ignore for %s by request of %s\n",st[1].c_str(),theClient->getNickName().c_str());
|
||||
}
|
||||
|
||||
else
|
||||
bot->Notice(theClient,"Can't find ignore for user %s",st[1].c_str());
|
||||
}
|
||||
else
|
||||
if(bot->removeIgnore(st[1]) == IGNORE_REMOVED)
|
||||
{
|
||||
bot->Notice(theClient,"Successfully removed ignore for host %s",st[1].c_str());
|
||||
bot->MsgChanLog("Removed ignore for %s by request of %s\n",st[1].c_str(),theClient->getNickName().c_str());
|
||||
}
|
||||
else
|
||||
bot->Notice(theClient,"Can't find ignore for host %s",st[1].c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* REMSERVERCommand.cc
|
||||
* Delete a server for the bot database
|
||||
*
|
||||
* 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: REMSERVERCommand.cc,v 1.14 2007/08/28 16:10:03 dan_karrels Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
#include "dbHandle.h"
|
||||
|
||||
RCSTAG( "$Id: REMSERVERCommand.cc,v 1.14 2007/08/28 16:10:03 dan_karrels Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::endl ;
|
||||
using std::ends ;
|
||||
using std::stringstream ;
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool REMSERVERCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
if(st[1].size() > server::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Server name can't be longer than %d characters",
|
||||
server::MaxName);
|
||||
return false;
|
||||
}
|
||||
|
||||
ccServer* tmpServer = bot->getServer(bot->removeSqlChars(st[1]));
|
||||
if(!tmpServer)
|
||||
{
|
||||
bot->Notice(theClient, "Server %s is not in my database!\n",st [ 1 ].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
bot->MsgChanLog("REMSERVER %s\n",st.assemble(1).c_str());
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << User::Query
|
||||
<< " Where lower(server) = '"
|
||||
<< string_lower(tmpServer->getName()) << "'"
|
||||
<< ends;
|
||||
|
||||
|
||||
elog << theQuery.str().c_str() << endl;
|
||||
|
||||
if( !bot->SQLDb->Exec( theQuery.str(), true ) )
|
||||
//if(PGRES_TUPLES_OK != status)
|
||||
{
|
||||
bot->Notice(theClient,"Database error, unable to remove the server.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(bot->SQLDb->Tuples() > 0)
|
||||
{
|
||||
bot->Notice(theClient,"There are %d users added to that server, please remove them first",
|
||||
bot->SQLDb->Tuples());
|
||||
return false;
|
||||
}
|
||||
|
||||
bot->MsgChanLog("Removing server '%s' from the database at the request of %s\n",
|
||||
tmpServer->getName().c_str(),theClient->getNickName().c_str());
|
||||
|
||||
//NewServer->setName(SName);
|
||||
if(tmpServer->Delete())
|
||||
{
|
||||
bot->Notice(theClient,"Server \002%s\002 has been successfully removed\n",tmpServer->getName().c_str());
|
||||
bot->remServer(tmpServer);
|
||||
delete tmpServer;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Database error while removing server \002%s\002\n",tmpServer->getName().c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* REMSGLINECommand.cc
|
||||
* Removes a gline
|
||||
*
|
||||
* 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: REMSGLINECommand.cc,v 1.8 2006/09/26 17:36:01 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: REMSGLINECommand.cc,v 1.8 2006/09/26 17:36:01 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
// remgline user@host
|
||||
bool REMSGLINECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
bot->MsgChanLog("REMSGLINE %s\n",st.assemble(1).c_str());
|
||||
|
||||
if(st[1].substr(0,1) == "#")
|
||||
{
|
||||
bot->Notice(theClient,"Please use REMGCHAN to remove a BADCHAN gline");
|
||||
return false;
|
||||
}
|
||||
ccGline *tmpGline;
|
||||
bool realName = false;
|
||||
if(st[1].substr(0,1) != "$")
|
||||
tmpGline = bot->findGline(st[1]);
|
||||
else
|
||||
{
|
||||
tmpGline = bot->findRealGline(st[1]);
|
||||
realName = true;
|
||||
}
|
||||
if(tmpGline != NULL)
|
||||
{
|
||||
if(!tmpGline->Delete())
|
||||
bot->MsgChanLog("Error while removing gline for host %s from the database\n",
|
||||
st[1].c_str());
|
||||
bot->remGline(tmpGline);
|
||||
delete tmpGline;
|
||||
}
|
||||
server->removeGline(st[1],bot);
|
||||
bot->Notice( theClient, "Removal of gline (%s) succeeded\n",st[1].c_str() ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* REMUSERCommand.cc
|
||||
* Removes an oper from the bot access list
|
||||
*
|
||||
* 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: REMUSERCommand.cc,v 1.14 2006/09/26 17:36:01 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "Network.h"
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: REMUSERCommand.cc,v 1.14 2006/09/26 17:36:01 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool REMUSERCommand::Exec( iClient* theClient, const string& Message)
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
//Fetch the user record from the database
|
||||
ccUser* theUser = bot->GetOper(bot->removeSqlChars(st[1]));
|
||||
if (!theUser)
|
||||
{
|
||||
bot->Notice(theClient,"Oper %s does not exist in database, "
|
||||
"check your handle and try again",st[1].c_str());
|
||||
return false;
|
||||
}
|
||||
ccUser* tempAuth = bot->IsAuth(theClient);
|
||||
|
||||
if(!tempAuth)
|
||||
{ //we should never get here
|
||||
return false;
|
||||
}
|
||||
if((tempAuth->getType() <= theUser->getType())
|
||||
&& (tempAuth->getType() < operLevel::CODERLEVEL))
|
||||
{
|
||||
bot->Notice(theClient,"You can't remove an oper who has a higher or equal "
|
||||
" access level to you.");
|
||||
return false;
|
||||
}
|
||||
if(((tempAuth->getType() < operLevel::SMTLEVEL)) &&
|
||||
(strcasecmp(tempAuth->getServer(),theUser->getServer())))
|
||||
{
|
||||
bot->Notice(theClient,"You can't remove opers from other servers");
|
||||
return false;
|
||||
}
|
||||
bot->MsgChanLog("REMUSER %s\n",st.assemble(1).c_str());
|
||||
|
||||
if(bot->DeleteOper(string_lower(st[1])))
|
||||
{
|
||||
bot->Notice(theClient,"Successfully deleted oper: %s",st[1].c_str());
|
||||
|
||||
//Check if the user is authenticate
|
||||
if(theUser->getClient())
|
||||
{
|
||||
//Get hte user iClient entry from the network , and notify him that he was deleted
|
||||
const iClient *TClient = theUser->getClient();
|
||||
if(TClient)
|
||||
bot->Notice(TClient,"You have been removed from my access list, "
|
||||
"and have been deauthenticated.");
|
||||
//Remove the user authenticate entry
|
||||
bot->deAuthUser(theUser);
|
||||
}
|
||||
delete theUser;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Error while deleting oper: %s",st[1].c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* REOPCommand.cc
|
||||
* Clears all channel ops, and reops the specified nick
|
||||
*
|
||||
* 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: REOPCommand.cc,v 1.7 2006/09/26 17:36:01 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "Network.h"
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Constants.h"
|
||||
#include "ccBadChannel.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: REOPCommand.cc,v 1.7 2006/09/26 17:36:01 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
using std::vector ;
|
||||
using gnuworld::iClient;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool REOPCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if( st.size() < 3 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if(st[1].size() > channel::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Channel name can't be more than %d characters",
|
||||
channel::MaxName);
|
||||
return false;
|
||||
}
|
||||
|
||||
Channel* theChan = Network->findChannel( st[ 1 ] ) ;
|
||||
if( NULL == theChan )
|
||||
{
|
||||
bot->Notice( theClient, "Unable to find channel %s",
|
||||
st[ 1 ].c_str() ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if(bot->isOperChan(theChan))
|
||||
{
|
||||
bot->Notice(theClient,"You can't reop an oper channel.");
|
||||
return false;
|
||||
}
|
||||
|
||||
iClient* reopClient = Network->findNick(st[2]);
|
||||
if(!reopClient)
|
||||
{
|
||||
bot->Notice(theClient,"I can't find %s online",st[2].c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bot->MsgChanLog("REOP %s\n",st.assemble(1).c_str());
|
||||
ccBadChannel* Chan = bot->isBadChannel(st[1]);
|
||||
if(Chan)
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, but you can't change modes in "
|
||||
"this channel because: %s",
|
||||
Chan->getReason().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
/* check if the user to be opped is actually in the channel! */
|
||||
ChannelUser* tmpChanUser = theChan->findUser(reopClient);
|
||||
if (0 == tmpChanUser)
|
||||
{
|
||||
bot->Notice(theClient, "Sorry, but that user is not in the channel.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// First, clear all ops
|
||||
bot->ClearMode( theChan, string( "o" ), true ) ;
|
||||
|
||||
/* Now, op the proper user - use mode instead of op so the ccontrol user
|
||||
doesnt have to enter the channel first */
|
||||
bot->Mode(theChan,"+o",st[2],true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* SAYCommand.cc
|
||||
* Forces the bot to quote a command
|
||||
*
|
||||
* 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.8 2006/09/26 17:36:01 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: SAYCommand.cc,v 1.8 2006/09/26 17:36:01 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool SAYCommand::Exec( iClient* theClient, const string& Message)
|
||||
{
|
||||
|
||||
StringTokenizer st( Message ) ;
|
||||
string Numeric;
|
||||
string Target;
|
||||
if(st.size() < 4)
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
bot->MsgChanLog("%s\n",st.assemble(0).c_str());
|
||||
if(!strcasecmp(st[1].c_str(),"-s"))
|
||||
{
|
||||
Numeric = bot->getUplink()->getCharYY();
|
||||
}
|
||||
else if(!strcasecmp(st[1].c_str(),"-b"))
|
||||
{
|
||||
Numeric = bot->getCharYYXXX();
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"First argument must be -s for server, or -b for bot");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!strcasecmp(st[2].substr(0,1),"#"))
|
||||
{
|
||||
if(!Network->findChannel(st[2]))
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, but i can't find channel %s",
|
||||
st[2].c_str());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Target = st[2];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iClient* tClient = Network->findNick(st[2]);
|
||||
if(!tClient)
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, but i can't find nick: %s",
|
||||
st[2].c_str());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Target = tClient->getCharYYXXX();
|
||||
}
|
||||
}
|
||||
|
||||
if (!match("SAY",st[0]))
|
||||
{
|
||||
bot->Write("%s P %s :%s",
|
||||
Numeric.c_str(),
|
||||
Target.c_str(),
|
||||
st.assemble(3).c_str());
|
||||
} else {
|
||||
bot->Write("%s P %s :%cACTION %s%c",
|
||||
Numeric.c_str(),
|
||||
Target.c_str(),
|
||||
1, st.assemble(3).c_str(), 1);
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
/**
|
||||
* SCANCommand.cc
|
||||
* Shows alist of users which match a certain host/real name
|
||||
*
|
||||
* 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: SCANCommand.cc,v 1.14 2006/09/26 17:36:01 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "misc.h"
|
||||
#include "match.h"
|
||||
#include "Network.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: SCANCommand.cc,v 1.14 2006/09/26 17:36:01 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool SCANCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
|
||||
if( st.size() < 3 )
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
bot->MsgChanLog("SCAN %s\n",st.assemble(1).c_str());
|
||||
|
||||
typedef list<const iClient*> clientsList;
|
||||
|
||||
bool showUsers = false;
|
||||
bool showIdentReport = false;
|
||||
bool realHostLook = false;
|
||||
bool fakeHostLook = false;
|
||||
bool nameLook = false;
|
||||
unsigned int pos = 1;
|
||||
string userName;
|
||||
string hostName;
|
||||
string realName;
|
||||
string ClientInfo;
|
||||
const iClient* curClient;
|
||||
typedef map<string,int> identMapType;
|
||||
identMapType identMap;
|
||||
clientsList cList;
|
||||
|
||||
for(pos = 1; pos < st.size() ; )
|
||||
{
|
||||
if(!strcasecmp(st[pos],"-v"))
|
||||
{
|
||||
showUsers = true;
|
||||
++pos;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-i"))
|
||||
{
|
||||
showIdentReport = true;
|
||||
++pos;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-h"))
|
||||
{
|
||||
if(pos +1 >= st.size())
|
||||
{
|
||||
bot->Notice(theClient,"-h must get a host to scan for");
|
||||
return true;
|
||||
}
|
||||
if((nameLook) || (fakeHostLook))
|
||||
{
|
||||
bot->Notice(theClient,"You can't specify more than one scanning option");
|
||||
return true;
|
||||
}
|
||||
realHostLook = true;
|
||||
hostName = st[pos+1];
|
||||
pos+=2;
|
||||
}
|
||||
else if(!strcasecmp(st[pos],"-fh"))
|
||||
{
|
||||
if(pos +1 >= st.size())
|
||||
{
|
||||
bot->Notice(theClient,"-fh must get a host to scan for");
|
||||
return true;
|
||||
}
|
||||
if((nameLook) || (realHostLook))
|
||||
{
|
||||
bot->Notice(theClient,"You can't specify more than one scanning option");
|
||||
return true;
|
||||
}
|
||||
fakeHostLook = true;
|
||||
hostName = st[pos+1];
|
||||
pos+=2;
|
||||
}
|
||||
|
||||
else if(!strcasecmp(st[pos],"-n"))
|
||||
{
|
||||
if(pos +1 >= st.size())
|
||||
{
|
||||
bot->Notice(theClient,"-n must get a real name to scan for");
|
||||
return true;
|
||||
}
|
||||
if((realHostLook) || (fakeHostLook))
|
||||
{
|
||||
bot->Notice(theClient,"You can't specify more than one scanning option");
|
||||
return true;
|
||||
}
|
||||
nameLook = true;
|
||||
realName = st[pos+1];
|
||||
pos+=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"SCAN command can only get -h <host>, -fh <host> or -n <real name>");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(fakeHostLook)
|
||||
{
|
||||
if(string::npos == hostName.find_first_of("@"))
|
||||
{
|
||||
hostName = string("*@" + hostName);
|
||||
}
|
||||
cList = Network->matchUserHost(hostName);
|
||||
}
|
||||
else if(realHostLook)
|
||||
{
|
||||
if(string::npos == hostName.find_first_of("@"))
|
||||
{
|
||||
hostName = string("*@" + hostName);
|
||||
}
|
||||
cList = Network->matchRealUserHost(hostName);
|
||||
}
|
||||
else if(nameLook)
|
||||
{
|
||||
cList = Network->matchRealName(realName);
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"You didn't specify a search type (-h/-fh/-n) - please try again");
|
||||
return true;
|
||||
}
|
||||
if( (cList.size() > scan::MAX_SHOW) && (showUsers))
|
||||
{
|
||||
bot->Notice(theClient,"There were %d users matching this search, only 15 will be shown",
|
||||
cList.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"There were %d users matching this search",cList.size());
|
||||
}
|
||||
|
||||
unsigned int shown = 0;
|
||||
unsigned int ident_nonidented = 0;
|
||||
unsigned int ident_count = 0;
|
||||
|
||||
if(showUsers)
|
||||
{
|
||||
const ChannelUser* curChannel;
|
||||
string ClientInfo;
|
||||
for(clientsList::iterator cptr = cList.begin();((cptr!=cList.end()) && (shown < 15));++cptr)
|
||||
{
|
||||
curClient = *cptr;
|
||||
ClientInfo = curClient->getNickUserHost();
|
||||
if(!curClient->getMode(iClient::MODE_SERVICES)) //Dont show channels for +k users
|
||||
{
|
||||
for( iClient::const_channelIterator ptr = curClient->channels_begin() ;
|
||||
ptr != curClient->channels_end() ; ++ptr )
|
||||
{
|
||||
ClientInfo += " ";
|
||||
curChannel = (*ptr)->findUser(const_cast< iClient* >(curClient));
|
||||
if(curChannel->isModeO())
|
||||
{
|
||||
ClientInfo += "@";
|
||||
}
|
||||
if(curChannel->isModeV())
|
||||
{
|
||||
ClientInfo += "+";
|
||||
}
|
||||
ClientInfo += (*ptr)->getName();
|
||||
}
|
||||
++shown;
|
||||
}
|
||||
bot->Notice(theClient,"%s",ClientInfo.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
/* do ident report here (if selected) */
|
||||
if(showIdentReport)
|
||||
{
|
||||
/* ok, show the report */
|
||||
for (clientsList::iterator cptr = cList.begin(); (cptr!=cList.end()); ++cptr)
|
||||
{
|
||||
/* cycle the userlist and gather stats */
|
||||
curClient = *cptr;
|
||||
ClientInfo = curClient->getNickUserHost();
|
||||
userName = curClient->getUserName();
|
||||
if (userName[0]=='~')
|
||||
{
|
||||
/* unidented client */
|
||||
ident_nonidented++;
|
||||
} else {
|
||||
/* idented client */
|
||||
identMap[userName]++;
|
||||
if (identMap[userName] == 1)
|
||||
ident_count++;
|
||||
}
|
||||
}
|
||||
bot->Notice(theClient, "Ident report: %d unidented clients, %d unique idents",
|
||||
ident_nonidented, ident_count);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* SCANGLINECommand.cc
|
||||
* Check if a certain host is glined, if it is returns the glines info
|
||||
*
|
||||
* 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: SCANGLINECommand.cc,v 1.13 2006/09/26 17:36:01 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: SCANGLINECommand.cc,v 1.13 2006/09/26 17:36:01 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool SCANGLINECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
bot->MsgChanLog("SCANGLINE %s\n",st.assemble(1).c_str());
|
||||
|
||||
bot->listGlines(theClient,st[1]);
|
||||
|
||||
/*vector< const Gline* > glines = server->matchGline( st[ 1 ] ) ;
|
||||
|
||||
bot->Notice( theClient, "Found %d matches", glines.size() ) ;
|
||||
if( glines.empty() )
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
|
||||
bot->Notice( theClient, "Current time: %ld", (long)::time( 0 ) ) ;
|
||||
|
||||
for( vector< const Gline* >::const_iterator ptr = glines.begin() ;
|
||||
ptr != glines.end() ; ++ptr )
|
||||
{
|
||||
bot->Notice( theClient, "%s expires at %d, set by %s because %s",
|
||||
(*ptr)->getUserHost().c_str(),
|
||||
(*ptr)->getExpiration(),
|
||||
(*ptr)->getSetBy().c_str(),
|
||||
(*ptr)->getReason().c_str() ) ;
|
||||
}*/
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* SCHANGLINECommand.cc
|
||||
* Glines a specific 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: SCHANGLINECommand.cc,v 1.5 2009/06/06 07:53:34 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "misc.h"
|
||||
#include "Gline.h"
|
||||
#include "ip.h"
|
||||
#include "ELog.h"
|
||||
#include "Gline.h"
|
||||
//#include "gline.h"
|
||||
#include "time.h"
|
||||
#include "ccUser.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: SCHANGLINECommand.cc,v 1.5 2009/06/06 07:53:34 hidden1 Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string;
|
||||
|
||||
// Input: changline #blah reason
|
||||
//
|
||||
// Output: C GL * +*@lamer.net 3600 :Banned (*@lamer) ...
|
||||
//
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool SCHANGLINECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st(Message);
|
||||
unsigned ResStart = 2;
|
||||
int uParam = 0; // if the -u paramter is used in the command, it will only gline unidented connections
|
||||
|
||||
if (st.size() < 4)
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (st[1] == "-u") {
|
||||
if (st.size() < 5) {
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
uParam = 1;
|
||||
}
|
||||
|
||||
StringTokenizer::size_type pos = 1;
|
||||
time_t gLength = bot->getDefaultGlineLength();
|
||||
ccUser* tmpUser = bot->IsAuth(theClient);
|
||||
|
||||
/* log use of the command */
|
||||
bot->MsgChanLog("SCHANGLINE %s\n",st.assemble(1).c_str());
|
||||
|
||||
/* make sure they're trying a channel gline! */
|
||||
if (st[pos+uParam].substr(0,1) != "#")
|
||||
{
|
||||
bot->Notice(theClient,"Umm... this is SCHANGLINE, not GLINE - Try "
|
||||
"glining a channel maybe?");
|
||||
return true;
|
||||
}
|
||||
if (IsTimeSpec(st[2+uParam]))
|
||||
{
|
||||
gLength = extractTime( st[2+uParam], 1 );
|
||||
} else {
|
||||
gLength = bot->getDefaultGlineLength();
|
||||
ResStart = 1;
|
||||
}
|
||||
|
||||
string nickUserHost = theClient->getRealNickUserHost();
|
||||
|
||||
if (!tmpUser)
|
||||
{
|
||||
bot->Notice(theClient,"You must login to issue this channel gline!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (st[1+uParam].size() > channel::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Channel name can't be more than %d "
|
||||
"characters", channel::MaxName);
|
||||
return false;
|
||||
}
|
||||
|
||||
Channel* theChan = Network->findChannel(st[1+uParam]);
|
||||
if (NULL == theChan)
|
||||
{
|
||||
bot->Notice(theClient, "Unable to find channel %s",
|
||||
st[1+uParam].c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
StringTokenizer reason(st.assemble ( pos + ResStart + uParam), '|');
|
||||
|
||||
bot->glineChannelUsers(theClient, theChan, reason[0], gLength, nickUserHost, false, uParam);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
/**
|
||||
* SGLINECommand.cc
|
||||
* Glines a specific mask
|
||||
*
|
||||
* 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: SGLINECommand.cc,v 1.15 2009/05/16 07:47:23 danielaustin Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "misc.h"
|
||||
#include "Gline.h"
|
||||
#include "ip.h"
|
||||
#include "ELog.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: SGLINECommand.cc,v 1.15 2009/05/16 07:47:23 danielaustin Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
// Input: sgline *@blah.net reason
|
||||
// Input: sgline 3600 *@blah.net reason
|
||||
//
|
||||
// Output: C GL * +*@lamer.net 3600 :Banned (*@lamer) ...
|
||||
//
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool SGLINECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if(st.size() < 3)
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
StringTokenizer::size_type pos = 1 ;
|
||||
bool RealName = (!strcasecmp(st[pos],"-rn"));
|
||||
if(RealName && (st.size() < 4))
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
string RealHost;
|
||||
|
||||
|
||||
ccUser* tmpUser = bot->IsAuth(theClient);
|
||||
bot->MsgChanLog("SGLINE %s\n",st.assemble(1).c_str());
|
||||
|
||||
if(!RealName &&(string::npos != st[pos].find_first_of('#')))
|
||||
{
|
||||
bot->Notice(theClient,"I don't think glining that host is such a good idea");
|
||||
return true;
|
||||
}
|
||||
time_t gLength = bot->getDefaultGlineLength() ;
|
||||
|
||||
// (pos) is the index of the next token, the user@host mask.
|
||||
|
||||
if(!RealName)
|
||||
{
|
||||
string::size_type atPos = st[ pos ].find_first_of( '@' ) ;
|
||||
if( string::npos == atPos )
|
||||
{
|
||||
// User has only specified hostname, not a user name
|
||||
bot->Notice( theClient, "GLINE: Please specify gline mask in the "
|
||||
"format of user@host" ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
string userName = st[ pos ].substr( 0, pos ) ;
|
||||
string hostName = st[ pos ].substr( pos + 1 ) ;
|
||||
}
|
||||
else //RealName Gline
|
||||
{
|
||||
++pos;
|
||||
bool hostOk = false;
|
||||
bool hasSlash = false;
|
||||
if(st[pos].substr(0,2) != "$R")
|
||||
{
|
||||
RealHost = "$R" + st[pos];
|
||||
}
|
||||
else
|
||||
{
|
||||
RealHost = st[pos];
|
||||
}
|
||||
//Do alittle sanity check
|
||||
for(string::size_type p =2; p< st[pos].size();++p)
|
||||
{
|
||||
if(RealHost[p] != '$' && RealHost[p] != '*' && RealHost[p] != '?')
|
||||
hostOk = true;
|
||||
if (RealHost[p] == '/')
|
||||
hasSlash = true;
|
||||
}
|
||||
if(!hostOk)
|
||||
{
|
||||
bot->Notice(theClient,"You must specify at least one character other "
|
||||
"than *?$ as the realname!");
|
||||
return true;
|
||||
}
|
||||
if(hasSlash)
|
||||
{
|
||||
bot->Notice(theClient, "You can't use a '/' in a realname gline, consider switching it to a '?'");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
string Length;
|
||||
Length.assign(st[pos+1]);
|
||||
unsigned int Units = 1; //Defualt for seconds
|
||||
unsigned int ResStart = 2;
|
||||
bool Ok = true;
|
||||
if(!strcasecmp(Length.substr(Length.length()-1).c_str(),"d"))
|
||||
{
|
||||
Units = 24*3600;
|
||||
Length.resize(Length.length()-1);
|
||||
}
|
||||
else if(!strcasecmp(Length.substr(Length.length()-1).c_str(),"h"))
|
||||
{
|
||||
Units = 3600;
|
||||
Length.resize(Length.length()-1);
|
||||
}
|
||||
else if(!strcasecmp(Length.substr(Length.length()-1).c_str(),"m"))
|
||||
{
|
||||
Units = 60;
|
||||
Length.resize(Length.length()-1);
|
||||
}
|
||||
else if(!strcasecmp(Length.substr(Length.length()-1).c_str(),"s"))
|
||||
{
|
||||
Units = 1;
|
||||
Length.resize(Length.length()-1);
|
||||
}
|
||||
gLength = atoi(Length.c_str()) * Units;
|
||||
|
||||
if(gLength == 0)
|
||||
{
|
||||
gLength = bot->getDefaultGlineLength() ;
|
||||
ResStart = 1;
|
||||
}
|
||||
if(!tmpUser)
|
||||
{ // We shouldnt have got here in the first place, but check it anyway
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int Users;
|
||||
string nickUserHost = bot->removeSqlChars(theClient->getRealNickUserHost()) ;
|
||||
StringTokenizer ReasonTokenizer ( st.assemble( pos + ResStart ), '|');
|
||||
string Reason = ReasonTokenizer[0];
|
||||
|
||||
if(!RealName)
|
||||
{
|
||||
int gCheck = bot->checkSGline(st[pos],gLength,Users);
|
||||
|
||||
if(gCheck & gline::NEG_TIME)
|
||||
{
|
||||
bot->Notice(theClient,"A negative gline duration is not valid.");
|
||||
Ok = false;
|
||||
}
|
||||
|
||||
if(gCheck & gline::HUH_NO_HOST)
|
||||
{
|
||||
bot->Notice(theClient,"I don't think glining that host is such a good idea, do you?");
|
||||
Ok = false;
|
||||
}
|
||||
if(gCheck & gline::BAD_CIDRMASK)
|
||||
{
|
||||
bot->Notice(theClient,"The IP listed is not on a bit boundary for the CIDR mask specified.");
|
||||
Ok = false;
|
||||
}
|
||||
if(gCheck & gline::BAD_CIDRLEN)
|
||||
{
|
||||
bot->Notice(theClient,"Bad CIDR length - try something more specific.");
|
||||
Ok = false;
|
||||
}
|
||||
if(gCheck & gline::BAD_CIDROVERRIDE)
|
||||
{
|
||||
bot->Notice(theClient,"For CIDR sglines, you must enter all 4 parts of the IP.");
|
||||
Ok = false;
|
||||
}
|
||||
if(gCheck & gline::BAD_HOST)
|
||||
{
|
||||
bot->Notice(theClient,"illegal host");
|
||||
Ok = false;
|
||||
}
|
||||
if(!Ok)
|
||||
{
|
||||
bot->Notice(theClient,"Please fix all of the above, and try again");
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
char Us[100];
|
||||
Us[0] = '\0';
|
||||
sprintf(Us,"%d",Users);
|
||||
Reason = string("[") + Us + string("] ") + Reason;
|
||||
} //RealName Gline
|
||||
else
|
||||
{
|
||||
Users = Network->matchRealName(RealHost.substr(2,RealHost.size()-2)).size();
|
||||
char Us[100];
|
||||
Us[0] = '\0';
|
||||
sprintf(Us,"%d",Users);
|
||||
Reason = string("[") + Us + string ("] ") + Reason;
|
||||
}
|
||||
if(Reason.size() > gline::MAX_REASON_LENGTH)
|
||||
{
|
||||
bot->Notice(theClient,"Gline reason can't be more than %d characters",
|
||||
gline::MAX_REASON_LENGTH);
|
||||
return false;
|
||||
}
|
||||
/*server->setGline( nickUserHost,
|
||||
st[ pos ],
|
||||
string("[") + Us + "] " + Reason,
|
||||
//st.assemble( pos + ResStart ) + "[" + Us + "]",
|
||||
gLength , bot) ;*/
|
||||
ccGline *TmpGline = bot->findGline(st[pos]);
|
||||
bool Up = false;
|
||||
|
||||
if(TmpGline)
|
||||
Up = true;
|
||||
else TmpGline = new ccGline(bot->SQLDb);
|
||||
if(!RealName)
|
||||
TmpGline->setHost(bot->removeSqlChars(st [ pos ]));
|
||||
else
|
||||
TmpGline->setHost(RealHost);
|
||||
TmpGline->setExpires(::time(0) + gLength);
|
||||
TmpGline->setAddedBy(nickUserHost);
|
||||
TmpGline->setReason(Reason);
|
||||
TmpGline->setAddedOn(::time(0));
|
||||
TmpGline->setLastUpdated(::time(0));
|
||||
bot->addGlineToUplink(TmpGline);
|
||||
if(Up)
|
||||
{
|
||||
TmpGline->Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
TmpGline->Insert();
|
||||
//We need to update the Id
|
||||
TmpGline->loadData(TmpGline->getHost());
|
||||
bot->addGline(TmpGline);
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* SHUTDOWNCommand.cc
|
||||
* Shuts down the bot
|
||||
*
|
||||
* 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.8 2005/01/08 23:33:42 dan_karrels Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "server.h"
|
||||
|
||||
RCSTAG( "$Id: SHUTDOWNCommand.cc,v 1.8 2005/01/08 23:33:42 dan_karrels Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool SHUTDOWNCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if(st.size() < 2)
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
bot->MsgChanLog("SHUTDOWN %s\n",st.assemble(1).c_str());
|
||||
|
||||
server->Shutdown( st.assemble( 1 ) ) ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* STATUSCommand.cc
|
||||
* Shows debug status
|
||||
*
|
||||
* 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.8 2005/01/12 03:50:29 dan_karrels Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
//#include "StringTokenizer.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: STATUSCommand.cc,v 1.8 2005/01/12 03:50:29 dan_karrels Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool STATUSCommand::Exec( iClient* theClient, const string& )
|
||||
{
|
||||
bot->MsgChanLog("STATUS\n");
|
||||
|
||||
bot->showStatus(theClient);
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* SUSPENDCommand.cc
|
||||
* Set oper as suspended
|
||||
*
|
||||
* 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.15 2006/09/26 17:36:01 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "ccUser.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: SUSPENDCommand.cc,v 1.15 2006/09/26 17:36:01 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool SUSPENDCommand::Exec( iClient* theClient, const string& Message)
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if( st.size() < 4 )
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
//Fetch the oper record from the database
|
||||
ccUser* tmpUser = bot->GetOper(bot->removeSqlChars(st[1]));
|
||||
|
||||
if(!tmpUser)
|
||||
{
|
||||
bot->Notice(theClient,"%s isn't on my access list",st[1].c_str());
|
||||
return false;
|
||||
}
|
||||
ccUser* tmpAuth = bot->IsAuth(theClient);
|
||||
if(!tmpAuth)
|
||||
{ //we should never get here
|
||||
return false;
|
||||
}
|
||||
bot->MsgChanLog("SUSPEND %s\n",st.assemble(1).c_str());
|
||||
|
||||
unsigned int AdFlag = tmpAuth->getType(); //Get the admin flag
|
||||
unsigned int OpFlag = tmpUser->getType(); //Get the oper flag
|
||||
bool Admin = AdFlag < operLevel::SMTLEVEL;
|
||||
|
||||
if((Admin) && (AdFlag <= OpFlag))
|
||||
{
|
||||
bot->Notice(theClient,"You can't suspend a user who has a higher or equal "
|
||||
"level to your own");
|
||||
return false;
|
||||
}
|
||||
else if(AdFlag < OpFlag)
|
||||
{
|
||||
bot->Notice(theClient,"You can't suspend a user who has a higher level than "
|
||||
"your own");
|
||||
return false;
|
||||
}
|
||||
if((Admin) && (strcasecmp(tmpAuth->getServer().c_str(),tmpUser->getServer().c_str())))
|
||||
{
|
||||
bot->Notice(theClient,"You can only suspend a user associated with the same server as you");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(bot->isSuspended(tmpUser))
|
||||
{
|
||||
bot->Notice(theClient,"%s is already suspended",st[1].c_str());
|
||||
return false;
|
||||
}
|
||||
//Fill in the suspendtion period according to the user entry
|
||||
unsigned int Units = 1;
|
||||
string Length = st[2];
|
||||
string Un = Length.substr(Length.length() - 1);
|
||||
if(!strcasecmp(Un,"d"))
|
||||
{
|
||||
Units = 24*3600;
|
||||
Length.resize(Length.length()-1);
|
||||
}
|
||||
else if(!strcasecmp(Un,"h"))
|
||||
{
|
||||
Units = 3600;
|
||||
Length.resize(Length.length()-1);
|
||||
}
|
||||
else if(!strcasecmp(Un,"m"))
|
||||
{
|
||||
Units = 60;
|
||||
Length.resize(Length.length()-1);
|
||||
}
|
||||
else if(!strcasecmp(Un,"s"))
|
||||
{
|
||||
Units = 1;
|
||||
Length.resize(Length.length()-1);
|
||||
}
|
||||
unsigned int Len = atoi(Length.c_str()) * Units;
|
||||
if(Len == 0)
|
||||
{
|
||||
bot->Notice(theClient,"Invalid duration!");
|
||||
return false;
|
||||
}
|
||||
unsigned int Level = operLevel::OPERLEVEL;;
|
||||
unsigned int ResPos = 3;
|
||||
if(!strcasecmp(st[3],"-l"))
|
||||
{
|
||||
if(st.size() < 6)
|
||||
{
|
||||
Usage(theClient);
|
||||
return false;
|
||||
}
|
||||
if(!strcasecmp(st[4],"OPER"))
|
||||
{
|
||||
Level = operLevel::OPERLEVEL;
|
||||
}
|
||||
else if(!strcasecmp(st[4],"ADMIN"))
|
||||
{
|
||||
Level = operLevel::ADMINLEVEL;
|
||||
}
|
||||
else if(!strcasecmp(st[4],"SMT"))
|
||||
{
|
||||
Level = operLevel::SMTLEVEL;
|
||||
}
|
||||
else if(!strcasecmp(st[4],"CODER"))
|
||||
{
|
||||
Level = operLevel::CODERLEVEL;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Invalid suspend level must be OPER, ADMIN, SMT or CODER");
|
||||
return false;
|
||||
}
|
||||
if(Level > AdFlag)
|
||||
{
|
||||
bot->Notice(theClient,"You can't suspend at a level higher than your own!");
|
||||
return false;
|
||||
}
|
||||
ResPos = 5;
|
||||
}
|
||||
//Set the suspention and update the db
|
||||
tmpUser->setSuspendExpires(Len + time( 0 ));
|
||||
tmpUser->setSuspendedBy(bot->removeSqlChars(theClient->getRealNickUserHost()));
|
||||
tmpUser->setIsSuspended(true);
|
||||
tmpUser->setSuspendLevel(Level);
|
||||
tmpUser->setSuspendReason(bot->removeSqlChars(st.assemble(ResPos)));
|
||||
if(tmpUser->Update())
|
||||
{
|
||||
bot->Notice(theClient,"%s has been suspended",st[1].c_str());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Error while suspending %s",st[1].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
|
||||
"$Id: TODO,v 1.3 2001/05/31 18:17:59 mrbean_ Exp $"
|
||||
|
||||
[ DONE - 31/05/01 ] - Add flood check for lame users
|
||||
|
||||
[ ] - Add update flags for oper (oper<->admin<->coder)
|
||||
|
||||
[ ] - Add glinechan / badchan
|
||||
|
||||
[ ] - Fix a minor bug in the suspend checking while loging in
|
||||
|
||||
[ ] - Fix a bug in lastcom, not showing the commands in the correct order
|
||||
|
||||
[ ] - Cleanup ... dont need to say how much its needed in here
|
||||
|
||||
- Truncate output of any commands which will flood an oper
|
||||
(access,lastcomm)
|
||||
- chaninfo output should also include human readable time
|
||||
- op command should op the requesting oper if no nicks are provided
|
||||
- same with deop
|
||||
- scangline doesn't work
|
||||
- "help translate" needs extra space between syntax and description (or is
|
||||
it just my terminal?)
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* TRANSLATECommand.cc
|
||||
* Translates a numeric to a nick
|
||||
*
|
||||
* 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: TRANSLATECommand.cc,v 1.14 2005/01/12 03:50:29 dan_karrels Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "Network.h"
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: TRANSLATECommand.cc,v 1.14 2005/01/12 03:50:29 dan_karrels Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
// translate yyxxx
|
||||
bool TRANSLATECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() != 2 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
iClient* Target = Network->findClient( st[ 1 ] ) ;
|
||||
|
||||
if( NULL == Target )
|
||||
{
|
||||
bot->Notice( theClient, "Unable to find numeric %s\n",
|
||||
st[ 1 ].c_str() ) ;
|
||||
return true ;
|
||||
}
|
||||
bot->MsgChanLog("TRANSLATE %s\n",st.assemble(1).c_str());
|
||||
|
||||
iServer* theServer = Network->findServer( Target->getIntYY() ) ;
|
||||
if( NULL == theServer )
|
||||
{
|
||||
elog << "TRANSLATECommand> Unable to find server\n" ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
if((Target->isModeR()) && (Target->isModeX()))
|
||||
{
|
||||
bot->Notice( theClient, "%s is %s (%s) on server %s",
|
||||
st[ 1 ].c_str(),
|
||||
Target->getNickUserHost().c_str(),
|
||||
Target->getRealNickUserHost().c_str(),
|
||||
theServer->getName().c_str() ) ;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
bot->Notice( theClient, "%s is %s on server %s",
|
||||
st[ 1 ].c_str(),
|
||||
Target->getNickUserHost().c_str(),
|
||||
theServer->getName().c_str() ) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* UNJUPECommand.cc
|
||||
* UNJupitur a 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: UNJUPECommand.cc,v 1.3 2006/09/26 17:36:01 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <new>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "iServer.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: UNJUPECommand.cc,v 1.3 2006/09/26 17:36:01 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool UNJUPECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// The server name to be juped must have at least 1 '.'
|
||||
if( st[1].length() > server::MaxName)
|
||||
{
|
||||
bot->Notice( theClient, "Bogus server name" ) ;
|
||||
return false ;
|
||||
}
|
||||
bot->MsgChanLog("UNJUPE %s\n",st.assemble(1).c_str());
|
||||
|
||||
iServer* Server;
|
||||
|
||||
if(string::npos != st[ 1 ].find_first_of( '*' ))
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, but you must give a full server name when juping!");
|
||||
return false;
|
||||
}
|
||||
else if(string::npos == st[ 1 ].find_first_of( '.' ))
|
||||
{
|
||||
bot->Notice( theClient, "Bogus server name" ) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
Server = Network->findServerName(st[1]);
|
||||
if(!Server)
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, but i can't find that server!");
|
||||
return false;
|
||||
}
|
||||
if(!Server->isJupe())
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, but the server is not juped!");
|
||||
return false;
|
||||
}
|
||||
server->DetachServer(Server);
|
||||
|
||||
|
||||
return true ;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* UNMODERATECommand.cc
|
||||
* Cause the bot to unmoderate 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: UNMODERATECommand.cc,v 1.14 2006/09/26 17:36:01 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "Network.h"
|
||||
#include "Constants.h"
|
||||
#include "ccBadChannel.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: UNMODERATECommand.cc,v 1.14 2006/09/26 17:36:01 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool UNMODERATECommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
if(st[1].size() > channel::MaxName)
|
||||
{
|
||||
bot->Notice(theClient,"Channel name can't be more than %d characters",
|
||||
channel::MaxName);
|
||||
}
|
||||
|
||||
bot->MsgChanLog("UNMODERATE %s\n",st.assemble(1).c_str());
|
||||
|
||||
ccBadChannel* Chan = bot->isBadChannel(st[1]);
|
||||
if(Chan)
|
||||
{
|
||||
bot->Notice(theClient,"Sorry, but you can't change modes in "
|
||||
"this channel because: %s",
|
||||
Chan->getReason().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
Channel* theChan = Network->findChannel( st[ 1 ] ) ;
|
||||
if( NULL == theChan )
|
||||
{
|
||||
bot->Notice( theClient, "Unable to find channel %s\n",
|
||||
st[ 1 ].c_str() ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
if(!theChan->getMode(Channel::MODE_M))
|
||||
{
|
||||
bot->Notice( theClient,"Channel %s is not moderated",
|
||||
st[ 1 ].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
bot->Mode( theChan, "-m", string(), true );
|
||||
|
||||
return true ;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* UNSUSPENDCommand.cc
|
||||
* Unsuspend 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: UNSUSPENDCommand.cc,v 1.14 2006/09/26 17:36:01 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: UNSUSPENDCommand.cc,v 1.14 2006/09/26 17:36:01 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool UNSUSPENDCommand::Exec( iClient* theClient, const string& Message)
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
//Fetch the user record from the database
|
||||
//ccUser *tmpUser = bot->GetUser(st[1]);
|
||||
ccUser* tmpUser = bot->GetOper(bot->removeSqlChars(st[1]));
|
||||
|
||||
if(!tmpUser)
|
||||
{
|
||||
bot->Notice(theClient,"%s isn't on my access list",st[1].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
ccUser* tmpAuth = bot->IsAuth(theClient->getCharYYXXX());
|
||||
if(!tmpAuth)
|
||||
{ //we should never get here
|
||||
return false;
|
||||
}
|
||||
bot->MsgChanLog("UNSUSPEND %s\n",st.assemble(1).c_str());
|
||||
|
||||
unsigned int AdFlag = tmpAuth->getType(); //Get the admin flag
|
||||
unsigned int OpFlag = tmpUser->getType(); //Get the oper flag
|
||||
bool Admin = AdFlag < operLevel::SMTLEVEL;
|
||||
|
||||
if((Admin) && (AdFlag <= OpFlag))
|
||||
{
|
||||
bot->Notice(theClient,"You can't unsuspend a user who has a higher or equal "
|
||||
"access level than you.");
|
||||
return false;
|
||||
}
|
||||
else if(AdFlag < OpFlag)
|
||||
{
|
||||
bot->Notice(theClient,"You can't unsuspend a user who has a higher level "
|
||||
"than you.");
|
||||
return false;
|
||||
}
|
||||
if((Admin) && (strcasecmp(tmpAuth->getServer().c_str(),tmpUser->getServer().c_str())))
|
||||
{
|
||||
bot->Notice(theClient,"You can only unsuspend a user that is associated with "
|
||||
"the same server as you");
|
||||
return false;
|
||||
}
|
||||
if(tmpUser->getSuspendLevel() > AdFlag)
|
||||
{
|
||||
bot->Notice(theClient,"The suspend level is set to a higher level than yours");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!(bot->isSuspended(tmpUser)))
|
||||
{
|
||||
bot->Notice(theClient,"%s is not suspended",st[1].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
//Remove the suspention and update the database
|
||||
tmpUser->setSuspendExpires(0);
|
||||
tmpUser->setIsSuspended(false);
|
||||
tmpUser->setSuspendedBy("");
|
||||
tmpUser->setSuspendReason("");
|
||||
tmpUser->setSuspendLevel(0);
|
||||
if(tmpUser->Update())
|
||||
{
|
||||
bot->Notice(theClient,"%s has been unsuspended",st[1].c_str());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice(theClient,"Error while unsuspending %s",st[1].c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
/**
|
||||
* USERINFOCommand.cc
|
||||
* Shows all kind of stuff about 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: USERINFOCommand.cc,v 1.13 2009/07/25 18:12:34 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "commLevels.h"
|
||||
#include "misc.h"
|
||||
#include "match.h"
|
||||
#include "Network.h"
|
||||
#include "ccontrol_generic.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: USERINFOCommand.cc,v 1.13 2009/07/25 18:12:34 hidden1 Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool USERINFOCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
|
||||
StringTokenizer st( Message ) ;
|
||||
|
||||
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage(theClient);
|
||||
return true;
|
||||
}
|
||||
|
||||
bot->MsgChanLog("USERINFO %s\n",st.assemble(1).c_str());
|
||||
|
||||
ccUser* tempUser;
|
||||
string Name;
|
||||
string Level;
|
||||
string Email;
|
||||
string Server;
|
||||
bool Suspended;
|
||||
char GetLogs[4];
|
||||
char GetLag[4];
|
||||
char NeedOp[4];
|
||||
string SuspendedBy;
|
||||
string SuspendReason;
|
||||
time_t SuspendExpires;
|
||||
unsigned int Id;
|
||||
unsigned int SuspendLevel;
|
||||
string SLevel;
|
||||
ccontrol::usersConstIterator ptr;
|
||||
for(ptr = bot->usersMap_begin();ptr != bot->usersMap_end();++ptr)
|
||||
{
|
||||
tempUser = ptr->second;
|
||||
if(!(match(st[1],tempUser->getUserName())) ||
|
||||
!(match(st[1],tempUser->getServer())))
|
||||
{
|
||||
Name.assign(tempUser->getUserName());
|
||||
Server.assign(tempUser->getServer());
|
||||
Email.assign(tempUser->getEmail());
|
||||
SuspendExpires = tempUser->getSuspendExpires();
|
||||
if((tempUser->getIsSuspended()) && (SuspendExpires > ::time(0)))
|
||||
{
|
||||
Suspended = true;
|
||||
SuspendedBy.assign(tempUser->getSuspendedBy());
|
||||
SuspendReason.assign(tempUser->getSuspendReason());
|
||||
SuspendLevel=tempUser->getSuspendLevel();
|
||||
if(SuspendLevel == operLevel::OPERLEVEL)
|
||||
{
|
||||
SLevel.assign("OPER");
|
||||
}
|
||||
else if(SuspendLevel == operLevel::ADMINLEVEL)
|
||||
{
|
||||
SLevel.assign("ADMIN");
|
||||
}
|
||||
else if(SuspendLevel == operLevel::SMTLEVEL)
|
||||
{
|
||||
SLevel.assign("SMT");
|
||||
}
|
||||
else if(SuspendLevel == operLevel::CODERLEVEL)
|
||||
{
|
||||
SLevel.assign("CODER");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Suspended = false;
|
||||
}
|
||||
if (tempUser->isUhs())
|
||||
{
|
||||
Level.assign("UHS");
|
||||
}
|
||||
else if(tempUser->isOper())
|
||||
{
|
||||
Level.assign("OPER");
|
||||
}
|
||||
else if(tempUser->isAdmin())
|
||||
{
|
||||
Level.assign("ADMIN");
|
||||
}
|
||||
else if(tempUser->isSmt())
|
||||
{
|
||||
Level.assign("SMT");
|
||||
}
|
||||
else
|
||||
Level.assign("CODER");
|
||||
|
||||
if(tempUser->getLogs())
|
||||
{
|
||||
sprintf(GetLogs,"YES");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(GetLogs,"NO");
|
||||
}
|
||||
|
||||
if(tempUser->getLag())
|
||||
{
|
||||
sprintf(GetLag,"YES");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(GetLag,"NO");
|
||||
}
|
||||
|
||||
if(tempUser->getNeedOp())
|
||||
{
|
||||
sprintf(NeedOp,"YES");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(NeedOp,"NO");
|
||||
}
|
||||
Id=tempUser->getID();
|
||||
if(tempUser->getClient())
|
||||
{
|
||||
bot->Notice(theClient,"User Name: %s Currently logged in from: %s",
|
||||
Name.c_str(),
|
||||
tempUser->getClient()->getRealNickUserHost().c_str());
|
||||
}
|
||||
else
|
||||
bot->Notice(theClient,"User Name: %s Not logged in",Name.c_str());
|
||||
if(Email == "")
|
||||
Email.assign("Not assigned");
|
||||
bot->Notice(theClient,"Level: %s E-mail: %s",Level.c_str(),Email.c_str());
|
||||
if(Server == "")
|
||||
Server.assign("Not assigned");
|
||||
bot->Notice(theClient,"Server: %s",Server.c_str());
|
||||
if(Suspended)
|
||||
{
|
||||
bot->Notice(theClient,"User was suspended by: %s until %s",
|
||||
SuspendedBy.c_str(),
|
||||
bot->convertToAscTime(SuspendExpires));
|
||||
bot->Notice(theClient,"Reason: %s",SuspendReason.c_str());
|
||||
bot->Notice(theClient,"Level: %s",SLevel.c_str());
|
||||
}
|
||||
bot->Notice(theClient,"User Flags: GetLogs \002%s\002 NeedOp \002%s\002 GetLag \002%s\002",
|
||||
GetLogs,NeedOp,GetLag);
|
||||
if ((st.size() > 2) && (!strcasecmp(st[2],"-cl")))
|
||||
{
|
||||
bot->Notice(theClient, "Password last changed: %s ago", (tempUser->getPassChangeTS() == 0) ? "N/A" : Ago(tempUser->getPassChangeTS()));
|
||||
/* commands list requested */
|
||||
bot->Notice(theClient,"Commands available to this user:");
|
||||
string cmdList = "";
|
||||
for (ccontrol::constCommandIterator cmdptr = bot->command_begin();
|
||||
cmdptr != bot->command_end(); ++cmdptr)
|
||||
{
|
||||
int ComLevel = cmdptr->second->getFlags();
|
||||
if ((ComLevel & commandLevel::flg_NOLOGIN) || ((tempUser) && (tempUser->gotAccess(cmdptr->second))))
|
||||
{
|
||||
cmdList += (cmdptr->second->getName() + " ");
|
||||
if (cmdList.size() > 80)
|
||||
{
|
||||
bot->Notice(theClient, "%s", cmdList.c_str());
|
||||
cmdList.assign("");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!cmdList.empty())
|
||||
bot->Notice(theClient, "%s", cmdList.c_str());
|
||||
}
|
||||
bot->Notice(theClient,"-----===== End of userinfo for %s =====-----",Name.c_str());
|
||||
}
|
||||
}
|
||||
bot->Notice(theClient,"End of userinfo");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* UserFilter.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.
|
||||
*
|
||||
= */
|
||||
#include "ccUser.h"
|
||||
|
||||
#include <vector>
|
||||
using std::vector;
|
||||
|
||||
#ifndef USERFILTER_H
|
||||
#define USERFILTER_H
|
||||
|
||||
namespace gnuworld {
|
||||
|
||||
namespace uworld {
|
||||
|
||||
class UserFilter {
|
||||
public:
|
||||
virtual bool filter(ccUser*) = 0;
|
||||
};
|
||||
|
||||
class UserFilterComposite : public UserFilter{
|
||||
|
||||
private:
|
||||
vector<UserFilter*> filters;
|
||||
public:
|
||||
void addFilter(UserFilter* filter) {
|
||||
filters.push_back(filter);
|
||||
}
|
||||
|
||||
virtual bool filter(ccUser* user) {
|
||||
for(unsigned int i=0; i < filters.size();++i) {
|
||||
if(!filters[i]->filter(user)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class ByLevelsUserFilter : public UserFilter {
|
||||
private:
|
||||
unsigned int levels;
|
||||
public:
|
||||
ByLevelsUserFilter() {
|
||||
this->levels = 0;
|
||||
}
|
||||
|
||||
void addLevel(unsigned int userLevel) {
|
||||
levels |= (1 << userLevel);
|
||||
}
|
||||
|
||||
virtual bool filter(ccUser* user) {
|
||||
return (levels & (1 << user->getType())) > 0 ;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif /* USERFILTER_H */
|
||||
@@ -0,0 +1,206 @@
|
||||
/**
|
||||
* WHOISCommand.cc
|
||||
* Gives varius data about 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: WHOISCommand.cc,v 1.25 2005/08/24 13:36:32 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "Network.h"
|
||||
#include "ccontrol.h"
|
||||
#include "CControlCommands.h"
|
||||
#include "StringTokenizer.h"
|
||||
#include "ip.h"
|
||||
#include "ccontrol_generic.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: WHOISCommand.cc,v 1.25 2005/08/24 13:36:32 kewlio Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
using std::endl ;
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
// whois nickname
|
||||
bool WHOISCommand::Exec( iClient* theClient, const string& Message )
|
||||
{
|
||||
StringTokenizer st( Message ) ;
|
||||
if( st.size() < 2 )
|
||||
{
|
||||
Usage( theClient ) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
iClient* Target = Network->findNick( st[ 1 ] ) ;
|
||||
if( NULL == Target )
|
||||
{
|
||||
bot->Notice( theClient, "Unable to find nick: %s", st[ 1 ].c_str() ) ;
|
||||
return true ;
|
||||
}
|
||||
bot->MsgChanLog("WHOIS %s\n",st.assemble(1).c_str());
|
||||
|
||||
iServer* targetServer = Network->findServer( Target->getIntYY() ) ;
|
||||
if( NULL == targetServer )
|
||||
{
|
||||
elog << "WHOISCommand> Unable to find server: "
|
||||
<< Target->getIntYY() << endl ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
if((Target->isModeX()) && (Target->isModeR()))
|
||||
{
|
||||
bot->Notice( theClient, "%s is %s (%s) [%s]",
|
||||
st[ 1 ].c_str(),
|
||||
Target->getNickUserHost().c_str(),
|
||||
Target->getRealNickUserHost().c_str(),
|
||||
xIP(Target->getIP() ).GetNumericIP().c_str()
|
||||
) ;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
bot->Notice( theClient, "%s is %s [%s]",
|
||||
st[ 1 ].c_str(),
|
||||
Target->getNickUserHost().c_str(),
|
||||
xIP(Target->getIP() ).GetNumericIP().c_str()
|
||||
) ;
|
||||
}
|
||||
|
||||
if (Target->getConnectTime() > 0)
|
||||
{
|
||||
/* we have a client connection timestamp, display it */
|
||||
bot->Notice(theClient, "%s has been connected for %s [since %ld]",
|
||||
st[1].c_str(),
|
||||
Ago(Target->getConnectTime()),
|
||||
Target->getConnectTime());
|
||||
}
|
||||
|
||||
if (Target->isModeR())
|
||||
{
|
||||
/* client is authed - show it here */
|
||||
bot->Notice(theClient, "%s is authed as [%s]",
|
||||
st[1].c_str(),
|
||||
Target->getAccount().c_str());
|
||||
}
|
||||
|
||||
bot->Notice( theClient, "Numeric: %s, UserModes: %s, Server Numeric: %s (%s)",
|
||||
Target->getCharYYXXX().c_str(),
|
||||
Target->getStringModes().c_str(),
|
||||
targetServer->getCharYY().c_str(),
|
||||
targetServer->getName().c_str()
|
||||
) ;
|
||||
|
||||
if( Target->isOper() )
|
||||
{
|
||||
bot->Notice( theClient, "%s is an IRCoperator",
|
||||
st[ 1 ].c_str() ) ;
|
||||
}
|
||||
|
||||
if(Target->getMode(iClient::MODE_SERVICES))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
vector< string > channels ;
|
||||
string curChannel ;
|
||||
string::size_type curPlace;
|
||||
string tChannel;
|
||||
char curChar[10];
|
||||
gnuworld::Channel* theChannel;
|
||||
gnuworld::ChannelUser* theChannelUser;
|
||||
bool hasCC; //Channel has control codes
|
||||
|
||||
for( iClient::const_channelIterator ptr = Target->channels_begin() ;
|
||||
ptr != Target->channels_end() ; ++ptr )
|
||||
{
|
||||
curChannel = "";
|
||||
theChannel = (*ptr);
|
||||
theChannelUser = theChannel->findUser(Target);
|
||||
tChannel = theChannel->getName();
|
||||
string chanUserModes = string();
|
||||
if(theChannelUser->getMode(gnuworld::ChannelUser::MODE_V)) chanUserModes = "+";
|
||||
if(theChannelUser->getMode(gnuworld::ChannelUser::MODE_H)) chanUserModes += "%";
|
||||
if(theChannelUser->getMode(gnuworld::ChannelUser::MODE_O)) chanUserModes += "@";
|
||||
tChannel = chanUserModes + tChannel;
|
||||
|
||||
hasCC = false;
|
||||
for(curPlace = 0; curPlace < tChannel.size();++curPlace)
|
||||
{
|
||||
if(((tChannel[curPlace] > 1) && (tChannel[curPlace] < 4))
|
||||
|| (tChannel[curPlace] == 15)
|
||||
|| ((tChannel[curPlace] > 27) && (tChannel[curPlace] < 33))
|
||||
|| (tChannel[curPlace] == 22)
|
||||
|| (tChannel[curPlace] == char(160))
|
||||
|| ((unsigned(tChannel[curPlace]) > 252)
|
||||
&& (unsigned(tChannel[curPlace]) <= 254)))
|
||||
{
|
||||
hasCC = true;
|
||||
sprintf(curChar,"%d",tChannel[curPlace]);
|
||||
curChannel += string("\x16^") + curChar + string("\x16");
|
||||
}
|
||||
else
|
||||
{
|
||||
curChannel += tChannel[curPlace];
|
||||
}
|
||||
}
|
||||
|
||||
if(hasCC)
|
||||
{
|
||||
curChannel = string("*") + curChannel;
|
||||
}
|
||||
|
||||
channels.push_back( curChannel) ;
|
||||
}
|
||||
|
||||
if( channels.empty() )
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
|
||||
string chanNames ;
|
||||
for( vector< string >::size_type i = 0 ; i < channels.size() ; i++ )
|
||||
{
|
||||
if ((chanNames.size() + channels[i].size()) > 410)
|
||||
{
|
||||
/* need to split lines up */
|
||||
bot->Notice(theClient, "On channels: %s", chanNames.c_str());
|
||||
chanNames = "";
|
||||
}
|
||||
chanNames += channels[ i ] ;
|
||||
if( (i + 1) < channels.size() )
|
||||
{
|
||||
chanNames += ", " ;
|
||||
}
|
||||
}
|
||||
|
||||
bot->Notice( theClient, "On channels: %s", chanNames.c_str() ) ;
|
||||
bot->Notice( theClient, "* - Channel contains control codes" );
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
* ccBadChannel.cc
|
||||
* Holds a bad channel record
|
||||
*
|
||||
* 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: ccBadChannel.cc,v 1.7 2007/08/28 16:10:03 dan_karrels Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include "dbHandle.h"
|
||||
#include "ccontrol.h"
|
||||
#include "ccBadChannel.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: ccBadChannel.cc,v 1.7 2007/08/28 16:10:03 dan_karrels Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
ccBadChannel::ccBadChannel(dbHandle* SQLDb, unsigned int Place)
|
||||
{
|
||||
Name = SQLDb->GetValue(Place,0);
|
||||
Reason = SQLDb->GetValue(Place,1);
|
||||
AddedBy = SQLDb->GetValue(Place,2);
|
||||
}
|
||||
|
||||
bool ccBadChannel::Update(dbHandle* SQLDb)
|
||||
{
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << "UPDATE BadChannels SET Reason = '"
|
||||
<< ccontrol::removeSqlChars(Reason)
|
||||
<< "', AddedBy = '"
|
||||
<< ccontrol::removeSqlChars(AddedBy)
|
||||
<< "' WHERE lower(Name) = '"
|
||||
<< ccontrol::removeSqlChars(string_lower(Name)) << "'"
|
||||
<< ends;
|
||||
|
||||
elog << "ccBadChannel::Update> "
|
||||
<< theQuery.str()
|
||||
<< endl;
|
||||
|
||||
if( !SQLDb->Exec( theQuery ) )
|
||||
//if (PGRES_COMMAND_OK != status)
|
||||
{
|
||||
elog << "ccBadChannel::Update SQL ERROR : "
|
||||
<< SQLDb->ErrorMessage() << endl;
|
||||
return false;
|
||||
}
|
||||
//delete[] theQuery.str() ;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ccBadChannel::Delete(dbHandle* SQLDb)
|
||||
{
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << "DELETE FROM BadChannels WHERE lower(Name) = '"
|
||||
<< ccontrol::removeSqlChars(string_lower(Name)) << "'"
|
||||
<< ends;
|
||||
|
||||
elog << "ccBadChannel::Delete> "
|
||||
<< theQuery.str()
|
||||
<< endl;
|
||||
|
||||
if( !SQLDb->Exec( theQuery ) )
|
||||
//if (PGRES_COMMAND_OK != status)
|
||||
{
|
||||
elog << "ccBadChannel::Delete SQL ERROR : "
|
||||
<< SQLDb->ErrorMessage() << endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ccBadChannel::Insert(dbHandle* SQLDb)
|
||||
{
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << "INSERT INTO BadChannels (Name,Reason,AddedBy) VALUES ('"
|
||||
<< ccontrol::removeSqlChars(Name) << "','"
|
||||
<< ccontrol::removeSqlChars(Reason)
|
||||
<< "','"
|
||||
<< ccontrol::removeSqlChars(AddedBy)
|
||||
<< "')"
|
||||
<< ends;
|
||||
|
||||
elog << "ccBadChannel::Insert> "
|
||||
<< theQuery.str()
|
||||
<< endl;
|
||||
|
||||
if( !SQLDb->Exec( theQuery ) )
|
||||
//if (PGRES_COMMAND_OK != status)
|
||||
{
|
||||
elog << "ccBadChannel::Insert SQL ERROR : "
|
||||
<< SQLDb->ErrorMessage() << endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* ccBadChannel.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: ccBadChannel.h,v 1.3 2007/08/28 16:10:03 dan_karrels Exp $
|
||||
*/
|
||||
|
||||
#ifndef __CCBADCHANNEL_H_
|
||||
#define __CCBADCHANNEL_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "dbHandle.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
class ccBadChannel
|
||||
{
|
||||
public:
|
||||
ccBadChannel() {}
|
||||
|
||||
ccBadChannel(dbHandle* , unsigned int);
|
||||
|
||||
ccBadChannel(const string& _Name, const string& _Reason ,
|
||||
const string& _AddedBy) : Name(_Name),
|
||||
Reason(_Reason),AddedBy(_AddedBy) {};
|
||||
|
||||
~ccBadChannel(){}
|
||||
|
||||
bool Update(dbHandle*);
|
||||
|
||||
bool Insert(dbHandle*);
|
||||
|
||||
bool Delete(dbHandle*);
|
||||
|
||||
const string& getName() const
|
||||
{ return Name; }
|
||||
|
||||
const string& getReason() const
|
||||
{ return Reason; }
|
||||
|
||||
const string& getAddedBy() const
|
||||
{ return AddedBy; }
|
||||
|
||||
void setName(const string& _Name)
|
||||
{ Name = _Name; }
|
||||
|
||||
void setReason(const string& _Reason)
|
||||
{ Reason = _Reason; }
|
||||
|
||||
void setAddedBy(const string& _AddedBy)
|
||||
{ AddedBy = _AddedBy; }
|
||||
|
||||
private:
|
||||
|
||||
string Name;
|
||||
|
||||
string Reason;
|
||||
|
||||
string AddedBy;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,556 @@
|
||||
/**
|
||||
* ccException.cc
|
||||
* Exception class
|
||||
*
|
||||
* 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: ccException.cc,v 1.17 2008/12/27 23:34:31 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <ctime>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ELog.h"
|
||||
#include "misc.h"
|
||||
#include "match.h"
|
||||
#include "ccException.h"
|
||||
#include "ccontrol.h"
|
||||
#include "gnuworld_config.h"
|
||||
#include "StringTokenizer.h"
|
||||
|
||||
RCSTAG( "$Id: ccException.cc,v 1.17 2008/12/27 23:34:31 hidden1 Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
using std::endl ;
|
||||
using std::stringstream ;
|
||||
using std::ends ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
//extern unsigned int dbConnected;
|
||||
unsigned int ccException::numAllocated = 0;
|
||||
unsigned int ccShellco::numAllocated = 0;
|
||||
unsigned int ccShellnb::numAllocated = 0;
|
||||
|
||||
ccException::ccException(dbHandle* _SQLDb)
|
||||
: Host(string()),
|
||||
Connections(0),
|
||||
AddedBy(string()),
|
||||
AddedOn(0),
|
||||
Reason(string()),
|
||||
SQLDb(_SQLDb)
|
||||
{
|
||||
++numAllocated;
|
||||
}
|
||||
|
||||
ccException::~ccException()
|
||||
{
|
||||
--numAllocated;
|
||||
}
|
||||
|
||||
void ccShellnb::setCidr( const string& _cidr )
|
||||
{
|
||||
cidr = _cidr;
|
||||
StringTokenizer st(cidr,'/');
|
||||
if (st.size() == 2) {
|
||||
cidr1 = st[0];
|
||||
cidr2 = atoi(st[1].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
int ccException::loadData(const string& HostName)
|
||||
{
|
||||
|
||||
static const char Main[] = "SELECT * FROM Exceptions WHERE lower(Host) = '";
|
||||
|
||||
if((!dbConnected) || !(SQLDb))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << Main
|
||||
<< ccontrol::removeSqlChars(string_lower(HostName))
|
||||
<< "'"
|
||||
<< ends;
|
||||
|
||||
elog << "ccException::loadData> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
// TODO: Isn't this impossible?
|
||||
if( !SQLDb->Exec( theQuery, true ) && (SQLDb->Tuples() > 0) )
|
||||
//if( (PGRES_TUPLES_OK != status) && (SQLDb->Tuples() > 0) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Host = SQLDb->GetValue(0,0);
|
||||
Connections = atoi(SQLDb->GetValue(0,1).c_str());
|
||||
AddedBy = SQLDb->GetValue(0,2);
|
||||
AddedOn = atoi(SQLDb->GetValue(0,3).c_str());
|
||||
Reason = SQLDb->GetValue(0,4);
|
||||
|
||||
theQuery.str("");
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
int ccException::updateData()
|
||||
{
|
||||
static const char *Main = "UPDATE Exceptions SET AddedBy = '";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << Main
|
||||
<< ccontrol::removeSqlChars(AddedBy)
|
||||
<< "', Connections = "
|
||||
<< Connections
|
||||
<< ", AddedOn = "
|
||||
<< AddedOn
|
||||
<< ", Reason = '"
|
||||
<< ccontrol::removeSqlChars(Reason)
|
||||
<< "' WHERE lower(Host) = '"
|
||||
<< ccontrol::removeSqlChars(string_lower(Host)) << "'"
|
||||
<< ends;
|
||||
|
||||
elog << "ccException::Update> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( SQLDb->Exec( theQuery ) )
|
||||
//if( PGRES_COMMAND_OK == status )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
elog << "ccException::Update> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool ccException::Insert()
|
||||
{
|
||||
static const char *quer = "INSERT INTO exceptions(host,connections,addedby,addedon,reason) VALUES ('";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream query;
|
||||
query << quer
|
||||
<< ccontrol::removeSqlChars(Host) << "',"
|
||||
<< Connections
|
||||
<< ",'" << ccontrol::removeSqlChars(AddedBy)
|
||||
<< "'," << AddedOn
|
||||
<< ",' " << ccontrol::removeSqlChars(Reason)
|
||||
<< "')" << ends;
|
||||
|
||||
elog << "ccException::Insert> "
|
||||
<< query.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( !SQLDb->Exec( query ) )
|
||||
//if(PGRES_COMMAND_OK != status)
|
||||
{
|
||||
elog << "ccException::Insert> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
//return (PGRES_COMMAND_OK == status) ;
|
||||
}
|
||||
|
||||
bool ccException::Delete()
|
||||
{
|
||||
static const char *quer = "DELETE FROM exceptions WHERE host = '";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream query;
|
||||
query << quer
|
||||
<< ccontrol::removeSqlChars(Host) << "'"
|
||||
<< ends;
|
||||
|
||||
elog << "ccException::delException> "
|
||||
<< query.str().c_str()
|
||||
<< endl ;
|
||||
|
||||
if( !SQLDb->Exec( query ) )
|
||||
//if( PGRES_COMMAND_OK != status )
|
||||
{
|
||||
elog << "ccException::findException> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
ccShellco::ccShellco(dbHandle* _SQLDb)
|
||||
{
|
||||
++numAllocated;
|
||||
maxlimit = 0;
|
||||
active = 1;
|
||||
AddedOn = ::time(0);
|
||||
ModOn = ::time(0);
|
||||
SQLDb = _SQLDb;
|
||||
}
|
||||
|
||||
|
||||
ccShellco::~ccShellco()
|
||||
{
|
||||
--numAllocated;
|
||||
}
|
||||
|
||||
ccShellnb::ccShellnb(dbHandle* _SQLDb)
|
||||
{
|
||||
++numAllocated;
|
||||
shellco = 0;
|
||||
AddedOn = ::time(0);
|
||||
SQLDb = _SQLDb;
|
||||
companyid = 0;
|
||||
cidr2 = 32;
|
||||
}
|
||||
|
||||
|
||||
ccShellnb::~ccShellnb()
|
||||
{
|
||||
--numAllocated;
|
||||
}
|
||||
|
||||
|
||||
int ccShellco::loadData(const string& Name)
|
||||
{
|
||||
int i = 0;
|
||||
static const char Main[] = "SELECT name,id,AddedBy,AddedOn,lastmodby,lastmodon,maxlimit,active FROM ShellCompanies WHERE name = '";
|
||||
|
||||
if((!dbConnected) || !(SQLDb))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << Main
|
||||
<< ccontrol::removeSqlChars(Name)
|
||||
<< "'"
|
||||
<< ends;
|
||||
|
||||
elog << "ccShellco::loadData> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
// TODO: Isn't this impossible?
|
||||
if( !SQLDb->Exec( theQuery, true ) && (SQLDb->Tuples() > 0) )
|
||||
//if( (PGRES_TUPLES_OK != status) && (SQLDb->Tuples() > 0) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
setName(SQLDb->GetValue(i,0));
|
||||
setID(atoi(SQLDb->GetValue(i,1).c_str()));
|
||||
setAddedBy(SQLDb->GetValue(i,2)) ;
|
||||
setAddedOn(static_cast< time_t >(
|
||||
atoi( SQLDb->GetValue(i,3).c_str() ) )) ;
|
||||
setModBy(SQLDb->GetValue(i,4)) ;
|
||||
setModOn(static_cast< time_t >(
|
||||
atoi( SQLDb->GetValue(i,5).c_str() ) )) ;
|
||||
setLimit(atoi(SQLDb->GetValue(i,6).c_str()));
|
||||
setActive(atoi(SQLDb->GetValue(i,7).c_str()));
|
||||
|
||||
theQuery.str("");
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int ccShellco::updateData()
|
||||
{
|
||||
static const char *Main = "UPDATE ShellCompanies SET AddedBy = '";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << Main
|
||||
<< ccontrol::removeSqlChars(AddedBy)
|
||||
<< "', maxlimit = "
|
||||
<< maxlimit
|
||||
<< ", addedon = "
|
||||
<< AddedOn
|
||||
<< ", active = "
|
||||
<< active
|
||||
<< ", lastmodon = "
|
||||
<< ModOn
|
||||
<< ", lastmodby = '"
|
||||
<< ccontrol::removeSqlChars(ModBy)
|
||||
<< "', name = '"
|
||||
<< ccontrol::removeSqlChars(Name)
|
||||
<< "' WHERE id = "
|
||||
<< id
|
||||
<< ends;
|
||||
|
||||
elog << "ccShellco::Update> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( SQLDb->Exec( theQuery ) )
|
||||
//if( PGRES_COMMAND_OK == status )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
elog << "ccShellco::Update> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int ccShellnb::updateData()
|
||||
{
|
||||
static const char *Main = "UPDATE ShellNetblocks SET AddedBy = '";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << Main
|
||||
<< ccontrol::removeSqlChars(AddedBy)
|
||||
<< "', addedon = "
|
||||
<< AddedOn
|
||||
<< ", companyid = "
|
||||
<< companyid
|
||||
<< " WHERE cidr = '"
|
||||
<< ccontrol::removeSqlChars(cidr) << "'"
|
||||
<< ends;
|
||||
|
||||
elog << "ccShellco::Update> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( SQLDb->Exec( theQuery ) )
|
||||
//if( PGRES_COMMAND_OK == status )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
elog << "ccShellco::Update> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool ccShellco::Insert()
|
||||
{
|
||||
static const char *quer = "INSERT INTO ShellCompanies(name,maxlimit,addedby,addedon,lastmodby,lastmodon) VALUES ('";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream query;
|
||||
query << quer
|
||||
<< ccontrol::removeSqlChars(Name) << "',"
|
||||
<< maxlimit
|
||||
<< ",'" << ccontrol::removeSqlChars(AddedBy)
|
||||
<< "'," << AddedOn
|
||||
<< ",'" << ccontrol::removeSqlChars(ModBy)
|
||||
<< "'," << ModOn
|
||||
<< ")" << ends;
|
||||
|
||||
elog << "ccShellco::Insert> "
|
||||
<< query.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( !SQLDb->Exec( query ) )
|
||||
//if(PGRES_COMMAND_OK != status)
|
||||
{
|
||||
elog << "ccShellco::Insert> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
//return (PGRES_COMMAND_OK == status) ;
|
||||
}
|
||||
|
||||
bool ccShellnb::Insert()
|
||||
{
|
||||
static const char *quer = "INSERT INTO ShellNetblocks(cidr,companyid,addedby,addedon) VALUES ('";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream query;
|
||||
query << quer
|
||||
<< ccontrol::removeSqlChars(cidr) << "',"
|
||||
<< companyid
|
||||
<< ",'" << ccontrol::removeSqlChars(AddedBy)
|
||||
<< "'," << AddedOn
|
||||
<< ")" << ends;
|
||||
|
||||
elog << "ccShellnb::Insert> "
|
||||
<< query.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( !SQLDb->Exec( query ) )
|
||||
//if(PGRES_COMMAND_OK != status)
|
||||
{
|
||||
elog << "ccShellnb::Insert> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
//return (PGRES_COMMAND_OK == status) ;
|
||||
}
|
||||
|
||||
bool ccShellco::Delete()
|
||||
{
|
||||
static const char *quer = "DELETE FROM ShellCompanies WHERE name = '";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream query;
|
||||
query << quer
|
||||
<< ccontrol::removeSqlChars(Name) << "'"
|
||||
<< ends;
|
||||
|
||||
elog << "ccShellco::delException> "
|
||||
<< query.str().c_str()
|
||||
<< endl ;
|
||||
|
||||
if( !SQLDb->Exec( query ) )
|
||||
//if( PGRES_COMMAND_OK != status )
|
||||
{
|
||||
elog << "ccShellco::findException> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ccShellnb::Delete()
|
||||
{
|
||||
static const char *quer = "DELETE FROM ShellNetblocks WHERE cidr = '";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream query;
|
||||
query << quer
|
||||
<< ccontrol::removeSqlChars(cidr) << "'"
|
||||
<< ends;
|
||||
|
||||
elog << "ccShellnb::delException> "
|
||||
<< query.str().c_str()
|
||||
<< endl ;
|
||||
|
||||
if( !SQLDb->Exec( query ) )
|
||||
//if( PGRES_COMMAND_OK != status )
|
||||
{
|
||||
elog << "ccShellnb::findException> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ccShellnb::set24Mask()
|
||||
{
|
||||
int client_addr[4] = { 0 };
|
||||
struct in_addr tmp_ip;
|
||||
unsigned long mask_ip;
|
||||
int i = 0;
|
||||
string cidrmask;
|
||||
string tIP;
|
||||
char *client_ip;
|
||||
|
||||
tIP = cidr1;
|
||||
|
||||
if (cidr2 <= 24) {
|
||||
str24 = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
/* CIDR checks */
|
||||
/* convert ip to longip */
|
||||
i = sscanf(tIP.c_str(), "%d.%d.%d.%d", &client_addr[0], &client_addr[1], &client_addr[2], &client_addr[3]);
|
||||
mask_ip = ntohl((client_addr[0]) | (client_addr[1] << 8) | (client_addr[2] << 16) | (client_addr[3] << 24));
|
||||
/* bitshift ip to strip the last (32-cidrmask) bits (leaving a mask for the ip) */
|
||||
for (i = 0; i < (32-24); i++) {
|
||||
/* right shift */
|
||||
mask_ip >>= 1;
|
||||
}
|
||||
for (i = 0; i < (32-24); i++) {
|
||||
/* left shift */
|
||||
mask_ip <<= 1;
|
||||
}
|
||||
/* convert longip back to ip */
|
||||
mask_ip = htonl(mask_ip);
|
||||
tmp_ip.s_addr = mask_ip;
|
||||
client_ip = inet_ntoa(tmp_ip);
|
||||
|
||||
str24 = string(client_ip);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
/**
|
||||
* ccException.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: ccException.h,v 1.13 2009/07/26 18:30:37 mrbean_ Exp $
|
||||
*/
|
||||
|
||||
#ifndef __CCEXCEPTION_H
|
||||
#define __CCEXCEPTION_H "$Id: ccException.h,v 1.13 2009/07/26 18:30:37 mrbean_ Exp $"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#include "dbHandle.h"
|
||||
|
||||
#include "match.h"
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
class ccException
|
||||
{
|
||||
public:
|
||||
ccException(dbHandle* _SQLDb);
|
||||
virtual ~ccException();
|
||||
|
||||
inline bool operator==( const string& ExceptionHost ) const
|
||||
{ return (!strcasecmp( Host, ExceptionHost )
|
||||
|| !match(Host.c_str(),ExceptionHost.c_str())) ; }
|
||||
|
||||
inline const string& getHost() const
|
||||
{ return Host; }
|
||||
|
||||
inline const int& getConnections() const
|
||||
{ return Connections; }
|
||||
|
||||
inline const string& getAddedBy() const
|
||||
{ return AddedBy; }
|
||||
|
||||
inline time_t getAddedOn() const
|
||||
{ return AddedOn; }
|
||||
|
||||
inline const string& getReason() const
|
||||
{ return Reason; }
|
||||
|
||||
inline void setHost( const string& _Host )
|
||||
{ Host = _Host; }
|
||||
|
||||
inline void setConnections( const int _Connections )
|
||||
{ Connections = _Connections; }
|
||||
|
||||
inline void setAddedBy( const string& _AddedBy)
|
||||
{ AddedBy = _AddedBy; }
|
||||
|
||||
inline void setAddedOn( const time_t _AddedOn )
|
||||
{ AddedOn = _AddedOn; }
|
||||
|
||||
inline void setReason( const string& _Reason )
|
||||
{ Reason = _Reason; }
|
||||
|
||||
inline void setSqldb(dbHandle* _SQLDb)
|
||||
{ SQLDb = _SQLDb; }
|
||||
|
||||
int loadData(const string& Host);
|
||||
|
||||
int updateData();
|
||||
|
||||
bool Insert();
|
||||
|
||||
bool Delete();
|
||||
|
||||
static unsigned int numAllocated;
|
||||
|
||||
protected:
|
||||
|
||||
string Host;
|
||||
int Connections;
|
||||
string AddedBy;
|
||||
time_t AddedOn;
|
||||
string Reason;
|
||||
dbHandle* SQLDb;
|
||||
|
||||
};
|
||||
|
||||
class ccShellco
|
||||
{
|
||||
public:
|
||||
ccShellco(dbHandle* _SQLDb);
|
||||
virtual ~ccShellco();
|
||||
|
||||
|
||||
inline bool isActive() const
|
||||
{ return (active == 1 ? true : false); }
|
||||
inline const string& getName() const
|
||||
{ return Name; }
|
||||
|
||||
inline const int& getID() const
|
||||
{ return id; }
|
||||
|
||||
inline const int& getLimit() const
|
||||
{ return maxlimit; }
|
||||
|
||||
inline const string& getAddedBy() const
|
||||
{ return AddedBy; }
|
||||
|
||||
inline time_t getAddedOn() const
|
||||
{ return AddedOn; }
|
||||
|
||||
inline const string& getModBy() const
|
||||
{ return ModBy; }
|
||||
|
||||
inline time_t getModOn() const
|
||||
{ return ModOn; }
|
||||
|
||||
inline void setName( const string& _Name )
|
||||
{ Name = _Name; }
|
||||
|
||||
inline void setLimit( const int _maxlimit )
|
||||
{ maxlimit = _maxlimit; }
|
||||
|
||||
inline void setID( const int _id )
|
||||
{ id = _id; }
|
||||
|
||||
inline void setAddedBy( const string& _AddedBy)
|
||||
{ AddedBy = _AddedBy; }
|
||||
|
||||
inline void setAddedOn( const time_t _AddedOn )
|
||||
{ AddedOn = _AddedOn; }
|
||||
|
||||
inline void setModBy( const string& _ModBy)
|
||||
{ ModBy = _ModBy; }
|
||||
|
||||
inline void setModOn( const time_t _ModOn )
|
||||
{ ModOn = _ModOn; }
|
||||
|
||||
inline void setActive( const int _active)
|
||||
{ active = _active; }
|
||||
|
||||
inline void setSqldb(dbHandle* _SQLDb)
|
||||
{ SQLDb = _SQLDb; }
|
||||
|
||||
int loadData(const string& Name);
|
||||
|
||||
int updateData();
|
||||
|
||||
bool Insert();
|
||||
|
||||
bool Delete();
|
||||
|
||||
static unsigned int numAllocated;
|
||||
|
||||
protected:
|
||||
|
||||
int id;
|
||||
string Name;
|
||||
int maxlimit;
|
||||
int active;
|
||||
string AddedBy;
|
||||
time_t AddedOn;
|
||||
string ModBy;
|
||||
time_t ModOn;
|
||||
dbHandle* SQLDb;
|
||||
|
||||
};
|
||||
|
||||
class ccShellnb
|
||||
{
|
||||
public:
|
||||
ccShellnb(dbHandle* _SQLDb);
|
||||
virtual ~ccShellnb();
|
||||
|
||||
inline bool operator==( const string& ExceptionHost ) const
|
||||
{ return (!strcasecmp( cidr, ExceptionHost )
|
||||
|| !match(cidr.c_str(),ExceptionHost.c_str())) ; }
|
||||
|
||||
inline const string& getCidr() const
|
||||
{ return cidr; }
|
||||
|
||||
inline const string& getCidr1() const
|
||||
{ return cidr1; }
|
||||
|
||||
inline const int& getCompanyID() const
|
||||
{ return companyid; }
|
||||
|
||||
inline const int& getCidr2() const
|
||||
{ return cidr2; }
|
||||
|
||||
inline const string& getAddedBy() const
|
||||
{ return AddedBy; }
|
||||
|
||||
inline time_t getAddedOn() const
|
||||
{ return AddedOn; }
|
||||
|
||||
inline const string& get24Mask() const
|
||||
{ return str24; }
|
||||
|
||||
inline void setShellco( ccShellco* _shellco )
|
||||
{ shellco = _shellco; }
|
||||
|
||||
inline void setCompanyID( const int _companyid )
|
||||
{ companyid = _companyid; }
|
||||
|
||||
inline void setAddedBy( const string& _AddedBy)
|
||||
{ AddedBy = _AddedBy; }
|
||||
|
||||
inline void setAddedOn( const time_t _AddedOn )
|
||||
{ AddedOn = _AddedOn; }
|
||||
|
||||
void setCidr( const string& _cidr );
|
||||
bool set24Mask();
|
||||
|
||||
inline void setSqldb(dbHandle* _SQLDb)
|
||||
{ SQLDb = _SQLDb; }
|
||||
|
||||
|
||||
ccShellco* shellco;
|
||||
|
||||
int updateData();
|
||||
|
||||
bool Insert();
|
||||
|
||||
bool Delete();
|
||||
|
||||
static unsigned int numAllocated;
|
||||
|
||||
protected:
|
||||
|
||||
int companyid;
|
||||
string cidr;
|
||||
string cidr1;
|
||||
int cidr2;
|
||||
string AddedBy;
|
||||
time_t AddedOn;
|
||||
string str24;
|
||||
dbHandle* SQLDb;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif // __CCEXCEPTION_H
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* ccFloodData.cc
|
||||
* flood data class
|
||||
*
|
||||
* 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: ccFloodData.cc,v 1.8 2005/01/12 03:50:29 dan_karrels Exp $
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include <ctime>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "ccFloodData.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: ccFloodData.cc,v 1.8 2005/01/12 03:50:29 dan_karrels Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
using std::endl ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
unsigned int ccFloodData::numAllocated = 0;
|
||||
|
||||
ccFloodData::ccFloodData(const string &_Numeric)
|
||||
: Numeric(_Numeric),
|
||||
Logins(0),
|
||||
IgnoreExpires( 0 ),
|
||||
Points(0),
|
||||
lastMessage(0)
|
||||
|
||||
{
|
||||
++numAllocated;
|
||||
}
|
||||
|
||||
ccFloodData::~ccFloodData()
|
||||
{
|
||||
--numAllocated;
|
||||
}
|
||||
|
||||
bool ccFloodData::addPoints(unsigned int _Points)
|
||||
{
|
||||
//Check if the flood points needs to be reset
|
||||
if((signed)flood::RESET_TIME < (::time(0) - lastMessage))
|
||||
Points = 0;
|
||||
|
||||
//Update the new flood points
|
||||
Points += _Points;
|
||||
lastMessage = ::time(0);
|
||||
|
||||
//We have updated everything, check if the user needs to be silenced
|
||||
|
||||
return (Points > flood::FLOOD_POINTS);
|
||||
}
|
||||
|
||||
}
|
||||
} //Namespace Gnuworld
|
||||
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* ccFlood.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: ccFloodData.h,v 1.6 2009/07/26 18:30:38 mrbean_ Exp $
|
||||
*/
|
||||
|
||||
#ifndef __CCFLOODDATA_H
|
||||
#define __CCFLOODDATA_H "$Id: ccFloodData.h,v 1.6 2009/07/26 18:30:38 mrbean_ Exp $"
|
||||
|
||||
#define IGNORE_NOT_FOUND -1
|
||||
#define IGNORE_REMOVED -2
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <ctime>
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
class ccFloodData
|
||||
{
|
||||
public:
|
||||
ccFloodData(const string &);
|
||||
|
||||
virtual ~ccFloodData();
|
||||
//Mehods for getting info
|
||||
|
||||
inline const string getNumeric() const
|
||||
{ return Numeric; }
|
||||
|
||||
inline const int& getLogins() const
|
||||
{ return Logins; }
|
||||
|
||||
inline time_t getIgnoreExpires() const
|
||||
{ return IgnoreExpires; }
|
||||
inline const string getIgnoredHost() const
|
||||
{ return IgnoredHost; }
|
||||
|
||||
//Methods for setting info
|
||||
|
||||
inline void setNumeric( string _Numeric )
|
||||
{ Numeric = _Numeric; }
|
||||
|
||||
inline void setLogins( int _Logins )
|
||||
{ Logins = _Logins; }
|
||||
|
||||
inline void add_Login()
|
||||
{ Logins++; }
|
||||
|
||||
inline void resetIgnore()
|
||||
{ IgnoreExpires = 0; IgnoredHost="" ; }
|
||||
|
||||
inline void resetLogins()
|
||||
{ Logins = 0; }
|
||||
|
||||
inline void setIgnoreExpires(time_t _Expires)
|
||||
{ IgnoreExpires =_Expires; }
|
||||
|
||||
inline void setIgnoredHost(string _Host)
|
||||
{ IgnoredHost =_Host; }
|
||||
|
||||
static unsigned int numAllocated;
|
||||
|
||||
inline unsigned int getPoints() const
|
||||
{ return Points; }
|
||||
|
||||
inline time_t getLastMessage() const
|
||||
{ return lastMessage; }
|
||||
|
||||
bool addPoints(unsigned int );
|
||||
|
||||
protected:
|
||||
string Numeric;
|
||||
|
||||
int Logins;
|
||||
|
||||
time_t IgnoreExpires;
|
||||
|
||||
string IgnoredHost;
|
||||
|
||||
//Holds the flood points a user has
|
||||
unsigned int Points;
|
||||
|
||||
//The last time we got data from this user
|
||||
time_t lastMessage;
|
||||
}; // class ccFloodData
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
#endif // __CCFLOODDATA_H
|
||||
@@ -0,0 +1,300 @@
|
||||
/**
|
||||
* ccGline.cc
|
||||
* Gline class
|
||||
*
|
||||
* 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: ccGline.cc,v 1.22 2007/08/28 16:10:06 dan_karrels Exp $
|
||||
*/
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <ctime>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "dbHandle.h"
|
||||
#include "ELog.h"
|
||||
#include "misc.h"
|
||||
#include "ccGline.h"
|
||||
#include "ccontrol.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: ccGline.cc,v 1.22 2007/08/28 16:10:06 dan_karrels Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
using std::endl ;
|
||||
using std::stringstream ;
|
||||
using std::ends ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
unsigned int ccGline::numAllocated = 0;
|
||||
|
||||
ccGline::ccGline(dbHandle* _SQLDb)
|
||||
: Id(),
|
||||
AddedBy(),
|
||||
AddedOn( 0 ),
|
||||
Expires( 0 ),
|
||||
LastUpdated( 0 ),
|
||||
Reason(),
|
||||
SQLDb( _SQLDb )
|
||||
{
|
||||
++numAllocated;
|
||||
}
|
||||
|
||||
ccGline::~ccGline()
|
||||
{
|
||||
--numAllocated;
|
||||
}
|
||||
|
||||
bool ccGline::Insert()
|
||||
{
|
||||
//First we gotta make sure, there is no old gline in the database
|
||||
static const char *Del = "DELETE FROM glines WHERE lower(host) = '";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
stringstream delQuery;
|
||||
delQuery << Del
|
||||
<< ccontrol::removeSqlChars(string_lower(Host)) << "'"
|
||||
<< ends;
|
||||
|
||||
|
||||
if( !SQLDb->Exec( delQuery ) )
|
||||
//if( PGRES_COMMAND_OK != status )
|
||||
{
|
||||
elog << "ccGline::DeleteOnInsert> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
//Now insert the new one
|
||||
static const char *Main = "INSERT INTO Glines (Host,AddedBy,AddedOn,ExpiresAt,LastUpdated,Reason) VALUES ('";
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << Main
|
||||
<< ccontrol::removeSqlChars(Host) << "','"
|
||||
<< ccontrol::removeSqlChars(AddedBy) << "',"
|
||||
<< AddedOn << ","
|
||||
<< Expires << ","
|
||||
<< LastUpdated << ",'"
|
||||
<< ccontrol::removeSqlChars(Reason) << "')"
|
||||
<< ends;
|
||||
|
||||
elog << "Gline::Insert::sqlQuery> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( SQLDb->Exec( theQuery ) )
|
||||
//if( PGRES_COMMAND_OK == status )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
elog << "ccontrol::Gline::Insert> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool ccGline::Update()
|
||||
{
|
||||
if(atoi(Id.c_str()) == -1) //saveGlines was false when this gline was added
|
||||
{
|
||||
return true;
|
||||
}
|
||||
static const char *Main = "UPDATE Glines SET Id = '";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << Main
|
||||
<< Id
|
||||
<< "', Host = '"
|
||||
<< ccontrol::removeSqlChars(Host)
|
||||
<< "', AddedBy = '"
|
||||
<< ccontrol::removeSqlChars(AddedBy)
|
||||
<< "', AddedOn = "
|
||||
<< AddedOn
|
||||
<< ",ExpiresAt = "
|
||||
<< Expires
|
||||
<< ",LastUpdated = "
|
||||
<< LastUpdated
|
||||
<< ",Reason = '"
|
||||
<< ccontrol::removeSqlChars(Reason) << "'"
|
||||
<< " WHERE Id = " << Id
|
||||
<< ends;
|
||||
|
||||
elog << "ccontrol::Gline::Update> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( SQLDb->Exec( theQuery ) )
|
||||
//if( PGRES_COMMAND_OK == status )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
elog << "ccontrol::Gline::Update> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ccGline::loadData(int GlineId)
|
||||
{
|
||||
static const char *Main = "SELECT Id,Host,AddedBy,AddedOn,ExpiresAt,LastUpdated,Reason FROM glines WHERE Id = ";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << Main
|
||||
<< GlineId
|
||||
<< ends;
|
||||
|
||||
elog << "ccontrol::glineload> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( !SQLDb->Exec( theQuery, true ) )
|
||||
//if( PGRES_TUPLES_OK != status )
|
||||
{
|
||||
elog << "ccGline::load> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
if(SQLDb->Tuples() < 6)
|
||||
return false;
|
||||
Id = SQLDb->GetValue(0,0);
|
||||
Host = SQLDb->GetValue(0,1);
|
||||
AddedBy = SQLDb->GetValue(0,2) ;
|
||||
AddedOn = static_cast< time_t >( unsigned(
|
||||
atoi( SQLDb->GetValue(0,3).c_str() ) )) ;
|
||||
Expires = static_cast< time_t >( unsigned(
|
||||
atoi( SQLDb->GetValue(0,4).c_str() ) )) ;
|
||||
LastUpdated = static_cast< time_t >( unsigned(
|
||||
atoi( SQLDb->GetValue(0,5).c_str() ) )) ;
|
||||
Reason = SQLDb->GetValue(0,6);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ccGline::loadData( const string & HostName)
|
||||
{
|
||||
static const char *Main = "SELECT Id,Host,AddedBy,AddedOn,ExpiresAt,LastUpdated,Reason FROM glines WHERE Host = '";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << Main
|
||||
<< ccontrol::removeSqlChars(HostName.c_str())
|
||||
<< "'" << ends;
|
||||
|
||||
elog << "ccontrol::loadData> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( !SQLDb->Exec( theQuery, true ) )
|
||||
//if( PGRES_TUPLES_OK != status )
|
||||
{
|
||||
elog << "ccGline::loadData> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
if(SQLDb->Tuples() == 0) //If no gline was found
|
||||
return false;
|
||||
Id = SQLDb->GetValue(0,0);
|
||||
Host = SQLDb->GetValue(0,1);
|
||||
AddedBy = SQLDb->GetValue(0,2) ;
|
||||
AddedOn = static_cast< time_t >( atoi( SQLDb->GetValue(0,3).c_str() ) ) ;
|
||||
Expires = static_cast< time_t >( atoi( SQLDb->GetValue(0,4).c_str() ) ) ;
|
||||
LastUpdated = static_cast< time_t >( atoi( SQLDb->GetValue(0,5).c_str() ) ) ;
|
||||
Reason = SQLDb->GetValue(0,6);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ccGline::Delete()
|
||||
{
|
||||
if(atoi(Id.c_str()) == -1) //saveGlines was false when this gline was added
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static const char *Main = "DELETE FROM glines WHERE Id = ";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << Main
|
||||
<< Id
|
||||
<< ends;
|
||||
|
||||
elog << "ccontrol::glineDelete> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( SQLDb->Exec( theQuery ) )
|
||||
//if( PGRES_COMMAND_OK == status )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
elog << "ccGline::ccDelete> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} //Namespace Gnuworld
|
||||
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* ccGline.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: ccGline.h,v 1.15 2007/08/28 16:10:07 dan_karrels Exp $
|
||||
*/
|
||||
|
||||
#ifndef __CCGLINE_H
|
||||
#define __CCGLINE_H "$Id: ccGline.h,v 1.15 2007/08/28 16:10:07 dan_karrels Exp $"
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#include "dbHandle.h"
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
using std::list ;
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
class ccGline
|
||||
{
|
||||
public:
|
||||
|
||||
ccGline(dbHandle*);
|
||||
|
||||
virtual ~ccGline();
|
||||
//Mehods for getting info
|
||||
|
||||
inline const string& getId() const
|
||||
{ return Id; }
|
||||
|
||||
inline const string& getHost() const
|
||||
{ return Host; }
|
||||
|
||||
inline const string& getAddedBy() const
|
||||
{ return AddedBy; }
|
||||
|
||||
inline const time_t& getAddedOn() const
|
||||
{ return AddedOn; }
|
||||
|
||||
inline const time_t& getExpires() const
|
||||
{ return Expires; }
|
||||
|
||||
inline const time_t& getLastUpdated() const
|
||||
{ return LastUpdated; }
|
||||
|
||||
inline const string& getReason() const
|
||||
{ return Reason; }
|
||||
|
||||
|
||||
//Methods for setting info
|
||||
|
||||
inline void setId( const string& _Id )
|
||||
{ Id = _Id; }
|
||||
|
||||
inline void setHost( const string& _Host )
|
||||
{ Host = _Host; }
|
||||
|
||||
inline void setAddedBy( const string& _AddedBy )
|
||||
{ AddedBy = _AddedBy; }
|
||||
|
||||
inline void setAddedOn( const time_t& _AddedOn )
|
||||
{ AddedOn = _AddedOn; }
|
||||
|
||||
inline void setExpires( const time_t& _Expires )
|
||||
{ Expires = _Expires; }
|
||||
|
||||
inline void setLastUpdated( const time_t& _LastUpdated )
|
||||
{ LastUpdated = _LastUpdated; }
|
||||
|
||||
inline void setReason( const string& _Reason )
|
||||
{ Reason = _Reason; }
|
||||
|
||||
inline void setSqldb(dbHandle* _SQLDb)
|
||||
{ SQLDb = _SQLDb; }
|
||||
|
||||
//Methods for updating
|
||||
|
||||
bool Insert();
|
||||
|
||||
bool Update();
|
||||
|
||||
bool loadData( int );
|
||||
|
||||
bool loadData( const string & );
|
||||
|
||||
bool Delete();
|
||||
|
||||
static unsigned int numAllocated;
|
||||
|
||||
protected:
|
||||
string Id;
|
||||
string Host;
|
||||
string AddedBy;
|
||||
time_t AddedOn;
|
||||
time_t Expires;
|
||||
time_t LastUpdated;
|
||||
string Reason;
|
||||
dbHandle* SQLDb;
|
||||
|
||||
}; // class ccGline
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
#endif // __CCGLINE_H
|
||||
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* ccLog.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: ccLog.cc,v 1.10 2007/09/12 13:36:02 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include "ccLog.h"
|
||||
#include <fstream>
|
||||
#include "ELog.h"
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "StringTokenizer.h"
|
||||
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: ccLog.cc,v 1.10 2007/09/12 13:36:02 kewlio Exp $" ) ;
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
bool ccLog::Save(fstream& out)
|
||||
{
|
||||
|
||||
if(out.bad())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
char time[20];
|
||||
time[0] = '\0';
|
||||
sprintf(time,"%ld",(long)::time(0));
|
||||
string Line = time;
|
||||
Line += " ";
|
||||
string::size_type pos;
|
||||
for(pos = 0; pos < User.size();++pos)
|
||||
{
|
||||
if(User[pos] != '\\')
|
||||
{
|
||||
Line += User[pos];
|
||||
}
|
||||
else
|
||||
{
|
||||
Line += "\\\\";
|
||||
}
|
||||
}
|
||||
Line += ' ';
|
||||
for(pos = 0; pos < Host.size();++pos)
|
||||
{
|
||||
if(Host[pos] != '\\')
|
||||
{
|
||||
Line += Host[pos];
|
||||
}
|
||||
else
|
||||
{
|
||||
Line += "\\\\";
|
||||
}
|
||||
}
|
||||
Line += ' ';
|
||||
for(pos = 0; pos < Desc.size();++pos)
|
||||
{
|
||||
if(Desc[pos] != '\\')
|
||||
{
|
||||
Line += Desc[pos];
|
||||
}
|
||||
else
|
||||
{
|
||||
Line += "\\\\";
|
||||
}
|
||||
}
|
||||
|
||||
/*out << Time
|
||||
<< " " << User.c_str()
|
||||
<< " " << Host.c_str()
|
||||
<< " " << Desc.c_str()
|
||||
<< "\n";*/
|
||||
out << Line << "\n";
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool ccLog::Load(fstream& in)
|
||||
{
|
||||
|
||||
if((in.bad()) || (in.eof()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
char read[513];
|
||||
if(!in.getline(read,512))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
StringTokenizer st(read);
|
||||
if(st.size() < 4)
|
||||
{
|
||||
elog << "invalid number of args in logs!" << endl;
|
||||
return false;
|
||||
}
|
||||
Time = atoi(st[0].c_str());
|
||||
User = st[1];
|
||||
Host = st[2];
|
||||
CommandName = st[3];
|
||||
Desc = st.assemble(3);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* ccLog.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: ccLog.h,v 1.5 2003/06/28 01:21:19 dan_karrels Exp $
|
||||
*/
|
||||
|
||||
#ifndef __CCLOG_H_
|
||||
#define __CCLOG_H_
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <sys/time.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
class ccLog
|
||||
{
|
||||
|
||||
public:
|
||||
ccLog() : Time(0) , User() , Host(), CommandName() , Desc() {}
|
||||
|
||||
ccLog(time_t _Time, string _User, string _Host
|
||||
,string _CommName , string _Desc)
|
||||
: Time(_Time), User(_User) , Host(_Host)
|
||||
,CommandName(_CommName), Desc(_Desc)
|
||||
{}
|
||||
|
||||
ccLog(fstream& in)
|
||||
{
|
||||
Load(in);
|
||||
}
|
||||
|
||||
time_t Time;
|
||||
|
||||
string User;
|
||||
|
||||
string Host;
|
||||
|
||||
string CommandName;
|
||||
|
||||
string Desc;
|
||||
|
||||
bool Save(fstream& out);
|
||||
|
||||
bool Load(fstream& in);
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,294 @@
|
||||
/**
|
||||
* ccServer.cc
|
||||
* Server class
|
||||
*
|
||||
* 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: ccServer.cc,v 1.18 2009/08/06 02:59:24 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <ctime>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "dbHandle.h"
|
||||
#include "ELog.h"
|
||||
#include "misc.h"
|
||||
#include "ccServer.h"
|
||||
#include "ccontrol.h"
|
||||
#include "Constants.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: ccServer.cc,v 1.18 2009/08/06 02:59:24 hidden1 Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
using std::endl ;
|
||||
using std::stringstream ;
|
||||
using std::ends ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
unsigned int ccServer::numAllocated = 0;
|
||||
|
||||
ccServer::ccServer(dbHandle* _SQLDb)
|
||||
: Name(),
|
||||
Uplink(),
|
||||
Numeric(),
|
||||
LastConnected( 0 ),
|
||||
LastSplitted( 0 ),
|
||||
SplitReason( "" ),
|
||||
Version( "Unknown" ),
|
||||
AddedOn( ::time(0) ),
|
||||
LastUpdated( 0 ),
|
||||
NetServer(NULL),
|
||||
ReportMissing(true),
|
||||
LagTime(0),
|
||||
LastLagReport(0),
|
||||
LastLagSent(0),
|
||||
LastLagRecv(0),
|
||||
SQLDb( _SQLDb )
|
||||
{
|
||||
++numAllocated;
|
||||
}
|
||||
|
||||
ccServer::~ccServer()
|
||||
{
|
||||
--numAllocated;
|
||||
}
|
||||
|
||||
bool ccServer::Insert()
|
||||
{
|
||||
static const char *Main = "INSERT INTO servers (Name,LastUplink,LastNumeric,LastConnected,SplitedOn,SplitReason,Version,AddedOn,LastUpdated,ReportMissing) VALUES ('";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
stringstream theQuery;
|
||||
theQuery << Main
|
||||
<< ccontrol::removeSqlChars(Name) <<"','"
|
||||
<< ccontrol::removeSqlChars(Uplink) << "','"
|
||||
<< ccontrol::removeSqlChars(Numeric) << "',"
|
||||
<< LastConnected << ","
|
||||
<< LastSplitted
|
||||
<< ",'" << ccontrol::removeSqlChars(SplitReason)
|
||||
<< "','" << ccontrol::removeSqlChars(Version)
|
||||
<< "'," << AddedOn
|
||||
<< "," << LastUpdated
|
||||
<< ","
|
||||
<< (ReportMissing ? "'t'" : "'n'")
|
||||
<< ")"
|
||||
<< ends;
|
||||
|
||||
elog << "ccontrol::Server::Insert::sqlQuery> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( SQLDb->Exec( theQuery ) )
|
||||
//if( PGRES_COMMAND_OK == status )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
elog << "ccontrol::Server::Insert> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool ccServer::Update()
|
||||
{
|
||||
static const char *Main = "UPDATE servers SET Name = '";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << Main
|
||||
<< ccontrol::removeSqlChars(Name)
|
||||
<< "', LastUplink = '"
|
||||
<< ccontrol::removeSqlChars(Uplink)
|
||||
<< "', LastNumeric = '"
|
||||
<< ccontrol::removeSqlChars(Numeric)
|
||||
<< "', LastConnected = "
|
||||
<< LastConnected
|
||||
<< ",SplitedOn = "
|
||||
<< LastSplitted
|
||||
<< ", SplitReason = '"
|
||||
<< ccontrol::removeSqlChars(SplitReason)
|
||||
<< "', Version = '"
|
||||
<< ccontrol::removeSqlChars(Version)
|
||||
<< "', AddedOn = "
|
||||
<< AddedOn
|
||||
<< ", LastUpdated = "
|
||||
<< LastUpdated
|
||||
<< ", ReportMissing = "
|
||||
<< (ReportMissing ? "'t'" : "'n'")
|
||||
<< " WHERE lower(Name) = '" << string_lower(Name)
|
||||
<< "'" << ends;
|
||||
|
||||
elog << "ccontrol::Server::Update> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( SQLDb->Exec( theQuery ) )
|
||||
//if( PGRES_COMMAND_OK == status )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
elog << "ccontrol::Server::Update> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ccServer::loadData(string ServerName)
|
||||
{
|
||||
//static const char *Main = "SELECT name,lastuplink,lastconnected,splitedon,lastnumeric,splitreason FROM servers WHERE
|
||||
//lower(Name) = '";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << server::Query
|
||||
<< "Where lower(Name) = '"
|
||||
<< ccontrol::removeSqlChars(string_lower(ServerName))
|
||||
<< "'" << ends;
|
||||
|
||||
elog << "ccontrol::Server::LoadData> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( !SQLDb->Exec( theQuery, true ) )
|
||||
//if( PGRES_TUPLES_OK != status )
|
||||
{
|
||||
elog << "ccontrol::Server> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
return loadDataFromDB();
|
||||
|
||||
}
|
||||
|
||||
bool ccServer::loadNumericData(string ServNumeric)
|
||||
{
|
||||
/*static const char *Main = "SELECT name,lastuplink,lastconnected,splitedon,lastnumeric,SplitReason FROM servers WHERE
|
||||
LastNumeric = '";*/
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << server::Query
|
||||
<< "Where LastNumeric = '"
|
||||
<< ccontrol::removeSqlChars(ServNumeric)
|
||||
<< "'" << ends;
|
||||
|
||||
elog << "ccontrol::Server::LoadNumericData> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( !SQLDb->Exec( theQuery, true ) )
|
||||
//if( PGRES_TUPLES_OK != status )
|
||||
{
|
||||
elog << "ccontrol::Server> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
return loadDataFromDB();
|
||||
|
||||
}
|
||||
|
||||
bool ccServer::loadDataFromDB(int place)
|
||||
{
|
||||
|
||||
if(SQLDb->Tuples() == 0 )
|
||||
return false;
|
||||
Name = SQLDb->GetValue(place,0);
|
||||
Uplink = SQLDb->GetValue(0,1);
|
||||
LastConnected = static_cast< time_t >(
|
||||
atoi( SQLDb->GetValue(place,2).c_str() ) ) ;
|
||||
LastSplitted = static_cast< time_t >(
|
||||
atoi( SQLDb->GetValue(place,3).c_str() ) ) ;
|
||||
Numeric = SQLDb->GetValue(place,4);
|
||||
SplitReason = SQLDb->GetValue(place,5);
|
||||
Version = SQLDb->GetValue(place,6);
|
||||
AddedOn = static_cast< time_t >(
|
||||
atoi( SQLDb->GetValue(place,7).c_str() ) ) ;
|
||||
LastUpdated = static_cast< time_t >(
|
||||
atoi( SQLDb->GetValue(place,8).c_str() ) ) ;
|
||||
ReportMissing = (!strcasecmp(SQLDb->GetValue(place,9),"t") ? true : false);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool ccServer::Delete()
|
||||
{
|
||||
static const char *Main = "DELETE FROM servers WHERE lower(Name) = '";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << Main
|
||||
<< ccontrol::removeSqlChars(string_lower(Name))
|
||||
<< "'" << ends;
|
||||
|
||||
elog << "ccontrol::Server::Delete> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( !SQLDb->Exec( theQuery ) )
|
||||
//if( PGRES_COMMAND_OK != status )
|
||||
{
|
||||
elog << "ccontrol::Server::Delete> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} //Namespace Gnuworld
|
||||
@@ -0,0 +1,181 @@
|
||||
/**
|
||||
* ccServer.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: ccServer.h,v 1.11 2009/07/26 18:30:38 mrbean_ Exp $
|
||||
*/
|
||||
|
||||
#ifndef __CCSERVER_H
|
||||
#define __CCSERVER_H "$Id: ccServer.h,v 1.11 2009/07/26 18:30:38 mrbean_ Exp $"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#include "dbHandle.h"
|
||||
#include "iServer.h"
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
class ccServer
|
||||
{
|
||||
public:
|
||||
ccServer(dbHandle*);
|
||||
virtual ~ccServer();
|
||||
//Mehods for getting info
|
||||
|
||||
inline const string& getName() const
|
||||
{ return Name; }
|
||||
|
||||
inline const string& getUplink() const
|
||||
{ return Uplink; }
|
||||
|
||||
inline const string& getLastNumeric() const
|
||||
{ return Numeric; }
|
||||
|
||||
inline const time_t& getLastConnected() const
|
||||
{ return LastConnected; }
|
||||
|
||||
inline const time_t& getLastSplitted() const
|
||||
{ return LastSplitted; }
|
||||
|
||||
inline const time_t& getLagTime() const
|
||||
{ return LagTime; }
|
||||
|
||||
inline const time_t& getLastLagReport() const
|
||||
{ return LastLagReport; }
|
||||
|
||||
inline const time_t& getLastLagSent() const
|
||||
{ return LastLagSent; }
|
||||
|
||||
inline const time_t& getLastLagRecv() const
|
||||
{ return LastLagRecv; }
|
||||
|
||||
inline const string& getSplitReason() const
|
||||
{ return SplitReason; }
|
||||
|
||||
inline const string& getVersion() const
|
||||
{ return Version; }
|
||||
|
||||
inline const time_t& getAddedOn() const
|
||||
{ return AddedOn; }
|
||||
|
||||
inline const time_t& getLastUpdated() const
|
||||
{ return LastUpdated; }
|
||||
|
||||
inline const iServer* getNetServer() const
|
||||
{ return NetServer; }
|
||||
|
||||
inline const bool& getReportMissing() const
|
||||
{ return ReportMissing; }
|
||||
|
||||
|
||||
//Methods for setting info
|
||||
|
||||
inline void setName( const string& _Name )
|
||||
{ Name = _Name; }
|
||||
|
||||
inline void setUplink( const string& _Uplink )
|
||||
{ Uplink = _Uplink; }
|
||||
|
||||
inline void setLastNumeric( const string& _LastNumeric )
|
||||
{ Numeric = _LastNumeric; }
|
||||
|
||||
inline void setLastConnected( const time_t& _LastConnected )
|
||||
{ LastConnected = _LastConnected; }
|
||||
|
||||
inline void setLastSplitted( const time_t& _LastSplitted )
|
||||
{ LastSplitted = _LastSplitted; }
|
||||
|
||||
inline void setSplitReason( const string& _Reason)
|
||||
{ SplitReason = _Reason; }
|
||||
|
||||
inline void setLagTime( const time_t& _LagTime )
|
||||
{ LagTime = _LagTime; }
|
||||
|
||||
inline void setLastLagReport( const time_t& _LastLagReport )
|
||||
{ LastLagReport = _LastLagReport; }
|
||||
|
||||
inline void setLastLagSent( const time_t& _LastLagSent )
|
||||
{ LastLagSent = _LastLagSent; }
|
||||
|
||||
inline void setLastLagRecv( const time_t& _LastLagRecv )
|
||||
{ LastLagRecv = _LastLagRecv; }
|
||||
|
||||
inline void setVersion( const string& _Version )
|
||||
{ Version = _Version; }
|
||||
|
||||
inline void setAddedOn( const time_t& _AddedOn )
|
||||
{ AddedOn = _AddedOn; }
|
||||
|
||||
inline void setLastUpdated( const time_t& _LastUpdated )
|
||||
{ LastUpdated = _LastUpdated; }
|
||||
|
||||
inline void setNetServer(iServer* NewServer)
|
||||
{ NetServer = NewServer; }
|
||||
|
||||
inline void setReportMissing( const bool _ReportMissing )
|
||||
{ ReportMissing = _ReportMissing; }
|
||||
|
||||
inline void setSqldb(dbHandle* _SQLDb)
|
||||
{ SQLDb = _SQLDb; }
|
||||
|
||||
//Methods for updating
|
||||
|
||||
bool Insert();
|
||||
|
||||
bool Update();
|
||||
|
||||
bool loadData( string );
|
||||
|
||||
bool loadNumericData( string );
|
||||
|
||||
bool loadDataFromDB(int place = 0 );
|
||||
|
||||
bool Delete();
|
||||
|
||||
static unsigned int numAllocated;
|
||||
|
||||
protected:
|
||||
string Name;
|
||||
string Uplink;
|
||||
string Numeric;
|
||||
time_t LastConnected;
|
||||
time_t LastSplitted;
|
||||
string SplitReason;
|
||||
string Version;
|
||||
time_t AddedOn;
|
||||
time_t LastUpdated;
|
||||
iServer* NetServer;
|
||||
bool ReportMissing;
|
||||
time_t LagTime;
|
||||
time_t LastLagReport;
|
||||
time_t LastLagSent;
|
||||
time_t LastLagRecv;
|
||||
dbHandle* SQLDb;
|
||||
|
||||
}; // class ccServer
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
#endif // __CCSERVER_H
|
||||
@@ -0,0 +1,411 @@
|
||||
/**
|
||||
* ccUser.cc
|
||||
* Storage class for accessing user information
|
||||
*
|
||||
* 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: ccUser.cc,v 1.22 2009/07/26 18:30:38 mrbean_ Exp $
|
||||
*/
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "dbHandle.h"
|
||||
#include "ELog.h"
|
||||
#include "misc.h"
|
||||
#include "ccUser.h"
|
||||
#include "commLevels.h"
|
||||
#include "ccontrol.h"
|
||||
#include "gnuworld_config.h"
|
||||
|
||||
RCSTAG( "$Id: ccUser.cc,v 1.22 2009/07/26 18:30:38 mrbean_ Exp $" ) ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string ;
|
||||
using std::endl ;
|
||||
using std::stringstream ;
|
||||
using std::ends ;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
unsigned int ccUser::numAllocated = 0;
|
||||
|
||||
ccUser::ccUser(dbHandle* _SQLDb)
|
||||
: Id( 0 ),
|
||||
Server( "" ),
|
||||
IsSuspended(0),
|
||||
SuspendExpires(0),
|
||||
SuspendLevel(0),
|
||||
SuspendReason(""),
|
||||
Access( 0 ),
|
||||
SAccess( 0 ),
|
||||
Flags( 0 ),
|
||||
IsUhs(0),
|
||||
IsOper(0),
|
||||
IsAdmin(0),
|
||||
IsSmt(0),
|
||||
IsCoder(0),
|
||||
GetLogs(0),
|
||||
GetLag(0),
|
||||
NeedOp(0),
|
||||
Notice(0),
|
||||
Client(NULL),
|
||||
SQLDb( _SQLDb ),
|
||||
PassChangeTS(0)
|
||||
{
|
||||
++numAllocated;
|
||||
}
|
||||
|
||||
ccUser::~ccUser()
|
||||
{
|
||||
--numAllocated;
|
||||
}
|
||||
|
||||
bool ccUser::loadData(const string& Name)
|
||||
{
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static const char Main[] = "SELECT user_id,user_name,password,access,saccess,flags,suspend_expires,suspended_by,server,isSuspended,IsUhs,IsOper,IsAdmin,IsSmt,IsCoder,GetLogs,NeedOp,Email,Suspend_Level,Suspend_Reason,Notice,GetLag,LastPassChangeTS FROM opers WHERE lower(user_name) = '";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << Main
|
||||
<< ccontrol::removeSqlChars(string_lower(Name))
|
||||
<< "'"
|
||||
<< ends;
|
||||
|
||||
elog << "ccUser::loadData> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( SQLDb->Exec( theQuery, true ) && (SQLDb->Tuples() > 0) )
|
||||
//if( (PGRES_TUPLES_OK == status) && (SQLDb->Tuples() > 0) )
|
||||
{
|
||||
GetParm();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ccUser::loadData( const unsigned int Id)
|
||||
{
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static const char Main[] = "SELECT user_id,user_name,password,access,saccess,flags,suspend_expires,suspended_by,server,isSuspended,IsUhs,IsOper,IsAdmin,IsSmt,IsCoder,GetLogs,NeedOp,Email,Suspend_Level,Suspend_Reason,Notice,GetLag,LastPassChangeTS FROM opers WHERE user_id = ";
|
||||
stringstream theQuery;
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
theQuery << Main
|
||||
<< Id
|
||||
<< ';'
|
||||
<< ends;
|
||||
|
||||
elog << "ccontrol::loadData> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( SQLDb->Exec( theQuery, true ) && (SQLDb->Tuples() > 0) )
|
||||
//if( (PGRES_TUPLES_OK == status) && (SQLDb->Tuples() > 0) )
|
||||
{
|
||||
GetParm();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ccUser::GetParm()
|
||||
{
|
||||
Id = atoi(SQLDb->GetValue(0, 0).c_str());
|
||||
UserName = SQLDb->GetValue(0, 1);
|
||||
Password = SQLDb->GetValue(0, 2);
|
||||
Access = atol(SQLDb->GetValue(0, 3).c_str());
|
||||
SAccess = atol(SQLDb->GetValue(0, 4).c_str());
|
||||
Flags = atoi(SQLDb->GetValue(0, 5).c_str());
|
||||
SuspendExpires = atoi(SQLDb->GetValue(0,6).c_str());
|
||||
SuspendedBy = SQLDb->GetValue(0,7);
|
||||
Server = SQLDb->GetValue(0,8);
|
||||
IsSuspended = (!strcasecmp(SQLDb->GetValue(0,9),"t") ? 1 : 0 );
|
||||
IsUhs = (!strcasecmp(SQLDb->GetValue(0,10),"t") ? 1 : 0 );
|
||||
IsOper = (!strcasecmp(SQLDb->GetValue(0,11),"t") ? 1 : 0 );
|
||||
IsAdmin = (!strcasecmp(SQLDb->GetValue(0,12),"t") ? 1 : 0 );
|
||||
IsSmt = (!strcasecmp(SQLDb->GetValue(0,13),"t") ? 1 : 0 );
|
||||
IsCoder = (!strcasecmp(SQLDb->GetValue(0,14),"t") ? 1 : 0 );
|
||||
GetLogs = (!strcasecmp(SQLDb->GetValue(0,15),"t") ? 1 : 0 );
|
||||
NeedOp = (!strcasecmp(SQLDb->GetValue(0,16),"t") ? 1 : 0 );
|
||||
Email = SQLDb->GetValue(0,17);
|
||||
SuspendLevel = atoi(SQLDb->GetValue(0,18).c_str());
|
||||
SuspendReason = SQLDb->GetValue(0,19);
|
||||
Notice = (!strcasecmp(SQLDb->GetValue(0,20),"t") ? 1 : 0 );
|
||||
GetLag = (!strcasecmp(SQLDb->GetValue(0,21),"t") ? 1 : 0 );
|
||||
PassChangeTS = atoi(SQLDb->GetValue(0,22).c_str());
|
||||
}
|
||||
|
||||
bool ccUser::Update()
|
||||
{
|
||||
static const char *Main = "UPDATE opers SET password = '";
|
||||
|
||||
if(!dbConnected)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
stringstream theQuery;
|
||||
theQuery << Main
|
||||
<< ccontrol::removeSqlChars(Password)
|
||||
<< "', Access = "
|
||||
<< Access
|
||||
<< ", SAccess = "
|
||||
<< SAccess
|
||||
<< ", last_updated_by = '"
|
||||
<< ccontrol::removeSqlChars(last_updated_by)
|
||||
<< "',last_updated = date_part('epoch', CURRENT_TIMESTAMP)::int,flags = "
|
||||
<< Flags
|
||||
<< ",suspend_expires = "
|
||||
<< SuspendExpires
|
||||
<< " ,suspended_by = '"
|
||||
<< SuspendedBy
|
||||
<< "' ,suspend_level = "
|
||||
<< SuspendLevel
|
||||
<< ", suspend_reason = '"
|
||||
<< SuspendReason
|
||||
<< "' ,server = '"
|
||||
<< Server
|
||||
<< "' ,isSuspended = "
|
||||
<< (IsSuspended ? "'t'" : "'n'")
|
||||
<< ",isUhs = "
|
||||
<< (IsUhs ? "'t'" : "'n'")
|
||||
<< ",isOper = "
|
||||
<< (IsOper ? "'t'" : "'n'")
|
||||
<< ",isAdmin = "
|
||||
<< (IsAdmin ? "'t'" : "'n'")
|
||||
<< ",isSmt = "
|
||||
<< (IsSmt ? "'t'" : "'n'")
|
||||
<< ",isCoder = "
|
||||
<< (IsCoder ? "'t'" : "'n'")
|
||||
<< ",GetLogs = "
|
||||
<< (GetLogs ? "'t'" : "'n'")
|
||||
<< ",GetLag = "
|
||||
<< (GetLag ? "'t'" : "'n'")
|
||||
<< ",LastPassChangeTS = "
|
||||
<< PassChangeTS
|
||||
<< ",NeedOp = "
|
||||
<< (NeedOp ? "'t'" : "'n'")
|
||||
<< ", Email = '"
|
||||
<< ccontrol::removeSqlChars(Email)
|
||||
<< "',Notice = "
|
||||
<< (Notice ? "'t'" : "'n'")
|
||||
<< " WHERE lower(user_name) = '"
|
||||
<< ccontrol::removeSqlChars( string_lower(UserName)) << "'"
|
||||
<< ends;
|
||||
|
||||
elog << "ccontrol::UpdateOper> "
|
||||
<< theQuery.str().c_str()
|
||||
<< endl;
|
||||
|
||||
if( SQLDb->Exec( theQuery ) )
|
||||
//if( PGRES_COMMAND_OK == status )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
elog << "ccontrol::UpdateOper> SQL Failure: "
|
||||
<< SQLDb->ErrorMessage()
|
||||
<< endl ;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void ccUser::setUhs()
|
||||
{
|
||||
IsUhs = true;
|
||||
IsOper = IsAdmin = IsSmt = IsCoder = false;
|
||||
}
|
||||
|
||||
void ccUser::setOper()
|
||||
{
|
||||
IsOper = true;
|
||||
IsUhs = IsAdmin = IsSmt = IsCoder = false;
|
||||
}
|
||||
|
||||
void ccUser::setAdmin()
|
||||
{
|
||||
IsAdmin = true;
|
||||
IsOper = IsUhs = IsSmt = IsCoder = false;
|
||||
}
|
||||
|
||||
void ccUser::setSmt()
|
||||
{
|
||||
IsSmt = true;
|
||||
IsOper = IsAdmin = IsUhs = IsCoder = false;
|
||||
}
|
||||
|
||||
void ccUser::setCoder()
|
||||
{
|
||||
IsCoder = true;
|
||||
IsOper = IsAdmin = IsSmt = IsUhs = false;
|
||||
}
|
||||
|
||||
unsigned int ccUser::getType()
|
||||
{
|
||||
return (operLevel::UHSLEVEL * IsUhs + operLevel::OPERLEVEL * IsOper
|
||||
+ operLevel::ADMINLEVEL * IsAdmin + operLevel::SMTLEVEL * IsSmt
|
||||
+ operLevel::CODERLEVEL * IsCoder);
|
||||
}
|
||||
|
||||
void ccUser::setType(unsigned int Type)
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case operLevel::UHSLEVEL:
|
||||
IsUhs = true;
|
||||
IsOper = false;
|
||||
IsAdmin = false;
|
||||
IsSmt = false;
|
||||
IsCoder = false;
|
||||
break;
|
||||
case operLevel::OPERLEVEL:
|
||||
IsUhs = false;
|
||||
IsOper = true;
|
||||
IsAdmin = false;
|
||||
IsSmt = false;
|
||||
IsCoder = false;
|
||||
break;
|
||||
case operLevel::ADMINLEVEL:
|
||||
IsUhs = false;
|
||||
IsOper = false;
|
||||
IsAdmin = true;
|
||||
IsSmt = false;
|
||||
IsCoder = false;
|
||||
break;
|
||||
case operLevel::SMTLEVEL:
|
||||
IsUhs = false;
|
||||
IsOper = false;
|
||||
IsAdmin = false;
|
||||
IsSmt = true;
|
||||
IsCoder = false;
|
||||
break;
|
||||
case operLevel::CODERLEVEL:
|
||||
IsUhs = false;
|
||||
IsOper = false;
|
||||
IsAdmin = false;
|
||||
IsSmt = false;
|
||||
IsCoder = true;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
||||
bool ccUser::gotAccess(Command* Comm)
|
||||
{
|
||||
if(Comm->getSecondAccess())
|
||||
{
|
||||
return ((SAccess & Comm->getFlags()) != 0 ? true : false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((Access & Comm->getFlags()) != 0 ? true : false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ccUser::addCommand(Command* Comm)
|
||||
{
|
||||
if(Comm->getSecondAccess())
|
||||
SAccess |= Comm->getFlags();
|
||||
else
|
||||
Access |= Comm->getFlags();
|
||||
}
|
||||
|
||||
void ccUser::removeCommand(Command* Comm)
|
||||
{
|
||||
if(Comm->getSecondAccess())
|
||||
SAccess &= ~Comm->getFlags();
|
||||
else
|
||||
Access &= ~Comm->getFlags();
|
||||
}
|
||||
|
||||
void ccUser::updateAccessFromFlags()
|
||||
{
|
||||
if(IsOper)
|
||||
{
|
||||
Access = commandLevel::OPER;
|
||||
SAccess = commandLevel::SOPER;
|
||||
}
|
||||
else if(IsAdmin)
|
||||
{
|
||||
Access = commandLevel::ADMIN;
|
||||
SAccess = commandLevel::SADMIN;
|
||||
}
|
||||
else if(IsSmt)
|
||||
{
|
||||
Access = commandLevel::SMT;
|
||||
SAccess = commandLevel::SSMT;
|
||||
}
|
||||
else if(IsCoder)
|
||||
{
|
||||
Access = commandLevel::CODER;
|
||||
SAccess = commandLevel::SCODER;
|
||||
}
|
||||
}
|
||||
|
||||
void ccUser::updateAccess(unsigned int Type)
|
||||
{
|
||||
switch(Type)
|
||||
{
|
||||
case operLevel::OPERLEVEL:
|
||||
Access = commandLevel::OPER;
|
||||
SAccess = commandLevel::SOPER;
|
||||
break;
|
||||
case operLevel::ADMINLEVEL:
|
||||
Access = commandLevel::ADMIN;
|
||||
SAccess = commandLevel::SADMIN;
|
||||
break;
|
||||
case operLevel::SMTLEVEL:
|
||||
Access = commandLevel::SMT;
|
||||
SAccess = commandLevel::SSMT;
|
||||
break;
|
||||
case operLevel::CODERLEVEL:
|
||||
Access = commandLevel::CODER;
|
||||
SAccess = commandLevel::SCODER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace gnuworld
|
||||
@@ -0,0 +1,328 @@
|
||||
/**
|
||||
* ccUser.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: ccUser.h,v 1.21 2009/07/26 18:30:38 mrbean_ Exp $
|
||||
*/
|
||||
|
||||
#ifndef __CCUSER_H
|
||||
#define __CCUSER_H "$Id: ccUser.h,v 1.21 2009/07/26 18:30:38 mrbean_ Exp $"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#include "dbHandle.h"
|
||||
|
||||
#include "CControlCommands.h"
|
||||
|
||||
#include "iClient.h"
|
||||
|
||||
|
||||
#include <vector>
|
||||
//#include "ccontrol.h"
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using std::pair;
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
namespace operLevel
|
||||
{
|
||||
const unsigned int UHSLEVEL = 0x01;
|
||||
const unsigned int OPERLEVEL = 0x02;
|
||||
const unsigned int ADMINLEVEL = 0x03;
|
||||
const unsigned int SMTLEVEL = 0x04;
|
||||
const unsigned int CODERLEVEL = 0x05;
|
||||
const string CODERLEVELSTR = "CODER";
|
||||
const string SMTLEVELSTR = "SMT";
|
||||
const string ADMINLEVELSTR = "ADMIN";
|
||||
const string OPERLEVELSTR = "OPER";
|
||||
const string UHSLEVELSTR = "UHS";
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
CLASS
|
||||
ccUser
|
||||
|
||||
Holds all the vital information about a user
|
||||
|
||||
*/
|
||||
class ccUser
|
||||
{
|
||||
public:
|
||||
ccUser(dbHandle*) ;
|
||||
virtual ~ccUser() ;
|
||||
|
||||
/*
|
||||
* Methods to get data atrributes.
|
||||
*/
|
||||
|
||||
inline const unsigned int& getID() const
|
||||
{ return Id ; }
|
||||
|
||||
inline const string& getUserName() const
|
||||
{ return UserName ; }
|
||||
|
||||
inline const string& getPassword() const
|
||||
{ return Password ; }
|
||||
|
||||
inline const string& getLast_Updated_by() const
|
||||
{ return last_updated_by ; }
|
||||
|
||||
inline const string& getNumeric() const
|
||||
{ return Numeric ; }
|
||||
|
||||
inline const string& getEmail() const
|
||||
{ return Email ; }
|
||||
|
||||
inline const bool& getIsSuspended() const
|
||||
{ return IsSuspended ; }
|
||||
|
||||
inline const time_t& getSuspendExpires() const
|
||||
{ return SuspendExpires ; }
|
||||
|
||||
inline const time_t& getPassChangeTS() const
|
||||
{ return PassChangeTS; }
|
||||
|
||||
inline const time_t& getLastAuthTS() const
|
||||
{ return LastAuthTS; }
|
||||
|
||||
inline const string& getLastAuthNumeric() const
|
||||
{ return LastAuthNumeric; }
|
||||
|
||||
inline const unsigned int& getSuspendLevel() const
|
||||
{ return SuspendLevel; }
|
||||
|
||||
inline const string& getSuspendedBy() const
|
||||
{ return SuspendedBy ; }
|
||||
|
||||
inline const string& getSuspendReason() const
|
||||
{ return SuspendReason ; }
|
||||
|
||||
inline const unsigned long int& getAccess() const
|
||||
{ return Access ; }
|
||||
|
||||
inline const unsigned long int& getSAccess() const
|
||||
{ return SAccess ; }
|
||||
|
||||
inline const unsigned int& getFlags() const
|
||||
{ return Flags ; }
|
||||
|
||||
inline bool gotFlag(unsigned int _flag) const
|
||||
{ return (Flags & _flag ? true : false) ; }
|
||||
|
||||
inline const string& getServer() const
|
||||
{ return Server; }
|
||||
|
||||
inline const bool& isUhs() const
|
||||
{ return IsUhs; }
|
||||
|
||||
inline const bool& isOper() const
|
||||
{ return IsOper; }
|
||||
|
||||
inline const bool& isAdmin() const
|
||||
{ return IsAdmin; }
|
||||
|
||||
inline const bool& isSmt() const
|
||||
{ return IsSmt; }
|
||||
|
||||
inline const bool& isCoder() const
|
||||
{ return IsCoder; }
|
||||
|
||||
inline const bool& getLogs() const
|
||||
{ return GetLogs; }
|
||||
|
||||
inline const bool& getLag() const
|
||||
{ return GetLag; }
|
||||
|
||||
inline const bool& getNeedOp() const
|
||||
{ return NeedOp; }
|
||||
|
||||
inline const bool& getNotice() const
|
||||
{ return Notice; }
|
||||
|
||||
inline const iClient* getClient() const
|
||||
{ return Client; }
|
||||
|
||||
/*
|
||||
* Methods to set data attributes
|
||||
*/
|
||||
|
||||
inline void setID( const unsigned int _id )
|
||||
{ Id = _id; }
|
||||
|
||||
inline void setUserName( const string& _username )
|
||||
{ UserName = _username; }
|
||||
|
||||
inline void setPassword( const string& _password )
|
||||
{ Password = _password; }
|
||||
|
||||
inline void setLast_Updated_By( const string& _last_updated_by )
|
||||
{ last_updated_by = _last_updated_by; }
|
||||
|
||||
inline void setNumeric( const string& _numeric )
|
||||
{ Numeric = _numeric; }
|
||||
|
||||
inline void setEmail(const string& _Email)
|
||||
{ Email = _Email; }
|
||||
|
||||
inline void setIsSuspended(const bool _suspeneded)
|
||||
{ IsSuspended = _suspeneded; }
|
||||
|
||||
inline void setSuspendExpires( const unsigned int _expire )
|
||||
{ SuspendExpires = _expire; }
|
||||
|
||||
inline void setLastAuthTS(const unsigned int _lastauth)
|
||||
{ LastAuthTS = _lastauth; }
|
||||
|
||||
inline void setPassChangeTS(const unsigned int _PassChangeTS)
|
||||
{ PassChangeTS = _PassChangeTS; }
|
||||
|
||||
inline void setLastAuthNumeric(const string& _numeric)
|
||||
{ LastAuthNumeric = _numeric; }
|
||||
|
||||
inline void setSuspendLevel( const unsigned int _level )
|
||||
{ SuspendLevel = _level; }
|
||||
|
||||
inline void setSuspendedBy( const string& _suspendedby )
|
||||
{ SuspendedBy = _suspendedby; }
|
||||
|
||||
inline void setSuspendReason( const string& _reason )
|
||||
{ SuspendReason = _reason; }
|
||||
|
||||
inline void setAccess( const unsigned long int _access )
|
||||
{ Access = _access; }
|
||||
|
||||
inline void setSAccess( const unsigned long int _saccess )
|
||||
{ SAccess = _saccess; }
|
||||
|
||||
|
||||
inline void setFlags( const unsigned int _flags )
|
||||
{ Flags = _flags; }
|
||||
|
||||
inline void removeFlag( const unsigned int _flag )
|
||||
{ Flags &= ~_flag; }
|
||||
|
||||
inline void setFlag( const unsigned int _flag )
|
||||
{ Flags |= _flag; }
|
||||
|
||||
inline void setServer( const string& _server )
|
||||
{ Server = _server; }
|
||||
|
||||
inline void setLogs( const bool _Logs )
|
||||
{ GetLogs = _Logs; }
|
||||
|
||||
inline void setLag( const bool _Lag )
|
||||
{ GetLag = _Lag; }
|
||||
|
||||
inline void setNeedOp( const bool _needOp )
|
||||
{ NeedOp = _needOp; }
|
||||
|
||||
inline void setNotice( const bool _notice )
|
||||
{ Notice = _notice; }
|
||||
|
||||
inline void setClient(iClient* _Client)
|
||||
{ Client = _Client; }
|
||||
|
||||
inline void setSqldb(dbHandle* _SQLDb)
|
||||
{ SQLDb = _SQLDb; }
|
||||
/*
|
||||
* Methods to load a user and update the
|
||||
* the database
|
||||
*/
|
||||
|
||||
bool loadData( const string& Name );
|
||||
|
||||
bool loadData( const unsigned int Id );
|
||||
|
||||
bool Update();
|
||||
|
||||
void GetParm();
|
||||
|
||||
void setUhs();
|
||||
|
||||
void setOper();
|
||||
|
||||
void setAdmin();
|
||||
|
||||
void setSmt();
|
||||
|
||||
void setCoder();
|
||||
|
||||
unsigned int getType();
|
||||
|
||||
void setType(unsigned int Type);
|
||||
|
||||
bool gotAccess(Command* Comm);
|
||||
|
||||
void addCommand(Command* Comm);
|
||||
|
||||
void removeCommand(Command* Comm);
|
||||
|
||||
void updateAccessFromFlags();
|
||||
|
||||
void updateAccess(unsigned int Type);
|
||||
|
||||
static unsigned int numAllocated;
|
||||
|
||||
protected:
|
||||
unsigned int Id;
|
||||
string UserName;
|
||||
string Password;
|
||||
string last_updated_by;
|
||||
string Numeric;
|
||||
string Server;
|
||||
string Email;
|
||||
bool IsSuspended;
|
||||
time_t SuspendExpires;
|
||||
string SuspendedBy;
|
||||
unsigned int SuspendLevel;
|
||||
string SuspendReason;
|
||||
unsigned long int Access;
|
||||
unsigned long int SAccess;
|
||||
unsigned int Flags;
|
||||
bool IsUhs;
|
||||
bool IsOper;
|
||||
bool IsAdmin;
|
||||
bool IsSmt;
|
||||
bool IsCoder;
|
||||
bool GetLogs;
|
||||
bool GetLag;
|
||||
bool NeedOp;
|
||||
bool Notice;
|
||||
iClient* Client;
|
||||
dbHandle* SQLDb;
|
||||
time_t LastAuthTS;
|
||||
time_t PassChangeTS;
|
||||
string LastAuthNumeric;
|
||||
|
||||
} ; // class ccUser
|
||||
|
||||
}
|
||||
} // namespace gnuworld
|
||||
|
||||
#endif // __CCUSER_H
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* ccUserData.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: ccUserData.h,v 1.2 2003/06/28 01:21:19 dan_karrels Exp $
|
||||
*/
|
||||
|
||||
#ifndef __CCUSERDATA_H_
|
||||
#define __CCUSERDATA_H_
|
||||
|
||||
#include "iClient.h"
|
||||
#include "ccUser.h"
|
||||
#include "ccFloodData.h"
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
class ccUserData
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
ccUserData(ccFloodData* tFlood = NULL,ccUser* tDbUser = NULL)
|
||||
: flood(tFlood),
|
||||
dbUser(tDbUser)
|
||||
{}
|
||||
|
||||
virtual ~ccUserData(){}
|
||||
|
||||
inline ccUser* getDbUser() const
|
||||
{ return dbUser; }
|
||||
|
||||
inline ccFloodData* getFlood() const
|
||||
{ return flood; }
|
||||
|
||||
inline void setDbUser(ccUser* _dbUser)
|
||||
{ dbUser = _dbUser; }
|
||||
|
||||
inline void setFlood(ccFloodData* _flood)
|
||||
{ flood = _flood; }
|
||||
protected:
|
||||
|
||||
|
||||
ccFloodData* flood;
|
||||
|
||||
ccUser* dbUser;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* ccontrol_generic.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: ccontrol_generic.cc,v 1.5 2008/01/03 04:26:22 kewlio Exp $
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "ccontrol_generic.h"
|
||||
|
||||
char ago[250];
|
||||
|
||||
char *Duration(long ts)
|
||||
{
|
||||
/* express duration in human readable format */
|
||||
long duration;
|
||||
int days, hours, mins = 0;
|
||||
char tmp[16];
|
||||
|
||||
ago[0] = '\0';
|
||||
|
||||
duration = ts;
|
||||
|
||||
days = (duration / 86400);
|
||||
duration %= 86400;
|
||||
hours = (duration / 3600);
|
||||
duration %= 3600;
|
||||
mins = (duration / 60);
|
||||
duration %= 60;
|
||||
|
||||
if (days > 0)
|
||||
{
|
||||
sprintf(tmp, "%dd", days);
|
||||
strcat(ago, tmp);
|
||||
}
|
||||
if (hours > 0)
|
||||
{
|
||||
sprintf(tmp, "%dh", hours);
|
||||
strcat(ago, tmp);
|
||||
}
|
||||
if (mins > 0)
|
||||
{
|
||||
sprintf(tmp, "%dm", mins);
|
||||
strcat(ago, tmp);
|
||||
}
|
||||
/* only show seconds if we have any (or no other units */
|
||||
if ((duration > 0) || (strlen(ago) == 0))
|
||||
{
|
||||
sprintf(tmp,"%ds", (int) duration);
|
||||
strcat(ago,tmp);
|
||||
}
|
||||
|
||||
return ago;
|
||||
}
|
||||
|
||||
char *Ago(long ts)
|
||||
{
|
||||
/* express a a timestamp in human readable format */
|
||||
long duration;
|
||||
|
||||
duration = (time(NULL) - ts);
|
||||
|
||||
return (Duration(duration));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* ccontrol_generic.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: ccontrol_generic.h,v 1.2 2005/06/19 12:09:56 kewlio Exp $
|
||||
*/
|
||||
|
||||
char *Ago(long ts);
|
||||
char *Duration(long ts);
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
* commLevels.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: commLevels.h,v 1.27 2009/06/13 06:43:34 hidden1 Exp $
|
||||
*/
|
||||
|
||||
#ifndef __COMMANDLEVELS_H
|
||||
#define __COMMANDLEVELS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
using std::string ;
|
||||
|
||||
namespace gnuworld
|
||||
{
|
||||
|
||||
namespace uworld
|
||||
{
|
||||
|
||||
namespace commandLevel
|
||||
{
|
||||
/*
|
||||
|
||||
These are the commands flags
|
||||
To enable a command for an oper he must have the command
|
||||
flag set in his access
|
||||
|
||||
**NOTE** Commands with access NOLOGIN/0 can be accessed without loginin first
|
||||
|
||||
*/
|
||||
|
||||
const unsigned long int flg_NOLOGIN = 0x0;
|
||||
const unsigned long int flg_HELP = 0x02 | flg_NOLOGIN;
|
||||
const unsigned long int flg_LOGIN = 0x0;
|
||||
const unsigned long int flg_DEAUTH = 0x04;
|
||||
const unsigned long int flg_NEWPASS = 0x08;
|
||||
const unsigned long int flg_MODE = 0x10 | flg_NOLOGIN;
|
||||
const unsigned long int flg_OP = 0x20 | flg_NOLOGIN;
|
||||
const unsigned long int flg_DEOP = 0x40 | flg_NOLOGIN;
|
||||
const unsigned long int flg_MODERATE = 0x80 | flg_NOLOGIN;
|
||||
const unsigned long int flg_UNMODERATE = 0x100 | flg_NOLOGIN;
|
||||
const unsigned long int flg_INVITE = 0x200 | flg_NOLOGIN;
|
||||
const unsigned long int flg_JUPE = 0x400;
|
||||
|
||||
const unsigned long int flg_GLINE = 0x800 | flg_NOLOGIN;
|
||||
const unsigned long int flg_SCGLINE = 0x1000;
|
||||
const unsigned long int flg_REMGLINE = 0x2000;
|
||||
const unsigned long int flg_REMOPCHN = 0x4000;
|
||||
const unsigned long int flg_ADDOPCHN = 0x8000;
|
||||
const unsigned long int flg_LOPCHN = 0x10000;
|
||||
const unsigned long int flg_CHINFO = 0x20000;
|
||||
const unsigned long int flg_WHOIS = 0x40000 | flg_NOLOGIN;
|
||||
const unsigned long int flg_ADDNOP = 0x80000;
|
||||
const unsigned long int flg_REMOP = 0x100000;
|
||||
const unsigned long int flg_MODOP = 0x200000;
|
||||
const unsigned long int flg_TRANS = 0x400000 | flg_NOLOGIN;
|
||||
const unsigned long int flg_KICK = 0x800000;
|
||||
const unsigned long int flg_ADDCMD = 0x1000000;
|
||||
const unsigned long int flg_DELCMD = 0x2000000;
|
||||
const unsigned long int flg_SUSPEND = 0x4000000;
|
||||
const unsigned long int flg_UNSUSPEND = 0x8000000;
|
||||
const unsigned long int flg_CLEARCHAN = 0x10000000;
|
||||
|
||||
const unsigned long int flg_LISTHOSTS = 0x20000000;
|
||||
const unsigned long int flg_ADDSERVER = 0x40000000;
|
||||
|
||||
const unsigned long int flg_REMSERVER = 0x2; //From here saccess must be toggled
|
||||
const unsigned long int flg_CHECKNET = 0x4;
|
||||
const unsigned long int flg_LASTCOM = 0x8;
|
||||
const unsigned long int flg_FGLINE = 0x10;
|
||||
const unsigned long int flg_EXCEPTIONS = 0x20;
|
||||
const unsigned long int flg_LISTIGNORES = 0x40;
|
||||
const unsigned long int flg_REMIGNORE = 0x80;
|
||||
const unsigned long int flg_LIST = 0x100;
|
||||
const unsigned long int flg_COMMANDS = 0x200;
|
||||
const unsigned long int flg_NOTES = 0x400;
|
||||
const unsigned long int flg_GCHAN = 0x800;
|
||||
const unsigned long int flg_RGCHAN = 0x1000;
|
||||
const unsigned long int flg_USERINFO = 0x2000;
|
||||
const unsigned long int flg_STATUS = 0x4000;
|
||||
const unsigned long int flg_SHUTDOWN = 0x8000;
|
||||
const unsigned long int flg_SCAN = 0x10000 | flg_NOLOGIN;
|
||||
const unsigned long int flg_LEARNNET = 0x20000;
|
||||
const unsigned long int flg_MAXUSERS = 0x40000;
|
||||
const unsigned long int flg_CONFIG = 0x80000;
|
||||
const unsigned long int flg_SAY = 0x100000;
|
||||
const unsigned long int flg_NOMODE = 0x200000;
|
||||
const unsigned long int flg_REOP = 0x400000;
|
||||
const unsigned long int flg_SGLINE = 0x800000;
|
||||
const unsigned long int flg_REMSGLINE = 0x1000000;
|
||||
const unsigned long int flg_UNJUPE = 0x2000000;
|
||||
const unsigned long int flg_SCHANGLINE = 0x4000000;
|
||||
const unsigned long int flg_FORCECHANGLINE = 0x8000000;
|
||||
const unsigned long int flg_SHELLS = 0x10000000;
|
||||
const unsigned long int flg_ANNOUNCE = 0x20000000;
|
||||
|
||||
/*
|
||||
Default commands that are added upon adding a new oper
|
||||
*/
|
||||
|
||||
const unsigned long int UHS = flg_NEWPASS | flg_HELP | flg_DEAUTH ;
|
||||
const unsigned long int SUHS = flg_ANNOUNCE;
|
||||
|
||||
const unsigned long int OPER = UHS | flg_MODE | flg_OP | flg_DEOP | flg_MODERATE
|
||||
| flg_UNMODERATE | flg_INVITE | flg_GLINE | flg_SCGLINE
|
||||
| flg_REMGLINE | flg_LOPCHN | flg_CHINFO | flg_WHOIS
|
||||
| flg_TRANS | flg_KICK | flg_CLEARCHAN | flg_LISTHOSTS
|
||||
| flg_MODOP;
|
||||
const unsigned long int SOPER = flg_CHECKNET | flg_LISTIGNORES | flg_LIST
|
||||
| flg_NOTES | flg_USERINFO | flg_SCAN | flg_MAXUSERS
|
||||
| flg_LASTCOM | flg_REOP | flg_UNJUPE | flg_ANNOUNCE;
|
||||
const unsigned long int ADMIN = OPER | flg_JUPE | flg_REMOPCHN | flg_ADDOPCHN
|
||||
| flg_ADDNOP | flg_REMOP | flg_ADDCMD
|
||||
| flg_DELCMD | flg_SUSPEND | flg_UNSUSPEND;
|
||||
const unsigned long int SADMIN = SOPER | flg_LEARNNET | flg_FGLINE
|
||||
| flg_REMIGNORE | flg_FORCECHANGLINE;
|
||||
const unsigned long int SMT = ADMIN | flg_ADDSERVER;
|
||||
const unsigned long int SSMT = SADMIN | flg_REMSERVER | flg_NOMODE;
|
||||
const unsigned long int CODER = SMT;
|
||||
const unsigned long int SCODER = SSMT | flg_COMMANDS| flg_GCHAN | flg_RGCHAN
|
||||
| flg_EXCEPTIONS | flg_STATUS | flg_SHUTDOWN
|
||||
| flg_CONFIG | flg_SAY | flg_SGLINE | flg_REMSGLINE | flg_SCHANGLINE | flg_SHELLS;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif // __COMMANDLEVELS_H
|
||||
Reference in new issue
Block a user