diff options
Diffstat (limited to 'src/modules/extra')
-rw-r--r-- | src/modules/extra/m_sql.cpp | 16 | ||||
-rw-r--r-- | src/modules/extra/m_sqllog.cpp | 36 |
2 files changed, 27 insertions, 25 deletions
diff --git a/src/modules/extra/m_sql.cpp b/src/modules/extra/m_sql.cpp index 45421e334..dd0cbdc1d 100644 --- a/src/modules/extra/m_sql.cpp +++ b/src/modules/extra/m_sql.cpp @@ -56,7 +56,9 @@ class SQLConnection this->pass = thispass; this->db = thisdb; this->id = myid; + unsigned int timeout = 1; mysql_init(&connection); + mysql_options(&connection,MYSQL_OPT_CONNECT_TIMEOUT,(char*)&timeout); } // This method connects to the database using the credentials supplied to the constructor, and returns @@ -187,18 +189,18 @@ class ModuleSQL : public Module } } - void LoadDatabases(ConfigReader* Conf) + void LoadDatabases(ConfigReader* ThisConf) { Srv->Log(DEFAULT,"SQL: Loading database settings"); Connections.clear(); Srv->Log(DEBUG,"Cleared connections"); - for (int j =0; j < Conf->Enumerate("database"); j++) + for (int j =0; j < ThisConf->Enumerate("database"); j++) { - std::string db = Conf->ReadValue("database","name",j); - std::string user = Conf->ReadValue("database","username",j); - std::string pass = Conf->ReadValue("database","password",j); - std::string host = Conf->ReadValue("database","hostname",j); - std::string id = Conf->ReadValue("database","id",j); + std::string db = ThisConf->ReadValue("database","name",j); + std::string user = ThisConf->ReadValue("database","username",j); + std::string pass = ThisConf->ReadValue("database","password",j); + std::string host = ThisConf->ReadValue("database","hostname",j); + std::string id = ThisConf->ReadValue("database","id",j); Srv->Log(DEBUG,"Read database settings"); if ((db != "") && (host != "") && (user != "") && (id != "") && (pass != "")) { diff --git a/src/modules/extra/m_sqllog.cpp b/src/modules/extra/m_sqllog.cpp index 55343e96d..035012650 100644 --- a/src/modules/extra/m_sqllog.cpp +++ b/src/modules/extra/m_sqllog.cpp @@ -100,26 +100,26 @@ class ModuleSQLLog : public Module delete query; if (nid < 1) { - SQLRequest* query = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_actors VALUES('','"+nick+"')"); - Request queryrequest((char*)query, this, SQLModule); - SQLResult* result = (SQLResult*)queryrequest.Send(); - if (result->GetType() == SQL_ERROR) + SQLRequest* query2 = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_actors VALUES('','"+nick+"')"); + Request queryrequest2((char*)query2, this, SQLModule); + SQLResult* result2 = (SQLResult*)queryrequest2.Send(); + if (result2->GetType() == SQL_ERROR) { - Srv->Log(DEFAULT,"SQL log error: " + result->GetError()); + Srv->Log(DEFAULT,"SQL log error: " + result2->GetError()); } - if (result) + if (result2) delete result; - if (query) - delete query; + if (query2) + delete query2; nid = InsertNick(nick); } return nid; } - void InsertEntry(long category,long nickid,long hostid,long sourceid,unsigned long date) + void InsertEntry(unsigned long category,unsigned long nickid,unsigned long hostid,unsigned long sourceid,unsigned long date) { char querybuffer[MAXBUF]; - snprintf(querybuffer,MAXBUF,"INSERT INTO ircd_log VALUES('',%d,%d,%d,%d,%lu)",category,nickid,hostid,sourceid,date); + snprintf(querybuffer,MAXBUF,"INSERT INTO ircd_log VALUES('',%lu,%lu,%lu,%lu,%lu)",(unsigned long)category,(unsigned long)nickid,(unsigned long)hostid,(unsigned long)sourceid,(unsigned long)date); SQLRequest* query = new SQLRequest(SQL_COUNT,dbid,querybuffer); Request queryrequest((char*)query, this, SQLModule); SQLResult* result = (SQLResult*)queryrequest.Send(); @@ -160,17 +160,17 @@ class ModuleSQLLog : public Module delete query; if (hid < 1) { - SQLRequest* query = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_hosts VALUES('','"+host+"')"); - Request queryrequest((char*)query, this, SQLModule); - SQLResult* result = (SQLResult*)queryrequest.Send(); - if (result->GetType() == SQL_ERROR) + SQLRequest* query2 = new SQLRequest(SQL_COUNT,dbid,"INSERT INTO ircd_log_hosts VALUES('','"+host+"')"); + Request queryrequest2((char*)query2, this, SQLModule); + SQLResult* result2 = (SQLResult*)queryrequest2.Send(); + if (result2->GetType() == SQL_ERROR) { - Srv->Log(DEFAULT,"SQL log error: " + result->GetError()); + Srv->Log(DEFAULT,"SQL log error: " + result2->GetError()); } if (result) - delete result; + delete result2; if (query) - delete query; + delete query2; hid = InsertHost(host); } return hid; @@ -185,7 +185,7 @@ class ModuleSQLLog : public Module long nickid = InsertNick(nick); long sourceid = InsertNick(source); long hostid = InsertHost(host); - InsertEntry(category,nickid,hostid,sourceid,time(NULL)); + InsertEntry((unsigned)category,(unsigned)nickid,(unsigned)hostid,(unsigned)sourceid,(unsigned long)time(NULL)); } virtual void OnOper(userrec* user) |