Click to See Complete Forum and Search --> : how to make a dynamic link to a zip file?


html20009876
11-07-2007, 11:45 AM
my purpose is to hide link of a zip file, so that hacker can not make spam download of the zip file.

if I can make a dynamic link to the zip file and make the link valid only for, e.g. one hour, the things sound better.

from replies of my another post, i know dynamic link is possible, but, my question is: how to do it?

Znupi
11-07-2007, 03:13 PM
I really don't see why you would do this. You don't want a hacker to download your zip file many times? Well:
1. Why would someone do that? To flood your server? There are other ways..
2. If he really wants to do it, he'll download it until he gets a 404 error and then just open the page with the 'dynamic link' in it and get the new link. For example, I could do this very easily, although I'm not a 'hacker'.

If you really want to do this, here's how I'd do it:
Store a key (like "a987fhsl") in a variable in a session. On the 'dynamic' link put a "?key=<key>" (where <key> is the key you stored in the session). Then, create a download script which compares the key stored in the session with the one in the URL and if they match, it serves the file, do not simply redirect using header("Location: ..."); because it will be trivial to find the actual location of the file. Optional: every time a user opens a new page on your site, store a new key in the session. Doing it this way is actually better than what you wanted to do, because it doesn't change once an hour, it changes on every pageview and is unique for every visitor of your site. If you need help with any of these, post back ;).

Again, I really don't think this is a solution against hackers, and I'm not aware of any good solution against them. This is actually a good solution against hot-linking. But then again, there are better ways against hot-linking (using the $_SERVER['HTTP_REFERER'] variable).

Good luck :)