67 lines
2.1 KiB
PHP
67 lines
2.1 KiB
PHP
<?php
|
|
require_once '../config/prepend.php';
|
|
//Gestion des paramètres
|
|
$q = isset($_REQUEST['q']) ? $_REQUEST['q'] : '' ;
|
|
$params = explode('/', $q);
|
|
$type = $params[0];
|
|
$file = $params[1];
|
|
|
|
//Gestion des types
|
|
switch ( $type ) {
|
|
case 'pdf':
|
|
$content_type = 'application/pdf';
|
|
$path = PATH_DATA.'/'.$type.'/';
|
|
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;
|
|
}
|
|
$path = PATH_DATA.'/'.$type.'/';
|
|
break;
|
|
case 'imgcache':
|
|
$content_type = 'image/png';
|
|
$path = PATH_SITE.'/cache/imgcache/';
|
|
break;
|
|
case 'consommation': /*@todo : A changer*/
|
|
$content_type = 'application/csv-tab-delimited-table';
|
|
$path = PATH_DATA.'/'.$type.'/';
|
|
break;
|
|
case 'surveillance': /*@todo : A changer*/
|
|
$content_type = 'application/csv-tab-delimited-table';
|
|
$path = PATH_DATA.'/'.$type.'/';
|
|
break;
|
|
case 'portefeuille': /*@todo : A changer*/
|
|
$content_type = 'application/csv-tab-delimited-table';
|
|
$path = PATH_DATA.'/'.$type.'/';
|
|
break;
|
|
case 'kbis':
|
|
$path = PATH_DATA.'/infogreffe/'.$type.'/';
|
|
$content_type = 'application/pdf';
|
|
break;
|
|
case 'commentaires':
|
|
$content_type = 'application/pdf';
|
|
$path = PATH_DATA.'/'.$type.'/';
|
|
break;
|
|
default:
|
|
exit;
|
|
break;
|
|
}
|
|
|
|
//Envoi du fichier sur la sortie standard
|
|
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);
|
|
} else {
|
|
echo 'Impossible de charger le fichier.';
|
|
} |