The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
If it is, the page displays all the files within a download folder. Now, I want this folder to be protected so no-one can simply type the URL of the folder (or one of the files contained within) and gain access. The only way I know of to do this is with .htaccess... If a folder is protected with .htaccess though, can I somehow unprotect it with the php page once a user has successfully logged on? Or is there some way of downloading the file with the php, as I'm under the impression server side scripts can still access .htaccess protected files/folders...?
Cheers in advance for any replies...
Before I had a function to display the contents of the download folder, along with links to the download.php?file=(whatever) download for that file... But I also need users to have different 'levels' of access to files, and was going to do this by having the 'top level' users start from a high folder, while as 'low level' users start further down the folder heirarchy. So I need a function to display all files in their start folder and all files in any folder contained within, until all nested folders have their contents displayed.
Obviously I'll have to then check what level the user is on the download.php file, but the algorithm will pretty much be a combination of the one already written and the display folder contents algorithm.
Anyway, I wrote the showFolderContents function, and it works fine at first, except it just stops running... And the rest of the page (eg. footer) is not processed. Any ideas what could be causing this? The algorithm is recursive, calling itself upon finding a folder with the new starting directory and increasing the nested level (which is just there to add some "|-" things to make it look a bit prettier and easier to see what file is in what folder).
Anyway, any ideas about this? Chars.
EDIT: By the way, I'm testing it further, and it seems to deal with one nested level fine. It will display the contents of the initial start folder and any/all folders contained within. But if I add a folder in one of the already nested folders, it breaks... :-S
EDIT-2: I was being an fool. I had a while loop in the function which gets the "|-" thing based on what nested level the function is on and had forgotten to decrease the loop variable... Doh.
Do a PHP file with the following code in:
That'll print the full path to the script.
> Is it a Windows platform? Using / will reference to the root of the
> operating system if it is Unix - not the root of the webserver.
Hmm, may be the problem... So I need to put something like /~username or whatever, and that'll be referencing the folder that is above the public_html...?
Very annoying!
So if there's nested includes, the top file calls an include, and it starts processing all that included files contents, so if there's an include in the initial included file, it all gets processed, then shoved in the initially included file, then that initially included file is going to be included in the top file for the browser to interpret.
So any refernces will have to be in the scope of the top file called.
By the way, has anyone else found problems with nested includes? Say you have an included file which includes another file, all the include paths have to be relative to the top level file.
However, I'd forgotten the passowrd is stored as encrypted in the database too, so I had to add that encryption to the password $_SESSION variable before the second 'session' encryption...
Working now!
EDIT: One niggle I've been having throughout is absolute referencing... I've never had use for it before, so never used it, but I've been having problems referencing the 'top' folder where the 'downloads' folder is stored so people can't access any of the files within... I've now resorted to relative referencing, meaning a bunch of "../"s, which isn't a tragedy, I was just interested if anyone could tell me how it's done... I thought it was just "/(folder in top directory)", but that refused to work...
Well, not working. But the session is now. Just gotta put in some echoes and see what section is causing it to do... nothing.
Chars!
session_start();
At the top of the page?