mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 18:32:03 +00:00
- Added basic ban logging for DB_Ban. First step for the cross-server ban system.
git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3916 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
77
code/modules/admin/DB ban/functions.dm
Normal file
77
code/modules/admin/DB ban/functions.dm
Normal file
@@ -0,0 +1,77 @@
|
||||
|
||||
obj/admins/proc/DB_ban_record(var/bantype, var/mob/banned_mob, var/duration = -1, var/reason, var/job = "", var/rounds = 0)
|
||||
var/user = sqlfdbklogin
|
||||
var/pass = sqlfdbkpass
|
||||
var/db = sqlfdbkdb
|
||||
var/address = sqladdress
|
||||
var/port = sqlport
|
||||
|
||||
var/DBConnection/dbcon = new()
|
||||
|
||||
dbcon.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]")
|
||||
if(!dbcon.IsConnected())
|
||||
return
|
||||
|
||||
var/serverip = "[world.internet_address]:[world.port]"
|
||||
var/bantype_pass = 0
|
||||
var/bantype_str
|
||||
switch(bantype)
|
||||
if(BANTYPE_PERMA)
|
||||
bantype_str = "PERMABAN"
|
||||
duration = -1
|
||||
bantype_pass = 1
|
||||
if(BANTYPE_TEMP)
|
||||
bantype_str = "TEMPBAN"
|
||||
bantype_pass = 1
|
||||
if(BANTYPE_JOB_PERMA)
|
||||
bantype_str = "JOB_PERMABAN"
|
||||
duration = -1
|
||||
bantype_pass = 1
|
||||
if(BANTYPE_JOB_TEMP)
|
||||
bantype_str = "JOB_TEMPBAN"
|
||||
bantype_pass = 1
|
||||
if( !bantype_pass ) return
|
||||
if( !istext(reason) ) return
|
||||
if( !isnum(duration) ) return
|
||||
|
||||
var/ckey
|
||||
var/computerid
|
||||
var/ip
|
||||
|
||||
if(ismob(banned_mob))
|
||||
ckey = banned_mob.ckey
|
||||
if(banned_mob.client)
|
||||
computerid = banned_mob.client.computer_id
|
||||
ip = banned_mob.client.address
|
||||
|
||||
var/a_ckey
|
||||
var/a_computerid
|
||||
var/a_ip
|
||||
|
||||
if(src.owner && istype(src.owner, /client))
|
||||
a_ckey = src.owner:ckey
|
||||
a_computerid = src.owner:computer_id
|
||||
a_ip = src.owner:address
|
||||
|
||||
var/list/client/clients = get_all_clients()
|
||||
var/who
|
||||
for(var/client/C in clients)
|
||||
if(!who)
|
||||
who = "[C]"
|
||||
else
|
||||
who += ", [C]"
|
||||
|
||||
var/list/client/admin_clients = get_all_admin_clients()
|
||||
var/adminwho
|
||||
for(var/client/C in admin_clients)
|
||||
if(!adminwho)
|
||||
adminwho = "[C]"
|
||||
else
|
||||
adminwho += ", [C]"
|
||||
|
||||
var/sql = "INSERT INTO erro_ban VALUES (null, Now(), '[serverip]', '[bantype_str]', '[reason]', '[job]', [(duration)?"[duration]":"0"], [(rounds)?"[rounds]":"0"], Now() + INTERVAL [(duration>0) ? duration : 0] MINUTE, '[ckey]', '[computerid]', '[ip]', '[a_ckey]', '[a_computerid]', '[a_ip]', '[who]', '[adminwho]', '', null, null, null, null, null)"
|
||||
world << sql
|
||||
var/DBQuery/query_insert = dbcon.NewQuery(sql)
|
||||
query_insert.Execute()
|
||||
|
||||
dbcon.Disconnect()
|
||||
Reference in New Issue
Block a user