All pastes #200418 Raw Edit

Mine

public text v1 · immutable
#200418 ·published 2006-10-13 04:25 UTC
rendered paste body
<?php

$file_name="/home/files/shows/" . str_replace("..","",$_REQUEST['f']);
$filename = $_GET['f'];
if(ini_get('zlib.output_compression'))
  ini_set('zlib.output_compression', 'Off');

$file_extension = strtolower(substr(strrchr($filename,"."),1));

if( $filename == "" )
{
  echo "Not Valid";
  exit;
} elseif ( ! file_exists( $file_name ) )
{
  echo "Not Found";
  exit;
};
switch( $file_extension )
{
  case "zip": $ctype="application/zip"; break;
  default: $ctype="application/force-download";
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: $ctype");
header("Content-Disposition: attachment; filename=\"".basename($file_name)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($file_name));
readfile("$file_name");
exit();
?>