added discord integration and updated create table script
This commit is contained in:
parent
532c3212ce
commit
2d3ef46f86
@ -1,9 +1,25 @@
|
||||
CREATE TABLE ban_detector (
|
||||
CREATE TABLE `ban_detector` (
|
||||
`fingerprint` varchar(512) NOT NULL,
|
||||
`ip` varchar(64) NOT NULL,
|
||||
`steamid` varchar(64),
|
||||
`name` varchar(128),
|
||||
`logged_message` boolean default false,
|
||||
`created_on` datetime DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`fingerprint`, `ip`)
|
||||
)
|
||||
`steamid` varchar(64) DEFAULT NULL,
|
||||
`name` varchar(128) DEFAULT NULL,
|
||||
`created_on` datetime DEFAULT CURRENT_TIMESTAMP
|
||||
PRIMARY KEY (`fingerprint`,`ip`)
|
||||
);
|
||||
|
||||
|
||||
--usefull read query
|
||||
select bd2.* from ban_detector bd2
|
||||
inner join
|
||||
(
|
||||
SELECT fingerprint,
|
||||
count(*) AS c
|
||||
FROM ban_detector bd
|
||||
GROUP BY fingerprint
|
||||
HAVING c > 1
|
||||
ORDER BY c DESC
|
||||
) as t
|
||||
on bd2.fingerprint = t.fingerprint
|
||||
|
||||
|
||||
|
||||
|
28
jenz_ban_detector/scripting/include/jenz_ban_detector.inc
Normal file
28
jenz_ban_detector/scripting/include/jenz_ban_detector.inc
Normal file
@ -0,0 +1,28 @@
|
||||
#if defined _jenz_ban_detector_Included
|
||||
#endinput
|
||||
#endif
|
||||
#define _jenz_ban_detector_Included
|
||||
|
||||
/**
|
||||
* Called after a client has been detected for ban avoiding
|
||||
*
|
||||
* @param client Client index of the target.
|
||||
* @param detected_sourceban either steamID or IP of the detected sourceban ban
|
||||
* @noreturn
|
||||
*/
|
||||
forward void BanDetectorPost(int client, const char[] detected_sourceban);
|
||||
|
||||
|
||||
/* Do not edit below this line */
|
||||
public SharedPlugin __pl_jenz_ban_detector =
|
||||
{
|
||||
name = "jenz_ban_detector",
|
||||
file = "jenz_ban_detector.smx",
|
||||
#if defined REQUIRE_PLUGIN
|
||||
required = 1,
|
||||
#else
|
||||
required = 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
int validate_state [MAXPLAYERS + 1];
|
||||
Database g_dDatabase;
|
||||
Database g_hDatabase_sourceban;
|
||||
Handle g_hOnReportBanPostForward;
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
@ -22,9 +23,15 @@ public Plugin myinfo =
|
||||
url = "www.unloze.com"
|
||||
};
|
||||
|
||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||
{
|
||||
RegPluginLibrary("jenz_ban_detector");
|
||||
return APLRes_Success;
|
||||
}
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
g_hOnReportBanPostForward = CreateGlobalForward("BanDetectorPost", ET_Ignore, Param_Cell, Param_String);
|
||||
if (!g_dDatabase)
|
||||
{
|
||||
Database.Connect(SQL_OnDatabaseConnect, "jenz_ban_detector");
|
||||
@ -90,7 +97,7 @@ public void SQL_UpdateEntry(Database db, DBResultSet results, const char[] error
|
||||
char sQuery[g_dLength];
|
||||
char sSID[MAX_NAME_LENGTH];
|
||||
GetClientAuthId(client, AuthId_Steam2, sSID, sizeof(sSID));
|
||||
Format(sQuery, sizeof(sQuery), "SELECT fingerprint FROM `ban_detector` where steamid = '%s' and detected_on_sourceban is NULL limit 1", sSID);
|
||||
Format(sQuery, sizeof(sQuery), "SELECT fingerprint FROM `ban_detector` where steamid = '%s' limit 1", sSID);
|
||||
//PrintToChatAll("sQuery: %s", sQuery);
|
||||
g_dDatabase.Query(SQL_FindFingerPrints, sQuery, client, DBPrio_High);
|
||||
}
|
||||
@ -157,28 +164,22 @@ public void sql_select_sb_bans(Database db, DBResultSet results, const char[] er
|
||||
if (results.RowCount && results.FetchRow())
|
||||
{
|
||||
char sSID[MAX_NAME_LENGTH];
|
||||
char sSIDClient[MAX_NAME_LENGTH];
|
||||
GetClientAuthId(client, AuthId_Steam2, sSIDClient, sizeof(sSIDClient));
|
||||
char sIP[MAX_NAME_LENGTH];
|
||||
results.FetchString(0, sSID, sizeof(sSID));
|
||||
results.FetchString(1, sIP, sizeof(sIP));
|
||||
char sql_statement[512];
|
||||
Format(sql_statement, sizeof(sql_statement), "UPDATE `ban_detector` SET detected_on_sourceban = '%s' where steamid = '%s'", sSID, sSIDClient);
|
||||
Call_StartForward(g_hOnReportBanPostForward);
|
||||
Call_PushCell(client);
|
||||
if (strlen(sSID) == 0)
|
||||
{
|
||||
Format(sql_statement, sizeof(sql_statement), "UPDATE `ban_detector` SET detected_on_sourceban = '%s' where steamid = '%s'", sIP, sSIDClient);
|
||||
// use IP instead if no steamID
|
||||
Call_PushString(sIP);
|
||||
}
|
||||
g_dDatabase.Query(SQL_UpdateLogged, sql_statement, _, DBPrio_High);
|
||||
}
|
||||
delete results;
|
||||
}
|
||||
|
||||
public void SQL_UpdateLogged(Database db, DBResultSet results, const char[] error, any data)
|
||||
{
|
||||
if (!db || strlen(error))
|
||||
{
|
||||
LogError("Database error: %s", error);
|
||||
return;
|
||||
else
|
||||
{
|
||||
//found steamID
|
||||
Call_PushString(sSID);
|
||||
}
|
||||
Call_Finish();
|
||||
}
|
||||
delete results;
|
||||
}
|
||||
@ -209,7 +210,6 @@ public Action start_checks(Handle hTimer)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
validate_state[client] = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user