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 | |
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')
-rw-r--r-- | modules/digibug/controllers/digibug.php | 25 | ||||
-rw-r--r-- | modules/digibug/helpers/digibug_theme.php | 15 |
2 files changed, 27 insertions, 13 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 diff --git a/modules/digibug/helpers/digibug_theme.php b/modules/digibug/helpers/digibug_theme.php index 2e44b115..0fe2ce2e 100644 --- a/modules/digibug/helpers/digibug_theme.php +++ b/modules/digibug/helpers/digibug_theme.php @@ -32,16 +32,11 @@ class digibug_theme_Core { static function thumb_bottom($theme, $child) { if ($theme->page_type() == "album" && $child->type == "photo") { - $csrf = access::csrf_token(); - $return = "album/{$child->parent()->id}"; - $href = url::site("digibug/print_photo/$child->id?csrf={$csrf}&return=$return"); - $title = t("Print photo with Digibug"); - return "<div class=\"gDigibugPrintButton\"> - <a class=\"gButtonLink ui-corner-all ui-state-default ui-icon-left\" href=\"$href\" - title=\"$title\"> - <span class=\"ui-icon ui-icon-print\">$title</span> - </a> - </div>"; + $v = new View("digibug_album.html"); + $v->id = $child->id; + $v->return = "album/{$child->parent()->id}"; + $v->title = t("Print photo with Digibug"); + return $v->render(); } return ""; } |