Location: PHPKode > projects > RCS Man on the Web > RCSManager-0.2/download.php
<?php
/**
 * $Id$
 * $Log$
 */

require("config.php");

function send_file($file)
{
  GLOBAL $msg;
  if(!is_file($file))
  {
    $msg = "File does not exist.";
    return(false);
  }
  $size = filesize($file);
  $fd = fopen($file, "r");
  if($fd == false)
  {
    $msg = "Can't open file.";
    return(false);    
  }
  header("HTTP/1.1 200 OK");
  header("Expires: Mon, 10 Jul 1978 13:45:00 GMT");
  header("Content-Type: application/octet-stream");
  header("Content-Length: $size");
  header("Content-Disposition: attachment; filename=" . urlencode(basename($file)));
  echo fread($fd, $size);
  fclose($fd);
  return(true);
}

if(isset($id))
{
  $id=stripslashes(urldecode($id));
  switch($type)
  {
    case "rcsfile":
      $file = TmpDIR . "/$id";
      if(send_file($file))
      {
	unlink($file);
	exit();
      }
      break;

    case "sysfile":
      if(send_file(BASE_dir . "/$id"))
	exit();
      break;
  }
}

header("HTTP/1.0 404 Not Found");
header("Expires: Mon, 10 Jul 1978 13:45:00 GMT");
header("Content-Type: text/html");
?>

<html>
  <head>
    <title>restart it !</title>
    <base href="<?php echo BASE_url; ?>">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  </head>
  <body>
    <h1>Erreur: Non-disponible</h1>
    La ressource dynamique -* <?php echo "$id" ?> *- n'est plus disponible.<br>
    msg: <?php echo $msg ?>
  </body>
</html>
Return current item: RCS Man on the Web