delete dbresults in more cases, some printing, using getclientserial
This commit is contained in:
@@ -62,7 +62,7 @@ public void SQL_addEntry(int client)
|
||||
g_dDatabase.Escape(sName, sEscapedName, size2 + 1);
|
||||
GetClientIP(client, sIP, sizeof(sIP));
|
||||
Format(sQuery, sizeof(sQuery), "insert into `ban_detector_steamids` (`steamid`, `name`, `ID`) SELECT '%s', '%s', bd.ID from `ban_detector` bd where bd.ip = '%s' and not exists (select bds.ID from `ban_detector_steamids` bds where bds.ID = bd.ID and bds.steamid = '%s')", sSID, sEscapedName, sIP, sSID);
|
||||
g_dDatabase.Query(SQL_UpdateEntry, sQuery, client, DBPrio_Low);
|
||||
g_dDatabase.Query(SQL_UpdateEntry, sQuery, GetClientSerial(client), DBPrio_Low);
|
||||
}
|
||||
|
||||
public void SQL_OnDatabaseConnect(Database db, const char[] error, any data)
|
||||
@@ -79,18 +79,25 @@ public void SQL_OnDatabaseConnect_sb(Database db, const char[] error, any data)
|
||||
{
|
||||
if(!db || strlen(error))
|
||||
{
|
||||
LogError("Database error: %s", error);
|
||||
return;
|
||||
LogError("Database error: %s", error);
|
||||
return;
|
||||
}
|
||||
g_hDatabase_sourceban = db;
|
||||
}
|
||||
|
||||
|
||||
public void SQL_UpdateEntry(Database db, DBResultSet results, const char[] error, int client)
|
||||
public void SQL_UpdateEntry(Database db, DBResultSet results, const char[] error, int Serial)
|
||||
{
|
||||
if(!db || strlen(error))
|
||||
{
|
||||
LogError("Database error: %s", error);
|
||||
delete results;
|
||||
return;
|
||||
}
|
||||
int client;
|
||||
if ((client = GetClientFromSerial(Serial)) == 0)
|
||||
{
|
||||
delete results;
|
||||
return;
|
||||
}
|
||||
if (IsValidClient(client))
|
||||
@@ -102,16 +109,28 @@ public void SQL_UpdateEntry(Database db, DBResultSet results, const char[] error
|
||||
GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
|
||||
Format(sQuery, sizeof(sQuery), "SELECT bd.fingerprint FROM `ban_detector` bd inner join `ban_detector_steamids` bds on bd.ID = bds.ID where bds.steamid = '%s' or bd.ip = '%s'", sSID, sIP);
|
||||
//PrintToChatAll("sQuery: %s", sQuery);
|
||||
g_dDatabase.Query(SQL_FindFingerPrints, sQuery, client, DBPrio_Low);
|
||||
g_dDatabase.Query(SQL_FindFingerPrints, sQuery, GetClientSerial(client), DBPrio_Low);
|
||||
}
|
||||
delete results;
|
||||
}
|
||||
|
||||
public void SQL_FindFingerPrints(Database db, DBResultSet results, const char[] error, int client)
|
||||
public void SQL_FindFingerPrints(Database db, DBResultSet results, const char[] error, int Serial)
|
||||
{
|
||||
if (!db || strlen(error))
|
||||
{
|
||||
LogError("Database error: %s", error);
|
||||
delete results;
|
||||
return;
|
||||
}
|
||||
int client;
|
||||
if ((client = GetClientFromSerial(Serial)) == 0)
|
||||
{
|
||||
delete results;
|
||||
return;
|
||||
}
|
||||
if (!IsValidClient(client))
|
||||
{
|
||||
delete results;
|
||||
return;
|
||||
}
|
||||
char fingerprint[1024];
|
||||
@@ -123,7 +142,7 @@ public void SQL_FindFingerPrints(Database db, DBResultSet results, const char[]
|
||||
g_dDatabase.Escape(fingerprint, sEscapedFingerPrint, 1024);
|
||||
Format(sQuery, sizeof(sQuery), "select steamid, ip from ban_detector bd inner join ban_detector_steamids bds on bd.ID = bds.ID where fingerprint = '%s'", sEscapedFingerPrint);
|
||||
//PrintToChatAll("sQuery: %s", sQuery);
|
||||
g_dDatabase.Query(SQL_checkSourcebans, sQuery, client, DBPrio_Low);
|
||||
g_dDatabase.Query(SQL_checkSourcebans, sQuery, GetClientSerial(client), DBPrio_Low);
|
||||
if (IsValidClient(client) && g_bReportedClientBanAvoiding[client])
|
||||
{
|
||||
break;
|
||||
@@ -132,14 +151,26 @@ public void SQL_FindFingerPrints(Database db, DBResultSet results, const char[]
|
||||
delete results;
|
||||
}
|
||||
|
||||
public void SQL_checkSourcebans(Database db, DBResultSet results, const char[] error, int client)
|
||||
public void SQL_checkSourcebans(Database db, DBResultSet results, const char[] error, int Serial)
|
||||
{
|
||||
if (!db || strlen(error))
|
||||
{
|
||||
delete results;
|
||||
LogError("Database error: %s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
int client;
|
||||
if ((client = GetClientFromSerial(Serial)) == 0)
|
||||
{
|
||||
delete results;
|
||||
return;
|
||||
}
|
||||
if (!IsValidClient(client))
|
||||
{
|
||||
delete results;
|
||||
return;
|
||||
}
|
||||
while (results.RowCount > 0 && results.FetchRow())
|
||||
{
|
||||
char sSID[MAX_NAME_LENGTH];
|
||||
@@ -151,7 +182,7 @@ public void SQL_checkSourcebans(Database db, DBResultSet results, const char[] e
|
||||
//PrintToChatAll(sIP);
|
||||
// + 3600 for one hour to accomdate timezone difference
|
||||
Format(sql_statement, sizeof(sql_statement), "select authid, ip from sb_bans where ((ip = '%s' and ip is not null and ip != '') or (authid = '%s' and authid is not null and authid =! '')) and (RemoveType != 'U' or RemoveType is NULL) and (ends > UNIX_TIMESTAMP() + 3600 or ends = created) order by created desc limit 1", sIP, sSID);
|
||||
g_hDatabase_sourceban.Query(sql_select_sb_bans, sql_statement, client, DBPrio_Low);
|
||||
g_hDatabase_sourceban.Query(sql_select_sb_bans, sql_statement, GetClientSerial(client), DBPrio_Low);
|
||||
if (IsValidClient(client) && g_bReportedClientBanAvoiding[client])
|
||||
{
|
||||
break;
|
||||
@@ -160,14 +191,21 @@ public void SQL_checkSourcebans(Database db, DBResultSet results, const char[] e
|
||||
delete results;
|
||||
}
|
||||
|
||||
public void sql_select_sb_bans(Database db, DBResultSet results, const char[] error, int client)
|
||||
public void sql_select_sb_bans(Database db, DBResultSet results, const char[] error, int Serial)
|
||||
{
|
||||
if (!db || strlen(error))
|
||||
{
|
||||
delete results;
|
||||
LogError("Database error: %s", error);
|
||||
return;
|
||||
}
|
||||
|
||||
int client;
|
||||
if ((client = GetClientFromSerial(Serial)) == 0)
|
||||
{
|
||||
delete results;
|
||||
return;
|
||||
}
|
||||
if (!IsValidClient(client))
|
||||
{
|
||||
delete results;
|
||||
|
||||
Reference in New Issue
Block a user