<commit_before>#include <YSI\y_hooks>


#define MAX_BAN_REASON (128)
#define ACCOUNTS_TABLE_BANS			"Bans"
#define FIELD_BANS_NAME				"name"		// 00
#define FIELD_BANS_IPV4				"ipv4"		// 01
#define FIELD_BANS_DATE				"date"		// 02
#define FIELD_BANS_REASON			"reason"	// 03
#define FIELD_BANS_BY				"by"		// 04
#define FIELD_BANS_DURATION			"duration"	// 05
#define FIELD_BANS_ACTIVE			"active"	// 06

enum
{
	FIELD_ID_BANS_NAME,
	FIELD_ID_BANS_IPV4,
	FIELD_ID_BANS_DATE,
	FIELD_ID_BANS_REASON,
	FIELD_ID_BANS_BY,
	FIELD_ID_BANS_DURATION,
	FIELD_ID_BANS_ACTIVE
}


static
DBStatement:	stmt_BanInsert,
DBStatement:	stmt_BanUnban,
DBStatement:	stmt_BanGetFromNameIp,
DBStatement:	stmt_BanNameCheck,
DBStatement:	stmt_BanGetList,
DBStatement:	stmt_BanGetTotal,
DBStatement:	stmt_BanGetInfo,
DBStatement:	stmt_BanUpdateInfo,
DBStatement:	stmt_BanSetIpv4,
DBStatement:	stmt_BanSetReason,
DBStatement:	stmt_BanSetDuration;


hook OnGameModeInit()
{
	db_free_result(db_query(gAccounts, "CREATE TABLE IF NOT EXISTS "ACCOUNTS_TABLE_BANS" (\
		"FIELD_BANS_NAME" TEXT,\
		"FIELD_BANS_IPV4" INTEGER,\
		"FIELD_BANS_DATE" INTEGER,\
		"FIELD_BANS_REASON" TEXT,\
		"FIELD_BANS_BY" TEXT,\
		"FIELD_BANS_DURATION" INTEGER,\
		"FIELD_BANS_ACTIVE" INTEGER)"));

	DatabaseTableCheck(gAccounts, ACCOUNTS_TABLE_BANS, 7);

	stmt_BanInsert				= db_prepare(gAccounts, "INSERT INTO "ACCOUNTS_TABLE_BANS" VALUES(?, ?, ?, ?, ?, ?, 1)");
	stmt_BanUnban				= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_BANS" SET "FIELD_BANS_ACTIVE"=0 WHERE "FIELD_BANS_NAME" = ? COLLATE NOCASE");
	stmt_BanGetFromNameIp		= db_prepare(gAccounts, "SELECT COUNT(*), "FIELD_BANS_DATE", "FIELD_BANS_REASON", "FIELD_BANS_DURATION" FROM "ACCOUNTS_TABLE_BANS" WHERE "FIELD_BANS_NAME" = ? COLLATE NOCASE AND "FIELD_BANS_ACTIVE"=1 OR "FIELD_BANS_IPV4" = ? ORDER BY "FIELD_BANS_DATE" DESC");
	stmt_BanNameCheck			= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_BANS" WHERE "FIELD_BANS_ACTIVE"=1 AND "FIELD_BANS_NAME" = ? COLLATE NOCASE ORDER BY "FIELD_BANS_DATE" DESC");
	stmt_BanGetList				= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_BANS" WHERE "FIELD_BANS_ACTIVE"=1 ORDER BY "FIELD_BANS_DATE" DESC LIMIT ?, ? COLLATE NOCASE");<commit_msg>Fixed unban query (again) this time it works<commit_after>#include <YSI\y_hooks>


#define MAX_BAN_REASON (128)
#define ACCOUNTS_TABLE_BANS			"Bans"
#define FIELD_BANS_NAME				"name"		// 00
#define FIELD_BANS_IPV4				"ipv4"		// 01
#define FIELD_BANS_DATE				"date"		// 02
#define FIELD_BANS_REASON			"reason"	// 03
#define FIELD_BANS_BY				"by"		// 04
#define FIELD_BANS_DURATION			"duration"	// 05
#define FIELD_BANS_ACTIVE			"active"	// 06

enum
{
	FIELD_ID_BANS_NAME,
	FIELD_ID_BANS_IPV4,
	FIELD_ID_BANS_DATE,
	FIELD_ID_BANS_REASON,
	FIELD_ID_BANS_BY,
	FIELD_ID_BANS_DURATION,
	FIELD_ID_BANS_ACTIVE
}


static
DBStatement:	stmt_BanInsert,
DBStatement:	stmt_BanUnban,
DBStatement:	stmt_BanGetFromNameIp,
DBStatement:	stmt_BanNameCheck,
DBStatement:	stmt_BanGetList,
DBStatement:	stmt_BanGetTotal,
DBStatement:	stmt_BanGetInfo,
DBStatement:	stmt_BanUpdateInfo,
DBStatement:	stmt_BanSetIpv4,
DBStatement:	stmt_BanSetReason,
DBStatement:	stmt_BanSetDuration;


hook OnGameModeInit()
{
	db_free_result(db_query(gAccounts, "CREATE TABLE IF NOT EXISTS "ACCOUNTS_TABLE_BANS" (\
		"FIELD_BANS_NAME" TEXT,\
		"FIELD_BANS_IPV4" INTEGER,\
		"FIELD_BANS_DATE" INTEGER,\
		"FIELD_BANS_REASON" TEXT,\
		"FIELD_BANS_BY" TEXT,\
		"FIELD_BANS_DURATION" INTEGER,\
		"FIELD_BANS_ACTIVE" INTEGER)"));

	DatabaseTableCheck(gAccounts, ACCOUNTS_TABLE_BANS, 7);

	stmt_BanInsert				= db_prepare(gAccounts, "INSERT INTO "ACCOUNTS_TABLE_BANS" VALUES(?, ?, ?, ?, ?, ?, 1)");
	stmt_BanUnban				= db_prepare(gAccounts, "UPDATE "ACCOUNTS_TABLE_BANS" SET "FIELD_BANS_ACTIVE"=0 WHERE "FIELD_BANS_NAME" = ? COLLATE NOCASE");
	stmt_BanGetFromNameIp		= db_prepare(gAccounts, "SELECT COUNT(*), "FIELD_BANS_DATE", "FIELD_BANS_REASON", "FIELD_BANS_DURATION" FROM "ACCOUNTS_TABLE_BANS" WHERE ("FIELD_BANS_NAME" = ? COLLATE NOCASE OR "FIELD_BANS_IPV4" = ?) AND "FIELD_BANS_ACTIVE"=1 ORDER BY "FIELD_BANS_DATE" DESC");
	stmt_BanNameCheck			= db_prepare(gAccounts, "SELECT COUNT(*) FROM "ACCOUNTS_TABLE_BANS" WHERE "FIELD_BANS_ACTIVE"=1 AND "FIELD_BANS_NAME" = ? COLLATE NOCASE ORDER BY "FIELD_BANS_DATE" DESC");
	stmt_BanGetList				= db_prepare(gAccounts, "SELECT * FROM "ACCOUNTS_TABLE_BANS" WHERE "FIELD_BANS_ACTIVE"=1 ORDER BY "FIELD_BANS_DATE" DESC LIMIT ?, ? COLLATE NOCASE");
{'fraction_non_alphanumeric': 0.10739159739384407, 'fraction_numerical': 0.013030779600089868, 'mean_word_length': 6.649484536082475, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2623244', 'n_tokens_mistral': 2112, 'n_tokens_neox': 1869, 'n_words': 328}