--- secure-files.php-orig Mon Oct 24 02:51:59 2005
+++ secure-files.php Mon Oct 24 03:22:15 2005
@@ -70,7 +70,21 @@
$downloadfile = $sf_directory . basename($downloadfile);
if (is_file($downloadfile)) {
header('Content-Description: File Transfer');
- header('Content-Type: application/force-download');
+ if (!extension_loaded('fileinfo')) {
+ if (!dl('fileinfo.' . PHP_SHLIB_SUFFIX)) {
+ header('Content-Type: application/force-download');
+ }
+
+ $res = finfo_open(FILEINFO_MIME);
+ $mime_type = finfo_file($res, $downloadfile);
+ finfo_close($res);
+ header('Content-Type: ' . $mime_type);
+ } else {
+ $res = finfo_open(FILEINFO_MIME);
+ $mime_type = finfo_file($res, $downloadfile);
+ finfo_close($res);
+ header('Content-Type: ' . $mime_type);
+ }
header('Content-Length: ' . filesize($downloadfile));
header('Content-Disposition: attachment; filename="' . basename($downloadfile).'"');
@readfile($downloadfile);
@@ -197,4 +211,4 @@
add_action('admin_head', 'sf_admin_head_js');
add_action('template_redirect', 'sf_downloads');
-?>
+?>
If the extension is not installed, it should fall back to the default one. Hope you might find it useful.
If you want the patch as an email attachment, shoot me an email and I'll be happy to resend it 'cause it looks like the BB software converts tabs to spaces and I can't seem to be able to attach a file.
Regards,
Pat