From 8a66665e95620922720ec86afc4bedbff9502150 Mon Sep 17 00:00:00 2001
From: Jordie <4343468+Jordie0608@users.noreply.github.com>
Date: Wed, 5 Dec 2018 06:48:37 +1100
Subject: [PATCH] Ban system and interface update (#41176)
Spiritual successor and extension to #17798, an almost entire rebuild of the SQL ban system backend and interface.
Bantypes are removed per #8584 and #6174. All bans are now 'role bans', server bans are when a ban's role is server. Admin bans are a column, meaning it's possible to ban admins from jobs.
Bans now have only an expiry datetime, duration is calculated from this when queried.
unbanned column is removed as it's superfluous, checking unban status is now done through checking unban_datetime. unban_round_id column added. Each ip and computerid columns rearranged so ip is always first, like in other tables. Bans now permit a null ckey, ip and computerid.
Ban checking is split into two procs now is_banned_from() does a check if a ckey is banned from one or more roles and returns true or false. This effectively replaces jobban_isbanned() used in simple if() statements. If connected a client's ban cache is checked rather than querying the DB. This makes it possible for a client connected to two or more servers to ignore any bans made on one server until their ban cache is rebuilt on the others. Could be avoided with cross-server calls to update ban caches or just the removal of the ban cache but as is I've done neither since I think it's enough of an edge case to not be worth it.
The second proc is is_banned_from_with_details(), this queries the DB for a role ban on a player's ckey, ip or CID and returns the details. This replaces direct queries in IsBanned.dm and the preferences menu.
The legacy ban system is removed.
The interfaces for banning, unbanning and editing bans have been remade to require less clicking and easier simultaneous operations. The banning and jobban panel are combined. They also store player connection details when opened so a client disconnecting no longer stops a ban being placed.
New banning panel:
Key, IP and CID can all be toggled to allow excluding them from a ban.
Checking Use IP and CID from last connection lets you enter only a ckey and have the DB fill these fields in for you, if possible.
Temporary bans have a drop-menu which lets you select between seconds, minutes, hours, days, weeks, months and years so you don't need to calculate how many minutes a long ban would be. The ban is still converted into minutes on the DB however.
Checking any of the head roles will check both of the boxes for you.
The red role box indicates there is already a ban on that role for this ckey. You can apply additional role bans to stack them.
New unbanning panel:
Unbanning panel is now separate from the banning panel but otherwise functionally the same.
Ban editing panel:
Actually just a modified banning panel, all the features from it work the same here.
You can now edit almost all parameters of a ban instead of just the reason.
You can't edit severity as it's not really part of the ban.
The panels have been tested but I've not been able to get my local server to be accessible so ban functionality isn't properly confirmed. Plenty of testing will be required as I'd rather not break bans.
cl
admin: Ban interface rework. The banning and unbanning panels have received a new design which is easier to use and allows multiple role bans to be made at once.
prefix: Ban search and unbanning moved to unbanning panel, which is now a separate panel to the old banning panel.
/cl
---
SQL/ban_conversion_2018-10-28.py | 174 ++++
SQL/database_changelog.txt | 42 +-
SQL/tgstation_schema.sql | 53 +-
SQL/tgstation_schema_prefixed.sql | 53 +-
code/__DEFINES/role_preferences.dm | 58 +-
code/__DEFINES/subsystems.dm | 4 +-
code/__HELPERS/game.dm | 4 +-
code/__HELPERS/unsorted.dm | 2 +-
.../configuration/entries/general.dm | 3 -
code/controllers/subsystem/job.dm | 12 +-
code/datums/diseases/transformation.dm | 2 +-
code/game/gamemodes/changeling/changeling.dm | 2 +-
.../game/gamemodes/changeling/traitor_chan.dm | 2 +-
code/game/gamemodes/game_mode.dm | 4 +-
code/game/gamemodes/traitor/traitor.dm | 4 +-
code/game/objects/items/robot/robot_parts.dm | 2 +-
code/game/objects/structures/ai_core.dm | 2 +-
code/game/world.dm | 1 -
code/modules/admin/DB_ban/functions.dm | 561 -------------
code/modules/admin/IsBanned.dm | 93 +-
code/modules/admin/NewBan.dm | 235 ------
code/modules/admin/admin.dm | 17 +-
code/modules/admin/admin_verbs.dm | 24 +-
code/modules/admin/banjob.dm | 40 -
code/modules/admin/sql_ban_system.dm | 713 ++++++++++++++++
code/modules/admin/topic.dm | 794 ++----------------
code/modules/admin/verbs/one_click_antag.dm | 2 +-
.../antagonists/_common/antag_datum.dm | 2 +-
code/modules/antagonists/cult/runes.dm | 2 +-
code/modules/awaymissions/corpse.dm | 2 +-
code/modules/client/client_defines.dm | 4 +-
code/modules/client/preferences.dm | 54 +-
code/modules/client/verbs/ooc.dm | 2 +-
.../modules/mob/dead/new_player/new_player.dm | 4 +-
code/modules/mob/living/brain/posibrain.dm | 2 +-
code/modules/mob/living/emote.dm | 2 +-
.../friendly/drone/drones_as_items.dm | 2 +-
code/modules/mob/say.dm | 2 +-
.../research/xenobiology/xenobiology.dm | 2 +-
config/config.txt | 3 -
html/admin/banpanel.css | 182 ++++
html/admin/banpanel.js | 16 +
html/admin/unbanpanel.css | 61 ++
tgstation.dme | 4 +-
44 files changed, 1419 insertions(+), 1830 deletions(-)
create mode 100644 SQL/ban_conversion_2018-10-28.py
delete mode 100644 code/modules/admin/DB_ban/functions.dm
delete mode 100644 code/modules/admin/NewBan.dm
delete mode 100644 code/modules/admin/banjob.dm
create mode 100644 code/modules/admin/sql_ban_system.dm
create mode 100644 html/admin/banpanel.css
create mode 100644 html/admin/banpanel.js
create mode 100644 html/admin/unbanpanel.css
diff --git a/SQL/ban_conversion_2018-10-28.py b/SQL/ban_conversion_2018-10-28.py
new file mode 100644
index 00000000000..26d928bfd16
--- /dev/null
+++ b/SQL/ban_conversion_2018-10-28.py
@@ -0,0 +1,174 @@
+#Python 3+ Script for converting ban table format as of 2018-10-28 made by Jordie0608
+#
+#Before starting ensure you have installed the mysqlclient package https://github.com/PyMySQL/mysqlclient-python
+#It can be downloaded from command line with pip:
+#pip install mysqlclient
+#
+#You will also have to create a new ban table for inserting converted data to per the schema:
+#CREATE TABLE `ban` (
+# `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+# `bantime` DATETIME NOT NULL,
+# `server_ip` INT(10) UNSIGNED NOT NULL,
+# `server_port` SMALLINT(5) UNSIGNED NOT NULL,
+# `round_id` INT(11) UNSIGNED NOT NULL,
+# `role` VARCHAR(32) NULL DEFAULT NULL,
+# `expiration_time` DATETIME NULL DEFAULT NULL,
+# `applies_to_admins` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
+# `reason` VARCHAR(2048) NOT NULL,
+# `ckey` VARCHAR(32) NULL DEFAULT NULL,
+# `ip` INT(10) UNSIGNED NULL DEFAULT NULL,
+# `computerid` VARCHAR(32) NULL DEFAULT NULL,
+# `a_ckey` VARCHAR(32) NOT NULL,
+# `a_ip` INT(10) UNSIGNED NOT NULL,
+# `a_computerid` VARCHAR(32) NOT NULL,
+# `who` VARCHAR(2048) NOT NULL,
+# `adminwho` VARCHAR(2048) NOT NULL,
+# `edits` TEXT NULL DEFAULT NULL,
+# `unbanned_datetime` DATETIME NULL DEFAULT NULL,
+# `unbanned_ckey` VARCHAR(32) NULL DEFAULT NULL,
+# `unbanned_ip` INT(10) UNSIGNED NULL DEFAULT NULL,
+# `unbanned_computerid` VARCHAR(32) NULL DEFAULT NULL,
+# `unbanned_round_id` INT(11) UNSIGNED NULL DEFAULT NULL,
+# PRIMARY KEY (`id`),
+# KEY `idx_ban_isbanned` (`ckey`,`role`,`unbanned_datetime`,`expiration_time`),
+# KEY `idx_ban_isbanned_details` (`ckey`,`ip`,`computerid`,`role`,`unbanned_datetime`,`expiration_time`),
+# KEY `idx_ban_count` (`bantime`,`a_ckey`,`applies_to_admins`,`unbanned_datetime`,`expiration_time`)
+#) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+#This is to prevent the destruction of existing data and allow rollbacks to be performed in the event of an error during conversion
+#Once conversion is complete remember to rename the old and new ban tables; it's up to you if you want to keep the old table
+#
+#To view the parameters for this script, execute it with the argument --help
+#All the positional arguments are required, remember to include prefixes in your table names if you use them
+#An example of the command used to execute this script from powershell:
+#python ban_conversion_2018-10-28.py "localhost" "root" "password" "feedback" "SS13_ban" "SS13_ban_new"
+#I found that this script would complete conversion of 35000 rows in approximately 20 seconds, results will depend on the size of your ban table and computer used
+#
+#The script has been tested to complete with tgstation's ban table as of 2018-09-02 02:19:56
+#In the event of an error the new ban table is automatically truncated
+#The source table is never modified so you don't have to worry about losing any data due to errors
+#Some additional error correction is performed to fix problems specific to legacy and invalid data in tgstation's ban table, these operations are tagged with a 'TG:' comment
+#Even if you don't have any of these specific problems in your ban table the operations won't have matter as they have an insignificant effect on runtime
+#
+#While this script is safe to run with your game server(s) active, any bans created after the script has started won't be converted
+#You will also have to ensure that the code and table names are updated between rounds as neither will be compatible
+
+import MySQLdb
+import argparse
+import sys
+from datetime import datetime
+
+def parse_role(bantype, job):
+ if bantype in ("PERMABAN", "TEMPBAN", "ADMIN_PERMABAN", "ADMIN_TEMPBAN"):
+ role = "Server"
+ else:
+ #TG: Some legacy jobbans are missing the last character from their job string.
+ job_name_fixes = {"A":"AI", "Captai":"Captain", "Cargo Technicia":"Cargo Technician", "Chaplai":"Chaplain", "Che":"Chef", "Chemis":"Chemist", "Chief Enginee":"Chief Engineer", "Chief Medical Office":"Chief Medical Officer", "Cybor":"Cyborg", "Detectiv":"Detective", "Head of Personne":"Head of Personnel", "Head of Securit":"Head of Security", "Mim":"Mime", "pA":"pAI", "Quartermaste":"Quartermaster", "Research Directo":"Research Director", "Scientis":"Scientist", "Security Office":"Security Officer", "Station Enginee":"Station Engineer", "Syndicat":"Syndicate", "Warde":"Warden"}
+ keep_job_names = ("AI", "Head of Personnel", "Head of Security", "OOC", "pAI")
+ if job in job_name_fixes:
+ role = job_name_fixes[job]
+ #Some job names we want to keep the same as .title() would return a different string.
+ elif job in keep_job_names:
+ role = job
+ #And then there's this asshole.
+ elif job == "servant of Ratvar":
+ role = "Servant of Ratvar"
+ else:
+ role = job.title()
+ return role
+
+def parse_admin(bantype):
+ if bantype in ("ADMIN_PERMABAN", "ADMIN_TEMPBAN"):
+ return 1
+ else:
+ return 0
+
+def parse_datetime(bantype, expiration_time):
+ if bantype in ("PERMABAN", "JOB_PERMABAN", "ADMIN_PERMABAN"):
+ expiration_time = None
+ #TG: two bans with an invalid expiration_time due to admins setting the duration to approx. 19 billion years, I'm going to count them as permabans.
+ elif expiration_time == "0000-00-00 00:00:00":
+ expiration_time = None
+ elif not expiration_time:
+ expiration_time = None
+ return expiration_time
+
+def parse_not_null(field):
+ if not field:
+ field = 0
+ return field
+
+def parse_for_empty(field):
+ if not field:
+ field = None
+ #TG: Several bans from 2012, probably from clients disconnecting while a ban was being made.
+ elif field == "BLANK CKEY ERROR":
+ field = None
+ return field
+
+if sys.version_info[0] < 3:
+ raise Exception("Python must be at least version 3 for this script.")
+current_round = 0
+parser = argparse.ArgumentParser()
+parser.add_argument("address", help="MySQL server address (use localhost for the current computer)")
+parser.add_argument("username", help="MySQL login username")
+parser.add_argument("password", help="MySQL login username")
+parser.add_argument("database", help="Database name")
+parser.add_argument("curtable", help="Name of the current ban table (remember prefixes if you use them)")
+parser.add_argument("newtable", help="Name of the new table to insert to, can't be same as the source table (remember prefixes)")
+args = parser.parse_args()
+db=MySQLdb.connect(host=args.address, user=args.username, passwd=args.password, db=args.database)
+cursor=db.cursor()
+current_table = args.curtable
+new_table = args.newtable
+#TG: Due to deleted rows and a legacy ban import being inserted from id 3140 id order is not contiguous or in line with date order. While technically valid, it's confusing and I don't like that.
+#TG: So instead of just running through to MAX(id) we're going to reorder the records by bantime as we go.
+cursor.execute("SELECT id FROM " + current_table + " ORDER BY bantime ASC")
+id_list = cursor.fetchall()
+start_time = datetime.now()
+print("Beginning conversion at {0}".format(start_time.strftime("%Y-%m-%d %H:%M:%S")))
+try:
+ for current_id in id_list:
+ if current_id[0] % 5000 == 0:
+ cur_time = datetime.now()
+ print("Reached row ID {0} Duration: {1}".format(current_id[0], cur_time - start_time))
+ cursor.execute("SELECT * FROM " + current_table + " WHERE id = %s", [current_id[0]])
+ query_row = cursor.fetchone()
+ if not query_row:
+ continue
+ else:
+ #TG: bans with an empty reason which were somehow created with almost every field being null or empty, we can't do much but skip this
+ if not query_row[6]:
+ continue
+ bantime = query_row[1]
+ server_ip = query_row[2]
+ server_port = query_row[3]
+ round_id = query_row[4]
+ applies_to_admins = parse_admin(query_row[5])
+ reason = query_row[6]
+ role = parse_role(query_row[5], query_row[7])
+ expiration_time = parse_datetime(query_row[5], query_row[9])
+ ckey = parse_for_empty(query_row[10])
+ computerid = parse_for_empty(query_row[11])
+ ip = parse_for_empty(query_row[12])
+ a_ckey = parse_not_null(query_row[13])
+ a_computerid = parse_not_null(query_row[14])
+ a_ip = parse_not_null(query_row[15])
+ who = query_row[16]
+ adminwho = query_row[17]
+ edits = parse_for_empty(query_row[18])
+ unbanned_datetime = parse_datetime(None, query_row[20])
+ unbanned_ckey = parse_for_empty(query_row[21])
+ unbanned_computerid = parse_for_empty(query_row[22])
+ unbanned_ip = parse_for_empty(query_row[23])
+ cursor.execute("INSERT INTO " + new_table + " (bantime, server_ip, server_port, round_id, role, expiration_time, applies_to_admins, reason, ckey, ip, computerid, a_ckey, a_ip, a_computerid, who, adminwho, edits, unbanned_datetime, unbanned_ckey, unbanned_ip, unbanned_computerid) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", (bantime, server_ip, server_port, round_id, role, expiration_time, applies_to_admins, reason, ckey, ip, computerid, a_ckey, a_ip, a_computerid, who, adminwho, edits, unbanned_datetime, unbanned_ckey, unbanned_ip, unbanned_computerid))
+ db.commit()
+ end_time = datetime.now()
+ print("Conversion completed at {0}".format(datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
+ print("Script duration: {0}".format(end_time - start_time))
+except Exception as e:
+ end_time = datetime.now()
+ print("Error encountered on row ID {0} at {1}".format(current_id[0], datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
+ print("Script duration: {0}".format(end_time - start_time))
+ cursor.execute("TRUNCATE {0} ".format(new_table))
+ raise e
+cursor.close()
diff --git a/SQL/database_changelog.txt b/SQL/database_changelog.txt
index 56f05e84f10..24ad3f1a659 100644
--- a/SQL/database_changelog.txt
+++ b/SQL/database_changelog.txt
@@ -2,14 +2,52 @@ Any time you make a change to the schema files, remember to increment the databa
The latest database version is 4.7; The query to update the schema revision table is:
-INSERT INTO `schema_revision` (`major`, `minor`) VALUES (4, 7);
+INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 0);
or
-INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (4, 7);
+INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 0);
In any query remember to add a prefix to the table names if you use one.
----------------------------------------------------
+Version 5.0, 28 October 2018, by Jordie0608
+Modified ban table to remove the need for the `bantype` column, a python script is used to migrate data to this new format.
+
+See the file 'ban_conversion_2018-10-28.py' for instructions on how to use the script.
+
+A new ban table can be created with the query:
+CREATE TABLE `ban` (
+ `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `bantime` DATETIME NOT NULL,
+ `server_ip` INT(10) UNSIGNED NOT NULL,
+ `server_port` SMALLINT(5) UNSIGNED NOT NULL,
+ `round_id` INT(11) UNSIGNED NOT NULL,
+ `role` VARCHAR(32) NULL DEFAULT NULL,
+ `expiration_time` DATETIME NULL DEFAULT NULL,
+ `applies_to_admins` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
+ `reason` VARCHAR(2048) NOT NULL,
+ `ckey` VARCHAR(32) NULL DEFAULT NULL,
+ `ip` INT(10) UNSIGNED NULL DEFAULT NULL,
+ `computerid` VARCHAR(32) NULL DEFAULT NULL,
+ `a_ckey` VARCHAR(32) NOT NULL,
+ `a_ip` INT(10) UNSIGNED NOT NULL,
+ `a_computerid` VARCHAR(32) NOT NULL,
+ `who` VARCHAR(2048) NOT NULL,
+ `adminwho` VARCHAR(2048) NOT NULL,
+ `edits` TEXT NULL DEFAULT NULL,
+ `unbanned_datetime` DATETIME NULL DEFAULT NULL,
+ `unbanned_ckey` VARCHAR(32) NULL DEFAULT NULL,
+ `unbanned_ip` INT(10) UNSIGNED NULL DEFAULT NULL,
+ `unbanned_computerid` VARCHAR(32) NULL DEFAULT NULL,
+ `unbanned_round_id` INT(11) UNSIGNED NULL DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ KEY `idx_ban_isbanned` (`ckey`,`role`,`unbanned_datetime`,`expiration_time`),
+ KEY `idx_ban_isbanned_details` (`ckey`,`ip`,`computerid`,`role`,`unbanned_datetime`,`expiration_time`),
+ KEY `idx_ban_count` (`bantime`,`a_ckey`,`applies_to_admins`,`unbanned_datetime`,`expiration_time`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+----------------------------------------------------
+
Version 4.7, 18 August 2018, by CitrusGender
Modified table `messages`, adding column `severity` to classify notes based on their severity.
diff --git a/SQL/tgstation_schema.sql b/SQL/tgstation_schema.sql
index dc0861220ae..6127c5b37de 100644
--- a/SQL/tgstation_schema.sql
+++ b/SQL/tgstation_schema.sql
@@ -67,34 +67,33 @@ DROP TABLE IF EXISTS `ban`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `ban` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `bantime` datetime NOT NULL,
- `server_ip` int(10) unsigned NOT NULL,
- `server_port` smallint(5) unsigned NOT NULL,
- `round_id` int(11) NOT NULL,
- `bantype` enum('PERMABAN','TEMPBAN','JOB_PERMABAN','JOB_TEMPBAN','ADMIN_PERMABAN','ADMIN_TEMPBAN') NOT NULL,
- `reason` varchar(2048) NOT NULL,
- `job` varchar(32) DEFAULT NULL,
- `duration` int(11) NOT NULL,
- `expiration_time` datetime NOT NULL,
- `ckey` varchar(32) NOT NULL,
- `computerid` varchar(32) NOT NULL,
- `ip` int(10) unsigned NOT NULL,
- `a_ckey` varchar(32) NOT NULL,
- `a_computerid` varchar(32) NOT NULL,
- `a_ip` int(10) unsigned NOT NULL,
- `who` varchar(2048) NOT NULL,
- `adminwho` varchar(2048) NOT NULL,
- `edits` text,
- `unbanned` tinyint(3) unsigned DEFAULT NULL,
- `unbanned_datetime` datetime DEFAULT NULL,
- `unbanned_ckey` varchar(32) DEFAULT NULL,
- `unbanned_computerid` varchar(32) DEFAULT NULL,
- `unbanned_ip` int(10) unsigned DEFAULT NULL,
+ `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `bantime` DATETIME NOT NULL,
+ `server_ip` INT(10) UNSIGNED NOT NULL,
+ `server_port` SMALLINT(5) UNSIGNED NOT NULL,
+ `round_id` INT(11) UNSIGNED NOT NULL,
+ `role` VARCHAR(32) NULL DEFAULT NULL,
+ `expiration_time` DATETIME NULL DEFAULT NULL,
+ `applies_to_admins` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
+ `reason` VARCHAR(2048) NOT NULL,
+ `ckey` VARCHAR(32) NULL DEFAULT NULL,
+ `ip` INT(10) UNSIGNED NULL DEFAULT NULL,
+ `computerid` VARCHAR(32) NULL DEFAULT NULL,
+ `a_ckey` VARCHAR(32) NOT NULL,
+ `a_ip` INT(10) UNSIGNED NOT NULL,
+ `a_computerid` VARCHAR(32) NOT NULL,
+ `who` VARCHAR(2048) NOT NULL,
+ `adminwho` VARCHAR(2048) NOT NULL,
+ `edits` TEXT NULL DEFAULT NULL,
+ `unbanned_datetime` DATETIME NULL DEFAULT NULL,
+ `unbanned_ckey` VARCHAR(32) NULL DEFAULT NULL,
+ `unbanned_ip` INT(10) UNSIGNED NULL DEFAULT NULL,
+ `unbanned_computerid` VARCHAR(32) NULL DEFAULT NULL,
+ `unbanned_round_id` INT(11) UNSIGNED NULL DEFAULT NULL,
PRIMARY KEY (`id`),
- KEY `idx_ban_checkban` (`ckey`,`bantype`,`expiration_time`,`unbanned`,`job`),
- KEY `idx_ban_isbanned` (`ckey`,`ip`,`computerid`,`bantype`,`expiration_time`,`unbanned`),
- KEY `idx_ban_count` (`id`,`a_ckey`,`bantype`,`expiration_time`,`unbanned`)
+ KEY `idx_ban_isbanned` (`ckey`,`role`,`unbanned_datetime`,`expiration_time`),
+ KEY `idx_ban_isbanned_details` (`ckey`,`ip`,`computerid`,`role`,`unbanned_datetime`,`expiration_time`),
+ KEY `idx_ban_count` (`bantime`,`a_ckey`,`applies_to_admins`,`unbanned_datetime`,`expiration_time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
diff --git a/SQL/tgstation_schema_prefixed.sql b/SQL/tgstation_schema_prefixed.sql
index 5cb57a9582e..e17ef712472 100644
--- a/SQL/tgstation_schema_prefixed.sql
+++ b/SQL/tgstation_schema_prefixed.sql
@@ -67,34 +67,33 @@ DROP TABLE IF EXISTS `SS13_ban`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `SS13_ban` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `bantime` datetime NOT NULL,
- `server_ip` int(10) unsigned NOT NULL,
- `server_port` smallint(5) unsigned NOT NULL,
- `round_id` int(11) NOT NULL,
- `bantype` enum('PERMABAN','TEMPBAN','JOB_PERMABAN','JOB_TEMPBAN','ADMIN_PERMABAN','ADMIN_TEMPBAN') NOT NULL,
- `reason` varchar(2048) NOT NULL,
- `job` varchar(32) DEFAULT NULL,
- `duration` int(11) NOT NULL,
- `expiration_time` datetime NOT NULL,
- `ckey` varchar(32) NOT NULL,
- `computerid` varchar(32) NOT NULL,
- `ip` int(10) unsigned NOT NULL,
- `a_ckey` varchar(32) NOT NULL,
- `a_computerid` varchar(32) NOT NULL,
- `a_ip` int(10) unsigned NOT NULL,
- `who` varchar(2048) NOT NULL,
- `adminwho` varchar(2048) NOT NULL,
- `edits` text,
- `unbanned` tinyint(3) unsigned DEFAULT NULL,
- `unbanned_datetime` datetime DEFAULT NULL,
- `unbanned_ckey` varchar(32) DEFAULT NULL,
- `unbanned_computerid` varchar(32) DEFAULT NULL,
- `unbanned_ip` int(10) unsigned DEFAULT NULL,
+ `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `bantime` DATETIME NOT NULL,
+ `server_ip` INT(10) UNSIGNED NOT NULL,
+ `server_port` SMALLINT(5) UNSIGNED NOT NULL,
+ `round_id` INT(11) UNSIGNED NOT NULL,
+ `role` VARCHAR(32) NULL DEFAULT NULL,
+ `expiration_time` DATETIME NULL DEFAULT NULL,
+ `applies_to_admins` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
+ `reason` VARCHAR(2048) NOT NULL,
+ `ckey` VARCHAR(32) NULL DEFAULT NULL,
+ `ip` INT(10) UNSIGNED NULL DEFAULT NULL,
+ `computerid` VARCHAR(32) NULL DEFAULT NULL,
+ `a_ckey` VARCHAR(32) NOT NULL,
+ `a_ip` INT(10) UNSIGNED NOT NULL,
+ `a_computerid` VARCHAR(32) NOT NULL,
+ `who` VARCHAR(2048) NOT NULL,
+ `adminwho` VARCHAR(2048) NOT NULL,
+ `edits` TEXT NULL DEFAULT NULL,
+ `unbanned_datetime` DATETIME NULL DEFAULT NULL,
+ `unbanned_ckey` VARCHAR(32) NULL DEFAULT NULL,
+ `unbanned_ip` INT(10) UNSIGNED NULL DEFAULT NULL,
+ `unbanned_computerid` VARCHAR(32) NULL DEFAULT NULL,
+ `unbanned_round_id` INT(11) UNSIGNED NULL DEFAULT NULL,
PRIMARY KEY (`id`),
- KEY `idx_ban_checkban` (`ckey`,`bantype`,`expiration_time`,`unbanned`,`job`),
- KEY `idx_ban_isbanned` (`ckey`,`ip`,`computerid`,`bantype`,`expiration_time`,`unbanned`),
- KEY `idx_ban_count` (`id`,`a_ckey`,`bantype`,`expiration_time`,`unbanned`)
+ KEY `idx_ban_isbanned` (`ckey`,`role`,`unbanned_datetime`,`expiration_time`),
+ KEY `idx_ban_isbanned_details` (`ckey`,`ip`,`computerid`,`role`,`unbanned_datetime`,`expiration_time`),
+ KEY `idx_ban_count` (`bantime`,`a_ckey`,`applies_to_admins`,`unbanned_datetime`,`expiration_time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
diff --git a/code/__DEFINES/role_preferences.dm b/code/__DEFINES/role_preferences.dm
index b694d101761..edf8af92f81 100644
--- a/code/__DEFINES/role_preferences.dm
+++ b/code/__DEFINES/role_preferences.dm
@@ -6,35 +6,35 @@
//These are synced with the Database, if you change the values of the defines
//then you MUST update the database!
-#define ROLE_SYNDICATE "Syndicate"
-#define ROLE_TRAITOR "traitor"
-#define ROLE_OPERATIVE "operative"
-#define ROLE_CHANGELING "changeling"
-#define ROLE_WIZARD "wizard"
-#define ROLE_MALF "malf AI"
-#define ROLE_REV "revolutionary"
-#define ROLE_REV_HEAD "Head Revolutionary"
-#define ROLE_ALIEN "xenomorph"
-#define ROLE_PAI "pAI"
-#define ROLE_CULTIST "cultist"
-#define ROLE_BLOB "blob"
-#define ROLE_NINJA "space ninja"
-#define ROLE_MONKEY "monkey"
-#define ROLE_ABDUCTOR "abductor"
-#define ROLE_REVENANT "revenant"
-#define ROLE_DEVIL "devil"
-#define ROLE_SERVANT_OF_RATVAR "servant of Ratvar"
-#define ROLE_BROTHER "blood brother"
-#define ROLE_BRAINWASHED "brainwashed victim"
-#define ROLE_OVERTHROW "syndicate mutineer"
-#define ROLE_HIVE "hivemind host"
-#define ROLE_SENTIENCE "sentience potion spawn"
-#define ROLE_MIND_TRANSFER "mind transfer potion"
-#define ROLE_POSIBRAIN "posibrain"
-#define ROLE_DRONE "drone"
-#define ROLE_DEATHSQUAD "deathsquad"
-#define ROLE_LAVALAND "lavaland"
-#define ROLE_INTERNAL_AFFAIRS "internal affairs agent"
+#define ROLE_SYNDICATE "Syndicate"
+#define ROLE_TRAITOR "Traitor"
+#define ROLE_OPERATIVE "Operative"
+#define ROLE_CHANGELING "Changeling"
+#define ROLE_WIZARD "Wizard"
+#define ROLE_MALF "Malf AI"
+#define ROLE_REV "Revolutionary"
+#define ROLE_REV_HEAD "Head Revolutionary"
+#define ROLE_ALIEN "Xenomorph"
+#define ROLE_PAI "pAI"
+#define ROLE_CULTIST "Cultist"
+#define ROLE_BLOB "Blob"
+#define ROLE_NINJA "Space Ninja"
+#define ROLE_MONKEY "Monkey"
+#define ROLE_ABDUCTOR "Abductor"
+#define ROLE_REVENANT "Revenant"
+#define ROLE_DEVIL "Devil"
+#define ROLE_SERVANT_OF_RATVAR "Servant of Ratvar"
+#define ROLE_BROTHER "Blood Brother"
+#define ROLE_BRAINWASHED "Brainwashed Victim"
+#define ROLE_OVERTHROW "Syndicate Mutineer"
+#define ROLE_HIVE "Hivemind Host"
+#define ROLE_SENTIENCE "Sentience Potion Spawn"
+#define ROLE_MIND_TRANSFER "Mind Transfer Potion"
+#define ROLE_POSIBRAIN "Posibrain"
+#define ROLE_DRONE "Drone"
+#define ROLE_DEATHSQUAD "Deathsquad"
+#define ROLE_LAVALAND "Lavaland"
+#define ROLE_INTERNAL_AFFAIRS "Internal Affairs Agent"
//Missing assignment means it's not a gamemode specific role, IT'S NOT A BUG OR ERROR.
//The gamemode specific ones are just so the gamemodes can query whether a player is old enough
diff --git a/code/__DEFINES/subsystems.dm b/code/__DEFINES/subsystems.dm
index 39da6d14099..89f281678a8 100644
--- a/code/__DEFINES/subsystems.dm
+++ b/code/__DEFINES/subsystems.dm
@@ -1,7 +1,7 @@
//Update this whenever the db schema changes
//make sure you add an update to the schema_version stable in the db changelog
-#define DB_MAJOR_VERSION 4
-#define DB_MINOR_VERSION 7
+#define DB_MAJOR_VERSION 5
+#define DB_MINOR_VERSION 0
//Timing subsystem
//Don't run if there is an identical unique timer active
diff --git a/code/__HELPERS/game.dm b/code/__HELPERS/game.dm
index 0655e8f53e8..62cff3e6bb7 100644
--- a/code/__HELPERS/game.dm
+++ b/code/__HELPERS/game.dm
@@ -433,7 +433,7 @@
if(!gametypeCheck.age_check(M.client))
continue
if(jobbanType)
- if(jobban_isbanned(M, jobbanType) || QDELETED(M) || jobban_isbanned(M, ROLE_SYNDICATE) || QDELETED(M))
+ if(is_banned_from(M.ckey, list(jobbanType, ROLE_SYNDICATE)) || QDELETED(M))
continue
showCandidatePollWindow(M, poll_time, Question, result, ignore_category, time_passed, flashwindow)
@@ -494,7 +494,7 @@
if(!C || (!C.prefs.windowflashing && !ignorepref))
return
winset(C, "mainwindow", "flash=5")
-
+
//Recursively checks if an item is inside a given type, even through layers of storage. Returns the atom if it finds it.
/proc/recursive_loc_check(atom/movable/target, type)
var/atom/A = target
diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm
index f37269a1024..27b7eb75a94 100644
--- a/code/__HELPERS/unsorted.dm
+++ b/code/__HELPERS/unsorted.dm
@@ -203,7 +203,7 @@ Turf and target are separate in case you want to teleport some distance from a t
var/loop = 1
var/safety = 0
- var/banned = jobban_isbanned(src, "appearance")
+ var/banned = is_banned_from(C.ckey, "Appearance")
while(loop && safety < 5)
if(C && C.prefs.custom_names[role] && !safety && !banned)
diff --git a/code/controllers/configuration/entries/general.dm b/code/controllers/configuration/entries/general.dm
index b73f2bdebba..807b7209ff0 100644
--- a/code/controllers/configuration/entries/general.dm
+++ b/code/controllers/configuration/entries/general.dm
@@ -153,9 +153,6 @@
/datum/config_entry/flag/usewhitelist
-/datum/config_entry/flag/ban_legacy_system //Defines whether the server uses the legacy banning system with the files in /data or the SQL system.
- protection = CONFIG_ENTRY_LOCKED
-
/datum/config_entry/flag/use_age_restriction_for_jobs //Do jobs use account age restrictions? --requires database
/datum/config_entry/flag/use_account_age_for_jobs //Uses the time they made the account for the job restriction stuff. New player joining alerts should be unaffected.
diff --git a/code/controllers/subsystem/job.dm b/code/controllers/subsystem/job.dm
index ab6cf5124c5..e56bf79e797 100644
--- a/code/controllers/subsystem/job.dm
+++ b/code/controllers/subsystem/job.dm
@@ -79,7 +79,7 @@ SUBSYSTEM_DEF(job)
var/datum/job/job = GetJob(rank)
if(!job)
return FALSE
- if(jobban_isbanned(player, rank) || QDELETED(player))
+ if(is_banned_from(player.ckey, rank) || QDELETED(player))
return FALSE
if(!job.player_old_enough(player.client))
return FALSE
@@ -101,7 +101,7 @@ SUBSYSTEM_DEF(job)
JobDebug("Running FOC, Job: [job], Level: [level], Flag: [flag]")
var/list/candidates = list()
for(var/mob/dead/new_player/player in unassigned)
- if(jobban_isbanned(player, job.title) || QDELETED(player))
+ if(is_banned_from(player.ckey, job.title) || QDELETED(player))
JobDebug("FOC isbanned failed, Player: [player]")
continue
if(!job.player_old_enough(player.client))
@@ -134,7 +134,7 @@ SUBSYSTEM_DEF(job)
if(job.title in GLOB.command_positions) //If you want a command position, select it!
continue
- if(jobban_isbanned(player, job.title) || QDELETED(player))
+ if(is_banned_from(player.ckey, job.title) || QDELETED(player))
if(QDELETED(player))
JobDebug("GRJ isbanned failed, Player deleted")
break
@@ -311,7 +311,7 @@ SUBSYSTEM_DEF(job)
if(!job)
continue
- if(jobban_isbanned(player, job.title))
+ if(is_banned_from(player.ckey, job.title))
JobDebug("DO isbanned failed, Player: [player], Job:[job.title]")
continue
@@ -360,7 +360,7 @@ SUBSYSTEM_DEF(job)
if(PopcapReached())
RejectPlayer(player)
else if(player.client.prefs.joblessrole == BEOVERFLOW)
- var/allowed_to_be_a_loser = !jobban_isbanned(player, SSjob.overflow_role)
+ var/allowed_to_be_a_loser = !is_banned_from(player.ckey, SSjob.overflow_role)
if(QDELETED(player) || !allowed_to_be_a_loser)
RejectPlayer(player)
else
@@ -489,7 +489,7 @@ SUBSYSTEM_DEF(job)
for(var/mob/dead/new_player/player in GLOB.player_list)
if(!(player.ready == PLAYER_READY_TO_PLAY && player.mind && !player.mind.assigned_role))
continue //This player is not ready
- if(jobban_isbanned(player, job.title) || QDELETED(player))
+ if(is_banned_from(player.ckey, job.title) || QDELETED(player))
banned++
continue
if(!job.player_old_enough(player.client))
diff --git a/code/datums/diseases/transformation.dm b/code/datums/diseases/transformation.dm
index 9dde4f01577..51abd1f47ac 100644
--- a/code/datums/diseases/transformation.dm
+++ b/code/datums/diseases/transformation.dm
@@ -61,7 +61,7 @@
affected_mob.dropItemToGround(I)
var/mob/living/new_mob = new new_form(affected_mob.loc)
if(istype(new_mob))
- if(bantype && jobban_isbanned(affected_mob, bantype))
+ if(bantype && is_banned_from(affected_mob.ckey, bantype))
replace_banned_player(new_mob)
new_mob.a_intent = INTENT_HARM
if(affected_mob.mind)
diff --git a/code/game/gamemodes/changeling/changeling.dm b/code/game/gamemodes/changeling/changeling.dm
index 98c9a0bfc91..a7f6065bc10 100644
--- a/code/game/gamemodes/changeling/changeling.dm
+++ b/code/game/gamemodes/changeling/changeling.dm
@@ -84,7 +84,7 @@ GLOBAL_VAR(changeling_team_objective_type) //If this is not null, we hand our th
return
if(changelings.len <= (changelingcap - 2) || prob(100 - (csc * 2)))
if(ROLE_CHANGELING in character.client.prefs.be_special)
- if(!jobban_isbanned(character, ROLE_CHANGELING) && !QDELETED(character) && !jobban_isbanned(character, ROLE_SYNDICATE) && !QDELETED(character))
+ if(!is_banned_from(character.ckey, list(ROLE_CHANGELING, ROLE_SYNDICATE)) && !QDELETED(character))
if(age_check(character.client))
if(!(character.job in restricted_jobs))
character.mind.make_Changeling()
diff --git a/code/game/gamemodes/changeling/traitor_chan.dm b/code/game/gamemodes/changeling/traitor_chan.dm
index 9f6fe524cbe..70c04cb008f 100644
--- a/code/game/gamemodes/changeling/traitor_chan.dm
+++ b/code/game/gamemodes/changeling/traitor_chan.dm
@@ -70,7 +70,7 @@
return
if(changelings.len <= (changelingcap - 2) || prob(100 / (csc * 4)))
if(ROLE_CHANGELING in character.client.prefs.be_special)
- if(!jobban_isbanned(character, ROLE_CHANGELING) && !QDELETED(character) && !jobban_isbanned(character, ROLE_SYNDICATE) && !QDELETED(character))
+ if(!is_banned_from(character.ckey, list(ROLE_CHANGELING, ROLE_SYNDICATE)) && !QDELETED(character))
if(age_check(character.client))
if(!(character.job in restricted_jobs))
character.mind.make_Changeling()
diff --git a/code/game/gamemodes/game_mode.dm b/code/game/gamemodes/game_mode.dm
index 3fbeb5f754c..e1945ea4d8e 100644
--- a/code/game/gamemodes/game_mode.dm
+++ b/code/game/gamemodes/game_mode.dm
@@ -368,7 +368,7 @@
for(var/mob/dead/new_player/player in players)
if(player.client && player.ready == PLAYER_READY_TO_PLAY)
if(role in player.client.prefs.be_special)
- if(!jobban_isbanned(player, ROLE_SYNDICATE) && !QDELETED(player) && !jobban_isbanned(player, role) && !QDELETED(player)) //Nodrak/Carn: Antag Job-bans
+ if(!is_banned_from(player.ckey, list(role, ROLE_SYNDICATE)) && !QDELETED(player))
if(age_check(player.client)) //Must be older than the minimum age
candidates += player.mind // Get a list of all the people who want to be the antagonist for this round
@@ -382,7 +382,7 @@
for(var/mob/dead/new_player/player in players)
if(player.client && player.ready == PLAYER_READY_TO_PLAY)
if(!(role in player.client.prefs.be_special)) // We don't have enough people who want to be antagonist, make a separate list of people who don't want to be one
- if(!jobban_isbanned(player, ROLE_SYNDICATE) && !QDELETED(player) && !jobban_isbanned(player, role) && !QDELETED(player) ) //Nodrak/Carn: Antag Job-bans
+ if(!is_banned_from(player.ckey, list(role, ROLE_SYNDICATE)) && !QDELETED(player))
drafted += player.mind
if(restricted_jobs)
diff --git a/code/game/gamemodes/traitor/traitor.dm b/code/game/gamemodes/traitor/traitor.dm
index a00797bde49..fe8948ed0d6 100644
--- a/code/game/gamemodes/traitor/traitor.dm
+++ b/code/game/gamemodes/traitor/traitor.dm
@@ -86,7 +86,7 @@
return
if((SSticker.mode.traitors.len + pre_traitors.len) <= (traitorcap - 2) || prob(100 / (tsc * 2)))
if(antag_flag in character.client.prefs.be_special)
- if(!jobban_isbanned(character, ROLE_TRAITOR) && !QDELETED(character) && !jobban_isbanned(character, ROLE_SYNDICATE) && !QDELETED(character))
+ if(!is_banned_from(character.ckey, list(ROLE_TRAITOR, ROLE_SYNDICATE)) && !QDELETED(character))
if(age_check(character.client))
if(!(character.job in restricted_jobs))
add_latejoin_traitor(character.mind)
@@ -97,4 +97,4 @@
/datum/game_mode/traitor/generate_report()
return "Although more specific threats are commonplace, you should always remain vigilant for Syndicate agents aboard your station. Syndicate communications have implied that many \
- Nanotrasen employees are Syndicate agents with hidden memories that may be activated at a moment's notice, so it's possible that these agents might not even know their positions."
\ No newline at end of file
+ Nanotrasen employees are Syndicate agents with hidden memories that may be activated at a moment's notice, so it's possible that these agents might not even know their positions."
diff --git a/code/game/objects/items/robot/robot_parts.dm b/code/game/objects/items/robot/robot_parts.dm
index 5538493d717..e4d7c3384d8 100644
--- a/code/game/objects/items/robot/robot_parts.dm
+++ b/code/game/objects/items/robot/robot_parts.dm
@@ -262,7 +262,7 @@
to_chat(user, "The MMI indicates that the brain is damaged!")
return
- if(jobban_isbanned(BM, "Cyborg") || QDELETED(src) || QDELETED(BM) || QDELETED(user) || QDELETED(M) || !Adjacent(user))
+ if(is_banned_from(BM.ckey, "Cyborg") || QDELETED(src) || QDELETED(BM) || QDELETED(user) || QDELETED(M) || !Adjacent(user))
if(!QDELETED(M))
to_chat(user, "This [M.name] does not seem to fit!")
return
diff --git a/code/game/objects/structures/ai_core.dm b/code/game/objects/structures/ai_core.dm
index fd71fb26aee..390e28893d8 100644
--- a/code/game/objects/structures/ai_core.dm
+++ b/code/game/objects/structures/ai_core.dm
@@ -195,7 +195,7 @@
to_chat(user, "Sticking an inactive [M.name] into the frame would sort of defeat the purpose.")
return
- if(!CONFIG_GET(flag/allow_ai) || (jobban_isbanned(M.brainmob, "AI") && !QDELETED(src) && !QDELETED(user) && !QDELETED(M) && !QDELETED(user) && Adjacent(user)))
+ if(!CONFIG_GET(flag/allow_ai) || (is_banned_from(M.brainmob.ckey, "AI") && !QDELETED(src) && !QDELETED(user) && !QDELETED(M) && !QDELETED(user) && Adjacent(user)))
if(!QDELETED(M))
to_chat(user, "This [M.name] does not seem to fit!")
return
diff --git a/code/game/world.dm b/code/game/world.dm
index f293db27d0d..e1e75a87c7a 100644
--- a/code/game/world.dm
+++ b/code/game/world.dm
@@ -36,7 +36,6 @@ GLOBAL_VAR_INIT(bypass_tgs_reboot, world.system_type == UNIX && world.byond_buil
LoadVerbs(/datum/verbs/menu)
if(CONFIG_GET(flag/usewhitelist))
load_whitelist()
- LoadBans()
GLOB.timezoneOffset = text2num(time2text(0,"hh")) * 36000
diff --git a/code/modules/admin/DB_ban/functions.dm b/code/modules/admin/DB_ban/functions.dm
deleted file mode 100644
index f60ec22489a..00000000000
--- a/code/modules/admin/DB_ban/functions.dm
+++ /dev/null
@@ -1,561 +0,0 @@
-#define MAX_ADMIN_BANS_PER_ADMIN 1
-#define MAX_ADMIN_BANS_PER_HEADMIN 3
-
-//Either pass the mob you wish to ban in the 'banned_mob' attribute, or the banckey, banip and bancid variables. If both are passed, the mob takes priority! If a mob is not passed, banckey is the minimum that needs to be passed! banip and bancid are optional.
-/datum/admins/proc/DB_ban_record(bantype, mob/banned_mob, duration = -1, reason, job = "", bankey = null, banip = null, bancid = null)
-
- if(!check_rights(R_BAN))
- return
-
- if(!SSdbcore.Connect())
- to_chat(src, "Failed to establish database connection.")
- return
-
- var/bantype_pass = 0
- var/bantype_str
- var/maxadminbancheck //Used to limit the number of active bans of a certein type that each admin can give. Used to protect against abuse or mutiny.
- var/announceinirc //When set, it announces the ban in irc. Intended to be a way to raise an alarm, so to speak.
- var/blockselfban //Used to prevent the banning of yourself.
- var/kickbannedckey //Defines whether this proc should kick the banned person, if they are connected (if banned_mob is defined).
- //some ban types kick players after this proc passes (tempban, permaban), but some are specific to db_ban, so
- //they should kick within this proc.
- switch(bantype)
- if(BANTYPE_PERMA)
- bantype_str = "PERMABAN"
- duration = -1
- bantype_pass = 1
- blockselfban = 1
- if(BANTYPE_TEMP)
- bantype_str = "TEMPBAN"
- bantype_pass = 1
- blockselfban = 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_ADMIN_PERMA)
- bantype_str = "ADMIN_PERMABAN"
- duration = -1
- bantype_pass = 1
- maxadminbancheck = 1
- announceinirc = 1
- blockselfban = 1
- kickbannedckey = 1
- if(BANTYPE_ADMIN_TEMP)
- bantype_str = "ADMIN_TEMPBAN"
- bantype_pass = 1
- maxadminbancheck = 1
- announceinirc = 1
- blockselfban = 1
- kickbannedckey = 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
- bankey = banned_mob.key
- if(banned_mob.client)
- computerid = banned_mob.client.computer_id
- ip = banned_mob.client.address
- else
- computerid = banned_mob.computer_id
- ip = banned_mob.lastKnownIP
- else if(bankey)
- ckey = ckey(bankey)
- computerid = bancid
- ip = banip
-
- var/had_banned_mob = banned_mob != null
- var/client/banned_client = banned_mob?.client
- var/banned_mob_guest_key = had_banned_mob && IsGuestKey(banned_mob.key)
- banned_mob = null
- var/sql_ckey = sanitizeSQL(ckey)
- var/datum/DBQuery/query_add_ban_get_ckey = SSdbcore.NewQuery("SELECT 1 FROM [format_table_name("player")] WHERE ckey = '[sql_ckey]'")
- if(!query_add_ban_get_ckey.warn_execute())
- qdel(query_add_ban_get_ckey)
- return
- var/seen_before = query_add_ban_get_ckey.NextRow()
- qdel(query_add_ban_get_ckey)
- if(!seen_before)
- if(!had_banned_mob || (had_banned_mob && !banned_mob_guest_key))
- if(alert(usr, "[bankey] has not been seen before, are you sure you want to create a ban for them?", "Unknown ckey", "Yes", "No", "Cancel") != "Yes")
- return
-
- var/a_key
- var/a_ckey
- var/a_computerid
- var/a_ip
-
- if(istype(owner))
- a_key = owner.key
- a_ckey = owner.ckey
- a_computerid = owner.computer_id
- a_ip = owner.address
-
- if(blockselfban)
- if(a_ckey == ckey)
- to_chat(usr, "You cannot apply this ban type on yourself.")
- return
-
- var/who
- for(var/client/C in GLOB.clients)
- if(!who)
- who = "[C]"
- else
- who += ", [C]"
-
- var/adminwho
- for(var/client/C in GLOB.admins)
- if(!adminwho)
- adminwho = "[C]"
- else
- adminwho += ", [C]"
-
- reason = sanitizeSQL(reason)
- var/sql_a_ckey = sanitizeSQL(a_ckey)
- if(maxadminbancheck)
- var/datum/DBQuery/query_check_adminban_amt = SSdbcore.NewQuery("SELECT count(id) AS num FROM [format_table_name("ban")] WHERE (a_ckey = '[sql_a_ckey]') AND (bantype = 'ADMIN_PERMABAN' OR (bantype = 'ADMIN_TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)")
- if(!query_check_adminban_amt.warn_execute())
- qdel(query_check_adminban_amt)
- return
- if(query_check_adminban_amt.NextRow())
- var/adm_bans = text2num(query_check_adminban_amt.item[1])
- var/max_bans = MAX_ADMIN_BANS_PER_ADMIN
- if (check_rights(R_PERMISSIONS, FALSE))
- max_bans = MAX_ADMIN_BANS_PER_HEADMIN
- if(adm_bans >= max_bans)
- to_chat(usr, "You already logged [max_bans] admin ban(s) or more. Do not abuse this function!")
- qdel(query_check_adminban_amt)
- return
- qdel(query_check_adminban_amt)
- if(!computerid)
- computerid = "0"
- if(!ip)
- ip = "0.0.0.0"
- var/sql_job = sanitizeSQL(job)
- var/sql_computerid = sanitizeSQL(computerid)
- var/sql_ip = sanitizeSQL(ip)
- var/sql_a_computerid = sanitizeSQL(a_computerid)
- var/sql_a_ip = sanitizeSQL(a_ip)
- var/sql = "INSERT INTO [format_table_name("ban")] (`bantime`,`server_ip`,`server_port`,`round_id`,`bantype`,`reason`,`job`,`duration`,`expiration_time`,`ckey`,`computerid`,`ip`,`a_ckey`,`a_computerid`,`a_ip`,`who`,`adminwho`) VALUES (Now(), INET_ATON(IF('[world.internet_address]' LIKE '', '0', '[world.internet_address]')), '[world.port]', '[GLOB.round_id]', '[bantype_str]', '[reason]', '[sql_job]', [(duration)?"[duration]":"0"], Now() + INTERVAL [(duration>0) ? duration : 0] MINUTE, '[sql_ckey]', '[sql_computerid]', INET_ATON('[sql_ip]'), '[sql_a_ckey]', '[sql_a_computerid]', INET_ATON('[sql_a_ip]'), '[who]', '[adminwho]')"
- var/datum/DBQuery/query_add_ban = SSdbcore.NewQuery(sql)
- if(!query_add_ban.warn_execute())
- qdel(query_add_ban)
- return
- qdel(query_add_ban)
- to_chat(usr, "Ban saved to database.")
- var/msg = "[key_name_admin(usr)] has added a [bantype_str] for [bankey] [(job)?"([job])":""] [(duration > 0)?"([DisplayTimeText(duration MINUTES)])":""] with the reason: \"[reason]\" to the ban database."
- message_admins(msg,1)
- var/datum/admin_help/AH = admin_ticket_log(ckey, msg)
-
- if(announceinirc)
- send2irc("BAN ALERT","[a_key] applied a [bantype_str] on [bankey]")
-
- if(kickbannedckey)
- if(AH)
- AH.Resolve() //with prejudice
- if(banned_client && banned_client.ckey == ckey)
- qdel(banned_client)
- return 1
-
-/datum/admins/proc/DB_ban_unban(ckey, bantype, job = "")
-
- if(!check_rights(R_BAN))
- return
-
- var/bantype_str
- if(bantype)
- var/bantype_pass = 0
- switch(bantype)
- if(BANTYPE_PERMA)
- bantype_str = "PERMABAN"
- bantype_pass = 1
- if(BANTYPE_TEMP)
- bantype_str = "TEMPBAN"
- bantype_pass = 1
- if(BANTYPE_JOB_PERMA)
- bantype_str = "JOB_PERMABAN"
- bantype_pass = 1
- if(BANTYPE_JOB_TEMP)
- bantype_str = "JOB_TEMPBAN"
- bantype_pass = 1
- if(BANTYPE_ADMIN_PERMA)
- bantype_str = "ADMIN_PERMABAN"
- bantype_pass = 1
- if(BANTYPE_ADMIN_TEMP)
- bantype_str = "ADMIN_TEMPBAN"
- bantype_pass = 1
- if(BANTYPE_ANY_FULLBAN)
- bantype_str = "ANY"
- bantype_pass = 1
- if(BANTYPE_ANY_JOB)
- bantype_str = "ANYJOB"
- bantype_pass = 1
- if( !bantype_pass )
- return
-
- var/bantype_sql
- if(bantype_str == "ANY")
- bantype_sql = "(bantype = 'PERMABAN' OR (bantype = 'TEMPBAN' AND expiration_time > Now() ) )"
- else if(bantype_str == "ANYJOB")
- bantype_sql = "(bantype = 'JOB_PERMABAN' OR (bantype = 'JOB_TEMPBAN' AND expiration_time > Now() ) )"
- else
- bantype_sql = "bantype = '[bantype_str]'"
- var/sql_ckey = sanitizeSQL(ckey)
- var/sql = "SELECT id FROM [format_table_name("ban")] WHERE ckey = '[sql_ckey]' AND [bantype_sql] AND (unbanned is null OR unbanned = false)"
- if(job)
- var/sql_job = sanitizeSQL(job)
- sql += " AND job = '[sql_job]'"
-
- if(!SSdbcore.Connect())
- return
-
- var/ban_id
- var/ban_number = 0 //failsafe
-
- var/datum/DBQuery/query_unban_get_id = SSdbcore.NewQuery(sql)
- if(!query_unban_get_id.warn_execute())
- qdel(query_unban_get_id)
- return
- while(query_unban_get_id.NextRow())
- ban_id = query_unban_get_id.item[1]
- ban_number++;
- qdel(query_unban_get_id)
-
- if(ban_number == 0)
- to_chat(usr, "Database update failed due to no bans fitting the search criteria. If this is not a legacy ban you should contact the database admin.")
- return
-
- if(ban_number > 1)
- to_chat(usr, "Database update failed due to multiple bans fitting the search criteria. Note down the ckey, job and current time and contact the database admin.")
- return
-
- if(istext(ban_id))
- ban_id = text2num(ban_id)
- if(!isnum(ban_id))
- to_chat(usr, "Database update failed due to a ban ID mismatch. Contact the database admin.")
- return
-
- DB_ban_unban_by_id(ban_id)
-
-/datum/admins/proc/DB_ban_edit(banid = null, param = null)
-
- if(!check_rights(R_BAN))
- return
-
- if(!isnum(banid) || !istext(param))
- to_chat(usr, "Cancelled")
- return
-
- var/datum/DBQuery/query_edit_ban_get_details = SSdbcore.NewQuery("SELECT IFNULL((SELECT byond_key FROM [format_table_name("player")] WHERE [format_table_name("player")].ckey = [format_table_name("ban")].ckey), ckey), duration, reason FROM [format_table_name("ban")] WHERE id = [banid]")
- if(!query_edit_ban_get_details.warn_execute())
- qdel(query_edit_ban_get_details)
- return
-
- var/e_key = usr.key //Editing admin key
- var/p_key //(banned) Player key
- var/duration //Old duration
- var/reason //Old reason
-
- if(query_edit_ban_get_details.NextRow())
- p_key = query_edit_ban_get_details.item[1]
- duration = query_edit_ban_get_details.item[2]
- reason = query_edit_ban_get_details.item[3]
- else
- to_chat(usr, "Invalid ban id. Contact the database admin")
- qdel(query_edit_ban_get_details)
- return
- qdel(query_edit_ban_get_details)
-
- reason = sanitizeSQL(reason)
- var/value
-
- switch(param)
- if("reason")
- if(!value)
- value = input("Insert the new reason for [p_key]'s ban", "New Reason", "[reason]", null) as null|text
- value = sanitizeSQL(value)
- if(!value)
- to_chat(usr, "Cancelled")
- return
-
- var/datum/DBQuery/query_edit_ban_reason = SSdbcore.NewQuery("UPDATE [format_table_name("ban")] SET reason = '[value]', edits = CONCAT(edits,'- [e_key] changed ban reason from \\\"[reason]\\\" to \\\"[value]\\\" ') WHERE id = [banid]")
- if(!query_edit_ban_reason.warn_execute())
- qdel(query_edit_ban_reason)
- return
- qdel(query_edit_ban_reason)
- message_admins("[key_name_admin(usr)] has edited a ban for [p_key]'s reason from [reason] to [value]")
- if("duration")
- if(!value)
- value = input("Insert the new duration (in minutes) for [p_key]'s ban", "New Duration", "[duration]", null) as null|num
- if(!isnum(value) || !value)
- to_chat(usr, "Cancelled")
- return
-
- var/datum/DBQuery/query_edit_ban_duration = SSdbcore.NewQuery("UPDATE [format_table_name("ban")] SET duration = [value], edits = CONCAT(edits,'- [e_key] changed ban duration from [duration] to [value] '), expiration_time = DATE_ADD(bantime, INTERVAL [value] MINUTE) WHERE id = [banid]")
- if(!query_edit_ban_duration.warn_execute())
- qdel(query_edit_ban_duration)
- return
- qdel(query_edit_ban_duration)
- message_admins("[key_name_admin(usr)] has edited a ban for [p_key]'s duration from [DisplayTimeText(duration MINUTES)] to [DisplayTimeText(value MINUTES)]")
- if("unban")
- if(alert("Unban [p_key]?", "Unban?", "Yes", "No") == "Yes")
- DB_ban_unban_by_id(banid)
- return
- else
- to_chat(usr, "Cancelled")
- return
- else
- to_chat(usr, "Cancelled")
- return
-
-/datum/admins/proc/DB_ban_unban_by_id(id)
-
- if(!check_rights(R_BAN))
- return
-
- var/sql = "SELECT IFNULL((SELECT byond_key FROM [format_table_name("player")] WHERE [format_table_name("player")].ckey = [format_table_name("ban")].ckey), ckey) FROM [format_table_name("ban")] WHERE id = [id]"
-
- if(!SSdbcore.Connect())
- return
-
- var/ban_number = 0 //failsafe
-
- var/p_key
- var/datum/DBQuery/query_unban_get_ckey = SSdbcore.NewQuery(sql)
- if(!query_unban_get_ckey.warn_execute())
- qdel(query_unban_get_ckey)
- return
- while(query_unban_get_ckey.NextRow())
- p_key = query_unban_get_ckey.item[1]
- ban_number++;
- qdel(query_unban_get_ckey)
-
- if(ban_number == 0)
- to_chat(usr, "Database update failed due to a ban id not being present in the database.")
- return
-
- if(ban_number > 1)
- to_chat(usr, "Database update failed due to multiple bans having the same ID. Contact the database admin.")
- return
-
- if(!istype(owner))
- return
-
- var/unban_ckey = owner.ckey
- var/unban_computerid = owner.computer_id
- var/unban_ip = owner.address
-
- var/sql_update = "UPDATE [format_table_name("ban")] SET unbanned = 1, unbanned_datetime = Now(), unbanned_ckey = '[unban_ckey]', unbanned_computerid = '[unban_computerid]', unbanned_ip = INET_ATON('[unban_ip]') WHERE id = [id]"
- var/datum/DBQuery/query_unban = SSdbcore.NewQuery(sql_update)
- if(!query_unban.warn_execute())
- qdel(query_unban)
- return
- qdel(query_unban)
- message_admins("[key_name_admin(usr)] has lifted [p_key]'s ban.")
-
-/client/proc/DB_ban_panel()
- set category = "Admin"
- set name = "Banning Panel"
- set desc = "Edit admin permissions"
-
- if(!holder)
- return
-
- holder.DB_ban_panel()
-
-
-/datum/admins/proc/DB_ban_panel(playerckey, adminckey, ip, cid, page = 0)
- if(!usr.client)
- return
-
- if(!check_rights(R_BAN))
- return
-
- if(!SSdbcore.Connect())
- to_chat(usr, "Failed to establish database connection.")
- return
-
- var/output = "
"
- usr << browse(dat, "window=jobban2;size=800x450")
- return
-
- //JOBBAN'S INNARDS
- else if(href_list["jobban3"])
- if(!check_rights(R_BAN))
- return
- var/mob/M = locate(href_list["jobban4"])
- if(!ismob(M))
- to_chat(usr, "This can only be used on instances of type /mob")
- return
- if(!SSjob)
- to_chat(usr, "Jobs subsystem not initialized yet!")
- return
- //get jobs for department if specified, otherwise just return the one job in a list.
- var/list/joblist = list()
- switch(href_list["jobban3"])
- if("commanddept")
- for(var/jobPos in GLOB.command_positions)
- if(!jobPos)
- continue
- joblist += jobPos
- if("securitydept")
- for(var/jobPos in GLOB.security_positions)
- if(!jobPos)
- continue
- joblist += jobPos
- if("engineeringdept")
- for(var/jobPos in GLOB.engineering_positions)
- if(!jobPos)
- continue
- joblist += jobPos
- if("medicaldept")
- for(var/jobPos in GLOB.medical_positions)
- if(!jobPos)
- continue
- joblist += jobPos
- if("sciencedept")
- for(var/jobPos in GLOB.science_positions)
- if(!jobPos)
- continue
- joblist += jobPos
- if("supplydept")
- for(var/jobPos in GLOB.supply_positions)
- if(!jobPos)
- continue
- joblist += jobPos
- if("civiliandept")
- for(var/jobPos in GLOB.civilian_positions)
- if(!jobPos)
- continue
- joblist += jobPos
- if("nonhumandept")
- for(var/jobPos in GLOB.nonhuman_positions)
- if(!jobPos)
- continue
- joblist += jobPos
- if("ghostroles")
- joblist += list(ROLE_PAI, ROLE_POSIBRAIN, ROLE_DRONE , ROLE_DEATHSQUAD, ROLE_LAVALAND, ROLE_SENTIENCE)
- if("teamantags")
- joblist += list(ROLE_OPERATIVE, ROLE_REV, ROLE_CULTIST, ROLE_SERVANT_OF_RATVAR, ROLE_ABDUCTOR, ROLE_ALIEN)
- if("convertantags")
- joblist += list(ROLE_REV, ROLE_CULTIST, ROLE_SERVANT_OF_RATVAR, ROLE_ALIEN)
- if("otherroles")
- joblist += list(ROLE_MIND_TRANSFER)
- else
- joblist += href_list["jobban3"]
-
- //Create a list of unbanned jobs within joblist
- var/list/notbannedlist = list()
- for(var/job in joblist)
- if(!jobban_isbanned(M, job))
- notbannedlist += job
-
- //Banning comes first
- if(notbannedlist.len) //at least 1 unbanned job exists in joblist so we have stuff to ban.
- var/severity = null
- switch(alert("Temporary Ban for [M.key]?",,"Yes","No", "Cancel"))
- if("Yes")
- var/mins = input(usr,"How long (in minutes)?","Ban time",1440) as num|null
- if(mins <= 0)
- to_chat(usr, "[mins] is not a valid duration.")
- return
- var/reason = input(usr,"Please State Reason For Banning [M.key].","Reason") as message|null
- if(!reason)
- return
- severity = input("Set the severity of the note/ban.", "Severity", null, null) as null|anything in list("High", "Medium", "Minor", "None")
- if(!severity)
- return
- var/msg
- var/fancy_jobban_duration = DisplayTimeText(mins MINUTES)
- for(var/job in notbannedlist)
- if(!DB_ban_record(BANTYPE_JOB_TEMP, M, mins, reason, job))
- to_chat(usr, "Failed to apply ban.")
- return
- if(M.client)
- jobban_buildcache(M.client)
- ban_unban_log_save("[key_name(usr)] temp-jobbanned [key_name(M)] from [job] for [fancy_jobban_duration]. reason: [reason]")
- log_admin_private("[key_name(usr)] temp-jobbanned [key_name(M)] from [job] for [fancy_jobban_duration].")
- if(!msg)
- msg = job
- else
- msg += ", [job]"
- create_message("note", M.key, null, "Banned from [msg] - [reason]", null, null, 0, 0, null, 0, severity)
- message_admins("[key_name_admin(usr)] banned [key_name_admin(M)] from [msg] for [fancy_jobban_duration].")
- to_chat(M, "You have been [(msg == ("ooc" || "appearance")) ? "banned" : "jobbanned"] by [usr.client.key] from: [msg].")
- to_chat(M, "The reason is: [reason]")
- to_chat(M, "This jobban will be lifted in [fancy_jobban_duration].")
- href_list["jobban2"] = 1 // lets it fall through and refresh
- return 1
- if("No")
- var/reason = input(usr,"Please State Reason For Banning [M.key].","Reason") as message|null
- severity = input("Set the severity of the note/ban.", "Severity", null, null) as null|anything in list("High", "Medium", "Minor", "None")
- if(!severity)
- return
- if(reason)
- var/msg
- for(var/job in notbannedlist)
- if(!DB_ban_record(BANTYPE_JOB_PERMA, M, -1, reason, job))
- to_chat(usr, "Failed to apply ban.")
- return
- if(M.client)
- jobban_buildcache(M.client)
- ban_unban_log_save("[key_name(usr)] perma-jobbanned [key_name(M)] from [job]. reason: [reason]")
- log_admin_private("[key_name(usr)] perma-banned [key_name(M)] from [job]")
- if(!msg)
- msg = job
- else
- msg += ", [job]"
- create_message("note", M.key, null, "Banned from [msg] - [reason]", null, null, 0, 0, null, 0, severity)
- message_admins("[key_name_admin(usr)] banned [key_name_admin(M)] from [msg].")
- to_chat(M, "You have been [(msg == ("ooc" || "appearance")) ? "banned" : "jobbanned"] by [usr.client.key] from: [msg].")
- to_chat(M, "The reason is: [reason]")
- to_chat(M, "Jobban can be lifted only upon request.")
- href_list["jobban2"] = 1 // lets it fall through and refresh
- return 1
- if("Cancel")
- return
-
- //Unbanning joblist
- //all jobs in joblist are banned already OR we didn't give a reason (implying they shouldn't be banned)
- if(joblist.len) //at least 1 banned job exists in joblist so we have stuff to unban.
- var/msg
- for(var/job in joblist)
- var/reason = jobban_isbanned(M, job)
- if(!reason)
- continue //skip if it isn't jobbanned anyway
- switch(alert("Job: '[job]' Reason: '[reason]' Un-jobban?","Please Confirm","Yes","No"))
- if("Yes")
- ban_unban_log_save("[key_name(usr)] unjobbanned [key_name(M)] from [job]")
- log_admin_private("[key_name(usr)] unbanned [key_name(M)] from [job]")
- DB_ban_unban(M.ckey, BANTYPE_ANY_JOB, job)
- if(M.client)
- jobban_buildcache(M.client)
- if(!msg)
- msg = job
- else
- msg += ", [job]"
- else
- continue
- if(msg)
- message_admins("[key_name_admin(usr)] unbanned [key_name_admin(M)] from [msg].")
- to_chat(M, "You have been un-jobbanned by [usr.client.key] from [msg].")
- href_list["jobban2"] = 1 // lets it fall through and refresh
- return 1
- return 0 //we didn't do anything!
-
else if(href_list["boot2"])
if(!check_rights(R_ADMIN))
return
@@ -1255,80 +588,6 @@
browser.open()
qdel(query_get_message_edits)
- else if(href_list["newban"])
- if(!check_rights(R_BAN))
- return
-
- var/mob/M = locate(href_list["newban"])
- if(!ismob(M))
- return
-
- if(M.client && M.client.holder)
- return //admins cannot be banned. Even if they could, the ban doesn't affect them anyway
-
- switch(alert("Temporary Ban for [M.key]?",,"Yes","No", "Cancel"))
- if("Yes")
- var/mins = input(usr,"How long (in minutes)?","Ban time",1440) as num|null
- if(mins <= 0)
- to_chat(usr, "[mins] is not a valid duration.")
- return
- var/reason = input(usr,"Please State Reason For Banning [M.key].","Reason") as message|null
- if(!reason)
- return
- if(!DB_ban_record(BANTYPE_TEMP, M, mins, reason))
- to_chat(usr, "Failed to apply ban.")
- return
- AddBan(M.ckey, M.computer_id, reason, usr.ckey, 1, mins)
- var/ban_duration = "[DisplayTimeText(mins MINUTES)]" //convert from minutes into deciseconds to display the amount of time in days, hours, minutes.
- create_message("note", ckey(M.ckey), usr.ckey, "Banned for [ban_duration] - [reason]", null, null, 0, 0, null, 0, 0)
- ban_unban_log_save("[key_name(usr)] has banned [key_name(M)]. - Reason: [reason] - This will be removed in [ban_duration].")
- to_chat(M, "You have been banned by [usr.client.key].\nReason: [reason]")
- to_chat(M, "This is a temporary ban, it will be removed in [ban_duration]. The round ID is [GLOB.round_id].")
- var/bran = CONFIG_GET(string/banappeals)
- if(bran)
- to_chat(M, "To try to resolve this matter head to [bran]")
- else
- to_chat(M, "No ban appeals URL has been set.")
- log_admin_private("[key_name(usr)] has banned [key_name(M)]. - Reason: [key_name(M)] - This will be removed in [ban_duration].")
- var/msg = "[key_name_admin(usr)] has banned [key_name_admin(M)]. - Reason: [reason] - This will be removed in [ban_duration]."
- message_admins(msg)
- var/datum/admin_help/AH = M.client ? M.client.current_ticket : null
- if(AH)
- AH.Resolve()
- qdel(M.client)
- if("No")
- var/reason = input(usr,"Please State Reason For Banning [M.key].","Reason") as message|null
- if(!reason)
- return
- switch(alert(usr,"IP ban?",,"Yes","No","Cancel"))
- if("Cancel")
- return
- if("Yes")
- AddBan(M.ckey, M.computer_id, reason, usr.ckey, 0, 0, M.lastKnownIP)
- if("No")
- AddBan(M.ckey, M.computer_id, reason, usr.ckey, 0, 0)
- create_message("note", ckey(M.ckey), usr.ckey, "Permanently banned - [reason]", null, null, 0, 0, null, 0, 0)
- to_chat(M, "You have been banned by [usr.client.key].\nReason: [reason]")
- to_chat(M, "This is a permanent ban. The round ID is [GLOB.round_id].")
- var/bran = CONFIG_GET(string/banappeals)
- if(bran)
- to_chat(M, "To try to resolve this matter head to [bran]")
- else
- to_chat(M, "No ban appeals URL has been set.")
- if(!DB_ban_record(BANTYPE_PERMA, M, -1, reason))
- to_chat(usr, "Failed to apply ban.")
- return
- ban_unban_log_save("[key_name(usr)] has permabanned [key_name(M)]. - Reason: [reason] - This is a permanent ban.")
- log_admin_private("[key_name(usr)] has banned [key_name(M)]. - Reason: [reason] - This is a permanent ban.")
- var/msg = "[key_name_admin(usr)] has banned [key_name_admin(M)]. - Reason: [reason] - This is a permanent ban."
- message_admins(msg)
- var/datum/admin_help/AH = M.client ? M.client.current_ticket : null
- if(AH)
- AH.Resolve()
- qdel(M.client)
- if("Cancel")
- return
-
else if(href_list["mute"])
if(!check_rights(R_ADMIN))
return
@@ -2565,6 +1824,59 @@
T.admin_remove_member(usr,M)
check_teams()
+ else if(href_list["newbankey"])
+ var/player_key = href_list["newbankey"]
+ var/player_ip = href_list["newbanip"]
+ var/player_cid = href_list["newbancid"]
+ ban_panel(player_key, player_ip, player_cid)
+
+ else if(href_list["intervaltype"]) //check for ban panel, intervaltype is used as it's the only value which will always be present
+ if(href_list["roleban_delimiter"])
+ ban_parse_href(href_list)
+ else
+ ban_parse_href(href_list, TRUE)
+
+ else if(href_list["searchunbankey"] || href_list["searchunbanadminkey"] || href_list["searchunbanip"] || href_list["searchunbancid"])
+ var/player_key = href_list["searchunbankey"]
+ var/admin_key = href_list["searchunbanadminkey"]
+ var/player_ip = href_list["searchunbanip"]
+ var/player_cid = href_list["searchunbancid"]
+ unban_panel(player_key, admin_key, player_ip, player_cid)
+
+ else if(href_list["unbanpagecount"])
+ var/page = href_list["unbanpagecount"]
+ var/player_key = href_list["unbankey"]
+ var/admin_key = href_list["unbanadminkey"]
+ var/player_ip = href_list["unbanip"]
+ var/player_cid = href_list["unbancid"]
+ unban_panel(player_key, admin_key, player_ip, player_cid, page)
+
+ else if(href_list["editbanid"])
+ var/edit_id = href_list["editbanid"]
+ var/player_key = href_list["editbankey"]
+ var/player_ip = href_list["editbanip"]
+ var/player_cid = href_list["editbancid"]
+ var/role = href_list["editbanrole"]
+ var/duration = href_list["editbanduration"]
+ var/applies_to_admins = text2num(href_list["editbanadmins"])
+ var/reason = href_list["editbanreason"]
+ var/page = href_list["editbanpage"]
+ var/admin_key = href_list["editbanadminkey"]
+ ban_panel(player_key, player_ip, player_cid, role, duration, applies_to_admins, reason, edit_id, page, admin_key)
+
+ else if(href_list["unbanid"])
+ var/ban_id = href_list["unbanid"]
+ var/player_key = href_list["unbankey"]
+ var/player_ip = href_list["unbanip"]
+ var/player_cid = href_list["unbancid"]
+ var/role = href_list["unbanrole"]
+ var/page = href_list["unbanpage"]
+ var/admin_key = href_list["unbanadminkey"]
+ unban(ban_id, player_key, player_ip, player_cid, role, page, admin_key)
+
+ else if(href_list["unbanlog"])
+ var/ban_id = href_list["unbanlog"]
+ ban_log(ban_id)
/datum/admins/proc/HandleCMode()
if(!check_rights(R_ADMIN))
diff --git a/code/modules/admin/verbs/one_click_antag.dm b/code/modules/admin/verbs/one_click_antag.dm
index d9732818bdb..ae4241796b0 100644
--- a/code/modules/admin/verbs/one_click_antag.dm
+++ b/code/modules/admin/verbs/one_click_antag.dm
@@ -41,7 +41,7 @@
return FALSE
if(!considered_alive(applicant.mind) || considered_afk(applicant.mind)) //makes sure the player isn't a zombie, brain, or just afk all together
return FALSE
- return (!jobban_isbanned(applicant, targetrole) && !jobban_isbanned(applicant, ROLE_SYNDICATE))
+ return !is_banned_from(applicant.ckey, list(targetrole, ROLE_SYNDICATE))
/datum/admins/proc/makeTraitors()
diff --git a/code/modules/antagonists/_common/antag_datum.dm b/code/modules/antagonists/_common/antag_datum.dm
index ad4851e0c3f..d1c15b15dc0 100644
--- a/code/modules/antagonists/_common/antag_datum.dm
+++ b/code/modules/antagonists/_common/antag_datum.dm
@@ -76,7 +76,7 @@ GLOBAL_LIST_EMPTY(antagonists)
/datum/antagonist/proc/is_banned(mob/M)
if(!M)
return FALSE
- . = (jobban_isbanned(M, ROLE_SYNDICATE) || QDELETED(M) || (job_rank && (jobban_isbanned(M,job_rank) || QDELETED(M))))
+ . = (is_banned_from(M.ckey, list(ROLE_SYNDICATE, job_rank)) || QDELETED(M))
/datum/antagonist/proc/replace_banned_player()
set waitfor = FALSE
diff --git a/code/modules/antagonists/cult/runes.dm b/code/modules/antagonists/cult/runes.dm
index f874566be11..f44be97d2d3 100644
--- a/code/modules/antagonists/cult/runes.dm
+++ b/code/modules/antagonists/cult/runes.dm
@@ -848,7 +848,7 @@ structure_check() searches for nearby cultist structures required for the invoca
notify_ghosts("Manifest rune invoked in [get_area(src)].", 'sound/effects/ghost2.ogg', source = src)
var/list/ghosts_on_rune = list()
for(var/mob/dead/observer/O in T)
- if(O.client && !jobban_isbanned(O, ROLE_CULTIST) && !QDELETED(src) && !QDELETED(O))
+ if(O.client && !is_banned_from(O.ckey, ROLE_CULTIST) && !QDELETED(src) && !QDELETED(O))
ghosts_on_rune += O
if(!ghosts_on_rune.len)
to_chat(user, "There are no spirits near [src]!")
diff --git a/code/modules/awaymissions/corpse.dm b/code/modules/awaymissions/corpse.dm
index 230521e3735..f60deae4618 100644
--- a/code/modules/awaymissions/corpse.dm
+++ b/code/modules/awaymissions/corpse.dm
@@ -36,7 +36,7 @@
if(!uses)
to_chat(user, "This spawner is out of charges!")
return
- if(jobban_isbanned(user, banType))
+ if(is_banned_from(user.key, banType))
to_chat(user, "You are jobanned!")
return
if(QDELETED(src) || QDELETED(user))
diff --git a/code/modules/client/client_defines.dm b/code/modules/client/client_defines.dm
index c85eb95b058..988c8546f1e 100644
--- a/code/modules/client/client_defines.dm
+++ b/code/modules/client/client_defines.dm
@@ -11,7 +11,7 @@
var/datum/click_intercept = null // Needs to implement InterceptClickOn(user,params,atom) proc
var/AI_Interact = 0
- var/jobbancache = null //Used to cache this client's jobbans to save on DB queries
+ var/ban_cache = null //Used to cache this client's bans to save on DB queries
var/last_message = "" //Contains the last message sent by this client - used to protect against copy-paste spamming.
var/last_message_count = 0 //contins a number of how many times a message identical to last_message was sent.
var/ircreplyamount = 0
@@ -72,4 +72,4 @@
var/list/credits //lazy list of all credit object bound to this client
- var/datum/player_details/player_details //these persist between logins/logouts during the same round.
\ No newline at end of file
+ var/datum/player_details/player_details //these persist between logins/logouts during the same round.
diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm
index e03eaf15097..e4b716fd2be 100644
--- a/code/modules/client/preferences.dm
+++ b/code/modules/client/preferences.dm
@@ -197,7 +197,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
dat += "
Current Quirks: [all_quirks.len ? all_quirks.Join(", ") : "None"]
"
dat += "
Identity
"
dat += "
"
- if(jobban_isbanned(user, "appearance"))
+ if(is_banned_from(user.ckey, "Appearance"))
dat += "You are banned from using custom names and appearances. You can continue to adjust your characters, but you will be randomised once you join the game. "
dat += "Random Name "
dat += "Always Random Name: [be_random_name ? "Yes" : "No"] "
@@ -547,14 +547,14 @@ GLOBAL_LIST_EMPTY(preferences_datums)
dat += "
Special Role Settings
"
- if(jobban_isbanned(user, ROLE_SYNDICATE))
- dat += "You are banned from antagonist roles."
+ if(is_banned_from(user.ckey, ROLE_SYNDICATE))
+ dat += "You are banned from antagonist roles. "
src.be_special = list()
for (var/i in GLOB.special_roles)
- if(jobban_isbanned(user, i))
- dat += "Be [capitalize(i)]:BANNED "
+ if(is_banned_from(user.ckey, i))
+ dat += "Be [capitalize(i)]:BANNED "
else
var/days_remaining = null
if(ispath(GLOB.special_roles[i]) && CONFIG_GET(flag/use_age_restriction_for_jobs)) //If it's a game mode antag, check if the player meets the minimum age
@@ -673,8 +673,8 @@ GLOBAL_LIST_EMPTY(preferences_datums)
HTML += "