diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-06-23 06:06:33 -0700 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-06-23 06:06:33 -0700 |
commit | 8f443cef3e304c12f9e3555332880395051e7e3d (patch) | |
tree | 5e47e11035aff9edf02fc8a6599d1b34f5f5f588 /modules/digibug/controllers | |
parent | 3824f2b52fed7bbbd3e1c91eafff9df21be6c765 (diff) |
This change implements the print_proxy method. This method allows a 1 time
security bypass for the remote print processor to retrieve the fullsize image.
Diffstat (limited to 'modules/digibug/controllers')
-rw-r--r-- | modules/digibug/controllers/digibug.php | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/modules/digibug/controllers/digibug.php b/modules/digibug/controllers/digibug.php index f90b88e2..b0807aa5 100644 --- a/modules/digibug/controllers/digibug.php +++ b/modules/digibug/controllers/digibug.php @@ -51,24 +51,43 @@ class Digibug_Controller extends Controller { "thumb_width_1" => $item->thumb_width, "title" => $item->title); - Kohana::log("error", Kohana::debug($digibug_parms)); - message::success( t("Photo '%title' was submitted for printing.", array("title" => $item->title))); print json_encode(array("result" => "success", "reload" => 1)); } public function print_proxy($id, $thumb=null) { + $proxy = ORM::factory("proxy") + ->where("uuid", $id) + ->find(); + + if (!$proxy->loaded) { + Kohana::show_404(); + } + + if (!$proxy->item->loaded) { + Kohana::show_404(); + } + + $file = empty($thumb) ? $proxy->item->file_path() : $proxy->item->thumb_path(); + if (!file_exists($file)) { + kohana::show_404(); + } // We don't need to save the session for this request Session::abort_save(); // Dump out the image - header("Content-Type: $item->mime_type"); + header("Content-Type: $proxy->item->mime_type"); Kohana::close_buffers(false); $fd = fopen($file, "rb"); fpassthru($fd); fclose($fd); + + // If the request was for the image and not the thumb, then delete the proxy. + if (empty($thumb)) { + $proxy->delete(); + } } }
\ No newline at end of file |