From bec9fca533663d0aedc7c8050e195a9e0f0114ae Mon Sep 17 00:00:00 2001 From: Markolie Date: Wed, 23 Sep 2015 06:13:42 +0200 Subject: [PATCH] SQL update --- README.md | 2 +- SQL/paradise_schema.sql | 87 ++-- SQL/paradise_schema_prefixed.sql | 492 ++++++++++++++++++++++ code/_globalvars/database.dm | 31 +- code/_globalvars/game_modes.dm | 4 +- code/_globalvars/misc.dm | 6 +- code/controllers/configuration.dm | 64 +-- code/defines/procs/dbcore.dm | 4 +- code/defines/procs/statistics.dm | 65 ++- code/game/gamemodes/gameticker.dm | 8 +- code/game/jobs/whitelist.dm | 4 +- code/game/machinery/records_scanner.dm | 9 +- code/game/magic/archived_book.dm | 126 ------ code/modules/admin/admin_verbs.dm | 29 +- code/modules/admin/verbs/debug.dm | 5 +- code/modules/client/preferences.dm | 2 +- code/modules/customitems/item_spawning.dm | 2 +- code/modules/karma/karma.dm | 32 +- code/modules/library/lib_machines.dm | 51 ++- code/world.dm | 44 -- config/example/config.txt | 3 - config/example/dbconfig.txt | 43 +- config/example/forumdbconfig.txt | 19 - 23 files changed, 677 insertions(+), 455 deletions(-) create mode 100644 SQL/paradise_schema_prefixed.sql delete mode 100644 code/game/magic/archived_book.dm delete mode 100644 config/example/forumdbconfig.txt diff --git a/README.md b/README.md index d5c90980bad..8509f205efc 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ For a basic setup, simply copy every file from config/example to config. ### SQL Setup -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 arecoming soon, for now ask in our IRC channel. +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/paradise_schema.sql and /SQL/paradise_schema_prefix.sql depending on if you want table prefixes. More detailed setup instructions are located on /tg/station's wiki: http://www.tgstation13.org/wiki/Downloading_the_source_code#Setting_up_the_database --- diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index deb2ae8d7f9..160d644585d 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -1,10 +1,5 @@ -CREATE DATABASE IF NOT EXISTS `paradise` /*!40100 DEFAULT CHARACTER SET utf8 */; -USE `paradise`; --- MySQL dump 10.13 Distrib 5.6.13, for Win32 (x86) --- --- Host: nanotrasen.se Database: paradise --- ------------------------------------------------------ --- Server version 5.6.15-log +CREATE DATABASE IF NOT EXISTS `feedback` /*!40100 DEFAULT CHARACTER SET utf8 */; +USE `feedback`; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -133,13 +128,13 @@ CREATE TABLE `death` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- 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', @@ -150,13 +145,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, @@ -167,13 +162,13 @@ CREATE TABLE `erro_admin_log` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- 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, @@ -202,13 +197,13 @@ CREATE TABLE `erro_ban` ( /*!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, @@ -220,13 +215,13 @@ CREATE TABLE `erro_feedback` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- 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, @@ -250,13 +245,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, @@ -271,13 +266,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, @@ -289,13 +284,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, @@ -308,13 +303,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, @@ -328,13 +323,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, @@ -400,13 +395,13 @@ CREATE TABLE `library` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `population` +-- Table structure for table `legacy_population` -- -DROP TABLE IF EXISTS `population`; +DROP TABLE IF EXISTS `legacy_population`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `population` ( +CREATE TABLE `legacy_population` ( `id` int(11) NOT NULL AUTO_INCREMENT, `playercount` int(11) DEFAULT NULL, `admincount` int(11) DEFAULT NULL, @@ -444,10 +439,10 @@ CREATE TABLE `whitelist` ( -- Table structure for table `watch` -- -DROP TABLE IF EXISTS `erro_watch`; +DROP TABLE IF EXISTS `watch`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_watch` ( +CREATE TABLE `watch` ( `ckey` varchar(32) NOT NULL, `reason` text NOT NULL, `timestamp` datetime NOT NULL, @@ -463,10 +458,10 @@ CREATE TABLE `erro_watch` ( -- Table structure for table `notes` -- -DROP TABLE IF EXISTS `erro_notes`; +DROP TABLE IF EXISTS `notes`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_notes` ( +CREATE TABLE `notes` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ckey` varchar(32) NOT NULL, `notetext` text NOT NULL, @@ -483,10 +478,10 @@ CREATE TABLE `erro_notes` ( -- Table structure for table `memo` -- -DROP TABLE IF EXISTS `erro_memo`; +DROP TABLE IF EXISTS `memo`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `erro_memo` ( +CREATE TABLE `memo` ( `ckey` varchar(32) NOT NULL, `memotext` text NOT NULL, `timestamp` datetime NOT NULL, diff --git a/SQL/paradise_schema_prefixed.sql b/SQL/paradise_schema_prefixed.sql new file mode 100644 index 00000000000..c0c4bca3553 --- /dev/null +++ b/SQL/paradise_schema_prefixed.sql @@ -0,0 +1,492 @@ +CREATE DATABASE IF NOT EXISTS `feedback` /*!40100 DEFAULT CHARACTER SET utf8 */; +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_characters` +-- + +DROP TABLE IF EXISTS `SS13_characters`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_characters` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ckey` varchar(32) NOT NULL, + `slot` int(2) NOT NULL, + `OOC_Notes` mediumtext NOT NULL, + `real_name` varchar(45) NOT NULL, + `name_is_always_random` tinyint(1) NOT NULL, + `gender` varchar(11) NOT NULL, + `age` smallint(4) NOT NULL, + `species` varchar(45) NOT NULL, + `language` varchar(45) NOT NULL, + `hair_red` smallint(4) NOT NULL, + `hair_green` smallint(4) NOT NULL, + `hair_blue` smallint(4) NOT NULL, + `facial_red` smallint(4) NOT NULL, + `facial_green` smallint(4) NOT NULL, + `facial_blue` smallint(4) NOT NULL, + `skin_tone` smallint(4) NOT NULL, + `skin_red` smallint(4) NOT NULL, + `skin_green` smallint(4) NOT NULL, + `skin_blue` smallint(4) NOT NULL, + `hair_style_name` varchar(45) NOT NULL, + `facial_style_name` varchar(45) NOT NULL, + `eyes_red` smallint(4) NOT NULL, + `eyes_green` smallint(4) NOT NULL, + `eyes_blue` smallint(4) NOT NULL, + `underwear` mediumtext NOT NULL, + `undershirt` mediumtext NOT NULL, + `backbag` smallint(4) NOT NULL, + `b_type` varchar(45) NOT NULL, + `alternate_option` smallint(4) NOT NULL, + `job_support_high` mediumint(8) NOT NULL, + `job_support_med` mediumint(8) NOT NULL, + `job_support_low` mediumint(8) NOT NULL, + `job_medsci_high` mediumint(8) NOT NULL, + `job_medsci_med` mediumint(8) NOT NULL, + `job_medsci_low` mediumint(8) NOT NULL, + `job_engsec_high` mediumint(8) NOT NULL, + `job_engsec_med` mediumint(8) NOT NULL, + `job_engsec_low` mediumint(8) NOT NULL, + `job_karma_high` mediumint(8) NOT NULL, + `job_karma_med` mediumint(8) NOT NULL, + `job_karma_low` mediumint(8) NOT NULL, + `flavor_text` mediumtext NOT NULL, + `med_record` mediumtext NOT NULL, + `sec_record` mediumtext NOT NULL, + `gen_record` mediumtext NOT NULL, + `be_special` mediumint(8) NOT NULL, + `disabilities` mediumint(8) NOT NULL, + `player_alt_titles` mediumtext NOT NULL, + `organ_data` mediumtext NOT NULL, + `rlimb_data` mediumtext NOT NULL, + `nanotrasen_relation` varchar(45) NOT NULL, + `speciesprefs` int(1) NOT NULL, + `socks` mediumtext NOT NULL, + `body_accessory` mediumtext NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=18747 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_customuseritems` +-- + +DROP TABLE IF EXISTS `SS13_customuseritems`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_customuseritems` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `cuiCKey` varchar(36) NOT NULL, + `cuiRealName` varchar(60) NOT NULL, + `cuiPath` varchar(255) NOT NULL, + `cuiItemName` text, + `cuiDescription` text, + `cuiReason` text, + `cuiPropAdjust` text, + `cuiJobMask` text NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=56 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=MyISAM AUTO_INCREMENT=166546 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- 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', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=99 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_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` tinyint(1) 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 AUTO_INCREMENT=10685 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 AUTO_INCREMENT=257638 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- 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', + `ooccolor` varchar(7) DEFAULT '#b82e00', + `UI_style` varchar(10) DEFAULT 'Midnight', + `UI_style_color` varchar(7) DEFAULT '#ffffff', + `UI_style_alpha` smallint(4) DEFAULT '255', + `be_special` mediumint(8) DEFAULT '0', + `default_slot` smallint(4) DEFAULT '1', + `toggles` mediumint(8) DEFAULT '383', + `sound` mediumint(8) DEFAULT '31', + `randomslot` tinyint(1) DEFAULT '0', + `volume` smallint(4) DEFAULT '100', + PRIMARY KEY (`id`), + UNIQUE KEY `ckey` (`ckey`) +) ENGINE=InnoDB AUTO_INCREMENT=32446 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', + 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 AUTO_INCREMENT=10000 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_karma` +-- + +DROP TABLE IF EXISTS `SS13_karma`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_karma` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `spendername` text NOT NULL, + `spenderkey` text NOT NULL, + `receivername` text NOT NULL, + `receiverkey` text NOT NULL, + `receiverrole` text, + `receiverspecial` text, + `isnegative` tinyint(1) DEFAULT NULL, + `spenderip` text NOT NULL, + `time` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=73614 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_karmatotals` +-- + +DROP TABLE IF EXISTS `SS13_karmatotals`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_karmatotals` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `byondkey` text NOT NULL, + `karma` int(11) NOT NULL, + `karmaspent` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=6765 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_library` +-- + +DROP TABLE IF EXISTS `SS13_library`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_library` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `author` text NOT NULL, + `title` text NOT NULL, + `content` text NOT NULL, + `category` text NOT NULL, + `ckey` varchar(45) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=929 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=MyISAM AUTO_INCREMENT=2550 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_whitelist` +-- + +DROP TABLE IF EXISTS `SS13_whitelist`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_whitelist` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ckey` text NOT NULL, + `job` text, + `species` text, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=877 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 */; + +-- +-- Table structure for table `SS13_watch` +-- + +DROP TABLE IF EXISTS `SS13_watch`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_watch` ( + `ckey` varchar(32) NOT NULL, + `reason` text NOT NULL, + `timestamp` datetime NOT NULL, + `adminckey` varchar(32) NOT NULL, + `last_editor` varchar(32), + `edits` text, + PRIMARY KEY (`ckey`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + + +-- +-- Table structure for table `SS13_notes` +-- + +DROP TABLE IF EXISTS `SS13_notes`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_notes` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `ckey` varchar(32) NOT NULL, + `notetext` text NOT NULL, + `timestamp` datetime NOT NULL, + `adminckey` varchar(32) NOT NULL, + `last_editor` varchar(32), + `edits` text, + `server` varchar(50) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_memo` +-- + +DROP TABLE IF EXISTS `SS13_memo`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_memo` ( + `ckey` varchar(32) NOT NULL, + `memotext` text NOT NULL, + `timestamp` datetime NOT NULL, + `last_editor` varchar(32), + `edits` text, + PRIMARY KEY (`ckey`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; diff --git a/code/_globalvars/database.dm b/code/_globalvars/database.dm index 987b31b9ff7..5c5b4e93f6a 100644 --- a/code/_globalvars/database.dm +++ b/code/_globalvars/database.dm @@ -1,36 +1,11 @@ - // MySQL configuration +// MySQL configuration var/sqladdress = "localhost" var/sqlport = "3306" -var/sqldb = "paradise" -var/sqllogin = "root" -var/sqlpass = "example" - - // Feedback gathering sql connection -var/sqlfdbkdb = "paradise" +var/sqlfdbkdb = "test" var/sqlfdbklogin = "root" -var/sqlfdbkpass = "example" +var/sqlfdbkpass = "" var/sqlfdbktableprefix = "erro_" //backwords compatibility with downstream server hosts -var/sqllogging = 0 // Should we log deaths, population stats, etc? - - // Forum MySQL configuration (for use with forum account/key authentication) - // These are all default values that will load should the forumdbconfig.txt - // file fail to read for whatever reason. - -var/forumsqladdress = "localhost" -var/forumsqlport = "3306" -var/forumsqldb = "tgstation" -var/forumsqllogin = "root" -var/forumsqlpass = "bleh" -var/forum_activated_group = "2" -var/forum_authenticated_group = "10" - - // For FTP requests. (i.e. downloading runtime logs.) - // However it'd be ok to use for accessing attack logs and such too, which are even laggier. -var/fileaccess_timer = 0 -var/custom_event_msg = null - //Database connections //A connection is established on world creation. Ideally, the connection dies when the server restarts (After feedback logging.). var/DBConnection/dbcon = new() //Feedback database (New database) -var/DBConnection/dbcon_old = new() //Tgstation database (Old database) - See the files in the SQL folder for information what goes where. \ No newline at end of file diff --git a/code/_globalvars/game_modes.dm b/code/_globalvars/game_modes.dm index 6051d6c8e16..16e54703cf4 100644 --- a/code/_globalvars/game_modes.dm +++ b/code/_globalvars/game_modes.dm @@ -2,4 +2,6 @@ var/master_mode = "extended"//"extended" var/secret_force_mode = "secret" // if this is anything but "secret", the secret rotation will forceably choose this mode var/wavesecret = 0 // meteor mode, delays wave progression, terrible name -var/datum/station_state/start_state = null // Used in round-end report \ No newline at end of file +var/datum/station_state/start_state = null // Used in round-end report + +var/custom_event_msg = null \ No newline at end of file diff --git a/code/_globalvars/misc.dm b/code/_globalvars/misc.dm index 00a878bf27f..b319f9259b9 100644 --- a/code/_globalvars/misc.dm +++ b/code/_globalvars/misc.dm @@ -66,4 +66,8 @@ var/score_dmgestkey = null var/TAB = "    " -var/timezoneOffset = 0 // The difference betwen midnight (of the host computer) and 0 world.ticks. \ No newline at end of file +var/timezoneOffset = 0 // The difference betwen midnight (of the host computer) and 0 world.ticks. + +// For FTP requests. (i.e. downloading runtime logs.) +// However it'd be ok to use for accessing attack logs and such too, which are even laggier. +var/fileaccess_timer = 0 \ No newline at end of file diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 5f6f5c9978a..4b74a3c7aa0 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -21,7 +21,7 @@ var/log_runtimes = 0 // Logs all runtimes. var/log_hrefs = 0 // logs all links clicked in-game. Could be used for debugging and tracking down exploits var/log_runtime = 0 // logs world.log to a file - var/sql_enabled = 1 // for sql switching + var/sql_enabled = 0 // for sql switching var/allow_admin_ooccolor = 0 // Allows admins with relevant permissions to have their own ooc colour var/allow_vote_restart = 0 // allow votes to restart var/allow_vote_mode = 0 // allow votes to change mode @@ -78,10 +78,10 @@ var/server var/banappeals - var/wikiurl = "http://baystation12.net/wiki" - var/forumurl = "http://baystation12.net/forums/" + var/wikiurl = "http://example.org" + var/forumurl = "http://example.org" - var/media_base_url = "http://nanotrasen.se/media" // http://ss13.nexisonline.net/media + var/media_base_url = "http://example.org" var/overflow_server_url var/forbid_singulo_possession = 0 @@ -101,7 +101,6 @@ var/revival_cloning = 1 var/revival_brain_life = -1 - var/auto_toggle_ooc_during_round = 0 //Used for modifying movement speed for mobs. @@ -234,9 +233,6 @@ if ("log_access") config.log_access = 1 - if ("sql_enabled") - config.sql_enabled = text2num(value) - if ("log_say") config.log_say = 1 @@ -623,16 +619,12 @@ continue switch (name) + if("sql_enabled") + config.sql_enabled = 1 if ("address") sqladdress = value if ("port") sqlport = value - if ("database") - sqldb = value - if ("login") - sqllogin = value - if ("password") - sqlpass = value if ("feedback_database") sqlfdbkdb = value if ("feedback_login") @@ -641,50 +633,6 @@ sqlfdbkpass = value if("feedback_tableprefix") sqlfdbktableprefix = value - if ("enable_stat_tracking") - sqllogging = 1 - else - diary << "Unknown setting in configuration: '[name]'" - -/datum/configuration/proc/loadforumsql(filename) // -- TLE - var/list/Lines = file2list(filename) - for(var/t in Lines) - if(!t) continue - - t = trim(t) - if (length(t) == 0) - continue - else if (copytext(t, 1, 2) == "#") - continue - - var/pos = findtext(t, " ") - var/name = null - var/value = null - - if (pos) - name = lowertext(copytext(t, 1, pos)) - value = copytext(t, pos + 1) - else - name = lowertext(t) - - if (!name) - continue - - switch (name) - if ("address") - forumsqladdress = value - if ("port") - forumsqlport = value - if ("database") - forumsqldb = value - if ("login") - forumsqllogin = value - if ("password") - forumsqlpass = value - if ("activatedgroup") - forum_activated_group = value - if ("authenticatedgroup") - forum_authenticated_group = value else diary << "Unknown setting in configuration: '[name]'" diff --git a/code/defines/procs/dbcore.dm b/code/defines/procs/dbcore.dm index 45139ab3fb1..35470e8c598 100644 --- a/code/defines/procs/dbcore.dm +++ b/code/defines/procs/dbcore.dm @@ -56,7 +56,7 @@ DBConnection/New(dbi_handler,username,password_handler,cursor_handler) _db_con = _dm_db_new_con() DBConnection/proc/Connect(dbi_handler=src.dbi,user_handler=src.user,password_handler=src.password,cursor_handler) - if(!sqllogging) + if(!config.sql_enabled) return 0 if(!src) return 0 cursor_handler = src.default_cursor @@ -66,7 +66,7 @@ DBConnection/proc/Connect(dbi_handler=src.dbi,user_handler=src.user,password_han DBConnection/proc/Disconnect() return _dm_db_close(_db_con) DBConnection/proc/IsConnected() - if(!sqllogging) return 0 + if(!config.sql_enabled) return 0 var/success = _dm_db_is_connected(_db_con) return success diff --git a/code/defines/procs/statistics.dm b/code/defines/procs/statistics.dm index 52c0af1af82..8c399d1a913 100644 --- a/code/defines/procs/statistics.dm +++ b/code/defines/procs/statistics.dm @@ -1,5 +1,5 @@ -proc/sql_poll_players() - if(!sqllogging) +/proc/sql_poll_players() + if(!config.sql_enabled) return var/playercount = 0 for(var/mob/M in player_list) @@ -10,14 +10,14 @@ 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_old.NewQuery("INSERT INTO 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") -proc/sql_poll_admins() - if(!sqllogging) +/proc/sql_poll_admins() + if(!config.sql_enabled) return var/admincount = admins.len establish_db_connection() @@ -25,33 +25,32 @@ 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_old.NewQuery("INSERT INTO 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") -proc/sql_report_round_start() +/proc/sql_report_round_start() // TODO - if(!sqllogging) - return -proc/sql_report_round_end() - // TODO - if(!sqllogging) + if(!config.sql_enabled) return -proc/sql_report_death(var/mob/living/carbon/human/H) - if(!sqllogging) +/proc/sql_report_round_end() + // TODO + if(!config.sql_enabled) + return + +/proc/sql_report_death(mob/living/carbon/human/H) + if(!config.sql_enabled) return if(!H) return if(!H.key || !H.mind) return - var/turf/T = get_turf(H) - var/area/placeofdeath = get_area(T) - var/podname = sanitizeSQL("Unknown Area") - if(placeofdeath) - podname = sanitizeSQL(placeofdeath.name) + var/turf/T = H.loc + var/area/placeofdeath = get_area(T.loc) + var/podname = placeofdeath.name var/sqlname = sanitizeSQL(H.real_name) var/sqlkey = sanitizeSQL(H.key) @@ -70,25 +69,23 @@ 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 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") -proc/sql_report_cyborg_death(var/mob/living/silicon/robot/H) - if(!sqllogging) +/proc/sql_report_cyborg_death(mob/living/silicon/robot/H) + if(!config.sql_enabled) return if(!H) return if(!H.key || !H.mind) return - var/turf/T = get_turf(H) - var/area/placeofdeath = get_area(T) - var/podname = sanitizeSQL("Unknown Area") - if(placeofdeath) - podname = sanitizeSQL(placeofdeath.name) + var/turf/T = H.loc + var/area/placeofdeath = get_area(T.loc) + var/podname = placeofdeath.name var/sqlname = sanitizeSQL(H.real_name) var/sqlkey = sanitizeSQL(H.key) @@ -107,23 +104,22 @@ 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 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") - -proc/statistic_cycle() - if(!sqllogging) +/proc/statistic_cycle() + if(!config.sql_enabled) return while(1) sql_poll_players() sleep(600) sql_poll_admins() - sleep(6000) // Poll every ten minutes + sleep(6000) //Poll every ten minutes //This proc is used for feedback. It is executed at round end. -proc/sql_commit_feedback() +/proc/sql_commit_feedback() if(!blackbox) log_game("Round ended without a blackbox recorder. No feedback was sent to the database.") return @@ -163,4 +159,5 @@ proc/sql_commit_feedback() 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 death reporting. Error : \[[err]\]\n") \ No newline at end of file + log_game("SQL ERROR during feedback reporting. Error : \[[err]\]\n") + \ No newline at end of file diff --git a/code/game/gamemodes/gameticker.dm b/code/game/gamemodes/gameticker.dm index e5badecac9b..3a45f364a94 100644 --- a/code/game/gamemodes/gameticker.dm +++ b/code/game/gamemodes/gameticker.dm @@ -214,6 +214,10 @@ var/global/datum/controller/gameticker/ticker if(admins_number == 0) send2adminirc("Round has started with no admins online.") auto_toggle_ooc(0) // Turn it off + + if(config.sql_enabled) + spawn(3000) + statistic_cycle() // Polls population totals regularly and stores them in an SQL DB /* DONE THROUGH PROCESS SCHEDULER supply_controller.process() //Start the supply shuttle regenerating points -- TLE @@ -223,10 +227,6 @@ var/global/datum/controller/gameticker/ticker processScheduler.start() - if(config.sql_enabled) - spawn(3000) - statistic_cycle() // Polls population totals regularly and stores them in an SQL DB -- TLE - votetimer() for(var/mob/M in mob_list) diff --git a/code/game/jobs/whitelist.dm b/code/game/jobs/whitelist.dm index ec1dd4491d2..68610e3c0a7 100644 --- a/code/game/jobs/whitelist.dm +++ b/code/game/jobs/whitelist.dm @@ -27,7 +27,7 @@ var/list/whitelist = list() usr << "\red Unable to connect to whitelist database. Please try again later.
" return 0 else - var/DBQuery/query = dbcon.NewQuery("SELECT job FROM whitelist WHERE ckey='[M.key]'") + var/DBQuery/query = dbcon.NewQuery("SELECT job FROM [format_table_name("whitelist")] WHERE ckey='[M.key]'") query.Execute() @@ -72,7 +72,7 @@ var/list/whitelist = list() usr << "\red Unable to connect to whitelist database. Please try again later.
" return 0 else - var/DBQuery/query = dbcon.NewQuery("SELECT species FROM whitelist WHERE ckey='[M.key]'") + var/DBQuery/query = dbcon.NewQuery("SELECT species FROM [format_table_name("whitelist")] WHERE ckey='[M.key]'") query.Execute() while(query.NextRow()) diff --git a/code/game/machinery/records_scanner.dm b/code/game/machinery/records_scanner.dm index 370e2f3843e..c203c318655 100644 --- a/code/game/machinery/records_scanner.dm +++ b/code/game/machinery/records_scanner.dm @@ -51,14 +51,7 @@ obj/machinery/scanner/attack_hand(mob/living/carbon/human/user) var/list/marks = list() var/age = user.age var/gender = user.gender - /* no dbstuff yet - var/DBQuery/cquery = dbcon.NewQuery("SELECT * from jobban WHERE ckey='[user.ckey]'") - if(!cquery.Execute()) return - else - while(cquery.NextRow()) - var/list/row = cquery.GetRowData() - marks += row["rank"] - */ + var/text = {"
Report

Name: [mname] diff --git a/code/game/magic/archived_book.dm b/code/game/magic/archived_book.dm deleted file mode 100644 index 2fc9412fcd9..00000000000 --- a/code/game/magic/archived_book.dm +++ /dev/null @@ -1,126 +0,0 @@ -//This file was auto-corrected by findeclaration.exe on 29/05/2012 15:03:04 - -#define BOOK_VERSION_MIN 1 -#define BOOK_VERSION_MAX 2 -#define BOOK_PATH "data/books/" -#define BOOKS_USE_SQL 0 // no guarentee for this branch to work right with sql - -var/global/datum/book_manager/book_mgr = new() - -datum/book_manager/proc/path(id) - if(isnum(id)) // kill any path exploits - return "[BOOK_PATH][id].sav" - -datum/book_manager/proc/getall() - var/list/paths = flist(BOOK_PATH) - var/list/books = new() - - for(var/path in paths) - var/datum/archived_book/B = new(BOOK_PATH + path) - books += B - - return books - -datum/book_manager/proc/freeid() - var/list/paths = flist(BOOK_PATH) - var/id = paths.len + 101 - - // start at 101+number of books, which will be correct id if none have been deleted, etc - // otherwise, keep moving forward until we find an open id - while(fexists(path(id))) - id++ - - return id - -/client/proc/delbook() - set name = "Delete Book" - set desc = "Permamently deletes a book from the database." - set category = "Admin" - if(!src.holder) - src << "Only administrators may use this command." - return - - var/isbn = input("ISBN number?", "Delete Book") as num | null - if(!isbn) - return - - if(BOOKS_USE_SQL && config.sql_enabled) - var/DBConnection/dbcon = new() - dbcon.Connect("dbi:mysql:[sqldb]:[sqladdress]:[sqlport]","[sqllogin]","[sqlpass]") - if(!dbcon.IsConnected()) - alert("Connection to Archive has been severed. Aborting.") - else - var/DBQuery/query = dbcon.NewQuery("DELETE FROM library WHERE id=[isbn]") - if(!query.Execute()) - usr << query.ErrorMsg() - dbcon.Disconnect() - else - book_mgr.remove(isbn) - log_admin("[usr.key] has deleted the book [isbn]") - -// delete a book -datum/book_manager/proc/remove(var/id) - fdel(path(id)) - -datum/archived_book - var/author // Who wrote the thing, can be changed by pen or PC. It is not automatically assigned - var/title // The real name of the book. - var/category // The category/genre of the book - var/id // the id of the book (like an isbn number) - var/dat // Actual page content - - var/author_real // author's real_name - var/author_key // author's byond key - var/list/icon/photos // in-game photos used - -// loads the book corresponding by the specified id -datum/archived_book/New(var/path) - if(isnull(path)) - return - - var/savefile/F = new(path) - - var/version - F["version"] >> version - - if (isnull(version) || version < BOOK_VERSION_MIN || version > BOOK_VERSION_MAX) - fdel(path) - usr << "What book?" - return 0 - - F["author"] >> author - F["title"] >> title - F["category"] >> category - F["id"] >> id - F["dat"] >> dat - - F["author_real"] >> author_real - F["author_key"] >> author_key - F["photos"] >> photos - if(!photos) - photos = new() - - // let's sanitize it here too! - for(var/tag in paper_blacklist) - if(findtext(dat,"<"+tag)) - dat = "" - return - - -datum/archived_book/proc/save() - var/savefile/F = new(book_mgr.path(id)) - - F["version"] << BOOK_VERSION_MAX - F["author"] << author - F["title"] << title - F["category"] << category - F["id"] << id - F["dat"] << dat - - F["author_real"] << author_real - F["author_key"] << author_key - F["photos"] << photos - -#undef BOOK_VERSION_MIN -#undef BOOK_VERSION_MAX -#undef BOOK_PATH diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 0164e814864..15db708048a 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -783,6 +783,8 @@ var/list/admin_verbs_mentor = list( /client/proc/playernotes() set name = "Show Player Info" set category = "Admin" + if(!check_rights(R_ADMIN)) + return if(holder) holder.PlayerNotes() return @@ -790,18 +792,21 @@ var/list/admin_verbs_mentor = list( /client/proc/free_slot() set name = "Free Job Slot" set category = "Admin" - if(holder) - var/list/jobs = list() - for (var/datum/job/J in job_master.occupations) - if (J.current_positions >= J.total_positions && J.total_positions != -1) - jobs += J.title - if (!jobs.len) - usr << "There are no fully staffed jobs." - return - var/job = input("Please select job slot to free", "Free job slot") as null|anything in jobs - if (job) - job_master.FreeRole(job) - return + if(!check_rights(R_ADMIN)) + return + + var/list/jobs = list() + for (var/datum/job/J in job_master.occupations) + if (J.current_positions >= J.total_positions && J.total_positions != -1) + jobs += J.title + if (!jobs.len) + usr << "There are no fully staffed jobs." + return + var/job = input("Please select job slot to free", "Free job slot") as null|anything in jobs + if (job) + job_master.FreeRole(job) + log_admin("[key_name(usr)] has freed a job slot for [job].") + message_admins("[key_name_admin(usr) has freed a job slot for [job].") /client/proc/toggleattacklogs() set name = "Toggle Attack Log Messages" diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index cdc89d056ad..2dd0e2adb71 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -5,17 +5,16 @@ if(Debug2) Debug2 = 0 - message_admins("[key_name(src)] toggled debugging off.") + message_admins("[key_name_admin(src)] toggled debugging off.") log_admin("[key_name(src)] toggled debugging off.") else Debug2 = 1 - message_admins("[key_name(src)] toggled debugging on.") + message_admins("[key_name_admin(src)] toggled debugging on.") log_admin("[key_name(src)] toggled debugging on.") feedback_add_details("admin_verb","DG2") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! - /* 21st Sept 2010 Updated by Skie -- Still not perfect but better! Stuff you can't do: diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index e777a1cc020..829c464bd28 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -1608,7 +1608,7 @@ datum/preferences proc/open_load_dialog(mob/user) - var/DBQuery/query = dbcon.NewQuery("SELECT slot,real_name FROM characters WHERE ckey='[user.ckey]' ORDER BY slot") + var/DBQuery/query = dbcon.NewQuery("SELECT slot,real_name FROM [format_table_name("characters")] WHERE ckey='[user.ckey]' ORDER BY slot") var/dat = "" dat += "
" diff --git a/code/modules/customitems/item_spawning.dm b/code/modules/customitems/item_spawning.dm index c1b1e5f644e..7a1045d988a 100644 --- a/code/modules/customitems/item_spawning.dm +++ b/code/modules/customitems/item_spawning.dm @@ -37,7 +37,7 @@ */ // Grab the info we want. - var/DBQuery/query = dbcon.NewQuery("SELECT cuiPath, cuiPropAdjust, cuiJobMask, cuiDescription, cuiItemName FROM CustomUserItems WHERE cuiCKey='[M.ckey]' AND (cuiRealName='[M.real_name]' OR cuiRealName='*')") + var/DBQuery/query = dbcon.NewQuery("SELECT cuiPath, cuiPropAdjust, cuiJobMask, cuiDescription, cuiItemName FROM [format_table_name("customuseritems")] WHERE cuiCKey='[M.ckey]' AND (cuiRealName='[M.real_name]' OR cuiRealName='*')") query.Execute() while(query.NextRow()) diff --git a/code/modules/karma/karma.dm b/code/modules/karma/karma.dm index 4144c4ef5cc..9633383e98a 100644 --- a/code/modules/karma/karma.dm +++ b/code/modules/karma/karma.dm @@ -18,13 +18,13 @@ proc/sql_report_karma(var/mob/spender, var/mob/receiver) log_game("SQL ERROR during karma logging. Failed to connect.") else var/sqltime = time2text(world.realtime, "YYYY-MM-DD hh:mm:ss") - var/DBQuery/query = dbcon.NewQuery("INSERT INTO karma (spendername, spenderkey, receivername, receiverkey, receiverrole, receiverspecial, spenderip, time) VALUES ('[sqlspendername]', '[sqlspenderkey]', '[sqlreceivername]', '[sqlreceiverkey]', '[sqlreceiverrole]', '[sqlreceiverspecial]', '[sqlspenderip]', '[sqltime]')") + var/DBQuery/query = dbcon.NewQuery("INSERT INTO [format_table_name("karma")] (spendername, spenderkey, receivername, receiverkey, receiverrole, receiverspecial, spenderip, time) VALUES ('[sqlspendername]', '[sqlspenderkey]', '[sqlreceivername]', '[sqlreceiverkey]', '[sqlreceiverrole]', '[sqlreceiverspecial]', '[sqlspenderip]', '[sqltime]')") if(!query.Execute()) var/err = query.ErrorMsg() log_game("SQL ERROR during karma logging. Error : \[[err]\]\n") - query = dbcon.NewQuery("SELECT * FROM karmatotals WHERE byondkey='[receiver.key]'") + query = dbcon.NewQuery("SELECT * FROM [format_table_name("karmatotals")] WHERE byondkey='[receiver.key]'") query.Execute() var/karma @@ -34,13 +34,13 @@ proc/sql_report_karma(var/mob/spender, var/mob/receiver) karma = text2num(query.item[3]) if(karma == null) karma = 1 - query = dbcon.NewQuery("INSERT INTO karmatotals (byondkey, karma) VALUES ('[receiver.key]', [karma])") + query = dbcon.NewQuery("INSERT INTO [format_table_name("karmatotals")] (byondkey, karma) VALUES ('[receiver.key]', [karma])") if(!query.Execute()) var/err = query.ErrorMsg() log_game("SQL ERROR during karmatotal logging (adding new key). Error : \[[err]\]\n") else karma += 1 - query = dbcon.NewQuery("UPDATE karmatotals SET karma=[karma] WHERE id=[id]") + query = dbcon.NewQuery("UPDATE [format_table_name("karmatotals")] SET karma=[karma] WHERE id=[id]") if(!query.Execute()) var/err = query.ErrorMsg() log_game("SQL ERROR during karmatotal logging (updating existing entry). Error : \[[err]\]\n") @@ -149,7 +149,7 @@ var/list/karma_spenders = list() usr << "\red Unable to connect to karma database. Please try again later.
" return else - var/DBQuery/query = dbcon.NewQuery("SELECT karma, karmaspent FROM karmatotals WHERE byondkey='[src.key]'") + var/DBQuery/query = dbcon.NewQuery("SELECT karma, karmaspent FROM [format_table_name("karmatotals")] WHERE byondkey='[src.key]'") query.Execute() var/totalkarma @@ -249,7 +249,7 @@ You've gained [totalkarma] total karma in your time here.
"} return /client/proc/DB_job_unlock(var/job,var/cost) - var/DBQuery/query = dbcon.NewQuery("SELECT * FROM whitelist WHERE ckey='[usr.key]'") + var/DBQuery/query = dbcon.NewQuery("SELECT * FROM [format_table_name("whitelist")] WHERE ckey='[usr.key]'") query.Execute() var/dbjob @@ -258,7 +258,7 @@ You've gained [totalkarma] total karma in your time here.
"} dbckey = query.item[2] dbjob = query.item[3] if(!dbckey) - query = dbcon.NewQuery("INSERT INTO whitelist (ckey, job) VALUES ('[usr.key]','[job]')") + query = dbcon.NewQuery("INSERT INTO [format_table_name("whitelist")] (ckey, job) VALUES ('[usr.key]','[job]')") if(!query.Execute()) var/err = query.ErrorMsg() log_game("SQL ERROR during whitelist logging (adding new key). Error: \[[err]\]\n") @@ -274,7 +274,7 @@ You've gained [totalkarma] total karma in your time here.
"} if(!(job in joblist)) joblist += job var/newjoblist = list2text(joblist,",") - query = dbcon.NewQuery("UPDATE whitelist SET job='[newjoblist]' WHERE ckey='[dbckey]'") + query = dbcon.NewQuery("UPDATE [format_table_name("whitelist")] SET job='[newjoblist]' WHERE ckey='[dbckey]'") if(!query.Execute()) var/err = query.ErrorMsg() log_game("SQL ERROR during whitelist logging (updating existing entry). Error : \[[err]\]\n") @@ -289,7 +289,7 @@ You've gained [totalkarma] total karma in your time here.
"} return /client/proc/DB_species_unlock(var/species,var/cost) - var/DBQuery/query = dbcon.NewQuery("SELECT * FROM whitelist WHERE ckey='[usr.key]'") + var/DBQuery/query = dbcon.NewQuery("SELECT * FROM [format_table_name("whitelist")] WHERE ckey='[usr.key]'") query.Execute() var/dbspecies @@ -298,7 +298,7 @@ You've gained [totalkarma] total karma in your time here.
"} dbckey = query.item[2] dbspecies = query.item[4] if(!dbckey) - query = dbcon.NewQuery("INSERT INTO whitelist (ckey, species) VALUES ('[usr.key]','[species]')") + query = dbcon.NewQuery("INSERT INTO [format_table_name("whitelist")] (ckey, species) VALUES ('[usr.key]','[species]')") if(!query.Execute()) var/err = query.ErrorMsg() log_game("SQL ERROR during whitelist logging (adding new key). Error : \[[err]\]\n") @@ -314,7 +314,7 @@ You've gained [totalkarma] total karma in your time here.
"} if(!(species in specieslist)) specieslist += species var/newspecieslist = list2text(specieslist,",") - query = dbcon.NewQuery("UPDATE whitelist SET species='[newspecieslist]' WHERE ckey='[dbckey]'") + query = dbcon.NewQuery("UPDATE [format_table_name("whitelist")] SET species='[newspecieslist]' WHERE ckey='[dbckey]'") if(!query.Execute()) var/err = query.ErrorMsg() log_game("SQL ERROR during whitelist logging (updating existing entry). Error: \[[err]\]\n") @@ -329,7 +329,7 @@ You've gained [totalkarma] total karma in your time here.
"} return /client/proc/karmacharge(var/cost,var/refund = 0) - var/DBQuery/query = dbcon.NewQuery("SELECT * FROM karmatotals WHERE byondkey='[usr.key]'") + var/DBQuery/query = dbcon.NewQuery("SELECT * FROM [format_table_name("karmatotals")] WHERE byondkey='[usr.key]'") query.Execute() while(query.NextRow()) @@ -338,7 +338,7 @@ You've gained [totalkarma] total karma in your time here.
"} spent -= cost else spent += cost - query = dbcon.NewQuery("UPDATE karmatotals SET karmaspent=[spent] WHERE byondkey='[usr.key]'") + query = dbcon.NewQuery("UPDATE [format_table_name("karmatotals")] SET karmaspent=[spent] WHERE byondkey='[usr.key]'") if(!query.Execute()) var/err = query.ErrorMsg() log_game("SQL ERROR during karmaspent updating (updating existing entry). Error: \[[err]\]\n") @@ -374,7 +374,7 @@ You've gained [totalkarma] total karma in your time here.
"} usr << "\red That job is not refundable." return - var/DBQuery/query = dbcon.NewQuery("SELECT * FROM whitelist WHERE ckey='[usr.key]'") + var/DBQuery/query = dbcon.NewQuery("SELECT * FROM [format_table_name("whitelist")] WHERE ckey='[usr.key]'") query.Execute() var/dbjob @@ -397,7 +397,7 @@ You've gained [totalkarma] total karma in your time here.
"} if(name in typelist) typelist -= name var/newtypelist = list2text(typelist,",") - query = dbcon.NewQuery("UPDATE whitelist SET [type]='[newtypelist]' WHERE ckey='[dbckey]'") + query = dbcon.NewQuery("UPDATE [format_table_name("whitelist")] SET [type]='[newtypelist]' WHERE ckey='[dbckey]'") if(!query.Execute()) var/err = query.ErrorMsg() log_game("SQL ERROR during whitelist logging (updating existing entry). Error: \[[err]\]\n") @@ -414,7 +414,7 @@ You've gained [totalkarma] total karma in your time here.
"} usr << "\red Your ckey ([dbckey]) was not found." /client/proc/checkpurchased(var/name = null) // If the first parameter is null, return a full list of purchases - var/DBQuery/query = dbcon.NewQuery("SELECT * FROM whitelist WHERE ckey='[usr.key]'") + var/DBQuery/query = dbcon.NewQuery("SELECT * FROM [format_table_name("whitelist")] WHERE ckey='[usr.key]'") query.Execute() var/dbjob diff --git a/code/modules/library/lib_machines.dm b/code/modules/library/lib_machines.dm index b41f77a0b42..f64b4b5ecf4 100644 --- a/code/modules/library/lib_machines.dm +++ b/code/modules/library/lib_machines.dm @@ -43,8 +43,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f Filter by Author: [author]
\[Start Search\]
"} if(1) - establish_old_db_connection() - if(!dbcon_old.IsConnected()) + if(!dbcon.IsConnected()) dat += "ERROR: Unable to contact External Archive. Please contact your system administrator for assistance.
" else if(!SQLquery) dat += "ERROR: Malformed search request. Please contact your system administrator for assistance.
" @@ -52,7 +51,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f dat += "" dat += "" - var/DBQuery/query = dbcon_old.NewQuery(SQLquery) + var/DBQuery/query = dbcon.NewQuery(SQLquery) query.Execute() while(query.NextRow()) @@ -94,7 +93,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 library WHERE " + SQLquery = "SELECT author, title, category, id FROM [format_table_name("library")] WHERE " if(category == "Any") SQLquery += "author LIKE '%[author]%' AND title LIKE '%[title]%'" else @@ -189,16 +188,18 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f (Return to main menu)
"} if(4) dat += "

External Archive

" - establish_old_db_connection() - if(!dbcon_old.IsConnected()) + if(!dbcon.IsConnected()) dat += "ERROR: Unable to contact External Archive. Please contact your system administrator for assistance." else dat += "(Order book by SS13BN)

" dat += "
AUTHORTITLECATEGORYSS13BN
" dat += "" - var/DBQuery/query = dbcon_old.NewQuery("SELECT id, author, title, category FROM library") - query.Execute() + var/DBQuery/query = dbcon.NewQuery("SELECT id, author, title, category FROM [format_table_name("library")]") + if(!query.Execute()) + var/err = query.ErrorMsg() + log_game("SQL ERROR accessing book. Error : \[[err]\]\n") + return while(query.NextRow()) var/id = query.item[1] @@ -333,8 +334,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f if(scanner.cache) var/choice = input("Are you certain you wish to upload this title to the Archive?") in list("Confirm", "Abort") if(choice == "Confirm") - establish_old_db_connection() - if(!dbcon_old.IsConnected()) + if(!dbcon.IsConnected()) alert("Connection to Archive has been severed. Aborting.") else /* @@ -347,9 +347,11 @@ 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_old.NewQuery("INSERT INTO library (author, title, content, category, ckey) VALUES ('[sqlauthor]', '[sqltitle]', '[sqlcontent]', '[sqlcategory]', '[usr.key]')") + var/DBQuery/query = dbcon.NewQuery("INSERT INTO [format_table_name("library")] (author, title, content, category, ckey) VALUES ('[sqlauthor]', '[sqltitle]', '[sqlcontent]', '[sqlcategory]', '[usr.key]')") if(!query.Execute()) - usr << query.ErrorMsg() + var/err = query.ErrorMsg() + log_game("SQL ERROR adding new book. Error : \[[err]\]\n") + return else log_game("[usr.name]/[usr.key] has uploaded the book titled [scanner.cache.name], [length(scanner.cache.dat)] signs") message_admins("[key_name_admin(usr)] has uploaded the book titled [scanner.cache.name], [length(scanner.cache.dat)] signs") @@ -357,8 +359,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f if(href_list["targetid"]) var/sqlid = sanitizeSQL(href_list["targetid"]) - establish_old_db_connection() - if(!dbcon_old.IsConnected()) + if(!dbcon.IsConnected()) alert("Connection to Archive has been severed. Aborting.") // reused working printing call from bible code.. needs testing ((Lazureus)) @@ -367,7 +368,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_old.NewQuery("SELECT * FROM library WHERE id=[sqlid]") + var/DBQuery/query = dbcon.NewQuery("SELECT * FROM [format_table_name("library")] WHERE id=[sqlid]") query.Execute() while(query.NextRow()) @@ -472,6 +473,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f qdel(O) else ..() + /client/proc/delbook() set name = "Delete Book" set desc = "Permamently deletes a book from the database." @@ -483,15 +485,12 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f var/isbn = input("ISBN number?", "Delete Book") as num | null if(!isbn) return + + var/DBQuery/query_delbook = dbcon.NewQuery("DELETE FROM [format_table_name("library")] WHERE id=[isbn]") + if(!query_delbook.Execute()) + var/err = query_delbook.ErrorMsg() + log_game("SQL ERROR deleting book. Error : \[[err]\]\n") + return - if(dbcon_old.IsConnected()) - var/DBConnection/dbcon = new() - dbcon.Connect("dbi:mysql:[sqldb]:[sqladdress]:[sqlport]","[sqllogin]","[sqlpass]") - if(!dbcon.IsConnected()) - alert("Connection to Archive has been severed. Aborting.") - else - var/DBQuery/query = dbcon.NewQuery("DELETE FROM library WHERE id=[isbn]") - if(!query.Execute()) - usr << query.ErrorMsg() - dbcon.Disconnect() - log_admin("[usr.key] has deleted the book [isbn]") + log_admin("[key_name(usr)] has deleted the book [isbn].") + message_admins("[key_name_admin(usr) has deleted the book [isbn].") diff --git a/code/world.dm b/code/world.dm index e5b158cbc7c..9edfb4c38a4 100644 --- a/code/world.dm +++ b/code/world.dm @@ -332,7 +332,6 @@ var/world_topic_spam_protect_time = world.timeofday config.load("config/config.txt") config.load("config/game_options.txt","game_options") config.loadsql("config/dbconfig.txt") - config.loadforumsql("config/forumdbconfig.txt") config.loadoverflowwhitelist("config/ofwhitelist.txt") // apply some settings from config.. @@ -469,47 +468,4 @@ proc/establish_db_connection() else return 1 - -/hook/startup/proc/connectOldDB() - if(!setup_old_database_connection()) - log_to_dd("Your server failed to establish a connection with the SQL database.") - else - log_to_dd("SQL database connection established.") - return 1 - -//These two procs are for the old database, while it's being phased out. See the tgstation.sql file in the SQL folder for more information. -proc/setup_old_database_connection() - - if(failed_old_db_connections > FAILED_DB_CONNECTION_CUTOFF) //If it failed to establish a connection more than 5 times in a row, don't bother attempting to conenct anymore. - return 0 - - if(!dbcon_old) - dbcon_old = new() - - var/user = sqllogin - var/pass = sqlpass - var/db = sqldb - var/address = sqladdress - var/port = sqlport - - dbcon_old.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]") - . = dbcon_old.IsConnected() - if ( . ) - failed_old_db_connections = 0 //If this connection succeeded, reset the failed connections counter. - else - failed_old_db_connections++ //If it failed, increase the failed connections counter. - log_to_dd(dbcon.ErrorMsg()) - - return . - -//This proc ensures that the connection to the feedback database (global variable dbcon) is established -proc/establish_old_db_connection() - if(failed_old_db_connections > FAILED_DB_CONNECTION_CUTOFF) - return 0 - - if(!dbcon_old || !dbcon_old.IsConnected()) - return setup_old_database_connection() - else - return 1 - #undef FAILED_DB_CONNECTION_CUTOFF diff --git a/config/example/config.txt b/config/example/config.txt index 28c664f3b6a..79dde60cd62 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -63,9 +63,6 @@ LOG_RUNTIME ## log admin warning messages ##LOG_ADMINWARN ## Also duplicates a bunch of other messages. -## sql switching -# SQL_ENABLED - ## disconnect players who did nothing during 15 minutes KICK_INACTIVE diff --git a/config/example/dbconfig.txt b/config/example/dbconfig.txt index 01d38fd1c56..4dd55974678 100644 --- a/config/example/dbconfig.txt +++ b/config/example/dbconfig.txt @@ -1,28 +1,33 @@ -# MySQL Connection Configuration +## MySQL Connection Configuration +## This is used for stats, feedback gathering, +## administration, and the in game library. -# Server the MySQL database can be found at +## Should SQL be enabled? Uncomment to enable. +#SQL_ENABLED + +## Server the MySQL database can be found at. # Examples: localhost, 200.135.5.43, www.mysqldb.com, etc. ADDRESS localhost -# MySQL server port (default is 3306) +## MySQL server port (default is 3306). PORT 3306 -# Database the population, death, karma, etc. tables may be found in -DATABASE paradise +## Database for all SQL functions, not just feedback. +FEEDBACK_DATABASE feedback -# Username/Login used to access the database -LOGIN mylogin +## 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 -# Password used to access the database -PASSWORD mypassword +## Username/Login used to access the database. +FEEDBACK_LOGIN username -# The following information is for feedback tracking via the blackbox server -FEEDBACK_DATABASE paradise -FEEDBACK_LOGIN mylogin -FEEDBACK_PASSWORD mypassword -# Table prefix - make sure you properly prefix the tables currently marked as erro_ in the .sql file as this is not fully implemented -FEEDBACK_TABLEPREFIX erro - -# Track population and death statistics -# Comment this out to disable -ENABLE_STAT_TRACKING \ No newline at end of file +## Password used to access the database. +FEEDBACK_PASSWORD password \ No newline at end of file diff --git a/config/example/forumdbconfig.txt b/config/example/forumdbconfig.txt deleted file mode 100644 index b66db6c5143..00000000000 --- a/config/example/forumdbconfig.txt +++ /dev/null @@ -1,19 +0,0 @@ -# This configuration file is for the forum database, if you need to set up -# population, death, etc. tracking see 'dbconfig.txt' -# The login credentials for this will likely differ from those in dbconfig.txt! - -# Server the MySQL database can be found at -# Examples: localhost, 200.135.5.43, www.mysqldb.com, etc. -ADDRESS localhost - -# MySQL server port (default is 3306) -PORT 3306 - -# Database the forum data may be found in -DATABASE paradise - -# Username/Login used to access the database -LOGIN mylogin - -# Password used to access the database -PASSWORD mypassword \ No newline at end of file
AUTHORTITLECATEGORYID