From 93b4cb9efedd6fc90824f2e28c2a59f3c162ef4b Mon Sep 17 00:00:00 2001 From: Kyep Date: Sat, 19 Oct 2019 23:56:29 -0700 Subject: [PATCH 01/16] Option to activate forum account when clicking 'forum' button --- interface/interface.dm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/interface/interface.dm b/interface/interface.dm index 8edded38e93..a733b8fed78 100644 --- a/interface/interface.dm +++ b/interface/interface.dm @@ -47,9 +47,11 @@ set desc = "Visit the forum." set hidden = 1 if(config.forumurl) - if(alert("This will open the forum in your browser. Are you sure?",,"Yes","No")=="No") - return - src << link(config.forumurl) + if(config.forum_link_url && prefs && !prefs.fuid) + if(alert("You need to activate your forum account. Activate now? (takes 2 seconds)",,"Yes","No")=="Yes") + link_forum_account() + if(alert("Open the forum in your browser?",,"Yes","No")=="Yes") + src << link(config.forumurl) else to_chat(src, "The forum URL is not set in the server configuration.") @@ -85,7 +87,7 @@ src << link(config.discordurl) else to_chat(src, "The Discord URL is not set in the server configuration.") - + /client/verb/donate() set name = "Donate" set desc = "Donate to help with hosting costs." @@ -96,7 +98,7 @@ src << link(config.donationsurl) else to_chat(src, "The rules URL is not set in the server configuration.") - + /client/verb/hotkeys_help() set name = "Hotkey Help" set category = "OOC" From 4ccf3f392484fcae0eef72135ee2e4876621c986 Mon Sep 17 00:00:00 2001 From: Kyep Date: Sun, 20 Oct 2019 00:02:28 -0700 Subject: [PATCH 02/16] Better tracking for admin online status --- code/game/jobs/job_exp.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/game/jobs/job_exp.dm b/code/game/jobs/job_exp.dm index 359981ded4f..1b64b3e8aee 100644 --- a/code/game/jobs/job_exp.dm +++ b/code/game/jobs/job_exp.dm @@ -286,9 +286,9 @@ var/global/list/role_playtime_requirements = list( var/new_exp = list2params(play_records) prefs.exp = new_exp new_exp = sanitizeSQL(new_exp) - var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("player")] SET exp = '[new_exp]' WHERE ckey='[ckey]'") + var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("player")] SET exp = '[new_exp]',lastseen = Now() WHERE ckey='[ckey]'") if(!update_query.Execute()) var/err = update_query.ErrorMsg() log_game("SQL ERROR during exp_update_client write. Error : \[[err]\]\n") message_admins("SQL ERROR during exp_update_client write. Error : \[[err]\]\n") - return + return \ No newline at end of file From adbe7f1b4324019616b17cc633fc9a0db4c348d6 Mon Sep 17 00:00:00 2001 From: Kyep Date: Sun, 20 Oct 2019 02:19:53 -0700 Subject: [PATCH 03/16] Hide forum link for new players --- code/modules/client/client procs.dm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 6f971d308fa..410109151ba 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -413,7 +413,7 @@ for(var/mob/M in GLOB.player_list) if(M.client) playercount += 1 - + if(playercount >= 150 && GLOB.panic_bunker_enabled == 0) GLOB.panic_bunker_enabled = 1 message_admins("Panic bunker has been automatically enabled due to playercount surpassing 150") @@ -553,7 +553,7 @@ src << "Sorry but the server is currently not accepting connections from never before seen players. Please try again later." del(src) return // Dont insert or they can just go in again - + var/DBQuery/query_insert = dbcon.NewQuery("INSERT INTO [format_table_name("player")] (id, ckey, firstseen, lastseen, ip, computerid, lastadminrank) VALUES (null, '[ckey]', Now(), Now(), '[sql_ip]', '[sql_computerid]', '[sql_admin_rank]')") if(!query_insert.Execute()) var/err = query_insert.ErrorMsg() @@ -601,8 +601,13 @@ /client/proc/check_forum_link() - if(config.forum_link_url && prefs && !prefs.fuid) - to_chat(src, "You do not have your forum account linked. LINK FORUM ACCOUNT") + if(!config.forum_link_url || !prefs || prefs.fuid) + return + if(config.use_exp_tracking) + var/living_hours = get_exp_type_num(EXP_TYPE_LIVING) / 60 + if(living_hours < 20) + return + to_chat(src, "You have no verified forum account. VERIFY FORUM ACCOUNT") /client/proc/create_oauth_token() var/DBQuery/query_find_token = dbcon.NewQuery("SELECT token FROM [format_table_name("oauth_tokens")] WHERE ckey = '[ckey]' limit 1") @@ -774,7 +779,7 @@ // Change the way they should download resources. if(config.resource_urls) preload_rsc = pick(config.resource_urls) - else + else preload_rsc = 1 // If config.resource_urls is not set, preload like normal. // Most assets are now handled through global_cache.dm getFiles( From a0081713f33fc2d20018860abb00c42fd42973ae Mon Sep 17 00:00:00 2001 From: Kyep Date: Sat, 2 Nov 2019 18:51:59 -0700 Subject: [PATCH 04/16] Adds web playerinfo link --- code/controllers/configuration.dm | 8 ++++++-- code/modules/admin/admin.dm | 2 ++ code/modules/admin/topic.dm | 7 +++++++ config/example/config.txt | 3 +++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 8ae35d52179..d24e4dc94f5 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -79,7 +79,7 @@ var/auto_cryo_ssd_mins = 0 var/ssd_warning = 0 - + var/list_afk_minimum = 5 // How long people have to be AFK before it's listed on the "List AFK players" verb var/traitor_objectives_amount = 2 @@ -144,6 +144,7 @@ var/ipintel_detailsurl = "https://iphub.info/?ip=" var/forum_link_url + var/forum_playerinfo_url var/admin_legacy_system = 0 //Defines whether the server uses the legacy admin system with admins.txt or the SQL system. Config option in config.txt var/ban_legacy_system = 0 //Defines whether the server uses the legacy banning system with the files in /data or the SQL system. Config option in config.txt @@ -244,7 +245,7 @@ //cube monkey limit var/cubemonkeycap = 20 - + // Makes gamemodes respect player limits var/enable_gamemode_player_limit = 0 @@ -354,6 +355,9 @@ if("forum_link_url") config.forum_link_url = value + if("forum_playerinfo_url") + config.forum_playerinfo_url = value + if("log_ooc") config.log_ooc = 1 diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index 6967a374b51..1801324e72d 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -100,6 +100,8 @@ var/global/nologevent = 0 body += "Jobban | " body += "Appearance Ban | " body += "Notes | " + if(config.forum_playerinfo_url) + body += "WebInfo | " if(M.client) if(M.client.check_watchlist(M.client.ckey)) body += "Remove from Watchlist | " diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index a318c316532..8db44a1ce53 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -936,6 +936,13 @@ target = text2num(target) show_note(index = target) + else if(href_list["webtools"]) + var/target_ckey = href_list["webtools"] + if(config.forum_playerinfo_url) + var/url_to_open = config.forum_playerinfo_url + target_ckey + if(alert("Open [url_to_open]",,"Yes","No")=="Yes") + usr.client << link(url_to_open) + else if(href_list["shownoteckey"]) var/target_ckey = href_list["shownoteckey"] show_note(target_ckey) diff --git a/config/example/config.txt b/config/example/config.txt index 7dfdc1e413a..27da54922bb 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -213,6 +213,9 @@ GUEST_BAN ## URL to use to link forum accounts. If not set, no link option will be offered. #FORUM_LINK_URL https://example.com/link.php?token= +## URL to use for admins accessing the web-based tools menu +#FORUM_PLAYERINFO_URL https://example.com/info.php?ckey= + ## Comment to disable checking for the cid randomizer dll. (disabled if database isn't enabled or connected) CHECK_RANDOMIZER From de7b8c52e7ee88755a0a7f17d9f865a3d41a686f Mon Sep 17 00:00:00 2001 From: Kyep Date: Sun, 3 Nov 2019 01:00:01 -0800 Subject: [PATCH 05/16] Add link for newly banned people verifying their forum accounts --- code/modules/admin/topic.dm | 4 ++++ code/modules/client/client procs.dm | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 8db44a1ce53..4abdc89677c 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -1002,6 +1002,8 @@ feedback_inc("ban_tmp",1) DB_ban_record(BANTYPE_TEMP, M, mins, reason) feedback_inc("ban_tmp_mins",mins) + if(M.client) + M.client.link_forum_account(TRUE) if(config.banappeals) to_chat(M, "To try to resolve this matter head to [config.banappeals]") else @@ -1018,6 +1020,8 @@ AddBan(M.ckey, M.computer_id, reason, usr.ckey, 0, 0, M.lastKnownIP) to_chat(M, "You have been banned by [usr.client.ckey].\nReason: [reason].") to_chat(M, "This ban does not expire automatically and must be appealed.") + if(M.client) + M.client.link_forum_account(TRUE) if(config.banappeals) to_chat(M, "To try to resolve this matter head to [config.banappeals]") else diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 410109151ba..644ac6aa123 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -622,12 +622,15 @@ return return tokenstr -/client/proc/link_forum_account() +/client/proc/link_forum_account(fromban) + if(!config.forum_link_url) + return if(IsGuestKey(key)) to_chat(src, "Guest keys cannot be linked.") return if(prefs && prefs.fuid) - to_chat(src, "Your forum account is already set.") + if(!fromban) + to_chat(src, "Your forum account is already set.") return var/DBQuery/query_find_link = dbcon.NewQuery("SELECT fuid FROM [format_table_name("player")] WHERE ckey = '[ckey]' limit 1") if(!query_find_link.Execute()) @@ -635,15 +638,19 @@ return if(query_find_link.NextRow()) if(query_find_link.item[1]) - to_chat(src, "Your forum account is already set. (" + query_find_link.item[1] + ")") + if(!fromban) + to_chat(src, "Your forum account is already set. (" + query_find_link.item[1] + ")") return var/tokenid = create_oauth_token() if(!tokenid) to_chat(src, "link_forum_account: unable to create token") return var/url = "[config.forum_link_url][tokenid]" - to_chat(src, {"Now opening a windows to verify your information with the forums. If the window does not load, please go to: [url]."}) - src << link(url) + if(fromban) + to_chat(src, {"Verify your forum account before you appeal: [url] (this link expires in a few minutes)"}) + else + to_chat(src, {"Now opening a window to verify your information with the forums. If the window does not load, please go to: [url]"}) + src << link(url) return #undef TOPIC_SPAM_DELAY From db82363bfb63ed77916af367286de8c5e09e91ed Mon Sep 17 00:00:00 2001 From: Kyep Date: Wed, 13 Nov 2019 20:41:28 -0800 Subject: [PATCH 06/16] Adds forum-based link config setting --- code/controllers/configuration.dm | 4 ++++ config/example/config.txt | 5 ++++- interface/interface.dm | 14 +++++++++----- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index d24e4dc94f5..86883654997 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -102,6 +102,7 @@ var/donationsurl = "http://example.org" var/repositoryurl = "http://example.org" var/discordurl = "http://example.org" + var/discordforumurl = "http://example.org" var/overflow_server_url var/forbid_singulo_possession = 0 @@ -487,6 +488,9 @@ if("discordurl") config.discordurl = value + if("discordforumurl") + config.discordforumurl = value + if("donationsurl") config.donationsurl = value diff --git a/config/example/config.txt b/config/example/config.txt index 27da54922bb..f4de07f581f 100644 --- a/config/example/config.txt +++ b/config/example/config.txt @@ -240,6 +240,9 @@ CHECK_RANDOMIZER ## Discord address # DISCORDURL http://example.org +## Discord address (forum-based invite) +# DISCORDFORUMURL http://example.org + ## Donations address # DONATIONSURL http://example.org @@ -454,4 +457,4 @@ DISABLE_HIGH_POP_MC_MODE_AMOUNT 60 #START_NOW_CONFIRMATION ## If uncommented, all gamemodes will respect the number of required players. Defaults to no. -#ENABLE_GAMEMODE_PLAYER_LIMIT \ No newline at end of file +#ENABLE_GAMEMODE_PLAYER_LIMIT diff --git a/interface/interface.dm b/interface/interface.dm index a733b8fed78..a97500ccb4f 100644 --- a/interface/interface.dm +++ b/interface/interface.dm @@ -81,12 +81,16 @@ set name = "Discord" set desc = "Join our Discord server." set hidden = 1 - if(config.discordurl) - if(alert("This will invite you to our Discord server. Are you sure?",,"Yes","No")=="No") - return - src << link(config.discordurl) - else + + var/durl = config.discordurl + if(config.forum_link_url && prefs && prefs.fuid && config.discordforumurl) + durl = config.discordforumurl + if(!durl) to_chat(src, "The Discord URL is not set in the server configuration.") + return + if(alert("This will invite you to our Discord server. Are you sure?",,"Yes","No")=="No") + return + src << link(durl) /client/verb/donate() set name = "Donate" From 7acb902388d3afc85cd362380f8be4f08f5405e0 Mon Sep 17 00:00:00 2001 From: Kyep Date: Sun, 15 Dec 2019 16:28:36 -0800 Subject: [PATCH 07/16] SQL update: track playtime per player per day for stats --- SQL/paradise_schema.sql | 15 +++++++++++++++ SQL/paradise_schema_prefixed.sql | 14 ++++++++++++++ SQL/updates/9-10.sql | 11 +++++++++++ code/__DEFINES/misc.dm | 2 +- code/game/jobs/job_exp.dm | 14 ++++++++++++-- config/example/dbconfig.txt | 2 +- 6 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 SQL/updates/9-10.sql diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index 1e4692b7e3b..445de8b4d08 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -565,3 +565,18 @@ CREATE TABLE `oauth_tokens` ( PRIMARY KEY (`token`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; + + +-- +-- Table structure for table `playtime_history` +-- +DROP TABLE IF EXISTS `playtime_history`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `playtime_history` ( + `ckey` varchar(32) NOT NULL, + `date` DATE NOT NULL, + `time_living` SMALLINT NOT NULL, + `time_ghost` SMALLINT NOT NULL, + PRIMARY KEY (`ckey`, `date`) +) 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 aa5d5895e56..f70593fc1ac 100644 --- a/SQL/paradise_schema_prefixed.sql +++ b/SQL/paradise_schema_prefixed.sql @@ -564,3 +564,17 @@ CREATE TABLE `SS13_oauth_tokens` ( PRIMARY KEY (`token`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `SS13_playtime_history` +-- +DROP TABLE IF EXISTS `SS13_playtime_history`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `SS13_playtime_history` ( + `ckey` varchar(32) NOT NULL, + `date` DATE NOT NULL, + `time_living` SMALLINT NOT NULL, + `time_ghost` SMALLINT NOT NULL, + PRIMARY KEY (`ckey`, `date`) +) 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 new file mode 100644 index 00000000000..f82e7c56830 --- /dev/null +++ b/SQL/updates/9-10.sql @@ -0,0 +1,11 @@ +# Updating SQL from ver 9 to 10 - Kyet + +# Add the 'playtime_history' table that tracks playtime per player per day +CREATE TABLE `playtime_history` ( + `ckey` varchar(32) NOT NULL, + `date` DATE NOT NULL, + `time_living` SMALLINT NOT NULL, + `time_ghost` SMALLINT NOT NULL, + PRIMARY KEY (`ckey`, `date`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index 7dd5fc5a609..5a2c087e1fd 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -319,7 +319,7 @@ #define INVESTIGATE_BOMB "bombs" // The SQL version required by this version of the code -#define SQL_VERSION 9 +#define SQL_VERSION 10 // Vending machine stuff #define CAT_NORMAL 1 diff --git a/code/game/jobs/job_exp.dm b/code/game/jobs/job_exp.dm index 1b64b3e8aee..b69dbfd3ed4 100644 --- a/code/game/jobs/job_exp.dm +++ b/code/game/jobs/job_exp.dm @@ -263,8 +263,11 @@ var/global/list/role_playtime_requirements = list( myrole = mob.mind.playtime_role else if(mob.mind.assigned_role) myrole = mob.mind.assigned_role + var/added_living = 0 + var/added_ghost = 0 if(mob.stat == CONSCIOUS && myrole) play_records[EXP_TYPE_LIVING] += minutes + added_living += minutes if(announce_changes) to_chat(mob,"You got: [minutes] Living EXP!") for(var/category in exp_jobsmap) @@ -279,6 +282,7 @@ var/global/list/role_playtime_requirements = list( to_chat(mob,"You got: [minutes] Special EXP!") else if(isobserver(mob)) play_records[EXP_TYPE_GHOST] += minutes + added_ghost += minutes if(announce_changes) to_chat(mob,"You got: [minutes] Ghost EXP!") else @@ -289,6 +293,12 @@ var/global/list/role_playtime_requirements = list( var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("player")] SET exp = '[new_exp]',lastseen = Now() WHERE ckey='[ckey]'") if(!update_query.Execute()) var/err = update_query.ErrorMsg() - log_game("SQL ERROR during exp_update_client write. Error : \[[err]\]\n") - message_admins("SQL ERROR during exp_update_client write. Error : \[[err]\]\n") + log_game("SQL ERROR during exp_update_client write 1. Error : \[[err]\]\n") + message_admins("SQL ERROR during exp_update_client write 1. Error : \[[err]\]\n") + return + var/DBQuery/update_query_history = dbcon.NewQuery("INSERT INTO [format_table_name("playtime_history")] (ckey, date, time_living, time_ghost) VALUES ('[ckey]',CURDATE(),[added_living],[added_ghost]) ON DUPLICATE KEY UPDATE time_living=time_living+VALUES(time_living),time_ghost=time_ghost+VALUES(time_ghost)") + if(!update_query_history.Execute()) + var/err = update_query_history.ErrorMsg() + log_game("SQL ERROR during exp_update_client write 2. Error : \[[err]\]\n") + message_admins("SQL ERROR during exp_update_client write 2. Error : \[[err]\]\n") return \ No newline at end of file diff --git a/config/example/dbconfig.txt b/config/example/dbconfig.txt index ad859d92543..654a7e348d5 100644 --- a/config/example/dbconfig.txt +++ b/config/example/dbconfig.txt @@ -9,7 +9,7 @@ ## This value must be set to the version of the paradise schema in use. ## If this value does not match, the SQL database will not be loaded and an error will be generated. ## Roundstart will be delayed. -DB_VERSION 9 +DB_VERSION 10 ## Server the MySQL database can be found at. # Examples: localhost, 200.135.5.43, www.mysqldb.com, etc. From 9783ac1598554f0f6d74731038d5ef8376c1fad4 Mon Sep 17 00:00:00 2001 From: Kyep Date: Sun, 15 Dec 2019 18:04:06 -0800 Subject: [PATCH 08/16] add mentor to list of predefined admin ranks --- code/modules/admin/topic.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 4abdc89677c..dfba257b66c 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -212,7 +212,7 @@ if(admin_ranks.len) new_rank = input("Please select a rank", "New rank", null, null) as null|anything in (admin_ranks|"*New Rank*") else - new_rank = input("Please select a rank", "New rank", null, null) as null|anything in list("Game Master","Game Admin", "Trial Admin", "Admin Observer","*New Rank*") + new_rank = input("Please select a rank", "New rank", null, null) as null|anything in list("Mentor", "Trial Admin", "Game Admin", "*New Rank*") var/rights = 0 if(D) From 76f4c88fea6d9d9d171771a27e0848b0a587ea82 Mon Sep 17 00:00:00 2001 From: Kyep Date: Sun, 15 Dec 2019 18:30:31 -0800 Subject: [PATCH 09/16] fixes admin_log not working, flags edited admins/mentors for sync --- code/modules/admin/permissionverbs/permissionedit.dm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/code/modules/admin/permissionverbs/permissionedit.dm b/code/modules/admin/permissionverbs/permissionedit.dm index 9d9e60db014..57d58533437 100644 --- a/code/modules/admin/permissionverbs/permissionedit.dm +++ b/code/modules/admin/permissionverbs/permissionedit.dm @@ -86,17 +86,18 @@ new_admin = 0 admin_id = text2num(select_query.item[1]) + flag_account_for_forum_sync(adm_ckey) if(new_admin) 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`.[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]');") + var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO [format_table_name("admin_log")] (`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (Now() , '[usr.ckey]', '[usr.client.address]', 'Added new admin [adm_ckey] to rank [new_rank]');") log_query.Execute() to_chat(usr, "New admin added.") else if(!isnull(admin_id) && isnum(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`.[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]');") + var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO [format_table_name("admin_log")] (`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (Now() , '[usr.ckey]', '[usr.client.address]', 'Edited the rank of [adm_ckey] to [new_rank]');") log_query.Execute() to_chat(usr, "Admin rank changed.") @@ -141,16 +142,17 @@ if(!admin_id) return + flag_account_for_forum_sync(adm_ckey) if(admin_rights & new_permission) //This admin already has this permission, so we are removing it. var/DBQuery/insert_query = dbcon.NewQuery("UPDATE [format_table_name("admin")] SET flags = [admin_rights & ~new_permission] WHERE id = [admin_id]") insert_query.Execute() - var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO `test`.[format_table_name("admin_log")] (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Removed permission [rights2text(new_permission)] (flag = [new_permission]) to admin [adm_ckey]');") + var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO [format_table_name("admin_log")] (`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (Now() , '[usr.ckey]', '[usr.client.address]', 'Removed permission [rights2text(new_permission)] (flag = [new_permission]) to admin [adm_ckey]');") log_query.Execute() to_chat(usr, "Permission removed.") else //This admin doesn't have this permission, so we are adding it. var/DBQuery/insert_query = dbcon.NewQuery("UPDATE [format_table_name("admin")] SET flags = '[admin_rights | new_permission]' WHERE id = [admin_id]") insert_query.Execute() - var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO `test`.[format_table_name("admin_log")] (`id` ,`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (NULL , NOW( ) , '[usr.ckey]', '[usr.client.address]', 'Added permission [rights2text(new_permission)] (flag = [new_permission]) to admin [adm_ckey]')") + var/DBQuery/log_query = dbcon.NewQuery("INSERT INTO [format_table_name("admin_log")] (`datetime` ,`adminckey` ,`adminip` ,`log` ) VALUES (Now() , '[usr.ckey]', '[usr.client.address]', 'Added permission [rights2text(new_permission)] (flag = [new_permission]) to admin [adm_ckey]')") log_query.Execute() to_chat(usr, "Permission added.") @@ -165,3 +167,4 @@ var/DBQuery/query_update = dbcon.NewQuery("UPDATE [format_table_name("player")] SET lastadminrank = '[sql_admin_rank]' WHERE ckey = '[sql_ckey]'") query_update.Execute() + flag_account_for_forum_sync(sql_ckey) \ No newline at end of file From fe53a5acf9a2dcd3a62043229fd08251359b7cf7 Mon Sep 17 00:00:00 2001 From: Kyep Date: Sun, 15 Dec 2019 19:19:50 -0800 Subject: [PATCH 10/16] fixes broken watchlist functionality --- code/modules/admin/admin.dm | 2 +- code/modules/admin/watchlist.dm | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index 1801324e72d..55fb1c4047a 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -103,7 +103,7 @@ var/global/nologevent = 0 if(config.forum_playerinfo_url) body += "WebInfo | " if(M.client) - if(M.client.check_watchlist(M.client.ckey)) + if(check_watchlist(M.client.ckey)) body += "Remove from Watchlist | " body += "Edit Watchlist Reason " else diff --git a/code/modules/admin/watchlist.dm b/code/modules/admin/watchlist.dm index 040bc08112b..a908c2c264b 100644 --- a/code/modules/admin/watchlist.dm +++ b/code/modules/admin/watchlist.dm @@ -113,9 +113,7 @@ output += "
[reason]
" usr << browse(output, "window=watchwin;size=900x500") -/client/proc/check_watchlist(target_ckey) - if(!check_rights(R_ADMIN,0)) - return +/proc/check_watchlist(target_ckey) var/target_sql_ckey = sanitizeSQL(target_ckey) var/DBQuery/query_watch = dbcon.NewQuery("SELECT reason FROM [format_table_name("watch")] WHERE ckey = '[target_sql_ckey]'") if(!query_watch.Execute()) From a4e6dba7384fe08168684d757cfd0e67961b4aac Mon Sep 17 00:00:00 2001 From: Kyep Date: Mon, 16 Dec 2019 15:55:04 -0800 Subject: [PATCH 11/16] 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() From 91a63e97a795acad217c3bc5019d873502f9cad6 Mon Sep 17 00:00:00 2001 From: Kyep Date: Mon, 16 Dec 2019 17:20:07 -0800 Subject: [PATCH 12/16] Add: notes are now recorded with player's playtime, for comparison --- SQL/paradise_schema.sql | 1 + SQL/paradise_schema_prefixed.sql | 1 + SQL/updates/9-10.sql | 3 ++ code/modules/admin/sql_notes.dm | 50 ++++++++++++++++++++------------ 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index bfab9ba76ce..01f83ba0194 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -505,6 +505,7 @@ CREATE TABLE `notes` ( `last_editor` varchar(32), `edits` text, `server` varchar(50) NOT NULL, + `crew_playtime` mediumint(8) UNSIGNED DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/SQL/paradise_schema_prefixed.sql b/SQL/paradise_schema_prefixed.sql index a83c93b7c38..9801c54d6f9 100644 --- a/SQL/paradise_schema_prefixed.sql +++ b/SQL/paradise_schema_prefixed.sql @@ -504,6 +504,7 @@ CREATE TABLE `SS13_notes` ( `last_editor` varchar(32), `edits` text, `server` varchar(50) NOT NULL, + `crew_playtime` mediumint(8) UNSIGNED DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/SQL/updates/9-10.sql b/SQL/updates/9-10.sql index aded1301b82..942aca1b541 100644 --- a/SQL/updates/9-10.sql +++ b/SQL/updates/9-10.sql @@ -19,3 +19,6 @@ CREATE TABLE `connection_log` ( `computerid` varchar(32) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +# Add the 'crew_playtime' field to the 'notes' table, which gives admins some idea of how many hours have passed for a player since they got a note +ALTER TABLE `notes` ADD `crew_playtime` mediumint(8) UNSIGNED DEFAULT '0' AFTER `server`; diff --git a/code/modules/admin/sql_notes.dm b/code/modules/admin/sql_notes.dm index 18112f584c2..a6ac31a4114 100644 --- a/code/modules/admin/sql_notes.dm +++ b/code/modules/admin/sql_notes.dm @@ -4,22 +4,30 @@ if(!dbcon.IsConnected()) to_chat(usr, "Failed to establish database connection.") return + if(!target_ckey) var/new_ckey = ckey(clean_input("Who would you like to add a note for?","Enter a ckey",null)) if(!new_ckey) return - new_ckey = ckey(new_ckey) - var/DBQuery/query_find_ckey = dbcon.NewQuery("SELECT ckey FROM [format_table_name("player")] WHERE ckey = '[new_ckey]'") - if(!query_find_ckey.Execute()) - var/err = query_find_ckey.ErrorMsg() - log_game("SQL ERROR obtaining ckey from player table. Error : \[[err]\]\n") - return - if(!query_find_ckey.NextRow()) - to_chat(usr, "[new_ckey] has not been seen before, you can only add notes to known players.") - return - else - target_ckey = new_ckey - var/target_sql_ckey = ckey(target_ckey) + target_ckey = ckey(new_ckey) + else + target_ckey = ckey(target_ckey) + + var/DBQuery/query_find_ckey = dbcon.NewQuery("SELECT ckey, exp FROM [format_table_name("player")] WHERE ckey = '[target_ckey]'") + if(!query_find_ckey.Execute()) + var/err = query_find_ckey.ErrorMsg() + log_game("SQL ERROR obtaining ckey from player table. Error : \[[err]\]\n") + return + if(!query_find_ckey.NextRow()) + to_chat(usr, "[target_ckey] has not been seen before, you can only add notes to known players.") + return + + var/exp_data = query_find_ckey.item[2] + var/crew_number = 0 + if(exp_data) + var/list/play_records = params2list(exp_data) + crew_number = play_records[EXP_TYPE_CREW] + if(!notetext) notetext = input(usr,"Write your note","Add Note") as message|null if(!notetext) @@ -38,7 +46,7 @@ if(config && config.server_name) server = config.server_name server = sanitizeSQL(server) - var/DBQuery/query_noteadd = dbcon.NewQuery("INSERT INTO [format_table_name("notes")] (ckey, timestamp, notetext, adminckey, server) VALUES ('[target_sql_ckey]', '[timestamp]', '[notetext]', '[admin_sql_ckey]', '[server]')") + var/DBQuery/query_noteadd = dbcon.NewQuery("INSERT INTO [format_table_name("notes")] (ckey, timestamp, notetext, adminckey, server, crew_playtime) VALUES ('[target_ckey]', '[timestamp]', '[notetext]', '[admin_sql_ckey]', '[server]', '[crew_number]')") if(!query_noteadd.Execute()) var/err = query_noteadd.ErrorMsg() log_game("SQL ERROR adding new note to table. Error : \[[err]\]\n") @@ -131,10 +139,10 @@ output = navbar if(target_ckey) var/target_sql_ckey = ckey(target_ckey) - var/DBQuery/query_get_notes = dbcon.NewQuery("SELECT id, timestamp, notetext, adminckey, last_editor, server FROM [format_table_name("notes")] WHERE ckey = '[target_sql_ckey]' ORDER BY timestamp") + var/DBQuery/query_get_notes = dbcon.NewQuery("SELECT id, timestamp, notetext, adminckey, last_editor, server, crew_playtime FROM [format_table_name("notes")] WHERE ckey = '[target_sql_ckey]' ORDER BY timestamp") if(!query_get_notes.Execute()) var/err = query_get_notes.ErrorMsg() - log_game("SQL ERROR obtaining ckey, notetext, adminckey, last_editor, server from notes table. Error : \[[err]\]\n") + log_game("SQL ERROR obtaining ckey, notetext, adminckey, last_editor, server, crew_playtime from notes table. Error : \[[err]\]\n") return output += "

Notes of [target_ckey]

" if(!linkless) @@ -147,7 +155,13 @@ var/adminckey = query_get_notes.item[4] var/last_editor = query_get_notes.item[5] var/server = query_get_notes.item[6] - output += "[timestamp] | [server] | [adminckey]" + var/mins = text2num(query_get_notes.item[7]) + output += "[timestamp] | [server] | [adminckey]" + if(mins) + var/playstring = get_exp_format(mins) + output += " | [playstring] as Crew" + output += "" + if(!linkless) output += " \[Remove Note\] \[Edit Note\]" if(last_editor) @@ -182,10 +196,10 @@ /proc/show_player_info_irc(var/key as text) var/target_sql_ckey = ckey(key) - var/DBQuery/query_get_notes = dbcon.NewQuery("SELECT timestamp, notetext, adminckey, server FROM [format_table_name("notes")] WHERE ckey = '[target_sql_ckey]' ORDER BY timestamp") + var/DBQuery/query_get_notes = dbcon.NewQuery("SELECT timestamp, notetext, adminckey, server, crew_playtime FROM [format_table_name("notes")] WHERE ckey = '[target_sql_ckey]' ORDER BY timestamp") if(!query_get_notes.Execute()) var/err = query_get_notes.ErrorMsg() - log_game("SQL ERROR obtaining timestamp, notetext, adminckey, server from notes table. Error : \[[err]\]\n") + log_game("SQL ERROR obtaining timestamp, notetext, adminckey, server, crew_playtime from notes table. Error : \[[err]\]\n") return var/output = " Info on [key]%0D%0A" while(query_get_notes.NextRow()) From 57412d810f053b344aaa6373d5ad65fd2002b584 Mon Sep 17 00:00:00 2001 From: Kyep Date: Sun, 22 Dec 2019 18:17:15 -0800 Subject: [PATCH 13/16] Text clarification --- code/modules/client/client procs.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 082ce969695..51ca4065801 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -646,7 +646,7 @@ return var/url = "[config.forum_link_url][tokenid]" if(fromban) - to_chat(src, {"Verify your forum account before you appeal: [url] (this link expires in a few minutes)"}) + to_chat(src, {"Copy/paste this URL into your browser to activate your forum account before you appeal: [url] (this link expires soon)"}) else to_chat(src, {"Now opening a window to verify your information with the forums. If the window does not load, please go to: [url]"}) src << link(url) From ad44e867befe6df1603eaff0a8c0050f192ae3e6 Mon Sep 17 00:00:00 2001 From: Kyep Date: Sat, 4 Jan 2020 16:05:42 -0800 Subject: [PATCH 14/16] forum button linking --- interface/interface.dm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/interface/interface.dm b/interface/interface.dm index a97500ccb4f..f616e41f713 100644 --- a/interface/interface.dm +++ b/interface/interface.dm @@ -48,8 +48,7 @@ set hidden = 1 if(config.forumurl) if(config.forum_link_url && prefs && !prefs.fuid) - if(alert("You need to activate your forum account. Activate now? (takes 2 seconds)",,"Yes","No")=="Yes") - link_forum_account() + link_forum_account() if(alert("Open the forum in your browser?",,"Yes","No")=="Yes") src << link(config.forumurl) else From 57d79c6eef1028bb83dcb6ede3fb953d33904a57 Mon Sep 17 00:00:00 2001 From: Kyep Date: Mon, 6 Jan 2020 15:32:55 -0800 Subject: [PATCH 15/16] cleanup --- interface/interface.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/interface.dm b/interface/interface.dm index f616e41f713..4a140769f18 100644 --- a/interface/interface.dm +++ b/interface/interface.dm @@ -47,9 +47,9 @@ set desc = "Visit the forum." set hidden = 1 if(config.forumurl) - if(config.forum_link_url && prefs && !prefs.fuid) - link_forum_account() if(alert("Open the forum in your browser?",,"Yes","No")=="Yes") + if(config.forum_link_url && prefs && !prefs.fuid) + link_forum_account() src << link(config.forumurl) else to_chat(src, "The forum URL is not set in the server configuration.") From 9dc3a18506a775702928d27c9716da0ba3fde774 Mon Sep 17 00:00:00 2001 From: Kyep Date: Thu, 9 Jan 2020 03:56:17 -0800 Subject: [PATCH 16/16] tweaks link message for banned players --- code/modules/client/client procs.dm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 5248ba22178..962be47cae9 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -646,10 +646,11 @@ return var/url = "[config.forum_link_url][tokenid]" if(fromban) - to_chat(src, {"Copy/paste this URL into your browser to activate your forum account before you appeal: [url] (this link expires soon)"}) + url += "&fwd=appeal" + to_chat(src, {"Now opening a window to verify your information with the forums, so that you can appeal your ban. If the window does not load, please copy/paste this link: [url]"}) else to_chat(src, {"Now opening a window to verify your information with the forums. If the window does not load, please go to: [url]"}) - src << link(url) + src << link(url) return #undef TOPIC_SPAM_DELAY