aboutsummaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/file/actions/file/upload.php25
-rw-r--r--mod/file/start.php8
2 files changed, 32 insertions, 1 deletions
diff --git a/mod/file/actions/file/upload.php b/mod/file/actions/file/upload.php
index 5242cbda2..d72d04eb7 100644
--- a/mod/file/actions/file/upload.php
+++ b/mod/file/actions/file/upload.php
@@ -94,8 +94,31 @@ if (isset($_FILES['upload']['name']) && !empty($_FILES['upload']['name'])) {
$filestorename = elgg_strtolower(time().$_FILES['upload']['name']);
}
- $mime_type = $file->detectMimeType($_FILES['upload']['tmp_name'], $_FILES['upload']['type']);
$file->setFilename($prefix . $filestorename);
+ $mime_type = ElggFile::detectMimeType($_FILES['upload']['tmp_name'], $_FILES['upload']['type']);
+
+ // hack for Microsoft zipped formats
+ $info = pathinfo($_FILES['upload']['name']);
+ $office_formats = array('docx', 'xlsx', 'pptx');
+ if ($mime_type == "application/zip" && in_array($info['extension'], $office_formats)) {
+ switch ($info['extension']) {
+ case 'docx':
+ $mime_type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
+ break;
+ case 'xlsx':
+ $mime_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
+ break;
+ case 'pptx':
+ $mime_type = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
+ break;
+ }
+ }
+
+ // check for bad ppt detection
+ if ($mime_type == "application/vnd.ms-office" && $info['extension'] == "ppt") {
+ $mime_type = "application/vnd.ms-powerpoint";
+ }
+
$file->setMimeType($mime_type);
$file->originalfilename = $_FILES['upload']['name'];
$file->simpletype = file_get_simple_type($mime_type);
diff --git a/mod/file/start.php b/mod/file/start.php
index 120129276..172042332 100644
--- a/mod/file/start.php
+++ b/mod/file/start.php
@@ -240,11 +240,15 @@ function file_get_simple_type($mimetype) {
switch ($mimetype) {
case "application/msword":
+ case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
return "document";
break;
case "application/pdf":
return "document";
break;
+ case "application/ogg":
+ return "audio";
+ break;
}
if (substr_count($mimetype, 'text/')) {
@@ -357,11 +361,15 @@ function file_icon_url_override($hook, $type, $returnvalue, $params) {
$mapping = array(
'application/excel' => 'excel',
'application/msword' => 'word',
+ 'application/ogg' => 'music',
'application/pdf' => 'pdf',
'application/powerpoint' => 'ppt',
'application/vnd.ms-excel' => 'excel',
'application/vnd.ms-powerpoint' => 'ppt',
'application/vnd.oasis.opendocument.text' => 'openoffice',
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'word',
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'excel',
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'ppt',
'application/x-gzip' => 'archive',
'application/x-rar-compressed' => 'archive',
'application/x-stuffit' => 'archive',