<?
DEFINE('DL_PATH',''); //Add trailing slash
isset($_GET['file'])?$rf = $_GET['file']:exit();
$path = DL_PATH . $rf;
if (file_exists(DL_PATH.$rf)) {
$fp = fopen('counter.php','r');
$count = fread($fp,4096);
fclose($fp);
$arr = json_decode($count,true);
$arr[$rf] = $arr[$rf]+1;
$fp = fopen('counter.php','w+');
fwrite($fp,json_encode($arr));
fclose($fp);
}
?>
<?php
$file = html_entity_decode(basename($rf));
if(!file_exists($path)):
header('HTTP/1.0 204 No Content');
header('Status: 204 No Content;');
else:
header('Content-Type: application/x-rar-compressed;');
header('Content-Disposition: attachment; filename=' . $rf . ';');
header('Content-Length: ' . sprintf('%u', filesize($path)) . ';');
readfile($path);
endif;
exit;
?>
<?
if (file_exists(DL_PATH.$rf)) {
$fp = fopen('counter.php','r');
$count = fread($fp,4096);
fclose($fp);
$arr = json_decode($count,true);
echo "File <b>$rf</b> has been downloaded <b>$arr[$rf]</b> times so far";
}
?>