Files
CHOMPStation2/code/defines/procs/statistics.dm
baloh.matevz 2f57200e82 - Fixes the broken population logging
- The current, file-based ban system is now a legacy system, the use of which is strongly discouraged for servers, which are constantly online.
- Added a database-based banning system, with a new baning panel, accessible through the 'banning panel' verb. Servers, which use this new banning system, will get the new panel up even if they use the old 'unban panel' or 'display job bans' verbs. These remain there for legacy support purposes. (Panel screenshot below)
- The most notable benefits of the new system are the ability to add offline bans, meaning the person does not have to be connected for a ban to be applied to their name. The second benefit is the ability to look up all previous bans that the person had.
- The major disadvantage is the complete incompatibility between the old and new system, meaning you have to either do a lot of copy-pasting or playing around in code to sync the old system with the new one. Servers upgrading to this system might want to consider a purge of all bans, if they don't want to go through this. Due to the incompatibility, there are no transition tools provided. Please contact me (errorage/rageroro) in #coderbus for help in syncing your database. The /tg/ legacy and database systems have been synced.
- The server configuration defaults to use the legacy system, as the new one requires the database to be set up. Please hash BAN_LEGACY_SYSTEM in config.txt as explained, to use the new system. If the database connection fails, the server reverts to the legacy system.

If any bugs or errors appear with either the legacy or new ban system, please let me know ASAP. The same applies if there are any syncronization problems between the legacy and new system, resulting in banned people unbanned or unbanned people banned.

Panel screenshot:
http://www.kamletos.si/new%20ban%20panel2.PNG

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@5034 316c924e-a436-60f5-8080-3fe189b3f50e
2012-11-11 05:39:09 +00:00

162 lines
6.1 KiB
Plaintext

proc/sql_poll_players()
if(!sqllogging)
return
var/playercount = 0
for(var/mob/M in player_list)
if(M.client)
playercount += 1
establish_db_connection()
if(!dbcon.IsConnected())
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]')")
if(!query.Execute())
var/err = query.ErrorMsg()
log_game("SQL ERROR during player polling. Error : \[[err]\]\n")
proc/sql_poll_admins()
if(!sqllogging)
return
var/admincount = admins.len
establish_db_connection()
if(!dbcon.IsConnected())
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]')")
if(!query.Execute())
var/err = query.ErrorMsg()
log_game("SQL ERROR during admin polling. Error : \[[err]\]\n")
proc/sql_report_round_start()
// TODO
if(!sqllogging)
return
proc/sql_report_round_end()
// TODO
if(!sqllogging)
return
proc/sql_report_death(var/mob/living/carbon/human/H)
if(!sqllogging)
return
if(!H)
return
if(!H.key || !H.mind)
return
var/turf/T = H.loc
var/area/placeofdeath = get_area(T.loc)
var/podname = placeofdeath.name
var/sqlname = sanitizeSQL(H.real_name)
var/sqlkey = sanitizeSQL(H.key)
var/sqlpod = sanitizeSQL(podname)
var/sqlspecial = sanitizeSQL(H.mind.special_role)
var/sqljob = sanitizeSQL(H.mind.assigned_role)
var/laname
var/lakey
if(H.lastattacker)
laname = sanitizeSQL(H.lastattacker:real_name)
lakey = sanitizeSQL(H.lastattacker:key)
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()
if(!dbcon.IsConnected())
log_game("SQL ERROR during death reporting. Failed to connect.")
else
var/DBQuery/query = dbcon.NewQuery("INSERT INTO death (name, byondkey, job, special, pod, tod, laname, lakey, gender, bruteloss, fireloss, brainloss, oxyloss, coord) VALUES ('[sqlname]', '[sqlkey]', '[sqljob]', '[sqlspecial]', '[sqlpod]', '[sqltime]', '[laname]', '[lakey]', '[H.gender]', [H.getBruteLoss()], [H.getFireLoss()], [H.brainloss], [H.getOxyLoss()], '[coord]')")
if(!query.Execute())
var/err = query.ErrorMsg()
log_game("SQL ERROR during death reporting. Error : \[[err]\]\n")
proc/sql_report_cyborg_death(var/mob/living/silicon/robot/H)
if(!sqllogging)
return
if(!H)
return
if(!H.key || !H.mind)
return
var/turf/T = H.loc
var/area/placeofdeath = get_area(T.loc)
var/podname = placeofdeath.name
var/sqlname = sanitizeSQL(H.real_name)
var/sqlkey = sanitizeSQL(H.key)
var/sqlpod = sanitizeSQL(podname)
var/sqlspecial = sanitizeSQL(H.mind.special_role)
var/sqljob = sanitizeSQL(H.mind.assigned_role)
var/laname
var/lakey
if(H.lastattacker)
laname = sanitizeSQL(H.lastattacker:real_name)
lakey = sanitizeSQL(H.lastattacker:key)
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()
if(!dbcon.IsConnected())
log_game("SQL ERROR during death reporting. Failed to connect.")
else
var/DBQuery/query = dbcon.NewQuery("INSERT INTO death (name, byondkey, job, special, pod, tod, laname, lakey, gender, bruteloss, fireloss, brainloss, oxyloss, coord) VALUES ('[sqlname]', '[sqlkey]', '[sqljob]', '[sqlspecial]', '[sqlpod]', '[sqltime]', '[laname]', '[lakey]', '[H.gender]', [H.getBruteLoss()], [H.getFireLoss()], [H.brainloss], [H.getOxyLoss()], '[coord]')")
if(!query.Execute())
var/err = query.ErrorMsg()
log_game("SQL ERROR during death reporting. Error : \[[err]\]\n")
proc/statistic_cycle()
if(!sqllogging)
return
while(1)
sql_poll_players()
sleep(600)
sql_poll_admins()
sleep(6000) // Poll every ten minutes
//This proc is used for feedback. It is executed at round end.
proc/sql_commit_feedback()
if(!blackbox)
log_game("Round ended without a blackbox recorder. No feedback was sent to the database.")
return
//content is a list of lists. Each item in the list is a list with two fields, a variable name and a value. Items MUST only have these two values.
var/list/datum/feedback_variable/content = blackbox.get_round_feedback()
if(!content)
log_game("Round ended without any feedback being generated. No feedback was sent to the database.")
return
establish_db_connection()
if(!dbcon.IsConnected())
log_game("SQL ERROR during feedback reporting. Failed to connect.")
else
var/DBQuery/max_query = dbcon.NewQuery("SELECT MAX(roundid) AS max_round_id FROM erro_feedback")
max_query.Execute()
var/newroundid
while(max_query.NextRow())
newroundid = max_query.item[1]
if(!(isnum(newroundid)))
newroundid = text2num(newroundid)
if(isnum(newroundid))
newroundid++
else
newroundid = 1
for(var/datum/feedback_variable/item in content)
var/variable = item.get_variable()
var/value = item.get_value()
var/DBQuery/query = dbcon.NewQuery("INSERT INTO erro_feedback (id, roundid, time, variable, value) VALUES (null, [newroundid], Now(), '[variable]', '[value]')")
if(!query.Execute())
var/err = query.ErrorMsg()
log_game("SQL ERROR during death reporting. Error : \[[err]\]\n")