<?php
session_set_cookie_params(10800);
session_start();
?>

<?php
$file = fopen("counter.txt","r+") or die("Cannot open file for reading");
$counter = fgets($file, 10);
if($counter == "")
{
   $counter = 0;
}
if(!isset($_SESSION['counter_ip']))
{
   $counter = $counter + 1;
   rewind($file);
   fwrite($file, $counter);
   $_SESSION['counter_ip'] = true;
}
else
{
   echo "Want to download PANDA again? Go ahead!";
}
fclose($file);
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
<!--
function delayer(){
    window.location = "downloads/current_panda.tar"
}
//-->
</script>
<title>Download PANDA</title>
</head>
<body onLoad="setTimeout('delayer()', 100)">
<H2>Thanks for downloading PANDA!</H2>
Click <a href="downloads/current_panda.tar">here</a> if the download doesn't start immediately.<BR>
<script type="text/javascript">
    document.write('<a href="' + document.referrer + '">Go back to the previous page.<\/a>');
</script>
</body>
</html>
