diff --git a/README.md b/README.md index 212c87e1e8d..3f8c4f97ec5 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ ##DOWNLOADING -There are a number of ways to download the source code. Some are described here, an alternative all-inclusive guide is also located at http://www.tgstation13.org/wiki/index.php/Downloading_the_source_code +There are a number of ways to download the source code. Some are described here, an alternative all-inclusive guide is also located at http://www.tgstation13.org/wiki/Downloading_the_source_code Option 1: Download the source code as a zip by clicking the ZIP button in the code tab of https://github.com/tgstation/-tg-station @@ -25,7 +25,7 @@ Then you simply search for the -tg-station repository and click the big clone button. Option 3: -Follow this: http://www.tgstation13.org/wiki/index.php/Setting_up_git +Follow this: http://www.tgstation13.org/wiki/Setting_up_git (It's recommended that you use git-scm, as above, rather than the git CLI suggested by the guide) @@ -109,7 +109,7 @@ To enable an away mission open fileList.txt in the _maps/RandomZLevels directory The SQL backend for the library and stats tracking requires a MySQL server. Your server details go in /config/dbconfig.txt, and the SQL -schema is in /SQL/tgstation_schema.sql. More detailed setup instructions are located here: http://www.tgstation13.org/wiki/index.php/Downloading_the_source_code#Setting_up_the_database +schema is in /SQL/tgstation_schema.sql and /SQL/tgstation_schema_prefix.sql depending on if you want table prefixes. More detailed setup instructions are located here: http://www.tgstation13.org/wiki/Downloading_the_source_code#Setting_up_the_database ##IRC BOT SETUP diff --git a/SQL/database_changelog.txt b/SQL/database_changelog.txt index fe3c40342da..80af03e4561 100644 --- a/SQL/database_changelog.txt +++ b/SQL/database_changelog.txt @@ -1,3 +1,15 @@ +19 September 2014, by MrStonedOne + +Removed erro_ from table names. dbconfig.txt has a option allowing you to change the prefix used in code, defaults to "erro_" if left out for legacy reasons. + +If you are creating a new database and want to change the prefix, simply find and replace SS13_ to what ever you want (including nothing) and set the prefix value + +Two schema files are now included, one with prefixes and one without. + +If you have an existing database, and you want to rid your database of erros, you will have to rename all of the tables. A bit sql is included to do just that in errofreedatabase.sql Feel free to find and replace the prefix to what ever you want (or nothing) + +---------------------------------------------------- + 4 November 2013, by Errorage The column 'deleted' was added to the erro_library table. If set to anything other than null, the book is interpreted as deleted. @@ -12,4 +24,6 @@ UPDATE erro_library SET deleted = 1 WHERE id = someid (Replace someid with the id of the book you want to soft delete.) ----------------------------------------------------- \ No newline at end of file +---------------------------------------------------- + + diff --git a/SQL/errofreedatabase.sql b/SQL/errofreedatabase.sql new file mode 100644 index 00000000000..ae5c0d7ee1c --- /dev/null +++ b/SQL/errofreedatabase.sql @@ -0,0 +1,15 @@ +ALTER TABLE erro_admin RENAME TO SS13_admin; +ALTER TABLE erro_admin_log RENAME TO SS13_admin_log; +ALTER TABLE erro_admin_ranks RENAME TO SS13_admin_ranks; +ALTER TABLE erro_ban RENAME TO SS13_ban; +ALTER TABLE erro_connection_log RENAME TO SS13_connection_log; +ALTER TABLE erro_death RENAME TO SS13_death; +ALTER TABLE erro_feedback RENAME TO SS13_feedback; +ALTER TABLE erro_legacy_population RENAME TO SS13_legacy_population; +ALTER TABLE erro_library RENAME TO SS13_library; +ALTER TABLE erro_player RENAME TO SS13_player; +ALTER TABLE erro_poll_option RENAME TO SS13_poll_option; +ALTER TABLE erro_poll_question RENAME TO SS13_poll_question; +ALTER TABLE erro_poll_textreply RENAME TO SS13_poll_textreply; +ALTER TABLE erro_poll_vote RENAME TO SS13_poll_vote; +ALTER TABLE erro_privacy RENAME TO SS13_privacy; \ No newline at end of file diff --git a/SQL/tgstation_schema.sql b/SQL/tgstation_schema.sql index 5eb2e9d8d95..5e053d8e110 100644 --- a/SQL/tgstation_schema.sql +++ b/SQL/tgstation_schema.sql @@ -13,13 +13,13 @@ USE `feedback`; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- --- Table structure for table `erro_admin` +-- Table structure for table `admin` -- -DROP TABLE IF EXISTS `erro_admin`; +DROP TABLE IF EXISTS `admin`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_admin` ( +CREATE TABLE `admin` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ckey` varchar(32) NOT NULL, `rank` varchar(32) NOT NULL DEFAULT 'Administrator', @@ -31,13 +31,13 @@ CREATE TABLE `erro_admin` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `erro_admin_log` +-- Table structure for table `admin_log` -- -DROP TABLE IF EXISTS `erro_admin_log`; +DROP TABLE IF EXISTS `admin_log`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_admin_log` ( +CREATE TABLE `admin_log` ( `id` int(11) NOT NULL AUTO_INCREMENT, `datetime` datetime NOT NULL, `adminckey` varchar(32) NOT NULL, @@ -48,13 +48,13 @@ CREATE TABLE `erro_admin_log` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `erro_admin_ranks` +-- Table structure for table `admin_ranks` -- -DROP TABLE IF EXISTS `erro_admin_ranks`; +DROP TABLE IF EXISTS `admin_ranks`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_admin_ranks` ( +CREATE TABLE `admin_ranks` ( `id` int(11) NOT NULL AUTO_INCREMENT, `rank` varchar(40) NOT NULL, `flags` int(16) NOT NULL DEFAULT '0', @@ -62,23 +62,23 @@ CREATE TABLE `erro_admin_ranks` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -insert into erro_admin_ranks (rank, flags) values ('Moderator',2); -insert into erro_admin_ranks (rank, flags) values ('Admin Candidate',2); -insert into erro_admin_ranks (rank, flags) values ('Trial Admin',5638); -insert into erro_admin_ranks (rank, flags) values ('Badmin',5727); -insert into erro_admin_ranks (rank, flags) values ('Game Admin',8063); -insert into erro_admin_ranks (rank, flags) values ('Game Master',65535); -insert into erro_admin_ranks (rank, flags) values ('Host',65535); -insert into erro_admin_ranks (rank, flags) values ('Coder',5168); +insert into admin_ranks (rank, flags) values ('Moderator',2); +insert into admin_ranks (rank, flags) values ('Admin Candidate',2); +insert into admin_ranks (rank, flags) values ('Trial Admin',5638); +insert into admin_ranks (rank, flags) values ('Badmin',5727); +insert into admin_ranks (rank, flags) values ('Game Admin',8063); +insert into admin_ranks (rank, flags) values ('Game Master',65535); +insert into admin_ranks (rank, flags) values ('Host',65535); +insert into admin_ranks (rank, flags) values ('Coder',5168); -- --- Table structure for table `erro_ban` +-- Table structure for table `ban` -- -DROP TABLE IF EXISTS `erro_ban`; +DROP TABLE IF EXISTS `ban`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_ban` ( +CREATE TABLE `ban` ( `id` int(11) NOT NULL AUTO_INCREMENT, `bantime` datetime NOT NULL, `serverip` varchar(32) NOT NULL, @@ -107,13 +107,13 @@ CREATE TABLE `erro_ban` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `erro_connection_log` +-- Table structure for table `connection_log` -- -DROP TABLE IF EXISTS `erro_connection_log`; +DROP TABLE IF EXISTS `connection_log`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_connection_log` ( +CREATE TABLE `connection_log` ( `id` int(11) NOT NULL AUTO_INCREMENT, `datetime` datetime DEFAULT NULL, `serverip` varchar(45) DEFAULT NULL, @@ -125,13 +125,13 @@ CREATE TABLE `erro_connection_log` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `erro_death` +-- Table structure for table `death` -- -DROP TABLE IF EXISTS `erro_death`; +DROP TABLE IF EXISTS `death`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_death` ( +CREATE TABLE `death` ( `id` int(11) NOT NULL AUTO_INCREMENT, `pod` text NOT NULL COMMENT 'Place of death', `coord` text NOT NULL COMMENT 'X, Y, Z POD', @@ -152,13 +152,13 @@ CREATE TABLE `erro_death` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `erro_feedback` +-- Table structure for table `feedback` -- -DROP TABLE IF EXISTS `erro_feedback`; +DROP TABLE IF EXISTS `feedback`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_feedback` ( +CREATE TABLE `feedback` ( `id` int(11) NOT NULL AUTO_INCREMENT, `time` datetime NOT NULL, `round_id` int(8) NOT NULL, @@ -170,13 +170,13 @@ CREATE TABLE `erro_feedback` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `erro_legacy_population` +-- Table structure for table `legacy_population` -- -DROP TABLE IF EXISTS `erro_legacy_population`; +DROP TABLE IF EXISTS `legacy_population`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_legacy_population` ( +CREATE TABLE `legacy_population` ( `id` int(11) NOT NULL AUTO_INCREMENT, `playercount` int(11) DEFAULT NULL, `admincount` int(11) DEFAULT NULL, @@ -186,11 +186,11 @@ CREATE TABLE `erro_legacy_population` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `erro_library` +-- Table structure for table `library` -- -DROP TABLE IF EXISTS `erro_library`; -CREATE TABLE `erro_library` ( +DROP TABLE IF EXISTS `library`; +CREATE TABLE `library` ( `id` int(11) NOT NULL AUTO_INCREMENT, `author` varchar(45) NOT NULL, `title` varchar(45) NOT NULL, @@ -203,13 +203,13 @@ CREATE TABLE `erro_library` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- --- Table structure for table `erro_player` +-- Table structure for table `player` -- -DROP TABLE IF EXISTS `erro_player`; +DROP TABLE IF EXISTS `player`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_player` ( +CREATE TABLE `player` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ckey` varchar(32) NOT NULL, `firstseen` datetime NOT NULL, @@ -223,13 +223,13 @@ CREATE TABLE `erro_player` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `erro_poll_option` +-- Table structure for table `poll_option` -- -DROP TABLE IF EXISTS `erro_poll_option`; +DROP TABLE IF EXISTS `poll_option`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_poll_option` ( +CREATE TABLE `poll_option` ( `id` int(11) NOT NULL AUTO_INCREMENT, `pollid` int(11) NOT NULL, `text` varchar(255) NOT NULL, @@ -244,13 +244,13 @@ CREATE TABLE `erro_poll_option` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `erro_poll_question` +-- Table structure for table `poll_question` -- -DROP TABLE IF EXISTS `erro_poll_question`; +DROP TABLE IF EXISTS `poll_question`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_poll_question` ( +CREATE TABLE `poll_question` ( `id` int(11) NOT NULL AUTO_INCREMENT, `polltype` varchar(16) NOT NULL DEFAULT 'OPTION', `starttime` datetime NOT NULL, @@ -263,13 +263,13 @@ CREATE TABLE `erro_poll_question` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `erro_poll_textreply` +-- Table structure for table `poll_textreply` -- -DROP TABLE IF EXISTS `erro_poll_textreply`; +DROP TABLE IF EXISTS `poll_textreply`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_poll_textreply` ( +CREATE TABLE `poll_textreply` ( `id` int(11) NOT NULL AUTO_INCREMENT, `datetime` datetime NOT NULL, `pollid` int(11) NOT NULL, @@ -282,13 +282,13 @@ CREATE TABLE `erro_poll_textreply` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `erro_poll_vote` +-- Table structure for table `poll_vote` -- -DROP TABLE IF EXISTS `erro_poll_vote`; +DROP TABLE IF EXISTS `poll_vote`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_poll_vote` ( +CREATE TABLE `poll_vote` ( `id` int(11) NOT NULL AUTO_INCREMENT, `datetime` datetime NOT NULL, `pollid` int(11) NOT NULL, @@ -302,13 +302,13 @@ CREATE TABLE `erro_poll_vote` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `erro_privacy` +-- Table structure for table `privacy` -- -DROP TABLE IF EXISTS `erro_privacy`; +DROP TABLE IF EXISTS `privacy`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_privacy` ( +CREATE TABLE `privacy` ( `id` int(11) NOT NULL AUTO_INCREMENT, `datetime` datetime NOT NULL, `ckey` varchar(32) NOT NULL, diff --git a/SQL/tgstation_schema_prefixed.sql b/SQL/tgstation_schema_prefixed.sql new file mode 100644 index 00000000000..c1b740b6874 --- /dev/null +++ b/SQL/tgstation_schema_prefixed.sql @@ -0,0 +1,330 @@ +CREATE DATABASE IF NOT EXISTS `feedback` /*!40100 DEFAULT CHARACTER SET latin1 */; +USE `feedback`; + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `SS13_admin` +-- + +DROP TABLE IF EXISTS `SS13_admin`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_admin` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ckey` varchar(32) NOT NULL, + `rank` varchar(32) NOT NULL DEFAULT 'Administrator', + `level` int(2) NOT NULL DEFAULT '0', + `flags` int(16) NOT NULL DEFAULT '0', + `email` varchar(45) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_admin_log` +-- + +DROP TABLE IF EXISTS `SS13_admin_log`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_admin_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `datetime` datetime NOT NULL, + `adminckey` varchar(32) NOT NULL, + `adminip` varchar(18) NOT NULL, + `log` text NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_admin_ranks` +-- + +DROP TABLE IF EXISTS `SS13_admin_ranks`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_admin_ranks` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `rank` varchar(40) NOT NULL, + `flags` int(16) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +insert into SS13_admin_ranks (rank, flags) values ('Moderator',2); +insert into SS13_admin_ranks (rank, flags) values ('Admin Candidate',2); +insert into SS13_admin_ranks (rank, flags) values ('Trial Admin',5638); +insert into SS13_admin_ranks (rank, flags) values ('Badmin',5727); +insert into SS13_admin_ranks (rank, flags) values ('Game Admin',8063); +insert into SS13_admin_ranks (rank, flags) values ('Game Master',65535); +insert into SS13_admin_ranks (rank, flags) values ('Host',65535); +insert into SS13_admin_ranks (rank, flags) values ('Coder',5168); + +-- +-- Table structure for table `SS13_ban` +-- + +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, + `serverip` varchar(32) NOT NULL, + `bantype` varchar(32) NOT NULL, + `reason` text NOT NULL, + `job` varchar(32) DEFAULT NULL, + `duration` int(11) NOT NULL, + `rounds` int(11) DEFAULT NULL, + `expiration_time` datetime NOT NULL, + `ckey` varchar(32) NOT NULL, + `computerid` varchar(32) NOT NULL, + `ip` varchar(32) NOT NULL, + `a_ckey` varchar(32) NOT NULL, + `a_computerid` varchar(32) NOT NULL, + `a_ip` varchar(32) NOT NULL, + `who` text NOT NULL, + `adminwho` text NOT NULL, + `edits` text, + `unbanned` int(2) DEFAULT NULL, + `unbanned_datetime` datetime DEFAULT NULL, + `unbanned_ckey` varchar(32) DEFAULT NULL, + `unbanned_computerid` varchar(32) DEFAULT NULL, + `unbanned_ip` varchar(32) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_connection_log` +-- + +DROP TABLE IF EXISTS `SS13_connection_log`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_connection_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `datetime` datetime DEFAULT NULL, + `serverip` varchar(45) DEFAULT NULL, + `ckey` varchar(45) DEFAULT NULL, + `ip` varchar(18) DEFAULT NULL, + `computerid` varchar(45) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_death` +-- + +DROP TABLE IF EXISTS `SS13_death`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_death` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `pod` text NOT NULL COMMENT 'Place of death', + `coord` text NOT NULL COMMENT 'X, Y, Z POD', + `tod` datetime NOT NULL COMMENT 'Time of death', + `job` text NOT NULL, + `special` text NOT NULL, + `name` text NOT NULL, + `byondkey` text NOT NULL, + `laname` text NOT NULL COMMENT 'Last attacker name', + `lakey` text NOT NULL COMMENT 'Last attacker key', + `gender` text NOT NULL, + `bruteloss` int(11) NOT NULL, + `brainloss` int(11) NOT NULL, + `fireloss` int(11) NOT NULL, + `oxyloss` int(11) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_feedback` +-- + +DROP TABLE IF EXISTS `SS13_feedback`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_feedback` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `time` datetime NOT NULL, + `round_id` int(8) NOT NULL, + `var_name` varchar(32) NOT NULL, + `var_value` int(16) DEFAULT NULL, + `details` text, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_legacy_population` +-- + +DROP TABLE IF EXISTS `SS13_legacy_population`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_legacy_population` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `playercount` int(11) DEFAULT NULL, + `admincount` int(11) DEFAULT NULL, + `time` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_library` +-- + +DROP TABLE IF EXISTS `SS13_library`; +CREATE TABLE `SS13_library` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `author` varchar(45) NOT NULL, + `title` varchar(45) NOT NULL, + `content` text NOT NULL, + `category` varchar(45) NOT NULL, + `ckey` varchar(45) DEFAULT 'LEGACY', + `datetime` datetime DEFAULT NULL, + `deleted` tinyint(1) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- +-- Table structure for table `SS13_player` +-- + +DROP TABLE IF EXISTS `SS13_player`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_player` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ckey` varchar(32) NOT NULL, + `firstseen` datetime NOT NULL, + `lastseen` datetime NOT NULL, + `ip` varchar(18) NOT NULL, + `computerid` varchar(32) NOT NULL, + `lastadminrank` varchar(32) NOT NULL DEFAULT 'Player', + PRIMARY KEY (`id`), + UNIQUE KEY `ckey` (`ckey`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_poll_option` +-- + +DROP TABLE IF EXISTS `SS13_poll_option`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_poll_option` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `pollid` int(11) NOT NULL, + `text` varchar(255) NOT NULL, + `percentagecalc` tinyint(1) NOT NULL DEFAULT '1', + `minval` int(3) DEFAULT NULL, + `maxval` int(3) DEFAULT NULL, + `descmin` varchar(32) DEFAULT NULL, + `descmid` varchar(32) DEFAULT NULL, + `descmax` varchar(32) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_poll_question` +-- + +DROP TABLE IF EXISTS `SS13_poll_question`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_poll_question` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `polltype` varchar(16) NOT NULL DEFAULT 'OPTION', + `starttime` datetime NOT NULL, + `endtime` datetime NOT NULL, + `question` varchar(255) NOT NULL, + `adminonly` tinyint(1) DEFAULT '0', + `multiplechoiceoptions` int(2) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_poll_textreply` +-- + +DROP TABLE IF EXISTS `SS13_poll_textreply`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_poll_textreply` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `datetime` datetime NOT NULL, + `pollid` int(11) NOT NULL, + `ckey` varchar(32) NOT NULL, + `ip` varchar(18) NOT NULL, + `replytext` text NOT NULL, + `adminrank` varchar(32) NOT NULL DEFAULT 'Player', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_poll_vote` +-- + +DROP TABLE IF EXISTS `SS13_poll_vote`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_poll_vote` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `datetime` datetime NOT NULL, + `pollid` int(11) NOT NULL, + `optionid` int(11) NOT NULL, + `ckey` varchar(255) NOT NULL, + `ip` varchar(16) NOT NULL, + `adminrank` varchar(32) NOT NULL, + `rating` int(2) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_privacy` +-- + +DROP TABLE IF EXISTS `SS13_privacy`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_privacy` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `datetime` datetime NOT NULL, + `ckey` varchar(32) NOT NULL, + `option` varchar(128) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2013-03-24 18:02:35 \ No newline at end of file diff --git a/code/__HELPERS/text.dm b/code/__HELPERS/text.dm index ebf047212fc..c15e4cfa516 100644 --- a/code/__HELPERS/text.dm +++ b/code/__HELPERS/text.dm @@ -1,7 +1,7 @@ /* * Holds procs designed to help with filtering text * Contains groups: - * SQL sanitization + * SQL sanitization/formating * Text sanitization * Text searches * Text modification @@ -18,6 +18,9 @@ var/sqltext = dbcon.Quote(t); return copytext(sqltext, 2, lentext(sqltext));//Quote() adds quotes around input, we already do that +/proc/format_table_name(var/table as text) + return sqlfdbktableprefix + table + /* * Text sanitization */ diff --git a/code/_globalvars/database.dm b/code/_globalvars/database.dm index 30fcdd5b135..58b6400ce43 100644 --- a/code/_globalvars/database.dm +++ b/code/_globalvars/database.dm @@ -5,6 +5,7 @@ var/sqlport = "3306" var/sqlfdbkdb = "test" var/sqlfdbklogin = "root" var/sqlfdbkpass = "" +var/sqlfdbktableprefix = "erro_" //backwords compatibility with downstream server hosts //Database connections //A connection is established on world creation. Ideally, the connection dies when the server restarts (After feedback logging.). diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 81c462441a8..ead5f6100d7 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -443,6 +443,8 @@ sqlfdbklogin = value if("feedback_password") sqlfdbkpass = value + if("feedback_tableprefix") + sqlfdbktableprefix = value else diary << "Unknown setting in configuration: '[name]'" diff --git a/code/defines/procs/statistics.dm b/code/defines/procs/statistics.dm index e0a97085222..06c076af6ac 100644 --- a/code/defines/procs/statistics.dm +++ b/code/defines/procs/statistics.dm @@ -10,7 +10,7 @@ proc/sql_poll_players() 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.NewQuery("INSERT INTO erro_legacy_population (playercount, time) VALUES ([playercount], '[sqltime]')") + var/DBQuery/query = dbcon.NewQuery("INSERT INTO [format_table_name("legacy_population")] (playercount, time) VALUES ([playercount], '[sqltime]')") if(!query.Execute()) var/err = query.ErrorMsg() log_game("SQL ERROR during player polling. Error : \[[err]\]\n") @@ -25,7 +25,7 @@ proc/sql_poll_admins() 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.NewQuery("INSERT INTO erro_legacy_population (admincount, time) VALUES ([admincount], '[sqltime]')") + var/DBQuery/query = dbcon.NewQuery("INSERT INTO [format_table_name("legacy_population")] (admincount, time) VALUES ([admincount], '[sqltime]')") if(!query.Execute()) var/err = query.ErrorMsg() log_game("SQL ERROR during admin polling. Error : \[[err]\]\n") @@ -69,7 +69,7 @@ proc/sql_report_death(var/mob/living/carbon/human/H) if(!dbcon.IsConnected()) log_game("SQL ERROR during death reporting. Failed to connect.") else - var/DBQuery/query = dbcon.NewQuery("INSERT INTO erro_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]')") + var/DBQuery/query = dbcon.NewQuery("INSERT INTO [format_table_name("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") @@ -104,7 +104,7 @@ proc/sql_report_cyborg_death(var/mob/living/silicon/robot/H) if(!dbcon.IsConnected()) log_game("SQL ERROR during death reporting. Failed to connect.") else - var/DBQuery/query = dbcon.NewQuery("INSERT INTO erro_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]')") + var/DBQuery/query = dbcon.NewQuery("INSERT INTO [format_table_name("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") @@ -137,7 +137,7 @@ proc/sql_commit_feedback() 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") + var/DBQuery/max_query = dbcon.NewQuery("SELECT MAX(roundid) AS max_round_id FROM [format_table_name("feedback")]") max_query.Execute() var/newroundid @@ -157,7 +157,7 @@ proc/sql_commit_feedback() 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]')") + var/DBQuery/query = dbcon.NewQuery("INSERT INTO [format_table_name("feedback")] (id, roundid, time, variable, value) VALUES (null, [newroundid], Now(), '[variable]', '[value]')") if(!query.Execute()) var/err = query.ErrorMsg() log_game("SQL ERROR during feedback reporting. Error : \[[err]\]\n") \ No newline at end of file diff --git a/code/modules/admin/DB ban/functions.dm b/code/modules/admin/DB ban/functions.dm index 7cdce2e281a..c7d9b68037d 100644 --- a/code/modules/admin/DB ban/functions.dm +++ b/code/modules/admin/DB ban/functions.dm @@ -75,7 +75,7 @@ datum/admins/proc/DB_ban_record(var/bantype, var/mob/banned_mob, var/duration = computerid = bancid ip = banip - var/DBQuery/query = dbcon.NewQuery("SELECT id FROM erro_player WHERE ckey = '[ckey]'") + var/DBQuery/query = dbcon.NewQuery("SELECT id FROM [format_table_name("player")] WHERE ckey = '[ckey]'") query.Execute() var/validckey = 0 if(query.NextRow()) @@ -116,7 +116,7 @@ datum/admins/proc/DB_ban_record(var/bantype, var/mob/banned_mob, var/duration = reason = sql_sanitize_text(reason) if(maxadminbancheck) - var/DBQuery/adm_query = dbcon.NewQuery("SELECT count(id) AS num FROM erro_ban WHERE (a_ckey = '[a_ckey]') AND (bantype = 'ADMIN_PERMABAN' OR (bantype = 'ADMIN_TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)") + var/DBQuery/adm_query = dbcon.NewQuery("SELECT count(id) AS num FROM [format_table_name("ban")] WHERE (a_ckey = '[a_ckey]') AND (bantype = 'ADMIN_PERMABAN' OR (bantype = 'ADMIN_TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)") adm_query.Execute() if(adm_query.NextRow()) var/adm_bans = text2num(adm_query.item[1]) @@ -124,7 +124,7 @@ datum/admins/proc/DB_ban_record(var/bantype, var/mob/banned_mob, var/duration = usr << "You already logged [MAX_ADMIN_BANS_PER_ADMIN] admin ban(s) or more. Do not abuse this function!" return - var/sql = "INSERT INTO erro_ban (`id`,`bantime`,`serverip`,`bantype`,`reason`,`job`,`duration`,`rounds`,`expiration_time`,`ckey`,`computerid`,`ip`,`a_ckey`,`a_computerid`,`a_ip`,`who`,`adminwho`,`edits`,`unbanned`,`unbanned_datetime`,`unbanned_ckey`,`unbanned_computerid`,`unbanned_ip`) 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)" + var/sql = "INSERT INTO [format_table_name("ban")] (`id`,`bantime`,`serverip`,`bantype`,`reason`,`job`,`duration`,`rounds`,`expiration_time`,`ckey`,`computerid`,`ip`,`a_ckey`,`a_computerid`,`a_ip`,`who`,`adminwho`,`edits`,`unbanned`,`unbanned_datetime`,`unbanned_ckey`,`unbanned_computerid`,`unbanned_ip`) 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)" var/DBQuery/query_insert = dbcon.NewQuery(sql) query_insert.Execute() usr << "Ban saved to database." @@ -178,7 +178,7 @@ datum/admins/proc/DB_ban_unban(var/ckey, var/bantype, var/job = "") else bantype_sql = "bantype = '[bantype_str]'" - var/sql = "SELECT id FROM erro_ban WHERE ckey = '[ckey]' AND [bantype_sql] AND (unbanned is null OR unbanned = false)" + var/sql = "SELECT id FROM [format_table_name("ban")] WHERE ckey = '[ckey]' AND [bantype_sql] AND (unbanned is null OR unbanned = false)" if(job) sql += " AND job = '[job]'" @@ -219,7 +219,7 @@ datum/admins/proc/DB_ban_edit(var/banid = null, var/param = null) usr << "Cancelled" return - var/DBQuery/query = dbcon.NewQuery("SELECT ckey, duration, reason FROM erro_ban WHERE id = [banid]") + var/DBQuery/query = dbcon.NewQuery("SELECT ckey, duration, reason FROM [format_table_name("ban")] WHERE id = [banid]") query.Execute() var/eckey = usr.ckey //Editing admin ckey @@ -247,7 +247,7 @@ datum/admins/proc/DB_ban_edit(var/banid = null, var/param = null) usr << "Cancelled" return - var/DBQuery/update_query = dbcon.NewQuery("UPDATE erro_ban SET reason = '[value]', edits = CONCAT(edits,'- [eckey] changed ban reason from \\\"[reason]\\\" to \\\"[value]\\\"
') WHERE id = [banid]") + var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("ban")] SET reason = '[value]', edits = CONCAT(edits,'- [eckey] changed ban reason from \\\"[reason]\\\" to \\\"[value]\\\"
') WHERE id = [banid]") update_query.Execute() message_admins("[key_name_admin(usr)] has edited a ban for [pckey]'s reason from [reason] to [value]",1) if("duration") @@ -257,7 +257,7 @@ datum/admins/proc/DB_ban_edit(var/banid = null, var/param = null) usr << "Cancelled" return - var/DBQuery/update_query = dbcon.NewQuery("UPDATE erro_ban SET duration = [value], edits = CONCAT(edits,'- [eckey] changed ban duration from [duration] to [value]
'), expiration_time = DATE_ADD(bantime, INTERVAL [value] MINUTE) WHERE id = [banid]") + var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("ban")] SET duration = [value], edits = CONCAT(edits,'- [eckey] changed ban duration from [duration] to [value]
'), expiration_time = DATE_ADD(bantime, INTERVAL [value] MINUTE) WHERE id = [banid]") message_admins("[key_name_admin(usr)] has edited a ban for [pckey]'s duration from [duration] to [value]",1) update_query.Execute() if("unban") @@ -275,7 +275,7 @@ datum/admins/proc/DB_ban_unban_by_id(var/id) if(!check_rights(R_BAN)) return - var/sql = "SELECT ckey FROM erro_ban WHERE id = [id]" + var/sql = "SELECT ckey FROM [format_table_name("ban")] WHERE id = [id]" establish_db_connection() if(!dbcon.IsConnected()) @@ -305,7 +305,7 @@ datum/admins/proc/DB_ban_unban_by_id(var/id) var/unban_computerid = src.owner:computer_id var/unban_ip = src.owner:address - var/sql_update = "UPDATE erro_ban SET unbanned = 1, unbanned_datetime = Now(), unbanned_ckey = '[unban_ckey]', unbanned_computerid = '[unban_computerid]', unbanned_ip = '[unban_ip]' WHERE id = [id]" + var/sql_update = "UPDATE [format_table_name("ban")] SET unbanned = 1, unbanned_datetime = Now(), unbanned_ckey = '[unban_ckey]', unbanned_computerid = '[unban_computerid]', unbanned_ip = '[unban_ip]' WHERE id = [id]" message_admins("[key_name_admin(usr)] has lifted [pckey]'s ban.",1) var/DBQuery/query_update = dbcon.NewQuery(sql_update) @@ -409,7 +409,7 @@ datum/admins/proc/DB_ban_unban_by_id(var/id) if(playerckey) playersearch = "AND ckey = '[playerckey]' " - var/DBQuery/select_query = dbcon.NewQuery("SELECT id, bantime, bantype, reason, job, duration, expiration_time, ckey, a_ckey, unbanned, unbanned_ckey, unbanned_datetime, edits FROM erro_ban WHERE 1 [playersearch] [adminsearch] ORDER BY bantime DESC") + var/DBQuery/select_query = dbcon.NewQuery("SELECT id, bantime, bantype, reason, job, duration, expiration_time, ckey, a_ckey, unbanned, unbanned_ckey, unbanned_datetime, edits FROM [format_table_name("ban")] WHERE 1 [playersearch] [adminsearch] ORDER BY bantime DESC") select_query.Execute() while(select_query.NextRow()) diff --git a/code/modules/admin/IsBanned.dm b/code/modules/admin/IsBanned.dm index 30162e14cdb..404d7c07a06 100644 --- a/code/modules/admin/IsBanned.dm +++ b/code/modules/admin/IsBanned.dm @@ -16,7 +16,7 @@ world/IsBanned(key,address,computer_id) diary << "Ban database connection failure. Admin [ckeytext] not checked" return - var/DBQuery/query = dbcon.NewQuery("SELECT ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype FROM erro_ban WHERE (ckey = '[ckeytext]') AND (bantype = 'ADMIN_PERMABAN' OR (bantype = 'ADMIN_TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)") + var/DBQuery/query = dbcon.NewQuery("SELECT ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype FROM [format_table_name("ban")] WHERE (ckey = '[ckeytext]') AND (bantype = 'ADMIN_PERMABAN' OR (bantype = 'ADMIN_TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)") query.Execute() @@ -80,7 +80,7 @@ world/IsBanned(key,address,computer_id) failedcid = 0 cidquery = " OR computerid = '[computer_id]' " - var/DBQuery/query = dbcon.NewQuery("SELECT ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype FROM erro_ban WHERE (ckey = '[ckeytext]' [ipquery] [cidquery]) AND (bantype = 'PERMABAN' OR (bantype = 'TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)") + var/DBQuery/query = dbcon.NewQuery("SELECT ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype FROM [format_table_name("ban")] WHERE (ckey = '[ckeytext]' [ipquery] [cidquery]) AND (bantype = 'PERMABAN' OR (bantype = 'TEMPBAN' AND expiration_time > Now())) AND isnull(unbanned)") query.Execute() diff --git a/code/modules/admin/admin_ranks.dm b/code/modules/admin/admin_ranks.dm index bb93132caa2..32a874d0f51 100644 --- a/code/modules/admin/admin_ranks.dm +++ b/code/modules/admin/admin_ranks.dm @@ -85,7 +85,7 @@ var/list/admin_ranks = list() //list of all admin_rank datums load_admin_ranks() return - var/DBQuery/query = dbcon.NewQuery("SELECT rank, flags FROM erro_admin_ranks") + var/DBQuery/query = dbcon.NewQuery("SELECT rank, flags FROM [format_table_name("admin_ranks")]") query.Execute() while(query.NextRow()) var/rank_name = ckeyEx(query.item[1]) @@ -153,7 +153,7 @@ var/list/admin_ranks = list() //list of all admin_rank datums load_admins() return - var/DBQuery/query = dbcon.NewQuery("SELECT ckey, rank FROM erro_admin") + var/DBQuery/query = dbcon.NewQuery("SELECT ckey, rank FROM [format_table_name("admin")]") query.Execute() while(query.NextRow()) var/ckey = ckey(query.item[1]) diff --git a/code/modules/admin/banappearance.dm b/code/modules/admin/banappearance.dm index 829ffee38e5..991fa9ad362 100644 --- a/code/modules/admin/banappearance.dm +++ b/code/modules/admin/banappearance.dm @@ -59,7 +59,7 @@ DEBUG return //appearance bans - var/DBQuery/query = dbcon.NewQuery("SELECT ckey FROM erro_ban WHERE bantype = 'APPEARANCE_PERMABAN' AND NOT unbanned = 1") + var/DBQuery/query = dbcon.NewQuery("SELECT ckey FROM [format_table_name("ban")] WHERE bantype = 'APPEARANCE_PERMABAN' AND NOT unbanned = 1") query.Execute() while(query.NextRow()) @@ -101,7 +101,7 @@ proc/DB_ban_isappearancebanned(var/playerckey) var/sqlplayerckey = sql_sanitize_text(ckey(playerckey)) - var/DBQuery/query = dbcon.NewQuery("SELECT id FROM erro_ban WHERE CKEY = '[sqlplayerckey]' AND ((bantype = 'APPEARANCE_PERMABAN') OR (bantype = 'APPEARANCE_TEMPBAN' AND expiration_time > Now())) AND unbanned != 1") + var/DBQuery/query = dbcon.NewQuery("SELECT id FROM [format_table_name("ban")] WHERE CKEY = '[sqlplayerckey]' AND ((bantype = 'APPEARANCE_PERMABAN') OR (bantype = 'APPEARANCE_TEMPBAN' AND expiration_time > Now())) AND unbanned != 1") query.Execute() while(query.NextRow()) return 1 diff --git a/code/modules/admin/banjob.dm b/code/modules/admin/banjob.dm index 1eb61cd4a92..bc68c4a9e01 100644 --- a/code/modules/admin/banjob.dm +++ b/code/modules/admin/banjob.dm @@ -67,7 +67,7 @@ DEBUG return //Job permabans - var/DBQuery/query = dbcon.NewQuery("SELECT ckey, job FROM erro_ban WHERE bantype = 'JOB_PERMABAN' AND isnull(unbanned)") + var/DBQuery/query = dbcon.NewQuery("SELECT ckey, job FROM [format_table_name("ban")] WHERE bantype = 'JOB_PERMABAN' AND isnull(unbanned)") query.Execute() while(query.NextRow()) @@ -77,7 +77,7 @@ DEBUG jobban_keylist.Add("[ckey] - [job]") //Job tempbans - var/DBQuery/query1 = dbcon.NewQuery("SELECT ckey, job FROM erro_ban WHERE bantype = 'JOB_TEMPBAN' AND isnull(unbanned) AND expiration_time > Now()") + var/DBQuery/query1 = dbcon.NewQuery("SELECT ckey, job FROM [format_table_name("ban")] WHERE bantype = 'JOB_TEMPBAN' AND isnull(unbanned) AND expiration_time > Now()") query1.Execute() while(query1.NextRow()) diff --git a/code/modules/admin/permissionverbs/permissionedit.dm b/code/modules/admin/permissionverbs/permissionedit.dm index 0112aedabd8..3507e19b1e8 100644 --- a/code/modules/admin/permissionverbs/permissionedit.dm +++ b/code/modules/admin/permissionverbs/permissionedit.dm @@ -73,7 +73,7 @@ if(!istext(adm_ckey) || !istext(new_rank)) return - var/DBQuery/select_query = dbcon.NewQuery("SELECT id FROM erro_admin WHERE ckey = '[adm_ckey]'") + var/DBQuery/select_query = dbcon.NewQuery("SELECT id FROM [format_table_name("admin")] WHERE ckey = '[adm_ckey]'") select_query.Execute() var/new_admin = 1 @@ -83,16 +83,16 @@ admin_id = text2num(select_query.item[1]) if(new_admin) - var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO `erro_admin` (`id`, `ckey`, `rank`, `level`, `flags`) VALUES (null, '[adm_ckey]', '[new_rank]', -1, 0)") + var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO `[format_table_name("admin")]` (`id`, `ckey`, `rank`, `level`, `flags`) VALUES (null, '[adm_ckey]', '[new_rank]', -1, 0)") insert_query.Execute() - var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO `test`.`erro_admin_log` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Added new admin [adm_ckey] to rank [new_rank]');") + var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO `[format_table_name("admin_log")]` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Added new admin [adm_ckey] to rank [new_rank]');") log_query.Execute() usr << "New admin added." else if(!isnull(admin_id) && isnum(admin_id)) - var/DBQuery/insert_query = dbcon.NewQuery("UPDATE `erro_admin` SET rank = '[new_rank]' WHERE id = [admin_id]") + var/DBQuery/insert_query = dbcon.NewQuery("UPDATE `[format_table_name("admin")]` SET rank = '[new_rank]' WHERE id = [admin_id]") insert_query.Execute() - var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO `test`.`erro_admin_log` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Edited the rank of [adm_ckey] to [new_rank]');") + var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO `[format_table_name("admin_log")]` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Edited the rank of [adm_ckey] to [new_rank]');") log_query.Execute() usr << "Admin rank changed." @@ -110,7 +110,7 @@ if(!adm_ckey || !istext(adm_ckey) || !isnum(new_permission)) return - var/DBQuery/select_query = dbcon.NewQuery("SELECT id, flags FROM erro_admin WHERE ckey = '[adm_ckey]'") + var/DBQuery/select_query = dbcon.NewQuery("SELECT id, flags FROM [format_table_name("admin")] WHERE ckey = '[adm_ckey]'") select_query.Execute() var/admin_id @@ -119,7 +119,7 @@ if(!admin_id) return - var/DBQuery/insert_query = dbcon.NewQuery("UPDATE `erro_admin` SET flags = [new_permission] WHERE id = [admin_id]") + var/DBQuery/insert_query = dbcon.NewQuery("UPDATE `[format_table_name("admin")]` SET flags = [new_permission] WHERE id = [admin_id]") insert_query.Execute() - var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO `test`.`erro_admin_log` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Edit permission [rights2text(new_permission)] (flag = [new_permission]) to admin [adm_ckey]');") + var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO `[format_table_name("admin_log")]` (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Edit permission [rights2text(new_permission)] (flag = [new_permission]) to admin [adm_ckey]');") log_query.Execute() diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 3c597dd443e..9cec6893165 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -165,7 +165,7 @@ var/next_external_rsc = 0 var/sql_ckey = sql_sanitize_text(src.ckey) - var/DBQuery/query = dbcon.NewQuery("SELECT id, datediff(Now(),firstseen) as age FROM erro_player WHERE ckey = '[sql_ckey]'") + var/DBQuery/query = dbcon.NewQuery("SELECT id, datediff(Now(),firstseen) as age FROM [format_table_name("player")] WHERE ckey = '[sql_ckey]'") query.Execute() var/sql_id = 0 while(query.NextRow()) @@ -173,14 +173,14 @@ var/next_external_rsc = 0 player_age = text2num(query.item[2]) break - var/DBQuery/query_ip = dbcon.NewQuery("SELECT ckey FROM erro_player WHERE ip = '[address]'") + var/DBQuery/query_ip = dbcon.NewQuery("SELECT ckey FROM [format_table_name("player")] WHERE ip = '[address]'") query_ip.Execute() related_accounts_ip = "" while(query_ip.NextRow()) related_accounts_ip += "[query_ip.item[1]], " break - var/DBQuery/query_cid = dbcon.NewQuery("SELECT ckey FROM erro_player WHERE computerid = '[computer_id]'") + var/DBQuery/query_cid = dbcon.NewQuery("SELECT ckey FROM [format_table_name("player")] WHERE computerid = '[computer_id]'") query_cid.Execute() related_accounts_cid = "" while(query_cid.NextRow()) @@ -205,16 +205,16 @@ var/next_external_rsc = 0 if(sql_id) //Player already identified previously, we need to just update the 'lastseen', 'ip' and 'computer_id' variables - var/DBQuery/query_update = dbcon.NewQuery("UPDATE erro_player SET lastseen = Now(), ip = '[sql_ip]', computerid = '[sql_computerid]', lastadminrank = '[sql_admin_rank]' WHERE id = [sql_id]") + var/DBQuery/query_update = dbcon.NewQuery("UPDATE [format_table_name("player")] SET lastseen = Now(), ip = '[sql_ip]', computerid = '[sql_computerid]', lastadminrank = '[sql_admin_rank]' WHERE id = [sql_id]") query_update.Execute() else //New player!! Need to insert all the stuff - var/DBQuery/query_insert = dbcon.NewQuery("INSERT INTO erro_player (id, ckey, firstseen, lastseen, ip, computerid, lastadminrank) VALUES (null, '[sql_ckey]', Now(), Now(), '[sql_ip]', '[sql_computerid]', '[sql_admin_rank]')") + var/DBQuery/query_insert = dbcon.NewQuery("INSERT INTO [format_table_name("player")] (id, ckey, firstseen, lastseen, ip, computerid, lastadminrank) VALUES (null, '[sql_ckey]', Now(), Now(), '[sql_ip]', '[sql_computerid]', '[sql_admin_rank]')") query_insert.Execute() //Logging player access var/serverip = "[world.internet_address]:[world.port]" - var/DBQuery/query_accesslog = dbcon.NewQuery("INSERT INTO `erro_connection_log`(`id`,`datetime`,`serverip`,`ckey`,`ip`,`computerid`) VALUES(null,Now(),'[serverip]','[sql_ckey]','[sql_ip]','[sql_computerid]');") + var/DBQuery/query_accesslog = dbcon.NewQuery("INSERT INTO `[format_table_name("connection_log")]` (`id`,`datetime`,`serverip`,`ckey`,`ip`,`computerid`) VALUES(null,Now(),'[serverip]','[sql_ckey]','[sql_ip]','[sql_computerid]');") query_accesslog.Execute() diff --git a/code/modules/library/lib_machines.dm b/code/modules/library/lib_machines.dm index 19559ac0523..96a727b7d8c 100644 --- a/code/modules/library/lib_machines.dm +++ b/code/modules/library/lib_machines.dm @@ -98,7 +98,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f author = null author = sanitizeSQL(author) if(href_list["search"]) - SQLquery = "SELECT author, title, category, id FROM erro_library WHERE isnull(deleted) AND " + SQLquery = "SELECT author, title, category, id FROM [format_table_name("library")] WHERE isnull(deleted) AND " if(category == "Any") SQLquery += "author LIKE '%[author]%' AND title LIKE '%[title]%'" else @@ -201,7 +201,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f dat += "" dat += "" - var/DBQuery/query = dbcon.NewQuery("SELECT id, author, title, category FROM erro_library WHERE isnull(deleted)") + var/DBQuery/query = dbcon.NewQuery("SELECT id, author, title, category FROM [format_table_name("library")] WHERE isnull(deleted)") query.Execute() while(query.NextRow()) @@ -351,7 +351,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f var/sqlauthor = sanitizeSQL(scanner.cache.author) var/sqlcontent = sanitizeSQL(scanner.cache.dat) var/sqlcategory = sanitizeSQL(upload_category) - var/DBQuery/query = dbcon.NewQuery("INSERT INTO erro_library (author, title, content, category, ckey, datetime) VALUES ('[sqlauthor]', '[sqltitle]', '[sqlcontent]', '[sqlcategory]', '[usr.ckey]', Now())") + var/DBQuery/query = dbcon.NewQuery("INSERT INTO [format_table_name("library")] (author, title, content, category, ckey, datetime) VALUES ('[sqlauthor]', '[sqltitle]', '[sqlcontent]', '[sqlcategory]', '[usr.ckey]', Now())") if(!query.Execute()) usr << query.ErrorMsg() else @@ -370,7 +370,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f bibledelay = 1 spawn(60) bibledelay = 0 - var/DBQuery/query = dbcon.NewQuery("SELECT * FROM erro_library WHERE id=[sqlid] AND isnull(deleted)") + var/DBQuery/query = dbcon.NewQuery("SELECT * FROM [format_table_name("library")] WHERE id=[sqlid] AND isnull(deleted)") query.Execute() while(query.NextRow()) diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index d17985336d4..441362e2711 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -40,7 +40,7 @@ var/isadmin = 0 if(src.client && src.client.holder) isadmin = 1 - var/DBQuery/query = dbcon.NewQuery("SELECT id FROM erro_poll_question WHERE [(isadmin ? "" : "adminonly = false AND")] Now() BETWEEN starttime AND endtime AND id NOT IN (SELECT pollid FROM erro_poll_vote WHERE ckey = \"[ckey]\") AND id NOT IN (SELECT pollid FROM erro_poll_textreply WHERE ckey = \"[ckey]\")") + var/DBQuery/query = dbcon.NewQuery("SELECT id FROM [format_table_name("poll_question")] WHERE [(isadmin ? "" : "adminonly = false AND")] Now() BETWEEN starttime AND endtime AND id NOT IN (SELECT pollid FROM [format_table_name("poll_vote")] WHERE ckey = \"[ckey]\") AND id NOT IN (SELECT pollid FROM [format_table_name("poll_textreply")] WHERE ckey = \"[ckey]\")") query.Execute() var/newpoll = 0 while(query.NextRow()) @@ -150,7 +150,7 @@ var/voted = 0 //First check if the person has not voted yet. - var/DBQuery/query = dbcon.NewQuery("SELECT * FROM erro_privacy WHERE ckey='[src.ckey]'") + var/DBQuery/query = dbcon.NewQuery("SELECT * FROM [format_table_name("privacy")] WHERE ckey='[src.ckey]'") query.Execute() while(query.NextRow()) voted = 1 @@ -175,7 +175,7 @@ return if(!voted) - var/sql = "INSERT INTO erro_privacy VALUES (null, Now(), '[src.ckey]', '[option]')" + var/sql = "INSERT INTO [format_table_name("privacy")] VALUES (null, Now(), '[src.ckey]', '[option]')" var/DBQuery/query_insert = dbcon.NewQuery(sql) query_insert.Execute() usr << "Thank you for your vote!" diff --git a/code/modules/mob/new_player/poll.dm b/code/modules/mob/new_player/poll.dm index ba3ff0e6940..8fd5ba2d93f 100644 --- a/code/modules/mob/new_player/poll.dm +++ b/code/modules/mob/new_player/poll.dm @@ -5,7 +5,7 @@ return var/voted = 0 - var/DBQuery/query = dbcon.NewQuery("SELECT * FROM erro_privacy WHERE ckey='[src.ckey]'") + var/DBQuery/query = dbcon.NewQuery("SELECT * FROM [format_table_name("privacy")] WHERE ckey='[src.ckey]'") query.Execute() while(query.NextRow()) voted = 1 @@ -53,7 +53,7 @@ if(src.client && src.client.holder) isadmin = 1 - var/DBQuery/select_query = dbcon.NewQuery("SELECT id, question FROM erro_poll_question WHERE [(isadmin ? "" : "adminonly = false AND")] Now() BETWEEN starttime AND endtime") + var/DBQuery/select_query = dbcon.NewQuery("SELECT id, question FROM [format_table_name("poll_question")] WHERE [(isadmin ? "" : "adminonly = false AND")] Now() BETWEEN starttime AND endtime") select_query.Execute() var/output = "
Player polls" @@ -84,7 +84,7 @@ establish_db_connection() if(dbcon.IsConnected()) - var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype, multiplechoiceoptions FROM erro_poll_question WHERE id = [pollid]") + var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype, multiplechoiceoptions FROM [format_table_name("poll_question")] WHERE id = [pollid]") select_query.Execute() var/pollstarttime = "" @@ -109,7 +109,7 @@ switch(polltype) //Polls that have enumerated options if("OPTION") - var/DBQuery/voted_query = dbcon.NewQuery("SELECT optionid FROM erro_poll_vote WHERE pollid = [pollid] AND ckey = '[usr.ckey]'") + var/DBQuery/voted_query = dbcon.NewQuery("SELECT optionid FROM [format_table_name("poll_vote")] WHERE pollid = [pollid] AND ckey = '[usr.ckey]'") voted_query.Execute() var/voted = 0 @@ -121,7 +121,7 @@ var/list/datum/polloption/options = list() - var/DBQuery/options_query = dbcon.NewQuery("SELECT id, text FROM erro_poll_option WHERE pollid = [pollid]") + var/DBQuery/options_query = dbcon.NewQuery("SELECT id, text FROM [format_table_name("poll_option")] WHERE pollid = [pollid]") options_query.Execute() while(options_query.NextRow()) var/datum/polloption/PO = new() @@ -162,7 +162,7 @@ //Polls with a text input if("TEXT") - var/DBQuery/voted_query = dbcon.NewQuery("SELECT replytext FROM erro_poll_textreply WHERE pollid = [pollid] AND ckey = '[usr.ckey]'") + var/DBQuery/voted_query = dbcon.NewQuery("SELECT replytext FROM [format_table_name("poll_textreply")] WHERE pollid = [pollid] AND ckey = '[usr.ckey]'") voted_query.Execute() var/voted = 0 @@ -204,7 +204,7 @@ //Polls with a text input if("NUMVAL") - var/DBQuery/voted_query = dbcon.NewQuery("SELECT o.text, v.rating FROM erro_poll_option o, erro_poll_vote v WHERE o.pollid = [pollid] AND v.ckey = '[usr.ckey]' AND o.id = v.optionid") + var/DBQuery/voted_query = dbcon.NewQuery("SELECT o.text, v.rating FROM [format_table_name("poll_option")] o, [format_table_name("poll_vote")] v WHERE o.pollid = [pollid] AND v.ckey = '[usr.ckey]' AND o.id = v.optionid") voted_query.Execute() var/output = "
Player poll" @@ -230,7 +230,7 @@ var/minid = 999999 var/maxid = 0 - var/DBQuery/option_query = dbcon.NewQuery("SELECT id, text, minval, maxval, descmin, descmid, descmax FROM erro_poll_option WHERE pollid = [pollid]") + var/DBQuery/option_query = dbcon.NewQuery("SELECT id, text, minval, maxval, descmin, descmid, descmax FROM [format_table_name("poll_option")] WHERE pollid = [pollid]") option_query.Execute() while(option_query.NextRow()) var/optionid = text2num(option_query.item[1]) @@ -273,7 +273,7 @@ src << browse(output,"window=playerpoll;size=500x500") if("MULTICHOICE") - var/DBQuery/voted_query = dbcon.NewQuery("SELECT optionid FROM erro_poll_vote WHERE pollid = [pollid] AND ckey = '[usr.ckey]'") + var/DBQuery/voted_query = dbcon.NewQuery("SELECT optionid FROM [format_table_name("poll_vote")] WHERE pollid = [pollid] AND ckey = '[usr.ckey]'") voted_query.Execute() var/list/votedfor = list() @@ -286,7 +286,7 @@ var/maxoptionid = 0 var/minoptionid = 0 - var/DBQuery/options_query = dbcon.NewQuery("SELECT id, text FROM erro_poll_option WHERE pollid = [pollid]") + var/DBQuery/options_query = dbcon.NewQuery("SELECT id, text FROM [format_table_name("poll_option")] WHERE pollid = [pollid]") options_query.Execute() while(options_query.NextRow()) var/datum/polloption/PO = new() @@ -345,7 +345,7 @@ establish_db_connection() if(dbcon.IsConnected()) - var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype, multiplechoiceoptions FROM erro_poll_question WHERE id = [pollid] AND Now() BETWEEN starttime AND endtime") + var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype, multiplechoiceoptions FROM [format_table_name("poll_question")] WHERE id = [pollid] AND Now() BETWEEN starttime AND endtime") select_query.Execute() var/validpoll = 0 @@ -363,7 +363,7 @@ usr << "Poll is not valid." return - var/DBQuery/select_query2 = dbcon.NewQuery("SELECT id FROM erro_poll_option WHERE id = [optionid] AND pollid = [pollid]") + var/DBQuery/select_query2 = dbcon.NewQuery("SELECT id FROM [format_table_name("poll_option")] WHERE id = [optionid] AND pollid = [pollid]") select_query2.Execute() var/validoption = 0 @@ -378,7 +378,7 @@ var/alreadyvoted = 0 - var/DBQuery/voted_query = dbcon.NewQuery("SELECT id FROM erro_poll_vote WHERE pollid = [pollid] AND ckey = '[usr.ckey]'") + var/DBQuery/voted_query = dbcon.NewQuery("SELECT id FROM [format_table_name("poll_vote")] WHERE pollid = [pollid] AND ckey = '[usr.ckey]'") voted_query.Execute() while(voted_query.NextRow()) @@ -399,7 +399,7 @@ adminrank = usr.client.holder.rank - var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO erro_poll_vote (id ,datetime ,pollid ,optionid ,ckey ,ip ,adminrank) VALUES (null, Now(), [pollid], [optionid], '[usr.ckey]', '[usr.client.address]', '[adminrank]')") + var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO [format_table_name("poll_vote")] (id ,datetime ,pollid ,optionid ,ckey ,ip ,adminrank) VALUES (null, Now(), [pollid], [optionid], '[usr.ckey]', '[usr.client.address]', '[adminrank]')") insert_query.Execute() usr << "Vote successful." @@ -415,7 +415,7 @@ establish_db_connection() if(dbcon.IsConnected()) - var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype FROM erro_poll_question WHERE id = [pollid] AND Now() BETWEEN starttime AND endtime") + var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype FROM [format_table_name("poll_question")] WHERE id = [pollid] AND Now() BETWEEN starttime AND endtime") select_query.Execute() var/validpoll = 0 @@ -432,7 +432,7 @@ var/alreadyvoted = 0 - var/DBQuery/voted_query = dbcon.NewQuery("SELECT id FROM erro_poll_textreply WHERE pollid = [pollid] AND ckey = '[usr.ckey]'") + var/DBQuery/voted_query = dbcon.NewQuery("SELECT id FROM [format_table_name("poll_textreply")] WHERE pollid = [pollid] AND ckey = '[usr.ckey]'") voted_query.Execute() while(voted_query.NextRow()) @@ -457,7 +457,7 @@ usr << "The text you entered was blank, contained illegal characters or was too long. Please correct the text and submit again." return - var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO erro_poll_textreply (id ,datetime ,pollid ,ckey ,ip ,replytext ,adminrank) VALUES (null, Now(), [pollid], '[usr.ckey]', '[usr.client.address]', '[replytext]', '[adminrank]')") + var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO [format_table_name("poll_textreply")] (id ,datetime ,pollid ,ckey ,ip ,replytext ,adminrank) VALUES (null, Now(), [pollid], '[usr.ckey]', '[usr.client.address]', '[replytext]', '[adminrank]')") insert_query.Execute() usr << "Feedback logging successful." @@ -473,7 +473,7 @@ establish_db_connection() if(dbcon.IsConnected()) - var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype FROM erro_poll_question WHERE id = [pollid] AND Now() BETWEEN starttime AND endtime") + var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype FROM [format_table_name("poll_question")] WHERE id = [pollid] AND Now() BETWEEN starttime AND endtime") select_query.Execute() var/validpoll = 0 @@ -488,7 +488,7 @@ usr << "Poll is not valid." return - var/DBQuery/select_query2 = dbcon.NewQuery("SELECT id FROM erro_poll_option WHERE id = [optionid] AND pollid = [pollid]") + var/DBQuery/select_query2 = dbcon.NewQuery("SELECT id FROM [format_table_name("poll_option")] WHERE id = [optionid] AND pollid = [pollid]") select_query2.Execute() var/validoption = 0 @@ -503,7 +503,7 @@ var/alreadyvoted = 0 - var/DBQuery/voted_query = dbcon.NewQuery("SELECT id FROM erro_poll_vote WHERE optionid = [optionid] AND ckey = '[usr.ckey]'") + var/DBQuery/voted_query = dbcon.NewQuery("SELECT id FROM [format_table_name("poll_vote")] WHERE optionid = [optionid] AND ckey = '[usr.ckey]'") voted_query.Execute() while(voted_query.NextRow()) @@ -519,7 +519,7 @@ adminrank = usr.client.holder.rank - var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO erro_poll_vote (id ,datetime ,pollid ,optionid ,ckey ,ip ,adminrank, rating) VALUES (null, Now(), [pollid], [optionid], '[usr.ckey]', '[usr.client.address]', '[adminrank]', [(isnull(rating)) ? "null" : rating])") + var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO [format_table_name("poll_vote")] (id ,datetime ,pollid ,optionid ,ckey ,ip ,adminrank, rating) VALUES (null, Now(), [pollid], [optionid], '[usr.ckey]', '[usr.client.address]', '[adminrank]', [(isnull(rating)) ? "null" : rating])") insert_query.Execute() usr << "Vote successful." diff --git a/code/modules/research/message_server.dm b/code/modules/research/message_server.dm index 884d4eb2f8b..c5dd5d2ae50 100644 --- a/code/modules/research/message_server.dm +++ b/code/modules/research/message_server.dm @@ -276,7 +276,7 @@ var/obj/machinery/blackbox_recorder/blackbox if(!dbcon.IsConnected()) return var/round_id - var/DBQuery/query = dbcon.NewQuery("SELECT MAX(round_id) AS round_id FROM erro_feedback") + var/DBQuery/query = dbcon.NewQuery("SELECT MAX(round_id) AS round_id FROM [format_table_name("feedback")]") query.Execute() while(query.NextRow()) round_id = query.item[1] @@ -286,7 +286,7 @@ var/obj/machinery/blackbox_recorder/blackbox round_id++ for(var/datum/feedback_variable/FV in feedback) - var/sql = "INSERT INTO erro_feedback VALUES (null, Now(), [round_id], \"[FV.get_variable()]\", [FV.get_value()], \"[FV.get_details()]\")" + var/sql = "INSERT INTO [format_table_name("feedback")] VALUES (null, Now(), [round_id], \"[FV.get_variable()]\", [FV.get_value()], \"[FV.get_details()]\")" var/DBQuery/query_insert = dbcon.NewQuery(sql) query_insert.Execute() diff --git a/config/dbconfig.txt b/config/dbconfig.txt index c7e81e02b22..dbc09df51df 100644 --- a/config/dbconfig.txt +++ b/config/dbconfig.txt @@ -15,6 +15,17 @@ PORT 3306 ## Database for all SQL functions, not just feedback. FEEDBACK_DATABASE feedback +## Prefix to be added to the name of every table, older databases will require this be set to erro_ +## if left out defaults to erro_ for legacy reasons, if you want no table prefix, give a blank prefix rather then comment out +## Note, this does not change the table names in the database, you will have to do that yourself. +##IE: +## FEEDBACK_TABLEPREFIX erro_ +## FEEDBACK_TABLEPREFIX +## FEEDBACK_TABLEPREFIX SS13_ +## +## Leave as is if you are using the standard schema file. +FEEDBACK_TABLEPREFIX + ## Username/Login used to access the database. FEEDBACK_LOGIN username
AUTHORTITLECATEGORY