"
+
+ usr << browse(output,"window=lookupbans;size=900x500")
\ No newline at end of file
diff --git a/code/modules/admin/IsBanned.dm b/code/modules/admin/IsBanned.dm
index a65b5beb36..09df6dbe73 100644
--- a/code/modules/admin/IsBanned.dm
+++ b/code/modules/admin/IsBanned.dm
@@ -1,27 +1,63 @@
//Blocks an attempt to connect before even creating our client datum thing.
world/IsBanned(key,address,computer_id)
- if(ckey(key) in admin_datums)
- return ..()
+ //if(ckey(key) in admin_datums)
+ // return ..()
- //Guest Checking
- if( !guests_allowed && IsGuestKey(key) )
- log_access("Failed Login: [key] - Guests not allowed")
- message_admins("\blue Failed Login: [key] - Guests not allowed")
- return list("reason"="guest", "desc"="\nReason: Guests not allowed. Please sign in with a byond account.")
+ if(config.ban_legacy_system)
- //check if the IP address is a known TOR node
- if( config && config.ToRban && ToRban_isbanned(address) )
- log_access("Failed Login: [src] - Banned: ToR")
- message_admins("\blue Failed Login: [src] - Banned: ToR")
- //ban their computer_id and ckey for posterity
- AddBan(ckey(key), computer_id, "Use of ToR", "Automated Ban", 0, 0)
- return list("reason"="Using ToR", "desc"="\nReason: The network you are using to connect has been banned.\nIf you believe this is a mistake, please request help at [config.banappeals]")
+ //Guest Checking
+ if( !guests_allowed && IsGuestKey(key) )
+ log_access("Failed Login: [key] - Guests not allowed")
+ message_admins("\blue Failed Login: [key] - Guests not allowed")
+ return list("reason"="guest", "desc"="\nReason: Guests not allowed. Please sign in with a byond account.")
- //Ban Checking
- . = CheckBan( ckey(key), computer_id, address )
- if(.)
- log_access("Failed Login: [key] [computer_id] [address] - Banned [.["reason"]]")
- message_admins("\blue Failed Login: [key] id:[computer_id] ip:[address] - Banned [.["reason"]]")
- return .
+ //check if the IP address is a known TOR node
+ if( config && config.ToRban && ToRban_isbanned(address) )
+ log_access("Failed Login: [src] - Banned: ToR")
+ message_admins("\blue Failed Login: [src] - Banned: ToR")
+ //ban their computer_id and ckey for posterity
+ AddBan(ckey(key), computer_id, "Use of ToR", "Automated Ban", 0, 0)
+ return list("reason"="Using ToR", "desc"="\nReason: The network you are using to connect has been banned.\nIf you believe this is a mistake, please request help at [config.banappeals]")
- return ..() //default pager ban stuff
+ //Ban Checking
+ . = CheckBan( ckey(key), computer_id, address )
+ if(.)
+ log_access("Failed Login: [key] [computer_id] [address] - Banned [.["reason"]]")
+ message_admins("\blue Failed Login: [key] id:[computer_id] ip:[address] - Banned [.["reason"]]")
+ return .
+
+ return ..() //default pager ban stuff
+
+ else
+
+ var/ckeytext = ckey(key)
+
+ if(!establish_db_connection())
+ world.log << "Ban database connection failure. Key [ckeytext] not checked"
+ diary << "Ban database connection failure. Key [ckeytext] not checked"
+ return
+
+ var/DBQuery/query = dbcon.NewQuery("SELECT ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype FROM erro_Ban WHERE (ckey = '[ckeytext]' OR ip = '[address]' OR computerid = '[computer_id]') AND (bantype = 'PERMABAN' OR (bantype = 'TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)")
+
+ query.Execute()
+
+ while(query.NextRow())
+ var/pckey = query.item[1]
+ //var/pip = query.item[2]
+ //var/pcid = query.item[3]
+ var/ackey = query.item[4]
+ var/reason = query.item[5]
+ var/expiration = query.item[6]
+ var/duration = query.item[7]
+ var/bantime = query.item[8]
+ var/bantype = query.item[9]
+
+ var/expires = ""
+ if(text2num(duration) > 0)
+ expires = " The ban is for [duration] minutes and expires on [expiration] (server time)."
+
+ var/desc = "\nReason: You, or another user of this computer or connection ([pckey]) is banned from playing here. The ban reason is:\n[reason]\nThis ban was applied by [ackey] on [bantime], [expires]"
+
+ return list("reason"="[bantype]", "desc"="[desc]")
+
+ return ..() //default pager ban stuff
\ No newline at end of file
diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm
index 7ad9a89c75..344bb02407 100644
--- a/code/modules/admin/admin_verbs.dm
+++ b/code/modules/admin/admin_verbs.dm
@@ -59,7 +59,8 @@ var/list/admin_verbs_admin = list(
var/list/admin_verbs_ban = list(
/client/proc/unban_panel,
/client/proc/jobbans,
- /client/proc/unjobban_panel
+ /client/proc/unjobban_panel,
+ /client/proc/DB_ban_panel
)
var/list/admin_verbs_sounds = list(
/client/proc/play_local_sound,
@@ -368,7 +369,10 @@ var/list/admin_verbs_hideable = list(
set name = "Display Job bans"
set category = "Admin"
if(holder)
- holder.Jobbans()
+ if(config.ban_legacy_system)
+ holder.Jobbans()
+ else
+ holder.DB_ban_panel()
feedback_add_details("admin_verb","VJB") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
return
@@ -376,7 +380,10 @@ var/list/admin_verbs_hideable = list(
set name = "Unban Panel"
set category = "Admin"
if(holder)
- holder.unbanpanel()
+ if(config.ban_legacy_system)
+ holder.unbanpanel()
+ else
+ holder.DB_ban_panel()
feedback_add_details("admin_verb","UBP") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
return
diff --git a/code/modules/admin/banjob.dm b/code/modules/admin/banjob.dm
index dd10d33f99..94c09c54ee 100644
--- a/code/modules/admin/banjob.dm
+++ b/code/modules/admin/banjob.dm
@@ -48,24 +48,31 @@ DEBUG
*/
/proc/jobban_loadbanfile()
- var/savefile/S=new("data/job_full.ban")
- S["keys[0]"] >> jobban_keylist
- log_admin("Loading jobban_rank")
- S["runonce"] >> jobban_runonce
+ if(config.ban_legacy_system)
+ var/savefile/S=new("data/job_full.ban")
+ S["keys[0]"] >> jobban_keylist
+ log_admin("Loading jobban_rank")
+ S["runonce"] >> jobban_runonce
- /*
- for(var/i = 1; i <= length(jobban_keylist); i++)
- if( findtext(jobban_keylist[i],"##") )
- var/index = findtext(jobban_keylist[i],"##")
- var/s = jobban_keylist[i]
- s = copytext( s , 1 , index ) //Removes the reason for the ban from this list
- jobban_keylist[i] = s
- world << "DEBUG: index: [index] - s: [s] - jobban_keylist\[[i]\] = [jobban_keylist[i]]"*/
+ if (!length(jobban_keylist))
+ jobban_keylist=list()
+ log_admin("jobban_keylist was empty")
+ else
+ if(!establish_db_connection())
+ world.log << "Database connection failed. Reverting to the legacy ban system."
+ diary << "Database connection failed. Reverting to the legacy ban system."
+ config.ban_legacy_system = 1
+ jobban_loadbanfile()
+ return
- if (!length(jobban_keylist))
- jobban_keylist=list()
- log_admin("jobban_keylist was empty")
+ var/DBQuery/query = dbcon.NewQuery("SELECT ckey, job FROM erro_ban WHERE bantype = 'JOB_PERMABAN' AND isnull(unbanned)")
+ query.Execute()
+ while(query.NextRow())
+ var/ckey = query.item[1]
+ var/job = query.item[2]
+
+ jobban_keylist.Add("[ckey] - [job]")
/proc/jobban_savebanfile()
var/savefile/S=new("data/job_full.ban")
diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm
index 17780619fb..e68aaf6d6d 100644
--- a/code/modules/admin/topic.dm
+++ b/code/modules/admin/topic.dm
@@ -45,6 +45,60 @@
log_admin("[key_name(usr)] has spawned a death squad.")
if(!src.makeDeathsquad())
usr << "\red Unfortunatly there were no candidates available"
+ else if(href_list["dbsearchckey"] || href_list["dbsearchadmin"])
+ var/adminckey = href_list["dbsearchadmin"]
+ var/playerckey = href_list["dbsearchckey"]
+
+ DB_ban_panel(playerckey, adminckey)
+ return
+
+ else if(href_list["dbbanedit"])
+ var/banedit = href_list["dbbanedit"]
+ var/banid = text2num(href_list["dbbanid"])
+ if(!banedit || !banid)
+ return
+
+ DB_ban_edit(banid, banedit)
+ return
+
+ else if(href_list["dbbanaddtype"])
+
+ var/bantype = text2num(href_list["dbbanaddtype"])
+ var/banckey = href_list["dbbanaddckey"]
+ var/banduration = text2num(href_list["dbbaddduration"])
+ var/banjob = href_list["dbbanaddjob"]
+ var/banreason = href_list["dbbanreason"]
+
+ banckey = ckey(banckey)
+
+ switch(bantype)
+ if(BANTYPE_PERMA)
+ if(!banckey || !banreason)
+ usr << "Not enough parameters (Requires ckey and reason)"
+ return
+ banduration = null
+ banjob = null
+ if(BANTYPE_TEMP)
+ if(!banckey || !banreason || !banduration)
+ usr << "Not enough parameters (Requires ckey, reason and duration)"
+ return
+ banjob = null
+ if(BANTYPE_JOB_PERMA)
+ if(!banckey || !banreason || !banjob)
+ usr << "Not enough parameters (Requires ckey, reason and job)"
+ return
+ banduration = null
+
+ var/mob/playermob
+
+ for(var/mob/M in player_list)
+ if(M.ckey == banckey)
+ playermob = M
+ break
+
+ banreason = "(MANUAL BAN) "+banreason
+
+ DB_ban_record(bantype, playermob, banduration, banreason, banjob, null, banckey)
else if(href_list["editadminpermissions"])
var/adm_ckey = href_list["editadminckey"]
@@ -595,6 +649,10 @@
//Unbanning joblist
//all jobs in joblist are banned already OR we didn't give a reason (implying they shouldn't be banned)
if(joblist.len) //at least 1 banned job exists in joblist so we have stuff to unban.
+ if(!config.ban_legacy_system)
+ usr << "Unfortunately, database based unbanning cannot be done through this panel"
+ DB_ban_panel(usr.client.ckey)
+ return
var/msg
for(var/job in joblist)
var/reason = jobban_isbanned(M, job)
diff --git a/config/config.txt b/config/config.txt
index 8280fec0b7..20cdea4fea 100644
--- a/config/config.txt
+++ b/config/config.txt
@@ -9,9 +9,12 @@ ALERT_RED_UPTO There is an immediate serious threat to the station. Security may
ALERT_RED_DOWNTO The self-destruct mechanism has been deactivated, there is still however an immediate serious threat to the station. Security may have weapons unholstered at all times, random searches are allowed and advised.
ALERT_DELTA The station's self-destruct mechanism has been engaged. All crew are instructed to obey all instructions given by heads of staff. Any violations of these orders can be punished by death. This is not a drill.
-## Add a # infront of this if you want to use the SQL based admin system, the legacy system uses admins.txt
+## Add a # infront of this if you want to use the SQL based admin system, the legacy system uses admins.txt. You need to set up your database to use the SQL based system.
ADMIN_LEGACY_SYSTEM
+## Add a # infront of this if you want to use the SQL based banning system. The legacy systems use the files in the data folder. You need to set up your database to use the SQL based system.
+BAN_LEGACY_SYSTEM
+
## log OOC channel
LOG_OOC