linea21-core
[ class tree: linea21-core ] [ index: linea21-core ] [ all elements ]

Source for file dl.php

Documentation is available at dl.php

  1. <?php
  2. /**
  3.  * @package linea21.core
  4.  * @subpackage library
  5.  * @author Simon Georget <simon@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  */
  10. include_once('../config/define.php');
  11.  
  12. $file str_replace('//''/'SITE_PATH '/' $_REQUEST['file']);
  13.  
  14. if (file_exists($file)) {
  15.   // default type
  16.   $m 'application/octet-stream';
  17.   if(function_exists('finfo_file')) {
  18.     $finfo finfo_open(FILEINFO_MIME_TYPE);
  19.     $m finfo_file($finfo$file);
  20.     $m mime_content_type($file);
  21.     finfo_close($finfo);
  22.   else {
  23.     if(function_exists('mime_content_type')) $m mime_content_type($file);
  24.   }
  25.  
  26.   header('Content-Description: File Transfer');
  27.   header('Content-Type: '.$m);
  28.   header('Content-Disposition: attachment; filename='.basename($file));
  29.   header('Content-Transfer-Encoding: binary');
  30.   header('Expires: 0');
  31.   header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  32.   header('Pragma: public');
  33.   header('Content-Length: ' filesize($file));
  34.   ob_clean();
  35.   flush();
  36.   readfile($file);
  37.   exit;
  38. }
  39. ?>

Documentation generated on Thu, 03 May 2012 15:04:26 +0200 by phpDocumentor 1.4.1