From: Jerome Jutteau Date: Thu, 7 May 2015 16:42:38 +0000 (+0200) Subject: add Content-MD5 header when downloading a file X-Git-Tag: 1.1~77^2 X-Git-Url: https://git.p6c8.net/jirafeau_project.git/commitdiff_plain/2fa05274bd24134ecf87bda06ce2626483ec3513 add Content-MD5 header when downloading a file Signed-off-by: Jerome Jutteau --- 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); +}