FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Free Download Email Signup





medesignz
I want to be able to send an automated email response (to a sign up) that has a link to a download file/page which expires after 48hrs.

Any tips please...
rvec
Put this in your database:
datetime (created_on) | varchar (key) | varchar (filepath)

When you make a new link put the current time in the "created on" column and a random key in the "key" column. Send a mail to the user with some url like http://www.example.com/download.php?key=asjkdhg439s43
And make the script something like this:
Code:

$key = mysql_real_escape_string($_GET['key']);
$download = mysql_fetch_object(mysql_query('SELECT * FROM keys WHERE key='.$key));
if (isset($download->filepath) AND file_exists($download->filepath)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($download->filepath));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($download->filepath));
    ob_clean();
    flush();
    readfile($download->filepath);
    exit;
}


edit: oh forgot to check the date, you'll probably be able to figure that out
imagefree
rvec wrote:
Put this in your database:
datetime (created_on) | varchar (key) | varchar (filepath)

When you make a new link put the current time in the "created on" column and a random key in the "key" column. Send a mail to the user with some url like http://www.example.com/download.php?key=asjkdhg439s43
And make the script something like this:
Code:

$key = mysql_real_escape_string($_GET['key']);
$download = mysql_fetch_object(mysql_query('SELECT * FROM keys WHERE key='.$key));
if (isset($download->filepath) AND file_exists($download->filepath)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($download->filepath));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($download->filepath));
    ob_clean();
    flush();
    readfile($download->filepath);
    exit;
}


edit: oh forgot to check the date, you'll probably be able to figure that out



whats the use of clean and then flush

Code:
    ob_clean();
    flush();

before sending file?
AftershockVibe
You may also want to create a cron job which executes periodically to clean out the expired keys, unless you want to leave the data there for some reason. Otherwise you're going to just have a table mostly full of useless keys. That said, you're going to need to have hundreds of thousands before this affects performance.

ob_clean() and flush() ensure that the headers you just specified are sent to the browser before the file data is sent. This ensures that the browser gets the information that the data you are about to send is, in fact, data so it will treat it as a download, not a web page for rendering.
medesignz
I'm a complete ignoramus when it come to PHP and MySQL...

DATETIME... you're looking at an idiot Smile

Please can you explain, or maybe point me to some tutorials,

Thanks
rvec
start here:
http://www.frihost.com/forums/vt-92218.html
medesignz
Using the PHP date function into a hidden input on submit, and then a combination of the date comparison javascript and php recalling script, do you think I can get the desired goal? This relieves me for the fact I am a cretin to TIMESTAMPS... Laughing
tukun2009manit
medesignz wrote:
I want to be able to send an automated email response (to a sign up) that has a link to a download file/page which expires after 48hrs.

Any tips please...


i also want to do the same thing if you get the above tell me
rvec
read the rest of the topic ... Confused
Related topics
Illegal website and illegal downloads!
A "small" list of free apps
do you think free download of mp3s should be legal or not?
Free Online Games (Do not make more new threads about this)
Excellent free IMAP email
Get free download here!!
Bryce 5 offered for free download by DAZ
kumar/war 1st person shooter with mulitplay free download
Any free download for CS(Counter Strike)?
My Music site for free download
Some useful DVD converter Software Free Download
my free download manger problem
Virus protection free download for windows 7
10 free antivirus programs for Windows
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.