* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: ADDFLAGCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: ADDFLAGCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: ADDFLAGCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: ADDFLAGCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
+ theUser->getUserName()
+ ") "
+ theClient->getRealNickUserHost() ) );
-targetUser->commit();
+targetUser->commit(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::added_flag_to_user,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: ADDHOSTCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: ADDHOSTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: ADDHOSTCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: ADDHOSTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
if (targetUser->matchHost(st[2].c_str())) {
if ((st[2] != "*!*@*") && targetUser->hasHost("*!*@*")) {
- targetUser->delHost("*!*@*");
+ targetUser->delHost(bot->getLocalDBHandle(),"*!*@*");
bot->SendTo(theClient,
bot->getResponse(theUser,
language::removed_default_hostmask,
}
}
-if (!targetUser->addHost(st[2].c_str())) {
+if (!targetUser->addHost(bot->getLocalDBHandle(),st[2].c_str())) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::failed_adding_hostmask,
+ theUser->getUserName()
+ ") "
+ theClient->getRealNickUserHost() ) );
-targetUser->commit();
+targetUser->commit(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: ADDNOTECommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: ADDNOTECommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: ADDNOTECommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: ADDNOTECommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
if (!theChan) theChan = bot->newChannelRecord(st[1]);
if (!theChan->useSQL())
- theChan->Insert();
+ theChan->Insert(bot->getLocalDBHandle());
-theChan->addNote(sqlChannel::EV_NOTE, theClient, st.assemble(2));
+theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_NOTE, theClient, st.assemble(2));
bot->SendTo(theClient,
bot->getResponse(theUser,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: ADDUSERCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: ADDUSERCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: ADDUSERCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: ADDUSERCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
else
newUser->setGroup("undernet.org");
-if (!newUser->Insert()) {
+if (!newUser->Insert(bot->getLocalDBHandle())) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::error_creating_user,
bot->usersMap[newUser->getUserName()] = newUser;
if (st.size() > 2) {
- if (newUser->addHost(st[2].c_str())) {
+ if (newUser->addHost(bot->getLocalDBHandle(),st[2].c_str())) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::created_user_w_host,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: ALERTCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: ALERTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: ALERTCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: ALERTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
theChan->setFlag(sqlChannel::F_ALERT);
if (!theChan->useSQL())
- theChan->Insert();
+ theChan->Insert(bot->getLocalDBHandle());
else
- theChan->commit();
+ theChan->commit(bot->getLocalDBHandle());
/* Add note to the channel about this command */
-theChan->addNote(sqlChannel::EV_ALERT, theClient, (st.size() > 2) ? st.assemble(2) : "");
+theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_ALERT, theClient, (st.size() > 2) ? st.assemble(2) : "");
bot->SendTo(theClient,
bot->getResponse(theUser,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: BLOCKCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: BLOCKCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: BLOCKCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: BLOCKCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
theChan->setFlag(sqlChannel::F_BLOCKED);
if (!theChan->useSQL())
- theChan->Insert();
+ theChan->Insert(bot->getLocalDBHandle());
else
- theChan->commit();
+ theChan->commit(bot->getLocalDBHandle());
/* Add note to the channel about this command */
-theChan->addNote(sqlChannel::EV_BLOCK, theClient, st.assemble(2));
+theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_BLOCK, theClient, st.assemble(2));
bot->SendTo(theClient,
bot->getResponse(theUser,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: CHANFIXCommand.cc,v 1.5 2007/03/11 14:52:28 buzlip01 Exp $
+ * $Id: CHANFIXCommand.cc,v 1.6 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "responses.h"
#include "StringTokenizer.h"
-RCSTAG("$Id: CHANFIXCommand.cc,v 1.5 2007/03/11 14:52:28 buzlip01 Exp $");
+RCSTAG("$Id: CHANFIXCommand.cc,v 1.6 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
/* Add the channel to the SQL database if it hasn't already been added */
if (!theChan->useSQL())
- theChan->Insert();
+ theChan->Insert(bot->getLocalDBHandle());
/* Alert top ops out of the channel if wanted */
if (alert)
bot->manualFix(netChan);
/* Add note to the channel about this manual fix */
-theChan->addNote(sqlChannel::EV_CHANFIX, theClient, (override) ? "[override]" : "");
+theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_CHANFIX, theClient, (override) ? "[override]" : "");
/* Log the chanfix */
bot->SendTo(theClient,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: DELFLAGCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: DELFLAGCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: DELFLAGCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: DELFLAGCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
+ theUser->getUserName()
+ ") "
+ theClient->getRealNickUserHost() ) );
-targetUser->commit();
+targetUser->commit(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::deleted_flag,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: DELHOSTCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: DELHOSTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: DELHOSTCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: DELHOSTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
return;
}
-if (!targetUser->delHost(st[2].c_str())) {
+if (!targetUser->delHost(bot->getLocalDBHandle(),st[2].c_str())) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::failed_deleting_host,
+ theUser->getUserName()
+ ") "
+ theClient->getRealNickUserHost() ) );
-targetUser->commit();
+targetUser->commit(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: DELNOTECommand.cc,v 1.5 2007/08/28 16:10:20 dan_karrels Exp $
+ * $Id: DELNOTECommand.cc,v 1.6 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: DELNOTECommand.cc,v 1.5 2007/08/28 16:10:20 dan_karrels Exp $");
+RCSTAG("$Id: DELNOTECommand.cc,v 1.6 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
return;
}
-if (!theChan->useSQL() || (theChan->countNotes(0) <= 0)) {
+if (!theChan->useSQL() || (theChan->countNotes(bot->getLocalDBHandle(),0) <= 0)) {
bot->SendTo(theClient,
bot->getResponse(theUser,
language::chan_has_no_notes,
unsigned int messageId = atoi(st[2].c_str());
/* Get a connection instance to our backend */
-dbHandle* cacheCon = bot->theManager->getConnection();
+dbHandle* cacheCon = bot->getLocalDBHandle();
/* Retrieve the note */
std::stringstream noteCheckQuery;
<< messageId
;
-if (!cacheCon->Exec(noteCheckQuery,true)) {
+if (!cacheCon->Exec(noteCheckQuery.str(),true)) {
elog << "DELNOTECommand> SQL Error: "
<< cacheCon->ErrorMessage()
<< std::endl ;
std::string("An unknown error occured while checking the note id.")).c_str());
/* Dispose of our connection instance */
- bot->theManager->removeConnection(cacheCon);
+ //bot->theManager->removeConnection(cacheCon);
return;
}
unsigned short eventType = atoi(cacheCon->GetValue(0,2));
/* Dispose of our connection instance */
-bot->theManager->removeConnection(cacheCon);
+//bot->theManager->removeConnection(cacheCon);
if (channelID != theChan->getID()) {
bot->SendTo(theClient,
return;
}
-theChan->deleteNote(messageId);
+theChan->deleteNote(bot->getLocalDBHandle(),messageId);
bot->SendTo(theClient,
bot->getResponse(theUser,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: DELUSERCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: DELUSERCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: DELUSERCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: DELUSERCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
}
}
-if (targetUser->Delete()) {
+if (targetUser->Delete(bot->getLocalDBHandle())) {
bot->usersMap.erase(bot->usersMap.find(targetUser->getUserName()));
bot->SendTo(theClient,
bot->getResponse(theUser,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: HISTORYCommand.cc,v 1.5 2007/08/28 16:10:21 dan_karrels Exp $
+ * $Id: HISTORYCommand.cc,v 1.6 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: HISTORYCommand.cc,v 1.5 2007/08/28 16:10:21 dan_karrels Exp $");
+RCSTAG("$Id: HISTORYCommand.cc,v 1.6 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
}
/* Get a connection instance to our backend */
-dbHandle* cacheCon = bot->theManager->getConnection();
+dbHandle* cacheCon = bot->getLocalDBHandle();
/*
* Perform a query to list the dates/times this channel was last chanfixed.
<< ") ORDER BY ts DESC"
;
-if (!cacheCon->Exec(chanfixQuery,true)) {
+if (!cacheCon->Exec(chanfixQuery.str(),true)) {
elog << "HISTORYCommand> SQL Error: "
<< cacheCon->ErrorMessage()
<< std::endl;
theChan->getChannel().c_str());
/* Dispose of our connection instance */
- bot->theManager->removeConnection(cacheCon);
+ //bot->theManager->removeConnection(cacheCon);
return;
}
std::string("End of list.")).c_str());
/* Dispose of our connection instance */
-bot->theManager->removeConnection(cacheCon);
+//bot->theManager->removeConnection(cacheCon);
bot->logAdminMessage("%s (%s) HISTORY %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: INFOCommand.cc,v 1.6 2007/08/28 16:10:21 dan_karrels Exp $
+ * $Id: INFOCommand.cc,v 1.7 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: INFOCommand.cc,v 1.6 2007/08/28 16:10:21 dan_karrels Exp $");
+RCSTAG("$Id: INFOCommand.cc,v 1.7 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
}
/* Get a connection instance to our backend */
-dbHandle* cacheCon = bot->theManager->getConnection();
+dbHandle* cacheCon = bot->getLocalDBHandle();
/*
* Perform a query to list all notes belonging to this channel.
<< " ORDER BY notes.ts DESC"
;
-if (!cacheCon->Exec(allNotesQuery,true)) {
+if (!cacheCon->Exec(allNotesQuery.str(),true)) {
elog << "INFOCommand> SQL Error: "
<< cacheCon->ErrorMessage()
<< std::endl;
std::string("An unknown error occurred while reading this channel's notes.")).c_str());
/* Dispose of our connection instance */
- bot->theManager->removeConnection(cacheCon);
+ //bot->theManager->removeConnection(cacheCon);
return ;
}
std::string("End of information.")).c_str());
/* Dispose of our connection instance */
-bot->theManager->removeConnection(cacheCon);
+//bot->theManager->removeConnection(cacheCon);
bot->logAdminMessage("%s (%s) INFO %s",
theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: LASTCOMCommand.cc,v 1.3 2007/08/28 16:10:21 dan_karrels Exp $
+ * $Id: LASTCOMCommand.cc,v 1.4 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include <sstream>
#include "ELog.h"
#include "gnuworld_config.h"
-RCSTAG( "$Id: LASTCOMCommand.cc,v 1.3 2007/08/28 16:10:21 dan_karrels Exp $" ) ;
+RCSTAG( "$Id: LASTCOMCommand.cc,v 1.4 2008/01/16 02:03:37 buzlip01 Exp $" ) ;
namespace gnuworld
{
unsigned int Days = 0;
std::stringstream theQuery;
-dbHandle* cacheCon = bot->theManager->getConnection();
+dbHandle* cacheCon = bot->getLocalDBHandle();
if (st.size() == 1 ) {
NumOfCom = 20;
<< theQuery.str().c_str()
<< std::endl;
-if (!cacheCon->Exec(theQuery,true)) {
+if (!cacheCon->Exec(theQuery.str(),true)) {
elog << "chanfix::LASTCOM> SQL Error: "
<< cacheCon->ErrorMessage()
<< std::endl ;
std::string("End of LASTCOM report.")).c_str());
/* Dispose of our connection instance */
-bot->theManager->removeConnection(cacheCon);
+//bot->theManager->removeConnection(cacheCon);
bot->logLastComMessage(theClient, Message);
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: LISTBLOCKEDCommand.cc,v 1.3 2007/08/28 16:10:21 dan_karrels Exp $
+ * $Id: LISTBLOCKEDCommand.cc,v 1.4 2008/01/16 02:03:37 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: LISTBLOCKEDCommand.cc,v 1.3 2007/08/28 16:10:21 dan_karrels Exp $");
+RCSTAG("$Id: LISTBLOCKEDCommand.cc,v 1.4 2008/01/16 02:03:37 buzlip01 Exp $");
namespace gnuworld
{
}
/* List blocks */
-dbHandle* cacheCon = bot->theManager->getConnection();
+dbHandle* cacheCon = bot->getLocalDBHandle();
std::stringstream theQuery;
theQuery << "SELECT channel FROM channels WHERE (flags & "
<< sqlChannel::F_BLOCKED
<< " ORDER BY channel ASC";
-if (!cacheCon->Exec(theQuery,true)) {
+if (!cacheCon->Exec(theQuery.str(),true)) {
elog << "chanfix::LISTBLOCKEDCommand> SQL Error: "
<< cacheCon->ErrorMessage()
<< std::endl;
}
/* Dispose of our connection instance */
-bot->theManager->removeConnection(cacheCon);
+//bot->theManager->removeConnection(cacheCon);
if (strBlocks.size())
bot->SendTo(theClient, strBlocks.c_str());
@SET_MAKE@
-# "$Id: Makefile.in,v 1.14 2007/10/31 14:56:44 kewlio Exp $"
+# "$Id: Makefile.in,v 1.15 2008/01/16 02:03:38 buzlip01 Exp $"
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: OPLISTCommand.cc,v 1.6 2007/02/01 14:11:17 buzlip01 Exp $
+ * $Id: OPLISTCommand.cc,v 1.7 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "sqlChannel.h"
#include "sqlChanOp.h"
-RCSTAG("$Id: OPLISTCommand.cc,v 1.6 2007/02/01 14:11:17 buzlip01 Exp $");
+RCSTAG("$Id: OPLISTCommand.cc,v 1.7 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (theChan) {
- bot->SendTo(theClient, "Notes: %d", theChan->countNotes(0));
+ bot->SendTo(theClient, "Notes: %d", theChan->countNotes(bot->getLocalDBHandle(),0));
if (bot->isTempBlocked(theChan->getChannel()))
bot->SendTo(theClient,
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (theChan) {
- bot->SendTo(theClient, "Notes: %d", theChan->countNotes(0));
+ bot->SendTo(theClient, "Notes: %d", theChan->countNotes(bot->getLocalDBHandle(),0));
if (bot->isTempBlocked(theChan->getChannel()))
bot->SendTo(theClient,
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (theChan) {
- bot->SendTo(theClient, "Notes: %d", theChan->countNotes(0));
+ bot->SendTo(theClient, "Notes: %d", theChan->countNotes(bot->getLocalDBHandle(), 0));
if (bot->isTempBlocked(theChan->getChannel()))
bot->SendTo(theClient,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: REQUESTOPCommand.cc,v 1.1 2006/12/09 00:29:19 buzlip01 Exp $
+ * $Id: REQUESTOPCommand.cc,v 1.2 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "responses.h"
#include "StringTokenizer.h"
-RCSTAG("$Id: REQUESTOPCommand.cc,v 1.1 2006/12/09 00:29:19 buzlip01 Exp $");
+RCSTAG("$Id: REQUESTOPCommand.cc,v 1.2 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
/* Add the channel to the SQL database if it hasn't already been added */
if (!theChan->useSQL())
- theChan->Insert();
+ theChan->Insert(bot->getLocalDBHandle());
/* Alert top ops out of the channel if wanted */
if (alert)
bot->manualFix(netChan);
/* Add note to the channel about this manual fix */
-theChan->addNote(sqlChannel::EV_REQUESTOP, theClient, "");
+theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_REQUESTOP, theClient, "");
/* Log the chanfix */
bot->SendTo(theClient,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: SCORECommand.cc,v 1.5 2007/02/01 14:11:16 buzlip01 Exp $
+ * $Id: SCORECommand.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include <sstream>
#include "sqlChanOp.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: SCORECommand.cc,v 1.5 2007/02/01 14:11:16 buzlip01 Exp $");
+RCSTAG("$Id: SCORECommand.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
sqlChannel* theChan = bot->getChannelRecord(st[1]);
if (theChan) {
- bot->SendTo(theClient, "Notes: %d", theChan->countNotes(0));
+ bot->SendTo(theClient, "Notes: %d", theChan->countNotes(bot->getLocalDBHandle(), 0));
if (theChan->getFlag(sqlChannel::F_BLOCKED))
bot->SendTo(theClient,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: SETGROUPCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $
+ * $Id: SETGROUPCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: SETGROUPCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $");
+RCSTAG("$Id: SETGROUPCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
+ theUser->getUserName()
+ ") "
+ theClient->getRealNickUserHost() ) );
-targetUser->commit();
+targetUser->commit(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: SIMULATECommand.cc,v 1.1 2006/12/09 00:29:19 buzlip01 Exp $
+ * $Id: SIMULATECommand.cc,v 1.2 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: SIMULATECommand.cc,v 1.1 2006/12/09 00:29:19 buzlip01 Exp $");
+RCSTAG("$Id: SIMULATECommand.cc,v 1.2 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
}
if (!theChan->useSQL())
- theChan->Insert();
+ theChan->Insert(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
sqlChannel* sqlChan = bot->getChannelRecord(st[1]);
bot->simulateFix(sqlChan, autof, theClient, theUser);
-theChan->addNote(sqlChannel::EV_SIMULATE, theClient, (autof) ? "[auto]" : "[manual]");
+theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_SIMULATE, theClient, (autof) ? "[auto]" : "[manual]");
bot->SendTo(theClient,
bot->getResponse(theUser,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: SUSPENDCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $
+ * $Id: SUSPENDCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: SUSPENDCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $");
+RCSTAG("$Id: SUSPENDCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
+ theUser->getUserName()
+ ") "
+ theClient->getRealNickUserHost() ) );
-targetUser->commit();
+targetUser->commit(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: UNALERTCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $
+ * $Id: UNALERTCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: UNALERTCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $");
+RCSTAG("$Id: UNALERTCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
theChan->removeFlag(sqlChannel::F_ALERT);
if (!theChan->useSQL())
- theChan->Insert();
+ theChan->Insert(bot->getLocalDBHandle());
else
- theChan->commit();
+ theChan->commit(bot->getLocalDBHandle());
/* Add note to the channel about this command */
-theChan->addNote(sqlChannel::EV_UNALERT, theClient, "");
+theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_UNALERT, theClient, "");
bot->SendTo(theClient,
bot->getResponse(theUser,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: UNBLOCKCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $
+ * $Id: UNBLOCKCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "sqlChannel.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: UNBLOCKCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $");
+RCSTAG("$Id: UNBLOCKCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
theChan->removeFlag(sqlChannel::F_BLOCKED);
if (!theChan->useSQL())
- theChan->Insert();
+ theChan->Insert(bot->getLocalDBHandle());
else
- theChan->commit();
+ theChan->commit(bot->getLocalDBHandle());
/* Add note to the channel about this command */
-theChan->addNote(sqlChannel::EV_UNBLOCK, theClient, "");
+theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_UNBLOCK, theClient, "");
bot->SendTo(theClient,
bot->getResponse(theUser,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: UNSUSPENDCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $
+ * $Id: UNSUSPENDCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: UNSUSPENDCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $");
+RCSTAG("$Id: UNSUSPENDCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
+ theUser->getUserName()
+ ") "
+ theClient->getRealNickUserHost() ) );
-targetUser->commit();
+targetUser->commit(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: USETCommand.cc,v 1.5 2006/12/09 00:29:19 buzlip01 Exp $
+ * $Id: USETCommand.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include <string>
#include "responses.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: USETCommand.cc,v 1.5 2006/12/09 00:29:19 buzlip01 Exp $");
+RCSTAG("$Id: USETCommand.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
targetUser->setNeedOper(true);
bot->SendTo(theClient, "%s is now required to be an IRC Operator",
targetUser->getUserName().c_str());
- targetUser->commit();
+ targetUser->commit(bot->getLocalDBHandle());
return;
} else if (value == "OFF" || value == "NO" || value == "0") {
targetUser->setNeedOper(false);
bot->SendTo(theClient, "%s is now not required to be an IRC Operator",
targetUser->getUserName().c_str());
- targetUser->commit();
+ targetUser->commit(bot->getLocalDBHandle());
return;
} else {
bot->SendTo(theClient, "Please use USET <username> NEEDOPER <on/off>.");
bot->getResponse(theUser,
language::send_notices,
std::string("I will now send you notices.")).c_str());
- theUser->commit();
+ theUser->commit(bot->getLocalDBHandle());
return;
} else if (value == "OFF" || value == "NO" || value == "0") {
theUser->setNotice(false);
bot->getResponse(theUser,
language::send_privmsgs,
std::string("I will now send you privmsgs.")).c_str());
- theUser->commit();
+ theUser->commit(bot->getLocalDBHandle());
return;
} else {
bot->SendTo(theClient,
if (ptr != bot->languageTable.end()) {
std::string lang = ptr->second.second;
theUser->setLanguageId(ptr->second.first);
- theUser->commit();
+ theUser->commit(bot->getLocalDBHandle());
bot->SendTo(theClient,
bot->getResponse(theUser,
language::lang_set_to,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: WHOGROUPCommand.cc,v 1.5 2007/08/28 16:10:22 dan_karrels Exp $
+ * $Id: WHOGROUPCommand.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include "gnuworld_config.h"
#include "StringTokenizer.h"
#include "sqlcfUser.h"
-RCSTAG("$Id: WHOGROUPCommand.cc,v 1.5 2007/08/28 16:10:22 dan_karrels Exp $");
+RCSTAG("$Id: WHOGROUPCommand.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
if (st.size() == 1) {
/* No parameter supplied, so list all groups */
- dbHandle* cacheCon = bot->theManager->getConnection();
+ dbHandle* cacheCon = bot->getLocalDBHandle();
std::stringstream theQuery;
theQuery << "SELECT DISTINCT faction FROM users ORDER BY faction ASC";
- if (!cacheCon->Exec(theQuery,true)) {
+ if (!cacheCon->Exec(theQuery.str(),true)) {
elog << "chanfix::WHOGROUPCommand> SQL Error: "
<< cacheCon->ErrorMessage()
<< std::endl;
}
/* Dispose of our connection instance */
- bot->theManager->removeConnection(cacheCon);
+ //bot->theManager->removeConnection(cacheCon);
bot->SendTo(theClient,
bot->getResponse(theUser,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: chanfix.cc,v 1.13 2007/08/28 16:10:22 dan_karrels Exp $
+ * $Id: chanfix.cc,v 1.14 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include <csignal>
#include <boost/thread/thread.hpp>
#endif /* CHANFIX_HAVE_BOOST_THREAD */
-RCSTAG("$Id: chanfix.cc,v 1.13 2007/08/28 16:10:22 dan_karrels Exp $");
+RCSTAG("$Id: chanfix.cc,v 1.14 2008/01/16 02:03:39 buzlip01 Exp $");
namespace gnuworld
{
sqlcfUser::F_LOGGEDIN
));
+/* Our global DB handler */
+localDBHandle = theManager->getConnection();
+
/* Set our current day. */
setCurrentDay();
if (theUser) {
theUser->setLastSeen(currentTime());
- theUser->commit();
+ theUser->commit(localDBHandle);
}
commHandler->second->Exec(theClient, theUser ? theUser : NULL, Message);
const std::string Command = string_upper(st[0]);
std::string log;
- dbHandle* cacheCon = theManager->getConnection();
+ dbHandle* cacheCon = getLocalDBHandle();
static const char *Main = "INSERT into comlog (ts,user_name,command) VALUES (now()::abstime::int4,'";
insertString << "')"
<< std::ends;
- if (!cacheCon->Exec(insertString)) {
+ if (!cacheCon->Exec(insertString.str())) {
elog << "sqlChannel::Insert> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
}
- theManager->removeConnection(cacheCon);
+ //theManager->removeConnection(cacheCon);
return true;
}
elog << "*** [chanfix::precacheChanOps] Precaching chanops." << std::endl;
/* Get a connection instance to our backend */
-dbHandle* cacheCon = theManager->getConnection();
+//dbHandle* cacheCon = theManager->getConnection();
/* Check for the backup table. If it exists, something went wrong. */
/* SELECT count(*) FROM pg_tables WHERE tablename = 'chanOpsBackup' */
/* SELECT chanOpsBackup FROM information_schema.tables */
-if (!cacheCon->Exec("SELECT count(*) FROM pg_tables WHERE tablename = 'chanOpsBackup'",true)) {
+if (!localDBHandle->Exec("SELECT count(*) FROM pg_tables WHERE tablename = 'chanOpsBackup'",true)) {
elog << "*** [chanfix::precacheChanOps]: Error checking for backup table presence: "
- << cacheCon->ErrorMessage()
+ << localDBHandle->ErrorMessage()
<< std::endl;
return;
}
-if (cacheCon->Tuples() && atoi(cacheCon->GetValue(0, 0))) {
+if (localDBHandle->Tuples() && atoi(localDBHandle->GetValue(0, 0))) {
elog << "*** [chanfix::precacheChanOps]: Backup table still exists! "
<< "Something must have gone wrong on the last update. Exiting..."
<< std::endl;
elog << "*** [chanfix::precacheChanOps]: Loading chanOps and their points ..."
<< std::endl;
-if (cacheCon->Exec(theQuery,true)) {
- for (unsigned int i = 0 ; i < cacheCon->Tuples(); i++) {
+if (localDBHandle->Exec(theQuery.str(),true)) {
+ for (unsigned int i = 0 ; i < localDBHandle->Tuples(); i++) {
sqlChanOp* newOp = new (std::nothrow) sqlChanOp(theManager);
assert( newOp != 0 ) ;
- newOp->setAllMembers(cacheCon, i);
+ newOp->setAllMembers(localDBHandle, i);
sqlChanOpsType::iterator ptr = sqlChanOps.find(newOp->getChannel());
if (ptr != sqlChanOps.end()) {
ptr->second.insert(sqlChanOpsType::mapped_type::value_type(newOp->getAccount(),newOp));
}
} else {
elog << "*** [chanfix::precacheChanOps] Error executing query: "
- << cacheCon->ErrorMessage()
+ << localDBHandle->ErrorMessage()
<< std::endl;
::exit(0);
}
<< std::endl;
/* Dispose of our connection instance */
-theManager->removeConnection(cacheCon);
+//theManager->removeConnection(cacheCon);
return;
}
elog << "*** [chanfix::precacheChannels] Precaching channels." << std::endl;
/* Get a connection instance to our backend */
-dbHandle* cacheCon = theManager->getConnection();
+dbHandle* cacheCon = localDBHandle;
/* Retrieve the list of channels */
std::stringstream theQuery;
elog << "*** [chanfix::precacheChannels]: Loading channels ..."
<< std::endl;
-if (cacheCon->Exec(theQuery,true)) {
+if (cacheCon->Exec(theQuery.str(),true)) {
for (unsigned int i = 0; i < cacheCon->Tuples(); i++) {
sqlChannel* newChan = new (std::nothrow) sqlChannel(theManager);
assert( newChan != 0 ) ;
<< std::endl;
/* Dispose of our connection instance */
-theManager->removeConnection(cacheCon);
+//theManager->removeConnection(cacheCon);
return;
}
elog << "*** [chanfix::precacheUsers] Precaching users." << std::endl;
/* Get a connection instance to our backend */
-dbHandle* cacheCon = theManager->getConnection();
+dbHandle* cacheCon = localDBHandle;
+
+if (!cacheCon)
+ elog << "*** [chanfix::precacheUsers]: Error getting a new SQL connection through the manager."
+ << std::endl;
/* Retrieve the list of chanops */
-std::stringstream theQuery;
-theQuery << "SELECT id, user_name, created, last_seen, last_updated, last_updated_by, language_id, faction, flags, issuspended, usenotice, needoper "
+std::stringstream myQuery;
+
+
+myQuery << "SELECT id, user_name, created, last_seen, last_updated, last_updated_by, language_id, faction, flags, issuspended, usenotice, needoper "
<< "FROM users"
;
-if (cacheCon->Exec(theQuery,true)) {
+
+if (cacheCon->Exec(myQuery.str(),true)) {
+
/* First we need to clear the current cache. */
for (usersMapType::iterator itr = usersMap.begin();
itr != usersMap.end(); ++itr) {
newUser->setAllMembers(cacheCon, i);
usersMap.insert(usersMapType::value_type(newUser->getUserName(), newUser));
}
+
+
} else {
elog << "*** [chanfix::precacheUsers] Error executing query: "
<< cacheCon->ErrorMessage()
/* Load up the host cache */
for (usersMapType::iterator itr = usersMap.begin();
itr != usersMap.end(); ++itr) {
- itr->second->loadHostList();
+ itr->second->loadHostList(cacheCon);
+
}
elog << "chanfix::precacheUsers> Loaded "
<< std::endl;
/* Dispose of our connection instance */
-theManager->removeConnection(cacheCon);
+//theManager->removeConnection(cacheCon);
return;
}
const std::string chanfix::getHostList( sqlcfUser* User)
{
/* Get a connection instance to our backend */
-dbHandle* cacheCon = theManager->getConnection();
+dbHandle* cacheCon = localDBHandle;
/* Grab the user's host list */
static const char* queryHeader
<< User->getID()
;
-if (!cacheCon->Exec(theQuery,true)) {
+if (!cacheCon->Exec(theQuery.str(),true)) {
elog << "chanfix::getHostList> SQL Error: "
<< cacheCon->ErrorMessage()
<< std::endl;
if (hostlist.str() == "") hostlist << "None.";
/* Dispose of our connection instance */
-theManager->removeConnection(cacheCon);
+//theManager->removeConnection(cacheCon);
return hostlist.str();
}
const int chanfix::getLastFix(sqlChannel* theChan)
{
/* Get a connection instance to our backend */
-dbHandle* cacheCon = theManager->getConnection();
+dbHandle* cacheCon = localDBHandle;
/* Grab the user's host list */
static const char* queryHeader
<< theChan->getID()
;
-if (!cacheCon->Exec(theQuery,true)) {
+if (!cacheCon->Exec(theQuery.str(),true)) {
elog << "chanfix::getHostList> SQL Error: "
<< cacheCon->ErrorMessage()
<< std::endl;
}
/* Dispose of our connection instance */
-theManager->removeConnection(cacheCon);
+//theManager->removeConnection(cacheCon);
return max_ts;
}
bool chanfix::deleteChannelRecord(sqlChannel* sqlChan)
{
-if (sqlChan->useSQL() && sqlChan->Delete())
+if (sqlChan->useSQL() && sqlChan->Delete(localDBHandle))
return false;
sqlChanCache.erase(sqlChan->getChannel());
delete sqlChan; sqlChan = 0;
updateDBTimer.Start();
/* Get a connection instance to our backend */
- dbHandle* cacheCon = theManager->getConnection();
+ dbHandle* cacheCon = localDBHandle;
/* Check for the backup table. If it exists, something went wrong. */
/* SELECT count(*) FROM pg_tables WHERE tablename = 'chanOpsBackup' */
}
/* Copy the current chanOps to SQL. */
- if( !cacheCon->StartCopyIn("COPY chanOps FROM stdin") )
+ if( !cacheCon->Exec("COPY chanOps FROM stdin") )
{
elog << "*** [chanfix::updateDB]: Error starting copy of chanOps table."
+ << cacheCon->ErrorMessage()
<< std::endl;
return;
}
}
/* Dispose of our connection instance */
- theManager->removeConnection(cacheCon);
+ //theManager->removeConnection(cacheCon);
/* Clean-up after ourselves and allow new updates to be started */
snapShot.clear();
void chanfix::loadHelpTable()
{
/* Get a connection instance to our backend */
-dbHandle* cacheCon = theManager->getConnection();
+//dbHandle* cacheCon = theManager->getConnection();
/* Grab the help table */
std::stringstream theQuery;
theQuery << "SELECT language_id,topic,contents FROM help"
;
-
-if (cacheCon->Exec(theQuery,true))
- for (unsigned int i = 0; i < cacheCon->Tuples(); i++)
+if (localDBHandle->Exec("SELECT language_id,topic,contents FROM help",true))
+ for (unsigned int i = 0; i < localDBHandle->Tuples(); i++)
helpTable.insert(helpTableType::value_type(
- std::make_pair(atoi(cacheCon->GetValue(i, 0)),
- cacheCon->GetValue(i, 1)),
- cacheCon->GetValue(i, 2)));
+ std::make_pair(atoi(localDBHandle->GetValue(i, 0)),
+ localDBHandle->GetValue(i, 1)),
+ localDBHandle->GetValue(i, 2)));
elog << "*** [chanfix::loadHelpTable]: Loaded "
<< helpTable.size()
<< std::endl;
/* Dispose of our connection instance */
-theManager->removeConnection(cacheCon);
+//theManager->removeConnection(cacheCon);
return;
}
langQuery << "SELECT id,code,name FROM languages"
;
-if (cacheCon->Exec(langQuery,true))
+if (cacheCon->Exec(langQuery.str(),true))
for (unsigned int i = 0; i < cacheCon->Tuples(); i++)
languageTable.insert(languageTableType::value_type(cacheCon->GetValue(i, 1),
std::make_pair(atoi(cacheCon->GetValue(i, 0)),
transQuery << "SELECT language_id,response_id,text FROM translations"
;
-if (cacheCon->Exec(transQuery,true)) {
+if (cacheCon->Exec(transQuery.str(),true)) {
for (unsigned int i = 0 ; i < cacheCon->Tuples(); i++) {
/*
* Add to our translations table.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: chanfix.h,v 1.8 2007/08/28 16:10:22 dan_karrels Exp $
+ * $Id: chanfix.h,v 1.9 2008/01/16 02:03:39 buzlip01 Exp $
*/
#ifndef __CHANFIX_H
-#define __CHANFIX_H "$Id: chanfix.h,v 1.8 2007/08/28 16:10:22 dan_karrels Exp $"
+#define __CHANFIX_H "$Id: chanfix.h,v 1.9 2008/01/16 02:03:39 buzlip01 Exp $"
#include <string>
#include <vector>
#include <map>
#include <list>
+#include <sstream>
#include "client.h"
#include "EConfig.h"
sqlChanOp* findChanOp(const std::string&, const std::string&);
sqlChanOp* findChanOp(Channel*, iClient*);
+ dbHandle* getLocalDBHandle() { return localDBHandle; }
+
size_t countMyOps(const std::string&);
size_t countMyOps(Channel*);
std::ofstream adminLog;
std::ofstream debugLog;
+ /**
+ * DB Handle
+ */
+ dbHandle* localDBHandle;
+
+
public:
/*
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: sqlChannel.cc,v 1.5 2007/08/28 16:10:25 dan_karrels Exp $
+ * $Id: sqlChannel.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $
*/
#include <sstream>
/**
* This function inserts a brand new channel into the DB.
*/
-bool sqlChannel::Insert()
+bool sqlChannel::Insert(dbHandle* cacheCon)
{
/* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
/* Grab the next available user id */
id = ++maxUserId;
<< ")"
;
-if (!cacheCon->Exec(insertString)) {
+if (!cacheCon->Exec(insertString.str())) {
elog << "sqlChannel::Insert> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
}
/* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
return inSQL;
} // sqlChannel::Insert()
-bool sqlChannel::Delete()
+bool sqlChannel::Delete(dbHandle* cacheCon)
{
bool retval = false;
/* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
/* Create the DELETE statement */
std::stringstream deleteString;
<< "WHERE id = '" << id << "'"
;
-if (!cacheCon->Exec(deleteString)) {
+if (!cacheCon->Exec(deleteString.str())) {
elog << "sqlChannel::Delete> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = true;
/* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
return retval;
}
-bool sqlChannel::commit()
+bool sqlChannel::commit(dbHandle* cacheCon)
{
bool retval = false;
/* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
/* Create the UPDATE statement */
std::stringstream chanCommit;
<< "id = " << id
;
-if (!cacheCon->Exec(chanCommit)) {
+if (!cacheCon->Exec(chanCommit.str())) {
elog << "sqlChannel::commit> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = true;
/* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
return retval;
}
* occured in this channel.
*/
-void sqlChannel::addNote(unsigned short eventType, iClient* theUser,
+void sqlChannel::addNote(dbHandle* cacheCon, unsigned short eventType, iClient* theUser,
const std::string& theMessage)
{
-unsigned int num_notes = countNotes(0);
+unsigned int num_notes = countNotes(cacheCon, 0);
while (num_notes >= MAXNOTECOUNT) {
- if (!deleteOldestNote())
+ if (!deleteOldestNote(cacheCon))
return;
num_notes--;
}
/* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
/* Create the INSERT statement */
std::stringstream theLog;
<< "')"
;
-if (!cacheCon->Exec(theLog)) {
+if (!cacheCon->Exec(theLog.str())) {
elog << "sqlChannel::addNote> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
}
/* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
return;
}
-const std::string sqlChannel::getLastNote(unsigned short eventType, time_t& eventTime)
+const std::string sqlChannel::getLastNote(dbHandle* cacheCon, unsigned short eventType, time_t& eventTime)
{
std::string retval;
/* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
/* Retrieve the last note */
std::stringstream queryString;
<< " ORDER BY ts DESC LIMIT 1"
;
-if (cacheCon->Exec(queryString,true)) {
+if (cacheCon->Exec(queryString.str(),true)) {
if (cacheCon->Tuples() > 0) {
std::string note = cacheCon->GetValue(0, 0);
eventTime = atoi(cacheCon->GetValue(0, 1));
}
/* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
return retval;
}
-bool sqlChannel::deleteNote(unsigned int messageId)
+bool sqlChannel::deleteNote(dbHandle* cacheCon, unsigned int messageId)
{
bool retval = false;
/* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
/* Create the DELETE statement */
std::stringstream deleteString;
<< messageId
;
-if (!cacheCon->Exec(deleteString)) {
+if (!cacheCon->Exec(deleteString.str())) {
elog << "sqlChannel::deleteNote> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = true;
/* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
return retval;
}
-bool sqlChannel::deleteOldestNote()
+bool sqlChannel::deleteOldestNote(dbHandle* cacheCon)
{
bool retval = false;
/* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
/* Retrieve the id of the oldest note */
std::stringstream selectString;
<< " ORDER BY ts ASC LIMIT 1"
;
-if (cacheCon->Exec(selectString,true)) {
+if (cacheCon->Exec(selectString.str(),true)) {
if (cacheCon->Tuples() > 0) {
unsigned int note_id = atoi(cacheCon->GetValue(0, 0));
<< note_id
;
- if (cacheCon->Exec(deleteString,true))
+ if (cacheCon->Exec(deleteString.str(),true))
retval = true;
}
}
/* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
return retval;
}
-bool sqlChannel::deleteAllNotes()
+bool sqlChannel::deleteAllNotes(dbHandle* cacheCon)
{
bool retval = false;
/* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
/* Create the DELETE statement */
std::stringstream deleteString;
<< id
;
-if (!cacheCon->Exec(deleteString)) {
+if (!cacheCon->Exec(deleteString.str())) {
elog << "sqlChannel::deleteAllNotes> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = true;
/* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
return retval;
}
-size_t sqlChannel::countNotes(unsigned short eventType)
+size_t sqlChannel::countNotes(dbHandle* cacheCon, unsigned short eventType)
{
/* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
/* Count the notes */
std::stringstream queryString;
size_t num_notes = 0;
-if (cacheCon->Exec(queryString,true))
+if (cacheCon->Exec(queryString.str(),true))
num_notes = atoi(cacheCon->GetValue(0, 0));
/* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
return num_notes;
}
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: sqlChannel.h,v 1.6 2007/08/28 16:10:25 dan_karrels Exp $
+ * $Id: sqlChannel.h,v 1.7 2008/01/16 02:03:39 buzlip01 Exp $
*/
#ifndef __SQLCHANNEL_H
-#define __SQLCHANNEL_H "$Id: sqlChannel.h,v 1.6 2007/08/28 16:10:25 dan_karrels Exp $"
+#define __SQLCHANNEL_H "$Id: sqlChannel.h,v 1.7 2008/01/16 02:03:39 buzlip01 Exp $"
#include <string>
#include <ctime>
inline void setUseSQL(bool _inSQL)
{ inSQL = _inSQL; }
- bool Insert();
- bool Delete();
- bool commit();
+ bool Insert(dbHandle*);
+ bool Delete(dbHandle*);
+ bool commit(dbHandle*);
void setAllMembers(dbHandle*, int);
/** Static member for keeping track of max user id */
static unsigned long int maxUserId;
- void addNote(unsigned short, iClient*, const std::string&);
- bool deleteNote(unsigned int);
- bool deleteOldestNote();
- bool deleteAllNotes();
- size_t countNotes(unsigned short);
- const std::string getLastNote(unsigned short, time_t&);
+ void addNote(dbHandle*, unsigned short, iClient*, const std::string&);
+ bool deleteNote(dbHandle*, unsigned int);
+ bool deleteOldestNote(dbHandle*);
+ bool deleteAllNotes(dbHandle*);
+ size_t countNotes(dbHandle*, unsigned short);
+ const std::string getLastNote(dbHandle*, unsigned short, time_t&);
protected:
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: sqlcfUser.cc,v 1.3 2007/08/28 16:10:25 dan_karrels Exp $
+ * $Id: sqlcfUser.cc,v 1.4 2008/01/16 02:03:40 buzlip01 Exp $
*/
#include <sstream>
#include "chanfix.h"
#include "sqlcfUser.h"
+using namespace std;
+
namespace gnuworld
{
+using std::stringstream;
+using std::string;
+
namespace cf
{
if (id > maxUserId) maxUserId = id;
}
-bool sqlcfUser::commit()
+bool sqlcfUser::commit(dbHandle* cacheCon)
{
bool retval = false;
/* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
/* Create the UPDATE statement */
std::stringstream userCommit;
<< "id = " << id
;
-if (!cacheCon->Exec(userCommit)) {
+if (!cacheCon->Exec(userCommit.str())) {
elog << "sqlcfUser::commit> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = true;
/* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
return retval;
}
* so that any new fields added will automatically be dealt with in commit()
* instead of in 50 different functions.
*/
-bool sqlcfUser::Insert()
+bool sqlcfUser::Insert(dbHandle* cacheCon)
{
bool retval = false;
/* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
/* Grab the next available user id */
id = ++maxUserId;
<< ")"
;
-if (!cacheCon->Exec(insertString)) {
+if (!cacheCon->Exec(insertString.str())) {
elog << "sqlcfUser::Insert> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = true;
/* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
if (retval)
- commit();
+ commit(cacheCon);
return retval;
} // sqlcfUser::Insert()
-bool sqlcfUser::Delete()
+bool sqlcfUser::Delete(dbHandle* cacheCon)
{
bool retval = false;
/* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
/* Create the DELETE statement */
std::stringstream hostString;
<< "WHERE user_id = " << id
;
-if (!cacheCon->Exec(hostString)) {
+if (!cacheCon->Exec(hostString.str())) {
elog << "sqlcfUser::Delete> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
<< "WHERE id = '" << id << "'"
;
-if (!cacheCon->Exec(deleteString)) {
+if (!cacheCon->Exec(deleteString.str())) {
elog << "sqlcfUser::Delete> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = true;
/* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
return retval;
}
-void sqlcfUser::loadHostList()
+void sqlcfUser::loadHostList(dbHandle* cacheCon)
{
/* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+
+// dbHandle* cacheCon = myManager->getConnection();
+// if (!cacheCon)
+// elog << "[sqlcfUser::loadHostList() Could not get a connection to the database from the manager." << std::endl;
+
/* Retrieve the hosts */
std::stringstream theQuery;
+
theQuery << "SELECT host FROM hosts WHERE user_id = "
<< id
- ;
+ << ends ;
-if (cacheCon->Exec(theQuery,true)) {
+
+if (cacheCon->Exec(theQuery.str(),true)) {
// SQL Query succeeded
for (unsigned int i = 0 ; i < cacheCon->Tuples(); i++) {
hostList.push_back(cacheCon->GetValue(i, 0));
}
/* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
-
+// myManager->removeConnection(cacheCon);
return;
}
-bool sqlcfUser::addHost(const std::string& _theHost)
+bool sqlcfUser::addHost(dbHandle* cacheCon, const std::string& _theHost)
{
bool retval = false;
/* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
/* Create the INSERT statement */
std::stringstream insertString;
<< "')"
;
-if (!cacheCon->Exec(insertString)) {
+if (!cacheCon->Exec(insertString.str())) {
elog << "sqlcfUser::addHost> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = true;
/* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
hostList.push_back(_theHost);
return retval;
}
-bool sqlcfUser::delHost(const std::string& _theHost)
+bool sqlcfUser::delHost(dbHandle* cacheCon, const std::string& _theHost)
{
bool retval = false;
/* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
/* Create the DELETE statement */
std::stringstream deleteString;
<< "'"
;
-if (!cacheCon->Exec(deleteString)) {
+if (!cacheCon->Exec(deleteString.str())) {
elog << "sqlcfUser::delHost> Something went wrong: "
<< cacheCon->ErrorMessage()
<< std::endl;
retval = true;
/* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
if (hostList.size() < 1) return false;
hostListType::iterator ptr = find( hostList.begin(), hostList.end(), string_lower(_theHost) );
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
- * $Id: sqlcfUser.h,v 1.3 2007/08/28 16:10:25 dan_karrels Exp $
+ * $Id: sqlcfUser.h,v 1.4 2008/01/16 02:03:40 buzlip01 Exp $
*/
#ifndef __sqlcfUser_H
-#define __sqlcfUser_H "$Id: sqlcfUser.h,v 1.3 2007/08/28 16:10:25 dan_karrels Exp $"
+#define __sqlcfUser_H "$Id: sqlcfUser.h,v 1.4 2008/01/16 02:03:40 buzlip01 Exp $"
#include <string>
#include <vector>
#include <ctime>
+#include <sstream>
#include "dbHandle.h"
+using namespace std;
+
namespace gnuworld
{
/* Methods to alter our SQL status */
void setAllMembers(dbHandle*, int);
- bool commit();
- bool Insert();
- bool Delete();
+ bool commit(dbHandle*);
+ bool Insert(dbHandle*);
+ bool Delete(dbHandle*);
/** Static member for keeping track of max user id */
static unsigned long int maxUserId;
- void loadHostList();
- bool addHost(const std::string&);
- bool delHost(const std::string&);
+ void loadHostList(dbHandle*);
+ bool addHost(dbHandle*, const std::string&);
+ bool delHost(dbHandle*, const std::string&);
bool matchHost(const std::string&);
bool hasHost(const std::string&);