Change net event and const prefix
This commit is contained in:
@@ -8,18 +8,18 @@
|
||||
// ===========================================================================
|
||||
|
||||
// Ban Types
|
||||
const VRR_BANTYPE_NONE = 0;
|
||||
const VRR_BANTYPE_ACCOUNT = 1;
|
||||
const VRR_BANTYPE_SUBACCOUNT = 2;
|
||||
const VRR_BANTYPE_IPADDRESS = 3;
|
||||
const VRR_BANTYPE_SUBNET = 4;
|
||||
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;
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
class BanData {
|
||||
constructor(dbAssoc = false) {
|
||||
this.databaseId = 0;
|
||||
this.type = VRR_BANTYPE_NONE;
|
||||
this.type = AGRP_BANTYPE_NONE;
|
||||
this.detail = "";
|
||||
this.ipAddress = "";
|
||||
this.name = "";
|
||||
@@ -174,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 (${VRR_BANTYPE_ACCOUNT}, ${accountId}, ${adminAccountId}, '${safeReason}');`);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_ACCOUNT}, ${accountId}, ${adminAccountId}, '${safeReason}');`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -189,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 (${VRR_BANTYPE_SUBACCOUNT}, ${subAccountId}, ${adminAccountId}, '${safeReason}');`);
|
||||
let dbQuery = queryDatabase(dbConnection, `INSERT INTO ban_main (ban_type, ban_detail, ban_who_banned, ban_reason) VALUES (${AGRP_BANTYPE_SUBACCOUNT}, ${subAccountId}, ${adminAccountId}, '${safeReason}');`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -204,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 (${VRR_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 (${AGRP_BANTYPE_IPADDRESS}, INET_ATON(${ipAddress}), ${adminAccountId}, '${safeReason}');`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -219,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 (${VRR_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 (${AGRP_BANTYPE_SUBNET}, INET_ATON(${ipAddressStart}), INET_ATON(${ipAddressEnd}), ${adminAccountId}, '${safeReason}');`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -233,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=${VRR_BANTYPE_ACCOUNT} AND ban_detail=${accountId}`);
|
||||
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}`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -247,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=${VRR_BANTYPE_SUBACCOUNT} AND ban_detail=${subAccountId}`);
|
||||
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}`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -261,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=${VRR_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=${AGRP_BANTYPE_IPADDRESS} AND ban_detail=INET_ATON(${ipAddress})`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -275,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=${VRR_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=${AGRP_BANTYPE_SUBNET} AND ban_ip_start=INET_ATON(${ipAddressStart}) AND ban_ip_end=INET_ATON(${ipAddressEnd})`);
|
||||
freeDatabaseQuery(dbQuery);
|
||||
dbConnection.close();
|
||||
return true;
|
||||
@@ -287,7 +287,7 @@ function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) {
|
||||
// ===========================================================================
|
||||
|
||||
function isAccountBanned(accountId) {
|
||||
let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_ACCOUNT && ban.detail === accountId);
|
||||
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_ACCOUNT && ban.detail === accountId);
|
||||
if (bans.length > 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -298,7 +298,7 @@ function isAccountBanned(accountId) {
|
||||
// ===========================================================================
|
||||
|
||||
function isSubAccountBanned(subAccountId) {
|
||||
let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_SUBACCOUNT && ban.detail === subAccountId);
|
||||
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_SUBACCOUNT && ban.detail === subAccountId);
|
||||
if (bans.length > 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -309,7 +309,7 @@ function isSubAccountBanned(subAccountId) {
|
||||
// ===========================================================================
|
||||
|
||||
function isIpAddressBanned(ipAddress) {
|
||||
let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_IPADDRESS && ban.detail === ipAddress);
|
||||
let bans = getServerData().bans.filter(ban => ban.type === AGRP_BANTYPE_IPADDRESS && ban.detail === ipAddress);
|
||||
if (bans.length > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user