mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +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:
@@ -1,3 +1,29 @@
|
||||
proc/get_all_clients()
|
||||
var/list/client/clients = list()
|
||||
|
||||
for (var/mob/M in world)
|
||||
if (!M.client)
|
||||
continue
|
||||
|
||||
clients += M.client
|
||||
|
||||
return clients
|
||||
|
||||
proc/get_all_admin_clients()
|
||||
var/list/client/clients = list()
|
||||
|
||||
for (var/mob/M in world)
|
||||
if (!M.client)
|
||||
continue
|
||||
|
||||
if (!M.client.holder)
|
||||
continue
|
||||
|
||||
clients += M.client
|
||||
|
||||
return clients
|
||||
|
||||
|
||||
/mob/verb/who()
|
||||
set name = "Who"
|
||||
set category = "OOC"
|
||||
|
||||
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()
|
||||
@@ -523,6 +523,7 @@ var/global/BSACooldown = 0
|
||||
ban_unban_log_save("[key_name(usr)] jobbanned [key_name(M)] from [job]. reason: [reason]")
|
||||
log_admin("[key_name(usr)] banned [key_name(M)] from [job]")
|
||||
feedback_inc("ban_job",1)
|
||||
DB_ban_record(BANTYPE_JOB_PERMA, M, -1, reason, job)
|
||||
feedback_add_details("ban_job","- [job]")
|
||||
jobban_fullban(M, job, "[reason]; By [usr.ckey] on [time2text(world.realtime)]")
|
||||
if(!msg) msg = job
|
||||
@@ -602,6 +603,7 @@ var/global/BSACooldown = 0
|
||||
M << "\red<BIG><B>You have been banned by [usr.client.ckey].\nReason: [reason].</B></BIG>"
|
||||
M << "\red This is a temporary ban, it will be removed in [mins] minutes."
|
||||
feedback_inc("ban_tmp",1)
|
||||
DB_ban_record(BANTYPE_TEMP, M, mins, reason)
|
||||
feedback_inc("ban_tmp_mins",mins)
|
||||
if(config.banappeals)
|
||||
M << "\red To try to resolve this matter head to [config.banappeals]"
|
||||
@@ -627,109 +629,12 @@ var/global/BSACooldown = 0
|
||||
log_admin("[usr.client.ckey] has banned [M.ckey].\nReason: [reason]\nThis is a permanent ban.")
|
||||
message_admins("\blue[usr.client.ckey] has banned [M.ckey].\nReason: [reason]\nThis is a permanent ban.")
|
||||
feedback_inc("ban_perma",1)
|
||||
DB_ban_record(BANTYPE_PERMA, M, -1, reason)
|
||||
|
||||
del(M.client)
|
||||
//del(M)
|
||||
if("Cancel")
|
||||
return
|
||||
if (href_list["newjobban1"])
|
||||
var/mob/M = locate(href_list["newjobban1"])
|
||||
var/dat = ""
|
||||
var/header = "<b>Pick Job to ban this guy from.<br>"
|
||||
var/body
|
||||
// var/list/alljobs = get_all_jobs()
|
||||
var/jobs = ""
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=Heads;jobban4=\ref[M]'>Heads</a> <br>"
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=Security;jobban4=\ref[M]'>Security</a> <br>"
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=Engineering;jobban4=\ref[M]'>Engineering</a> <br>"
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=Research;jobban4=\ref[M]'>Research</a> <br>"
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=Medical;jobban4=\ref[M]'>Medical</a> <br><br>"
|
||||
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=CE_Station_Engineer;jobban4=\ref[M]'>CE+Station Engineer</a> <br>"
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=CE_Atmospheric_Tech;jobban4=\ref[M]'>CE+Atmospheric Tech</a> <br>"
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=CE_Shaft_Miner;jobban4=\ref[M]'>CE+Shaft Miner</a> <br>"
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=Chemist_RD_CMO;jobban4=\ref[M]'>Chemist+RD+CMO</a> <br>"
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=Geneticist_RD_CMO;jobban4=\ref[M]'>Geneticist+RD+CMO</a> <br>"
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=MD_CMO;jobban4=\ref[M]'>MD+CMO</a> <br>"
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=Virologist_RD_CMO;jobban4=\ref[M]'>Virologist+RD+CMO</a> <br>"
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=Scientist_RD;jobban4=\ref[M]'>Scientist+RD</a> <br>"
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=AI_Cyborg;jobban4=\ref[M]'>AI+Cyborg</a> <br>"
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=Detective_HoS;jobban4=\ref[M]'>Detective+HoS</a> <br><br>"
|
||||
for(var/datum/job/job in job_master.occupations)
|
||||
if(jobban_isbanned(M, job.title))
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=[job.title];jobban4=\ref[M]'><font color=red>[dd_replacetext(job.title, " ", " ")]</font></a> "
|
||||
else
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=[job.title];jobban4=\ref[M]'>[dd_replacetext(job.title, " ", " ")]</a> " //why doesn't this work the stupid cunt
|
||||
|
||||
/* if(jobban_isbanned(M, "Captain"))
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=Captain;jobban4=\ref[M]'><font color=red>Captain</font></a> "
|
||||
else
|
||||
jobs += "<a href='?src=\ref[src];newjobban2=Captain;jobban4=\ref[M]'>Captain</a> " //why doesn't this work the stupid cunt
|
||||
*/
|
||||
if(jobban_isbanned(M, "Syndicate"))
|
||||
jobs += "<BR><a href='?src=\ref[src];newjobban2=Syndicate;jobban4=\ref[M]'><font color=red>[dd_replacetext("Syndicate", " ", " ")]</font></a> "
|
||||
else
|
||||
jobs += "<BR><a href='?src=\ref[src];newjobban2=Syndicate;jobban4=\ref[M]'>[dd_replacetext("Syndicate", " ", " ")]</a> " //why doesn't this work the stupid cunt
|
||||
|
||||
body = "<br>[jobs]<br><br>"
|
||||
dat = "<tt>[header][body]</tt>"
|
||||
usr << browse(dat, "window=jobban2;size=600x250")
|
||||
return
|
||||
if(href_list["newjobban2"])
|
||||
if ((src.rank in list("Moderator", "Administrator", "Badmin", "Tyrant" )))
|
||||
var/mob/M = locate(href_list["jobban4"])
|
||||
var/job = href_list["newjobban2"]
|
||||
if(!ismob(M)) return
|
||||
//if ((M.client && M.client.holder && (M.client.holder.level >= src.level)))
|
||||
// alert("You cannot perform this action. You must be of a higher administrative rank!")
|
||||
// return
|
||||
switch(alert("Temporary Ban?",,"Yes","No", "Cancel"))
|
||||
if("Yes")
|
||||
var/mins = input(usr,"How long (in days)?","Ban time",7) as num
|
||||
mins = mins * 24 * 60
|
||||
if(!mins)
|
||||
return
|
||||
if(mins >= 525600) mins = 525599
|
||||
var/reason = input(usr,"Reason?","reason","Griefer") as text
|
||||
if(!reason)
|
||||
return
|
||||
if(AddBanjob(M.ckey, M.computer_id, reason, usr.ckey, 1, mins, job))
|
||||
M << "\red<BIG><B>You have been jobbanned from [job] by [usr.client.ckey].\nReason: [reason].</B></BIG>"
|
||||
M << "\red This is a temporary ban, it will be removed in [mins] minutes."
|
||||
if(config.banappeals)
|
||||
M << "\red To try to resolve this matter head to [config.banappeals]"
|
||||
else
|
||||
M << "\red No ban appeals URL has been set."
|
||||
ban_unban_log_save("[usr.client.ckey] has jobbanned [M.ckey] from [job]. - Reason: [reason] - This will be removed in [mins] minutes.")
|
||||
feedback_inc("ban_job",1)
|
||||
feedback_add_details("ban_job","- [job]")
|
||||
log_admin("[usr.client.ckey] has banned [M.ckey] from [job].\nReason: [reason]\nThis will be removed in [mins] minutes.")
|
||||
message_admins("\blue[usr.client.ckey] has banned [M.ckey] from [job].\nReason: [reason]\nThis will be removed in [mins] minutes.")
|
||||
|
||||
//del(M.client)
|
||||
//del(M) // See no reason why to delete mob. Important stuff can be lost. And ban can be lifted before round ends.
|
||||
if("No")
|
||||
var/reason = input(usr,"Reason?","reason","Griefer") as text
|
||||
if(!reason)
|
||||
return
|
||||
if(AddBanjob(M.ckey, M.computer_id, reason, usr.ckey, 0, 0, job))
|
||||
M << "\red<BIG><B>You have been banned from [job] by [usr.client.ckey].\nReason: [reason].</B></BIG>"
|
||||
M << "\red This is a permanent ban."
|
||||
if(config.banappeals)
|
||||
M << "\red To try to resolve this matter head to [config.banappeals]"
|
||||
else
|
||||
M << "\red No ban appeals URL has been set."
|
||||
ban_unban_log_save("[usr.client.ckey] has banned [M.ckey] from [job]. - Reason: [reason] - This is a permanent ban.")
|
||||
feedback_inc("ban_job_tmp",1)
|
||||
feedback_add_details("ban_job_tmp","- [job]")
|
||||
log_admin("[usr.client.ckey] has banned [M.ckey] from [job].\nReason: [reason]\nThis is a permanent ban.")
|
||||
message_admins("\blue[usr.client.ckey] has banned [M.ckey] from [job].\nReason: [reason]\nThis is a permanent ban.")
|
||||
|
||||
//del(M.client)
|
||||
//del(M)
|
||||
if("Cancel")
|
||||
return
|
||||
|
||||
if(href_list["unjobbanf"])
|
||||
var/banfolder = href_list["unjobbanf"]
|
||||
Banlist.cd = "/base/[banfolder]"
|
||||
|
||||
@@ -370,5 +370,12 @@ var/list/liftable_structures = list(\
|
||||
#define MUTE_DEADCHAT 5
|
||||
#define MUTE_ALL 6
|
||||
|
||||
//Number of identical messages required to get the spam-prevention automute thing to trigger warnings and automutes
|
||||
#define SPAM_TRIGGER_WARNING 5
|
||||
#define SPAM_TRIGGER_AUTOMUTE 10
|
||||
|
||||
//Some constants for DB_Ban
|
||||
#define BANTYPE_PERMA 1
|
||||
#define BANTYPE_TEMP 2
|
||||
#define BANTYPE_JOB_PERMA 3
|
||||
#define BANTYPE_JOB_TEMP 4
|
||||
@@ -84,6 +84,7 @@
|
||||
#define FILE_DIR "code/js"
|
||||
#define FILE_DIR "code/modules"
|
||||
#define FILE_DIR "code/modules/admin"
|
||||
#define FILE_DIR "code/modules/admin/DB ban"
|
||||
#define FILE_DIR "code/modules/admin/verbs"
|
||||
#define FILE_DIR "code/modules/assembly"
|
||||
#define FILE_DIR "code/modules/chemical"
|
||||
@@ -186,6 +187,7 @@
|
||||
#define FILE_DIR "icons/vending_icons"
|
||||
#define FILE_DIR "interface"
|
||||
#define FILE_DIR "maps"
|
||||
#define FILE_DIR "maps/backup"
|
||||
#define FILE_DIR "maps/RandomZLevels"
|
||||
#define FILE_DIR "sound"
|
||||
#define FILE_DIR "sound/AI"
|
||||
@@ -765,6 +767,7 @@
|
||||
#include "code\modules\admin\NewBan.dm"
|
||||
#include "code\modules\admin\newbanjob.dm"
|
||||
#include "code\modules\admin\player_panel.dm"
|
||||
#include "code\modules\admin\DB ban\functions.dm"
|
||||
#include "code\modules\admin\verbs\adminhelp.dm"
|
||||
#include "code\modules\admin\verbs\adminjump.dm"
|
||||
#include "code\modules\admin\verbs\adminpm.dm"
|
||||
|
||||
Reference in New Issue
Block a user