aboutsummaryrefslogtreecommitdiff
path: root/mod/file/pages
diff options
context:
space:
mode:
Diffstat (limited to 'mod/file/pages')
-rw-r--r--mod/file/pages/file/download.php38
-rw-r--r--mod/file/pages/file/friends.php3
-rw-r--r--mod/file/pages/file/owner.php3
-rw-r--r--mod/file/pages/file/search.php7
-rw-r--r--mod/file/pages/file/view.php2
-rw-r--r--mod/file/pages/file/world.php3
6 files changed, 54 insertions, 2 deletions
diff --git a/mod/file/pages/file/download.php b/mod/file/pages/file/download.php
new file mode 100644
index 000000000..00e6d500e
--- /dev/null
+++ b/mod/file/pages/file/download.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Elgg file download.
+ *
+ * @package ElggFile
+ */
+
+// Get the guid
+$file_guid = get_input("guid");
+
+// Get the file
+$file = get_entity($file_guid);
+if (!$file) {
+ register_error(elgg_echo("file:downloadfailed"));
+ forward();
+}
+
+$mime = $file->getMimeType();
+if (!$mime) {
+ $mime = "application/octet-stream";
+}
+
+$filename = $file->originalfilename;
+
+// fix for IE https issue
+header("Pragma: public");
+
+header("Content-type: $mime");
+if (strpos($mime, "image/") !== false) {
+ header("Content-Disposition: inline; filename=\"$filename\"");
+} else {
+ header("Content-Disposition: attachment; filename=\"$filename\"");
+}
+
+ob_clean();
+flush();
+readfile($file->getFilenameOnFilestore());
+exit;
diff --git a/mod/file/pages/file/friends.php b/mod/file/pages/file/friends.php
index 0b351efaf..f504bdc1f 100644
--- a/mod/file/pages/file/friends.php
+++ b/mod/file/pages/file/friends.php
@@ -6,6 +6,9 @@
*/
$owner = elgg_get_page_owner_entity();
+if (!$owner) {
+ forward('file/all');
+}
elgg_push_breadcrumb(elgg_echo('file'), "file/all");
elgg_push_breadcrumb($owner->name, "file/owner/$owner->username");
diff --git a/mod/file/pages/file/owner.php b/mod/file/pages/file/owner.php
index 4e2ec89d4..fb87af1b2 100644
--- a/mod/file/pages/file/owner.php
+++ b/mod/file/pages/file/owner.php
@@ -9,6 +9,9 @@
group_gatekeeper();
$owner = elgg_get_page_owner_entity();
+if (!$owner) {
+ forward('file/all');
+}
elgg_push_breadcrumb(elgg_echo('file'), "file/all");
elgg_push_breadcrumb($owner->name);
diff --git a/mod/file/pages/file/search.php b/mod/file/pages/file/search.php
index 569657fd4..402a28933 100644
--- a/mod/file/pages/file/search.php
+++ b/mod/file/pages/file/search.php
@@ -5,7 +5,12 @@
* @package ElggFile
*/
-$page_owner_guid = (int)get_input('page_owner', null);
+$page_owner_guid = get_input('page_owner', null);
+
+if ($page_owner_guid !== null) {
+ $page_owner_guid = sanitise_int($page_owner_guid);
+}
+
if ($page_owner_guid) {
elgg_set_page_owner_guid($page_owner_guid);
}
diff --git a/mod/file/pages/file/view.php b/mod/file/pages/file/view.php
index 50c55a74f..a571c9d68 100644
--- a/mod/file/pages/file/view.php
+++ b/mod/file/pages/file/view.php
@@ -28,7 +28,7 @@ $content .= elgg_view_comments($file);
elgg_register_menu_item('title', array(
'name' => 'download',
'text' => elgg_echo('file:download'),
- 'href' => "mod/file/download.php?file_guid=$file->guid",
+ 'href' => "file/download/$file->guid",
'link_class' => 'elgg-button elgg-button-action',
));
diff --git a/mod/file/pages/file/world.php b/mod/file/pages/file/world.php
index e438ca2f0..770dfd6e8 100644
--- a/mod/file/pages/file/world.php
+++ b/mod/file/pages/file/world.php
@@ -19,6 +19,9 @@ $content = elgg_list_entities(array(
'limit' => $limit,
'full_view' => FALSE
));
+if (!$content) {
+ $content = elgg_echo('file:none');
+}
$sidebar = file_get_type_cloud();
$sidebar = elgg_view('file/sidebar');