mirror of
https://github.com/Aurorastation/Aurora-Old.git
synced 2026-08-28 15:16:21 +01:00
SQL backstage update
Since Aurora only has one SQL database, I've removed the old database proc and object (dbcon_old). It'll make everything connect to the same database, and be less of a hassle with the config files.
This commit is contained in:
@@ -608,12 +608,6 @@
|
||||
sqllogin = value
|
||||
if ("password")
|
||||
sqlpass = value
|
||||
if ("feedback_database")
|
||||
sqlfdbkdb = value
|
||||
if ("feedback_login")
|
||||
sqlfdbklogin = value
|
||||
if ("feedback_password")
|
||||
sqlfdbkpass = value
|
||||
if ("enable_stat_tracking")
|
||||
sqllogging = 1
|
||||
else
|
||||
|
||||
@@ -10,7 +10,7 @@ proc/sql_poll_players()
|
||||
log_game("SQL ERROR during player polling. Failed to connect.")
|
||||
else
|
||||
var/sqltime = time2text(world.realtime, "YYYY-MM-DD hh:mm:ss")
|
||||
var/DBQuery/query = dbcon_old.NewQuery("INSERT INTO population (playercount, time) VALUES ([playercount], '[sqltime]')")
|
||||
var/DBQuery/query = dbcon.NewQuery("INSERT INTO population (playercount, time) VALUES ([playercount], '[sqltime]')")
|
||||
if(!query.Execute())
|
||||
var/err = query.ErrorMsg()
|
||||
log_game("SQL ERROR during player polling. Error : \[[err]\]\n")
|
||||
@@ -24,7 +24,7 @@ proc/sql_poll_admins()
|
||||
log_game("SQL ERROR during admin polling. Failed to connect.")
|
||||
else
|
||||
var/sqltime = time2text(world.realtime, "YYYY-MM-DD hh:mm:ss")
|
||||
var/DBQuery/query = dbcon_old.NewQuery("INSERT INTO population (admincount, time) VALUES ([admincount], '[sqltime]')")
|
||||
var/DBQuery/query = dbcon.NewQuery("INSERT INTO population (admincount, time) VALUES ([admincount], '[sqltime]')")
|
||||
if(!query.Execute())
|
||||
var/err = query.ErrorMsg()
|
||||
log_game("SQL ERROR during admin polling. Error : \[[err]\]\n")
|
||||
@@ -49,7 +49,7 @@ proc/sql_poll_population()
|
||||
log_game("SQL ERROR during population polling. Failed to connect.")
|
||||
else
|
||||
var/sqltime = time2text(world.realtime, "YYYY-MM-DD hh:mm:ss")
|
||||
var/DBQuery/query = dbcon_old.NewQuery("INSERT INTO population (playercount, admincount, time) VALUES ([playercount], [admincount], '[sqltime]')")
|
||||
var/DBQuery/query = dbcon.NewQuery("INSERT INTO population (playercount, admincount, time) VALUES ([playercount], [admincount], '[sqltime]')")
|
||||
if(!query.Execute())
|
||||
var/err = query.ErrorMsg()
|
||||
log_game("SQL ERROR during population polling. Error: \[[err]\]\n")
|
||||
|
||||
@@ -234,12 +234,6 @@ var/sqldb = "tgstation"
|
||||
var/sqllogin = "root"
|
||||
var/sqlpass = ""
|
||||
|
||||
// Feedback gathering sql connection
|
||||
|
||||
var/sqlfdbkdb = "test"
|
||||
var/sqlfdbklogin = "root"
|
||||
var/sqlfdbkpass = ""
|
||||
|
||||
var/sqllogging = 0 // Should we log deaths, population stats, etc?
|
||||
|
||||
|
||||
@@ -264,7 +258,6 @@ var/custom_event_msg = null
|
||||
//Database connections
|
||||
//A connection is established on world creation. Ideally, the connection dies when the server restarts (After feedback logging.).
|
||||
var/DBConnection/dbcon = new() //Feedback database (New database)
|
||||
var/DBConnection/dbcon_old = new() //Tgstation database (Old database) - See the files in the SQL folder for information what goes where.
|
||||
|
||||
// Reference list for disposal sort junctions. Filled up by sorting junction's New()
|
||||
/var/list/tagger_locations = list()
|
||||
|
||||
@@ -43,8 +43,8 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
<A href='?src=\ref[src];setauthor=1'>Filter by Author: [author]</A><BR>
|
||||
<A href='?src=\ref[src];search=1'>\[Start Search\]</A><BR>"}
|
||||
if(1)
|
||||
establish_old_db_connection()
|
||||
if(!dbcon_old.IsConnected())
|
||||
establish_db_connection()
|
||||
if(!dbcon.IsConnected())
|
||||
dat += "<font color=red><b>ERROR</b>: Unable to contact External Archive. Please contact your system administrator for assistance.</font><BR>"
|
||||
else if(!SQLquery)
|
||||
dat += "<font color=red><b>ERROR</b>: Malformed search request. Please contact your system administrator for assistance.</font><BR>"
|
||||
@@ -52,7 +52,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
dat += {"<table>
|
||||
<tr><td>AUTHOR</td><td>TITLE</td><td>CATEGORY</td><td>SS<sup>13</sup>BN</td></tr>"}
|
||||
|
||||
var/DBQuery/query = dbcon_old.NewQuery(SQLquery)
|
||||
var/DBQuery/query = dbcon.NewQuery(SQLquery)
|
||||
query.Execute()
|
||||
|
||||
while(query.NextRow())
|
||||
@@ -189,15 +189,15 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
<A href='?src=\ref[src];switchscreen=0'>(Return to main menu)</A><BR>"}
|
||||
if(4)
|
||||
dat += "<h3>External Archive</h3>"
|
||||
establish_old_db_connection()
|
||||
if(!dbcon_old.IsConnected())
|
||||
establish_db_connection()
|
||||
if(!dbcon.IsConnected())
|
||||
dat += "<font color=red><b>ERROR</b>: Unable to contact External Archive. Please contact your system administrator for assistance.</font>"
|
||||
else
|
||||
dat += {"<A href='?src=\ref[src];orderbyid=1'>(Order book by SS<sup>13</sup>BN)</A><BR><BR>
|
||||
<table>
|
||||
<tr><td>AUTHOR</td><td>TITLE</td><td>CATEGORY</td><td></td></tr>"}
|
||||
|
||||
var/DBQuery/query = dbcon_old.NewQuery("SELECT id, author, title, category FROM library")
|
||||
var/DBQuery/query = dbcon.NewQuery("SELECT id, author, title, category FROM library")
|
||||
query.Execute()
|
||||
|
||||
while(query.NextRow())
|
||||
@@ -332,8 +332,8 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
if(scanner.cache.unique)
|
||||
alert("This book has been rejected from the database. Aborting!")
|
||||
else
|
||||
establish_old_db_connection()
|
||||
if(!dbcon_old.IsConnected())
|
||||
establish_db_connection()
|
||||
if(!dbcon.IsConnected())
|
||||
alert("Connection to Archive has been severed. Aborting.")
|
||||
else
|
||||
/*
|
||||
@@ -347,7 +347,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
var/sqlcontent = sanitizeSQL(scanner.cache.dat)
|
||||
var/sqlcategory = sanitizeSQL(upload_category)
|
||||
var/sqluploader = sanitizeSQL(usr.key)
|
||||
var/DBQuery/query = dbcon_old.NewQuery("INSERT INTO library (author, title, content, category, uploadtime, uploader) VALUES ('[sqlauthor]', '[sqltitle]', '[sqlcontent]', '[sqlcategory]', Now(), '[sqluploader]')")
|
||||
var/DBQuery/query = dbcon.NewQuery("INSERT INTO library (author, title, content, category, uploadtime, uploader) VALUES ('[sqlauthor]', '[sqltitle]', '[sqlcontent]', '[sqlcategory]', Now(), '[sqluploader]')")
|
||||
if(!query.Execute())
|
||||
usr << query.ErrorMsg()
|
||||
else
|
||||
@@ -356,8 +356,8 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
|
||||
if(href_list["targetid"])
|
||||
var/sqlid = sanitizeSQL(href_list["targetid"])
|
||||
establish_old_db_connection()
|
||||
if(!dbcon_old.IsConnected())
|
||||
establish_db_connection()
|
||||
if(!dbcon.IsConnected())
|
||||
alert("Connection to Archive has been severed. Aborting.")
|
||||
if(bibledelay)
|
||||
for (var/mob/V in hearers(src))
|
||||
@@ -366,7 +366,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
bibledelay = 1
|
||||
spawn(60)
|
||||
bibledelay = 0
|
||||
var/DBQuery/query = dbcon_old.NewQuery("SELECT * FROM library WHERE id=[sqlid]")
|
||||
var/DBQuery/query = dbcon.NewQuery("SELECT * FROM library WHERE id=[sqlid]")
|
||||
query.Execute()
|
||||
|
||||
while(query.NextRow())
|
||||
|
||||
+3
-47
@@ -342,7 +342,6 @@ var/world_topic_spam_protect_time = world.timeofday
|
||||
|
||||
#define FAILED_DB_CONNECTION_CUTOFF 5
|
||||
var/failed_db_connections = 0
|
||||
var/failed_old_db_connections = 0
|
||||
|
||||
/hook/startup/proc/connectDB()
|
||||
if(!setup_database_connection())
|
||||
@@ -359,9 +358,9 @@ proc/setup_database_connection()
|
||||
if(!dbcon)
|
||||
dbcon = new()
|
||||
|
||||
var/user = sqlfdbklogin
|
||||
var/pass = sqlfdbkpass
|
||||
var/db = sqlfdbkdb
|
||||
var/user = sqllogin
|
||||
var/pass = sqlpass
|
||||
var/db = sqldb
|
||||
var/address = sqladdress
|
||||
var/port = sqlport
|
||||
|
||||
@@ -385,47 +384,4 @@ proc/establish_db_connection()
|
||||
else
|
||||
return 1
|
||||
|
||||
|
||||
/hook/startup/proc/connectOldDB()
|
||||
if(!setup_old_database_connection())
|
||||
world.log << "Your server failed to establish a connection with the SQL database."
|
||||
else
|
||||
world.log << "SQL database connection established."
|
||||
return 1
|
||||
|
||||
//These two procs are for the old database, while it's being phased out. See the tgstation.sql file in the SQL folder for more information.
|
||||
proc/setup_old_database_connection()
|
||||
|
||||
if(failed_old_db_connections > FAILED_DB_CONNECTION_CUTOFF) //If it failed to establish a connection more than 5 times in a row, don't bother attempting to conenct anymore.
|
||||
return 0
|
||||
|
||||
if(!dbcon_old)
|
||||
dbcon_old = new()
|
||||
|
||||
var/user = sqllogin
|
||||
var/pass = sqlpass
|
||||
var/db = sqldb
|
||||
var/address = sqladdress
|
||||
var/port = sqlport
|
||||
|
||||
dbcon_old.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]")
|
||||
. = dbcon_old.IsConnected()
|
||||
if ( . )
|
||||
failed_old_db_connections = 0 //If this connection succeeded, reset the failed connections counter.
|
||||
else
|
||||
failed_old_db_connections++ //If it failed, increase the failed connections counter.
|
||||
world.log << dbcon.ErrorMsg()
|
||||
|
||||
return .
|
||||
|
||||
//This proc ensures that the connection to the feedback database (global variable dbcon) is established
|
||||
proc/establish_old_db_connection()
|
||||
if(failed_old_db_connections > FAILED_DB_CONNECTION_CUTOFF)
|
||||
return 0
|
||||
|
||||
if(!dbcon_old || !dbcon_old.IsConnected())
|
||||
return setup_old_database_connection()
|
||||
else
|
||||
return 1
|
||||
|
||||
#undef FAILED_DB_CONNECTION_CUTOFF
|
||||
|
||||
Reference in New Issue
Block a user