Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: pepa on March 12, 2018, 12:37:01 AM

Title: Folder Security
Post by: pepa on March 12, 2018, 12:37:01 AM
I have a folder placed one level up from the Forum's root directory.  It contains lots of pdf documents that are linked to from within posts in the forum.  I would like to be able to make this folder secure within the forum, so any registered forum member can access the files there by clicking the links within the relevant posts.  I also want Mr Google to keep out.

So I have tried the usual robots.txt file while realising this is no guarantee.  Yes I could password protect the folder and then give the password to forum members but that's kinda messy.  I've looked for some mods but come up with a blank.  Does anyone have suggestions?
Title: Re: Folder Security
Post by: aegersz on March 12, 2018, 04:39:02 AM
how do you link to the documents one directory up from your web root ?
Title: Re: Folder Security
Post by: pepa on March 12, 2018, 05:01:53 AM
Quote from: aegersz on March 12, 2018, 04:39:02 AM
how do you link to the documents one directory up from your web root ?

It's one directory up from the forum root not from the web root.  So e.g. domain is reformaps.net.au

there's a folder docs then -> a folder forum.  So link to the docs is reformaps.net.au/docs.doc.pdf, then I use target=_blank to open in a new tab.
Title: Re: Folder Security
Post by: Illori on March 12, 2018, 05:06:18 AM
might be easier for you to use a downloads mod or just attach the files to the posts and let SMF take care of the permissions for access.
Title: Re: Folder Security
Post by: pepa on March 12, 2018, 06:28:17 AM
Quote from: Illori on March 12, 2018, 05:06:18 AM
might be easier for you to use a downloads mod or just attach the files to the posts and let SMF take care of the permissions for access.

Hi Illori, thanks for your suggestion.  I can't attach the files to the posts as I have created a library using just one post.  Don't think I can attach 100 files to one post and, in most cases I need people to be able to open the file in a new tab and read it there not download an attached file.  Are you aware of a downloads mod that will let me do that?
Title: Re: Folder Security
Post by: Illori on March 12, 2018, 07:18:00 AM
check the downloads system, it may do what you need.
Title: Re: Folder Security
Post by: pepa on March 12, 2018, 08:44:19 AM
Quote from: Illori on March 12, 2018, 07:18:00 AM
check the downloads system, it may do what you need.

Thanks again Illori, I tried it but it will only allow downloads, it doesn't have an option to open the file in a new tab.  Also I encountered errors in the permissions, when I set the permissions for a Global Moderator to view the downloads the menu item didn't appear .. in the end I uninstalled the mod.
Title: Re: Folder Security
Post by: Kindred on March 12, 2018, 09:00:03 AM
in short, there is no good or easy way to do what you are asking.

You can not easily use the SMF security system to limit access to a directory.
SMF uses php
direct file/directory structure/access uses your web server (probably apache) and/or file system (Linux or Windows)

You have to put a layer between the files and the user, that uses php to access the files.
Either attachments or a download system...   or a third party file controller system.

Title: Re: Folder Security
Post by: Aleksi "Lex" Kilpinen on March 12, 2018, 12:43:11 PM
You could use something like this http://www.directorylister.com/
together with SSI. I haven't tried that, no warranties from me, just an idea.
Title: Re: Folder Security
Post by: pepa on March 13, 2018, 08:22:32 AM
Thanks for all the suggestions, much appreciated.  I thought about adding another layer between the server and the forum authentication, but then people would need two logins.  In the end I decided upon a more practical solution ... looked at the files and the majority of them don't have to be protected, so they'll all remain in an unprotected folder and people can open them in a new tab by clicking the link.  I moved the much smaller number of files that do need protection to another folder and password protected that with the web server software.  I'll just have to give the password out to forum members as required.  I can live with that.