45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
$file = $_REQUEST['q'];
|
|
$type = $_REQUEST['type'];
|
|
if (empty($type) == false) {
|
|
switch ($type) {
|
|
case 'pdf':
|
|
$content_type = 'application/pdf';
|
|
break;
|
|
case 'logos':
|
|
$explode = explode('.', $file);
|
|
switch ($explode[1]) {
|
|
case 'png' : $content_type = 'image/png'; break;
|
|
case 'gif' : $content_type = 'image/gif'; break;
|
|
case 'jpeg':
|
|
case 'jpg' : $content_type = 'image/jpeg'; break;
|
|
}
|
|
break;
|
|
case 'consommation':
|
|
$content_type = 'application/csv-tab-delimited-table';
|
|
break;
|
|
case 'surveillance':
|
|
$content_type = 'application/csv-tab-delimited-table';
|
|
break;
|
|
default:
|
|
exit;
|
|
break;
|
|
}
|
|
$path = PATH_DATA.'/'.$type.'/';
|
|
} else {
|
|
$path = PATH_DATA.'/';
|
|
}
|
|
$firephp->log($path.$file, 'path');
|
|
if (file_exists($path.$file)) {
|
|
header('Content-Transfer-Encoding: none');
|
|
header('Content-type: '.$content_type.'');
|
|
header('Content-Length: '.filesize($path.$file));
|
|
header('Content-MD5: '.base64_encode(md5_file($path.$file)));
|
|
header('Content-Disposition: filename="'.basename($path.$file).'"');
|
|
header('Cache-Control: private, max-age=0, must-revalidate');
|
|
header('Pragma: public');
|
|
ini_set('zlib.output_compression', '0');
|
|
echo file_get_contents($path.$file);
|
|
}
|
|
?>
|