Thread: Random links
View Single Post
Old 09-02-2009, 07:12 AM   #5 (permalink)
TheOnly92
The Contributor
 
Join Date: Mar 2009
Posts: 49
Thanks: 0
TheOnly92 is on a distinguished road
Default

Perhaps when an order comes, you can generate a random id by using something like this:

PHP Code:
$id md5(time());
$sql "INSERT INTO access (`down_id`,`down_created`) VALUES ('{$id}',".time().")"
Or more complicated if you like, then at the download side:

PHP Code:
// Check of expired download links
$expire time() - 30 60 60// Links created 30 minutes ago are expired
$sql "DELETE FROM access WHERE down_created < {$expired}";
mysql_query($sql);
// Now process the download
$id $_GET['id'];
$id mysql_real_escape_string($id);
$sql "SELECT * FROM access WHERE down_id='{$id}'";
$rs mysql_query($sql);
if (
mysql_num_rows != 1) {
    die(
'Unauthorized access!');
} else {
    
// Allow download of file

It's best you also rather use echo $file; than redirect to the link of the file in case some of your customers leak them.
TheOnly92 is offline  
Reply With Quote