...

View Full Version : Random URL That Expires



transfield
11-10-2006, 03:31 PM
Hello,
I want to hide a file somewhere on my server. I then want to create a random url that will eventually expire(after a few days) which links to this file. Then I want to give this url to my customers in order for them to download the file.

I tried this tutorial at http://forums.devshed.com/php-development-5/generate-random-link-to-url-38357.html This code works fine & is exactly what I'm looking for. The only problem with this code is the location of the secret file is eventually revealed in this line:-

// Take the user to the file:
header("Location: http://mydomain.com/filedir/" . addslashes($n));

So how do I hide the actual location of the file?

Thanks.

mlseim
11-10-2006, 04:36 PM
Not sure how complex you want to make it ...

No matter how you do it, you'll have to give them a URL to
download the code ...

So I would do something like this (using PHP/MySQL ?) ...

You create a random directory with the file copied into it ...like: /id34324/yourfile.zip
That would be the key thing. Your PHP script is taking the original file and copying
it into the new directory, so your original file location is kept secret.

You give the customer that id number (id34324).
When they log-in with that id number, they are allowed to download
the file. After so many days, that directory and file are deleted, but you
retain their id number in the database ... so if they come back and say
that the need to download it again (for some reason), you can verify that
they downloaded it once already and decide what to do ... either put the
directory and file back in place, or assign a new id.

But since you might use MySQL anyhow, I think if a file is saved in the
database (instead of in a directory), you have some control over things.
I'm not a MySQL expert, but I think there might be some possibilities there.

Lee Stevens
11-11-2006, 09:19 PM
Easyest way to make a DB with all generated links, date and user id. So user can only download it and query the date, if it i dunno 5 days older than in TB set link as expired.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum