From 9832f8d056e26dd1121eef1560607bfb510ddec2 Mon Sep 17 00:00:00 2001 From: Alffd Date: Sun, 21 Jan 2018 00:36:50 -0500 Subject: [PATCH 1/3] Add World/Topic() call for rotating log files --- code/world.dm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/code/world.dm b/code/world.dm index 9d41a06c0fb..f229d71b6e9 100644 --- a/code/world.dm +++ b/code/world.dm @@ -23,14 +23,9 @@ var/global/datum/global_init/init = new () var/global/list/map_transition_config = MAP_TRANSITION_CONFIG /world/New() - //logs - var/date_string = time2text(world.realtime, "YYYY/MM-Month/DD-Day") - href_logfile = file("data/logs/[date_string] hrefs.htm") - diary = file("data/logs/[date_string].log") - diaryofmeanpeople = file("data/logs/[date_string] Attack.log") + setLog() diary << "\n\nStarting up. [time2text(world.timeofday, "hh:mm.ss")]\n---------------------" diaryofmeanpeople << "\n\nStarting up. [time2text(world.timeofday, "hh:mm.ss")]\n---------------------" - if(byond_version < RECOMMENDED_VERSION) log_to_dd("Your server's byond version does not meet the recommended requirements for this code. Please update BYOND") @@ -264,6 +259,14 @@ var/world_topic_spam_protect_time = world.timeofday return "Kick Successful" + else if("setlog" in input) + if(!key_valid) + return keySpamProtect(addr) + + setLog() + + return "Logs set to current date" + /proc/keySpamProtect(var/addr) if(world_topic_spam_protect_ip == addr && abs(world_topic_spam_protect_time - world.time) < 50) spawn(50) @@ -453,6 +456,12 @@ var/world_topic_spam_protect_time = world.timeofday var/failed_db_connections = 0 var/failed_old_db_connections = 0 +/world/proc/setLog() + var/date_string = time2text(world.realtime, "YYYY/MM-Month/DD-Day") + href_logfile = file("data/logs/[date_string] hrefs.htm") + diary = file("data/logs/[date_string].log") + diaryofmeanpeople = file("data/logs/[date_string] Attack.log") + /hook/startup/proc/connectDB() if(!setup_database_connection()) log_to_dd("Your server failed to establish a connection with the feedback database.") @@ -495,3 +504,4 @@ proc/establish_db_connection() return 1 #undef FAILED_DB_CONNECTION_CUTOFF + From abe0d96839b1afb8b9bd80ca8410c3d191e9ae59 Mon Sep 17 00:00:00 2001 From: Alffd Date: Sun, 21 Jan 2018 00:46:13 -0500 Subject: [PATCH 2/3] Moves log setup to before world --- code/world.dm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/code/world.dm b/code/world.dm index f229d71b6e9..0f129b5e842 100644 --- a/code/world.dm +++ b/code/world.dm @@ -7,7 +7,7 @@ var/global/datum/global_init/init = new () makeDatumRefLists() load_configuration() - + setLog() del(src) /world @@ -23,7 +23,6 @@ var/global/datum/global_init/init = new () var/global/list/map_transition_config = MAP_TRANSITION_CONFIG /world/New() - setLog() diary << "\n\nStarting up. [time2text(world.timeofday, "hh:mm.ss")]\n---------------------" diaryofmeanpeople << "\n\nStarting up. [time2text(world.timeofday, "hh:mm.ss")]\n---------------------" if(byond_version < RECOMMENDED_VERSION) @@ -456,7 +455,7 @@ var/world_topic_spam_protect_time = world.timeofday var/failed_db_connections = 0 var/failed_old_db_connections = 0 -/world/proc/setLog() +proc/setLog() var/date_string = time2text(world.realtime, "YYYY/MM-Month/DD-Day") href_logfile = file("data/logs/[date_string] hrefs.htm") diary = file("data/logs/[date_string].log") From 336e5248187196dbb6b7375ba3eafda566dd7e7e Mon Sep 17 00:00:00 2001 From: Alffd Date: Tue, 23 Jan 2018 02:26:29 -0500 Subject: [PATCH 3/3] Fix missing / --- code/world.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/world.dm b/code/world.dm index 0f129b5e842..542e19ef619 100644 --- a/code/world.dm +++ b/code/world.dm @@ -455,7 +455,7 @@ var/world_topic_spam_protect_time = world.timeofday var/failed_db_connections = 0 var/failed_old_db_connections = 0 -proc/setLog() +/proc/setLog() var/date_string = time2text(world.realtime, "YYYY/MM-Month/DD-Day") href_logfile = file("data/logs/[date_string] hrefs.htm") diary = file("data/logs/[date_string].log") @@ -468,7 +468,7 @@ proc/setLog() log_to_dd("Feedback database connection established.") return 1 -proc/setup_database_connection() +/proc/setup_database_connection() if(failed_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