[MIRROR] Moving the database to a subsystem (#9963)

Co-authored-by: Selis <12716288+ItsSelis@users.noreply.github.com>
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2025-01-29 03:25:00 -07:00
committed by GitHub
parent 26ff936832
commit 40e935a774
33 changed files with 559 additions and 310 deletions

View File

@@ -371,24 +371,23 @@ var/obj/machinery/blackbox_recorder/blackbox
round_end_data_gathering() //round_end time logging and some other data processing
establish_db_connection()
if(!SSdbcore.IsConnected()) return //CHOMPEdit TGSQL
if(!SSdbcore.IsConnected()) return
var/round_id
var/datum/db_query/query = SSdbcore.NewQuery("SELECT MAX(round_id) AS round_id FROM erro_feedback") //CHOMPEdit TGSQL
var/datum/db_query/query = SSdbcore.NewQuery("SELECT MAX(round_id) AS round_id FROM erro_feedback")
query.Execute()
while(query.NextRow())
round_id = query.item[1]
qdel(query) //CHOMPEdit TGSQL
qdel(query)
if(!isnum(round_id))
round_id = text2num(round_id)
round_id++
for(var/datum/feedback_variable/FV in feedback)
var/list/sqlargs = list("t_roundid" = round_id, "t_variable" = "[FV.get_variable()]", "t_value" = "[FV.get_value()]", "t_details" = "[FV.get_details()]") //CHOMPEdit TGSQL
var/sql = "INSERT INTO erro_feedback VALUES (null, Now(), :t_roundid, :t_variable, :t_value, :t_details)" //CHOMPEdit TGSQL
var/datum/db_query/query_insert = SSdbcore.NewQuery(sql, sqlargs) //CHOMPEdit TGSQL
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) //CHOMPEdit TGSQL
qdel(query_insert)
// Sanitize inputs to avoid SQL injection attacks //CHOMPEdit NOTE: This is not secure. Basic filters like this are pretty easy to bypass. Use the format for arguments used in the above.
/proc/sql_sanitize_text(var/text)