From 4356dc746f3075eb5c28c1501aa030b519862a42 Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Sat, 27 Nov 2021 18:58:10 +0000 Subject: [PATCH] Ban refactor part 2/3 - Kills off savefile bans (#17135) --- .../sections/general_configuration.dm | 3 - code/game/world.dm | 3 +- code/modules/admin/IsBanned.dm | 144 +++++------ code/modules/admin/NewBan.dm | 228 ------------------ code/modules/admin/admin.dm | 13 - code/modules/admin/admin_verbs.dm | 5 +- code/modules/admin/banjob.dm | 147 +++++------ code/modules/admin/db_ban/functions.dm | 11 - code/modules/admin/topic.dm | 114 ++------- config/example/config.toml | 2 - paradise.dme | 1 - 11 files changed, 141 insertions(+), 530 deletions(-) delete mode 100644 code/modules/admin/NewBan.dm diff --git a/code/controllers/configuration/sections/general_configuration.dm b/code/controllers/configuration/sections/general_configuration.dm index 816775fa6d9..0dc1680da5a 100644 --- a/code/controllers/configuration/sections/general_configuration.dm +++ b/code/controllers/configuration/sections/general_configuration.dm @@ -6,8 +6,6 @@ var/server_tag_line = "The perfect mix of RP & action" /// Server features in a newline var/server_features = "Medium RP, varied species/jobs" - /// Should bans be stored in the DB - var/use_database_bans = FALSE /// Allow character OOC notes var/allow_character_metadata = TRUE /// Time in seconds for the pregame lobby @@ -87,7 +85,6 @@ // Use the load wrappers here. That way the default isnt made 'null' if you comment out the config line // A lot of bools - CONFIG_LOAD_BOOL(use_database_bans, data["use_database_bans"]) CONFIG_LOAD_BOOL(allow_character_metadata, data["allow_character_metadata"]) CONFIG_LOAD_BOOL(guest_ban, data["guest_ban"]) CONFIG_LOAD_BOOL(allow_antag_hud, data["allow_antag_hud"]) diff --git a/code/game/world.dm b/code/game/world.dm index f90c59a8657..b3729428119 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -77,8 +77,7 @@ GLOBAL_LIST_INIT(map_transition_config, list(CC_TRANSITION_CONFIG)) // This is basically a replacement for hook/startup. Please dont shove random bullshit here // If it doesnt need to happen IMMEDIATELY on world load, make a subsystem for it /world/proc/startup_procs() - LoadBans() // Load up who is banned and who isnt. DONT PUT THIS IN A SUBSYSTEM IT WILL TAKE TOO LONG TO BE CALLED - jobban_loadbanfile() // Load up jobbans. Again, DO NOT PUT THIS IN A SUBSYSTEM IT WILL TAKE TOO LONG TO BE CALLED + jobban_loadbans() // Load up jobbans. Again, DO NOT PUT THIS IN A SUBSYSTEM IT WILL TAKE TOO LONG TO BE CALLED investigate_reset() // This is part of the admin investigate system. PLEASE DONT SS THIS EITHER /// List of all world topic spam prevention handlers. See code/modules/world_topic/_spam_prevention_handler.dm diff --git a/code/modules/admin/IsBanned.dm b/code/modules/admin/IsBanned.dm index c4d6d4ae9c6..60f870d9e8d 100644 --- a/code/modules/admin/IsBanned.dm +++ b/code/modules/admin/IsBanned.dm @@ -109,91 +109,79 @@ qdel(exist_query) - if(!GLOB.configuration.general.use_database_bans) - //Ban Checking - . = CheckBan(ckey(key), computer_id, address) - if(.) - if(admin) - log_admin("The admin [key] has been allowed to bypass a matching ban on [.["key"]]") - message_admins("The admin [key] has been allowed to bypass a matching ban on [.["key"]]") - addclientmessage(ckey,"You have been allowed to bypass a matching ban on [.["key"]].") - else - log_adminwarn("Failed Login: [key] [computer_id] [address] - Banned [.["reason"]]") - return . - else - var/ckeytext = ckey(key) + var/ckeytext = ckey(key) - if(!SSdbcore.IsConnected()) - log_world("Ban database connection failure. Key [ckeytext] not checked") - return + if(!SSdbcore.IsConnected()) + log_world("Ban database connection failure. Key [ckeytext] not checked") + return - var/list/sql_query_params = list( - "ckeytext" = ckeytext - ) + var/list/sql_query_params = list( + "ckeytext" = ckeytext + ) - var/ipquery = "" - var/cidquery = "" - if(address) - ipquery = " OR ip=:ip " - sql_query_params["ip"] = address + var/ipquery = "" + var/cidquery = "" + if(address) + ipquery = " OR ip=:ip " + sql_query_params["ip"] = address - if(computer_id) - cidquery = " OR computerid=:cid " - sql_query_params["cid"] = computer_id + if(computer_id) + cidquery = " OR computerid=:cid " + sql_query_params["cid"] = computer_id - var/datum/db_query/query = SSdbcore.NewQuery({" - SELECT ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype, ban_round_id FROM ban - WHERE (ckey=:ckeytext [ipquery] [cidquery]) AND (bantype = 'PERMABAN' OR bantype = 'ADMIN_PERMABAN' - OR ((bantype = 'TEMPBAN' OR bantype = 'ADMIN_TEMPBAN') AND expiration_time > Now())) AND isnull(unbanned)"}, sql_query_params) + var/datum/db_query/query = SSdbcore.NewQuery({" + SELECT ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype, ban_round_id FROM ban + WHERE (ckey=:ckeytext [ipquery] [cidquery]) AND (bantype = 'PERMABAN' OR bantype = 'ADMIN_PERMABAN' + OR ((bantype = 'TEMPBAN' OR bantype = 'ADMIN_TEMPBAN') AND expiration_time > Now())) AND isnull(unbanned)"}, sql_query_params) - if(!query.warn_execute()) - message_admins("Failed to do a DB ban check for [ckeytext]. You have been warned.") - qdel(query) - return - - 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/ban_round_id = query.item[10] - if(bantype == "ADMIN_PERMABAN" || bantype == "ADMIN_TEMPBAN") - //admin bans MUST match on ckey to prevent cid-spoofing attacks - // as well as dynamic ip abuse - if(pckey != ckey) - continue - if(admin) - if(bantype == "ADMIN_PERMABAN" || bantype == "ADMIN_TEMPBAN") - log_admin("The admin [key] is admin banned, and has been disallowed access") - message_admins("The admin [key] is admin banned, and has been disallowed access") - else - log_admin("The admin [key] has been allowed to bypass a matching ban on [pckey]") - message_admins("The admin [key] has been allowed to bypass a matching ban on [pckey]") - addclientmessage(ckey,"You have been allowed to bypass a matching ban on [pckey].") - continue - var/expires = "" - if(text2num(duration) > 0) - expires = " The ban is for [duration] minutes and expires on [expiration] (server time)." - else - var/appealmessage = "" - if(GLOB.configuration.url.banappeals_url) - appealmessage = " You may appeal it at [GLOB.configuration.url.banappeals_url]." - expires = " This ban does not expire automatically and must be appealed.[appealmessage]" - - 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][ban_round_id ? " (Round [ban_round_id])" : ""].[expires]" - - . = list("reason"="[bantype]", "desc"="[desc]") - - log_adminwarn("Failed Login: [key] [computer_id] [address] - Banned [.["reason"]]") - INVOKE_ASYNC(GLOBAL_PROC, .proc/log_connection, ckey(key), address, computer_id, CONNECTION_TYPE_DROPPED_BANNED) - qdel(query) - return . + if(!query.warn_execute()) + message_admins("Failed to do a DB ban check for [ckeytext]. You have been warned.") qdel(query) + return + + 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/ban_round_id = query.item[10] + if(bantype == "ADMIN_PERMABAN" || bantype == "ADMIN_TEMPBAN") + //admin bans MUST match on ckey to prevent cid-spoofing attacks + // as well as dynamic ip abuse + if(pckey != ckey) + continue + if(admin) + if(bantype == "ADMIN_PERMABAN" || bantype == "ADMIN_TEMPBAN") + log_admin("The admin [key] is admin banned, and has been disallowed access") + message_admins("The admin [key] is admin banned, and has been disallowed access") + else + log_admin("The admin [key] has been allowed to bypass a matching ban on [pckey]") + message_admins("The admin [key] has been allowed to bypass a matching ban on [pckey]") + addclientmessage(ckey,"You have been allowed to bypass a matching ban on [pckey].") + continue + var/expires = "" + if(text2num(duration) > 0) + expires = " The ban is for [duration] minutes and expires on [expiration] (server time)." + else + var/appealmessage = "" + if(GLOB.configuration.url.banappeals_url) + appealmessage = " You may appeal it at [GLOB.configuration.url.banappeals_url]." + expires = " This ban does not expire automatically and must be appealed.[appealmessage]" + + 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][ban_round_id ? " (Round [ban_round_id])" : ""].[expires]" + + . = list("reason"="[bantype]", "desc"="[desc]") + + log_adminwarn("Failed Login: [key] [computer_id] [address] - Banned [.["reason"]]") + INVOKE_ASYNC(GLOBAL_PROC, .proc/log_connection, ckey(key), address, computer_id, CONNECTION_TYPE_DROPPED_BANNED) + qdel(query) + return . + qdel(query) . = ..() //default pager ban stuff if(.) diff --git a/code/modules/admin/NewBan.dm b/code/modules/admin/NewBan.dm deleted file mode 100644 index 65eff893de6..00000000000 --- a/code/modules/admin/NewBan.dm +++ /dev/null @@ -1,228 +0,0 @@ -GLOBAL_VAR(CMinutes) -GLOBAL_DATUM(banlist_savefile, /savefile) -GLOBAL_PROTECT(banlist_savefile) // Obvious reasons - -/proc/CheckBan(ckey, id, address) - if(!GLOB.banlist_savefile) // if banlist_savefile cannot be located for some reason - LoadBans() // try to load the bans - if(!GLOB.banlist_savefile) // uh oh, can't find bans! - return 0 // ABORT ABORT ABORT - - . = list() - var/appeal - if(GLOB.configuration.url.banappeals_url) - appeal = "\nFor more information on your ban, or to appeal, head to [GLOB.configuration.url.banappeals_url]" - GLOB.banlist_savefile.cd = "/base" - if( "[ckey][id]" in GLOB.banlist_savefile.dir ) - GLOB.banlist_savefile.cd = "[ckey][id]" - if(GLOB.banlist_savefile["temp"]) - if(!GetExp(GLOB.banlist_savefile["minutes"])) - ClearTempbans() - return 0 - else - .["desc"] = "\nReason: [GLOB.banlist_savefile["reason"]]\nExpires: [GetExp(GLOB.banlist_savefile["minutes"])]\nBy: [GLOB.banlist_savefile["bannedby"]][appeal]" - else - GLOB.banlist_savefile.cd = "/base/[ckey][id]" - .["desc"] = "\nReason: [GLOB.banlist_savefile["reason"]]\nExpires: PERMENANT\nBy: [GLOB.banlist_savefile["bannedby"]][appeal]" - .["reason"] = "ckey/id" - return . - else - for(var/A in GLOB.banlist_savefile.dir) - GLOB.banlist_savefile.cd = "/base/[A]" - var/matches - if( ckey == GLOB.banlist_savefile["key"] ) - matches += "ckey" - if( id == GLOB.banlist_savefile["id"] ) - if(matches) - matches += "/" - matches += "id" - if( address == GLOB.banlist_savefile["ip"] ) - if(matches) - matches += "/" - matches += "ip" - - if(matches) - if(GLOB.banlist_savefile["temp"]) - if(!GetExp(GLOB.banlist_savefile["minutes"])) - ClearTempbans() - return 0 - else - .["desc"] = "\nReason: [GLOB.banlist_savefile["reason"]]\nExpires: [GetExp(GLOB.banlist_savefile["minutes"])]\nBy: [GLOB.banlist_savefile["bannedby"]][appeal]" - else - .["desc"] = "\nReason: [GLOB.banlist_savefile["reason"]]\nExpires: PERMENANT\nBy: [GLOB.banlist_savefile["bannedby"]][appeal]" - .["reason"] = matches - return . - return 0 - -/proc/UpdateTime() //No idea why i made this a proc. - GLOB.CMinutes = (world.realtime / 10) / 60 - return 1 - -/proc/LoadBans() - - GLOB.banlist_savefile = new("data/banlist.bdb") - log_admin("Loading Banlist") - - if(!length(GLOB.banlist_savefile.dir)) log_admin("Banlist is empty.") - - if(!GLOB.banlist_savefile.dir.Find("base")) - log_admin("Banlist missing base dir.") - GLOB.banlist_savefile.dir.Add("base") - GLOB.banlist_savefile.cd = "/base" - else if(GLOB.banlist_savefile.dir.Find("base")) - GLOB.banlist_savefile.cd = "/base" - - ClearTempbans() - return 1 - -/proc/ClearTempbans() - UpdateTime() - - GLOB.banlist_savefile.cd = "/base" - for(var/A in GLOB.banlist_savefile.dir) - GLOB.banlist_savefile.cd = "/base/[A]" - if(!GLOB.banlist_savefile["key"] || !GLOB.banlist_savefile["id"]) - RemoveBan(A) - log_admin("Invalid Ban.") - message_admins("Invalid Ban.") - continue - - if(!GLOB.banlist_savefile["temp"]) continue - if(GLOB.CMinutes >= GLOB.banlist_savefile["minutes"]) RemoveBan(A) - - return 1 - - -/proc/AddBan(ckey, computerid, reason, bannedby, temp, minutes, address) - - var/bantimestamp - - if(temp) - UpdateTime() - bantimestamp = GLOB.CMinutes + minutes - - GLOB.banlist_savefile.cd = "/base" - if( GLOB.banlist_savefile.dir.Find("[ckey][computerid]") ) - if(usr) - to_chat(usr, "Ban already exists.") - return 0 - else - GLOB.banlist_savefile.dir.Add("[ckey][computerid]") - GLOB.banlist_savefile.cd = "/base/[ckey][computerid]" - GLOB.banlist_savefile["key"] << ckey - GLOB.banlist_savefile["id"] << computerid - GLOB.banlist_savefile["ip"] << address - GLOB.banlist_savefile["reason"] << reason - GLOB.banlist_savefile["bannedby"] << bannedby - GLOB.banlist_savefile["temp"] << temp - if(temp) - GLOB.banlist_savefile["minutes"] << bantimestamp - if(!temp) - add_note(ckey, "Permanently banned - [reason]", null, bannedby, 0) - else - add_note(ckey, "Banned for [minutes] minutes - [reason]", null, bannedby, 0) - return 1 - -/proc/RemoveBan(foldername) - var/key - var/id - - GLOB.banlist_savefile.cd = "/base/[foldername]" - GLOB.banlist_savefile["key"] >> key - GLOB.banlist_savefile["id"] >> id - GLOB.banlist_savefile.cd = "/base" - - if(!GLOB.banlist_savefile.dir.Remove(foldername)) return 0 - - if(!usr) - log_admin("Ban Expired: [key]") - message_admins("Ban Expired: [key]") - else - log_admin("[key_name_admin(usr)] unbanned [key]") - message_admins("[key_name_admin(usr)] unbanned: [key]") - usr.client.holder.DB_ban_unban( ckey(key), BANTYPE_ANY_FULLBAN) - for(var/A in GLOB.banlist_savefile.dir) - GLOB.banlist_savefile.cd = "/base/[A]" - if(key == GLOB.banlist_savefile["key"] /*|| id == GLOB.banlist_savefile["id"]*/) - GLOB.banlist_savefile.cd = "/base" - GLOB.banlist_savefile.dir.Remove(A) - continue - - return 1 - -/proc/GetExp(minutes as num) - UpdateTime() - var/exp = minutes - GLOB.CMinutes - if(exp <= 0) - return 0 - else - var/timeleftstring - if(exp >= 1440) //1440 = 1 day in minutes - timeleftstring = "[round(exp / 1440, 0.1)] Days" - else if(exp >= 60) //60 = 1 hour in minutes - timeleftstring = "[round(exp / 60, 0.1)] Hours" - else - timeleftstring = "[exp] Minutes" - return timeleftstring - -/datum/admins/proc/unbanpanel() - var/count = 0 - var/dat - GLOB.banlist_savefile.cd = "/base" - for(var/A in GLOB.banlist_savefile.dir) - count++ - GLOB.banlist_savefile.cd = "/base/[A]" - var/ref = UID() - var/key = GLOB.banlist_savefile["key"] - var/id = GLOB.banlist_savefile["id"] - var/ip = GLOB.banlist_savefile["ip"] - var/reason = GLOB.banlist_savefile["reason"] - var/by = GLOB.banlist_savefile["bannedby"] - var/expiry - if(GLOB.banlist_savefile["temp"]) - expiry = GetExp(GLOB.banlist_savefile["minutes"]) - if(!expiry) expiry = "Removal Pending" - else expiry = "Permaban" - - dat += text("(U)(E) Key: [key]ComputerID: [id]IP: [ip] [expiry](By: [by])(Reason: [reason])") - - dat += "" - dat = "
Bans: (U) = Unban , (E) = Edit Ban - ([count] Bans)
[dat]" - usr << browse(dat, "window=unbanp;size=875x400") - -//////////////////////////////////// DEBUG //////////////////////////////////// - -/proc/CreateBans() - - UpdateTime() - - var/i - var/last - - for(i=0, i<1001, i++) - var/a = pick(1,0) - var/b = pick(1,0) - if(b) - GLOB.banlist_savefile.cd = "/base" - GLOB.banlist_savefile.dir.Add("trash[i]trashid[i]") - GLOB.banlist_savefile.cd = "/base/trash[i]trashid[i]" - GLOB.banlist_savefile["key"] << "trash[i]" - else - GLOB.banlist_savefile.cd = "/base" - GLOB.banlist_savefile.dir.Add("[last]trashid[i]") - GLOB.banlist_savefile.cd = "/base/[last]trashid[i]" - GLOB.banlist_savefile["key"] << last - GLOB.banlist_savefile["id"] << "trashid[i]" - GLOB.banlist_savefile["reason"] << "Trashban[i]." - GLOB.banlist_savefile["temp"] << a - GLOB.banlist_savefile["minutes"] << GLOB.CMinutes + rand(1,2000) - GLOB.banlist_savefile["bannedby"] << "trashmin" - last = "trash[i]" - - GLOB.banlist_savefile.cd = "/base" - -/proc/ClearAllBans() - GLOB.banlist_savefile.cd = "/base" - for(var/A in GLOB.banlist_savefile.dir) - RemoveBan(A) - diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index 8d97a764e47..fca3a4fb476 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -311,19 +311,6 @@ GLOBAL_VAR_INIT(nologevent, 0) if(key) SSipintel.vpn_whitelist_panel(key) -/datum/admins/proc/Jobbans() - if(!check_rights(R_BAN)) - return - - var/dat = "Job Bans!
" - for(var/t in GLOB.jobban_keylist) - var/r = t - if( findtext(r,"##") ) - r = copytext( r, 1, findtext(r,"##") )//removes the description - dat += text("") - dat += "
[t] (unban)
" - usr << browse(dat, "window=ban;size=400x400") - /datum/admins/proc/Game() if(!check_rights(R_ADMIN)) return diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index c4b14311986..ab752c42dc5 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -409,10 +409,7 @@ GLOBAL_LIST_INIT(admin_verbs_ticket, list( if(!check_rights(R_BAN)) return - if(!GLOB.configuration.general.use_database_bans) - holder.unbanpanel() - else - holder.DB_ban_panel() + holder.DB_ban_panel() SSblackbox.record_feedback("tally", "admin_verb", 1, "Ban Panel") //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 ced3e6ff964..808491d3994 100644 --- a/code/modules/admin/banjob.dm +++ b/code/modules/admin/banjob.dm @@ -17,16 +17,12 @@ GLOBAL_DATUM_INIT(jobban_regex, /regex, regex("(\[\\S]+) - (\[^#]+\[^# ])(?: ## return GLOB.jobban_keylist.Add(text("[M.ckey] - [rank] ## [reason]")) jobban_assoc_insert(M.ckey, rank, reason) - if(!GLOB.configuration.general.use_database_bans) - jobban_savebanfile() /proc/jobban_client_fullban(ckey, rank) if(!ckey || !rank) return GLOB.jobban_keylist.Add(text("[ckey] - [rank]")) jobban_assoc_insert(ckey, rank) - if(!GLOB.configuration.general.use_database_bans) - jobban_savebanfile() //returns a reason if M is banned from rank, returns 0 otherwise /proc/jobban_isbanned(mob/M, rank) @@ -55,58 +51,40 @@ GLOBAL_DATUM_INIT(jobban_regex, /regex, regex("(\[\\S]+) - (\[^#]+\[^# ])(?: ## return null -/proc/jobban_loadbanfile() - if(!GLOB.configuration.general.use_database_bans) - var/savefile/S=new("data/job_full.ban") - S["keys[0]"] >> GLOB.jobban_keylist - log_admin("Loading jobban_rank") - S["runonce"] >> GLOB.jobban_runonce +/proc/jobban_loadbans() + if(!SSdbcore.IsConnected()) + log_world("Database connection failed. Job bans not loaded.") + return - if(!length(GLOB.jobban_keylist)) - GLOB.jobban_keylist=list() - log_admin("jobban_keylist was empty") - - for(var/s in GLOB.jobban_keylist) - if(GLOB.jobban_regex.Find(s)) - jobban_assoc_insert(GLOB.jobban_regex.group[1], GLOB.jobban_regex.group[2], GLOB.jobban_regex.group[3]) - else - log_runtime(EXCEPTION("Skipping malformed job ban: [s]")) - else - if(!SSdbcore.IsConnected()) - log_world("Database connection failed. Reverting to the legacy ban system.") - GLOB.configuration.general.use_database_bans = FALSE - jobban_loadbanfile() - return - - //Job permabans - var/datum/db_query/permabans = SSdbcore.NewQuery("SELECT ckey, job FROM ban WHERE bantype = 'JOB_PERMABAN' AND isnull(unbanned)") - - if(!permabans.warn_execute(async=FALSE)) - qdel(permabans) - return FALSE - - while(permabans.NextRow()) - var/ckey = permabans.item[1] - var/job = permabans.item[2] - GLOB.jobban_keylist.Add("[ckey] - [job]") - jobban_assoc_insert(ckey, job) + //Job permabans + var/datum/db_query/permabans = SSdbcore.NewQuery("SELECT ckey, job FROM ban WHERE bantype = 'JOB_PERMABAN' AND isnull(unbanned)") + if(!permabans.warn_execute(async=FALSE)) qdel(permabans) + return FALSE - // Job tempbans - var/datum/db_query/tempbans = SSdbcore.NewQuery("SELECT ckey, job FROM ban WHERE bantype = 'JOB_TEMPBAN' AND isnull(unbanned) AND expiration_time > Now()") + while(permabans.NextRow()) + var/ckey = permabans.item[1] + var/job = permabans.item[2] + GLOB.jobban_keylist.Add("[ckey] - [job]") + jobban_assoc_insert(ckey, job) - if(!tempbans.warn_execute(async=FALSE)) - qdel(tempbans) - return FALSE + qdel(permabans) - while(tempbans.NextRow()) - var/ckey = tempbans.item[1] - var/job = tempbans.item[2] - GLOB.jobban_keylist.Add("[ckey] - [job]") - jobban_assoc_insert(ckey, job) + // Job tempbans + var/datum/db_query/tempbans = SSdbcore.NewQuery("SELECT ckey, job FROM ban WHERE bantype = 'JOB_TEMPBAN' AND isnull(unbanned) AND expiration_time > Now()") + if(!tempbans.warn_execute(async=FALSE)) qdel(tempbans) + return FALSE + + while(tempbans.NextRow()) + var/ckey = tempbans.item[1] + var/job = tempbans.item[2] + GLOB.jobban_keylist.Add("[ckey] - [job]") + jobban_assoc_insert(ckey, job) + + qdel(tempbans) /proc/jobban_savebanfile() var/savefile/S=new("data/job_full.ban") @@ -132,8 +110,6 @@ GLOBAL_DATUM_INIT(jobban_regex, /regex, regex("(\[\\S]+) - (\[^#]+\[^# ])(?: ## else log_runtime(EXCEPTION("Failed to remove malformed job ban from associative list: [X]")) GLOB.jobban_keylist.Remove(GLOB.jobban_keylist[i]) - if(!GLOB.configuration.general.use_database_bans) - jobban_savebanfile() return 1 return 0 @@ -144,45 +120,40 @@ GLOBAL_DATUM_INIT(jobban_regex, /regex, regex("(\[\\S]+) - (\[^#]+\[^# ])(?: ## if(!client || !ckey) return - if(!GLOB.configuration.general.use_database_bans) - //using the legacy .txt ban system - to_chat(src, "The server is using the legacy ban system. Ask an administrator for help!") - else - //using the SQL ban system - var/is_actually_banned = FALSE - var/datum/db_query/select_query = SSdbcore.NewQuery({" - SELECT bantime, bantype, reason, job, duration, expiration_time, a_ckey FROM ban - WHERE ckey LIKE :ckey AND ((bantype like 'JOB_TEMPBAN' AND expiration_time > Now()) OR (bantype like 'JOB_PERMABAN')) AND isnull(unbanned) - ORDER BY bantime DESC LIMIT 100"}, - list("ckey" = ckey) - ) - - if(!select_query.warn_execute()) - qdel(select_query) - return FALSE - - while(select_query.NextRow()) - - var/bantime = select_query.item[1] - var/bantype = select_query.item[2] - var/reason = select_query.item[3] - var/job = select_query.item[4] - var/duration = select_query.item[5] - var/expiration = select_query.item[6] - var/ackey = select_query.item[7] - - if(bantype == "JOB_PERMABAN") - to_chat(src, "[bantype]: [job] - REASON: [reason], by [ackey]; [bantime]") - else if(bantype == "JOB_TEMPBAN") - to_chat(src, "[bantype]: [job] - REASON: [reason], by [ackey]; [bantime]; [duration]; expires [expiration]") - - is_actually_banned = TRUE + var/is_actually_banned = FALSE + var/datum/db_query/select_query = SSdbcore.NewQuery({" + SELECT bantime, bantype, reason, job, duration, expiration_time, a_ckey FROM ban + WHERE ckey LIKE :ckey AND ((bantype like 'JOB_TEMPBAN' AND expiration_time > Now()) OR (bantype like 'JOB_PERMABAN')) AND isnull(unbanned) + ORDER BY bantime DESC LIMIT 100"}, + list("ckey" = ckey) + ) + if(!select_query.warn_execute()) qdel(select_query) + return FALSE - if(is_actually_banned) - if(GLOB.configuration.url.banappeals_url) - to_chat(src, "You can appeal the bans at: [GLOB.configuration.url.banappeals_url]") - else - to_chat(src, "You have no active jobbans!") + while(select_query.NextRow()) + + var/bantime = select_query.item[1] + var/bantype = select_query.item[2] + var/reason = select_query.item[3] + var/job = select_query.item[4] + var/duration = select_query.item[5] + var/expiration = select_query.item[6] + var/ackey = select_query.item[7] + + if(bantype == "JOB_PERMABAN") + to_chat(src, "[bantype]: [job] - REASON: [reason], by [ackey]; [bantime]") + else if(bantype == "JOB_TEMPBAN") + to_chat(src, "[bantype]: [job] - REASON: [reason], by [ackey]; [bantime]; [duration]; expires [expiration]") + + is_actually_banned = TRUE + + qdel(select_query) + + if(is_actually_banned) + if(GLOB.configuration.url.banappeals_url) + to_chat(src, "You can appeal the bans at: [GLOB.configuration.url.banappeals_url]") + else + to_chat(src, "You have no active jobbans!") diff --git a/code/modules/admin/db_ban/functions.dm b/code/modules/admin/db_ban/functions.dm index b65f5decd8c..b83bc4ec028 100644 --- a/code/modules/admin/db_ban/functions.dm +++ b/code/modules/admin/db_ban/functions.dm @@ -412,17 +412,6 @@ flag_account_for_forum_sync(pckey) -/client/proc/DB_ban_panel() - set category = "Admin" - set name = "Banning Panel" - set desc = "DB Ban Panel" - - if(!check_rights(R_BAN)) - return - - holder.DB_ban_panel() - - /datum/admins/proc/DB_ban_panel(playerckey = null, adminckey = null, playerip = null, playercid = null, dbbantype = null, match = null) if(!usr.client) diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 20ff7bb3394..a63bb54264b 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -425,71 +425,13 @@ log_admin("[key_name(usr)] has used rudimentary transformation on [key_name(M)]. Transforming to [href_list["simplemake"]]; deletemob=[delmob]") message_admins("[key_name_admin(usr)] has used rudimentary transformation on [key_name_admin(M)]. Transforming to [href_list["simplemake"]]; deletemob=[delmob]", 1) - - /////////////////////////////////////new ban stuff - else if(href_list["unbanf"]) - if(!check_rights(R_BAN)) return - - var/banfolder = href_list["unbanf"] - GLOB.banlist_savefile.cd = "/base/[banfolder]" - var/key = GLOB.banlist_savefile["key"] - if(alert(usr, "Are you sure you want to unban [key]?", "Confirmation", "Yes", "No") == "Yes") - if(RemoveBan(banfolder)) - unbanpanel() - else - alert(usr, "This ban has already been lifted / does not exist.", "Error", "Ok") - unbanpanel() - - else if(href_list["unbane"]) - if(!check_rights(R_BAN)) return - - UpdateTime() - var/reason - - var/banfolder = href_list["unbane"] - GLOB.banlist_savefile.cd = "/base/[banfolder]" - var/reason2 = GLOB.banlist_savefile["reason"] - var/temp = GLOB.banlist_savefile["temp"] - - var/minutes = GLOB.banlist_savefile["minutes"] - - var/banned_key = GLOB.banlist_savefile["key"] - GLOB.banlist_savefile.cd = "/base" - - var/duration - - switch(alert("Temporary Ban?",,"Yes","No")) - if("Yes") - temp = 1 - var/mins = 0 - if(minutes > GLOB.CMinutes) - mins = minutes - GLOB.CMinutes - mins = input(usr,"How long (in minutes)? (Default: 1440)","Ban time",mins ? mins : 1440) as num|null - if(!mins) return - mins = min(525599,mins) - minutes = GLOB.CMinutes + mins - duration = GetExp(minutes) - reason = input(usr,"Please state the reason","Reason",reason2) as message|null - if(!reason) return - if("No") - temp = 0 - duration = "Perma" - reason = input(usr,"Please state the reason","Reason",reason2) as message|null - if(!reason) return - - log_admin("[key_name(usr)] edited [banned_key]'s ban. Reason: [reason] Duration: [duration]") - message_admins("[key_name_admin(usr)] edited [banned_key]'s ban. Reason: [reason] Duration: [duration]", 1) - GLOB.banlist_savefile.cd = "/base/[banfolder]" - to_chat(GLOB.banlist_savefile["reason"], reason) - to_chat(GLOB.banlist_savefile["temp"], temp) - to_chat(GLOB.banlist_savefile["minutes"], minutes) - to_chat(GLOB.banlist_savefile["bannedby"], usr.ckey) - GLOB.banlist_savefile.cd = "/base" - unbanpanel() - else if(href_list["jobban2"]) // if(!check_rights(R_BAN)) return + if(!SSdbcore.IsConnected()) + alert(usr, "Job bans require the datbase to be setup.", "Error", "Ok") + return + var/mob/M = locateUID(href_list["jobban2"]) if(!istype(M, /mob)) to_chat(usr, "This can only be used on instances of type /mob") @@ -507,11 +449,11 @@ var/body var/jobs = "" - /***********************************WARNING!************************************ - The jobban stuff looks mangled and disgusting - But it looks beautiful in-game - -Nodrak - ************************************WARNING!***********************************/ + /***********************************WARNING!************************************ + The jobban stuff looks mangled and disgusting + But it looks beautiful in-game + -Nodrak + ************************************WARNING!***********************************/ var/counter = 0 //Regular jobs //Command (Blue) @@ -691,7 +633,7 @@ counter = 0 jobs += "" - //Other races (BLUE, because I have no idea what other color to make this) + //Other races (BLUE, because I have no idea what other color to make this) jobs += "" jobs += "" @@ -819,9 +761,6 @@ if(notbannedlist.len) //at least 1 unbanned job exists in joblist so we have stuff to ban. switch(alert("Temporary Ban of [M.ckey]?",,"Yes","No", "Cancel")) if("Yes") - if(!GLOB.configuration.general.use_database_bans) - to_chat(usr, "Your server is using the legacy banning system, which does not support temporary job bans. Consider upgrading. Aborting ban.") - return var/mins = input(usr,"How long (in minutes)?","Ban time",1440) as num|null if(!mins) return @@ -867,33 +806,6 @@ if("Cancel") return - //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(GLOB.configuration.general.use_database_bans) - to_chat(usr, "Unfortunately, database based unbanning cannot be done through this panel") - DB_ban_panel(M.ckey) - return - var/msg - for(var/job in joblist) - var/reason = jobban_isbanned(M, job) - if(!reason) continue //skip if it isn't jobbanned anyway - switch(alert("Job: '[job]' Reason: '[reason]' Un-jobban?","Please Confirm","Yes","No")) - if("Yes") - log_admin("[key_name(usr)] unbanned [key_name(M)] from [job]") - DB_ban_unban(M.ckey, BANTYPE_JOB_PERMA, job) - jobban_unban(M, job) - if(!msg) msg = job - else msg += ", [job]" - else - continue - if(msg) - message_admins("[key_name_admin(usr)] unbanned [key_name_admin(M)] from [msg]", 1) - to_chat(M, "You have been un-jobbanned by [usr.client.ckey] from [msg].") - href_list["jobban2"] = 1 // lets it fall through and refresh - return 1 - return 0 //we didn't do anything! - else if(href_list["boot2"]) var/mob/M = locateUID(href_list["boot2"]) if(!ismob(M)) @@ -989,6 +901,10 @@ else if(href_list["newban"]) if(!check_rights(R_BAN)) return + if(!SSdbcore.IsConnected()) + alert(usr, "Bans require the database to be connected.
If this is a local server, please ban from within Dream Daemon.", "Error", "Ok") + return + var/mob/M = locateUID(href_list["newban"]) if(!istype(M, /mob)) return @@ -1004,7 +920,6 @@ if(!reason) return M = admin_ban_mobsearch(M, ban_ckey_param, usr) - AddBan(M.ckey, M.computer_id, reason, usr.ckey, 1, mins) to_chat(M, "You have been banned by [usr.client.ckey].\nReason: [reason].") to_chat(M, "This is a temporary ban, it will be removed in [mins] minutes.") DB_ban_record(BANTYPE_TEMP, M, mins, reason) @@ -1022,7 +937,6 @@ var/reason = input(usr,"Please state the reason","Reason") as message|null if(!reason) return - AddBan(M.ckey, M.computer_id, reason, usr.ckey, 0, 0, M.lastKnownIP) to_chat(M, "You have been banned by [usr.client.ckey].\nReason: [reason].") to_chat(M, "This ban does not expire automatically and must be appealed.") if(M.client) diff --git a/config/example/config.toml b/config/example/config.toml index 150e989a2a1..56089864d4f 100644 --- a/config/example/config.toml +++ b/config/example/config.toml @@ -297,8 +297,6 @@ server_name = "ParaCode Test" server_tag_line = "ParaCode Testing Server" # Server features. Shows in a newline server_features = "Medium RP, varied species/jobs." -# Store bans in the database? If you are in production, you want this on -use_database_bans = false # Allow OOC character metadata notes allow_character_metadata = true # Lobby time before roundstart (Seconds) diff --git a/paradise.dme b/paradise.dme index 10853436ee4..456ab1bf3d5 100644 --- a/paradise.dme +++ b/paradise.dme @@ -1191,7 +1191,6 @@ #include "code\modules\admin\IsBanned.dm" #include "code\modules\admin\machine_upgrade.dm" #include "code\modules\admin\mute.dm" -#include "code\modules\admin\NewBan.dm" #include "code\modules\admin\outfits.dm" #include "code\modules\admin\player_panel.dm" #include "code\modules\admin\secrets.dm"
Other