simply adding check for the convar disablehtml motd to check if webapp misses the updates sometimes

This commit is contained in:
jenz 2023-08-01 23:49:29 +02:00
parent b54644c0ea
commit 28bb26e897
2 changed files with 27 additions and 32 deletions

View File

@ -1,10 +1,11 @@
CREATE TABLE ban_detector.ban_detector (
CREATE TABLE `ban_detector` (
`fingerprint` varchar(512) DEFAULT NULL,
`ip` varchar(64) NOT NULL,
`steamid` varchar(64) NOT NULL,
`name` varchar(128) DEFAULT NULL,
`created_on` datetime DEFAULT CURRENT_TIMESTAMP,
`modified_on` datetime default null,
`last_connect` datetime default null,
`created_on` datetime DEFAULT current_timestamp(),
`modified_on` datetime DEFAULT NULL,
`last_connect` datetime DEFAULT NULL,
`disable_html_motd` int(11) DEFAULT 0,
PRIMARY KEY (`steamid`)
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

View File

@ -60,10 +60,29 @@ public void OnClientPostAdminCheck(int client)
if (!IsFakeClient(client) && !IsClientSourceTV(client))
{
SQL_addEntry(client);
QueryClientConVar(client, "cl_disablehtmlmotd", CvarQueryFinished);
CreateTimer(15.0, SQL_Select_fingerprints, GetClientSerial(client));
}
}
public void CvarQueryFinished(QueryCookie cookie, int client, ConVarQueryResult res, const char[] sCvarName, const char[] sCvarVal)
{
if (res != ConVarQuery_Okay)
{
return;
}
int disable_html_motd = StringToInt(sCvarVal);
if (IsValidClient(client))
{
char sQuery[g_dLength];
char sSID[MAX_NAME_LENGTH];
GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
Format(sQuery, sizeof(sQuery), "UPDATE ban_detector SET last_connect = now(), disable_html_motd = '%i' where steamid = '%s'", disable_html_motd, sSID);
g_dDatabase.Query(SQL_callbackDummy, sQuery, GetClientSerial(client), DBPrio_Low);
}
}
public void SQL_addEntry(int client)
{
char sQuery[g_dLength];
@ -77,35 +96,10 @@ public void SQL_addEntry(int client)
g_dDatabase.Escape(sName, sEscapedName, size2 + 1);
GetClientIP(client, sIP, sizeof(sIP));
Format(sQuery, sizeof(sQuery), "insert ignore into `ban_detector` (`steamid`, `ip`, `name`) SELECT '%s', '%s','%s'", sSID, sIP,sEscapedName);
g_dDatabase.Query(SQL_UpdateEntry, sQuery, GetClientSerial(client), DBPrio_Low);
g_dDatabase.Query(SQL_callbackDummy, sQuery, GetClientSerial(client), DBPrio_Low);
}
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))
{
char sQuery[g_dLength];
char sSID[MAX_NAME_LENGTH];
GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
Format(sQuery, sizeof(sQuery), "UPDATE ban_detector SET last_connect = now() where steamid = '%s'", sSID);
g_dDatabase.Query(SQL_update_last_connect, sQuery, GetClientSerial(client), DBPrio_Low);
}
delete results;
}
public void SQL_update_last_connect(Database db, DBResultSet results, const char[] error, int Serial)
public void SQL_callbackDummy(Database db, DBResultSet results, const char[] error, int Serial)
{
if(!db || strlen(error))
{