<?php
/**
* mod.output.php -> Make a file available for download
* @package phlyMail "Yokohama 2" 4.x Default Branch
* @subpackage Handler Files
* @copyright 2004-2009 phlyLabs, Berlin (http://phlylabs.de)
* @version 4.0.7 2009-05-21
*/
// Only valid within phlyMail
if (!defined('_IN_PHM_')) die();
require_once(dirname(__FILE__).'/fs.php');
$FS = new files_storage($_SESSION['phM_uid']);
$item = $FS->get_item_info($_REQUEST['item'], true);
$path = $FS->item_get_real_location($_REQUEST['item']);
$uid = $_SESSION['phM_uid'];
session_write_close();
unset($FS);
header('Content-Type: '.($item['type'] ? $item['type'] : 'application/octet-stream'));
if (!isset($_REQUEST['inline'])) {
header('Content-Disposition: attachment; filename="'.basename($item['friendly_name']).'"');
}
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.$item['size']);
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
header('Expires: Sat, 01 Jan 2000 00:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: public');
header('Content-Description: File Transfer');
} else {
header('Cache-Control: post-check=0, pre-check=0');
}
if ($fp = fopen($_PM_['path']['storage'].'/'.$uid.'/files/'.$path[0].'/'.$path[1], 'rb')) {
while((!feof($fp)) && (connection_status() == 0)) {
echo fread($fp, 1024*8);
flush();
}
fclose($fp);
}
exit;
?>