• Dump Globals

    From Mortifis@VERT/ALLEYCAT to All on Sat Feb 16 11:26:39 2019
    Is there a js function similar to php var_dump($GLOBALS); ?ãã2 wrongs don't make a right, but 3 left turns will get you back on the freeway!ãã---ã þ Synchronet þ AlleyCat! BBS - http://alleycat.synchro.net:81ã
  • From echicken@VERT/ECBBS to Mortifis on Sat Feb 16 11:36:44 2019
    Re: Dump Globalsã By: Mortifis to All on Sat Feb 16 2019 11:26:39ãã Mo> 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');ã });ã}ããTweak the 'exclude' array to filter unneeded stuff like 'system', 'msg_area',ã'file_area', 'xtrn_area'. The defaults are there to avoid problems and shouldãbe left in, though some don't matter in certain contexts (like the webserver).ãã---ãechickenãelectronic chicken bbs - bbs.electronicchicken.com - 416-425-5435ã þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.comã
  • From Mortifis@VERT/ALLEYCAT to echicken on Sat Feb 16 13:04:07 2019
    Re: Dump Globalsã > By: Mortifis to All on Sat Feb 16 2019 11:26:39ãã > Mo> 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 ãã2 wrongs don't make a right, but 3 left turns will get you back on the freeway!ãã---ã þ Synchronet þ AlleyCat! BBS - http://alleycat.synchro.net:81ã
  • From echicken@VERT/ECBBS to Mortifis on Sat Feb 16 12:32:19 2019
    Re: Re: Dump Globalsã By: Mortifis to echicken on Sat Feb 16 2019 13:04:07ãã Mo> perfect, thank you, one thing I am having trouble with is set_cookie(...,ã Mo> (time() - 1000, ...) I keep getting an error: cannot convert NaN toã Mo> 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ãã---ãechickenãelectronic chicken bbs - bbs.electronicchicken.com - 416-425-5435ã þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.comã
  • From Mortifis@VERT/ALLEYCAT to echicken on Sat Feb 16 15:33:53 2019
    Re: Re: Dump Globalsã > By: Mortifis to echicken on Sat Feb 16 2019 13:04:07ãã > Mo> perfect, thank you, one thing I am having trouble with isã > Mo> set_cookie(..., (time() - 1000, ...) I keep getting an error: cannotã > Mo> 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ããthat's is the format I have been using, though I believe I tracked the issueãdown to a misplace , :/ so in the web interface I am, ahem, scripting, I setãthe cookie then did the scope_dump() you gave me and http_request:{ ... cookieãis still cookie{} ... ããnew question: how would one do a logout from the interface ... tried settingãuser.numer = 0; with no affect ãã2 wrongs don't make a right, but 3 left turns will get you back on the freeway!ãã---ã þ Synchronet þ AlleyCat! BBS - http://alleycat.synchro.net:81ã
  • From echicken@VERT/ECBBS to Mortifis on Sat Feb 16 17:53:05 2019
    Re: Re: Dump Globalsã By: Mortifis to echicken on Sat Feb 16 2019 15:33:53ãã Mo> new question: how would one do a logout from the interface ... triedã Mo> 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.ããMy web UI does things a bit differently and does have a way of destroying aãsession, but that's a whole other story. It's also something I'm planning onãrevising in the near term.ããAre you creating a web interface from scratch, or is this a mod of somethingãthat already exists?ãã---ãechickenãelectronic chicken bbs - bbs.electronicchicken.com - 416-425-5435ã þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.comã
  • From Mortifis@VERT/ALLEYCAT to echicken on Sat Feb 16 20:08:10 2019
    Re: Re: Dump Globalsã > By: Mortifis to echicken on Sat Feb 16 2019 15:33:53ãã > Mo> new question: how would one do a logout from the interface ... triedã > Mo> 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.ããI had been using runemaster logout.ssjs and fiddling with it because it didn'tãactually logout, even if you close the browser and reopen it you're stillãlogged in; unless you clear the cache and cookies etc ...ã ã > Are you creating a web interface from scratch, or is this a mod of somethingã > that already exists?ããhalf of both ... I migrated a php theme I wrote for my transport managementãsuite and am modifying it for js, ssjs, xjs and in an attempt to change theãcurrent login.ssjs and logout.ssjs I am running into the issues you mention,ãespecially since the theme navigation remains and content is in a centre, ahem,ã<iframe> some, if not most, of the content is ripped and modified fromãweb/root web/templates/nightshade ããI'll just leave it with the baked in stock login.ssjs and forget logouts :-Þããããã2 wrongs don't make a right, but 3 left turns will get you back on the freeway!ãã---ã þ Synchronet þ AlleyCat! BBS - http://alleycat.synchro.net:81ã
  • From Mortifis@VERT/ALLEYCAT to echicken on Sat Feb 16 20:37:39 2019
    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?ãã ãI have a basic running model at http://ephram.synchro.net ã2 wrongs don't make a right, but 3 left turns will get you back on the freeway!ãã---ã þ Synchronet þ AlleyCat! BBS - http://alleycat.synchro.net:81ã