From a4e6dba7384fe08168684d757cfd0e67961b4aac Mon Sep 17 00:00:00 2001 From: Kyep Date: Mon, 16 Dec 2019 15:55:04 -0800 Subject: [PATCH] fixes connection logging to DB not working --- SQL/paradise_schema.sql | 14 ++++++++++++++ SQL/paradise_schema_prefixed.sql | 13 +++++++++++++ SQL/updates/9-10.sql | 10 ++++++++++ code/modules/client/client procs.dm | 5 ++--- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index 445de8b4d08..bfab9ba76ce 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -579,4 +579,18 @@ CREATE TABLE `playtime_history` ( `time_living` SMALLINT NOT NULL, `time_ghost` SMALLINT NOT NULL, PRIMARY KEY (`ckey`, `date`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + + +-- +-- Table structure for table `connection_log` +-- +DROP TABLE IF EXISTS `connection_log`; +CREATE TABLE `connection_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `datetime` datetime NOT NULL, + `ckey` varchar(32) NOT NULL, + `ip` varchar(32) NOT NULL, + `computerid` varchar(32) NOT NULL, + PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; \ No newline at end of file diff --git a/SQL/paradise_schema_prefixed.sql b/SQL/paradise_schema_prefixed.sql index f70593fc1ac..a83c93b7c38 100644 --- a/SQL/paradise_schema_prefixed.sql +++ b/SQL/paradise_schema_prefixed.sql @@ -577,4 +577,17 @@ CREATE TABLE `SS13_playtime_history` ( `time_living` SMALLINT NOT NULL, `time_ghost` SMALLINT NOT NULL, PRIMARY KEY (`ckey`, `date`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- +-- Table structure for table `SS13_connection_log` +-- +DROP TABLE IF EXISTS `SS13_connection_log`; +CREATE TABLE `SS13_connection_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `datetime` datetime NOT NULL, + `ckey` varchar(32) NOT NULL, + `ip` varchar(32) NOT NULL, + `computerid` varchar(32) NOT NULL, + PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; \ No newline at end of file diff --git a/SQL/updates/9-10.sql b/SQL/updates/9-10.sql index f82e7c56830..aded1301b82 100644 --- a/SQL/updates/9-10.sql +++ b/SQL/updates/9-10.sql @@ -9,3 +9,13 @@ CREATE TABLE `playtime_history` ( PRIMARY KEY (`ckey`, `date`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +# Add the 'connection_log' table, which is used to log all connections to the server +DROP TABLE IF EXISTS `connection_log`; +CREATE TABLE `connection_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `datetime` datetime NOT NULL, + `ckey` varchar(32) NOT NULL, + `ip` varchar(32) NOT NULL, + `computerid` varchar(32) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 644ac6aa123..082ce969695 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -560,9 +560,8 @@ log_game("SQL ERROR during log_client_to_db (insert). Error : \[[err]\]\n") message_admins("SQL ERROR during log_client_to_db (insert). Error : \[[err]\]\n") - //Logging player access - var/serverip = "[world.internet_address]:[world.port]" - var/DBQuery/query_accesslog = dbcon.NewQuery("INSERT INTO `[format_table_name("connection_log")]`(`id`,`datetime`,`serverip`,`ckey`,`ip`,`computerid`) VALUES(null,Now(),'[serverip]','[ckey]','[sql_ip]','[sql_computerid]');") + // Log player connections to DB + var/DBQuery/query_accesslog = dbcon.NewQuery("INSERT INTO `[format_table_name("connection_log")]`(`datetime`,`ckey`,`ip`,`computerid`) VALUES(Now(),'[ckey]','[sql_ip]','[sql_computerid]');") query_accesslog.Execute() /client/proc/check_ip_intel()