diff --git a/code/__HELPERS/files.dm b/code/__HELPERS/files.dm index 9d9a3140d26..d804dcb06a9 100644 --- a/code/__HELPERS/files.dm +++ b/code/__HELPERS/files.dm @@ -15,4 +15,46 @@ //Sends resource files to client cache /client/proc/getFiles() for(var/file in args) - src << browse_rsc(file) \ No newline at end of file + src << browse_rsc(file) + +/client/proc/browse_files(root="data/logs/", max_iterations=10, list/valid_extensions=list(".txt",".log",".htm")) + var/path = root + + for(var/i=0, iError: browse_files(): File not found/Invalid file([path])." + return + + return path + +#define FTPDELAY 200 //200 tick delay to discourage spam +/* This proc is a failsafe to prevent spamming of file requests. + It is just a timer that only permits a download every [FTPDELAY] ticks. + This can be changed by modifying FTPDELAY's value above. + + PLEASE USE RESPONSIBLY, Some log files canr each sizes of 4MB! */ +/client/proc/file_spam_check() + var/time_to_wait = fileaccess_timer - world.time + if(time_to_wait > 0) + src << "Error: file_spam_check(): Spam. Please wait [round(time_to_wait/10)] seconds." + return 1 + fileaccess_timer = world.time + FTPDELAY + return 0 +#undef FTPDELAY \ No newline at end of file diff --git a/code/global.dm b/code/global.dm index ec3e9a21f54..cd9570b5d87 100644 --- a/code/global.dm +++ b/code/global.dm @@ -204,7 +204,7 @@ 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 = 1800 //Cannot access files by ftp until the game is finished setting up and stuff. +var/fileaccess_timer = 0 //Database connections //A connection is established on world creation. Ideally, the connection dies when the server restarts (After feedback logging.). diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 0cfccd5cd89..cea84b5f1b8 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -40,6 +40,7 @@ var/list/admin_verbs_admin = list( /client/proc/cmd_admin_check_contents, /*displays the contents of an instance*/ /datum/admins/proc/access_news_network, /*allows access of newscasters*/ /client/proc/giveruntimelog, /*allows us to give access to runtime logs to somebody*/ + /client/proc/getruntimelog, /*allows us to access runtime logs to somebody*/ /client/proc/getserverlog, /*allows us to fetch server logs (diary) for other days*/ /client/proc/jumptocoord, /*we ghost and jump to a coordinate*/ /client/proc/Getmob, /*teleports a mob to our location*/ @@ -153,8 +154,6 @@ var/list/admin_verbs_hideable = list( /client/proc/cmd_admin_subtle_message, /client/proc/cmd_admin_check_contents, /datum/admins/proc/access_news_network, - /client/proc/giveruntimelog, - /client/proc/getserverlog, /client/proc/admin_call_shuttle, /client/proc/admin_cancel_shuttle, /client/proc/cmd_admin_direct_narrate, diff --git a/code/modules/admin/verbs/getlogs.dm b/code/modules/admin/verbs/getlogs.dm index e64df78c539..e71244b9c25 100644 --- a/code/modules/admin/verbs/getlogs.dm +++ b/code/modules/admin/verbs/getlogs.dm @@ -13,14 +13,6 @@ codebase for the entire /TG/station commuity a TONNE easier :3 Thanks for your help! */ -#define FTPDELAY 600 //600 tick delay to discourage spam -/* - These procs have failsafes built in to prevent spamming of file requests. As such it can only be used once every - [FTPDELAY] ticks. This can be changed by modifying FTPDELAY's value above. - - PLEASE USE RESPONSIBLY, only download from the server if the log isn't already available elsewhere! - Bandwidth is expensive and lags are lame. Some log files canr each sizes of 4MB! -*/ //This proc allows Game Masters to grant a client access to the .getruntimelog verb //Permissions expire at the end of each round. @@ -31,12 +23,12 @@ set desc = "Give somebody access to any session logfiles saved to the /log/runtime/ folder." set category = null - if( !src.holder ) - src << "Only Game Masters may use this command." + if(!src.holder) + src << "Only Admins may use this command." return var/client/target = input(src,"Choose somebody to grant access to the server's runtime logs (permissions expire at the end of each round):","Grant Permissions",null) as null|anything in clients - if( !target || !istype(target,/client) ) + if(!istype(target,/client)) src << "Error: giveruntimelog(): Client not found." return @@ -44,6 +36,7 @@ target << "You have been granted access to runtime logs. Please use them responsibly or risk being banned." return + //This proc allows download of runtime logs saved within the data/logs/ folder by dreamdeamon. //It works similarly to show-server-log. /client/proc/getruntimelog() @@ -51,57 +44,36 @@ set desc = "Retrieve any session logfiles saved by dreamdeamon." set category = null - var/time_to_wait = fileaccess_timer - world.time - if(time_to_wait > 0) - src << "Error: getruntimelog(): spam prevention. Please wait [round(time_to_wait/10)] seconds." - return - fileaccess_timer = world.time + FTPDELAY - - var/path = "data/logs/runtime/" - - var/list/path_list = flist(path) - var/choice = input(src,"Choose a runtime-log to download:","Download",null) as null|anything in path_list - if(!choice) return - - path += "[choice]" - if(!fexists(path)) - src << "Error: getruntimelog(): Files not found/Invalid file([path])." + var/path = browse_files("data/logs/runtime/") + if(!path) return - message_admins("[src] accessed runtime log: [path]") + if(file_spam_check()) + return + + message_admins("[key_name_admin(src)] accessed file: [path]") src << run( file(path) ) + src << "Attempting to send file, this may take a fair few minutes if the file is very large." return + //This proc allows download of past server logs saved within the data/logs/ folder. //It works similarly to show-server-log. /client/proc/getserverlog() set name = ".getserverlog" - set desc = "Like 'Show Server Log' but it fetches old logs if there are any." + set desc = "Fetch logfiles from data/logs" set category = null - var/time_to_wait = fileaccess_timer - world.time - if(time_to_wait > 0) - src << "Error: getserverlog(): spam prevention. Please wait [round(time_to_wait/10)] seconds." + var/path = browse_files("data/logs/") + if(!path) return - fileaccess_timer = world.time + FTPDELAY - var/path = "data/logs/" - for(var/i=0, i<4, i++) //only bother searching up to 4 sub-directories. If we don't find it by then: give up. - var/list/path_list = flist(path) - if(path_list.len) path_list -= "runtime/" - else break + if(file_spam_check()) + return - var/choice = input(src,"Choose a directory to access:","Download",null) as null|anything in path_list - if(!choice) return - - path += "[choice]" - - if( text2ascii(choice,length(choice)) != 47 ) //not a directory, finish up - if(!fexists(path)) - src << "Error: getserverlog(): File not found/Invalid file([path])." - return - src << run( file(path) ) - return + message_admins("[key_name_admin(src)] accessed file: [path]") + src << run( file(path) ) + src << "Attempting to send file, this may take a fair few minutes if the file is very large." return diff --git a/code/world.dm b/code/world.dm index ca0a4f2fb02..42d120f58c1 100644 --- a/code/world.dm +++ b/code/world.dm @@ -7,22 +7,23 @@ -#define RECOMMENDED_VERSION 494 +#define RECOMMENDED_VERSION 495 /world/New() - ..() + //logs + var/date_string = time2text(world.realtime, "YYYY/MM-Month/DD-Day") + log = file("data/logs/runtime/[time2text(world.realtime,"YYYY-MM")].log") //funtimelog + href_logfile = file("data/logs/[date_string] hrefs.htm") + diary = file("data/logs/[date_string].log") + diaryofmeanpeople = file("data/logs/[date_string] Attack.log") + diary << "\n\nStarting up. [time2text(world.timeofday, "hh:mm.ss")]\n---------------------" + diaryofmeanpeople << "\n\nStarting up. [time2text(world.timeofday, "hh:mm.ss")]\n---------------------" + changelog_hash = md5('html/changelog.html') //used for telling if the changelog has changed recently if(byond_version < RECOMMENDED_VERSION) world.log << "Your server's byond version does not meet the recommended requirements for TGstation code. Please update BYOND" - changelog_hash = md5('html/changelog.html') make_datum_references_lists() //initialises global lists for referencing frequently used datums (so that we only ever do it once) - href_logfile = file("data/logs/[time2text(world.realtime, "YYYY/MM-Month/DD-Day")] hrefs.html") - diary = file("data/logs/[time2text(world.realtime, "YYYY/MM-Month/DD-Day")].log") - diary << "\n\nStarting up. [time2text(world.timeofday, "hh:mm.ss")]\n---------------------" - diaryofmeanpeople = file("data/logs/[time2text(world.realtime, "YYYY/MM-Month/DD-Day")] Attack.log") - diaryofmeanpeople << "\n\nStarting up. [time2text(world.timeofday, "hh:mm.ss")]\n---------------------" - load_configuration() load_mode() load_motd() diff --git a/tgstation.dme b/tgstation.dme index 6e322c87453..8739497e56c 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -6,234 +6,10 @@ // BEGIN_FILE_DIR #define FILE_DIR . -#define FILE_DIR "code" -#define FILE_DIR "code/__HELPERS" -#define FILE_DIR "code/ATMOSPHERICS" -#define FILE_DIR "code/ATMOSPHERICS/components" -#define FILE_DIR "code/ATMOSPHERICS/components/binary_devices" -#define FILE_DIR "code/ATMOSPHERICS/components/trinary_devices" -#define FILE_DIR "code/ATMOSPHERICS/components/unary" -#define FILE_DIR "code/controllers" -#define FILE_DIR "code/datums" -#define FILE_DIR "code/datums/diseases" -#define FILE_DIR "code/datums/diseases/advance" -#define FILE_DIR "code/datums/diseases/advance/symptoms" -#define FILE_DIR "code/datums/helper_datums" -#define FILE_DIR "code/datums/organs" -#define FILE_DIR "code/datums/spells" -#define FILE_DIR "code/defines" -#define FILE_DIR "code/defines/obj" -#define FILE_DIR "code/defines/procs" -#define FILE_DIR "code/FEA" -#define FILE_DIR "code/game" -#define FILE_DIR "code/game/area" -#define FILE_DIR "code/game/gamemodes" -#define FILE_DIR "code/game/gamemodes/blob" -#define FILE_DIR "code/game/gamemodes/blob/blobs" -#define FILE_DIR "code/game/gamemodes/changeling" -#define FILE_DIR "code/game/gamemodes/cult" -#define FILE_DIR "code/game/gamemodes/events" -#define FILE_DIR "code/game/gamemodes/events/holidays" -#define FILE_DIR "code/game/gamemodes/extended" -#define FILE_DIR "code/game/gamemodes/malfunction" -#define FILE_DIR "code/game/gamemodes/meteor" -#define FILE_DIR "code/game/gamemodes/nuclear" -#define FILE_DIR "code/game/gamemodes/revolution" -#define FILE_DIR "code/game/gamemodes/sandbox" -#define FILE_DIR "code/game/gamemodes/traitor" -#define FILE_DIR "code/game/gamemodes/wizard" -#define FILE_DIR "code/game/jobs" -#define FILE_DIR "code/game/jobs/job" -#define FILE_DIR "code/game/machinery" -#define FILE_DIR "code/game/machinery/atmoalter" -#define FILE_DIR "code/game/machinery/bots" -#define FILE_DIR "code/game/machinery/camera" -#define FILE_DIR "code/game/machinery/computer" -#define FILE_DIR "code/game/machinery/doors" -#define FILE_DIR "code/game/machinery/embedded_controller" -#define FILE_DIR "code/game/machinery/kitchen" -#define FILE_DIR "code/game/machinery/pipe" -#define FILE_DIR "code/game/machinery/telecomms" -#define FILE_DIR "code/game/mecha" -#define FILE_DIR "code/game/mecha/combat" -#define FILE_DIR "code/game/mecha/equipment" -#define FILE_DIR "code/game/mecha/equipment/tools" -#define FILE_DIR "code/game/mecha/equipment/weapons" -#define FILE_DIR "code/game/mecha/medical" -#define FILE_DIR "code/game/mecha/working" -#define FILE_DIR "code/game/objects" -#define FILE_DIR "code/game/objects/effects" -#define FILE_DIR "code/game/objects/effects/decals" -#define FILE_DIR "code/game/objects/effects/decals/Cleanable" -#define FILE_DIR "code/game/objects/effects/spawners" -#define FILE_DIR "code/game/objects/items" -#define FILE_DIR "code/game/objects/items/devices" -#define FILE_DIR "code/game/objects/items/devices/PDA" -#define FILE_DIR "code/game/objects/items/devices/radio" -#define FILE_DIR "code/game/objects/items/robot" -#define FILE_DIR "code/game/objects/items/stacks" -#define FILE_DIR "code/game/objects/items/stacks/sheets" -#define FILE_DIR "code/game/objects/items/stacks/tiles" -#define FILE_DIR "code/game/objects/items/weapons" -#define FILE_DIR "code/game/objects/items/weapons/grenades" -#define FILE_DIR "code/game/objects/items/weapons/implants" -#define FILE_DIR "code/game/objects/items/weapons/melee" -#define FILE_DIR "code/game/objects/items/weapons/secstorage" -#define FILE_DIR "code/game/objects/items/weapons/storage" -#define FILE_DIR "code/game/objects/items/weapons/tanks" -#define FILE_DIR "code/game/objects/structures" -#define FILE_DIR "code/game/objects/structures/crates_lockers" -#define FILE_DIR "code/game/objects/structures/crates_lockers/closets" -#define FILE_DIR "code/game/objects/structures/crates_lockers/closets/secure" -#define FILE_DIR "code/game/objects/structures/stool_bed_chair_nest" -#define FILE_DIR "code/game/turfs" -#define FILE_DIR "code/game/turfs/simulated" -#define FILE_DIR "code/game/turfs/space" -#define FILE_DIR "code/game/turfs/unsimulated" -#define FILE_DIR "code/game/verbs" -#define FILE_DIR "code/js" -#define FILE_DIR "code/modules" -#define FILE_DIR "code/modules/admin" -#define FILE_DIR "code/modules/admin/DB ban" -#define FILE_DIR "code/modules/admin/permissionverbs" -#define FILE_DIR "code/modules/admin/verbs" -#define FILE_DIR "code/modules/assembly" -#define FILE_DIR "code/modules/awaymissions" -#define FILE_DIR "code/modules/awaymissions/maploader" -#define FILE_DIR "code/modules/client" -#define FILE_DIR "code/modules/clothing" -#define FILE_DIR "code/modules/clothing/glasses" -#define FILE_DIR "code/modules/clothing/gloves" -#define FILE_DIR "code/modules/clothing/head" -#define FILE_DIR "code/modules/clothing/masks" -#define FILE_DIR "code/modules/clothing/shoes" -#define FILE_DIR "code/modules/clothing/spacesuits" -#define FILE_DIR "code/modules/clothing/suits" -#define FILE_DIR "code/modules/clothing/under" -#define FILE_DIR "code/modules/clothing/under/jobs" -#define FILE_DIR "code/modules/detectivework" -#define FILE_DIR "code/modules/flufftext" -#define FILE_DIR "code/modules/food" -#define FILE_DIR "code/modules/library" -#define FILE_DIR "code/modules/liquid" -#define FILE_DIR "code/modules/mining" -#define FILE_DIR "code/modules/mob" -#define FILE_DIR "code/modules/mob/dead" -#define FILE_DIR "code/modules/mob/dead/observer" -#define FILE_DIR "code/modules/mob/living" -#define FILE_DIR "code/modules/mob/living/blob" -#define FILE_DIR "code/modules/mob/living/carbon" -#define FILE_DIR "code/modules/mob/living/carbon/alien" -#define FILE_DIR "code/modules/mob/living/carbon/alien/humanoid" -#define FILE_DIR "code/modules/mob/living/carbon/alien/humanoid/caste" -#define FILE_DIR "code/modules/mob/living/carbon/alien/larva" -#define FILE_DIR "code/modules/mob/living/carbon/alien/special" -#define FILE_DIR "code/modules/mob/living/carbon/brain" -#define FILE_DIR "code/modules/mob/living/carbon/human" -#define FILE_DIR "code/modules/mob/living/carbon/metroid" -#define FILE_DIR "code/modules/mob/living/carbon/monkey" -#define FILE_DIR "code/modules/mob/living/silicon" -#define FILE_DIR "code/modules/mob/living/silicon/ai" -#define FILE_DIR "code/modules/mob/living/silicon/ai/freelook" -#define FILE_DIR "code/modules/mob/living/silicon/decoy" -#define FILE_DIR "code/modules/mob/living/silicon/pai" -#define FILE_DIR "code/modules/mob/living/silicon/robot" -#define FILE_DIR "code/modules/mob/living/simple_animal" -#define FILE_DIR "code/modules/mob/living/simple_animal/friendly" -#define FILE_DIR "code/modules/mob/living/simple_animal/hostile" -#define FILE_DIR "code/modules/mob/new_player" -#define FILE_DIR "code/modules/paperwork" -#define FILE_DIR "code/modules/power" -#define FILE_DIR "code/modules/power/antimatter" -#define FILE_DIR "code/modules/power/singularity" -#define FILE_DIR "code/modules/power/singularity/particle_accelerator" -#define FILE_DIR "code/modules/projectiles" -#define FILE_DIR "code/modules/projectiles/ammunition" -#define FILE_DIR "code/modules/projectiles/guns" -#define FILE_DIR "code/modules/projectiles/guns/energy" -#define FILE_DIR "code/modules/projectiles/guns/projectile" -#define FILE_DIR "code/modules/projectiles/projectile" -#define FILE_DIR "code/modules/reagents" -#define FILE_DIR "code/modules/reagents/reagent_containers" -#define FILE_DIR "code/modules/reagents/reagent_containers/food" -#define FILE_DIR "code/modules/reagents/reagent_containers/food/drinks" -#define FILE_DIR "code/modules/reagents/reagent_containers/food/drinks/bottle" -#define FILE_DIR "code/modules/reagents/reagent_containers/food/snacks" -#define FILE_DIR "code/modules/reagents/reagent_containers/glass" -#define FILE_DIR "code/modules/reagents/reagent_containers/glass/bottle" -#define FILE_DIR "code/modules/recycling" -#define FILE_DIR "code/modules/research" -#define FILE_DIR "code/modules/scripting" -#define FILE_DIR "code/modules/scripting/AST" -#define FILE_DIR "code/modules/scripting/AST/Operators" -#define FILE_DIR "code/modules/scripting/Implementations" -#define FILE_DIR "code/modules/scripting/Interpreter" -#define FILE_DIR "code/modules/scripting/Parser" -#define FILE_DIR "code/modules/scripting/Scanner" -#define FILE_DIR "code/modules/security levels" -#define FILE_DIR "code/unused" -#define FILE_DIR "code/unused/beast" -#define FILE_DIR "code/unused/computer2" -#define FILE_DIR "code/unused/disease2" -#define FILE_DIR "code/unused/gamemodes" -#define FILE_DIR "code/unused/hivebot" -#define FILE_DIR "code/unused/mining" -#define FILE_DIR "code/unused/optics" -#define FILE_DIR "code/unused/pda2" -#define FILE_DIR "code/unused/powerarmor" -#define FILE_DIR "code/unused/spacecraft" -#define FILE_DIR "code/WorkInProgress" -#define FILE_DIR "code/WorkInProgress/carn" -#define FILE_DIR "code/WorkInProgress/mapload" -#define FILE_DIR "code/WorkInProgress/organs" -#define FILE_DIR "code/WorkInProgress/Sigyn" -#define FILE_DIR "code/WorkInProgress/Sigyn/Department Sec" -#define FILE_DIR "code/WorkInProgress/Sigyn/Softcurity" -#define FILE_DIR "code/WorkInProgress/virus2" -#define FILE_DIR "html" -#define FILE_DIR "icons" -#define FILE_DIR "icons/effects" -#define FILE_DIR "icons/mecha" -#define FILE_DIR "icons/misc" -#define FILE_DIR "icons/mob" -#define FILE_DIR "icons/obj" -#define FILE_DIR "icons/obj/assemblies" -#define FILE_DIR "icons/obj/atmospherics" -#define FILE_DIR "icons/obj/clothing" -#define FILE_DIR "icons/obj/doors" -#define FILE_DIR "icons/obj/flora" -#define FILE_DIR "icons/obj/machines" -#define FILE_DIR "icons/obj/pipes" -#define FILE_DIR "icons/pda_icons" -#define FILE_DIR "icons/spideros_icons" -#define FILE_DIR "icons/Testing" -#define FILE_DIR "icons/turf" -#define FILE_DIR "icons/vending_icons" -#define FILE_DIR "interface" -#define FILE_DIR "maps" -#define FILE_DIR "maps/backup" -#define FILE_DIR "maps/RandomZLevels" -#define FILE_DIR "maps/RandomZLevels/backup" -#define FILE_DIR "music" -#define FILE_DIR "music/interface" -#define FILE_DIR "sound" -#define FILE_DIR "sound/AI" -#define FILE_DIR "sound/ambience" -#define FILE_DIR "sound/effects" -#define FILE_DIR "sound/hallucinations" -#define FILE_DIR "sound/items" -#define FILE_DIR "sound/machines" -#define FILE_DIR "sound/mecha" -#define FILE_DIR "sound/misc" -#define FILE_DIR "sound/piano" -#define FILE_DIR "sound/violin" -#define FILE_DIR "sound/voice" -#define FILE_DIR "sound/weapons" -#define FILE_DIR "tools" -#define FILE_DIR "tools/Redirector" // END_FILE_DIR // BEGIN_PREFERENCES +#define DEBUG // END_PREFERENCES // BEGIN_INCLUDE