Not really much in the way of a question at this point, more of an inquiry. On my site, on June 1st, I will have the index.php page loaded as this chunk of code. My intention is to give viewers an opportunity to download a file for 24 hrs. Once the 24 hrs is up the script should unlink the file in question as well as itself. I guess my question (if any) is do I understand the unlink function correctly? will this in essence delete the opening page and the file or will people still be able to access the opening page and file if they type in the URL to the resource? If I have to delete it manually than I will, I would just rather automate as much of the process as possible:
Code: Select all
<a href="http://www.mywebsite.com/fileToDownload.zip"><img src="http://www.mywebsite.com/images/picForFile.jpg" width="450" alt="Pic For File" /></a><br />
<?php
countdown(6,1,24,0,0);
function countdown($month, $day, $hour, $minute, $second)
{
$the_countdown_date = mktime($hour, $minute, $second, $month, $day);
$today = time();
$difference = $the_countdown_date - $today;
if ($difference < 0) $difference = 0;
$days_left = floor($difference/60/60/24);
$hours_left = floor(($difference - $days_left*60*60*24)/60/60);
$minutes_left = floor(($difference - $days_left*60*60*24 - $hours_left*60*60)/60);
$seconds_left = floor((($difference - $days_left*60*60*24 - $hours_left*60*60 - $minutes_left*60)*60)/60);
if ($the_countdown_date == $today) {
$myJunk = "fileToDownload.zip";
$myOtherJunk = "index.php";
unlink($myJunk);
unlink($myOtherJunk);
}
echo "For the next " .$days_left. " days " .$hours_left."h : ".$minutes_left."m : " .$seconds_left."s<br /> ";
echo "download this file for free!<br />";
echo '<a href="http://www.mywebsite.com/index2.php">Enter the site!</a>';
}
?>