From 2fa05274bd24134ecf87bda06ce2626483ec3513 Mon Sep 17 00:00:00 2001 From: Jerome Jutteau Date: Thu, 7 May 2015 18:42:38 +0200 Subject: [PATCH] add Content-MD5 header when downloading a file Signed-off-by: Jerome Jutteau --- f.php | 1 + lib/functions.php | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/f.php b/f.php index 59717b9..99a67df 100644 --- a/f.php +++ b/f.php @@ -240,6 +240,7 @@ if (!jirafeau_is_viewable ($link['mime_type']) || !$cfg['preview'] || $do_downlo else header ('Content-Disposition: filename="' . $link['file_name'] . '"'); header ('Content-Type: ' . $link['mime_type']); +header ('Content-MD5: ' . hex_to_base64($link['md5'])); /* Read encrypted file. */ if ($link['crypted']) diff --git a/lib/functions.php b/lib/functions.php index 77acae1..1800231 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -1134,3 +1134,14 @@ function get_ip_address($cfg) { } return $_SERVER['REMOTE_ADDR']; } + +/** + * Convert hexadecimal string to base64 + */ +function hex_to_base64($hex) +{ + $b = ''; + foreach (str_split ($hex, 2) as $pair) + $b .= chr (hexdec ($pair)); + return base64_encode ($b); +} -- 2.34.1