Relative folder location

Workarounds and usability notes.

Relative folder location

Postby John Robin Dove » Wed Jul 26, 2017 4:40 am

Hi Clifton,

You said: If in the end, all the content will be served from a single folder, I would recommend using a relative folder location as this will be more fool-proof when you go to the web and it should work in any test scenario on your local hard drive.
So try . . . (it should work regardless of where the content is being tested from)
"../programs"
instead of . . .
"http://localhost/programs"


I am probably doing something wrong but I have tried to use "../programs" but it doesn't seem to work. Here is the code:

url : "../programs/moveobjects/index.html"

The code below works as it always has done:

url : progFolder & "/moveobjects/index.html"

I am assuming you prefer "../programs" because it's less of a security risk?

John

UPDATE: I have found the solutions it should be: url : "/programs/moveobjects/index.html"

Will this work in an XmlHttpRequest I wonder.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Relative folder location

Postby Clifton » Wed Jul 26, 2017 6:04 am

Relative paths work fine in XMLHttpRequest() as well.
 
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Relative folder location

Postby John Robin Dove » Wed Jul 26, 2017 6:42 am

Thanks. Sorry to bother you again but could you confirm that my global variable progFolder is a security risk? Eliminating it will be a bit time-consuming because my tbk is too full and I can't dump the actions.

As regards certain other global variables like school, student, teacher etc. I encrypt them all in one stack and they are only decrypted as local variables when required. Is this sufficient?
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Relative folder location

Postby Clifton » Wed Jul 26, 2017 7:05 am

My suggestion did not necessarily have anything to do with security. Relative paths are most beneficial for portability when moving from a development to a live environment on the web.

Where you feel something needs encryption, you have probably explored pgStringEncrypt() for client-side encryption. You can also use server-side encryption via PHP, etc.
 
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Relative folder location

Postby John Robin Dove » Wed Jul 26, 2017 7:49 am

OK thanks.

I seem to remember you saying that using Firefox anyone can get the value of all the global variables used in a program. Surely progFolder = https:// (...) /programs or school = [name of school] might be potentially dangerous, no? I have done all the encyption a nd decryption using pgStringEncrypt() .
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Relative folder location

Postby John Robin Dove » Wed Nov 15, 2017 10:06 am

Hi Clifton,

I'm on this topic again. I have been using a global variable progfolder which contains "https://[name of site]/programs/" I thought it might be better to get rid of this and just use the relative path "/programs/[etc]" I don't understand why it won't work with htmlVideoLoader. In the same action sequence I use the relative path twice. Once with XMLHttpRequest and then with htmlVideoLoader. There is no problem reading the file but the mp4 video is not loaded!?

If I continue to use the global variable again does it constitute a security risk?

John
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Relative folder location

Postby Clifton » Wed Nov 15, 2017 10:45 am

A relative path has to resolve to the location where your mp4 file is located.
Example:
    If my mp4 files are stored in a folder called video structured something like this:
    [calendar]
    [dialog]
    [fe]
    [media]
    [video]
    bootstrap.js
    index.html

    Then a relative path to an mp4 video may look like this:
    ../video/myVideo.mp4
    htmlVideoLoader() should find and play a video from a relative path like this.

    The key here is to issue a debug (alert or prompt) action to reveal the actual relative path being used. You will likely find that there is a path separator (/) or a missing dot notation ("../") in the relative path.

    Note that "/programs/[etc]" is not a relative path. However, "../programs/[etc]/" is a relative path.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Relative folder location

Postby John Robin Dove » Wed Nov 15, 2017 12:56 pm

Thanks for your reply.

Sorry if I'm a bit dense but to use "../video/myVideo.mp4" video would have to be in the folder created in the webExport folder e.g. myProgram.tbk => webExport\myprogram => https://[name of site]...etc /myProgram/video for this to work. This is not the case. I have all my files and folders in a folder called programs: https://[name of site]/programs/myProgram or https://[name of site]/programs/doStuff.php etc. I want to be able to access everything that's in the programs folder. I read that "/[name od folder]" refers to a folder directly after the root folder. And this seems to work when I want to access a txt file via XMLHttpRequest but it doesn't work for HtmlVideoLoader.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Relative folder location

Postby Clifton » Wed Nov 15, 2017 1:03 pm

I suspected this was the case for you.
If you [video] folder is outside of the ToolBook exported folder structure, just use dot notation to backup to it to its relative location.
Example:
[video]
[programs]
[toolbook]
[calendar]
[dialog]
[fe]
[media]
bootstrap.js
index.hmtl
To run a video in [video], use this relative path:
../../../video/mymovie.mp4
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Relative folder location

Postby John Robin Dove » Wed Nov 15, 2017 2:46 pm

Thank you very much. Problem solved!

Just two other things:

1) (as asked previously) if I use a global variable containing "https://[name of site/programs" will this be a security risk? If so I now have two options: continue using it containing "../../../programs" or get rid of it and rewrite everything using "../../../programs" instead of a variable (a bit daunting as it is used many times in a book that's too big to dump / check its actions). What do you think please?

2) Should we now avoid using flv files as they trigger a warning about slowing down the browser and are due to be phased out sooner or later?
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron