mirror of
https://github.com/fulpstation/fulpstation.git
synced 2025-12-10 10:01:40 +00:00
fixed giveruntimelog getruntimelog and getserverlog Any admin with ADMIN rights can give anybody permission to view runtimes simply by typing .giveruntimelog The person given permission can then type .getruntimelog Admins can type .getruntimelog without giving themselves permissions first Moved a lot of the copypasta code into helper procs in __HELPERS/files.dm. There is one which allows a client to browse through folders on the server (in this case to look for logfiles). You can now also return to the directory you started at. Note, for some weird reason, runtimes will no longer show in dreamdeamon. If this is a massive problem I can make it a compile option or something (or you can comment out the line if you're a coder). I know this is a massive pain but it sort of removes much of the effort in getting runtimes from other servers, since they all now have their runtimes saved in a way coders can easily access. It also sort of means we don't have to rely on people remembering to log runtimes and such. And all logs will be organised by month. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@5466 316c924e-a436-60f5-8080-3fe189b3f50e
60 lines
1.8 KiB
Plaintext
60 lines
1.8 KiB
Plaintext
//checks if a file exists and contains text
|
|
//returns text as a string if these conditions are met
|
|
/proc/return_file_text(filename)
|
|
if(fexists(filename) == 0)
|
|
error("File not found ([filename])")
|
|
return
|
|
|
|
var/text = file2text(filename)
|
|
if(!text)
|
|
error("File empty ([filename])")
|
|
return
|
|
|
|
return text
|
|
|
|
//Sends resource files to client cache
|
|
/client/proc/getFiles()
|
|
for(var/file in args)
|
|
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, i<max_iterations, i++)
|
|
var/list/choices = flist(path)
|
|
if(path != root)
|
|
choices.Insert(1,"/")
|
|
|
|
var/choice = input(src,"Choose a file to access:","Download",null) as null|anything in choices
|
|
switch(choice)
|
|
if(null)
|
|
return
|
|
if("/")
|
|
path = root
|
|
continue
|
|
path += choice
|
|
|
|
if(copytext(path,-1,0) != "/") //didn't choose a directory, no need to iterate again
|
|
break
|
|
|
|
var/extension = copytext(path,-4,0)
|
|
if( !fexists(path) || !(extension in valid_extensions) )
|
|
src << "<font color='red'>Error: browse_files(): File not found/Invalid file([path]).</font>"
|
|
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 << "<font color='red'>Error: file_spam_check(): Spam. Please wait [round(time_to_wait/10)] seconds.</font>"
|
|
return 1
|
|
fileaccess_timer = world.time + FTPDELAY
|
|
return 0
|
|
#undef FTPDELAY |