In the next Modx R project I'm about to build I will need to create files to be downloaded only by logged users. Fact is that if I simply put these files into a private page, I can't avoid a direct download once the URL is aknowledged. Is there any extra or a combination of extras that can do that? Best would be if downloads could also be tracked for each user.
I am not aware of such extras, but here are some tips:
Put all your files outside publicly accessible folder (ie outside public_html...)
When user clicks download redirect him to another resource with no template, pass filename to that resource, check if user is authenticated and if he is use header function with correct mime type.
That are some rough ideas, you should really study this:
http://php.net/manual/en/function.header.php
Antonio Zdilar
linearvector.com
Ok let me see if I've understood what you're suggesting (I am a graphic designer with very little knowledge in php). I put all the files into a non-public folder. Each link to a file will be a snippet that recalls a no-template page where the specific file is passed and where the user session is validated before proceeding any further. If it's OK then the page remains available and download may occur else the user gets redirected elsewhere and the link to the file gets erased. Is it correct?
Also I've read about using few strings in a .htaccess file to protect all files contained into a certain directory from download if users are not logged....
Those are just ideas, but it should be along those lines:
link: www.yourdomain.com/resourceWithNoTemplate?file=somefile
In resourceWithNoTemplate validate user
If validated, send file with header function
Antonio Zdilar
linearvector.com