viewing paste Unknown #5764 | Plain text

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
<?
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";
       
}
?>
Viewed 307 times, submitted by Xgear.