Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Tue Mar 30, 2010 1:28 pm 
Offline
Senior Member

Joined: Mon May 14, 2007 8:20 am
Posts: 81
hello,

I have some files should be accessed only by the logged in users of a website
I am using php and cookies to make sure only those who have logged in have access to the links to those images. This is a good first step.

Now, I am realizing that those link (such as <img src='http://example.com/image.jpg />) could actually be shared. For instance I could log in and copy the above link and email it to someone and the image would be seen by someone who did not log in.
How can I do to ensure that someone typing the example.com/image.jpg and who did not logged in would be automatically forwarded to another page?

I am using apache 2.2

Thanks


Top
   
 Post subject:
PostPosted: Tue Mar 30, 2010 6:55 pm 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
Well theres some good new and bad news.

Good news, what you want is possible. Since you're using PHP create a php file which takes a GET variable which is the file name. Move your images out of the web accessible directory. Set your PHP file to check if the user is logged in, if they're not throw whatever message you want, if they are get the PHP file to take the GET variable, open the related file using readfile() which will output it to the browser (remember to use header() to set the correct mime type) also don't forget to secure your GET input you don't want someone being able to read stuff that isn't an image.

Bad news, there's nothing stopping someone logging in, copying the image and emailing it to someone else.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group