make a download expire?
Moderator: General Moderators
make a download expire?
hello i need help with making a download expire, itll be a product being purchased through paypal ipn, and it will be downloaded a lot, i need the download to expire, right now what i have is a field in my downloads table called "hex" which is the md5("FILEURL"), and when they purchase the download they get an email going to download.php?38724187328947328dfshafjkhsafdsa(hex code) and that redirects to the file download, but i need it so the file expires for each person who downloads it, paypal automitcally generates a unique ID called TXN_ID, i was figuring i can use that somehow, but if someone can help me think of how to do it, thatd be awesome, thanks, i need it to expire in 48 hours somehow.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- thomas777neo
- Forum Contributor
- Posts: 214
- Joined: Mon Mar 10, 2003 6:12 am
- Location: Johannesburg,South Africa
Question
So, on download, you want the file to delete itself after a specific period of time. Like a cookie?
no, its to be able to be downloaded by multiple people buying the product, so like they will be emailed
http://blah.com/download.php?HEXCODEHER ... 3721094321
each person who buys the template is given a unique TXN ID, so i figure i can tmake it expire with that some how, i dunno....
http://blah.com/download.php?HEXCODEHER ... 3721094321
each person who buys the template is given a unique TXN ID, so i figure i can tmake it expire with that some how, i dunno....
- thomas777neo
- Forum Contributor
- Posts: 214
- Joined: Mon Mar 10, 2003 6:12 am
- Location: Johannesburg,South Africa
Agreement
Then I agree with Phenom's idea.
Maybe he can give you a sample of code
Maybe he can give you a sample of code
maybe someone can help me let me show you what i think, but i know it wont work
when paypal process is finished
INSTERT the TXN_ID into table_downloads
mail the user
http://blah.com/download.php?hex=md5(FI ... TXNID_HERE
once they get to that page
download.php FILE
-------------------------------------------------------------------------
when paypal process is finished
INSTERT the TXN_ID into table_downloads
mail the user
http://blah.com/download.php?hex=md5(FI ... TXNID_HERE
once they get to that page
download.php FILE
-------------------------------------------------------------------------
Code: Select all
<?php
DBCONNECT HERE
$GRABTXNID = @mysql_query("SELECT * FROM `orders` WHERE `txn_id` = '" . $_GET['txnid'] . "'");
--- SOME ACTION HERE I CANNOT THING OF, ---
$GRABDOWNLOADURL= @mysql_query("SELECT * FROM `templates` WHERE `hex` = '" . $_GET['file'] . "'");
$row = @mysql_fetch_array($GRABDOWNLOADURL);
header("location: " . $row['file']);
?>
Last edited by ecaandrew on Mon Nov 15, 2004 5:47 am, edited 1 time in total.
insert another field that has a ie. (purchasedDate)datestamp in it that gets set/updated when someone purchases the file.
When they click on the email link do a quick check to make sure that say 48 hours hasn't passed first.
If it hasn't then let them down load the file using your current system other wise tell them that the download has expired.
see
[mysql_man]datediff[/mysql_man] in the manual
When they click on the email link do a quick check to make sure that say 48 hours hasn't passed first.
If it hasn't then let them down load the file using your current system other wise tell them that the download has expired.
see
[mysql_man]datediff[/mysql_man] in the manual
check out http://dev.mysql.com/doc/mysql/en/Date_ ... tions.html from the mysql man, it should get you in the right direction as well as examples of how to do what you want to do.