Is there a js function similar to php var_dump($GLOBALS); ?
Re: Dump Globals
By: Mortifis to All on Sat Feb 16 2019 11:26:39
Is there a js function similar to php var_dump($GLOBALS); ?
Not that I'm aware of. It's easier and less verbose to target the variable that you want rather than dumping the entire global space:
writeln(JSON.stringify(my_var));
You could use this to dump the global scope of your script:
function scope_dump() {
Object.keys(js.scope).forEach(function (e) {
const exclude = [
'conio',
'js',
'stderr',
'stdin',
'stdout'
];
if (exclude.indexOf(e) > -1) return;
writeln(e + ':\r\n' + JSON.stringify(js.scope[e]) + '\r\n');
});
}
perfect, thank you, one thing I am having trouble with is set_cookie(..., (time() - 1000, ...) I keep getting an error: cannot convert NaN to integer
Re: Re: Dump Globals
By: Mortifis to echicken on Sat Feb 16 2019 13:04:07
perfect, thank you, one thing I am having trouble with is set_cookie(..., (time() - 1000, ...) I keep getting an error: cannot convert NaN to integer
http://wiki.synchro.net/server:web#extra_global_methods
What you're passing as the expiration time can't be interpreted as an integer. Mind the order of parameters you're passing to set_cookie. The first two parameters need to be strings. The third parameter is optional, and if passed needs to be a number, being the expiration time. See the wiki for the rest of the parameters.
So what you want is something like this:
set_cookie('key', 'value', time() - 1000); // Or time() - 1000 or whatever
new question: how would one do a logout from the interface ... tried setting user.numer = 0; with no affect
Re: Re: Dump Globals
By: Mortifis to echicken on Sat Feb 16 2019 15:33:53
new question: how would one do a logout from the interface ... tried setting user.numer = 0; with no affect
How are you logging the user in in the first place?
I believe the Runemaster web UI uses HTTP authentication that's baked into the web server. The user is already logged in before the script begins to execute, and I don't think there's a proper way to log them out after that. With most browsers, the only way to log out of this type of session is to close the browser. Clearing the cache may work. I see a logout.ssjs that attempts to do just this, but if it does it wouldn't take effect until the next request comes in from that client.
Are you creating a web interface from scratch, or is this a mod of something that already exists?
Re: Re: Dump Globals
By: Mortifis to echicken on Sat Feb 16 2019 15:33:53
Are you creating a web interface from scratch, or is this a mod of something that already exists?
Sysop: | digital man |
---|---|
Location: | Riverside County, California |
Users: | 1,043 |
Nodes: | 15 (0 / 15) |
Uptime: | 41:47:35 |
Calls: | 500,899 |
Calls today: | 2 |
Files: | 109,370 |
D/L today: |
4,721 files (479M bytes) |
Messages: | 304,224 |