From c8169d289f34ebcf9dab9b302314500e2d30177a Mon Sep 17 00:00:00 2001
From: quotefox <49098813+quotefox@users.noreply.github.com>
Date: Fri, 22 Nov 2019 14:00:04 +0000
Subject: [PATCH] perminant solution to the whitelist, whitelist/panic is now
handled on the database.
---
code/game/world.dm | 6 ++--
code/modules/admin/verbs/panicbunker.dm | 48 +++++++++++--------------
code/modules/client/client_procs.dm | 32 ++++++++++-------
3 files changed, 41 insertions(+), 45 deletions(-)
diff --git a/code/game/world.dm b/code/game/world.dm
index 09697a52..d3491903 100644
--- a/code/game/world.dm
+++ b/code/game/world.dm
@@ -32,10 +32,8 @@ GLOBAL_VAR(restart_counter)
load_admins()
LoadVerbs(/datum/verbs/menu)
- load_paniclist()
-// Hyperstation: Whitelists do not work.
-// if(CONFIG_GET(flag/usewhitelist))
-// load_whitelist()
+ if(CONFIG_GET(flag/usewhitelist))
+ load_whitelist()
LoadBans()
reload_custom_roundstart_items_list()//Cit change - loads donator items. Remind me to remove when I port over bay's loadout system
diff --git a/code/modules/admin/verbs/panicbunker.dm b/code/modules/admin/verbs/panicbunker.dm
index 262d35c9..f1084310 100644
--- a/code/modules/admin/verbs/panicbunker.dm
+++ b/code/modules/admin/verbs/panicbunker.dm
@@ -1,6 +1,3 @@
-#define PANICFILE "[global.config.directory]/whitelist.txt"
-
-
/client/proc/panicbunker()
set category = "Server"
set name = "Toggle Panic Bunker"
@@ -22,16 +19,31 @@
/client/proc/addbunkerbypass(ckeytobypass as text)
set category = "Special Verbs"
set name = "Whitelist"
- set desc = "Allows a given ckey to connect despite the panic bunker for a given round."
+ set desc = "Adds a given ckey onto the whitelist to bypass the panic bunker."
if(!CONFIG_GET(flag/sql_enabled))
to_chat(usr, "The Database is not enabled!")
return
GLOB.bunker_passthrough |= ckey(ckeytobypass)
- log_admin("[key_name(usr)] has added [ckeytobypass] to the bunker bypass list.")
- message_admins("[key_name_admin(usr)] has added [ckeytobypass] to the bunker bypass list.")
- send2irc("Panic Bunker", "[key_name(usr)] has added [ckeytobypass] to the bunker bypass list.")
- save_paniclist()
+ log_admin("[key_name(usr)] has added [ckeytobypass] to the whitelist.")
+ message_admins("[key_name_admin(usr)] has added [ckeytobypass] to the whitelist.")
+ send2irc("Panic Bunker", "[key_name(usr)] has added [ckeytobypass] to the whitelist.")
+
+
+ //Hyperstation13 change Adds to a whitelist on the database table "whitelist", so players can join at a later date!
+ var/sql_ckey = sanitizeSQL(ckeytobypass)
+ var/datum/DBQuery/query_client_in_db = SSdbcore.NewQuery("SELECT 1 FROM [format_table_name("whitelist")] WHERE ckey = '[sql_ckey]'")
+ if(!query_client_in_db.Execute())
+ qdel(query_client_in_db)
+ return
+ if(!query_client_in_db.NextRow())
+ //add to database!
+ var/datum/DBQuery/query_add_player_whitelist = SSdbcore.NewQuery("INSERT INTO [format_table_name("whitelist")] (`ckey`) VALUES ('[sql_ckey]')")
+ if(!query_add_player_whitelist.Execute())
+ qdel(query_client_in_db)
+ qdel(query_add_player_whitelist)
+ return
+
/client/proc/revokebunkerbypass(ckeytobypass as text)
set category = "Special Verbs"
@@ -45,23 +57,3 @@
log_admin("[key_name(usr)] has removed [ckeytobypass] from the current round's bunker bypass list.")
message_admins("[key_name_admin(usr)] has removed [ckeytobypass] from the current round's bunker bypass list.")
send2irc("Panic Bunker", "[key_name(usr)] has removed [ckeytobypass] from the current round's bunker bypass list.")
- save_paniclist()
-
-//Hyperchange, we altered the panic bunker into a whitelist. So it will load whitelist.txt and treat it as a bypass to the panic bunker.
-
-/proc/load_paniclist()
- GLOB.bunker_passthrough = list()
- for(var/line in world.file2list(PANICFILE))
- if(!line)
- continue
- if(findtextEx(line,"#",1,2))
- continue
- GLOB.bunker_passthrough += ckey(line)
-
- if(!GLOB.bunker_passthrough.len)
- GLOB.bunker_passthrough = null
-
-/proc/save_paniclist()
- var/namelist = list2text(GLOB.bunker_passthrough, ",")
- var/paniclist = PANICFILE
- paniclist << namelist
\ No newline at end of file
diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm
index b29fa56f..1713df90 100644
--- a/code/modules/client/client_procs.dm
+++ b/code/modules/client/client_procs.dm
@@ -500,19 +500,25 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
return
if(!query_client_in_db.NextRow())
if (CONFIG_GET(flag/panic_bunker) && !holder && !GLOB.deadmins[ckey] && !(ckey in GLOB.bunker_passthrough))
- log_access("Failed Login: [key] - New account attempting to connect during panic bunker")
- message_admins("Failed Login: [key] - New account attempting to connect without being whitelisted!")
- to_chat(src, "You must first join the Discord to verify your account before joining this server.
To do so, read the rules here http://hyperstation13.com/rules and post a request in the #whitelist-application under the \"Main server\" category in the Discord server linked here: https://discordapp.com/invite/PCtX2fH") //CIT CHANGE - makes the panic bunker disconnect message point to the discord
- var/list/connectiontopic_a = params2list(connectiontopic)
- var/list/panic_addr = CONFIG_GET(string/panic_server_address)
- if(panic_addr && !connectiontopic_a["redirect"])
- var/panic_name = CONFIG_GET(string/panic_server_name)
- to_chat(src, "Sending you to [panic_name ? panic_name : panic_addr].")
- winset(src, null, "command=.options")
- src << link("[panic_addr]?redirect=1")
- qdel(query_client_in_db)
- qdel(src)
- return
+ var/datum/DBQuery/query_client_in_db_whitelist = SSdbcore.NewQuery("SELECT 1 FROM [format_table_name("whitelist")] WHERE ckey = '[sql_ckey]'")
+ if(!query_client_in_db_whitelist.Execute())
+ qdel(query_client_in_db_whitelist)
+ return
+ if(!query_client_in_db_whitelist.NextRow()) //they are not on the whitelist OR have played before! on the database!
+
+ log_access("Failed Login: [key] - New account attempting to connect during panic bunker")
+ message_admins("Failed Login: [key] - New account attempting to connect without being whitelisted!")
+ to_chat(src, "You must first join the Discord to verify your account before joining this server.
To do so, read the rules here http://hyperstation13.com/rules and post a request in the #whitelist-application under the \"Main server\" category in the Discord server linked here: https://discordapp.com/invite/PCtX2fH") //CIT CHANGE - makes the panic bunker disconnect message point to the discord
+ var/list/connectiontopic_a = params2list(connectiontopic)
+ var/list/panic_addr = CONFIG_GET(string/panic_server_address)
+ if(panic_addr && !connectiontopic_a["redirect"])
+ var/panic_name = CONFIG_GET(string/panic_server_name)
+ to_chat(src, "Sending you to [panic_name ? panic_name : panic_addr].")
+ winset(src, null, "command=.options")
+ src << link("[panic_addr]?redirect=1")
+ qdel(query_client_in_db)
+ qdel(src)
+ return
new_player = 1
account_join_date = sanitizeSQL(findJoinDate())