Skip to content
Extraits de code Groupes Projets
Valider 1d2d5ac9 rédigé par cerdic's avatar cerdic Validation de marcimat
Parcourir les fichiers

refactor: utiliser la fonction interne du core `spip_livrer_fichier()`

parent aa873a40
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -89,42 +89,23 @@ function action_acceder_document_dist() { ...@@ -89,42 +89,23 @@ function action_acceder_document_dist() {
break; break;
default: default:
header('Content-Type: ' . $doc['mime_type']); include_spip('inc/livrer_fichier');
// pour les images ne pas passer en attachment
// sinon, lorsqu'on pointe directement sur leur adresse,
// le navigateur les downloade au lieu de les afficher
$options = ['attachment' => false];
if ($doc['inclus'] == 'non') { if ($doc['inclus'] == 'non') {
$options['attachment'] = true;
// Si le fichier a un titre avec extension, // Si le fichier a un titre avec extension,
// ou si c'est un nom bien connu d'Unix, le prendre // ou si c'est un nom bien connu d'Unix, le prendre
// sinon l'ignorer car certains navigateurs pataugent // sinon l'ignorer car certains navigateurs pataugent
$f = basename($file);
if ( if (
isset($doc['titre']) isset($doc['titre'])
and (preg_match('/^\w+[.]\w+$/', $doc['titre']) or $doc['titre'] == 'Makefile') and (preg_match('/^\w+[.]\w+$/', $doc['titre']) or $doc['titre'] == 'Makefile')
) { ) {
$f = $doc['titre']; $options['attachment'] = $doc['titre'];
} }
// ce content-type est necessaire pour eviter des corruptions de zip dans ie6
header('Content-Type: application/octet-stream');
header("Content-Disposition: attachment; filename=\"$f\";");
header('Content-Transfer-Encoding: binary');
// fix for IE catching or PHP bug issue
header('Pragma: public');
header('Expires: 0'); // set expiration time
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
}
if ($cl = filesize($file)) {
header('Content-Length: ' . $cl);
} }
spip_livrer_fichier($file, $doc['mime_type'], $options);
readfile($file); exit;
break; break;
} }
} }
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter