From 4ce267de4023960c197d067da7dd45fe9125722f Mon Sep 17 00:00:00 2001 From: Kashargul <144968721+Kashargul@users.noreply.github.com> Date: Tue, 28 Jan 2025 12:29:44 +0100 Subject: [PATCH] fix dm (#16981) --- code/defines/procs/statistics.dm | 3 +- code/game/machinery/records_scanner.dm | 2 +- code/game/magic/archived_book.dm | 2 +- code/game/world.dm | 17 ++++++++++ code/modules/admin/DB ban/functions.dm | 10 ++++-- code/modules/admin/IsBanned.dm | 4 +-- code/modules/admin/admin_ranks.dm | 1 + code/modules/admin/banjob.dm | 2 ++ .../admin/permissionverbs/permissionedit.dm | 11 +++++- .../admin/verbs/check_customitem_activity.dm | 4 ++- code/modules/client/client procs.dm | 7 ++++ code/modules/library/lib_machines.dm | 3 ++ code/modules/mob/new_player/new_player.dm | 2 ++ code/modules/mob/new_player/poll.dm | 34 +++++++++++-------- code/modules/research/message_server.dm | 3 +- code/modules/tgs/v5/chat_commands.dm | 7 ++-- 16 files changed, 86 insertions(+), 26 deletions(-) diff --git a/code/defines/procs/statistics.dm b/code/defines/procs/statistics.dm index 0f1278ee302..5f6bd68eaa5 100644 --- a/code/defines/procs/statistics.dm +++ b/code/defines/procs/statistics.dm @@ -129,7 +129,7 @@ while(max_query.NextRow()) newroundid = max_query.item[1] - + qdel(max_query) if(!(isnum(newroundid))) newroundid = text2num(newroundid) @@ -146,3 +146,4 @@ if(!query.Execute()) var/err = query.ErrorMsg() log_game("SQL ERROR during death reporting. Error : \[[err]\]\n") + qdel(query) diff --git a/code/game/machinery/records_scanner.dm b/code/game/machinery/records_scanner.dm index 3ff97f160e5..b5b9712e705 100644 --- a/code/game/machinery/records_scanner.dm +++ b/code/game/machinery/records_scanner.dm @@ -51,7 +51,7 @@ var/age = user.age var/gender = user.gender /* no dbstuff yet - var/datum/DBQuery/cquery = SSdbcore.NewQuery("SELECT * from jobban WHERE ckey='[user.ckey]'") + var/datum/db_query/cquery = SSdbcore.NewQuery("SELECT * from jobban WHERE ckey='[user.ckey]'") if(!cquery.Execute()) return else while(cquery.NextRow()) diff --git a/code/game/magic/archived_book.dm b/code/game/magic/archived_book.dm index 86a9620c224..36da263386a 100644 --- a/code/game/magic/archived_book.dm +++ b/code/game/magic/archived_book.dm @@ -59,7 +59,7 @@ var/global/datum/book_manager/book_mgr = new() dat += {"(Order book by SS13BN)

" output += "
TITLE 0)?"([duration] minutes)":""] with the reason: \"[reason]\" to the ban database.",1) - + qdel(query_insert) /datum/admins/proc/DB_ban_unban(var/ckey, var/bantype, var/job = "") @@ -135,6 +136,7 @@ while(query.NextRow()) ban_id = query.item[1] ban_number++; + qdel(query) if(ban_number == 0) to_chat(usr, span_filter_adminlog("[span_red("Database update failed due to no bans fitting the search criteria. If this is not a legacy ban you should contact the database admin.")]")) @@ -193,6 +195,7 @@ var/datum/db_query/update_query = SSdbcore.NewQuery("UPDATE erro_ban SET reason = '[value]', edits = CONCAT(edits,'- [eckey] changed ban reason from \\\"[reason]\\\" to \\\"[value]\\\"
') WHERE id = [banid]") update_query.Execute() message_admins("[key_name_admin(usr)] has edited a ban for [pckey]'s reason from [reason] to [value]",1) + qdel(update_query) if("duration") if(!value) value = tgui_input_number(usr, "Insert the new duration (in minutes) for [pckey]'s ban", "New Duration", "[duration]", null) @@ -203,6 +206,7 @@ var/datum/db_query/update_query = SSdbcore.NewQuery("UPDATE erro_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]") message_admins("[key_name_admin(usr)] has edited a ban for [pckey]'s duration from [duration] to [value]",1) update_query.Execute() + qdel(update_query) if("unban") if(tgui_alert(usr, "Unban [pckey]?", "Unban?", list("Yes", "No")) == "Yes") DB_ban_unban_by_id(banid) @@ -228,7 +232,7 @@ while(query.NextRow()) pckey = query.item[1] ban_number++; - + qdel(query) if(ban_number == 0) to_chat(usr, span_filter_adminlog("[span_red("Database update failed due to a ban id not being present in the database.")]")) return @@ -249,6 +253,7 @@ var/datum/db_query/query_update = SSdbcore.NewQuery(sql_update) query_update.Execute() + qdel(query_update) /client/proc/DB_ban_panel() @@ -479,5 +484,6 @@ output += "
" + qdel(select_query) usr << browse("[output]","window=lookupbans;size=900x700") diff --git a/code/modules/admin/IsBanned.dm b/code/modules/admin/IsBanned.dm index 2334f72e8e3..4d99d907436 100644 --- a/code/modules/admin/IsBanned.dm +++ b/code/modules/admin/IsBanned.dm @@ -76,9 +76,9 @@ expires = " The ban is for [duration] minutes and expires on [expiration] (server time)." var/desc = "\nReason: You, or another user of this computer or connection ([pckey]) is banned from playing here. The ban reason is:\n[reason]\nThis ban was applied by [ackey] on [bantime], [expires]" - + qdel(query) return list("reason"="[bantype]", "desc"="[desc]") - + qdel(query) if (failedcid) message_admins("[key] has logged in with a blank computer id in the ban check.") if (failedip) diff --git a/code/modules/admin/admin_ranks.dm b/code/modules/admin/admin_ranks.dm index a66d2689775..766f6eeb422 100644 --- a/code/modules/admin/admin_ranks.dm +++ b/code/modules/admin/admin_ranks.dm @@ -126,6 +126,7 @@ var/list/admin_ranks = list() //list of all ranks with associated rights //find the client for a ckey if they are connected and associate them with the new admin datum D.associate(GLOB.directory[ckey]) + qdel(query) if(!admin_datums) error("The database query in load_admins() resulted in no admins being added to the list. Reverting to legacy system.") log_misc("The database query in load_admins() resulted in no admins being added to the list. Reverting to legacy system.") diff --git a/code/modules/admin/banjob.dm b/code/modules/admin/banjob.dm index 60f350390f9..56a495c4767 100644 --- a/code/modules/admin/banjob.dm +++ b/code/modules/admin/banjob.dm @@ -85,6 +85,7 @@ DEBUG var/job = query.item[2] jobban_keylist.Add("[ckey] - [job]") + qdel(query) //Job tempbans var/datum/db_query/query1 = SSdbcore.NewQuery("SELECT ckey, job FROM erro_ban WHERE bantype = 'JOB_TEMPBAN' AND isnull(unbanned) AND expiration_time > Now()") @@ -95,6 +96,7 @@ DEBUG var/job = query1.item[2] jobban_keylist.Add("[ckey] - [job]") + qdel(query1) /proc/jobban_savebanfile() var/savefile/S=new("data/job_full.ban") diff --git a/code/modules/admin/permissionverbs/permissionedit.dm b/code/modules/admin/permissionverbs/permissionedit.dm index cbb1e9f7290..ba0f4636a54 100644 --- a/code/modules/admin/permissionverbs/permissionedit.dm +++ b/code/modules/admin/permissionverbs/permissionedit.dm @@ -80,18 +80,23 @@ new_admin = 0 admin_id = text2num(select_query.item[1]) + qdel(select_query) if(new_admin) var/datum/db_query/insert_query = SSdbcore.NewQuery("INSERT INTO `erro_admin` (`id`, `ckey`, `rank`, `level`, `flags`) VALUES (null, '[adm_ckey]', '[new_rank]', -1, 0)") insert_query.Execute() + qdel(insert_query) var/datum/db_query/log_query = SSdbcore.NewQuery("INSERT INTO `test`.`erro_admin_log` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Added new admin [adm_ckey] to rank [new_rank]');") log_query.Execute() + qdel(log_query) to_chat(usr, span_filter_adminlog("[span_blue("New admin added.")]")) else if(!isnull(admin_id) && isnum(admin_id)) var/datum/db_query/insert_query = SSdbcore.NewQuery("UPDATE `erro_admin` SET rank = '[new_rank]' WHERE id = [admin_id]") insert_query.Execute() + qdel(insert_query) var/datum/db_query/log_query = SSdbcore.NewQuery("INSERT INTO `test`.`erro_admin_log` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Edited the rank of [adm_ckey] to [new_rank]');") log_query.Execute() + qdel(log_query) to_chat(usr, span_filter_adminlog("[span_blue("Admin rank changed.")]")) /datum/admins/proc/log_admin_permission_modification(var/adm_ckey, var/new_permission) @@ -131,19 +136,23 @@ while(select_query.NextRow()) admin_id = text2num(select_query.item[1]) admin_rights = text2num(select_query.item[2]) - + qdel(select_query) if(!admin_id) return if(admin_rights & new_permission) //This admin already has this permission, so we are removing it. var/datum/db_query/insert_query = SSdbcore.NewQuery("UPDATE `erro_admin` SET flags = [admin_rights & ~new_permission] WHERE id = [admin_id]") insert_query.Execute() + qdel(insert_query) var/datum/db_query/log_query = SSdbcore.NewQuery("INSERT INTO `test`.`erro_admin_log` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Removed permission [rights2text(new_permission)] (flag = [new_permission]) to admin [adm_ckey]');") log_query.Execute() + qdel(log_query) to_chat(usr, span_filter_adminlog("[span_blue("Permission removed.")]")) else //This admin doesn't have this permission, so we are adding it. var/datum/db_query/insert_query = SSdbcore.NewQuery("UPDATE `erro_admin` SET flags = '[admin_rights | new_permission]' WHERE id = [admin_id]") insert_query.Execute() + qdel(insert_query) var/datum/db_query/log_query = SSdbcore.NewQuery("INSERT INTO `test`.`erro_admin_log` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Added permission [rights2text(new_permission)] (flag = [new_permission]) to admin [adm_ckey]')") log_query.Execute() + qdel(log_query) to_chat(usr, span_filter_adminlog("[span_blue("Permission added.")]")) diff --git a/code/modules/admin/verbs/check_customitem_activity.dm b/code/modules/admin/verbs/check_customitem_activity.dm index 003a3da3776..704f7a4eef5 100644 --- a/code/modules/admin/verbs/check_customitem_activity.dm +++ b/code/modules/admin/verbs/check_customitem_activity.dm @@ -63,14 +63,16 @@ var/inactive_keys = "None
" if(ckeys_with_customitems.Find(cur_ckey)) ckeys_with_customitems.Remove(cur_ckey) inactive_ckeys[cur_ckey] = "last seen on [query_inactive.item[2]]" + qdel(query_inactive) //if there are ckeys left over, check whether they have a database entry at all if(ckeys_with_customitems.len) for(var/cur_ckey in ckeys_with_customitems) var/datum/db_query/query_inactive = SSdbcore.NewQuery("SELECT ckey FROM erro_player WHERE ckey = '[cur_ckey]'") query_inactive.Execute() - if(!query_inactive.rows) + if(!length(query_inactive.rows)) inactive_ckeys += cur_ckey + qdel(query_inactive) if(inactive_ckeys.len) inactive_keys = "" diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index cdb73164a8f..9c5f266ff1c 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -155,6 +155,7 @@ else to_chat(src, span_warning("There was an error registering your Discord ID in the database. Contact an administrator.")) log_and_message_admins("[ckey] failed to register their Discord ID. Their Discord snowflake ID is: [their_id]. Is the database connected?", src) + qdel(query) return //VOREStation Add End if(href_list["reload_statbrowser"]) @@ -425,11 +426,13 @@ player_age = text2num(query.item[2]) break + qdel(query) account_join_date = sanitizeSQL(findJoinDate()) if(account_join_date && SSdbcore.IsConnected()) var/datum/db_query/query_datediff = SSdbcore.NewQuery("SELECT DATEDIFF(Now(),'[account_join_date]')") if(query_datediff.Execute() && query_datediff.NextRow()) account_age = text2num(query_datediff.item[1]) + qdel(query_datediff) var/datum/db_query/query_ip = SSdbcore.NewQuery("SELECT ckey FROM erro_player WHERE ip = '[address]'") query_ip.Execute() @@ -506,20 +509,24 @@ log_debug("Error loading play hours for [ckey]: [error_message]") tgui_alert_async(src, "The query to load your existing playtime failed. Screenshot this, give the screenshot to a developer, and reconnect, otherwise you may lose any recorded play hours (which may limit access to jobs). ERROR: [error_message]", "PROBLEMS!!") // VOREStation Edit End - Department Hours + qdel(query_hours) if(sql_id) //Player already identified previously, we need to just update the 'lastseen', 'ip' and 'computer_id' variables var/datum/db_query/query_update = SSdbcore.NewQuery("UPDATE erro_player SET lastseen = Now(), ip = '[sql_ip]', computerid = '[sql_computerid]', lastadminrank = '[sql_admin_rank]' WHERE id = [sql_id]") query_update.Execute() + qdel(query_update) else //New player!! Need to insert all the stuff var/datum/db_query/query_insert = SSdbcore.NewQuery("INSERT INTO erro_player (id, ckey, firstseen, lastseen, ip, computerid, lastadminrank) VALUES (null, '[sql_ckey]', Now(), Now(), '[sql_ip]', '[sql_computerid]', '[sql_admin_rank]')") query_insert.Execute() + qdel(query_insert) //Logging player access var/serverip = "[world.internet_address]:[world.port]" var/datum/db_query/query_accesslog = SSdbcore.NewQuery("INSERT INTO `erro_connection_log`(`id`,`datetime`,`serverip`,`ckey`,`ip`,`computerid`) VALUES(null,Now(),'[serverip]','[sql_ckey]','[sql_ip]','[sql_computerid]');") query_accesslog.Execute() + qdel(query_accesslog) #undef UPLOAD_LIMIT #undef MIN_CLIENT_VERSION diff --git a/code/modules/library/lib_machines.dm b/code/modules/library/lib_machines.dm index 1c115ffac53..0dfc2f4f9a1 100644 --- a/code/modules/library/lib_machines.dm +++ b/code/modules/library/lib_machines.dm @@ -297,6 +297,7 @@ if(show_admin_options) // This isn't the only check, since you can just href-spoof press this button. Just to tidy things up. dat += "\[Del\]" dat += "" + qdel(query) dat += "" dat += "
(Return to main menu)
" @@ -457,6 +458,7 @@ else log_game("[usr.name]/[usr.key] has uploaded the book titled [scanner.cache.name], [length(scanner.cache.dat)] signs") tgui_alert_async(usr, "Upload Complete.") + qdel(query) //VOREStation Edit End if(href_list["targetid"]) @@ -487,6 +489,7 @@ B.item_state = B.icon_state src.visible_message("[src]'s printer hums as it produces a completely bound book. How did it do that?") break + qdel(query) if(href_list["delid"]) if(!check_rights(R_ADMIN)) diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index 387c6e01d41..dbf695b23d1 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -83,6 +83,7 @@ while(query.NextRow()) newpoll = 1 break + qdel(query) if(newpoll) output += "

Show Player Polls (NEW!)

" @@ -244,6 +245,7 @@ while(query.NextRow()) voted = 1 break + qdel(query) //This is a safety switch, so only valid options pass through var/option = "UNKNOWN" diff --git a/code/modules/mob/new_player/poll.dm b/code/modules/mob/new_player/poll.dm index 751b3ebd997..5225ed1e82f 100644 --- a/code/modules/mob/new_player/poll.dm +++ b/code/modules/mob/new_player/poll.dm @@ -10,7 +10,7 @@ while(query.NextRow()) voted = 1 break - + qdel(query) if(!voted) privacy_poll() @@ -72,7 +72,7 @@ pollquestion = select_query.item[2] output += "[pollquestion]" i++ - + qdel(select_query) output += "" src << browse("[output]","window=playerpolllist;size=500x300") @@ -101,7 +101,7 @@ polltype = select_query.item[4] found = 1 break - + qdel(select_query) if(!found) to_chat(usr, span_red("Poll question details not found.")) return @@ -118,7 +118,7 @@ votedoptionid = text2num(voted_query.item[1]) voted = 1 break - + qdel(voted_query) var/list/datum/polloption/options = list() var/datum/db_query/options_query = SSdbcore.NewQuery("SELECT id, text FROM erro_poll_option WHERE pollid = [pollid]") @@ -128,7 +128,7 @@ PO.optionid = text2num(options_query.item[1]) PO.optiontext = options_query.item[2] options += PO - + qdel(options_query) var/output = "
Player poll" output +="
" output += span_bold("Question: [pollquestion]") + "
" @@ -171,6 +171,7 @@ vote_text = voted_query.item[1] voted = 1 break + qdel(voted_query) var/output = "
Player poll" @@ -220,7 +221,7 @@ var/rating = voted_query.item[2] output += "
[optiontext] - [rating]" - + qdel(voted_query) if(!voted) //Only make this a form if we have not voted yet output += "
" output += "" @@ -264,7 +265,7 @@ output += "" output += "" - + qdel(option_query) output += "" output += "" @@ -281,7 +282,7 @@ while(voted_query.NextRow()) votedfor.Add(text2num(voted_query.item[1])) voted = 1 - + qdel(voted_query) var/list/datum/polloption/options = list() var/maxoptionid = 0 var/minoptionid = 0 @@ -297,7 +298,7 @@ if(PO.optionid < minoptionid || !minoptionid) minoptionid = PO.optionid options += PO - + qdel(options_query) if(select_query.item[5]) multiplechoiceoptions = text2num(select_query.item[5]) @@ -358,7 +359,7 @@ if(select_query.item[5]) multiplechoiceoptions = text2num(select_query.item[5]) break - + qdel(select_query) if(!validpoll) to_chat(usr, span_red("Poll is not valid.")) return @@ -386,7 +387,7 @@ alreadyvoted += 1 if(!multichoice) break - + qdel(voted_query) if(!multichoice && alreadyvoted) to_chat(usr, span_red("You already voted in this poll.")) return @@ -404,6 +405,7 @@ insert_query.Execute() to_chat(usr, span_blue("Vote successful.")) + qdel(insert_query) usr << browse(null,"window=playerpoll") @@ -426,6 +428,7 @@ return validpoll = 1 break + qdel(select_query) if(!validpoll) to_chat(usr, span_red("Poll is not valid.")) @@ -439,7 +442,7 @@ while(voted_query.NextRow()) alreadyvoted = 1 break - + qdel(voted_query) if(alreadyvoted) to_chat(usr, span_red("You already sent your feedback for this poll.")) return @@ -462,6 +465,7 @@ insert_query.Execute() to_chat(usr, span_blue("Feedback logging successful.")) + qdel(insert_query) usr << browse(null,"window=playerpoll") @@ -484,7 +488,7 @@ return validpoll = 1 break - + qdel(select_query) if(!validpoll) to_chat(usr, span_red("Poll is not valid.")) return @@ -497,6 +501,7 @@ while(select_query2.NextRow()) validoption = 1 break + qdel(select_query2) if(!validoption) to_chat(usr, span_red("Poll option is not valid.")) @@ -510,7 +515,7 @@ while(voted_query.NextRow()) alreadyvoted = 1 break - + qdel(voted_query) if(alreadyvoted) to_chat(usr, span_red("You already voted in this poll.")) return @@ -524,4 +529,5 @@ insert_query.Execute() to_chat(usr, span_blue("Vote successful.")) + qdel(insert_query) usr << browse(null,"window=playerpoll") diff --git a/code/modules/research/message_server.dm b/code/modules/research/message_server.dm index 2c5aae52e57..35bff91b60f 100644 --- a/code/modules/research/message_server.dm +++ b/code/modules/research/message_server.dm @@ -355,7 +355,7 @@ var/obj/machinery/blackbox_recorder/blackbox query.Execute() while(query.NextRow()) round_id = query.item[1] - + qdel(query) if(!isnum(round_id)) round_id = text2num(round_id) round_id++ @@ -364,6 +364,7 @@ var/obj/machinery/blackbox_recorder/blackbox var/sql = "INSERT INTO erro_feedback VALUES (null, Now(), [round_id], \"[FV.get_variable()]\", [FV.get_value()], \"[FV.get_details()]\")" var/datum/db_query/query_insert = SSdbcore.NewQuery(sql) query_insert.Execute() + qdel(query_insert) // Sanitize inputs to avoid SQL injection attacks /proc/sql_sanitize_text(var/text) diff --git a/code/modules/tgs/v5/chat_commands.dm b/code/modules/tgs/v5/chat_commands.dm index d6df106afb2..43993e2a2a4 100644 --- a/code/modules/tgs/v5/chat_commands.dm +++ b/code/modules/tgs/v5/chat_commands.dm @@ -95,8 +95,9 @@ GLOBAL_LIST_EMPTY(pending_discord_registrations) var/datum/db_query/query = SSdbcore.NewQuery("SELECT discord_id FROM erro_player WHERE discord_id = '[sql_discord]'") query.Execute() if(query.NextRow()) + qdel(query) return "[sender.friendly_name], your Discord ID is already registered to a Byond username. Please contact an administrator if you changed your Byond username or Discord ID." - + qdel(query) var/key_to_find = "[ckey(params)]" // They didn't provide anything worth looking up. @@ -120,12 +121,14 @@ GLOBAL_LIST_EMPTY(pending_discord_registrations) // We somehow found their client, BUT they don't exist in the database if(!query.NextRow()) + qdel(query) return "[sender.friendly_name], the server's database is either not responding or there's no evidence you've ever logged in. Please contact an administrator." // We found them in the database, AND they already have a discord ID assigned if(query.item[1]) + qdel(query) return "[sender.friendly_name], it appears you've already registered your chat and game IDs. If you've changed game or chat usernames, please contact an administrator for help." - + qdel(query) // Okay. We found them, they're in the DB, and they have no discord ID set. var/message = span_notice("A request has been sent from Discord to validate your Byond username, by '[sender.friendly_name]' in '[sender.channel.friendly_name]'") + "\
" + span_warning("If you did not send this request, do not click the link below, and do notify an administrator in-game or on Discord ASAP.") + "\