diff --git a/SQL/admin_import_2018-02-03.py b/SQL/admin_import_2018-02-03.py
index 6bd8892b5e27..b9ce28cef171 100644
--- a/SQL/admin_import_2018-02-03.py
+++ b/SQL/admin_import_2018-02-03.py
@@ -93,7 +93,7 @@ with open("..\\config\\admins.txt") as admins_file:
matches = re.match("(.+)\\b\\s+=\\s+(.+)", line)
ckey = "".join((c for c in matches.group(1) if c not in ckeyformat)).lower()
rank = "".join((c for c in matches.group(2) if c not in ckeyExformat))
- cursor.execute("INSERT INTO {0} (ckey, rank) VALUES ('{1}', '{2}')".format(admin_table, ckey, rank))
+ cursor.execute("INSERT INTO {0} (ckey, rank) VALUES ('{1}', '{2}')".format(admin_table, ckey, rank))
db.commit()
cursor.close()
print("Import complete.")
diff --git a/SQL/database_changelog.txt b/SQL/database_changelog.txt
index d3339df1fb84..fc93bb8fec33 100644
--- a/SQL/database_changelog.txt
+++ b/SQL/database_changelog.txt
@@ -1,15 +1,23 @@
Any time you make a change to the schema files, remember to increment the database schema version. Generally increment the minor number, major should be reserved for significant changes to the schema. Both values go up to 255.
-The latest database version is 4.4; The query to update the schema revision table is:
+The latest database version is 4.5; The query to update the schema revision table is:
-INSERT INTO `schema_revision` (`major`, `minor`) VALUES (4, 4);
+INSERT INTO `schema_revision` (`major`, `minor`) VALUES (4, 5);
or
-INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (4, 4);
+INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (4, 5);
In any query remember to add a prefix to the table names if you use one.
----------------------------------------------------
+Version 4.5, 9 July 2018, by Jordie0608
+Modified table `player`, adding column `byond_key` to store a user's key along with their ckey.
+To populate this new column run the included script 'populate_key_2018-07', see the file for use instructions.
+
+ALTER TABLE `player` ADD `byond_key` VARCHAR(32) DEFAULT NULL AFTER `ckey`;
+
+----------------------------------------------------
+
Version 4.4, 9 May 2018, by Jordie0608
Modified table `round`, renaming column `start_datetime` to `initialize_datetime` and `end_datetime` to `shutdown_datetime` and adding columns to replace both under the same name in preparation for changes to TGS server initialization.
diff --git a/SQL/populate_key_2018-07-09.py b/SQL/populate_key_2018-07-09.py
new file mode 100644
index 000000000000..82e7a3f4af0c
--- /dev/null
+++ b/SQL/populate_key_2018-07-09.py
@@ -0,0 +1,92 @@
+#Python 3+ Script for populating the key of all ckeys in player table made by Jordie0608
+#
+#Before starting ensure you have installed the mysqlclient package https://github.com/PyMySQL/mysqlclient-python
+#It can be downloaded from command line with pip:
+#pip install mysqlclient
+#And that you have run the most recent commands listed in database_changelog.txt
+#
+#To view the parameters for this script, execute it with the argument --help
+#All the positional arguments are required, remember to include a prefixe in your table name if you use one
+#--useckey and --onlynull are optional arguments, see --help for their function
+#An example of the command used to execute this script from powershell:
+#python populate_key_2018-07-09.py "localhost" "root" "password" "feedback" "SS13_player" --onlynull --useckey
+#
+#This script requires an internet connection to function
+#Sometimes byond.com fails to return the page for a valid ckey, this can be a temporary problem and may be resolved by rerunning the script
+#You can have the script use the existing ckey instead if the key is unable to be parsed with the --useckey optional argument
+#To make the script only iterate on rows that failed to parse a ckey and have a null byond_key column, use the --onlynull optional argument
+#To make the script only iterate on rows that have a matching ckey and byond_key column, use the --onlyckeymatch optional argument
+#The --onlynull and --onlyckeymatch arguments are mutually exclusive, the script can't be run with both of them enabled
+#
+#It's safe to run this script with your game server(s) active.
+
+import MySQLdb
+import argparse
+import re
+import sys
+from urllib.request import urlopen
+from datetime import datetime
+
+if sys.version_info[0] < 3:
+ raise Exception("Python must be at least version 3 for this script.")
+query_values = ""
+current_round = 0
+parser = argparse.ArgumentParser()
+parser.add_argument("address", help="MySQL server address (use localhost for the current computer)")
+parser.add_argument("username", help="MySQL login username")
+parser.add_argument("password", help="MySQL login password")
+parser.add_argument("database", help="Database name")
+parser.add_argument("playertable", help="Name of the player table (remember a prefix if you use one)")
+parser.add_argument("--useckey", help="Use the player's ckey for their key if unable to contact or parse their member page", action="store_true")
+group = parser.add_mutually_exclusive_group()
+group.add_argument("--onlynull", help="Only try to update rows if their byond_key column is null, mutually exclusive with --onlyckeymatch", action="store_true")
+group.add_argument("--onlyckeymatch", help="Only try to update rows that have matching ckey and byond_key columns from the --useckey argument, mutually exclusive with --onlynull", action="store_true")
+args = parser.parse_args()
+where = ""
+if args.onlynull:
+ where = " WHERE byond_key IS NULL"
+if args.onlyckeymatch:
+ where = " WHERE byond_key = ckey"
+db=MySQLdb.connect(host=args.address, user=args.username, passwd=args.password, db=args.database)
+cursor=db.cursor()
+player_table = args.playertable
+cursor.execute("SELECT ckey FROM {0}{1}".format(player_table, where))
+ckey_list = cursor.fetchall()
+failed_ckeys = []
+start_time = datetime.now()
+success = 0
+fail = 0
+print("Beginning script at {0}".format(start_time.strftime("%Y-%m-%d %H:%M:%S")))
+if not ckey_list:
+ print("Query returned no rows")
+for current_ckey in ckey_list:
+ link = urlopen("https://secure.byond.com/members/{0}/?format=text".format(current_ckey[0]))
+ data = link.read()
+ data = data.decode("ISO-8859-1")
+ match = re.search("\tkey = \"(.+)\"", data)
+ if match:
+ key = match.group(1)
+ success += 1
+ else:
+ fail += 1
+ failed_ckeys.append(current_ckey[0])
+ msg = "Failed to parse a key for {0}".format(current_ckey[0])
+ if args.useckey:
+ msg += ", using their ckey instead"
+ print(msg)
+ key = current_ckey[0]
+ else:
+ print(msg)
+ continue
+ cursor.execute("UPDATE {0} SET byond_key = \'{1}\' WHERE ckey = \'{2}\'".format(player_table, key, current_ckey[0]))
+ db.commit()
+end_time = datetime.now()
+print("Script completed at {0} with duration {1}".format(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), end_time - start_time))
+if failed_ckeys:
+ if args.useckey:
+ print("The following ckeys failed to parse a key so their ckey was used instead:")
+ else:
+ print("The following ckeys failed to parse a key and were skipped:")
+ print("\n".join(failed_ckeys))
+ print("Keys successfully parsed: {0} Keys failed parsing: {1}".format(success, fail))
+cursor.close()
diff --git a/SQL/tgstation_schema.sql b/SQL/tgstation_schema.sql
index dad9f1e766a9..480ad58ff4ee 100644
--- a/SQL/tgstation_schema.sql
+++ b/SQL/tgstation_schema.sql
@@ -309,6 +309,7 @@ DROP TABLE IF EXISTS `player`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `player` (
`ckey` varchar(32) NOT NULL,
+ `byond_key` varchar(32) DEFAULT NULL,
`firstseen` datetime NOT NULL,
`firstseen_round_id` int(11) unsigned NOT NULL,
`lastseen` datetime NOT NULL,
diff --git a/SQL/tgstation_schema_prefixed.sql b/SQL/tgstation_schema_prefixed.sql
index 8c9b15e8941f..2842ee912248 100644
--- a/SQL/tgstation_schema_prefixed.sql
+++ b/SQL/tgstation_schema_prefixed.sql
@@ -309,6 +309,7 @@ DROP TABLE IF EXISTS `SS13_player`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `SS13_player` (
`ckey` varchar(32) NOT NULL,
+ `byond_key` varchar(32) DEFAULT NULL,
`firstseen` datetime NOT NULL,
`firstseen_round_id` int(11) unsigned NOT NULL,
`lastseen` datetime NOT NULL,
diff --git a/code/__DEFINES/subsystems.dm b/code/__DEFINES/subsystems.dm
index c2ffd3319698..0317b5ba7f15 100644
--- a/code/__DEFINES/subsystems.dm
+++ b/code/__DEFINES/subsystems.dm
@@ -1,7 +1,7 @@
//Update this whenever the db schema changes
//make sure you add an update to the schema_version stable in the db changelog
#define DB_MAJOR_VERSION 4
-#define DB_MINOR_VERSION 4
+#define DB_MINOR_VERSION 5
//Timing subsystem
//Don't run if there is an identical unique timer active
diff --git a/code/__HELPERS/mobs.dm b/code/__HELPERS/mobs.dm
index 24b6233c598c..30fcf6b151e5 100644
--- a/code/__HELPERS/mobs.dm
+++ b/code/__HELPERS/mobs.dm
@@ -192,15 +192,15 @@ Proc for attack log creation, because really why not
var/starget = "NON-EXISTENT SUBJECT"
if(target)
- if(is_mob_target && target.ckey)
- starget = "[target.name]([target.ckey])"
+ if(is_mob_target && target.key)
+ starget = "[target.name]([target.key])"
else
starget = "[target.name]"
var/ssource = "NON-EXISTENT USER" //How!?
if(user)
- if(is_mob_user && user.ckey)
- ssource = "[user.name]([user.ckey])"
+ if(is_mob_user && user.key)
+ ssource = "[user.name]([user.key])"
else
ssource = "[user.name]"
diff --git a/code/controllers/subsystem/medals.dm b/code/controllers/subsystem/medals.dm
index 21366978f662..6dafb2c3cb9a 100644
--- a/code/controllers/subsystem/medals.dm
+++ b/code/controllers/subsystem/medals.dm
@@ -14,8 +14,8 @@ SUBSYSTEM_DEF(medals)
return
if(isnull(world.SetMedal(medal, player, CONFIG_GET(string/medal_hub_address), CONFIG_GET(string/medal_hub_password))))
hub_enabled = FALSE
- log_game("MEDAL ERROR: Could not contact hub to award medal:[medal] player:[player.ckey]")
- message_admins("Error! Failed to contact hub to award [medal] medal to [player.ckey]!")
+ log_game("MEDAL ERROR: Could not contact hub to award medal:[medal] player:[player.key]")
+ message_admins("Error! Failed to contact hub to award [medal] medal to [player.key]!")
return
to_chat(player, "Achievement unlocked: [medal]!")
@@ -38,8 +38,8 @@ SUBSYSTEM_DEF(medals)
if(isnull(world.SetScores(player.ckey, newscoreparam, CONFIG_GET(string/medal_hub_address), CONFIG_GET(string/medal_hub_password))))
hub_enabled = FALSE
- log_game("SCORE ERROR: Could not contact hub to set score. Score:[score] player:[player.ckey]")
- message_admins("Error! Failed to contact hub to set [score] score for [player.ckey]!")
+ log_game("SCORE ERROR: Could not contact hub to set score. Score:[score] player:[player.key]")
+ message_admins("Error! Failed to contact hub to set [score] score for [player.key]!")
/datum/controller/subsystem/medals/proc/GetScore(score, client/player, returnlist)
if(!score || !hub_enabled)
@@ -48,8 +48,8 @@ SUBSYSTEM_DEF(medals)
var/scoreget = world.GetScores(player.ckey, score, CONFIG_GET(string/medal_hub_address), CONFIG_GET(string/medal_hub_password))
if(isnull(scoreget))
hub_enabled = FALSE
- log_game("SCORE ERROR: Could not contact hub to get score. Score:[score] player:[player.ckey]")
- message_admins("Error! Failed to contact hub to get score: [score] for [player.ckey]!")
+ log_game("SCORE ERROR: Could not contact hub to get score. Score:[score] player:[player.key]")
+ message_admins("Error! Failed to contact hub to get score: [score] for [player.key]!")
return
. = params2list(scoreget)
if(!returnlist)
@@ -61,8 +61,8 @@ SUBSYSTEM_DEF(medals)
if(isnull(world.GetMedal(medal, player, CONFIG_GET(string/medal_hub_address), CONFIG_GET(string/medal_hub_password))))
hub_enabled = FALSE
- log_game("MEDAL ERROR: Could not contact hub to get medal:[medal] player: [player.ckey]")
- message_admins("Error! Failed to contact hub to get [medal] medal for [player.ckey]!")
+ log_game("MEDAL ERROR: Could not contact hub to get medal:[medal] player: [player.key]")
+ message_admins("Error! Failed to contact hub to get [medal] medal for [player.key]!")
return
to_chat(player, "[medal] is unlocked")
@@ -73,15 +73,15 @@ SUBSYSTEM_DEF(medals)
switch(result)
if(null)
hub_enabled = FALSE
- log_game("MEDAL ERROR: Could not contact hub to clear medal:[medal] player:[player.ckey]")
- message_admins("Error! Failed to contact hub to clear [medal] medal for [player.ckey]!")
+ log_game("MEDAL ERROR: Could not contact hub to clear medal:[medal] player:[player.key]")
+ message_admins("Error! Failed to contact hub to clear [medal] medal for [player.key]!")
if(TRUE)
- message_admins("Medal: [medal] removed for [player.ckey]")
+ message_admins("Medal: [medal] removed for [player.key]")
if(FALSE)
- message_admins("Medal: [medal] was not found for [player.ckey]. Unable to clear.")
+ message_admins("Medal: [medal] was not found for [player.key]. Unable to clear.")
/datum/controller/subsystem/medals/proc/ClearScore(client/player)
if(isnull(world.SetScores(player.ckey, "", CONFIG_GET(string/medal_hub_address), CONFIG_GET(string/medal_hub_password))))
- log_game("MEDAL ERROR: Could not contact hub to clear scores for [player.ckey]!")
- message_admins("Error! Failed to contact hub to clear scores for [player.ckey]!")
\ No newline at end of file
+ log_game("MEDAL ERROR: Could not contact hub to clear scores for [player.key]!")
+ message_admins("Error! Failed to contact hub to clear scores for [player.key]!")
diff --git a/code/datums/brain_damage/split_personality.dm b/code/datums/brain_damage/split_personality.dm
index 337926ce6b3e..ba39845d61a8 100644
--- a/code/datums/brain_damage/split_personality.dm
+++ b/code/datums/brain_damage/split_personality.dm
@@ -61,7 +61,7 @@
current_backseat = owner_backseat
free_backseat = stranger_backseat
- log_game("[key_name(current_backseat)] assumed control of [key_name(owner)] due to [src]. (Original owner: [current_controller == OWNER ? owner.ckey : current_backseat.ckey])")
+ log_game("[key_name(current_backseat)] assumed control of [key_name(owner)] due to [src]. (Original owner: [current_controller == OWNER ? owner.key : current_backseat.key])")
to_chat(owner, "You feel your control being taken away... your other personality is in charge now!")
to_chat(current_backseat, "You manage to take control of your body!")
diff --git a/code/datums/wires/airlock.dm b/code/datums/wires/airlock.dm
index c08239af30a8..e6f79c67b0ac 100644
--- a/code/datums/wires/airlock.dm
+++ b/code/datums/wires/airlock.dm
@@ -79,7 +79,7 @@
if(!A.secondsElectrified)
A.set_electrified(30)
if(usr)
- LAZYADD(A.shockedby, text("\[[time_stamp()]\][usr](ckey:[usr.ckey])"))
+ LAZYADD(A.shockedby, text("\[[time_stamp()]\] [key_name(usr)]"))
add_logs(usr, A, "electrified")
if(WIRE_SAFETY)
A.safe = !A.safe
@@ -134,7 +134,7 @@
if(A.secondsElectrified != -1)
A.set_electrified(-1)
if(usr)
- LAZYADD(A.shockedby, text("\[[time_stamp()]\][usr](ckey:[usr.ckey])"))
+ LAZYADD(A.shockedby, text("\[[time_stamp()]\] [key_name(usr)]"))
add_logs(usr, A, "electrified")
if(WIRE_SAFETY) // Cut to disable safeties, mend to re-enable.
A.safe = mend
diff --git a/code/game/gamemodes/game_mode.dm b/code/game/gamemodes/game_mode.dm
index 1a1c882bedbd..3417363733a0 100644
--- a/code/game/gamemodes/game_mode.dm
+++ b/code/game/gamemodes/game_mode.dm
@@ -445,23 +445,23 @@
continue // never had a client
if(L.ckey && !GLOB.directory[L.ckey])
- msg += "[L.name] ([L.ckey]), the [L.job] (Disconnected)\n"
+ msg += "[L.name] ([L.key]), the [L.job] (Disconnected)\n"
if(L.ckey && L.client)
var/failed = FALSE
if(L.client.inactivity >= (ROUNDSTART_LOGOUT_REPORT_TIME / 2)) //Connected, but inactive (alt+tabbed or something)
- msg += "[L.name] ([L.ckey]), the [L.job] (Connected, Inactive)\n"
+ msg += "[L.name] ([L.key]), the [L.job] (Connected, Inactive)\n"
failed = TRUE //AFK client
if(!failed && L.stat)
if(L.suiciding) //Suicider
- msg += "[L.name] ([L.ckey]), the [L.job] (Suicide)\n"
+ msg += "[L.name] ([L.key]), the [L.job] (Suicide)\n"
failed = TRUE //Disconnected client
if(!failed && L.stat == UNCONSCIOUS)
- msg += "[L.name] ([L.ckey]), the [L.job] (Dying)\n"
+ msg += "[L.name] ([L.key]), the [L.job] (Dying)\n"
failed = TRUE //Unconscious
if(!failed && L.stat == DEAD)
- msg += "[L.name] ([L.ckey]), the [L.job] (Dead)\n"
+ msg += "[L.name] ([L.key]), the [L.job] (Dead)\n"
failed = TRUE //Dead
var/p_ckey = L.client.ckey
diff --git a/code/game/machinery/computer/prisoner.dm b/code/game/machinery/computer/prisoner.dm
index 166da2843544..1c1944e73ee9 100644
--- a/code/game/machinery/computer/prisoner.dm
+++ b/code/game/machinery/computer/prisoner.dm
@@ -136,7 +136,7 @@
if(I && istype(I) && I.imp_in)
var/mob/living/R = I.imp_in
to_chat(R, "You hear a voice in your head saying: '[warning]'")
- log_talk(usr,"[key_name(usr)] sent an implant message to [R]/[R.ckey]: '[warning]'",LOGSAY)
+ log_talk(usr,"[key_name(usr)] sent an implant message to [key_name(R)]: '[warning]'",LOGSAY)
src.add_fingerprint(usr)
src.updateUsrDialog()
diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm
index 21355ff0fa2d..ba9176711c79 100644
--- a/code/game/machinery/doors/airlock.dm
+++ b/code/game/machinery/doors/airlock.dm
@@ -1280,7 +1280,7 @@
bolt() //Bolt it!
set_electrified(ELECTRIFIED_PERMANENT) //Shock it!
if(origin)
- LAZYADD(shockedby, "\[[time_stamp()]\][origin](ckey:[origin.ckey])")
+ LAZYADD(shockedby, "\[[time_stamp()]\] [key_name(origin)]")
/obj/machinery/door/airlock/disable_lockdown()
@@ -1550,7 +1550,7 @@
if(wires.is_cut(WIRE_SHOCK))
to_chat(user, "The electrification wire has been cut")
else
- LAZYADD(shockedby, "\[[time_stamp()]\][user](ckey:[user.ckey])")
+ LAZYADD(shockedby, "\[[time_stamp()]\] [key_name(user)]")
add_logs(user, src, "electrified")
set_electrified(AI_ELECTRIFY_DOOR_TIME)
@@ -1560,7 +1560,7 @@
if(wires.is_cut(WIRE_SHOCK))
to_chat(user, "The electrification wire has been cut")
else
- LAZYADD(shockedby, text("\[[time_stamp()]\][user](ckey:[user.ckey])"))
+ LAZYADD(shockedby, text("\[[time_stamp()]\] [key_name(user)]"))
add_logs(user, src, "electrified")
set_electrified(ELECTRIFIED_PERMANENT)
to_chat(user, "Door electrified") //yogs
diff --git a/code/game/objects/structures/morgue.dm b/code/game/objects/structures/morgue.dm
index a247f4c125c7..111ce3ccca30 100644
--- a/code/game/objects/structures/morgue.dm
+++ b/code/game/objects/structures/morgue.dm
@@ -256,10 +256,10 @@ GLOBAL_LIST_EMPTY(crematoriums)
if (M.stat != DEAD)
M.emote("scream")
if(user)
- user.log_message("Cremated [M]/[M.ckey]", INDIVIDUAL_ATTACK_LOG)
- log_attack("[user]/[user.ckey] cremated [M]/[M.ckey]")
+ user.log_message("Cremated [key_name(M)]", INDIVIDUAL_ATTACK_LOG)
+ log_attack("[key_name(user)] cremated [key_name(M)]")
else
- log_attack("UNKNOWN cremated [M]/[M.ckey]")
+ log_attack("UNKNOWN cremated [key_name(M)]")
M.death(1)
if(M) //some animals get automatically deleted on death.
M.ghostize()
diff --git a/code/modules/admin/DB_ban/functions.dm b/code/modules/admin/DB_ban/functions.dm
index e719955cea24..a33f1827c033 100644
--- a/code/modules/admin/DB_ban/functions.dm
+++ b/code/modules/admin/DB_ban/functions.dm
@@ -2,7 +2,7 @@
#define MAX_ADMIN_BANS_PER_HEADMIN 3
//Either pass the mob you wish to ban in the 'banned_mob' attribute, or the banckey, banip and bancid variables. If both are passed, the mob takes priority! If a mob is not passed, banckey is the minimum that needs to be passed! banip and bancid are optional.
-/datum/admins/proc/DB_ban_record(bantype, mob/banned_mob, duration = -1, reason, job = "", banckey = null, banip = null, bancid = null)
+/datum/admins/proc/DB_ban_record(bantype, mob/banned_mob, duration = -1, reason, job = "", bankey = null, banip = null, bancid = null)
if(!check_rights(R_BAN))
return
@@ -64,23 +64,24 @@
if(ismob(banned_mob))
ckey = banned_mob.ckey
+ bankey = banned_mob.key
if(banned_mob.client)
computerid = banned_mob.client.computer_id
ip = banned_mob.client.address
else
computerid = banned_mob.computer_id
ip = banned_mob.lastKnownIP
- else if(banckey)
- ckey = ckey(banckey)
+ else if(bankey)
+ ckey = ckey(bankey)
computerid = bancid
ip = banip
-
+
var/had_banned_mob = banned_mob != null
var/client/banned_client = banned_mob?.client
var/banned_mob_guest_key = had_banned_mob && IsGuestKey(banned_mob.key)
banned_mob = null
- var/datum/DBQuery/query_add_ban_get_ckey = SSdbcore.NewQuery("SELECT ckey FROM [format_table_name("player")] WHERE ckey = '[ckey]'")
+ var/datum/DBQuery/query_add_ban_get_ckey = SSdbcore.NewQuery("SELECT 1 FROM [format_table_name("player")] WHERE ckey = '[ckey]'")
if(!query_add_ban_get_ckey.warn_execute())
qdel(query_add_ban_get_ckey)
return
@@ -88,14 +89,16 @@
qdel(query_add_ban_get_ckey)
if(!seen_before)
if(!had_banned_mob || (had_banned_mob && !banned_mob_guest_key))
- if(alert(usr, "[ckey] has not been seen before, are you sure you want to create a ban for them?", "Unknown ckey", "Yes", "No", "Cancel") != "Yes")
+ if(alert(usr, "[bankey] has not been seen before, are you sure you want to create a ban for them?", "Unknown ckey", "Yes", "No", "Cancel") != "Yes")
return
+ var/a_key
var/a_ckey
var/a_computerid
var/a_ip
if(istype(owner))
+ a_key = owner.key
a_ckey = owner.ckey
a_computerid = owner.computer_id
a_ip = owner.address
@@ -147,17 +150,21 @@
return
qdel(query_add_ban)
to_chat(usr, "Ban saved to database.")
+<<<<<<< HEAD
var/msg = "[key_name(usr)] has added a [bantype_str] for [ckey] [(job)?"([job])":""] [(duration > 0)?"([duration] minutes)":""] with the reason: \"[reason]\" to the ban database." // yogs - Yog Tickets
+=======
+ var/msg = "[key_name_admin(usr)] has added a [bantype_str] for [bankey] [(job)?"([job])":""] [(duration > 0)?"([duration] minutes)":""] with the reason: \"[reason]\" to the ban database."
+>>>>>>> 0d7ef3ed65... Key instead of ckey for user facing logs and ui (#39009)
message_admins(msg,1)
var/datum/admin_help/AH = admin_ticket_log(ckey, msg)
if(announceinirc)
- send2irc("BAN ALERT","[a_ckey] applied a [bantype_str] on [ckey]")
+ send2irc("BAN ALERT","[a_key] applied a [bantype_str] on [bankey]")
if(kickbannedckey)
if(AH)
AH.Resolve() //with prejudice
- if(banned_client && banned_client.ckey == banckey)
+ if(banned_client && banned_client.ckey == ckey)
qdel(banned_client)
return 1
@@ -249,18 +256,18 @@
to_chat(usr, "Cancelled")
return
- var/datum/DBQuery/query_edit_ban_get_details = SSdbcore.NewQuery("SELECT ckey, duration, reason FROM [format_table_name("ban")] WHERE id = [banid]")
+ var/datum/DBQuery/query_edit_ban_get_details = SSdbcore.NewQuery("SELECT (SELECT byond_key FROM [format_table_name("player")] WHERE [format_table_name("player")].ckey = [format_table_name("ban")].ckey), duration, reason FROM [format_table_name("ban")] WHERE id = [banid]")
if(!query_edit_ban_get_details.warn_execute())
qdel(query_edit_ban_get_details)
return
- var/eckey = usr.ckey //Editing admin ckey
- var/pckey //(banned) Player ckey
+ var/e_key = usr.key //Editing admin key
+ var/p_key //(banned) Player key
var/duration //Old duration
var/reason //Old reason
if(query_edit_ban_get_details.NextRow())
- pckey = query_edit_ban_get_details.item[1]
+ p_key = query_edit_ban_get_details.item[1]
duration = query_edit_ban_get_details.item[2]
reason = query_edit_ban_get_details.item[3]
else
@@ -275,33 +282,33 @@
switch(param)
if("reason")
if(!value)
- value = input("Insert the new reason for [pckey]'s ban", "New Reason", "[reason]", null) as null|text
+ value = input("Insert the new reason for [p_key]'s ban", "New Reason", "[reason]", null) as null|text
value = sanitizeSQL(value)
if(!value)
to_chat(usr, "Cancelled")
return
- var/datum/DBQuery/query_edit_ban_reason = SSdbcore.NewQuery("UPDATE [format_table_name("ban")] SET reason = '[value]', edits = CONCAT(edits,'- [eckey] changed ban reason from \\\"[reason]\\\" to \\\"[value]\\\" ') WHERE id = [banid]")
+ var/datum/DBQuery/query_edit_ban_reason = SSdbcore.NewQuery("UPDATE [format_table_name("ban")] SET reason = '[value]', edits = CONCAT(edits,'- [e_key] changed ban reason from \\\"[reason]\\\" to \\\"[value]\\\" ') WHERE id = [banid]")
if(!query_edit_ban_reason.warn_execute())
qdel(query_edit_ban_reason)
return
qdel(query_edit_ban_reason)
- message_admins("[key_name_admin(usr)] has edited a ban for [pckey]'s reason from [reason] to [value]")
+ message_admins("[key_name_admin(usr)] has edited a ban for [p_key]'s reason from [reason] to [value]")
if("duration")
if(!value)
- value = input("Insert the new duration (in minutes) for [pckey]'s ban", "New Duration", "[duration]", null) as null|num
+ value = input("Insert the new duration (in minutes) for [p_key]'s ban", "New Duration", "[duration]", null) as null|num
if(!isnum(value) || !value)
to_chat(usr, "Cancelled")
return
- var/datum/DBQuery/query_edit_ban_duration = SSdbcore.NewQuery("UPDATE [format_table_name("ban")] SET duration = [value], edits = CONCAT(edits,'- [eckey] changed ban duration from [duration] to [value] '), expiration_time = DATE_ADD(bantime, INTERVAL [value] MINUTE) WHERE id = [banid]")
+ var/datum/DBQuery/query_edit_ban_duration = SSdbcore.NewQuery("UPDATE [format_table_name("ban")] SET duration = [value], edits = CONCAT(edits,'- [e_key] changed ban duration from [duration] to [value] '), expiration_time = DATE_ADD(bantime, INTERVAL [value] MINUTE) WHERE id = [banid]")
if(!query_edit_ban_duration.warn_execute())
qdel(query_edit_ban_duration)
return
qdel(query_edit_ban_duration)
- message_admins("[key_name_admin(usr)] has edited a ban for [pckey]'s duration from [duration] to [value]")
+ message_admins("[key_name_admin(usr)] has edited a ban for [p_key]'s duration from [duration] to [value]")
if("unban")
- if(alert("Unban [pckey]?", "Unban?", "Yes", "No") == "Yes")
+ if(alert("Unban [p_key]?", "Unban?", "Yes", "No") == "Yes")
DB_ban_unban_by_id(banid)
return
else
@@ -316,20 +323,20 @@
if(!check_rights(R_BAN))
return
- var/sql = "SELECT ckey FROM [format_table_name("ban")] WHERE id = [id]"
+ var/sql = "SELECT (SELECT byond_key FROM [format_table_name("player")] WHERE [format_table_name("player")].ckey = [format_table_name("ban")].ckey) FROM [format_table_name("ban")] WHERE id = [id]"
if(!SSdbcore.Connect())
return
var/ban_number = 0 //failsafe
- var/pckey
+ var/p_key
var/datum/DBQuery/query_unban_get_ckey = SSdbcore.NewQuery(sql)
if(!query_unban_get_ckey.warn_execute())
qdel(query_unban_get_ckey)
return
while(query_unban_get_ckey.NextRow())
- pckey = query_unban_get_ckey.item[1]
+ p_key = query_unban_get_ckey.item[1]
ban_number++;
qdel(query_unban_get_ckey)
@@ -354,7 +361,7 @@
qdel(query_unban)
return
qdel(query_unban)
- message_admins("[key_name_admin(usr)] has lifted [pckey]'s ban.")
+ message_admins("[key_name_admin(usr)] has lifted [p_key]'s ban.")
/client/proc/DB_ban_panel()
set category = "Admin"
@@ -399,7 +406,7 @@
output += ""
output += ""
output += ""
- output += "
Ckey:
"
+ output += "
Key:
"
output += "
IP:
"
output += "
Computer id:
"
output += "
Duration:
"
@@ -474,7 +481,7 @@
output += "
OPTIONS
"
output += "
"
var/limit = " LIMIT [bansperpage * page], [bansperpage]"
- var/datum/DBQuery/query_search_bans = SSdbcore.NewQuery("SELECT id, bantime, bantype, reason, job, duration, expiration_time, ckey, a_ckey, unbanned, unbanned_ckey, unbanned_datetime, edits, round_id FROM [format_table_name("ban")] WHERE [search] ORDER BY bantime DESC[limit]")
+ var/datum/DBQuery/query_search_bans = SSdbcore.NewQuery("SELECT id, bantime, bantype, reason, job, duration, expiration_time, (SELECT byond_key FROM [format_table_name("player")] WHERE [format_table_name("player")].ckey = [format_table_name("ban")].ckey), (SELECT byond_key FROM [format_table_name("player")] WHERE [format_table_name("player")].ckey = [format_table_name("ban")].a_ckey), unbanned, (SELECT byond_key FROM [format_table_name("player")] WHERE [format_table_name("player")].ckey = [format_table_name("ban")].unbanned_ckey), unbanned_datetime, edits, round_id FROM [format_table_name("ban")] WHERE [search] ORDER BY bantime DESC[limit]")
if(!query_search_bans.warn_execute())
qdel(query_search_bans)
return
@@ -487,10 +494,17 @@
var/job = query_search_bans.item[5]
var/duration = query_search_bans.item[6]
var/expiration = query_search_bans.item[7]
+<<<<<<< HEAD
var/ckey = query_search_bans.item[8]
var/ackey = query_search_bans.item[9]
var/unbanned = text2num(query_search_bans.item[10]) // yogs - Yog Bans
var/unbanckey = query_search_bans.item[11]
+=======
+ var/ban_key = query_search_bans.item[8]
+ var/a_key = query_search_bans.item[9]
+ var/unbanned = query_search_bans.item[10]
+ var/unban_key = query_search_bans.item[11]
+>>>>>>> 0d7ef3ed65... Key instead of ckey for user facing logs and ui (#39009)
var/unbantime = query_search_bans.item[12]
var/edits = query_search_bans.item[13]
var/round_id = query_search_bans.item[14]
@@ -518,9 +532,9 @@
output += "
"
diff --git a/code/modules/admin/IsBanned.dm b/code/modules/admin/IsBanned.dm
index 2ce8c399315e..c13095bbec60 100644
--- a/code/modules/admin/IsBanned.dm
+++ b/code/modules/admin/IsBanned.dm
@@ -23,7 +23,7 @@
//Whitelist
if(CONFIG_GET(flag/usewhitelist))
- if(!check_whitelist(ckey(key)))
+ if(!check_whitelist(ckey))
if (admin)
log_admin("The admin [key] has been allowed to bypass the whitelist")
message_admins("The admin [key] has been allowed to bypass the whitelist")
@@ -50,7 +50,7 @@
if(CONFIG_GET(flag/ban_legacy_system))
//Ban Checking
- . = CheckBan( ckey(key), computer_id, address )
+ . = CheckBan(ckey, computer_id, address )
if(.)
if (admin)
log_admin("The admin [key] has been allowed to bypass a matching ban on [.["key"]]")
@@ -61,11 +61,8 @@
return .
else
-
- var/ckeytext = ckey(key)
-
if(!SSdbcore.Connect())
- var/msg = "Ban database connection failure. Key [ckeytext] not checked"
+ var/msg = "Ban database connection failure. Key [ckey] not checked"
log_world(msg)
message_admins(msg)
return
@@ -78,13 +75,17 @@
if(computer_id)
cidquery = " OR computerid = '[computer_id]' "
+<<<<<<< HEAD
var/datum/DBQuery/query_ban_check = SSdbcore.NewQuery("SELECT ckey, a_ckey, reason, expiration_time, duration, bantime, bantype, id, 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) OR unbanned = 0)") // yogs - Yog Bans
+=======
+ var/datum/DBQuery/query_ban_check = SSdbcore.NewQuery("SELECT (SELECT byond_key FROM [format_table_name("player")] WHERE [format_table_name("player")].ckey = [format_table_name("ban")].ckey), (SELECT byond_key FROM [format_table_name("player")] WHERE [format_table_name("player")].ckey = [format_table_name("ban")].a_ckey), reason, expiration_time, duration, bantime, bantype, id, round_id FROM [format_table_name("ban")] WHERE (ckey = '[ckey]' [ipquery] [cidquery]) AND (bantype = 'PERMABAN' OR bantype = 'ADMIN_PERMABAN' OR ((bantype = 'TEMPBAN' OR bantype = 'ADMIN_TEMPBAN') AND expiration_time > Now())) AND isnull(unbanned)")
+>>>>>>> 0d7ef3ed65... Key instead of ckey for user facing logs and ui (#39009)
if(!query_ban_check.Execute(async = TRUE))
qdel(query_ban_check)
return
while(query_ban_check.NextRow())
- var/pckey = query_ban_check.item[1]
- var/ackey = query_ban_check.item[2]
+ var/pkey = query_ban_check.item[1]
+ var/akey = query_ban_check.item[2]
var/reason = query_ban_check.item[3]
var/expiration = query_ban_check.item[4]
var/duration = query_ban_check.item[5]
@@ -95,16 +96,16 @@
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)
+ if (ckey(pkey) != ckey)
continue
if (admin)
if (bantype == "ADMIN_PERMABAN" || bantype == "ADMIN_TEMPBAN")
log_admin("The admin [key] is admin banned (#[banid]), and has been disallowed access")
message_admins("The admin [key] is admin banned (#[banid]), and has been disallowed access")
else
- log_admin("The admin [key] has been allowed to bypass a matching ban on [pckey] (#[banid])")
- message_admins("The admin [key] has been allowed to bypass a matching ban on [pckey] (#[banid])")
- addclientmessage(ckey,"You have been allowed to bypass a matching ban on [pckey] (#[banid])")
+ log_admin("The admin [key] has been allowed to bypass a matching ban on [pkey] (#[banid])")
+ message_admins("The admin [key] has been allowed to bypass a matching ban on [pkey] (#[banid])")
+ addclientmessage(ckey,"You have been allowed to bypass a matching ban on [pkey] (#[banid])")
continue
var/expires = ""
if(text2num(duration) > 0)
@@ -112,7 +113,11 @@
else
expires = " The is a permanent ban."
+<<<<<<< HEAD
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 (BanID #[banid]) was applied by [ackey] on [bantime] during round ID [ban_round_id], [expires]. If you wish to appeal this ban please use the keyword 'assistantgreytide' to register an account on the forums." //yogs
+=======
+ var/desc = "\nReason: You, or another user of this computer or connection ([pkey]) is banned from playing here. The ban reason is:\n[reason]\nThis ban (BanID #[banid]) was applied by [akey] on [bantime] during round ID [ban_round_id], [expires]"
+>>>>>>> 0d7ef3ed65... Key instead of ckey for user facing logs and ui (#39009)
. = list("reason"="[bantype]", "desc"="[desc]")
diff --git a/code/modules/admin/NewBan.dm b/code/modules/admin/NewBan.dm
index 1e092a16e98e..d81d037c50e7 100644
--- a/code/modules/admin/NewBan.dm
+++ b/code/modules/admin/NewBan.dm
@@ -98,22 +98,22 @@ GLOBAL_PROTECT(Banlist)
return 1
-/proc/AddBan(ckey, computerid, reason, bannedby, temp, minutes, address)
+/proc/AddBan(key, computerid, reason, bannedby, temp, minutes, address)
var/bantimestamp
-
+ var/ban_ckey = ckey(key)
if (temp)
UpdateTime()
bantimestamp = GLOB.CMinutes + minutes
GLOB.Banlist.cd = "/base"
- if ( GLOB.Banlist.dir.Find("[ckey][computerid]") )
+ if ( GLOB.Banlist.dir.Find("[ban_ckey][computerid]") )
to_chat(usr, text("Ban already exists."))
return 0
else
- GLOB.Banlist.dir.Add("[ckey][computerid]")
- GLOB.Banlist.cd = "/base/[ckey][computerid]"
- WRITE_FILE(GLOB.Banlist["key"], ckey)
+ GLOB.Banlist.dir.Add("[ban_ckey][computerid]")
+ GLOB.Banlist.cd = "/base/[ban_ckey][computerid]"
+ WRITE_FILE(GLOB.Banlist["key"], ban_ckey)
WRITE_FILE(GLOB.Banlist["id"], computerid)
WRITE_FILE(GLOB.Banlist["ip"], address)
WRITE_FILE(GLOB.Banlist["reason"], reason)
@@ -123,9 +123,9 @@ GLOBAL_PROTECT(Banlist)
if (temp)
WRITE_FILE(GLOB.Banlist["minutes"], bantimestamp)
if(!temp)
- create_message("note", ckey, bannedby, "Permanently banned - [reason]", null, null, 0, 0)
+ create_message("note", key, bannedby, "Permanently banned - [reason]", null, null, 0, 0)
else
- create_message("note", ckey, bannedby, "Banned for [minutes] minutes - [reason]", null, null, 0, 0)
+ create_message("note", key, bannedby, "Banned for [minutes] minutes - [reason]", null, null, 0, 0)
return 1
/proc/RemoveBan(foldername)
diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm
index 42740b32c867..b1353ac0362b 100644
--- a/code/modules/admin/admin.dm
+++ b/code/modules/admin/admin.dm
@@ -29,7 +29,7 @@
body += "Options panel for [M]"
if(M.client)
body += " played by [M.client] "
- body += "\[[M.client.holder ? M.client.holder.rank : "Player"]\]"
+ body += "\[[M.client.holder ? M.client.holder.rank : "Player"]\]"
if(CONFIG_GET(flag/use_exp_tracking))
body += "\[" + M.client.get_exp_living() + "\]"
@@ -827,7 +827,7 @@
continue
if(message)
to_chat(C, message)
- kicked_client_names.Add("[C.ckey]")
+ kicked_client_names.Add("[C.key]")
qdel(C)
return kicked_client_names
@@ -856,8 +856,8 @@
tomob.ghostize(0)
- message_admins("[key_name_admin(usr)] has put [frommob.ckey] in control of [tomob.name].")
- log_admin("[key_name(usr)] stuffed [frommob.ckey] into [tomob.name].")
+ message_admins("[key_name_admin(usr)] has put [frommob.key] in control of [tomob.name].")
+ log_admin("[key_name(usr)] stuffed [frommob.key] into [tomob.name].")
SSblackbox.record_feedback("tally", "admin_verb", 1, "Ghost Drag Control")
tomob.ckey = frommob.ckey
diff --git a/code/modules/admin/permissionedit.dm b/code/modules/admin/permissionedit.dm
index ac55eac872fd..c962aaac41cb 100644
--- a/code/modules/admin/permissionedit.dm
+++ b/code/modules/admin/permissionedit.dm
@@ -44,29 +44,29 @@
pagecount++
output += "|"
var/limit = " LIMIT [logssperpage * page], [logssperpage]"
- var/datum/DBQuery/query_search_admin_logs = SSdbcore.NewQuery("SELECT datetime, round_id, adminckey, operation, target, log FROM [format_table_name("admin_log")][search] ORDER BY datetime DESC[limit]")
+ var/datum/DBQuery/query_search_admin_logs = SSdbcore.NewQuery("SELECT datetime, round_id, (SELECT byond_key FROM [format_table_name("player")] WHERE ckey = adminckey), operation, IF(ckey IS NULL, target, byond_key), log FROM [format_table_name("admin_log")] LEFT JOIN [format_table_name("player")] ON target = ckey[search] ORDER BY datetime DESC[limit]")
if(!query_search_admin_logs.warn_execute())
qdel(query_search_admin_logs)
return
while(query_search_admin_logs.NextRow())
var/datetime = query_search_admin_logs.item[1]
var/round_id = query_search_admin_logs.item[2]
- var/admin_ckey = query_search_admin_logs.item[3]
+ var/admin_key = query_search_admin_logs.item[3]
operation = query_search_admin_logs.item[4]
target = query_search_admin_logs.item[5]
var/log = query_search_admin_logs.item[6]
- output += "
[datetime] | Round ID [round_id] | Admin [admin_ckey] | Operation [operation] on [target] [log]
"
+ output += "
[datetime] | Round ID [round_id] | Admin [admin_key] | Operation [operation] on [target] [log]
[timestamp] | [server] | [admin_key]")
if(!linkless)
data += " \[Delete\]"
if(type == "note")
data += " [secret ? "\[Secret\]" : "\[Not secret\]"]"
if(type == "message sent")
data += " Message has been sent"
- if(editor_ckey)
+ if(editor_key)
data += "|"
else
data += " \[Edit\]"
- if(editor_ckey)
- data += " Last edit by [editor_ckey] (Click here to see edit log)"
+ if(editor_key)
+ data += " Last edit by [editor_key] (Click here to see edit log)"
data += " [text]