From 3bd5e571364385cb93a93b8526e1e90e56db7b49 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Fri, 11 Dec 2009 12:30:23 +0000 Subject: moved download action to download page --- actions/download.php | 52 ----------------------------------- start.php | 26 +++++------------- views/default/object/image.php | 2 +- views/default/tidypics/image_menu.php | 2 +- views/rss/object/album.php | 4 +-- views/rss/object/file.php | 2 +- 6 files changed, 12 insertions(+), 76 deletions(-) delete mode 100644 actions/download.php diff --git a/actions/download.php b/actions/download.php deleted file mode 100644 index b382c56bc..000000000 --- a/actions/download.php +++ /dev/null @@ -1,52 +0,0 @@ -originalfilename; - $mime = $file->mimetype; - - header("Content-Type: $mime"); - if ($view == "inline") - header("Content-Disposition: inline; filename=\"$filename\""); - else - header("Content-Disposition: attachment; filename=\"$filename\""); - - - $readfile = new ElggFile($file_guid); - $readfile->owner_guid = $file->owner_guid; - - $contents = $readfile->grabFile(); - - if (empty($contents)) { - echo file_get_contents(dirname(dirname(__FILE__)) . "/graphics/image_error_large.png" ); - } else { - - // expires every 60 days - $expires = 60 * 60*60*24; - - header("Content-Length: " . strlen($contents)); - header("Cache-Control: public", true); - header("Pragma: public", true); - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true); - - - echo $contents; - } - - exit; - } - else - register_error(elgg_echo("image:downloadfailed")); - -?> \ No newline at end of file diff --git a/start.php b/start.php index 54322d8c9..6a1b95723 100644 --- a/start.php +++ b/start.php @@ -72,10 +72,7 @@ } // slideshow plugin hook - register_plugin_hook('tp_slideshow', 'album', 'tidypics_slideshow'); - - // no checking security token for download - register_plugin_hook('action', 'tidypics/download', 'tidypics_download_override'); + register_plugin_hook('tp_slideshow', 'album', 'tidypics_slideshow'); } /** @@ -273,6 +270,12 @@ include($CONFIG->pluginspath . "tidypics/pages/world.php"); break; + case "download": // download an image + if (isset($page[1])) set_input('file_guid', $page[1]); + if (isset($page[2])) set_input('type', $page[2]); + include($CONFIG->pluginspath . "tidypics/pages/download.php"); + break; + case "tagged": // all photos tagged with user if (isset($page[1])) set_input('guid',$page[1]); include($CONFIG->pluginspath . "tidypics/pages/tagged.php"); @@ -425,20 +428,6 @@ function tp_mostrecentimages($max = 8, $pagination = true) { return list_entities("object", "image", 0, $max, false, false, $pagination); } - /** - * Called before validating the security token on a download link - * We don't need security as this is not a true action (it doesn't change any data) - * - * @return false (shouldn't return though since the action exits - */ - function tidypics_download_override($hook, $action) - { - global $CONFIG; - - include $CONFIG->actions[$action]['file']; - - return false; - } // Make sure tidypics_init is called on initialisation @@ -453,7 +442,6 @@ register_action("tidypics/edit", false, $CONFIG->pluginspath. "tidypics/actions/edit.php"); register_action("tidypics/delete", false, $CONFIG->pluginspath. "tidypics/actions/delete.php"); register_action("tidypics/edit_multi", false, $CONFIG->pluginspath. "tidypics/actions/edit_multi.php"); - register_action("tidypics/download", true, $CONFIG->pluginspath . "tidypics/actions/download.php"); register_action("tidypics/addtag", true, $CONFIG->pluginspath . "tidypics/actions/addtag.php"); register_action("tidypics/deletetag", true, $CONFIG->pluginspath . "tidypics/actions/deletetag.php"); register_action("tidypics/flickrSetup", true, $CONFIG->pluginspath . "tidypics/actions/flickrSetup.php"); diff --git a/views/default/object/image.php b/views/default/object/image.php index dd52f872e..fb7a72ff8 100644 --- a/views/default/object/image.php +++ b/views/default/object/image.php @@ -150,7 +150,7 @@ $image_link = false; if (get_plugin_setting('download_link', 'tidypics') != "disabled") { // admin allows downloads so default to inline download link - $image_link = $vars['url'] . "action/tidypics/download?file_guid=" . $image_guid . "&view=inline"; + $image_link = $vars['url'] . "pg/photos/download/{$image_guid}/inline/"; } // does any plugin want to override the link $image_link = trigger_plugin_hook('tp_image_link', 'image', $image, $image_link); diff --git a/views/default/tidypics/image_menu.php b/views/default/tidypics/image_menu.php index 5e6053a94..9e7a53969 100644 --- a/views/default/tidypics/image_menu.php +++ b/views/default/tidypics/image_menu.php @@ -43,7 +43,7 @@ } if (get_plugin_setting('download_link', 'tidypics') != "disabled") { - $download_url = $vars['url'] . "action/tidypics/download?file_guid=" . $image_guid; + $download_url = $vars['url'] . "pg/photos/download/{$image_guid}/"; ?>
  • cover) { @@ -52,7 +52,7 @@ time_created); ?> getURL(); ?> - + title; ?> description); ?> diff --git a/views/rss/object/file.php b/views/rss/object/file.php index ace3e28e6..e40da4f69 100644 --- a/views/rss/object/file.php +++ b/views/rss/object/file.php @@ -19,5 +19,5 @@ getURL(); ?> <![CDATA[<?php echo $title; ?>]]> description)); ?>]]> - + -- cgit v1.2.3