- Added a config option that allows the admin system to run off of data from the database. There is a config options in config.txt that dictates whether to use the new SQL based system or the legacy admins.txt system. If a server is set to use the new system, but a connection cannot be established to the database, it reverts to the legacy system, same applies if a query to the database returns empty. The config option defaults to use the legacy system.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4863 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
baloh.matevz
2012-10-13 22:32:51 +00:00
parent 940808ee86
commit a5b37f81c3
4 changed files with 58 additions and 20 deletions

View File

@@ -89,6 +89,7 @@
var/metroid_delay = 0
var/animal_delay = 0
var/admin_legacy_system = 0 //Defines whether the server uses the legacy admin system with admins.txt or the SQL system.
/datum/configuration/New()
var/list/L = typesof(/datum/game_mode) - /datum/game_mode
@@ -145,6 +146,9 @@
if(type == "config")
switch (name)
if ("admin_legacy_system")
config.admin_legacy_system = 1
if ("log_ooc")
config.log_ooc = 1

View File

@@ -17,10 +17,6 @@
var/airlock_wire = null
var/datum/radio_frequency/radio_connection
proc
signal()
New()
..()
spawn(40)
@@ -103,7 +99,7 @@
return
signal()
proc/signal()
if(!radio_connection) return
var/datum/signal/signal = new

View File

@@ -191,24 +191,59 @@ Starting up. [time2text(world.timeofday, "hh:mm.ss")]
/world/proc/load_admins()
var/text = file2text("config/admins.txt")
if (!text)
diary << "Failed to load config/admins.txt\n"
if(config.admin_legacy_system)
//Legacy admin system uses admins.txt
var/text = file2text("config/admins.txt")
if (!text)
diary << "Failed to load config/admins.txt\n"
else
var/list/lines = dd_text2list(text, "\n")
for(var/line in lines)
if (!line)
continue
if (copytext(line, 1, 2) == ";")
continue
var/pos = findtext(line, " - ", 1, null)
if (pos)
var/m_key = copytext(line, 1, pos)
var/a_lev = copytext(line, pos + 3, length(line) + 1)
admins[m_key] = new /datum/admins(a_lev)
diary << ("ADMIN: [m_key] = [a_lev]")
else
var/list/lines = dd_text2list(text, "\n")
for(var/line in lines)
if (!line)
continue
//The current admin system uses SQL
var/user = sqlfdbklogin
var/pass = sqlfdbkpass
var/db = sqlfdbkdb
var/address = sqladdress
var/port = sqlport
if (copytext(line, 1, 2) == ";")
continue
var/DBConnection/dbcon = new()
dbcon.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]")
if(!dbcon.IsConnected())
diary << "Failed to connect to database in load_admins(). Reverting to legacy system."
config.admin_legacy_system
load_admins()
return
var/DBQuery/query = dbcon.NewQuery("SELECT ckey, rank, level FROM erro_admin")
query.Execute()
while(query.NextRow())
var/adminckey = query.item[1]
var/adminrank = query.item[2]
var/adminlevel = query.item[3]
var/datum/admins/AD = new /datum/admins(adminrank)
AD.level = adminlevel
admins[adminckey] = AD
if(!admins)
diary << "The database query in load_admins() resulted in no admins being added to the list. Reverting to legacy system."
config.admin_legacy_system
load_admins()
return
var/pos = findtext(line, " - ", 1, null)
if (pos)
var/m_key = copytext(line, 1, pos)
var/a_lev = copytext(line, pos + 3, length(line) + 1)
admins[m_key] = new /datum/admins(a_lev)
diary << ("ADMIN: [m_key] = [a_lev]")
/world/proc/load_configuration()

View File

@@ -6,6 +6,9 @@ ALERT_RED_UPTO There is an immediate serious threat to the station. Security may
ALERT_RED_DOWNTO The self-destruct mechanism has been deactivated, there is still however an immediate serious threat to the station. Security may have weapons unholstered at all times, random searches are allowed and advised.
ALERT_DELTA The station's self-destruct mechanism has been engaged. All crew are instructed to obey all instructions given by heads of staff. Any violations of these orders can be punished by death. This is not a drill.
## Add a # infront of this if you want to use the SQL based admin system, the legacy system uses admins.txt
#ADMIN_LEGACY_SYSTEM
## log OOC channel
LOG_OOC