Wordpress / how to create user-specific private folders? - wordpress

My website includes forms and php code which create pdf files for logged in users. How can I make sure only the appropriate user, the one which generated the files, can access his own files ? Also, the admin user should be able to access these files too.
At the moment, my code creates files in the wp-content/uploads folder, but then any user can access the files generated by the other users, if he can guess the file name... I am OK to create the file in any other folder if required.
I am familiar with command chown and chmod, but I am not sure how to use it in this context. The private folder of each user could be created by my php code.
Thanks for your help,
Ilann
what I did so far: a lot of google searches around "wordpress private folder", "wordpress user-specific folders"...

Related

Symfony2: How restrict files in publicly accessible directory

I have XML files in a publicly accessible directory. I want to restrict them to accessible only to logged in users. So when I go to http://example.com/web/file.xml only AUTHENTICATED members can access the file. I'm using PHP & Symfony2.
Files in web are all public so don't put it into that folder.
You can create a folder into Ressources and put your xml into it.
Then create an action witch read and display your file. In this way you will be able to secure your action.
For exemple you can access as http://monsite.com/xml/get
How to secure : http://symfony.com/doc/current/cookbook/security/securing_services.html
I solve the problem with this
$filename = $this->get('kernel')->locateResource("#SomeBundle/Resources/folder/‌file.xml");
(Accessing Files Relative to Bundle in Symfony2)

Give anonymous access to a folder under wp-admin folder in WordPress

I have a folder in wordpress which is located under the wp-admin folder and that folder contains the documents that can be downloaded from the user section.Now when the user downloads the words files using IE-9 and click on the open option from the IE save dialog it gives them a security warning. This problem is solved if I move the folder the root of the website. So I guess there is some access issue is there any way I can provide anonymous access to that folder. I really don't want to change the location of the folder as it will reqiure lots of changes to code and database.
FYI : This is issue comes only for word files , PDF files in the same folder work fine.
no you cannot access the folder without the username and password even when you try to grab the files of that folder using idm grabber or httrack you will need username and password

Hide/encrypt or otherwise change path to mp4 file in drupal

I have video files (mp4's as I want people to be able to view them on ipads etc.) that I serve to users. However some of these videos are only available to users who have a certain number of user points. I have that working in that if a user doesn't have enough user points they can't view the node. All users have the same role (video viewer) and the problem is that it is possible for someone who has enough user points to view the node, grab the url of the video and then give it to someone who has the video viewer role but doesn't have enough user points and then that person can directly download that mp4.
Just looking for a way to limit access to the mp4 file if a user does not have access to the node or hide the path to the file somehow. I have the mp4's stored in a private file system but this hasn't solved the problem as the users have the same role.
I've got this (http://www.ioncube.com/html_encoder.php) working on static pages in my webspace (non drupal pages) but can't get it working in my drupal setup. When I include the php code in my node to include the php file it just gives me a blank page.
Many thanks
There's not much I could say about this that the Drupal documentation doesn't already.
http://drupal.org/documentation/modules/file#access
Managing file locations and access
When you create a file field, you can specify the sub-directory of the site's file system where uploaded files for this content type will be stored. The site's file system paths are defined on the File system page (Administer > Configuration > Media: File system).
You can also specify whether files are stored in a public directory or in a private file storage area. Files in the public directory can be accessed directly through the web server; when public files are listed, direct links to the files are used and anyone who knows a file's URL can download the file. Files in the private directory are not accessible directly through the web server; when private files are listed, the links are Drupal path requests. This adds to server load and download time, since Drupal must resolve the path for each file download request, but allows for access restrictions.
The best practice for public files is to store them in the multi-site directory like: sites/default/files
The default way to securely add a private directory for your files is to use a directory that can not be accessed directly by your web server, but can be accessed by Drupal. Ideally this directory should be located outside of your Drupal root folder.
The simple way to add a private directory for your files is to create a sub-directory under the public directory like: sites/default/files/private
When you specify the private directory in admin/config/media/file-system it will automatically create the sub-directory & create a simple .htaccess file with Deny from all. This stops Apache from serving files from this directory. Make sure that you test this by adding file to that directory and verifying that you can't browse there directly. If this isn't working, all files in this directory will be accessible to anyone who can guess the URL! Note that non-Apache web servers may need additional configuration to secure private file directories.
Accessing Private Files
Once configured, files stored in the private directory are inaccessible via a direct link; however, if Drupal constructs a link to the file, the file will be accessible to anyone who can see the link.
For example: you have created a new content type with a file field which stores files in your site's private file directory. Next you create a node from this new content type and attach two new files. When the node is published links to both attached files are visible and anyone who can view the node may download the files. Now, if you unpublish the node, all attached files become inaccessible for download even if you use the direct link to the files that worked when the node was published.
Re-publish the node, and disable the "display" checkbox for one of the files. Save the node. Now one file is accessible for public download and the other is not accessible--even if you have the direct URL for the file that is not listed you will not be able to download this file.
For finer grained control of who can see/download attached files you will need an additional access control module. You may write a module yourself, or use a contributed module such as Content Access.

Folder permissions through a web page?

I want a folder on a site where logged-in active directory users can create sub folders and upload images under an "/Uploads" folder off the root. I am able to retrieve the username using System.DirectoryServices.
Is there a way to:
Restrict what is returned from the DirectoryInfo().GetDirectories based on their username
Set permissions on a subfolder of /Uploads (via a web page) to read/write.
You might want to look at this post on how to create folder dynamically at run time
And this post from stackoverflow shows bunch of ways to assign folder permissions. See which one applies
Good luck!

how to restrict access to uploaded files using cck file field from other users

I've a node type created by different users who will be uploading private files.
Now all of whom land in sites/default/files folder which has public access and is visible to the world.
I've tried Private Download module but it can't restrict other users to access one's uploaded files.
I'm using Drupal 6.2
This doesn't use the filefield module, but User Files allows making files private except to the uploading user.
EDIT:
filedepot may work for you. It will allow you to create a folder and only allow that user to access it. I haven't played around with it too much, but it can definitely be a useful tool.

Resources