Page 1 of 1

Link Encrypting

Posted: Fri Mar 28, 2008 2:16 pm
by scotty
I was wondering how to encrypt links using php? I have a few links to images etc that I don't want others hotlinking to. For example Myspace used msplink to encrypt their links. Is something similar possible with php?

Thanks!

Re: Link Encrypting

Posted: Fri Mar 28, 2008 3:24 pm
by Christopher
Instead you could generate a unique ID each request and save it in the session. Then use a script as your image and pass it the ID. Check if they are the same, if yes display the image, if not show an error image.

Code: Select all

<?php
session_start();
$_SESSION['verify'] = uniqid();
?>
<img src="showimage.php?file=foo.jpg&verify=<?php echo $_SESSION['verify']; ?>"/>

Re: Link Encrypting

Posted: Fri Mar 28, 2008 3:46 pm
by scotty
Hi arborint. I am pretty new at this php stuff so i don't know how to do that. To clearify, I am wanting to just encrypt links and not the actual file location. The links are on my phpbb3 forum. Not sure if that will make a difference.

Re: Link Encrypting

Posted: Fri Apr 04, 2008 6:07 am
by anto91
He made should have told you what to add to the showimage.php

but what happens in his code is that on the main page load he generates a php session with a unique id.

Then in the showimage you output image data IF the session is equvilent.