Page 1 of 1
make a download expire?
Posted: Sun Nov 14, 2004 3:45 pm
by ecaandrew
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.
Posted: Sun Nov 14, 2004 4:16 pm
by John Cartwright
Insert a timestamp in your database which is updated with the current timestamp of the time purchased. then run a check everytime a user laods the page for expired times... ( if timestamp > timestamp+48hours )
then update the field again which will flag it expired..
Posted: Mon Nov 15, 2004 1:04 am
by ecaandrew
i get it but i dont
Question
Posted: Mon Nov 15, 2004 1:38 am
by thomas777neo
So, on download, you want the file to delete itself after a specific period of time. Like a cookie?
Posted: Mon Nov 15, 2004 1:47 am
by ecaandrew
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....
Posted: Mon Nov 15, 2004 1:48 am
by ecaandrew
like maybe i can have the TXN ID entered in the Database, and have it expire according to TXN ID? but how so
Agreement
Posted: Mon Nov 15, 2004 1:56 am
by thomas777neo
Then I agree with Phenom's idea.
Maybe he can give you a sample of code
Posted: Mon Nov 15, 2004 3:39 am
by ecaandrew
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
-------------------------------------------------------------------------
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']);
?>
Posted: Mon Nov 15, 2004 4:33 am
by phpScott
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
Posted: Mon Nov 15, 2004 4:39 am
by ecaandrew
what kind of timestamp should i use to enter the date????
$purchastedate = timestamp();
??? something like that, thanks
Posted: Mon Nov 15, 2004 5:26 pm
by ecaandrew
anyone?
Posted: Tue Nov 16, 2004 3:14 am
by phpScott
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.