loaded()) { throw new Kohana_404_Exception(); } // Make sure checksum matches, if not, throw a 404 error. if ($str_checksum != md5($item->created)) { throw new Kohana_404_Exception(); } // If the resize file doesn't exist for some reason, display a 404 error. if (!file_exists($item->resize_path())) { throw new Kohana_404_Exception(); } // Display the image. header("Content-Type: {$item->mime_type}"); Kohana::close_buffers(false); $fd = fopen($item->resize_path(), "rb"); fpassthru($fd); fclose($fd); } public function print_proxy($site_key, $file_id) { // This function retrieves the full-sized image for fotomoto. // As this function by-passes normal Gallery security, a private // site-key is used to try and prevent people other then fotomoto // from finding the URL. // If the site key doesn't match, display a 404 error. if ($site_key != module::get_var("fotomotorw", "fotomoto_private_key")) { throw new Kohana_404_Exception(); } // Load the photo from the provided id. If the id# is invalid, display a 404 error. $item = ORM::factory("item", $file_id); if (!$item->loaded()) { throw new Kohana_404_Exception(); } // If the image file doesn't exist for some reason, display a 404 error. if (!file_exists($item->file_path())) { throw new Kohana_404_Exception(); } // Display the image. header("Content-Type: {$item->mime_type}"); Kohana::close_buffers(false); $fd = fopen($item->file_path(), "rb"); fpassthru($fd); fclose($fd); } }