Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<?php
$email=$_GET["id"];
?>
<?php
$con = mysql_connect(connection info);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$result = mysql_query("SELECT * FROM expiring_link_signups WHERE email='$email'");
while($row = mysql_fetch_array($result))
{
echo $row['created_on'];
}
?>
<script>
var myDate=new Date();
myDate.setFullYear($row['created_on']);
var today = new Date();
if (myDate<today)
{
document.write("<meta http-equiv=REFRESH CONTENT='5; url=DOWNLOAD LINK'> </head><body>Your download should begin in five seconds.</body></html>");
}
else
{
alert("Your download has expired");
}
</script>
create table if not exists
expiring_link_signups (
id int(10) not null auto_increment primary key,
link varchar(255) not null,
userID int(10) not null,
ts timestamp DEFAULT CURRENT_TIMESTAMP
)
insert into expiring_link_signups
(id, link, userID)
values
(NULL, 'mylinkaddress', relevantuserID)
$query = "select * from expiring_link_signups where userID='userID' and id='id' and TIMESTAMPDIFF(SECOND,ts, now()) < 86400";
$results = mysql_query($query) or die (mysql_error());
if (mysql_num_rows() > 0 ){
$row = mysql_fetch_assoc($results);
//serve the file
readfile($row['link']);
} else {
echo 'no documents available to download';
}
pruneDatabase();
//this deletes expired links.
function pruneDatabase(){
$query = "delete from expiring_link_signup where TIMESTAMPDIFF(SECOND,ts, now()) >= 86400";
mysql_query($query) or die (mysql_error());
}