From adb9b58f8e064effb0fa32642ed52631380b89ac Mon Sep 17 00:00:00 2001
From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
Date: Sat, 16 Jan 2021 21:38:45 +0000
Subject: [PATCH] Updates some admin stuff (#15297)
* Fixes camera view
* Unique CID tracking notes
* Ban tracking
* Note round IDs
* Karma viewing
* Minor tweak
* Manual ban job bans
* More tweaks
* Farie tweaks
* Connection result field
* Orange watchlist names
* Autopopulate tickbox
---
SQL/paradise_schema.sql | 5 +
SQL/paradise_schema_prefixed.sql | 5 +
SQL/updates/19-20.sql | 14 +++
code/__DEFINES/admin.dm | 16 +++
code/__DEFINES/misc.dm | 2 +-
code/__HELPERS/unsorted.dm | 11 ++
code/controllers/configuration.dm | 5 +
code/defines/procs/admin.dm | 2 +
code/modules/admin/IsBanned.dm | 13 ++-
code/modules/admin/admin.dm | 1 +
code/modules/admin/banjob.dm | 13 +++
code/modules/admin/cookielog.dm | 113 +++++++++++++++++++++
code/modules/admin/db_ban/functions.dm | 19 ++--
code/modules/admin/sql_notes.dm | 30 ++++--
code/modules/admin/topic.dm | 133 +++++++++++++++++++++++--
code/modules/admin/verbs/mapping.dm | 19 ++--
code/modules/admin/watchlist.dm | 6 ++
code/modules/client/client_defines.dm | 3 +
code/modules/client/client_procs.dm | 92 +++++++++++++++--
config/example/config.txt | 3 +
config/example/dbconfig.txt | 2 +-
goon/code/datums/browserOutput.dm | 1 +
paradise.dme | 1 +
tools/ci/dbconfig.txt | 2 +-
24 files changed, 462 insertions(+), 49 deletions(-)
create mode 100644 SQL/updates/19-20.sql
create mode 100644 code/modules/admin/cookielog.dm
diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql
index 7da1473b4c3..dab229a8051 100644
--- a/SQL/paradise_schema.sql
+++ b/SQL/paradise_schema.sql
@@ -195,6 +195,7 @@ DROP TABLE IF EXISTS `ban`;
CREATE TABLE `ban` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`bantime` datetime NOT NULL,
+ `ban_round_id` INT(11) NULL DEFAULT NULL,
`serverip` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
`bantype` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
`reason` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -213,6 +214,7 @@ CREATE TABLE `ban` (
`edits` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`unbanned` tinyint(1) DEFAULT NULL,
`unbanned_datetime` datetime DEFAULT NULL,
+ `unbanned_round_id` INT(11) NULL DEFAULT NULL,
`unbanned_ckey` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`unbanned_computerid` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`unbanned_ip` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
@@ -433,11 +435,13 @@ CREATE TABLE `notes` (
`ckey` varchar(32) NOT NULL,
`notetext` text NOT NULL,
`timestamp` datetime NOT NULL,
+ `round_id` INT(11) NULL DEFAULT NULL,
`adminckey` varchar(32) NOT NULL,
`last_editor` varchar(32),
`edits` text,
`server` varchar(50) NOT NULL,
`crew_playtime` mediumint(8) UNSIGNED DEFAULT '0',
+ `automated` TINYINT(3) UNSIGNED NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `ckey` (`ckey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
@@ -527,6 +531,7 @@ CREATE TABLE `connection_log` (
`ckey` varchar(32) NOT NULL,
`ip` varchar(32) NOT NULL,
`computerid` varchar(32) NOT NULL,
+ `result` ENUM('ESTABLISHED','DROPPED - IPINTEL','DROPPED - BANNED','DROPPED - INVALID') NOT NULL DEFAULT 'ESTABLISHED' COLLATE 'utf8mb4_general_ci',
PRIMARY KEY (`id`),
KEY `ckey` (`ckey`),
KEY `ip` (`ip`),
diff --git a/SQL/paradise_schema_prefixed.sql b/SQL/paradise_schema_prefixed.sql
index 4f6898eeee7..a58d6250f65 100644
--- a/SQL/paradise_schema_prefixed.sql
+++ b/SQL/paradise_schema_prefixed.sql
@@ -194,6 +194,7 @@ DROP TABLE IF EXISTS `SS13_ban`;
CREATE TABLE `SS13_ban` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`bantime` datetime NOT NULL,
+ `ban_round_id` INT(11) NULL DEFAULT NULL,
`serverip` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
`bantype` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL,
`reason` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -212,6 +213,7 @@ CREATE TABLE `SS13_ban` (
`edits` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`unbanned` tinyint(1) DEFAULT NULL,
`unbanned_datetime` datetime DEFAULT NULL,
+ `unbanned_round_id` INT(11) NULL DEFAULT NULL,
`unbanned_ckey` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`unbanned_computerid` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`unbanned_ip` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
@@ -432,11 +434,13 @@ CREATE TABLE `SS13_notes` (
`ckey` varchar(32) NOT NULL,
`notetext` text NOT NULL,
`timestamp` datetime NOT NULL,
+ `round_id` INT(11) NULL DEFAULT NULL,
`adminckey` varchar(32) NOT NULL,
`last_editor` varchar(32),
`edits` text,
`server` varchar(50) NOT NULL,
`crew_playtime` mediumint(8) UNSIGNED DEFAULT '0',
+ `automated` TINYINT(3) UNSIGNED NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `ckey` (`ckey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
@@ -524,6 +528,7 @@ CREATE TABLE `SS13_connection_log` (
`ckey` varchar(32) NOT NULL,
`ip` varchar(32) NOT NULL,
`computerid` varchar(32) NOT NULL,
+ `result` ENUM('ESTABLISHED','DROPPED - IPINTEL','DROPPED - BANNED','DROPPED - INVALID') NOT NULL DEFAULT 'ESTABLISHED' COLLATE 'utf8mb4_general_ci',
PRIMARY KEY (`id`),
KEY `ckey` (`ckey`),
KEY `ip` (`ip`),
diff --git a/SQL/updates/19-20.sql b/SQL/updates/19-20.sql
new file mode 100644
index 00000000000..16eac5e7b68
--- /dev/null
+++ b/SQL/updates/19-20.sql
@@ -0,0 +1,14 @@
+# Updating DB from 19-20, -AffectedArc07
+# Tracks round IDs in notes and bans, as well as other admin tweaks
+
+# Add new columns to ban
+ALTER TABLE `ban` ADD COLUMN `ban_round_id` INT NULL DEFAULT NULL AFTER `bantime`;
+ALTER TABLE `ban` ADD COLUMN `unbanned_round_id` INT NULL DEFAULT NULL AFTER `unbanned_datetime`;
+
+
+# Add new columns to notes
+ALTER TABLE `notes` ADD COLUMN `round_id` INT NULL DEFAULT NULL AFTER `timestamp`;
+ALTER TABLE `notes` ADD COLUMN `automated` TINYINT UNSIGNED NULL DEFAULT '0' AFTER `crew_playtime`;
+
+# Add new column to connection_log
+ALTER TABLE `connection_log` ADD COLUMN `result` ENUM('ESTABLISHED','DROPPED - IPINTEL', 'DROPPED - BANNED', 'DROPPED - INVALID') NOT NULL DEFAULT 'ESTABLISHED' AFTER `computerid`;
diff --git a/code/__DEFINES/admin.dm b/code/__DEFINES/admin.dm
index 95494fb88cf..99fa1c50e0a 100644
--- a/code/__DEFINES/admin.dm
+++ b/code/__DEFINES/admin.dm
@@ -72,3 +72,19 @@
#define MAX_KEYPRESS_AUTOKICK 50
///Length of held key rolling buffer
#define HELD_KEY_BUFFER_LENGTH 15
+
+/// Note text for suppressed CID warning
+#define CIDWARNING_SUPPRESSED_NOTETEXT "CID COUNT WARNING DISABLED - Delete this note to re-enable"
+
+/// Note "ckey" for CID info tracking. Do not EVER update this.
+#define CIDTRACKING_PSUEDO_CKEY "ALICE-CIDTRACKING"
+
+// Connection types. These match enums in the SQL DB. Dont change them
+/// Client was let into the server
+#define CONNECTION_TYPE_ESTABLISHED "ESTABLISHED"
+/// Client was disallowed due to IPIntel
+#define CONNECTION_TYPE_DROPPED_IPINTEL "DROPPED - IPINTEL"
+/// Client was disallowed due to being banned
+#define CONNECTION_TYPE_DROPPED_BANNED "DROPPED - BANNED"
+/// Client was disallowed due to invalid data
+#define CONNECTION_TYPE_DROPPED_INVALID "DROPPED - INVALID"
diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm
index 82550c5113a..c37a1943046 100644
--- a/code/__DEFINES/misc.dm
+++ b/code/__DEFINES/misc.dm
@@ -363,7 +363,7 @@
#define INVESTIGATE_BOMB "bombs"
// The SQL version required by this version of the code
-#define SQL_VERSION 19
+#define SQL_VERSION 20
// Vending machine stuff
#define CAT_NORMAL 1
diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm
index 4a2cbf8ce4f..33582212c1f 100644
--- a/code/__HELPERS/unsorted.dm
+++ b/code/__HELPERS/unsorted.dm
@@ -2052,3 +2052,14 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
return TRUE
return contains(location.loc)
+
+/proc/log_connection(ckey, ip, cid, connection_type)
+ ASSERT(connection_type in list(CONNECTION_TYPE_ESTABLISHED, CONNECTION_TYPE_DROPPED_IPINTEL, CONNECTION_TYPE_DROPPED_BANNED, CONNECTION_TYPE_DROPPED_INVALID))
+ var/datum/db_query/query_accesslog = SSdbcore.NewQuery("INSERT INTO `[format_table_name("connection_log")]`(`datetime`, `ckey`, `ip`, `computerid`, `result`) VALUES(Now(), :ckey, :ip, :cid, :result)", list(
+ "ckey" = ckey,
+ "ip" = "[ip ? ip : ""]", // This is important. NULL is not the same as "", and if you directly open the `.dmb` file, you get a NULL IP.
+ "cid" = cid,
+ "result" = connection_type
+ ))
+ query_accesslog.warn_execute()
+ qdel(query_accesslog)
diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm
index c80fe0f7804..6640882facc 100644
--- a/code/controllers/configuration.dm
+++ b/code/controllers/configuration.dm
@@ -274,6 +274,9 @@
/// Limit of how many SQL threads can run at once
var/rust_sql_thread_limit = 50
+ /// Max amount of CIDs that one ckey can have attached to them before they trip a warning
+ var/max_client_cid_history = 3
+
/datum/configuration/New()
for(var/T in subtypesof(/datum/game_mode))
var/datum/game_mode/M = T
@@ -765,6 +768,8 @@
// End discord stuff
if("centcom_ban_db_url")
centcom_ban_db_url = value
+ if("max_client_cid_history")
+ max_client_cid_history = text2num(value)
else
log_config("Unknown setting in configuration: '[name]'")
diff --git a/code/defines/procs/admin.dm b/code/defines/procs/admin.dm
index fa5556b4e40..dea540791be 100644
--- a/code/defines/procs/admin.dm
+++ b/code/defines/procs/admin.dm
@@ -48,6 +48,8 @@
if(include_link && C)
. += ""
. += key
+ if(C && C.watchlisted)
+ . += "(W)"
if(include_link)
if(C) . += ""
diff --git a/code/modules/admin/IsBanned.dm b/code/modules/admin/IsBanned.dm
index 44da9f04d58..e160ee3838d 100644
--- a/code/modules/admin/IsBanned.dm
+++ b/code/modules/admin/IsBanned.dm
@@ -3,6 +3,8 @@
if(!key || !address || !computer_id)
log_adminwarn("Failed Login (invalid data): [key] [address]-[computer_id]")
+ // The nested ternaries are needed here
+ INVOKE_ASYNC(GLOBAL_PROC, .proc/log_connection, (ckey(key) || ""), (address || ""), (computer_id || ""), CONNECTION_TYPE_DROPPED_INVALID)
return list("reason"="invalid login data", "desc"="Error: Could not check ban status, please try again. Error message: Your computer provided invalid or blank information to the server on connection (BYOND Username, IP, and Computer ID). Provided information for reference: Username: '[key]' IP: '[address]' Computer ID: '[computer_id]'. If you continue to get this error, please restart byond or contact byond support.")
if(type == "world")
@@ -10,6 +12,7 @@
if(text2num(computer_id) == 2147483647) //this cid causes stickybans to go haywire
log_adminwarn("Failed Login (invalid cid): [key] [address]-[computer_id]")
+ INVOKE_ASYNC(GLOBAL_PROC, .proc/log_connection, ckey(key), address, computer_id, CONNECTION_TYPE_DROPPED_INVALID)
return list("reason"="invalid login data", "desc"="Error: Could not check ban status, Please try again. Error message: Your computer provided an invalid Computer ID.")
var/admin = 0
@@ -28,6 +31,7 @@
if(!GLOB.guests_allowed && IsGuestKey(key))
log_adminwarn("Failed Login: [key] [computer_id] [address] - Guests not allowed")
// message_admins("Failed Login: [key] - Guests not allowed")
+ INVOKE_ASYNC(GLOBAL_PROC, .proc/log_connection, ckey(key), address, computer_id, CONNECTION_TYPE_DROPPED_BANNED)
return list("reason"="guest", "desc"="\nReason: Guests not allowed. Please sign in with a BYOND account.")
//check if the IP address is a known proxy/vpn, and the user is not whitelisted
@@ -36,6 +40,7 @@
var/mistakemessage = ""
if(config.banappeals)
mistakemessage = "\nIf you have to use one, request whitelisting at: [config.banappeals]"
+ INVOKE_ASYNC(GLOBAL_PROC, .proc/log_connection, ckey(key), address, computer_id, CONNECTION_TYPE_DROPPED_IPINTEL)
return list("reason"="using proxy or vpn", "desc"="\nReason: Proxies/VPNs are not allowed here. [mistakemessage]")
@@ -72,7 +77,7 @@
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 FROM [format_table_name("ban")]
+ SELECT ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype, ban_round_id FROM [format_table_name("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)
@@ -91,6 +96,7 @@
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
@@ -114,11 +120,12 @@
appealmessage = " You may appeal it at [config.banappeals]."
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].[expires]"
+ 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)
@@ -135,5 +142,5 @@
return null
else
log_adminwarn("Failed Login: [key] [computer_id] [address] - Banned [.["message"]]")
-
+ INVOKE_ASYNC(GLOBAL_PROC, .proc/log_connection, ckey(key), address, computer_id, CONNECTION_TYPE_DROPPED_BANNED)
return .
diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm
index 1d63a00874f..64ad4bf7c4a 100644
--- a/code/modules/admin/admin.dm
+++ b/code/modules/admin/admin.dm
@@ -126,6 +126,7 @@ GLOBAL_VAR_INIT(nologevent, 0)
body += "Jobban | "
body += "Appearance Ban | "
body += "Notes | "
+ body += "View Karma | "
if(config.forum_playerinfo_url)
body += "WebInfo | "
if(M.client)
diff --git a/code/modules/admin/banjob.dm b/code/modules/admin/banjob.dm
index 22d2a825ac6..7ff26de5992 100644
--- a/code/modules/admin/banjob.dm
+++ b/code/modules/admin/banjob.dm
@@ -42,6 +42,19 @@ GLOBAL_DATUM_INIT(jobban_regex, /regex, regex("(\[\\S]+) - (\[^#]+\[^# ])(?: ##
else
return 0
+/proc/jobban_isbanned_ckey(ckey, rank)
+ if(!ckey || !rank)
+ return null
+
+ if(config.guest_jobban && guest_jobbans(rank))
+ if(IsGuestKey(ckey))
+ return "Guest Job-ban"
+
+ if(GLOB.jobban_assoclist[ckey])
+ return GLOB.jobban_assoclist[ckey][rank]
+
+ return null
+
/proc/jobban_loadbanfile()
if(config.ban_legacy_system)
var/savefile/S=new("data/job_full.ban")
diff --git a/code/modules/admin/cookielog.dm b/code/modules/admin/cookielog.dm
new file mode 100644
index 00000000000..a2de0c126fe
--- /dev/null
+++ b/code/modules/admin/cookielog.dm
@@ -0,0 +1,113 @@
+//////////////////////////////////////////////////////////////////////////////////////
+// This file houses all the code for cookie datum serialization and deserialization
+//
+// If you are going to modify ANYTHING in here, please test it THOROUGHLY
+// The serialization and deserialization here is so complicated that you WILL break something here
+// PLEASE test things properly if you modify this file. -aa07
+//
+//////////////////////////////////////////////////////////////////////////////////////
+
+// Everything in this file is intentionally NOT autodocumented. PLEASE keep it that way.
+// All these defines are integral to the workings and mesh together with the database.
+// DO NOT EDIT THESE UNDER ANY CIRCUMSTANCES EVER
+#define COOKIERECORD_FIRST_INFRACTION "First cookie match: "
+#define COOKIERECORD_LAST_INFRACTION "Last cookie match: "
+#define COOKIERECORD_TOTAL_INFRACTIONS "Total cookie matches: "
+#define COOKIERECORD_MATCHED_CKEYS "Matched ckeys: "
+#define COOKIERECORD_MATCHED_IPS "Matched IPs: "
+#define COOKIERECORD_MATCHED_CIDS "Matched CIDS: "
+#define COOKIERECORD_PSUEDO_CKEY "ALICE-COOKIE_RECORD"
+
+/datum/cookie_record
+ var/cookie_holder_ckey
+ var/first_infraction_date
+ var/last_infraction_date
+ var/infraction_count
+ var/list/matched_ckeys = list()
+ var/list/matched_ips = list()
+ var/list/matched_cids = list()
+
+// Some of these params can be null, others CAN NOT
+/datum/cookie_record/New(holder_ckey, matched_ckey, matched_ip, matched_cid)
+ // Right off the bat
+ cookie_holder_ckey = holder_ckey
+
+ var/has_note = FALSE
+ var/raw_text = ""
+ // Now lets see if we have a note logging the infraction in the past
+ var/datum/db_query/check_existing_note = SSdbcore.NewQuery("SELECT notetext FROM [format_table_name("notes")] WHERE ckey=:ckey AND adminckey=:ackey", list(
+ "ckey" = cookie_holder_ckey,
+ "ackey" = COOKIERECORD_PSUEDO_CKEY
+ ))
+ if(!check_existing_note.warn_execute())
+ qdel(check_existing_note)
+ return
+ if(check_existing_note.NextRow())
+ has_note = TRUE
+ raw_text = check_existing_note.item[1]
+ qdel(check_existing_note)
+
+ if(has_note)
+ deserialize_and_load(raw_text)
+ infraction_count++
+ else
+ // Sane defaults
+ first_infraction_date = SQLtime()
+ infraction_count = 1
+
+ last_infraction_date = SQLtime()
+ matched_ckeys |= matched_ckey
+ matched_ips |= matched_ip
+ matched_cids |= matched_cid
+
+ serialize_and_save(has_note)
+
+/*
+ Expected output below. These are parsed from raw_text by splitting by
+ [1] COOKIERECORD_FIRST_INFRACTION
+ [2] COOKIERECORD_LAST_INFRACTION
+ [3] COOKIERECORD_TOTAL_INFRACTIONS
+ [4] COOKIERECORD_MATCHED_CKEYS
+ [5] COOKIERECORD_MATCHED_IPS
+ [6] COOKIERECORD_MATCHED_CIDS
+*/
+
+/datum/cookie_record/proc/deserialize_and_load(raw_text)
+ var/list/lines = splittext(raw_text, "
")
+ // Text
+ first_infraction_date = splittext(lines[1], COOKIERECORD_FIRST_INFRACTION)[2]
+ last_infraction_date = splittext(lines[2], COOKIERECORD_LAST_INFRACTION)[2]
+ // Number
+ infraction_count = text2num(splittext(lines[3], COOKIERECORD_TOTAL_INFRACTIONS)[2]) // Make sure its a number
+ // Lists
+ matched_ckeys = splittext(splittext(lines[4], COOKIERECORD_MATCHED_CKEYS)[2], ",")
+ matched_ips = splittext(splittext(lines[5], COOKIERECORD_MATCHED_IPS)[2], ",")
+ matched_cids = splittext(splittext(lines[6], COOKIERECORD_MATCHED_CIDS)[2], ",")
+
+/datum/cookie_record/proc/serialize_and_save(has_note)
+ var/serialized_text
+ var/list/serialized_list = list()
+ serialized_list.len = 6 // Make it 6 off the bat
+
+ serialized_list[1] = "[COOKIERECORD_FIRST_INFRACTION][first_infraction_date]"
+ serialized_list[2] = "[COOKIERECORD_LAST_INFRACTION][last_infraction_date]"
+ serialized_list[3] = "[COOKIERECORD_TOTAL_INFRACTIONS][infraction_count]"
+ serialized_list[4] = "[COOKIERECORD_MATCHED_CKEYS][matched_ckeys.Join(",")]"
+ serialized_list[5] = "[COOKIERECORD_MATCHED_IPS][matched_ips.Join(",")]"
+ serialized_list[6] = "[COOKIERECORD_MATCHED_CIDS][matched_cids.Join(",")]"
+
+ serialized_text = serialized_list.Join("
")
+
+ if(has_note) // They have a note. Update.
+ var/datum/db_query/update_existing_note = SSdbcore.NewQuery("UPDATE [format_table_name("notes")] SET notetext=:nt, timestamp=NOW(), round_id=:rid WHERE ckey=:ckey AND adminckey=:ackey", list(
+ "nt" = serialized_text,
+ "rid" = GLOB.round_id,
+ "ckey" = cookie_holder_ckey,
+ "ackey" = COOKIERECORD_PSUEDO_CKEY
+ ))
+ if(!update_existing_note.warn_execute())
+ qdel(update_existing_note)
+ return
+ qdel(update_existing_note)
+ else // They dont have a note. Insert.
+ add_note(cookie_holder_ckey, serialized_text, adminckey = COOKIERECORD_PSUEDO_CKEY, logged = FALSE, checkrights = FALSE, automated = TRUE)
diff --git a/code/modules/admin/db_ban/functions.dm b/code/modules/admin/db_ban/functions.dm
index 126e584e864..105c6bd6778 100644
--- a/code/modules/admin/db_ban/functions.dm
+++ b/code/modules/admin/db_ban/functions.dm
@@ -146,8 +146,8 @@
qdel(adm_query)
var/datum/db_query/query_insert = SSdbcore.NewQuery({"
- INSERT INTO [format_table_name("ban")] (`id`,`bantime`,`serverip`,`bantype`,`reason`,`job`,`duration`,`rounds`,`expiration_time`,`ckey`,`computerid`,`ip`,`a_ckey`,`a_computerid`,`a_ip`,`who`,`adminwho`,`edits`,`unbanned`,`unbanned_datetime`,`unbanned_ckey`,`unbanned_computerid`,`unbanned_ip`)
- VALUES (null, Now(), :serverip, :bantype_str, :reason, :job, :duration, :rounds, Now() + INTERVAL :duration MINUTE, :ckey, :computerid, :ip, :a_ckey, :a_computerid, :a_ip, :who, :adminwho, '', null, null, null, null, null)
+ INSERT INTO [format_table_name("ban")] (`id`,`bantime`,`serverip`,`bantype`,`reason`,`job`,`duration`,`rounds`,`expiration_time`,`ckey`,`computerid`,`ip`,`a_ckey`,`a_computerid`,`a_ip`,`who`,`adminwho`,`edits`,`unbanned`,`unbanned_datetime`,`unbanned_ckey`,`unbanned_computerid`,`unbanned_ip`,`ban_round_id`,`unbanned_round_id`)
+ VALUES (null, Now(), :serverip, :bantype_str, :reason, :job, :duration, :rounds, Now() + INTERVAL :duration MINUTE, :ckey, :computerid, :ip, :a_ckey, :a_computerid, :a_ip, :who, :adminwho, '', null, null, null, null, null, :roundid, null)
"}, list(
// Get ready for parameters
"serverip" = serverip,
@@ -163,7 +163,8 @@
"a_computerid" = a_computerid,
"a_ip" = a_ip,
"who" = who,
- "adminwho" = adminwho
+ "adminwho" = adminwho,
+ "roundid" = GLOB.round_id
))
if(!query_insert.warn_execute())
qdel(query_insert)
@@ -399,10 +400,11 @@
var/unban_computerid = src.owner:computer_id
var/unban_ip = src.owner:address
- var/datum/db_query/query_update = SSdbcore.NewQuery("UPDATE [format_table_name("ban")] SET unbanned = 1, unbanned_datetime = Now(), unbanned_ckey=:unban_ckey, unbanned_computerid=:unban_computerid, unbanned_ip=:unban_ip WHERE id=:id", list(
+ var/datum/db_query/query_update = SSdbcore.NewQuery("UPDATE [format_table_name("ban")] SET unbanned = 1, unbanned_datetime = Now(), unbanned_ckey=:unban_ckey, unbanned_computerid=:unban_computerid, unbanned_ip=:unban_ip, unbanned_round_id=:roundid WHERE id=:id", list(
"unban_ckey" = unban_ckey,
"unban_computerid" = unban_computerid,
"unban_ip" = unban_ip,
+ "roundid" = GLOB.round_id,
"id" = id
))
if(!query_update.warn_execute())
@@ -477,6 +479,7 @@
output += ""
output += ""
output += "Reason:
"
+ output += " Auto populate CID & IP for online players
"
output += ""
output += ""
@@ -582,7 +585,7 @@
var/datum/db_query/select_query = SSdbcore.NewQuery({"
- SELECT id, bantime, bantype, reason, job, duration, expiration_time, ckey, a_ckey, unbanned, unbanned_ckey, unbanned_datetime, edits, ip, computerid
+ SELECT id, bantime, bantype, reason, job, duration, expiration_time, ckey, a_ckey, unbanned, unbanned_ckey, unbanned_datetime, edits, ip, computerid, ban_round_id, unbanned_round_id
FROM [format_table_name("ban")] WHERE 1 [playersearch] [adminsearch] [ipsearch] [cidsearch] [bantypesearch] ORDER BY bantime DESC LIMIT 100"}, sql_params)
if(!select_query.warn_execute())
@@ -605,6 +608,8 @@
var/edits = select_query.item[13]
var/ip = select_query.item[14]
var/cid = select_query.item[15]
+ var/ban_round_id = select_query.item[16]
+ var/unban_round_id = select_query.item[17]
var/lcolor = blcolor
var/dcolor = bdcolor
@@ -632,7 +637,7 @@
output += "