diff --git a/common/code/boost_archive.php b/common/code/boost_archive.php index d142ff51..0addb5a8 100644 --- a/common/code/boost_archive.php +++ b/common/code/boost_archive.php @@ -118,7 +118,8 @@ function display_from_archive( .' '.escapeshellarg($params['file']); if($extractor == 'raw') { - display_raw_file($unzip, $type, $expires); + raw_headers($type, $expires); + if($_SERVER['REQUEST_METHOD'] != 'HEAD') display_raw_file($unzip, $type); return; } @@ -137,7 +138,8 @@ function display_from_archive( else { if($extractor == 'raw') { - display_unzipped_file($params['file'], $type, $expires); + raw_headers($type, $expires); + if($_SERVER['REQUEST_METHOD'] != 'HEAD') readfile($params['file']); return; } @@ -223,8 +225,8 @@ HTML; } } -function display_raw_file($unzip, $type, $expires = null) - { +function raw_headers($type, $expires = null) +{ header('Content-type: '.$type); switch($type) { case 'image/png': @@ -242,11 +244,10 @@ function display_raw_file($unzip, $type, $expires = null) header('Cache-Control: max-age='.strtotime($expires, 0)); } } +} - // Since we're not returning a HTTP error for non-existant files, - // might as well not bother checking for the file - if($_SERVER['REQUEST_METHOD'] == 'HEAD') return; - +function display_raw_file($unzip, $type) +{ ## header('Content-Disposition: attachment; filename="downloaded.pdf"'); $file_handle = popen($unzip,'rb'); fpassthru($file_handle); @@ -259,39 +260,6 @@ function display_raw_file($unzip, $type, $expires = null) echo 'Error extracting file: '.unzip_error($exit_status); }; -function display_unzipped_file($file, $type, $expires = null) { - header('Content-type: '.$type); - switch($type) { - case 'image/png': - case 'image/gif': - case 'image/jpeg': - case 'text/css': - case 'application/x-javascript': - case 'application/pdf': - case 'application/xml-dtd': - header('Expires: '.date(DATE_RFC2822, strtotime("+1 year"))); - header('Cache-Control: max-age=31556926'); // A year, give or take a day. - default: - if($expires) { - header('Expires: '.date(DATE_RFC2822, strtotime($expires))); - header('Cache-Control: max-age='.strtotime($expires, 0)); - } - } - - // Since we're not returning a HTTP error for non-existant files, - // might as well not bother checking for the file - if($_SERVER['REQUEST_METHOD'] == 'HEAD') return; - - ## header('Content-Disposition: attachment; filename="downloaded.pdf"'); - $file_handle = fopen($file,'rb'); - // TODO: Check $file_handle (should be okay, because already checked for file). - fpassthru($file_handle); - $exit_status = fclose($file_handle); - - // TODO: What if !$exit_status? -}; - - function extract_file($unzip, &$content) { header('Expires: '.date(DATE_RFC2822, strtotime("+1 month"))); header('Cache-Control: max-age=2592000'); // 30 days @@ -361,7 +329,7 @@ function boost_book_html_filter($params) { function boost_book_html_filter_content($params) { - $text = prepare_html($params['content']); + $text = prepare_html($params['content'], true); $text = substr($text,strpos($text,'