Better SQL prepared statements (#2474)

The system used to be of complexity O(n^2). Essentially two for loops running per every argument. Which ended up being surprisingly slow (there were instances where I saw the argument parser as using quite a lot of CPU time).

This replaces it with a more linear algorithm. It's somewhere near O(n) where n is the length of the unparsed query. Which is more stable and faaaster. This comes with two changes, however:

Parameters inside the query now have to be delimited from both sides with : (colons). The alternative to this would be to use something like $n or just assume that space marks the end of a marker. Only the former is workable, the latter would break a few queries already.
Arguments in the argument array no longer have to be prefixed by : (colons). So, while in the query you would write :thing:, you'd initialize the array of args as: list("thing" = somevar). It could be made to work without it, but eh, I think this is fine.
Argument validation is slightly weaker. What I mean by this is that with the old system, unused keys would result in an error. This is no longer a thing. Missing keys will still result in an error, however.
One more improvement: double delimiting removes an edge case where if key A partially covers key B, depending on the order, key A would mangle key B.
Updated and tested all queries that I could find. So this should be good.
This commit is contained in:
skull132
2017-05-29 21:17:41 +03:00
committed by GitHub
parent b88d6aaadb
commit a3ec0cf45d
36 changed files with 366 additions and 333 deletions
+1 -1
View File
@@ -5,4 +5,4 @@
ALTER TABLE `ss13_characters_flavour`
ADD `signature` TINYTEXT NULL DEFAULT NULL AFTER `char_id`,
ADD `signature_font` TINYTEXT TINYTEXT NULL DEFAULT NULL AFTER `signature`;
ADD `signature_font` TINYTEXT NULL DEFAULT NULL AFTER `signature`;
+19 -19
View File
@@ -44,15 +44,15 @@
WHERE api_t.id = api_t_f.token_id AND api_f.id = api_t_f.command_id
AND api_t.deleted_at IS NULL
AND (
(token = :token AND ip = :ip AND command = :command)
(token = :token: AND ip = :ip: AND command = :command:)
OR
(token = :token AND ip IS NULL AND command = :command)
(token = :token: AND ip IS NULL AND command = :command:)
OR
(token = :token AND ip = :ip AND command = \"_ANY\")
(token = :token: AND ip = :ip: AND command = \"_ANY\")
OR
(token = :token AND ip IS NULL AND command = \"_ANY\")
(token = :token: AND ip IS NULL AND command = \"_ANY\")
OR
(token IS NULL AND ip IS NULL AND command = :command)
(token IS NULL AND ip IS NULL AND command = :command:)
)"})
//Check if the token is not deleted
//Check if one of the following is true:
@@ -62,7 +62,7 @@
// Any Command, Any IP - Token Matches, IP is set to NULL (not required), Command is set to _ANY
// Public - Token is set to NULL, IP is set to NULL and command matches
authquery.Execute(list(":token" = auth, ":ip" = addr, ":command" = command.name))
authquery.Execute(list("token" = auth, "ip" = addr, "command" = command.name))
log_debug("API: Auth Check - Query Executed - Returned Rows: [authquery.RowCount()]")
if (authquery.RowCount())
@@ -77,12 +77,12 @@ proc/api_update_command_database()
return 0 //Error
var/DBQuery/commandinsertquery = dbcon.NewQuery({"INSERT INTO ss13_api_commands (command,description)
VALUES (:command_name,:command_description)
ON DUPLICATE KEY UPDATE description = :command_description;"})
VALUES (:command_name:,:command_description:)
ON DUPLICATE KEY UPDATE description = :command_description:;"})
for(var/com in topic_commands)
var/datum/topic_command/command = topic_commands[com]
commandinsertquery.Execute(list(":command_name" = command.name, ":command_description" = command.description))
commandinsertquery.Execute(list("command_name" = command.name, "command_description" = command.description))
log_debug("API: DB Command Update Executed")
return 1 //OK
@@ -176,16 +176,16 @@ proc/api_update_command_database()
FROM ss13_api_token_command as api_t_f, ss13_api_tokens as api_t, ss13_api_commands as api_f
WHERE api_t.id = api_t_f.token_id AND api_f.id = api_t_f.command_id
AND (
(token = :token AND ip = :ip)
(token = :token: AND ip = :ip:)
OR
(token = :token AND ip IS NULL)
(token = :token: AND ip IS NULL)
OR
(token IS NULL AND ip = :ip)
(token IS NULL AND ip = :ip:)
)
ORDER BY command DESC"})
commandsquery.Execute(list(":token" = queryparams["auth"], ":ip" = queryparams["addr"]))
commandsquery.Execute(list("token" = queryparams["auth"], "ip" = queryparams["addr"]))
while (commandsquery.NextRow())
commands[commandsquery.item[1]] = commandsquery.item[1]
if(commandsquery.item[1] == "_ANY")
@@ -228,15 +228,15 @@ proc/api_update_command_database()
WHERE api_t.id = api_t_f.token_id AND api_f.id = api_t_f.command_id
AND api_t.deleted_at IS NULL
AND (
(token = :token AND ip = :ip AND command = :command)
(token = :token: AND ip = :ip: AND command = :command:)
OR
(token = :token AND ip IS NULL AND command = :command)
(token = :token: AND ip IS NULL AND command = :command:)
OR
(token = :token AND ip = :ip AND command = \"_ANY\")
(token = :token: AND ip = :ip: AND command = \"_ANY\")
OR
(token = :token AND ip IS NULL AND command = \"_ANY\")
(token = :token: AND ip IS NULL AND command = \"_ANY\")
OR
(token IS NULL AND ip IS NULL AND command = :command)
(token IS NULL AND ip IS NULL AND command = :command:)
)"})
//Get the tokens and the associated commands
//Check if the token, the ip and the command matches OR
@@ -244,7 +244,7 @@ proc/api_update_command_database()
// the token + ip matches and the command is NULL (Allow a specific ip with a specific token to use all commands)
// the token + ip is NULL and the command matches (Allow a specific command to be used without auth)
permquery.Execute(list(":token" = queryparams["auth"], ":ip" = queryparams["addr"], ":command" = queryparams["command"]))
permquery.Execute(list("token" = queryparams["auth"], "ip" = queryparams["addr"], "command" = queryparams["command"]))
if (!permquery.RowCount())
statuscode = 401
+72 -33
View File
@@ -183,47 +183,86 @@ DBQuery/proc/SetConversion(column,conversion)
conversions.len = column
conversions[column] = conversion
/* Works similarly to the PDO object's Execute() method in PHP.
* Insert a list of keys/values, it searches the SQL syntax for the keys,
* and replaces them with sanitized versions of the values.
* Can be called independently, or through dbcon.Execute(), where the list would be the first argument.
* passNotFound controls whether or not is passes keys not found in the SQL query.
* Keys are /case-sensitive/, be careful!
* Returns the parsed SQL query upon completion.
* - Skull132
/**
* Automatic query parsing. Works similarly to any SQL prepared statement system.
*
* You pass in here a query which has special argument markers (we use :marker: style),
* and a map of argument -> content. Note that in this map, the argument key should not
* contain the colon delimiters. So while it's :marker: in the query, in the args list,
* it would be list("marker" = somevar).
*
* The parser will then crawl the input query and replace any placeholders it finds
* with automatically sanitized values. Values can even be lists, at which point a
* MySQL list is generated: (VALUE1, VALUE2).
*
* @param query_to_parse The query we will be parsing.
* @param argument_list A map of markers associated with their values. Values can
* be numeric, strings, null, or lists of primitives. In case of null, MySQL NULL is
* used. In case of a list of primitives, a MySQL comma delimited list is used instead.
*
* @return The parsed query upon success. null upon failure.
*/
/DBQuery/proc/parseArguments(var/query_to_parse = null, var/list/argument_list, var/pass_not_found = 0)
/DBQuery/proc/parseArguments(var/query_to_parse = null, var/list/argument_list)
if (!query_to_parse || !argument_list || !argument_list.len)
log_debug("parseArguments() failed! Improper arguments sent!")
return 0
log_debug("SQL ARGPARSE: Invalid arguments sent.")
return null
for (var/placeholder in argument_list)
if (!findtextEx(query_to_parse, placeholder))
if (pass_not_found)
var/parsed = ""
var/list/cache = list()
var/pos = 1
var/search = 0
var/curr_arg = ""
// We crawl the key list first. This is required to properly notice missing
// arguments/keys. Otherwise, list[non-key] will always result in null and
// will thus be populated as NULL. Which is bad.
for (var/key in argument_list)
var/argument = argument_list[key]
if (istext(argument))
cache[key] = "[dbcon.Quote(argument)]"
else if (isnum(argument))
cache[key] = "[argument]"
else if (istype(argument, /list))
cache[key] = parse_db_lists(argument)
else if (isnull(argument))
cache[key] = "NULL"
else
log_debug("SQL ARGPARSE: Cannot identify argument! [key]. Argument: [argument]")
return null
while (1)
search = findtext(query_to_parse, ":", pos)
parsed += copytext(query_to_parse, pos, search)
if (search)
pos = search
search = findtext(query_to_parse, ":", pos + 1)
if (search)
curr_arg = copytext(query_to_parse, pos + 1, search)
if (cache[curr_arg])
parsed += cache[curr_arg]
else
log_debug("SQL ARGPARSE: Unpopulated argument found in an SQL query.")
log_debug("SQL ARGPARSE: [curr_arg]. Query: [query_to_parse]")
return null
pos = search + 1
curr_arg = ""
continue
else
log_debug("parseArguments() failed! Key not found: [placeholder].")
return 0
parsed += copytext(query_to_parse, pos, search)
var/argument = argument_list[placeholder]
break
if (istext(argument))
argument = dbcon.Quote(argument)
else if (isnum(argument))
argument = "[argument]"
else if (istype(argument, /list))
argument = parse_db_lists(argument)
else if (isnull(argument))
argument = "NULL"
else
log_debug("parseArguments() failed! Cannot identify argument!")
log_debug("Placeholder: '[placeholder]'. Argument: '[argument]'")
return 0
query_to_parse = replacetextEx(query_to_parse, placeholder, argument)
return query_to_parse
return parsed
/**
* Generates a MySQL list from a list of primitives. Also escapes values.
*
* @param argument The list of primitives we want to generate a MySQL list from.
*
* @return A string representing the MySQL list if the parsing is successful.
* "NULL", the MySQL null value, if parsing fails for some reason.
*/
/DBQuery/proc/parse_db_lists(var/list/argument)
if (!argument || !istype(argument) || !argument.len)
return "NULL"
+10 -10
View File
@@ -104,7 +104,7 @@ A list of items and costs is stored under the datum of every game mode, alongsid
// Interaction code. Gathers a list of items purchasable from the paren't uplink and displays it. It also adds a lock button.
/obj/item/device/uplink/hidden/interact(mob/user)
ui_interact(user)
/obj/item/device/uplink/hidden/CanUseTopic()
if(!active)
return STATUS_CLOSE
@@ -208,14 +208,14 @@ A list of items and costs is stored under the datum of every game mode, alongsid
switch (nanoui_data["contracts_view"])
if (1)
query_details[":status"] = "open"
query_details["status"] = "open"
if (2)
query_details[":status"] = "closed"
query_details["status"] = "closed"
else
nanoui_data["contracts_view"] = 1
query_details[":status"] = "open"
query_details["status"] = "open"
var/DBQuery/index_query = dbcon.NewQuery("SELECT count(*) as Total_Contracts FROM ss13_syndie_contracts WHERE deleted_at IS NULL AND status = :status")
var/DBQuery/index_query = dbcon.NewQuery("SELECT count(*) as Total_Contracts FROM ss13_syndie_contracts WHERE deleted_at IS NULL AND status = :status:")
index_query.Execute(query_details)
var/pages = 0
@@ -242,9 +242,9 @@ A list of items and costs is stored under the datum of every game mode, alongsid
if (nanoui_data["contracts_current_page"] > pages)
return
query_details[":offset"] = (nanoui_data["contracts_current_page"] - 1) * 10
query_details["offset"] = (nanoui_data["contracts_current_page"] - 1) * 10
var/DBQuery/list_query = dbcon.NewQuery("SELECT contract_id, contractee_name, title FROM ss13_syndie_contracts WHERE deleted_at IS NULL AND status = :status LIMIT 10 OFFSET :offset")
var/DBQuery/list_query = dbcon.NewQuery("SELECT contract_id, contractee_name, title FROM ss13_syndie_contracts WHERE deleted_at IS NULL AND status = :status: LIMIT 10 OFFSET :offset:")
list_query.Execute(query_details)
var/list/contracts = list()
@@ -272,11 +272,11 @@ A list of items and costs is stored under the datum of every game mode, alongsid
nanoui_data["contracts_view"] = 1
var/query_details[0]
query_details[":contract_id"] = exploit_id
query_details["contract_id"] = exploit_id
var/DBQuery/select_query = dbcon.NewQuery("SELECT contract_id, contractee_name, status, title, description, reward_other FROM ss13_syndie_contracts WHERE contract_id = :contract_id")
var/DBQuery/select_query = dbcon.NewQuery("SELECT contract_id, contractee_name, status, title, description, reward_other FROM ss13_syndie_contracts WHERE contract_id = :contract_id:")
select_query.Execute(query_details)
if (select_query.NextRow())
nanoui_data["contracts_found"] = 1
+12 -12
View File
@@ -15,8 +15,8 @@
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")
original_ban.Execute(list(":ban_id" = ban_id))
var/DBQuery/original_ban = dbcon.NewQuery("SELECT ckey, ip, computerid FROM ss13_ban WHERE id = :ban_id:")
original_ban.Execute(list("ban_id" = ban_id))
if (original_ban.NextRow())
var/original_ckey = original_ban.item[1]
@@ -30,8 +30,8 @@
bad_data &= ~BAD_CID
if (bad_data)
var/DBQuery/mirrored_bans = dbcon.NewQuery("SELECT player_ckey, ban_mirror_ip, ban_mirror_computerid FROM ss13_ban_mirrors WHERE ban_id = :ban_id")
mirrored_bans.Execute(list(":ban_id" = ban_id))
var/DBQuery/mirrored_bans = dbcon.NewQuery("SELECT player_ckey, ban_mirror_ip, ban_mirror_computerid FROM ss13_ban_mirrors WHERE ban_id = :ban_id:")
mirrored_bans.Execute(list("ban_id" = ban_id))
while (mirrored_bans.NextRow())
var/mirrored_ckey = mirrored_bans.item[1]
@@ -66,8 +66,8 @@
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/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()
@@ -78,8 +78,8 @@
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(list(":vars" = ban_ids))
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(list("vars" = ban_ids))
var/list/active_bans = list()
@@ -103,8 +103,8 @@
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))
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))
var/mirrors[] = list()
while (query.NextRow())
@@ -122,8 +122,8 @@
if (!ckey || !address || !computer_id || !ban_id)
return
var/DBQuery/new_mirror = dbcon.NewQuery("INSERT INTO ss13_ban_mirrors (ban_id, player_ckey, ban_mirror_ip, ban_mirror_computerid, ban_mirror_datetime) VALUES (:ban_id, :ckey, :address, :computerid, NOW())")
new_mirror.Execute(list(":ban_id" = ban_id, ":ckey" = ckey, ":address" = address, ":computerid" = computer_id))
var/DBQuery/new_mirror = dbcon.NewQuery("INSERT INTO ss13_ban_mirrors (ban_id, player_ckey, ban_mirror_ip, ban_mirror_computerid, ban_mirror_datetime) VALUES (:ban_id:, :ckey:, :address:, :computerid:, NOW())")
new_mirror.Execute(list("ban_id" = ban_id, "ckey" = ckey, "address" = address, "computerid" = computer_id))
log_misc("Mirrored ban #[ban_id] for player [ckey] from [address]-[computer_id].")
+2 -2
View File
@@ -515,8 +515,8 @@
output += "</tr>"
if (bantype in list("PERMABAN", "TEMPBAN"))
var/mirror_count = 0
var/DBQuery/get_mirrors = dbcon.NewQuery("SELECT ban_mirror_id FROM ss13_ban_mirrors WHERE ban_id = :ban_id")
get_mirrors.Execute(list(":ban_id" = text2num(banid)))
var/DBQuery/get_mirrors = dbcon.NewQuery("SELECT ban_mirror_id FROM ss13_ban_mirrors WHERE ban_id = :ban_id:")
get_mirrors.Execute(list("ban_id" = text2num(banid)))
while (get_mirrors.NextRow())
mirror_count++
+6 -6
View File
@@ -54,13 +54,13 @@ world/IsBanned(key,address,computer_id)
var/params[] = list()
var/query_content = ""
if (pulled_ban_id)
query_content = "SELECT id, ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype FROM ss13_ban WHERE id = :ban_id AND (bantype = 'PERMABAN' OR (bantype = 'TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)"
params[":ban_id"] = pulled_ban_id
query_content = "SELECT id, ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype FROM ss13_ban WHERE id = :ban_id: AND (bantype = 'PERMABAN' OR (bantype = 'TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)"
params["ban_id"] = pulled_ban_id
else
query_content = "SELECT id, ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype FROM ss13_ban WHERE (ckey = :ckey OR computerid = :computerid OR ip = :address) AND (bantype = 'PERMABAN' OR (bantype = 'TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)"
params[":ckey"] = ckey
params[":computerid"] = computer_id
params[":address"] = address
query_content = "SELECT id, ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype FROM ss13_ban WHERE (ckey = :ckey: OR computerid = :computerid: OR ip = :address:) AND (bantype = 'PERMABAN' OR (bantype = 'TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)"
params["ckey"] = ckey
params["computerid"] = computer_id
params["address"] = address
var/DBQuery/query = dbcon.NewQuery(query_content)
query.Execute(params)
+35 -37
View File
@@ -5,12 +5,12 @@
if(!player_ckey || !note)
return
var/list/query_details = list(":ckey" = player_ckey, ":address" = player_address ? player_address : null, ":computer_id" = player_computerid ? player_computerid : null, ":a_ckey" = null, ":note" = note)
var/list/query_details = list("ckey" = player_ckey, "address" = player_address ? player_address : null, "computer_id" = player_computerid ? player_computerid : null, "a_ckey" = null, "note" = note)
if (!user)
query_details[":a_ckey"] = "Adminbot"
query_details["a_ckey"] = "Adminbot"
else
query_details[":a_ckey"] = user.ckey
query_details["a_ckey"] = user.ckey
establish_db_connection(dbcon)
if (!dbcon.IsConnected())
@@ -18,15 +18,15 @@
return
if (!player_address || !player_computerid)
var/DBQuery/init_query = dbcon.NewQuery("SELECT ip, computerid FROM ss13_player WHERE ckey = :ckey")
init_query.Execute(list(":ckey" = player_ckey))
var/DBQuery/init_query = dbcon.NewQuery("SELECT ip, computerid FROM ss13_player WHERE ckey = :ckey:")
init_query.Execute(list("ckey" = player_ckey))
if (init_query.NextRow())
if (!query_details[":address"])
query_details[":address"] = init_query.item[1]
if (!query_details[":computer_id"])
query_details[":computer_id"] = init_query.item[2]
if (!query_details["address"])
query_details["address"] = init_query.item[1]
if (!query_details["computer_id"])
query_details["computer_id"] = init_query.item[2]
var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO ss13_notes (id, adddate, ckey, ip, computerid, a_ckey, content) VALUES (null, Now(), :ckey, :address, :computer_id, :a_ckey, :note)")
var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO ss13_notes (id, adddate, ckey, ip, computerid, a_ckey, content) VALUES (null, Now(), :ckey:, :address:, :computer_id:, :a_ckey:, :note:)")
insert_query.Execute(query_details)
message_admins("<span class='notice'>[key_name_admin(user)] has edited [player_ckey]'s notes.</span>")
@@ -45,8 +45,8 @@
var/ckey
var/note
var/DBQuery/init_query = dbcon.NewQuery("SELECT ckey, content FROM ss13_notes WHERE id = :note_id")
init_query.Execute(list(":note_id" = note_id))
var/DBQuery/init_query = dbcon.NewQuery("SELECT ckey, content FROM ss13_notes WHERE id = :note_id:")
init_query.Execute(list("note_id" = note_id))
while (init_query.NextRow())
ckey = init_query.item[1]
note = init_query.item[2]
@@ -65,8 +65,8 @@
switch (note_edit)
if ("delete")
if(alert("Delete this note?", "Delete?", "Yes", "No") == "Yes")
var/DBQuery/deletequery = dbcon.NewQuery("UPDATE ss13_notes SET visible = 0 WHERE id = :note_id")
deletequery.Execute(list(":note_id" = note_id))
var/DBQuery/deletequery = dbcon.NewQuery("UPDATE ss13_notes SET visible = 0 WHERE id = :note_id:")
deletequery.Execute(list("note_id" = note_id))
message_admins("<span class='notice'>[key_name_admin(usr)] deleted one of [ckey]'s notes.</span>")
log_admin("[key_name(usr)] deleted one of [ckey]'s notes.",admin_key=key_name(usr),ckey=ckey)
@@ -78,8 +78,8 @@
if (!new_content)
usr << "Cancelled"
return
var/DBQuery/editquery = dbcon.NewQuery("UPDATE ss13_notes SET content = :new_content, lasteditor = :a_ckey, lasteditdate = Now(), edited = 1 WHERE id = :note_id")
editquery.Execute(list(":new_content" = new_content, ":a_ckey" = usr.client.ckey, ":note_id" = note_id))
var/DBQuery/editquery = dbcon.NewQuery("UPDATE ss13_notes SET content = :new_content:, lasteditor = :a_ckey:, lasteditdate = Now(), edited = 1 WHERE id = :note_id:")
editquery.Execute(list("new_content" = new_content, "a_ckey" = usr.client.ckey, "note_id" = note_id))
/datum/admins/proc/show_notes_sql(var/player_ckey = null, var/admin_ckey = null)
if (!check_rights(R_ADMIN|R_MOD))
@@ -118,28 +118,26 @@
dat += "</tr>"
if (player_ckey)
var/list/query_details = list(":player_ckey" = player_ckey)
var/list/query_details = list("player_ckey" = player_ckey)
dat += "<tr><td align='center' colspan='4' bgcolor='white'><b><a href='?src=\ref[src];add_player_info=[player_ckey]'>Add Note</a></b></td></tr>"
var/DBQuery/init_query = dbcon.NewQuery("SELECT ip, computerid FROM ss13_player WHERE ckey = :player_ckey")
var/DBQuery/init_query = dbcon.NewQuery("SELECT ip, computerid FROM ss13_player WHERE ckey = :player_ckey:")
init_query.Execute(query_details)
if (init_query.NextRow())
query_details += ":player_address"
query_details += ":player_computerid"
query_details[":player_address"] = init_query.item[1]
query_details[":player_computerid"] = init_query.item[2]
query_details["player_address"] = init_query.item[1]
query_details["player_computerid"] = init_query.item[2]
var/query_content = "SELECT id, adddate, ckey, a_ckey, content, edited, lasteditor, lasteditdate FROM ss13_notes WHERE ckey = :player_ckey AND visible = '1'"
var/query_content = "SELECT id, adddate, ckey, a_ckey, content, edited, lasteditor, lasteditdate FROM ss13_notes WHERE ckey = :player_ckey: AND visible = '1'"
if (query_details[":player_address"])
query_content += " OR ip = :player_address AND visible = '1'"
if (query_details[":player_computerid"])
query_content += " OR computerid = :player_computerid AND visible = '1'"
if (query_details["player_address"])
query_content += " OR ip = :player_address: AND visible = '1'"
if (query_details["player_computerid"])
query_content += " OR computerid = :player_computerid: AND visible = '1'"
query_content += " ORDER BY adddate ASC"
var/DBQuery/query = dbcon.NewQuery(query_content)
query.Execute(query_details, 1)
query.Execute(query_details)
while (query.NextRow())
var/id = text2num(query.item[1])
@@ -161,9 +159,9 @@
dat += "<tr><td colspan='4' bgcolor='white'>&nbsp</td></tr>"
else if (admin_ckey && !player_ckey)
var/aquery_content = "SELECT id, adddate, ckey, content, edited, lasteditor, lasteditdate FROM ss13_notes WHERE a_ckey = :a_ckey AND visible = '1' ORDER BY adddate ASC"
var/aquery_content = "SELECT id, adddate, ckey, content, edited, lasteditor, lasteditdate FROM ss13_notes WHERE a_ckey = :a_ckey: AND visible = '1' ORDER BY adddate ASC"
var/DBQuery/admin_query = dbcon.NewQuery(aquery_content)
admin_query.Execute(list(":a_ckey" = admin_ckey))
admin_query.Execute(list("a_ckey" = admin_ckey))
while (admin_query.NextRow())
var/id = text2num(admin_query.item[1])
@@ -192,8 +190,8 @@
if (!dbcon.IsConnected())
return "Unable to establish database connection! Aborting!"
var/DBQuery/info_query = dbcon.NewQuery("SELECT ip, computerid FROM ss13_player WHERE ckey = :ckey")
info_query.Execute(list(":ckey" = ckey))
var/DBQuery/info_query = dbcon.NewQuery("SELECT ip, computerid FROM ss13_player WHERE ckey = :ckey:")
info_query.Execute(list("ckey" = ckey))
var/address = null
var/computer_id = null
@@ -201,15 +199,15 @@
address = info_query.item[1]
computer_id = info_query.item[2]
var/query_content = "SELECT a_ckey, adddate, content FROM ss13_notes WHERE visible = '1' AND ckey = :ckey"
var/query_details = list(":ckey" = ckey, ":address" = address, ":computerid" = computer_id)
var/query_content = "SELECT a_ckey, adddate, content FROM ss13_notes WHERE visible = '1' AND ckey = :ckey:"
var/query_details = list("ckey" = ckey, "address" = address, "computerid" = computer_id)
if (address)
query_content += " OR ip = :address"
query_content += " OR ip = :address:"
if (computer_id)
query_content += " OR computerid = :computerid"
query_content += " OR computerid = :computerid:"
var/DBQuery/query = dbcon.NewQuery(query_content)
query.Execute(query_details, 1)
query.Execute(query_details)
var/notes
while (query.NextRow())
+32 -34
View File
@@ -36,15 +36,15 @@
warned_computerid = C.computer_id
warned_ip = C.address
else
var/DBQuery/lookup_query = dbcon.NewQuery("SELECT ip, computerid FROM ss13_player WHERE ckey = :ckey")
lookup_query.Execute(list(":ckey" = warned_ckey))
var/DBQuery/lookup_query = dbcon.NewQuery("SELECT ip, computerid FROM ss13_player WHERE ckey = :ckey:")
lookup_query.Execute(list("ckey" = warned_ckey))
if (lookup_query.NextRow())
warned_ip = lookup_query.item[1]
warned_computerid = lookup_query.item[2]
var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO ss13_warnings (id, time, severity, reason, notes, ckey, computerid, ip, a_ckey, a_ip, a_computerid) VALUES (null, Now(), :warning_severity, :warning_reason, :warning_notes, :warned_ckey, :warned_computerid, :warned_ip, :a_ckey, :a_ip, :a_computerid)")
insert_query.Execute(list(":warning_severity" = warning_severity, ":warning_reason" = warning_reason, ":warning_notes" = warning_notes, ":warned_ckey" = warned_ckey, ":warned_computerid" = warned_computerid, ":warned_ip" = warned_ip, ":a_ckey" = ckey, ":a_ip" = address, ":a_computerid" = computer_id))
var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO ss13_warnings (id, time, severity, reason, notes, ckey, computerid, ip, a_ckey, a_ip, a_computerid) VALUES (null, Now(), :warning_severity:, :warning_reason:, :warning_notes:, :warned_ckey:, :warned_computerid:, :warned_ip:, :a_ckey:, :a_ip:, :a_computerid:)")
insert_query.Execute(list("warning_severity" = warning_severity, "warning_reason" = warning_reason, "warning_notes" = warning_notes, "warned_ckey" = warned_ckey, "warned_computerid" = warned_computerid, "warned_ip" = warned_ip, "a_ckey" = ckey, "a_ip" = address, "a_computerid" = computer_id))
notes_add_sql(warned_ckey, "Warning added by [ckey], for: [warning_reason]. || Notes regarding the warning: [warning_notes].", src, warned_ip, warned_computerid)
@@ -124,8 +124,8 @@
dat += "<th width='60%'>REASON</th>"
dat += "</tr>"
var/DBQuery/search_query = dbcon.NewQuery("SELECT id, time, severity, reason, a_ckey, acknowledged, expired FROM ss13_warnings WHERE visible = 1 AND (ckey = :ckey OR computerid = :computer_id OR ip = :address) ORDER BY time DESC;")
search_query.Execute(list(":ckey" = ckey, ":computer_id" = computer_id, ":address" = address))
var/DBQuery/search_query = dbcon.NewQuery("SELECT id, time, severity, reason, a_ckey, acknowledged, expired FROM ss13_warnings WHERE visible = 1 AND (ckey = :ckey: OR computerid = :computer_id: OR ip = :address:) ORDER BY time DESC;")
search_query.Execute(list("ckey" = ckey, "computer_id" = computer_id, "address" = address))
while (search_query.NextRow())
var/id = text2num(search_query.item[1])
@@ -177,8 +177,8 @@
alert("Connection to SQL database failed while attempting to update your warning's status!")
return
var/DBQuery/query = dbcon.NewQuery("UPDATE ss13_warnings SET acknowledged = 1 WHERE id = :warning_id;")
query.Execute(list(":warning_id" = warning_id))
var/DBQuery/query = dbcon.NewQuery("UPDATE ss13_warnings SET acknowledged = 1 WHERE id = :warning_id:;")
query.Execute(list("warning_id" = warning_id))
warnings_check()
@@ -194,17 +194,17 @@
if (!dbcon.IsConnected())
return
var/list/client_details = list(":ckey" = ckey, ":computer_id" = computer_id, ":address" = address)
var/list/client_details = list("ckey" = ckey, "computer_id" = computer_id, "address" = address)
var/DBQuery/expire_query = dbcon.NewQuery("SELECT id FROM ss13_warnings WHERE (acknowledged = 1 AND expired = 0 AND DATE_SUB(CURDATE(),INTERVAL 3 MONTH) > time) AND (ckey = :ckey OR computerid = :computer_id OR ip = :address)")
var/DBQuery/expire_query = dbcon.NewQuery("SELECT id FROM ss13_warnings WHERE (acknowledged = 1 AND expired = 0 AND DATE_SUB(CURDATE(),INTERVAL 3 MONTH) > time) AND (ckey = :ckey: OR computerid = :computer_id: OR ip = :address:)")
expire_query.Execute(client_details)
while (expire_query.NextRow())
var/warning_id = text2num(expire_query.item[1])
var/DBQuery/update_query = dbcon.NewQuery("UPDATE ss13_warnings SET expired = 1 WHERE id = :warning_id")
update_query.Execute(list(":warning_id" = warning_id))
var/DBQuery/update_query = dbcon.NewQuery("UPDATE ss13_warnings SET expired = 1 WHERE id = :warning_id:")
update_query.Execute(list("warning_id" = warning_id))
count_expire++
var/DBQuery/query = dbcon.NewQuery("SELECT id FROM ss13_warnings WHERE (visible = 1 AND acknowledged = 0 AND expired = 0) AND (ckey = :ckey OR computerid = :computer_id OR ip = :address)")
var/DBQuery/query = dbcon.NewQuery("SELECT id FROM ss13_warnings WHERE (visible = 1 AND acknowledged = 0 AND expired = 0) AND (ckey = :ckey: OR computerid = :computer_id: OR ip = :address:)")
query.Execute(client_details)
while (query.NextRow())
count++
@@ -265,18 +265,18 @@
dat += "<th width='60%'>REASON</th>"
dat += "</tr>"
var/list/query_details = list(":a_ckey", ":ckey")
var/list/query_details = list("a_ckey", "ckey")
var/paramone = ""
var/paramtwo = ""
if(adminckey)
paramone = "AND a_ckey = :a_ckey "
query_details[":a_ckey"] = adminckey
paramone = "AND a_ckey = :a_ckey: "
query_details["a_ckey"] = adminckey
if(playerckey)
paramtwo = "AND ckey = :ckey "
query_details[":ckey"] = playerckey
paramtwo = "AND ckey = :ckey: "
query_details["ckey"] = playerckey
var/DBQuery/search_query = dbcon.NewQuery("SELECT id, time, severity, reason, notes, ckey, a_ckey, acknowledged, expired, edited, lasteditor, lasteditdate FROM ss13_warnings WHERE visible = 1 [paramone] [paramtwo] ORDER BY time DESC;")
search_query.Execute(query_details, 1)
search_query.Execute(query_details)
while (search_query.NextRow())
var/id = text2num(search_query.item[1])
@@ -351,10 +351,10 @@
var/ckey
var/reason
var/notes
var/list/query_details = list(":warning_id" = warning_id, ":a_ckey" = usr.ckey)
var/list/query_details = list("warning_id" = warning_id, "a_ckey" = usr.ckey)
var/DBQuery/initial_query = dbcon.NewQuery("SELECT ckey, reason, notes FROM ss13_warnings WHERE id = :warning_id")
initial_query.Execute(query_details, 1)
var/DBQuery/initial_query = dbcon.NewQuery("SELECT ckey, reason, notes FROM ss13_warnings WHERE id = :warning_id:")
initial_query.Execute(query_details)
while (initial_query.NextRow())
ckey = initial_query.item[1]
reason = initial_query.item[2]
@@ -374,8 +374,8 @@
switch (warning_edit)
if ("delete")
if(alert("Delete this warning?", "Delete?", "Yes", "No") == "Yes")
var/DBQuery/deleteQuery = dbcon.NewQuery("UPDATE ss13_warnings SET visible = 0 WHERE id = :warning_id")
deleteQuery.Execute(query_details, 1)
var/DBQuery/deleteQuery = dbcon.NewQuery("UPDATE ss13_warnings SET visible = 0 WHERE id = :warning_id:")
deleteQuery.Execute(query_details)
message_admins("<span class='notice'>[key_name_admin(usr)] deleted one of [ckey]'s warnings.</span>")
log_admin("[key_name(usr)] deleted one of [ckey]'s warnings.", admin_key=key_name(usr), ckey=ckey)
@@ -384,29 +384,27 @@
return
if ("editReason")
query_details += ":new_reason"
query_details[":new_reason"] = input("Edit this warning's reason.", "New Reason", reason, null) as null|text
query_details["new_reason"] = input("Edit this warning's reason.", "New Reason", reason, null) as null|text
if(!query_details[":new_reason"] || query_details[":new_reason"] == reason)
if(!query_details["new_reason"] || query_details["new_reason"] == reason)
usr << "Cancelled"
return
var/DBQuery/reason_query = dbcon.NewQuery("UPDATE ss13_warnings SET reason = :new_reason, edited = 1, lasteditor = :a_ckey, lasteditdate = NOW() WHERE id = :warning_id")
reason_query.Execute(query_details, 1)
var/DBQuery/reason_query = dbcon.NewQuery("UPDATE ss13_warnings SET reason = :new_reason:, edited = 1, lasteditor = :a_ckey:, lasteditdate = NOW() WHERE id = :warning_id:")
reason_query.Execute(query_details)
message_admins("<span class='notice'>[key_name_admin(usr)] edited one of [ckey]'s warning reasons.</span>")
log_admin("[key_name(usr)] edited one of [ckey]'s warning reasons.", admin_key=key_name(usr), ckey=ckey)
if("editNotes")
query_details += ":new_notes"
query_details[":new_notes"] = input("Edit this warning's notes.", "New Notes", notes, null) as null|text
query_details["new_notes"] = input("Edit this warning's notes.", "New Notes", notes, null) as null|text
if(!query_details[":new_notes"] || query_details[":new_notes"] == notes)
if(!query_details["new_notes"] || query_details["new_notes"] == notes)
usr << "Cancelled"
return
var/DBQuery/notes_query = dbcon.NewQuery("UPDATE ss13_warnings SET notes = :new_notes, edited = 1, lasteditor = :a_ckey, lasteditdate = NOW() WHERE id = :warning_id")
notes_query.Execute(query_details, 1)
var/DBQuery/notes_query = dbcon.NewQuery("UPDATE ss13_warnings SET notes = :new_notes:, edited = 1, lasteditor = :a_ckey:, lasteditdate = NOW() WHERE id = :warning_id:")
notes_query.Execute(query_details)
message_admins("<span class='notice'>[key_name_admin(usr)] edited one of [ckey]'s warning notes.</span>")
log_admin("[key_name(usr)] edited one of [ckey]'s warning notes.", admin_key=key_name(usr), ckey=ckey)
@@ -30,8 +30,8 @@
/datum/preferences/proc/load_character_contest(slot)
if (config.antag_contest_enabled && config.sql_enabled && establish_db_connection(dbcon))
var/DBQuery/query = dbcon.NewQuery("SELECT contest_faction FROM ss13_contest_participants WHERE character_id = :char_id")
query.Execute(list(":char_id" = slot))
var/DBQuery/query = dbcon.NewQuery("SELECT contest_faction FROM ss13_contest_participants WHERE character_id = :char_id:")
query.Execute(list("char_id" = slot))
if (query.NextRow())
antag_contest_faction = text2num(query.item[1])
@@ -52,4 +52,4 @@
var/obj/item/organ/external/affected = M.organs_by_name["head"]
affected.implants += L
L.part = affected
L.implanted(src)
L.implanted(src)
@@ -54,16 +54,16 @@
error("Unable to establish database connection while logging objective results!")
return
var/DBQuery/get_query = dbcon.NewQuery("SELECT contest_faction FROM ss13_contest_participants WHERE player_ckey = :ckey AND character_id = :char_id")
get_query.Execute(list(":ckey" = owner.current.client.ckey, ":char_id" = owner.current.client.prefs.current_character))
var/DBQuery/get_query = dbcon.NewQuery("SELECT contest_faction FROM ss13_contest_participants WHERE player_ckey = :ckey: AND character_id = :char_id:")
get_query.Execute(list("ckey" = owner.current.client.ckey, "char_id" = owner.current.client.prefs.current_character))
var/params[] = list(":ckey" = owner.current.client.ckey, ":char_id" = owner.current.client.prefs.current_character, ":char_faction" = INDEP, ":obj_type" = type_name, ":obj_side" = side, ":obj_outcome" = completed)
var/params[] = list("ckey" = owner.current.client.ckey, "char_id" = owner.current.client.prefs.current_character, "char_faction" = INDEP, "obj_type" = type_name, "obj_side" = side, "obj_outcome" = completed)
if (get_query.NextRow())
var/list/faction_data = contest_faction_data(get_query.item[1])
params[":char_faction"] = faction_data[1]
params["char_faction"] = faction_data[1]
var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO ss13_contest_reports (id, player_ckey, character_id, character_faction, objective_type, objective_side, objective_outcome, objective_datetime) VALUES (NULL, :ckey, :char_id, :char_faction, :obj_type, :obj_side, :obj_outcome, NOW())")
var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO ss13_contest_reports (id, player_ckey, character_id, character_faction, objective_type, objective_side, objective_outcome, objective_datetime) VALUES (NULL, :ckey:, :char_id:, :char_faction:, :obj_type:, :obj_side:, :obj_outcome:, NOW())")
log_query.Execute(params)
if (log_query.ErrorMsg())
+9 -9
View File
@@ -34,8 +34,8 @@
src << "<span class='warning'>Failed to establish SQL connection! Contact a member of staff!</span>"
return
var/DBQuery/character_query = dbcon.NewQuery("SELECT id, name FROM ss13_characters WHERE ckey = :ckey AND deleted_at IS NULL")
character_query.Execute(list(":ckey" = src.ckey))
var/DBQuery/character_query = dbcon.NewQuery("SELECT id, name FROM ss13_characters WHERE ckey = :ckey: AND deleted_at IS NULL")
character_query.Execute(list("ckey" = src.ckey))
var/list/char_ids = list()
while (character_query.NextRow())
@@ -45,8 +45,8 @@
src << "<span class='warning'>Something went horribly wrong! Apparently you don't have any saved characters?</span>"
return
var/DBQuery/participation_query = dbcon.NewQuery("SELECT character_id, contest_faction FROM ss13_contest_participants WHERE character_id IN :char_ids")
participation_query.Execute(list(":char_ids" = char_ids))
var/DBQuery/participation_query = dbcon.NewQuery("SELECT character_id, contest_faction FROM ss13_contest_participants WHERE character_id IN :char_ids:")
participation_query.Execute(list("char_ids" = char_ids))
while (participation_query.NextRow())
char_ids[participation_query.item[1]]["assigned"] = 1
@@ -102,8 +102,8 @@
src << "<span class='warning'>Failed to establish SQL connection! Contact a member of staff!</span>"
return
var/DBQuery/part_check = dbcon.NewQuery("SELECT contest_faction FROM ss13_contest_participants WHERE character_id = :char_id AND player_ckey = :ckey")
part_check.Execute(list(":char_id" = src.prefs.current_character, ":ckey" = src.ckey))
var/DBQuery/part_check = dbcon.NewQuery("SELECT contest_faction FROM ss13_contest_participants WHERE character_id = :char_id: AND player_ckey = :ckey:")
part_check.Execute(list("char_id" = src.prefs.current_character, "ckey" = src.ckey))
if (part_check.NextRow())
var/list/available_objs
@@ -244,12 +244,12 @@
src << "<span class='notice'>Cancelled</span>"
return
var/list/sql_args = list(":ckey" = src.ckey, ":char_id" = href["char_id"], ":new_side" = contest_factions[choice])
var/list/sql_args = list("ckey" = src.ckey, "char_id" = href["char_id"], "new_side" = contest_factions[choice])
var/query_content = "UPDATE ss13_contest_participants SET contest_faction = :new_side WHERE player_ckey = :ckey AND character_id = :char_id"
var/query_content = "UPDATE ss13_contest_participants SET contest_faction = :new_side: WHERE player_ckey = :ckey: AND character_id = :char_id:"
if (text2num(href["previously_assigned"]) == 0)
query_content = "INSERT INTO ss13_contest_participants (player_ckey, character_id, contest_faction) VALUES (:ckey, :char_id, :new_side)"
query_content = "INSERT INTO ss13_contest_participants (player_ckey, character_id, contest_faction) VALUES (:ckey:, :char_id:, :new_side:)"
var/DBQuery/query = dbcon.NewQuery(query_content)
query.Execute(sql_args)
+13 -13
View File
@@ -106,8 +106,8 @@
return
var/DBQuery/check_query = dbcon.NewQuery("SELECT player_ckey, status FROM ss13_player_linking WHERE id = :id")
check_query.Execute(list(":id" = request_id))
var/DBQuery/check_query = dbcon.NewQuery("SELECT player_ckey, status FROM ss13_player_linking WHERE id = :id:")
check_query.Execute(list("id" = request_id))
if (!check_query.NextRow())
src << "<span class='warning'>No request found!</span>"
@@ -118,19 +118,19 @@
return
var/query_contents = ""
var/list/query_details = list(":new_status", ":id")
var/list/query_details = list("new_status", "id")
var/feedback_message = ""
switch (href_list["linkingaction"])
if ("accept")
query_contents = "UPDATE ss13_player_linking SET status = :new_status, updated_at = NOW() WHERE id = :id"
query_details[":new_status"] = "confirmed"
query_details[":id"] = request_id
query_contents = "UPDATE ss13_player_linking SET status = :new_status:, updated_at = NOW() WHERE id = :id:"
query_details["new_status"] = "confirmed"
query_details["id"] = request_id
feedback_message = "<font color='green'><b>Account successfully linked!</b></font>"
if ("deny")
query_contents = "UPDATE ss13_player_linking SET status = :new_status, deleted_at = NOW() WHERE id = :id"
query_details[":new_status"] = "rejected"
query_details[":id"] = request_id
query_contents = "UPDATE ss13_player_linking SET status = :new_status:, deleted_at = NOW() WHERE id = :id:"
query_details["new_status"] = "rejected"
query_details["id"] = request_id
feedback_message = "<font color='red'><b>Link request rejected!</b></font>"
else
@@ -516,9 +516,9 @@
return
var/list/requests = list()
var/list/query_details = list(":ckey" = ckey)
var/list/query_details = list("ckey" = ckey)
var/DBQuery/select_query = dbcon.NewQuery("SELECT id, forum_id, forum_username, datediff(Now(), created_at) as request_age FROM ss13_player_linking WHERE status = 'new' AND player_ckey = :ckey AND deleted_at IS NULL")
var/DBQuery/select_query = dbcon.NewQuery("SELECT id, forum_id, forum_username, datediff(Now(), created_at) as request_age FROM ss13_player_linking WHERE status = 'new' AND player_ckey = :ckey: AND deleted_at IS NULL")
select_query.Execute(query_details)
while (select_query.NextRow())
@@ -553,8 +553,8 @@
if (!dbcon.IsConnected())
return
var/DBQuery/select_query = dbcon.NewQuery("SELECT COUNT(*) AS request_count FROM ss13_player_linking WHERE status = 'new' AND player_ckey = :ckey AND deleted_at IS NULL")
select_query.Execute(list(":ckey" = ckey))
var/DBQuery/select_query = dbcon.NewQuery("SELECT COUNT(*) AS request_count FROM ss13_player_linking WHERE status = 'new' AND player_ckey = :ckey: AND deleted_at IS NULL")
select_query.Execute(list("ckey" = ckey))
if (select_query.NextRow())
if (text2num(select_query.item[1]) > 0)
@@ -12,13 +12,13 @@
return list("ss13_characters" = list("vars" = list("be_special_role"), "args" = list("id")))
/datum/category_item/player_setup_item/antagonism/candidacy/gather_load_parameters()
return list(":id" = pref.current_character)
return list("id" = pref.current_character)
/datum/category_item/player_setup_item/antagonism/candidacy/gather_save_query()
return list("ss13_characters" = list("be_special_role", "id" = 1, "ckey" = 1))
/datum/category_item/player_setup_item/antagonism/candidacy/gather_save_parameters()
return list(":be_special_role" = list2params(pref.be_special_role), ":id" = pref.current_character, ":ckey" = pref.client.ckey)
return list("be_special_role" = list2params(pref.be_special_role), "id" = pref.current_character, "ckey" = pref.client.ckey)
/datum/category_item/player_setup_item/antagonism/candidacy/sanitize_character(var/sql_load = 0)
if (sql_load)
@@ -17,14 +17,14 @@ var/global/list/uplink_locations = list("PDA", "Headset", "None")
"ss13_characters" = list("vars" = list("uplink_location" = "uplinklocation"), "args" = list("id")))
/datum/category_item/player_setup_item/antagonism/basic/gather_load_parameters()
return list(":char_id" = pref.current_character, ":id" = pref.current_character)
return list("char_id" = pref.current_character, "id" = pref.current_character)
/datum/category_item/player_setup_item/antagonism/basic/gather_save_query()
return list("ss13_characters_flavour" = list("records_exploit", "char_id" = 1),
"ss13_characters" = list("uplink_location", "id" = 1, "ckey" = 1))
/datum/category_item/player_setup_item/antagonism/basic/gather_save_parameters()
return list(":records_exploit" = pref.exploit_record, ":char_id" = pref.current_character, ":uplink_location" = pref.uplinklocation, ":id" = pref.current_character, ":ckey" = pref.client.ckey)
return list("records_exploit" = pref.exploit_record, "char_id" = pref.current_character, "uplink_location" = pref.uplinklocation, "id" = pref.current_character, "ckey" = pref.client.ckey)
/datum/category_item/player_setup_item/antagonism/basic/sanitize_character()
pref.uplinklocation = sanitize_inlist(pref.uplinklocation, uplink_locations, initial(pref.uplinklocation))
@@ -26,7 +26,7 @@
"args" = list("id")))
/datum/category_item/player_setup_item/general/basic/gather_load_parameters()
return list(":id" = pref.current_character)
return list("id" = pref.current_character)
/datum/category_item/player_setup_item/general/basic/gather_save_query()
return list("ss13_characters" = list("name",
@@ -38,13 +38,13 @@
"ckey" = 1))
/datum/category_item/player_setup_item/general/basic/gather_save_parameters()
return list(":name" = pref.real_name,
":gender" = pref.gender,
":age" = pref.age,
":metadata" = pref.metadata,
":spawnpoint" = pref.spawnpoint,
":id" = pref.current_character,
":ckey" = pref.client.ckey)
return list("name" = pref.real_name,
"gender" = pref.gender,
"age" = pref.age,
"metadata" = pref.metadata,
"spawnpoint" = pref.spawnpoint,
"id" = pref.current_character,
"ckey" = pref.client.ckey)
/datum/category_item/player_setup_item/general/basic/load_special()
pref.can_edit_name = 1
@@ -55,8 +55,8 @@
// Called /after/ loading and /before/ sanitization.
// So we have pref.current_character. It's just in text format.
var/DBQuery/query = dbcon.NewQuery("SELECT DATEDIFF(NOW(), created_at) AS DiffDate FROM ss13_characters WHERE id = :id")
query.Execute(list(":id" = text2num(pref.current_character)))
var/DBQuery/query = dbcon.NewQuery("SELECT DATEDIFF(NOW(), created_at) AS DiffDate FROM ss13_characters WHERE id = :id:")
query.Execute(list("id" = text2num(pref.current_character)))
if (query.NextRow())
if (text2num(query.item[1]) > 5)
@@ -12,7 +12,7 @@
return list("ss13_characters" = list("vars" = list("language" = "alternate_languages"), "args" = list("id")))
/datum/category_item/player_setup_item/general/language/gather_load_parameters()
return list(":id" = pref.current_character)
return list("id" = pref.current_character)
/datum/category_item/player_setup_item/general/language/gather_save_query()
return list("ss13_characters" = list("id" = 1,
@@ -20,9 +20,9 @@
"language"))
/datum/category_item/player_setup_item/general/language/gather_save_parameters()
return list(":language" = list2params(pref.alternate_languages),
":id" = pref.current_character,
":ckey" = pref.client.ckey)
return list("language" = list2params(pref.alternate_languages),
"id" = pref.current_character,
"ckey" = pref.client.ckey)
/datum/category_item/player_setup_item/general/language/sanitize_character(var/sql_load = 0)
if (sql_load)
@@ -64,7 +64,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
"args" = list("id")))
/datum/category_item/player_setup_item/general/body/gather_load_parameters()
return list(":id" = pref.current_character)
return list("id" = pref.current_character)
/datum/category_item/player_setup_item/general/body/gather_save_query()
return list("ss13_characters" = list("species",
@@ -83,20 +83,20 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
"ckey" = 1))
/datum/category_item/player_setup_item/general/body/gather_save_parameters()
return list(":species" = pref.species,
":hair_colour" = "#" + num2hex(pref.r_hair, 2) + num2hex(pref.g_hair, 2) + num2hex(pref.b_hair, 2),
":facial_colour" = "#" + num2hex(pref.r_facial, 2) + num2hex(pref.g_facial, 2) + num2hex(pref.b_facial, 2),
":skin_tone" = pref.s_tone,
":skin_colour" = "#" + num2hex(pref.r_skin, 2) + num2hex(pref.g_skin, 2) + num2hex(pref.b_skin, 2),
":hair_style" = pref.h_style,
":facial_style" = pref.f_style,
":eyes_colour" = "#" + num2hex(pref.r_eyes, 2) + num2hex(pref.g_eyes, 2) + num2hex(pref.b_eyes, 2),
":b_type" = pref.b_type,
":disabilities" = pref.disabilities,
":organs_data" = list2params(pref.organ_data),
":organs_robotic"= list2params(pref.rlimb_data),
":id" = pref.current_character,
":ckey" = pref.client.ckey)
return list("species" = pref.species,
"hair_colour" = "#" + num2hex(pref.r_hair, 2) + num2hex(pref.g_hair, 2) + num2hex(pref.b_hair, 2),
"facial_colour" = "#" + num2hex(pref.r_facial, 2) + num2hex(pref.g_facial, 2) + num2hex(pref.b_facial, 2),
"skin_tone" = pref.s_tone,
"skin_colour" = "#" + num2hex(pref.r_skin, 2) + num2hex(pref.g_skin, 2) + num2hex(pref.b_skin, 2),
"hair_style" = pref.h_style,
"facial_style" = pref.f_style,
"eyes_colour" = "#" + num2hex(pref.r_eyes, 2) + num2hex(pref.g_eyes, 2) + num2hex(pref.b_eyes, 2),
"b_type" = pref.b_type,
"disabilities" = pref.disabilities,
"organs_data" = list2params(pref.organ_data),
"organs_robotic"= list2params(pref.rlimb_data),
"id" = pref.current_character,
"ckey" = pref.client.ckey)
/datum/category_item/player_setup_item/general/body/sanitize_character(var/sql_load = 0)
if(!pref.species || !(pref.species in playable_species))
@@ -18,13 +18,13 @@
return list("ss13_characters" = list("vars" = list("underwear", "undershirt", "socks", "backbag"), "args" = list("id")))
/datum/category_item/player_setup_item/general/equipment/gather_load_parameters()
return list(":id" = pref.current_character)
return list("id" = pref.current_character)
/datum/category_item/player_setup_item/general/equipment/gather_save_query()
return list("ss13_characters" = list("underwear", "undershirt", "socks", "backbag", "id" = 1, "ckey" = 1))
/datum/category_item/player_setup_item/general/equipment/gather_save_parameters()
return list(":underwear" = pref.underwear, ":undershirt" = pref.undershirt, ":socks" = pref.socks, ":backbag" = pref.backbag, ":id" = pref.current_character, ":ckey" = pref.client.ckey)
return list("underwear" = pref.underwear, "undershirt" = pref.undershirt, "socks" = pref.socks, "backbag" = pref.backbag, "id" = pref.current_character, "ckey" = pref.client.ckey)
/datum/category_item/player_setup_item/general/equipment/sanitize_character(var/sql_load = 0)
if (sql_load)
@@ -31,7 +31,7 @@
"ss13_characters" = list("vars" = list("home_system", "citizenship", "faction", "religion"), "args" = list("id")))
/datum/category_item/player_setup_item/general/background/gather_load_parameters()
return list(":id" = pref.current_character, ":char_id" = pref.current_character)
return list("id" = pref.current_character, "char_id" = pref.current_character)
/datum/category_item/player_setup_item/general/background/gather_save_query()
return list("ss13_characters_flavour" = list("records_employment",
@@ -41,16 +41,16 @@
"ss13_characters" = list("home_system", "citizenship", "faction", "religion", "id" = 1, "ckey" = 1))
/datum/category_item/player_setup_item/general/background/gather_save_parameters()
return list(":records_employment" = pref.gen_record,
":records_medical" = pref.med_record,
":records_security" = pref.sec_record,
":char_id" = pref.current_character,
":home_system" = pref.home_system,
":citizenship" = pref.citizenship,
":faction" = pref.faction,
":religion" = pref.religion,
":id" = pref.current_character,
":ckey" = pref.client.ckey)
return list("records_employment" = pref.gen_record,
"records_medical" = pref.med_record,
"records_security" = pref.sec_record,
"char_id" = pref.current_character,
"home_system" = pref.home_system,
"citizenship" = pref.citizenship,
"faction" = pref.faction,
"religion" = pref.religion,
"id" = pref.current_character,
"ckey" = pref.client.ckey)
/datum/category_item/player_setup_item/general/background/sanitize_character()
if(!pref.home_system)
@@ -59,7 +59,7 @@
return list("ss13_characters_flavour" = list("vars" = var_list, "args" = list("char_id")))
/datum/category_item/player_setup_item/general/flavor/gather_load_parameters()
return list(":char_id" = pref.current_character)
return list("char_id" = pref.current_character)
/datum/category_item/player_setup_item/general/flavor/gather_save_query()
var/list/var_list = list("flavour_general",
@@ -82,22 +82,22 @@
return list("ss13_characters_flavour" = var_list)
/datum/category_item/player_setup_item/general/flavor/gather_save_parameters()
var/list/var_list = list(":char_id" = pref.current_character,
":flavour_general" = pref.flavor_texts["general"],
":flavour_head" = pref.flavor_texts["head"],
":flavour_face" = pref.flavor_texts["face"],
":flavour_eyes" = pref.flavor_texts["eyes"],
":flavour_torso" = pref.flavor_texts["torso"],
":flavour_arms" = pref.flavor_texts["arms"],
":flavour_hands" = pref.flavor_texts["hands"],
":flavour_legs" = pref.flavor_texts["legs"],
":flavour_feet" = pref.flavor_texts["feet"],
":robot_default" = pref.flavour_texts_robot["default"],
":signature_font" = pref.signfont,
":signature" = pref.signature)
var/list/var_list = list("char_id" = pref.current_character,
"flavour_general" = pref.flavor_texts["general"],
"flavour_head" = pref.flavor_texts["head"],
"flavour_face" = pref.flavor_texts["face"],
"flavour_eyes" = pref.flavor_texts["eyes"],
"flavour_torso" = pref.flavor_texts["torso"],
"flavour_arms" = pref.flavor_texts["arms"],
"flavour_hands" = pref.flavor_texts["hands"],
"flavour_legs" = pref.flavor_texts["legs"],
"flavour_feet" = pref.flavor_texts["feet"],
"robot_default" = pref.flavour_texts_robot["default"],
"signature" = pref.signature,
"signature_font" = pref.signfont)
for (var/module in robot_module_types)
var_list[":robot_[module]"] += pref.flavour_texts_robot[module]
var_list["robot_[module]"] += pref.flavour_texts_robot[module]
return var_list
@@ -18,13 +18,13 @@
return list("ss13_player_preferences" = list("vars" = list("UI_style", "UI_style_color", "UI_style_alpha", "ooccolor"), "args" = list("ckey")))
/datum/category_item/player_setup_item/player_global/ui/gather_load_parameters()
return list(":ckey" = pref.client.ckey)
return list("ckey" = pref.client.ckey)
/datum/category_item/player_setup_item/player_global/ui/gather_save_query()
return list("ss13_player_preferences" = list("UI_style", "UI_style_color", "UI_style_alpha", "ooccolor", "ckey" = 1))
/datum/category_item/player_setup_item/player_global/ui/gather_save_parameters()
return list(":ckey" = pref.client.ckey, ":UI_style_alpha" = pref.UI_style_alpha, ":UI_style_color" = pref.UI_style_color, ":UI_style" = pref.UI_style, ":ooccolor" = pref.ooccolor)
return list("ckey" = pref.client.ckey, "UI_style_alpha" = pref.UI_style_alpha, "UI_style_color" = pref.UI_style_color, "UI_style" = pref.UI_style, "ooccolor" = pref.ooccolor)
/datum/category_item/player_setup_item/player_global/ui/sanitize_preferences()
pref.UI_style = sanitize_inlist(pref.UI_style, all_ui_styles, initial(pref.UI_style))
@@ -26,21 +26,21 @@
return list("ss13_player_preferences" = list("vars" = list("lastchangelog", "current_character", "toggles", "asfx_togs", "lastmotd" = "motd_hash", "lastmemo" = "memo_hash"), "args" = list("ckey")))
/datum/category_item/player_setup_item/player_global/settings/gather_load_parameters()
return list(":ckey" = pref.client.ckey)
return list("ckey" = pref.client.ckey)
/datum/category_item/player_setup_item/player_global/settings/gather_save_query()
return list("ss13_player_preferences" = list("lastchangelog", "current_character", "toggles", "asfx_togs", "lastmotd", "lastmemo", "ckey" = 1, "parallax_toggles", "parallax_speed"))
/datum/category_item/player_setup_item/player_global/settings/gather_save_parameters()
return list(":ckey" = pref.client.ckey,
":lastchangelog" = pref.lastchangelog,
":current_character" = pref.current_character,
":toggles" = pref.toggles,
":asfx_togs" = pref.asfx_togs,
":lastmotd" = pref.motd_hash,
":lastmemo" = pref.memo_hash,
":parallax_toggles" = pref.parallax_togs,
":parallax_speed" = pref.parallax_speed)
return list("ckey" = pref.client.ckey,
"lastchangelog" = pref.lastchangelog,
"current_character" = pref.current_character,
"toggles" = pref.toggles,
"asfx_togs" = pref.asfx_togs,
"lastmotd" = pref.motd_hash,
"lastmemo" = pref.memo_hash,
"parallax_toggles" = pref.parallax_togs,
"parallax_speed" = pref.parallax_speed)
/datum/category_item/player_setup_item/player_global/settings/sanitize_preferences(var/sql_load = 0)
if (sql_load)
@@ -12,13 +12,13 @@
return list("ss13_player_preferences" = list("vars" = list("language_prefixes"), "args" = list("ckey")))
/datum/category_item/player_setup_item/player_global/language/gather_load_parameters()
return list(":ckey" = pref.client.ckey)
return list("ckey" = pref.client.ckey)
/datum/category_item/player_setup_item/player_global/language/gather_save_query()
return list("ss13_player_preferences" = list("language_prefixes", "ckey" = 1))
/datum/category_item/player_setup_item/player_global/language/gather_save_parameters()
return list(":ckey" = pref.client.ckey, ":language_prefixes" = list2params(pref.language_prefixes))
return list("ckey" = pref.client.ckey, "language_prefixes" = list2params(pref.language_prefixes))
/datum/category_item/player_setup_item/player_global/language/sanitize_preferences(var/sql_load = 0)
if (sql_load && pref.language_prefixes)
@@ -31,7 +31,7 @@
return list("ss13_player_pai" = list("vars" = list("name" = "pai/name", "description" = "pai/description", "role" = "pai/role", "comments" = "pai/comments"), "args" = list("ckey")))
/datum/category_item/player_setup_item/player_global/pai/gather_load_parameters()
return list(":ckey" = pref.client.ckey)
return list("ckey" = pref.client.ckey)
/datum/category_item/player_setup_item/player_global/pai/gather_save_query()
return list("ss13_player_pai" = list("name", "description", "role", "comments", "ckey" = 1))
@@ -40,7 +40,7 @@
if (!candidate)
return list()
return list(":ckey" = pref.client.ckey, ":name" = candidate.name, ":description" = candidate.description, ":role" = candidate.role, ":comments" = candidate.comments)
return list("ckey" = pref.client.ckey, "name" = candidate.name, "description" = candidate.description, "role" = candidate.role, "comments" = candidate.comments)
/datum/category_item/player_setup_item/player_global/pai/sanitize_preferences(var/sql_load = 0)
if (sql_load && candidate && pref.pai.len)
@@ -44,7 +44,7 @@ var/list/gear_datums = list()
S["gear"] << pref.gear
/datum/category_item/player_setup_item/loadout/gather_load_parameters()
return list(":id" = pref.current_character)
return list("id" = pref.current_character)
/datum/category_item/player_setup_item/loadout/gather_load_query()
return list("ss13_characters" = list("vars" = list("gear"), "args" = list("id")))
@@ -53,7 +53,7 @@ var/list/gear_datums = list()
return list("ss13_characters" = list("gear", "id" = 1, "ckey" = 1))
/datum/category_item/player_setup_item/loadout/gather_save_parameters()
return list(":gear" = json_encode(pref.gear), ":id" = pref.current_character, ":ckey" = pref.client.ckey)
return list("gear" = json_encode(pref.gear), "id" = pref.current_character, "ckey" = pref.client.ckey)
/datum/category_item/player_setup_item/loadout/proc/valid_gear_choices(var/max_cost)
. = list()
@@ -37,7 +37,7 @@
return list("ss13_characters" = list("vars" = list("jobs" = "unsanitized_jobs", "alternate_option", "alternate_titles" = "player_alt_titles"), "args" = list("id")))
/datum/category_item/player_setup_item/occupation/gather_load_parameters()
return list(":id" = pref.current_character)
return list("id" = pref.current_character)
/datum/category_item/player_setup_item/occupation/gather_save_query()
return list("ss13_characters" = list("jobs", "alternate_option", "alternate_titles", "id" = 1, "ckey" = 1))
@@ -53,7 +53,7 @@
"job_engsec_med" = pref.job_engsec_med,
"job_engsec_low" = pref.job_engsec_low)
return list(":jobs" = list2params(compiled_jobs), ":alternate_option" = pref.alternate_option, ":alternate_titles" = list2params(pref.player_alt_titles), ":id" = pref.current_character, ":ckey" = pref.client.ckey)
return list("jobs" = list2params(compiled_jobs), "alternate_option" = pref.alternate_option, "alternate_titles" = list2params(pref.player_alt_titles), "id" = pref.current_character, "ckey" = pref.client.ckey)
/datum/category_item/player_setup_item/occupation/sanitize_character(var/sql_load = 0)
if (sql_load)
@@ -19,11 +19,11 @@
JOIN ss13_characters chr ON act_chr.char_id = chr.id
JOIN ss13_ccia_actions act ON act_chr.action_id = act.id
WHERE
act_chr.char_id = ':char_id' AND
act_chr.char_id = :char_id: AND
(act.expires_at IS NULL OR act.expires_at >= CURRENT_DATE()) AND
act.deleted_at IS NULL;
"})
if (!ccia_action_query.Execute(list(":char_id" = pref.current_character)))
if (!ccia_action_query.Execute(list("char_id" = pref.current_character)))
error("Error CCIA Actions for character #[pref.current_character]. SQL error message: '[ccia_action_query.ErrorMsg()]'.")
while(ccia_action_query.NextRow())
@@ -42,9 +42,9 @@
id, char_id, UID, datetime, notes, charges, evidence, arbiters, brig_sentence, fine, felony
FROM ss13_character_incidents
WHERE
char_id = ':char_id' AND deleted_at IS NULL
char_id = :char_id: AND deleted_at IS NULL
"})
char_infraction_query.Execute(list(":char_id" = pref.current_character))
char_infraction_query.Execute(list("char_id" = pref.current_character))
while(char_infraction_query.NextRow())
var/datum/char_infraction/infraction = new()
@@ -70,8 +70,7 @@
var/list/arg_names = tables[table]["args"]
count = arg_names.len
for (i = 1, i <= count, i++)
query += "[arg_names[i]] = :[arg_names[i]]"
arg_names[i] = ":[arg_names[i]]"
query += "[arg_names[i]] = :[arg_names[i]]:"
if (i != count)
query += " AND "
@@ -96,7 +95,7 @@
for (var/query_text in query_cache[type])
var/DBQuery/query = dbcon.NewQuery(query_text)
query.Execute(arg_list, 1)
query.Execute(arg_list)
if (query.ErrorMsg())
error("SQL CHARACTER LOAD: SQL query error: [query.ErrorMsg()]")
log_debug("SQL CHARACTER LOAD: SQL query error: [query.ErrorMsg()]")
@@ -180,7 +179,7 @@
// Process the args.
var/list/arg_names = list()
for (var/variable in var_names)
arg_names += ":[variable]"
arg_names += ":[variable]:"
query += "[jointext(arg_names, ", ")]) ON DUPLICATE KEY UPDATE"
@@ -215,7 +214,7 @@
var/datum/category_collection/player_setup_collection/cc = collection
for (var/query_text in query_cache[type])
var/DBQuery/query = dbcon.NewQuery(query_text)
query.Execute(arg_list, 1)
query.Execute(arg_list)
if (query.ErrorMsg())
error("SQL CHARACTER SAVE: SQL query error: [query.ErrorMsg()]")
@@ -16,13 +16,13 @@
return list("ss13_characters" = list("vars" = list("skills", "skill_specialization"), "args" = list("id")))
/datum/category_item/player_setup_item/skills/gather_load_parameters()
return list(":id" = pref.current_character)
return list("id" = pref.current_character)
/datum/category_item/player_setup_item/skills/gather_save_query()
return list("ss13_characters" = list("skills", "skill_specialization", "id" = 1, "ckey" = 1))
/datum/category_item/player_setup_item/skills/gather_save_parameters()
return list(":skills" = list2params(pref.skills), ":skill_specialization" = pref.skill_specialization, ":id" = pref.current_character, ":ckey" = pref.client.ckey)
return list("skills" = list2params(pref.skills), "skill_specialization" = pref.skill_specialization, "id" = pref.current_character, "ckey" = pref.client.ckey)
/datum/category_item/player_setup_item/skills/sanitize_character(var/sql_load = 0)
if (SKILLS == null)
+6 -6
View File
@@ -415,8 +415,8 @@ datum/preferences
if(!dbcon.IsConnected())
return open_load_dialog_file(user)
var/DBQuery/query = dbcon.NewQuery("SELECT id, name FROM ss13_characters WHERE ckey = :ckey AND deleted_at IS NULL ORDER BY id ASC")
query.Execute(list(":ckey" = user.client.ckey))
var/DBQuery/query = dbcon.NewQuery("SELECT id, name FROM ss13_characters WHERE ckey = :ckey: AND deleted_at IS NULL ORDER BY id ASC")
query.Execute(list("ckey" = user.client.ckey))
dat += "<b>Select a character slot to load</b><hr>"
var/name
@@ -471,8 +471,8 @@ datum/preferences
if (!config.sql_saves || !config.sql_stats || !establish_db_connection(dbcon) || !H)
return
var/DBQuery/query = dbcon.NewQuery("INSERT INTO ss13_characters_log (char_id, game_id, datetime, job_name, special_role) VALUES (:char_id, :game_id, NOW(), :job, :special_role)")
query.Execute(list(":char_id" = current_character, ":game_id" = game_id, ":job" = H.mind.assigned_role, ":special_role" = H.mind.special_role))
var/DBQuery/query = dbcon.NewQuery("INSERT INTO ss13_characters_log (char_id, game_id, datetime, job_name, special_role) VALUES (:char_id:, :game_id:, NOW(), :job:, :special_role:)")
query.Execute(list("char_id" = current_character, "game_id" = game_id, "job" = H.mind.assigned_role, "special_role" = H.mind.special_role))
// Turned into a proc so we could reuse it for SQL shenanigans.
/datum/preferences/proc/new_setup(var/re_initialize = 0)
@@ -570,8 +570,8 @@ datum/preferences
C << "<span class='notice'>Unable to establish database connection.</span>"
return
var/DBQuery/query = dbcon.NewQuery("UPDATE ss13_characters SET deleted_at = NOW() WHERE id = :char_id")
query.Execute(list(":char_id" = current_character))
var/DBQuery/query = dbcon.NewQuery("UPDATE ss13_characters SET deleted_at = NOW() WHERE id = :char_id:")
query.Execute(list("char_id" = current_character))
// Create a new character.
new_setup(1)
@@ -165,8 +165,8 @@
error("Error initiatlizing database connection while counting CCIA actions.")
return null
var/DBQuery/prep_query = dbcon.NewQuery("SELECT id FROM ss13_characters WHERE ckey = :ckey")
prep_query.Execute(list(":ckey" = user.ckey))
var/DBQuery/prep_query = dbcon.NewQuery("SELECT id FROM ss13_characters WHERE ckey = :ckey:")
prep_query.Execute(list("ckey" = user.ckey))
var/list/chars = list()
while (prep_query.NextRow())
@@ -181,10 +181,10 @@
JOIN ss13_characters chr ON act_chr.char_id = chr.id
JOIN ss13_ccia_actions act ON act_chr.action_id = act.id
WHERE
act_chr.char_id IN :char_id AND
act_chr.char_id IN :char_id: AND
(act.expires_at IS NULL OR act.expires_at >= CURRENT_DATE()) AND
act.deleted_at IS NULL;"})
query.Execute(list(":char_id" = chars))
query.Execute(list("char_id" = chars))
if (query.NextRow())
var/action_count = text2num(query.item[1])
+26 -26
View File
@@ -235,34 +235,34 @@
return
var/list/sql_args[] = list(
":char_id" = char_id,
":uid" = UID,
":datetime" = datetime,
":notes" = notes,
":charges" = json_encode(charges),
":evidence" = json_encode(evidence),
":arbiters" = json_encode(arbiters),
":brig_sentence" = brig_sentence,
":fine" = fine,
":felony" = felony,
":created_by" = created_by,
":game_id" = game_id
"char_id" = char_id,
"uid" = UID,
"datetime" = datetime,
"notes" = notes,
"charges" = json_encode(charges),
"evidence" = json_encode(evidence),
"arbiters" = json_encode(arbiters),
"brig_sentence" = brig_sentence,
"fine" = fine,
"felony" = felony,
"created_by" = created_by,
"game_id" = game_id
)
//Insert a new entry into the db. Upate if a entry with the same chard_id and UID already exists
var/DBQuery/infraction_insert_query = dbcon.NewQuery({"INSERT INTO ss13_character_incidents
(char_id, UID, datetime, notes, charges, evidence, arbiters, brig_sentence, fine, felony, created_by, game_id)
VALUES
(:char_id, :uid, :datetime, :notes, :charges, :evidence, :arbiters, :brig_sentence, :fine, :felony, :created_by, :game_id)
(:char_id:, :uid:, :datetime:, :notes:, :charges:, :evidence:, :arbiters:, :brig_sentence:, :fine:, :felony:, :created_by:, :game_id:)
ON DUPLICATE KEY UPDATE
notes = :notes,
charges = :charges,
evidence = :evidence,
arbiters = :arbiters,
brig_sentence = :brig_sentence,
fine = :fine,
felony = :felony,
created_by = :created_by,
game_id = :game_id
notes = :notes:,
charges = :charges:,
evidence = :evidence:,
arbiters = :arbiters:,
brig_sentence = :brig_sentence:,
fine = :fine:,
felony = :felony:,
created_by = :created_by:,
game_id = :game_id:
"})
infraction_insert_query.Execute(sql_args)
@@ -282,14 +282,14 @@
log_debug("Infraction: Not deleted from the db - db_id 0")
var/list/sql_args[] = list(
":id" = db_id,
":deleted_by" = deleted_by
"id" = db_id,
"deleted_by" = deleted_by
)
//Insert a new entry into the db. Upate if a entry with the same chard_id and UID already exists
var/DBQuery/infraction_delete_query = dbcon.NewQuery({"UPDATE ss13_character_incidents
SET
deleted_by=:deleted_by,
deleted_by=:deleted_by:,
deleted_at=NOW()
WHERE
id = :id"})
id = :id:"})
infraction_delete_query.Execute(sql_args)
+11 -11
View File
@@ -20,20 +20,20 @@
var/static/DBQuery/lprof_q
if (!lprof_q)
lprof_q = dbcon.NewQuery({"INSERT INTO ss13dbg_lighting (time,tick_usage,type,name,loc_name,x,y,z)
VALUES (:time,:tick_usage,:type,:name,:loc_name,:x,:y,:z);"})
lprof_q = dbcon.NewQuery({"INSERT INTO ss13dbg_lighting (time,tick_usage,type,name,loc_name,x,y,z)
VALUES (:time:,:tick_usage:,:type:,:name:,:loc_name:,:x:,:y:,:z:);"})
lprof_q.Execute(
list(
":time" = world.time,
":tick_usage" = world.tick_usage,
":type" = type,
":name" = name,
":loc_name" = locname,
":x" = x,
":y" = y,
":z" = z))
"time" = world.time,
"tick_usage" = world.tick_usage,
"type" = type,
"name" = name,
"loc_name" = locname,
"x" = x,
"y" = y,
"z" = z))
var/err = lprof_q.ErrorMsg()
if (err)
log_debug("lprof_write: SQL Error: [err]")
@@ -479,14 +479,14 @@ datum/species/machine/handle_post_spawn(var/mob/living/carbon/human/H)
var/obj/item/organ/ipc_tag/tag = new_machine.internal_organs_by_name["ipc tag"]
var/status = 0
var/list/query_details = list(":ckey" = player.ckey, ":character_name" = player.prefs.real_name)
var/DBQuery/query = dbcon.NewQuery("SELECT tag_status FROM ss13_ipc_tracking WHERE player_ckey = :ckey AND character_name = :character_name")
var/list/query_details = list("ckey" = player.ckey, "character_name" = player.prefs.real_name)
var/DBQuery/query = dbcon.NewQuery("SELECT tag_status FROM ss13_ipc_tracking WHERE player_ckey = :ckey: AND character_name = :character_name:")
query.Execute(query_details)
if (query.NextRow())
status = text2num(query.item[1])
else
var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO ss13_ipc_tracking (player_ckey, character_name) VALUES (:ckey, :character_name)")
var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO ss13_ipc_tracking (player_ckey, character_name) VALUES (:ckey:, :character_name:)")
log_query.Execute(query_details)
if (!status)
@@ -504,8 +504,8 @@ datum/species/machine/handle_post_spawn(var/mob/living/carbon/human/H)
if (target.internal_organs_by_name["ipc tag"])
status = 1
var/list/query_details = list(":ckey" = player.ckey, ":character_name" = target.real_name)
var/DBQuery/query = dbcon.NewQuery("SELECT tag_status FROM ss13_ipc_tracking WHERE player_ckey = :ckey AND character_name = :character_name")
var/list/query_details = list("ckey" = player.ckey, "character_name" = target.real_name)
var/DBQuery/query = dbcon.NewQuery("SELECT tag_status FROM ss13_ipc_tracking WHERE player_ckey = :ckey: AND character_name = :character_name:")
query.Execute(query_details)
if (query.NextRow())
@@ -513,9 +513,8 @@ datum/species/machine/handle_post_spawn(var/mob/living/carbon/human/H)
if (sql_status == status)
return
query_details.Add(":status")
query_details[":status"] = status
var/DBQuery/update_query = dbcon.NewQuery("UPDATE ss13_ipc_tracking SET tag_status = :status WHERE player_ckey = :ckey AND character_name = :character_name")
query_details["status"] = status
var/DBQuery/update_query = dbcon.NewQuery("UPDATE ss13_ipc_tracking SET tag_status = :status: WHERE player_ckey = :ckey: AND character_name = :character_name:")
update_query.Execute(query_details)
/datum/species/machine/get_light_color(hair_style)
+2 -2
View File
@@ -83,8 +83,8 @@
alert("An error occured while attempting to connect to the database!")
return 0
var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO ss13_web_sso (ckey, token, ip, created_at) VALUES (:ckey, :token, :ip, NOW())")
insert_query.Execute(list(":ckey" = user.ckey, ":token" = token, ":ip" = user.address))
var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO ss13_web_sso (ckey, token, ip, created_at) VALUES (:ckey:, :token:, :ip:, NOW())")
insert_query.Execute(list("ckey" = user.ckey, "token" = token, "ip" = user.address))
if (insert_query.ErrorMsg())
alert("An error occured while trying to upload the session data!")