Change copyright, consts, and net events prefix
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
// ===========================================================================
|
||||
// Asshat Gaming Roleplay
|
||||
// https://github.com/VortrexFTW/agrp_main
|
||||
// (c) 2022 Asshat Gaming
|
||||
// Vortrex's Roleplay Resource
|
||||
// https://github.com/VortrexFTW/v-roleplay
|
||||
// ===========================================================================
|
||||
// FILE: bans.js
|
||||
// DESC: Provides ban functions and usage
|
||||
@@ -9,18 +8,18 @@
|
||||
// ===========================================================================
|
||||
|
||||
// Ban Types
|
||||
const AGRP_BANTYPE_NONE = 0;
|
||||
const AGRP_BANTYPE_ACCOUNT = 1;
|
||||
const AGRP_BANTYPE_SUBACCOUNT = 2;
|
||||
const AGRP_BANTYPE_IPADDRESS = 3;
|
||||
const AGRP_BANTYPE_SUBNET = 4;
|
||||
const V_BANTYPE_NONE = 0;
|
||||
const V_BANTYPE_ACCOUNT = 1;
|
||||
const V_BANTYPE_SUBACCOUNT = 2;
|
||||
const V_BANTYPE_IPADDRESS = 3;
|
||||
const V_BANTYPE_SUBNET = 4;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
class BanData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.type = AGRP_BANTYPE_NONE;
|
||||
this.type = V_BANTYPE_NONE;
|
||||
this.detail = "";
|
||||
this.ipAddress = "";
|
||||
this.name = "";
|
||||
@@ -175,7 +174,7 @@ function banAccount(accountId, adminAccountId, reason) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let safeReason = dbConnection.escapetoString(reason);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_ACCOUNT}, ${accountId}, ${adminAccountId}, '${safeReason}');`);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${V_BANTYPE_ACCOUNT}, ${accountId}, ${adminAccountId}, '${safeReason}');`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -190,7 +189,7 @@ function banSubAccount(subAccountId, adminAccountId, reason) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let safeReason = dbConnection.escapetoString(reason);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_SUBACCOUNT}, ${subAccountId}, ${adminAccountId}, '${safeReason}');`);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${V_BANTYPE_SUBACCOUNT}, ${subAccountId}, ${adminAccountId}, '${safeReason}');`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -205,7 +204,7 @@ function banIPAddress(ipAddress, adminAccountId, reason) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let safeReason = dbConnection.escapetoString(reason);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_IPADDRESS}, INET_ATON(${ipAddress}), ${adminAccountId}, '${safeReason}');`);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${V_BANTYPE_IPADDRESS}, INET_ATON(${ipAddress}), ${adminAccountId}, '${safeReason}');`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -220,7 +219,7 @@ function banSubNet(ipAddressStart, ipAddressEnd, adminAccountId, reason) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let safeReason = dbConnection.escapetoString(reason);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_ip_start, ban_ip_end, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_SUBNET}, INET_ATON(${ipAddressStart}), INET_ATON(${ipAddressEnd}), ${adminAccountId}, '${safeReason}');`);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_ip_start, ban_ip_end, ban_who_banned, ban_reason) VALUES (${V_BANTYPE_SUBNET}, INET_ATON(${ipAddressStart}), INET_ATON(${ipAddressEnd}), ${adminAccountId}, '${safeReason}');`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -234,7 +233,7 @@ function banSubNet(ipAddressStart, ipAddressEnd, adminAccountId, reason) {
|
||||
function unbanAccount(accountId, adminAccountId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${AGRP_BANTYPE_ACCOUNT} AND ban_detail=${accountId}`);
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${V_BANTYPE_ACCOUNT} AND ban_detail=${accountId}`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -248,7 +247,7 @@ function unbanAccount(accountId, adminAccountId) {
|
||||
function unbanSubAccount(subAccountId, adminAccountId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${AGRP_BANTYPE_SUBACCOUNT} AND ban_detail=${subAccountId}`);
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${V_BANTYPE_SUBACCOUNT} AND ban_detail=${subAccountId}`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -262,7 +261,7 @@ function unbanSubAccount(subAccountId, adminAccountId) {
|
||||
function unbanIPAddress(ipAddress, adminAccountId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${AGRP_BANTYPE_IPADDRESS} AND ban_detail=INET_ATON(${ipAddress})`);
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${V_BANTYPE_IPADDRESS} AND ban_detail=INET_ATON(${ipAddress})`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -276,7 +275,7 @@ function unbanIPAddress(ipAddress, adminAccountId) {
|
||||
function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if (dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${AGRP_BANTYPE_SUBNET} AND ban_ip_start=INET_ATON(${ipAddressStart}) AND ban_ip_end=INET_ATON(${ipAddressEnd})`);
|
||||
let dbQuery = queryDatabase(dbConnection, `UPDATE ban_main SET ban_who_removed=${adminAccountId}, ban_removed=1 WHERE ban_type=${V_BANTYPE_SUBNET} AND ban_ip_start=INET_ATON(${ipAddressStart}) AND ban_ip_end=INET_ATON(${ipAddressEnd})`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -288,7 +287,7 @@ function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) {
|
||||
// ===========================================================================
|
||||
|
||||
function isAccountBanned(accountId) {
|
||||
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_ACCOUNT && ban.detail === accountId);
|
||||
let bans = getServerData().bans.filter(ban => ban.type === V_BANTYPE_ACCOUNT && ban.detail === accountId);
|
||||
if (bans.length > 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -299,7 +298,7 @@ function isAccountBanned(accountId) {
|
||||
// ===========================================================================
|
||||
|
||||
function isSubAccountBanned(subAccountId) {
|
||||
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_SUBACCOUNT && ban.detail === subAccountId);
|
||||
let bans = getServerData().bans.filter(ban => ban.type === V_BANTYPE_SUBACCOUNT && ban.detail === subAccountId);
|
||||
if (bans.length > 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -310,7 +309,7 @@ function isSubAccountBanned(subAccountId) {
|
||||
// ===========================================================================
|
||||
|
||||
function isIpAddressBanned(ipAddress) {
|
||||
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_IPADDRESS && ban.detail === ipAddress);
|
||||
let bans = getServerData().bans.filter(ban => ban.type === V_BANTYPE_IPADDRESS && ban.detail === ipAddress);
|
||||
if (bans.length > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user