mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-24 13:30:42 +01:00
Ban System Update - better mirroring
Mirrors have been updated to actually fetch the active mirror, as opposed to using an old mirror and referencing that, and then letting the banned individual through. You can also now view the mirrors for a ban. Also denies entry for people who for _some_ reason lack a computer ID or an IP address. The former can be done by using a specific wsock32.dll in your BYOND bin to bypass bans.
This commit is contained in:
@@ -13,8 +13,6 @@
|
||||
log_misc("Ban database connection failure while attempting to mirror. Key passed for mirror handling: [ckey].")
|
||||
return
|
||||
|
||||
ckey = ckey(ckey)
|
||||
|
||||
var/bad_data = BAD_CKEY|BAD_IP|BAD_CID
|
||||
|
||||
var/DBQuery/original_ban = dbcon.NewQuery("SELECT ckey, ip, computerid FROM ss13_ban WHERE id = :ban_id")
|
||||
@@ -63,3 +61,68 @@
|
||||
#undef BAD_CID
|
||||
#undef BAD_IP
|
||||
#undef BAD_CKEY
|
||||
|
||||
/proc/get_active_mirror(var/ckey, var/address, var/computer_id)
|
||||
if (!ckey || !address || !computer_id)
|
||||
return null
|
||||
|
||||
establish_db_connection(dbcon)
|
||||
|
||||
if (!dbcon.IsConnected())
|
||||
error("Ban database connection failure while attempting to check mirrors. Key passed for mirror checking: [ckey].")
|
||||
log_misc("Ban database connection failure while attempting to check mirrors. Key passed for mirror checking: [ckey].")
|
||||
return null
|
||||
|
||||
var/DBQuery/initial_query = dbcon.NewQuery("SELECT DISTINCT ban_id FROM ss13_ban_mirrors WHERE player_ckey = :ckey OR ban_mirror_ip = :address OR ban_mirror_computerid = :computerid")
|
||||
initial_query.Execute(list(":ckey" = ckey, ":address" = address, ":computerid" = computer_id))
|
||||
|
||||
var/list/ban_ids = list()
|
||||
|
||||
while (initial_query.NextRow())
|
||||
ban_ids += text2num(initial_query.item[1])
|
||||
|
||||
// No mirrors exist.
|
||||
if (!ban_ids.len)
|
||||
return null
|
||||
|
||||
var/DBQuery/search_query = dbcon.NewQuery("SELECT id FROM ss13_ban WHERE id IN :vars AND (bantype = 'PERMABAN' OR (bantype = 'TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)")
|
||||
search_query.Execute(":vars" = ban_ids)
|
||||
|
||||
var/list/active_bans = list()
|
||||
|
||||
while (search_query.NextRow())
|
||||
active_bans += text2num(search_query.item[1])
|
||||
|
||||
if (!active_bans.len)
|
||||
// None are active.
|
||||
return null
|
||||
else
|
||||
// Return the latest entry, if multiple bans are active.
|
||||
// Just in case.
|
||||
return active_bans[active_bans.len]
|
||||
|
||||
/proc/get_ban_mirrors(var/ban_id)
|
||||
if (!ban_id)
|
||||
return null
|
||||
|
||||
establish_db_connection(dbcon)
|
||||
|
||||
if (!dbcon.IsConnected())
|
||||
return null
|
||||
|
||||
var/DBQuery/query = dbcon.NewQuery("SELECT ban_mirror_id, player_ckey, ban_mirror_ip, ban_mirror_computerid, date(ban_mirror_datetime) as datetime FROM ss13_ban_mirrors WHERE ban_id = :ban_id")
|
||||
query.Execute(list(":ban_id" = ban_id))
|
||||
|
||||
testing("Ban ID: [ban_id]")
|
||||
|
||||
var/mirrors[] = list()
|
||||
while (query.NextRow())
|
||||
var/items[] = list()
|
||||
items["ckey"] = query.item[2]
|
||||
items["ip"] = query.item[3]
|
||||
items["computerid"] = query.item[4]
|
||||
items["date"] = query.item[5]
|
||||
|
||||
mirrors[query.item[1]] = items
|
||||
|
||||
return mirrors
|
||||
|
||||
@@ -488,7 +488,7 @@ datum/admins/proc/DB_ban_unban_by_id(var/id)
|
||||
|
||||
if (mirror_count)
|
||||
output += "<tr bgcolor='[dcolor]'>"
|
||||
output += "<td align='center' colspan='5' bgcolor=''><b>Ban Mirrored [mirror_count > 1 ? "[mirror_count] times" : "once"]!</b></td>"
|
||||
output += "<td align='center' colspan='5' bgcolor=''><b>Ban Mirrored <a href=\"byond://?src=\ref[src];dbbanmirrors=[banid]\">[mirror_count > 1 ? "[mirror_count] times" : "once"]</a>!</b></td>"
|
||||
output += "</tr>"
|
||||
|
||||
output += "<tr>"
|
||||
|
||||
Reference in New Issue
Block a user