diff --git a/baystation12.dme b/baystation12.dme
index aede49368ad..7b37efa3483 100644
--- a/baystation12.dme
+++ b/baystation12.dme
@@ -1715,6 +1715,7 @@
#include "code\modules\virus2\helpers.dm"
#include "code\modules\virus2\isolator.dm"
#include "code\modules\virus2\items_devices.dm"
+#include "code\modules\web_interface\webint_procs.dm"
#include "code\TriDimension\controller.dm"
#include "code\TriDimension\controller_presets.dm"
#include "code\TriDimension\Movement.dm"
diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm
index 4b00ae7af1c..ec7719154c9 100644
--- a/code/controllers/configuration.dm
+++ b/code/controllers/configuration.dm
@@ -209,6 +209,9 @@ var/list/gamemode_cache = list()
var/aggressive_changelog = 0
+ //Web interface settings
+ var/webint_url = ""
+
/datum/configuration/New()
var/list/L = typesof(/datum/game_mode) - /datum/game_mode
for (var/T in L)
@@ -278,7 +281,7 @@ var/list/gamemode_cache = list()
config.log_access = 1
if ("sql_enabled")
- config.sql_enabled = text2num(value)
+ config.sql_enabled = 1
if ("log_say")
config.log_say = 1
@@ -678,6 +681,9 @@ var/list/gamemode_cache = list()
if("show_auxiliary_roles")
config.show_auxiliary_roles = 1
+ if("webint_url")
+ config.webint_url = value
+
else
log_misc("Unknown setting in configuration: '[name]'")
@@ -741,88 +747,6 @@ var/list/gamemode_cache = list()
else
log_misc("Unknown setting in configuration: '[name]'")
-/datum/configuration/proc/loadsql(filename) // -- TLE
- var/list/Lines = file2list(filename)
- for(var/t in Lines)
- if(!t) continue
-
- t = trim(t)
- if (length(t) == 0)
- continue
- else if (copytext(t, 1, 2) == "#")
- continue
-
- var/pos = findtext(t, " ")
- var/name = null
- var/value = null
-
- if (pos)
- name = lowertext(copytext(t, 1, pos))
- value = copytext(t, pos + 1)
- else
- name = lowertext(t)
-
- if (!name)
- continue
-
- switch (name)
- if ("address")
- sqladdress = value
- if ("port")
- sqlport = value
- if ("database")
- sqldb = value
- if ("login")
- sqllogin = value
- if ("password")
- sqlpass = value
- if ("enable_stat_tracking")
- sqllogging = 1
- else
- log_misc("Unknown setting in configuration: '[name]'")
-
-/datum/configuration/proc/loadforumsql(filename) // -- TLE
- var/list/Lines = file2list(filename)
- for(var/t in Lines)
- if(!t) continue
-
- t = trim(t)
- if (length(t) == 0)
- continue
- else if (copytext(t, 1, 2) == "#")
- continue
-
- var/pos = findtext(t, " ")
- var/name = null
- var/value = null
-
- if (pos)
- name = lowertext(copytext(t, 1, pos))
- value = copytext(t, pos + 1)
- else
- name = lowertext(t)
-
- if (!name)
- continue
-
- switch (name)
- if ("address")
- forumsqladdress = value
- if ("port")
- forumsqlport = value
- if ("database")
- forumsqldb = value
- if ("login")
- forumsqllogin = value
- if ("password")
- forumsqlpass = value
- if ("activatedgroup")
- forum_activated_group = value
- if ("authenticatedgroup")
- forum_authenticated_group = value
- else
- log_misc("Unknown setting in configuration: '[name]'")
-
/datum/configuration/proc/pick_mode(mode_name)
// I wish I didn't have to instance the game modes in order to look up
// their information, but it is the only way (at least that I know of).
diff --git a/code/controllers/news_controller.dm b/code/controllers/news_controller.dm
index 1598fc8a226..f8d9ce3c808 100644
--- a/code/controllers/news_controller.dm
+++ b/code/controllers/news_controller.dm
@@ -27,7 +27,7 @@ var/global/datum/news_controller/news_controller
//Stores a new article for publishing.
/datum/news_controller/proc/update()
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
error("SQL database connection failed. News_controller failed to retreive information.")
fails++
@@ -52,7 +52,7 @@ var/global/datum/news_controller/news_controller
//Publish the stored article.
/datum/news_controller/proc/publish()
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
error("SQL database connection failed. News_controller failed to retreive information.")
fails++
diff --git a/code/defines/procs/dbcore.dm b/code/defines/procs/dbcore.dm
index cd5f5dcdbd9..166896587cf 100644
--- a/code/defines/procs/dbcore.dm
+++ b/code/defines/procs/dbcore.dm
@@ -31,45 +31,47 @@
#define BLOB 14
// TODO: Investigate more recent type additions and see if I can handle them. - Nadrew
-
-// Deprecated! See global.dm for new configuration vars
-/*
-var/DB_SERVER = "" // This is the location of your MySQL server (localhost is USUALLY fine)
-var/DB_PORT = 3306 // This is the port your MySQL server is running on (3306 is the default)
-*/
-
DBConnection
var/_db_con // This variable contains a reference to the actual database connection.
- var/dbi // This variable is a string containing the DBI MySQL requires.
- var/user // This variable contains the username data.
- var/password // This variable contains the password data.
- var/default_cursor // This contains the default database cursor data.
- //
- var/server = ""
- var/port = 3306
+ var/con_dbi // This variable is a string containing the DBI MySQL requires.
+ var/con_user // This variable contains the username data.
+ var/con_password // This variable contains the password data.
+ var/con_cursor // This contains the default database cursor data.
+ var/con_server = ""
+ var/con_port = 3306
+ var/con_database = ""
+ var/failed_connections = 0
+
+DBConnection/New(server, port = 3306, database, username, password_handler, cursor_handler = Default_Cursor, dbi_handler)
+ con_user = username
+ con_password = password_handler
+ con_cursor = cursor_handler
+ con_server = server
+ con_port = port
+ con_database = database
+
+ if (dbi_handler)
+ con_dbi = dbi_handler
+ else
+ con_dbi = "dbi:mysql:[database]:[server]:[port]"
-DBConnection/New(dbi_handler, username, password_handler, cursor_handler)
- dbi = dbi_handler
- user = username
- password = password_handler
- default_cursor = cursor_handler
_db_con = _dm_db_new_con()
-DBConnection/proc/Connect(dbi_handler = dbi, user_handler = user, password_handler = password, cursor_handler)
- if (!sqllogging)
+DBConnection/proc/Connect(dbi_handler = con_dbi, user_handler = con_user, password_handler = con_password, cursor_handler)
+ if (!config.sql_enabled)
return 0
if (!src)
return 0
- cursor_handler = default_cursor
+ cursor_handler = con_cursor
if (!cursor_handler)
cursor_handler = Default_Cursor
- return _dm_db_connect(_db_con,dbi_handler, user_handler, password_handler, cursor_handler, null)
+ return _dm_db_connect(_db_con, dbi_handler, user_handler, password_handler, cursor_handler, null)
DBConnection/proc/Disconnect()
return _dm_db_close(_db_con)
DBConnection/proc/IsConnected()
- if(!sqllogging)
+ if(!config.sql_enabled)
return 0
var/success = _dm_db_is_connected(_db_con)
return success
@@ -80,12 +82,13 @@ DBConnection/proc/Quote(str)
DBConnection/proc/ErrorMsg()
return _dm_db_error_msg(_db_con)
-DBConnection/proc/SelectDB(database_name,dbi)
- if(IsConnected()) Disconnect()
- //return Connect("[dbi?"[dbi]":"dbi:mysql:[database_name]:[DB_SERVER]:[DB_PORT]"]",user,password)
- return Connect("[dbi?"[dbi]":"dbi:mysql:[database_name]:[sqladdress]:[sqlport]"]", user, password)
+DBConnection/proc/SelectDB(database_name, new_dbi)
+ if (IsConnected())
+ Disconnect()
+ con_database = database_name
+ return Connect(new_dbi ? new_dbi : "dbi:mysql:[database_name]:[con_server]:[con_port]", con_user, con_password)
-DBConnection/proc/NewQuery(sql_query, cursor_handler = default_cursor)
+DBConnection/proc/NewQuery(sql_query, cursor_handler = con_cursor)
return new/DBQuery(sql_query, src, cursor_handler)
DBQuery
@@ -194,12 +197,12 @@ DBQuery/proc/parseArguments(var/query_to_parse = null, var/list/argument_list, v
var/argument = argument_list[placeholder]
- if (isnull(argument))
- argument = "NULL"
- else if (istext(argument))
+ if (istext(argument))
argument = dbcon.Quote(argument)
else if (isnum(argument))
- argument = "'[argument]'"
+ argument = "[argument]"
+ else if (isnull(argument))
+ argument = "NULL"
else
log_debug("parseArguments() failed! Cannot identify argument!")
return 0
diff --git a/code/defines/procs/statistics.dm b/code/defines/procs/statistics.dm
index 01c97f4fcfc..e807e4cbbce 100644
--- a/code/defines/procs/statistics.dm
+++ b/code/defines/procs/statistics.dm
@@ -1,12 +1,12 @@
proc/sql_poll_population()
- if(!sqllogging)
+ if(!config.sql_enabled)
return
var/admincount = admins.len
var/playercount = 0
for(var/mob/M in player_list)
if(M.client)
playercount += 1
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
log_game("SQL ERROR during population polling. Failed to connect.")
else
@@ -18,15 +18,15 @@ proc/sql_poll_population()
proc/sql_report_round_start()
// TODO
- if(!sqllogging)
+ if(!config.sql_enabled)
return
proc/sql_report_round_end()
// TODO
- if(!sqllogging)
+ if(!config.sql_enabled)
return
proc/sql_report_death(var/mob/living/carbon/human/H)
- if(!sqllogging)
+ if(!config.sql_enabled)
return
if(!H)
return
@@ -49,7 +49,7 @@ proc/sql_report_death(var/mob/living/carbon/human/H)
var/sqltime = time2text(world.realtime, "YYYY-MM-DD hh:mm:ss")
var/coord = "[H.x], [H.y], [H.z]"
//world << "INSERT INTO death (name, byondkey, job, special, pod, tod, laname, lakey, gender, bruteloss, fireloss, brainloss, oxyloss) VALUES ('[sqlname]', '[sqlkey]', '[sqljob]', '[sqlspecial]', '[sqlpod]', '[sqltime]', '[laname]', '[lakey]', '[H.gender]', [H.bruteloss], [H.getFireLoss()], [H.brainloss], [H.getOxyLoss()])"
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
log_game("SQL ERROR during death reporting. Failed to connect.")
else
@@ -60,7 +60,7 @@ proc/sql_report_death(var/mob/living/carbon/human/H)
proc/sql_report_cyborg_death(var/mob/living/silicon/robot/H)
- if(!sqllogging)
+ if(!config.sql_enabled)
return
if(!H)
return
@@ -83,7 +83,7 @@ proc/sql_report_cyborg_death(var/mob/living/silicon/robot/H)
var/sqltime = time2text(world.realtime, "YYYY-MM-DD hh:mm:ss")
var/coord = "[H.x], [H.y], [H.z]"
//world << "INSERT INTO death (name, byondkey, job, special, pod, tod, laname, lakey, gender, bruteloss, fireloss, brainloss, oxyloss) VALUES ('[sqlname]', '[sqlkey]', '[sqljob]', '[sqlspecial]', '[sqlpod]', '[sqltime]', '[laname]', '[lakey]', '[H.gender]', [H.bruteloss], [H.getFireLoss()], [H.brainloss], [H.getOxyLoss()])"
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
log_game("SQL ERROR during death reporting. Failed to connect.")
else
@@ -94,7 +94,7 @@ proc/sql_report_cyborg_death(var/mob/living/silicon/robot/H)
proc/statistic_cycle()
- if(!sqllogging)
+ if(!config.sql_enabled)
return
while(1)
sql_poll_population()
@@ -113,7 +113,7 @@ proc/sql_commit_feedback()
log_game("Round ended without any feedback being generated. No feedback was sent to the database.")
return
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
log_game("SQL ERROR during feedback reporting. Failed to connect.")
else
diff --git a/code/game/antagonist/outsider/raider.dm b/code/game/antagonist/outsider/raider.dm
index fcb0e1d2b73..1e4a481e4dc 100644
--- a/code/game/antagonist/outsider/raider.dm
+++ b/code/game/antagonist/outsider/raider.dm
@@ -220,6 +220,11 @@ var/datum/antagonist/raider/raiders
player.equip_to_slot_or_del(new new_suit(player),slot_wear_suit)
equip_weapons(player)
+ //Try to equip it, del if we fail.
+ var/obj/item/device/contract_uplink/new_uplink = new()
+ if (!player.equip_to_appropriate_slot(new_uplink))
+ qdel(new_uplink)
+
var/obj/item/weapon/card/id/id = create_id("Visitor", player, equip = 0)
id.name = "[player.real_name]'s Passport"
id.assignment = "Visitor"
@@ -311,4 +316,3 @@ var/datum/antagonist/raider/raiders
player.internals.icon_state = "internal1"
return 1
-
diff --git a/code/game/jobs/whitelist.dm b/code/game/jobs/whitelist.dm
index b6f16388be7..28b216654d3 100644
--- a/code/game/jobs/whitelist.dm
+++ b/code/game/jobs/whitelist.dm
@@ -9,7 +9,7 @@ var/list/whitelist = list()
/proc/load_whitelist()
if (config.sql_whitelists)
- establish_db_connection()
+ establish_db_connection(dbcon)
if (!dbcon.IsConnected())
//Continue with the old code if we have no database.
@@ -43,7 +43,7 @@ var/list/whitelist = list()
/proc/load_alienwhitelist()
if (config.sql_whitelists)
- establish_db_connection()
+ establish_db_connection(dbcon)
if (!dbcon.IsConnected())
//Continue with the old code if we have no database.
diff --git a/code/game/machinery/requests_console.dm b/code/game/machinery/requests_console.dm
index d4beeb78ea1..c3f9ee71080 100644
--- a/code/game/machinery/requests_console.dm
+++ b/code/game/machinery/requests_console.dm
@@ -211,7 +211,7 @@ var/list/obj/machinery/requests_console/allConsoles = list()
if(11) //form database
dat += text("NanoTrasen Corporate Forms
")
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
dat += text("ERROR: Unable to contact external database. Please contact your system administrator for assistance.")
log_game("SQL database connection failed. Attempted to fetch form information.")
@@ -377,7 +377,7 @@ var/list/obj/machinery/requests_console/allConsoles = list()
if(href_list["print"])
var/printid = sanitizeSQL(href_list["print"])
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
alert("Connection to the database lost. Aborting.")
@@ -405,7 +405,7 @@ var/list/obj/machinery/requests_console/allConsoles = list()
if(href_list["whatis"])
var/whatisid = sanitizeSQL(href_list["whatis"])
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
alert("Connection to the database lost. Aborting.")
if(!whatisid)
diff --git a/code/game/objects/items/devices/scanners.dm b/code/game/objects/items/devices/scanners.dm
index c0275461962..691f56de1b3 100644
--- a/code/game/objects/items/devices/scanners.dm
+++ b/code/game/objects/items/devices/scanners.dm
@@ -178,9 +178,9 @@ REAGENT SCANNER
user.show_message(text("\red Warning: [D.form] Detected\nName: [D.name].\nType: [D.spread].\nStage: [D.stage]/[D.max_stages].\nPossible Cure: [D.cure]"))
// if (M.reagents && M.reagents.get_reagent_amount("inaprovaline"))
// user.show_message("\blue Bloodstream Analysis located [M.reagents:get_reagent_amount("inaprovaline")] units of rejuvenation chemicals.")
- if (M.has_brain_worms())
- user.show_message("\red Subject suffering from aberrant brain activity. Recommend further scanning.")
- else if (M.getBrainLoss() >= 100 || !M.has_brain())
+// if (M.has_brain_worms())
+// user.show_message("\red Subject suffering from aberrant brain activity. Recommend further scanning.") //Cortical borer disable
+ if (M.getBrainLoss() >= 100 || !M.has_brain())
user.show_message("\red Subject is brain dead.")
else if (M.getBrainLoss() >= 60)
user.show_message("\red Severe brain damage detected. Subject likely to have mental retardation.")
diff --git a/code/game/objects/items/devices/uplinks.dm b/code/game/objects/items/devices/uplinks.dm
index c8f23054e4d..2fbf1f99732 100644
--- a/code/game/objects/items/devices/uplinks.dm
+++ b/code/game/objects/items/devices/uplinks.dm
@@ -213,6 +213,9 @@ datum/nano_item_lists
data["welcome"] = welcome
data["crystals"] = uses
data["menu"] = nanoui_menu
+ //Small hack for the contract_uplink device, to make sure the data is initialized properly.
+ if(nanoui_menu == 2)
+ update_nano_data()
if(!nanoui_items)
generate_items()
data["nano_items"] = nanoui_items
@@ -257,6 +260,16 @@ datum/nano_item_lists
if(href_list["menu"])
nanoui_menu = text2num(href_list["menu"])
update_nano_data(href_list["id"])
+ if(href_list["contract_interact"])
+ var/list/params = list("location" = "contract_details", "contract" = href_list["contract_interact"])
+ usr.client.process_webint_link("interface/login/sso_server", list2params(params))
+ if(href_list["contract_page"])
+ nanoui_data["contracts_current_page"] = text2num(href_list["contract_page"])
+ update_nano_data()
+ if(href_list["contract_view"])
+ nanoui_data["contracts_view"] = text2num(href_list["contract_view"])
+ nanoui_data["contracts_current_page"] = 1
+ update_nano_data()
interact(usr)
return 1
@@ -292,6 +305,108 @@ datum/nano_item_lists
nanoui_data["exploit_exists"] = 1
break
+ if(nanoui_menu == 2)
+ nanoui_data["contracts_found"] = 0
+
+ establish_db_connection(dbcon)
+
+ if (dbcon.IsConnected())
+ nanoui_data["contracts"] = list()
+
+ if (!nanoui_data["contracts_current_page"])
+ nanoui_data["contracts_current_page"] = 1
+
+ if (!nanoui_data["contracts_view"])
+ nanoui_data["contracts_view"] = 1
+
+ var/query_details[0]
+
+ switch (nanoui_data["contracts_view"])
+ if (1)
+ query_details[":status"] = "open"
+ if (2)
+ query_details[":status"] = "closed"
+ else
+ nanoui_data["contracts_view"] = 1
+ 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")
+ index_query.Execute(query_details)
+
+ var/pages = 0
+
+ if (index_query.NextRow())
+ var/total_contracts = text2num(index_query.item[1])
+
+ pages = total_contracts / 10
+
+ if (total_contracts % 10)
+ pages++
+
+ pages = round(pages)
+
+ var/list/contracts_pages = list()
+
+ for (var/i = 1, i <= pages, i++)
+ contracts_pages.Add(i)
+
+ for (var/a in contracts_pages)
+
+ nanoui_data["contracts_pages"] = contracts_pages
+
+ if (nanoui_data["contracts_current_page"] > pages)
+ return
+
+ 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")
+ list_query.Execute(query_details)
+
+ var/list/contracts = list()
+ while (list_query.NextRow())
+ contracts.Add(list(list("id" = list_query.item[1],
+ "contractee" = list_query.item[2],
+ "title" = list_query.item[3])))
+
+ nanoui_data["contracts"] = contracts
+
+ nanoui_data["contracts_found"] = 1
+
+ if(nanoui_menu == 21)
+ nanoui_data["contracts_found"] = 0
+
+ establish_db_connection(dbcon)
+
+ if (dbcon.IsConnected())
+ var/query_details[0]
+ query_details[":contract_id"] = text2num(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
+
+ var/contract[0]
+ contract["id"] = select_query.item[1]
+ contract["contractee"] = select_query.item[2]
+
+ switch (select_query.item[3])
+ if ("open")
+ contract["status"] = "1"
+ else
+ contract["status"] = "0"
+
+ contract["title"] = html_encode(select_query.item[4])
+ contract["description"] = select_query.item[5]
+
+ contract["description"] = html_encode(contract["description"])
+ contract["description"] = replacetext(contract["description"], "\n", "
")
+ contract["description"] = replacetext(contract["description"], ascii2text(13), "")
+ contract["reward_other"] = select_query.item[6]
+
+ nanoui_data["contract"] = contract
+
// I placed this here because of how relevant it is.
// You place this in your uplinkable item to check if an uplink is active or not.
// If it is, it will display the uplink menu and return 1, else it'll return false.
@@ -332,3 +447,25 @@ datum/nano_item_lists
..()
hidden_uplink = new(src)
hidden_uplink.uses = 10
+
+/*
+ * A simple device for accessing the SQL based contract database
+ */
+
+/obj/item/device/contract_uplink
+ name = "contract uplink"
+ desc = "A small device used for access restricted sites in the remote corners of the Extranet."
+ icon = 'icons/obj/radio.dmi'
+ icon_state = "radio"
+ flags = CONDUCT
+ w_class = 2
+
+/obj/item/device/contract_uplink/New()
+ ..()
+ hidden_uplink = new(src)
+ hidden_uplink.uses = 0
+ hidden_uplink.nanoui_menu = 2
+
+/obj/item/device/contract_uplink/attack_self(mob/user as mob)
+ if (hidden_uplink)
+ hidden_uplink.trigger(user)
diff --git a/code/global.dm b/code/global.dm
index 626960698b1..ccb57713b0e 100644
--- a/code/global.dm
+++ b/code/global.dm
@@ -187,32 +187,14 @@ var/datum/subsystem/alarm/alarm_manager = new() // Alarm Manager, the manager fo
var/list/awaydestinations = list() // Away missions. A list of landmarks that the warpgate can take you to.
-// MySQL configuration
-var/sqladdress = "localhost"
-var/sqlport = "3306"
-var/sqldb = "tgstation"
-var/sqllogin = "root"
-var/sqlpass = ""
-var/sqllogging = 0 // Should we log deaths, population stats, etc.?
-
-// Forum MySQL configuration. (for use with forum account/key authentication)
-// These are all default values that will load should the forumdbconfig.txt file fail to read for whatever reason.
-var/forumsqladdress = "localhost"
-var/forumsqlport = "3306"
-var/forumsqldb = "tgstation"
-var/forumsqllogin = "root"
-var/forumsqlpass = ""
-var/forum_activated_group = "2"
-var/forum_authenticated_group = "10"
-
// For FTP requests. (i.e. downloading runtime logs.)
// However it'd be ok to use for accessing attack logs and such too, which are even laggier.
var/fileaccess_timer = 0
var/custom_event_msg = null
-// Database connections. A connection is established on world creation.
+// Database connections. A connection is established along with /hook/startup/proc/load_databases().
// Ideally, the connection dies when the server restarts (After feedback logging.).
-var/DBConnection/dbcon = new() // Feedback database (New database)
+var/DBConnection/dbcon
// Reference list for disposal sort junctions. Filled up by sorting junction's New()
/var/list/tagger_locations = list()
diff --git a/code/modules/admin/DB ban/ban_mirroring.dm b/code/modules/admin/DB ban/ban_mirroring.dm
index 588acbdfccb..d6af7bafbba 100644
--- a/code/modules/admin/DB ban/ban_mirroring.dm
+++ b/code/modules/admin/DB ban/ban_mirroring.dm
@@ -6,7 +6,7 @@
if (!ckey || !address || !computer_id || !ban_id)
return
- establish_db_connection()
+ establish_db_connection(dbcon)
if (!dbcon.IsConnected())
error("Ban database connection failure while attempting to mirror. Key passed for mirror handling: [ckey].")
diff --git a/code/modules/admin/DB ban/functions.dm b/code/modules/admin/DB ban/functions.dm
index e36fc4ff21f..d266eaf7295 100644
--- a/code/modules/admin/DB ban/functions.dm
+++ b/code/modules/admin/DB ban/functions.dm
@@ -4,7 +4,7 @@ datum/admins/proc/DB_ban_record(var/bantype, var/mob/banned_mob, var/duration =
if(!check_rights(R_MOD,0) && !check_rights(R_BAN)) return
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
return
@@ -122,7 +122,7 @@ datum/admins/proc/DB_ban_unban(var/ckey, var/bantype, var/job = "")
if(job)
sql += " AND job = '[job]'"
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
return
@@ -217,7 +217,7 @@ datum/admins/proc/DB_ban_unban_by_id(var/id)
var/sql = "SELECT ckey FROM ss13_ban WHERE id = [id]"
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
return
@@ -269,7 +269,7 @@ datum/admins/proc/DB_ban_unban_by_id(var/id)
if(!check_rights(R_BAN)) return
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
usr << "\red Failed to establish database connection"
return
diff --git a/code/modules/admin/IsBanned.dm b/code/modules/admin/IsBanned.dm
index da4f2af534b..37eb7cc691b 100644
--- a/code/modules/admin/IsBanned.dm
+++ b/code/modules/admin/IsBanned.dm
@@ -34,7 +34,7 @@ world/IsBanned(key,address,computer_id)
var/ckeytext = ckey(key)
- if(!establish_db_connection())
+ if(!establish_db_connection(dbcon))
error("Ban database connection failure. Key [ckeytext] not checked")
log_misc("Ban database connection failure. Key [ckeytext] not checked")
return
diff --git a/code/modules/admin/admin_ranks.dm b/code/modules/admin/admin_ranks.dm
index 27eb8b6d3f3..3049976dfad 100644
--- a/code/modules/admin/admin_ranks.dm
+++ b/code/modules/admin/admin_ranks.dm
@@ -102,7 +102,7 @@ var/list/admin_ranks = list() //list of all ranks with associated rights
else
//The current admin system uses SQL
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
error("Failed to connect to database in load_admins(). Reverting to legacy system.")
log_misc("Failed to connect to database in load_admins(). Reverting to legacy system.")
diff --git a/code/modules/admin/banjob.dm b/code/modules/admin/banjob.dm
index ae04799354c..96899fc6d9c 100644
--- a/code/modules/admin/banjob.dm
+++ b/code/modules/admin/banjob.dm
@@ -65,7 +65,7 @@ DEBUG
jobban_keylist=list()
log_admin("jobban_keylist was empty")
else
- if(!establish_db_connection())
+ if(!establish_db_connection(dbcon))
error("Database connection failed. Reverting to the legacy ban system.")
log_misc("Database connection failed. Reverting to the legacy ban system.")
config.ban_legacy_system = 1
diff --git a/code/modules/admin/permissionverbs/permissionedit.dm b/code/modules/admin/permissionverbs/permissionedit.dm
index 0969fa35d88..1af56750311 100644
--- a/code/modules/admin/permissionverbs/permissionedit.dm
+++ b/code/modules/admin/permissionverbs/permissionedit.dm
@@ -54,7 +54,7 @@
usr << "\red You do not have permission to do this!"
return
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
usr << "\red Failed to establish database connection"
@@ -104,7 +104,7 @@
usr << "\red You do not have permission to do this!"
return
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
usr << "\red Failed to establish database connection"
return
diff --git a/code/modules/admin/player_notes_sql.dm b/code/modules/admin/player_notes_sql.dm
index 1d447110771..cfd42df4b7c 100644
--- a/code/modules/admin/player_notes_sql.dm
+++ b/code/modules/admin/player_notes_sql.dm
@@ -12,7 +12,7 @@
else
query_details[":a_ckey"] = user.ckey
- establish_db_connection()
+ establish_db_connection(dbcon)
if (!dbcon.IsConnected())
alert("SQL connection failed while trying to add a note!")
return
@@ -36,7 +36,7 @@
if (!note_id || !note_edit)
return
- establish_db_connection()
+ establish_db_connection(dbcon)
if (!dbcon.IsConnected())
error("SQL connection failed while attempting to delete a note!")
return
@@ -93,7 +93,7 @@
player_ckey = ckey(player_ckey)
admin_ckey = ckey(admin_ckey)
- establish_db_connection()
+ establish_db_connection(dbcon)
if (!dbcon.IsConnected())
error("SQL connection failed while attempting to view a player's notes!")
return
@@ -187,7 +187,7 @@
if (!ckey)
return "No ckey given!"
- establish_db_connection()
+ establish_db_connection(dbcon)
if (!dbcon.IsConnected())
return "Unable to establish database connection! Aborting!"
@@ -231,7 +231,7 @@
note_list >> note_keys
msg_scopes("Establishing DB connection!")
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
msg_scopes("No DB connection!")
return
diff --git a/code/modules/admin/verbs/check_customitem_activity.dm b/code/modules/admin/verbs/check_customitem_activity.dm
index 8d701e26734..e9bbaded60b 100644
--- a/code/modules/admin/verbs/check_customitem_activity.dm
+++ b/code/modules/admin/verbs/check_customitem_activity.dm
@@ -29,7 +29,7 @@ var/inactive_keys = "None
"
if(checked_for_inactives)
return
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
return
diff --git a/code/modules/admin/verbs/warning.dm b/code/modules/admin/verbs/warning.dm
index b19454d04de..3ad7a81bfff 100644
--- a/code/modules/admin/verbs/warning.dm
+++ b/code/modules/admin/verbs/warning.dm
@@ -9,7 +9,7 @@
if (!warned_ckey || !istext(warned_ckey))
return
- establish_db_connection()
+ establish_db_connection(dbcon)
if (!dbcon.IsConnected())
usr << "Error: warn(): Database Connection failed, reverting to legacy systems."
usr.client.warn_legacy(warned_ckey)
@@ -110,7 +110,7 @@
var/dcolor = "#ffaaaa" //dark colour, severity = 1
var/ecolor = "#e3e3e3" //gray colour, expired = 1
- establish_db_connection()
+ establish_db_connection(dbcon)
if (!dbcon.IsConnected())
alert("Connection to the SQL database lost. Aborting. Please alert an Administrator or a member of staff.")
return
@@ -172,7 +172,7 @@
if (!warning_id)
return
- establish_db_connection()
+ establish_db_connection(dbcon)
if (!dbcon.IsConnected())
alert("Connection to SQL database failed while attempting to update your warning's status!")
return
@@ -191,7 +191,7 @@
var/count = 0
var/count_expire = 0
- establish_db_connection()
+ establish_db_connection(dbcon)
if (!dbcon.IsConnected())
return
@@ -239,7 +239,7 @@
var/dcolor = "#ffdddd" //dark colour, severity = 1
var/ecolor = "#e3e3e3" //gray colour, expired = 1
- establish_db_connection()
+ establish_db_connection(dbcon)
if (!dbcon.IsConnected())
alert("Connection to the SQL database lost. Aborting. Please alert the database admin!")
return
@@ -342,7 +342,7 @@
if(!warning_id || !warning_edit)
return
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
alert("Connection to the SQL database lost. Aborting. Please alert the database admin!")
return
diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm
index 09127b10095..3a936f7eb0c 100644
--- a/code/modules/client/client procs.dm
+++ b/code/modules/client/client procs.dm
@@ -74,7 +74,68 @@
if(href_list["warnview"])
warnings_check()
- ..() //redirect to hsrc.Topic()
+ if(href_list["linkingrequest"])
+ if (!config.webint_url)
+ return
+
+ if (!href_list["linkingaction"])
+ return
+
+ var/request_id = text2num(href_list["linkingrequest"])
+
+ establish_db_connection(dbcon)
+ if (!dbcon.IsConnected())
+ src << "\red Action failed! Database link could not be established!"
+ 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))
+
+ if (!check_query.NextRow())
+ src << "\red No request found!"
+ return
+
+ if (ckey(check_query.item[1]) != ckey || check_query.item[2] != "new")
+ src << "\red Request authentication failed!"
+ return
+
+ var/query_contents = ""
+ 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
+
+ feedback_message = "Account successfully linked!"
+ 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
+
+ feedback_message = "Link request rejected!"
+ else
+ src << "\red Invalid command sent."
+ return
+
+ var/DBQuery/update_query = dbcon.NewQuery(query_contents)
+ update_query.Execute(query_details)
+
+ if (href_list["linkingaction"] == "accept" && alert("To complete the process, you have to visit the website. Do you want to do so now?",,"Yes","No") == "Yes")
+ process_webint_link("interface/user/link")
+
+ src << feedback_message
+ check_linking_requests()
+ return
+
+ if (href_list["routeWebInt"])
+ process_webint_link(href_list["routeWebInt"], href_list["routeAttributes"])
+
+ return
+
+ ..() //redirect to hsrc.()
/client/proc/handle_spam_prevention(var/message, var/mute_type)
if(config.automute_on && !holder && src.last_message == message)
@@ -175,6 +236,8 @@
log_client_to_db()
+ check_linking_requests()
+
send_resources()
nanomanager.send_resources(src)
@@ -203,7 +266,7 @@
// Returns null if no DB connection can be established, or -1 if the requested key was not found in the database
/proc/get_player_age(key)
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
return null
@@ -223,7 +286,7 @@
if ( IsGuestKey(src.key) )
return
- establish_db_connection()
+ establish_db_connection(dbcon)
if(!dbcon.IsConnected())
return
@@ -344,12 +407,101 @@
)
-mob/proc/MayRespawn()
+/mob/proc/MayRespawn()
return 0
-client/proc/MayRespawn()
+/client/proc/MayRespawn()
if(mob)
return mob.MayRespawn()
// Something went wrong, client is usually kicked or transfered to a new mob at this point
return 0
+
+//I honestly can't find a good place for this atm.
+//If the webint interaction gets more features, I'll move it. - Skull132
+/client/verb/view_linking_requests()
+ set name = "View Linking Requests"
+ set category = "OOC"
+
+ check_linking_requests()
+
+/client/proc/check_linking_requests()
+ if (!config.webint_url || !config.sql_enabled)
+ return
+
+ establish_db_connection(dbcon)
+ if (!dbcon.IsConnected())
+ return
+
+ var/list/requests = list()
+ 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")
+ select_query.Execute(query_details)
+
+ while (select_query.NextRow())
+ requests.Add(list(list("id" = text2num(select_query.item[1]), "forum_id" = text2num(select_query.item[2]), "forum_username" = select_query.item[3], "request_age" = select_query.item[4])))
+
+ if (!requests.len)
+ return
+
+ var/dat = "
| ID | Contractor | Title | + {{if data.contracts_view == 1}} +|
|---|---|---|---|
| Available Contracts | |||
| Closed Contracts | |||
| {{:value.id}} | {{:value.contractee}} | {{:value.title}} | {{:helper.link('View', null, {'menu' : 21, 'id' : value.id}, null, 'fixedLeft')}} |