All pastes #468634 Raw Edit

Someone

public text v1 · immutable
·published 2007-05-03 07:43 UTC
rendered paste body
<?php 

define('FILE_APPEND', 1);
function file_put_contents($n, $d, $flag = false) {
    $mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w';
    $f = @fopen($n, $mode);
    if ($f === false) {
        return 0;
    } else {
        if (is_array($d)) $d = implode($d);
        $bytes_written = fwrite($f, $d);
        fclose($f);
        return $bytes_written;
    }
}

function get_file_contents($filename)
/* Returns the contents of file name passed
*/
{
if (!function_exists('file_get_contents'))
{
$fhandle = fopen($filename, "r");
$fcontents = fread($fhandle, filesize($filename));
fclose($fhandle);
}
else
{
$fcontents = file_get_contents($filename);
}
return $fcontents;
}


$filename = '..\Gahzette - Issue 2.pdf'; 
file_put_contents("stats.txt",get_file_contents("stats.txt") + 1);
 header('Content-type: application/pdf');
 header('Content-Disposition: attachment; filename="'.str_replace(array('.','/'),'',$filename).'"');
 readfile($filename); ?>