diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-01-08 15:37:24 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-01-08 15:37:24 -0800 |
commit | 5a8d48a86953781c682be7c8052ae804c65f7e3b (patch) | |
tree | 9425dd46f8997860a29b16d16a4d667336940ec8 | |
parent | 9864ab4b2708ec54c39092a21828403cbbd25e2e (diff) | |
parent | bd9f945e3f2de4ea2402bd3941dba69c79ddc5a4 (diff) |
Merge branch 'master' of git@github.com:gallery/gallery3 into bharat_dev
-rw-r--r-- | modules/gallery/controllers/file_proxy.php | 37 | ||||
-rw-r--r-- | modules/gallery/libraries/Theme_View.php | 5 | ||||
-rw-r--r-- | modules/slideshow/helpers/slideshow_theme.php | 2 | ||||
-rw-r--r-- | system/helpers/expires.php | 1 |
4 files changed, 26 insertions, 19 deletions
diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index f0a38fbe..646edf17 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -28,16 +28,17 @@ */ class File_Proxy_Controller extends Controller { public function __call($function, $args) { - // request_uri: http://example.com/gallery3/var/trunk/albums/foo/bar.jpg - $request_uri = Input::instance()->server("REQUEST_URI"); + // request_uri: gallery3/var/trunk/albums/foo/bar.jpg + $request_uri = rawurldecode(Input::instance()->server("REQUEST_URI")); + $request_uri = preg_replace("/\?.*/", "", $request_uri); - // var_uri: http://example.com/gallery3/var/ + // var_uri: gallery3/var/ $var_uri = url::file("var/"); // Make sure that the request is for a file inside var - $offset = strpos($request_uri, $var_uri); - if ($offset === false) { + $offset = strpos(rawurldecode($request_uri), $var_uri); + if ($offset !== 0) { throw new Kohana_404_Exception(); } @@ -55,9 +56,16 @@ class File_Proxy_Controller extends Controller { // If the last element is .album.jpg, pop that off since it's not a real item $path = preg_replace("|/.album.jpg$|", "", $path); + $encoded_path = array(); + foreach (explode("/", $path) as $path_part) { + $encoded_path[] = rawurlencode($path_part); + } // We now have the relative path to the item. Search for it in the path cache - $item = ORM::factory("item")->where("relative_path_cache", "=", $path)->find(); + // The patch cache is urlencoded so re-encode the path. (it was decoded earlier to + // insure that the paths are normalized. + $item = ORM::factory("item") + ->where("relative_path_cache", "=", implode("/", $encoded_path))->find(); if (!$item->loaded()) { // We didn't turn it up. It's possible that the relative_path_cache is out of date here. // There was fallback code, but bharat deleted it in 8f1bca74. If it turns out to be @@ -81,14 +89,6 @@ class File_Proxy_Controller extends Controller { throw new Kohana_404_Exception(); } - if ($type == "albums") { - $file = $item->file_path(); - } else if ($type == "resizes") { - $file = $item->resize_path(); - } else { - $file = $item->thumb_path(); - } - // Make sure we have access to the item if (!access::can("view", $item)) { throw new Kohana_404_Exception(); @@ -104,11 +104,18 @@ class File_Proxy_Controller extends Controller { throw new Kohana_404_Exception(); } + if ($type == "albums") { + $file = $item->file_path(); + } else if ($type == "resizes") { + $file = $item->resize_path(); + } else { + $file = $item->thumb_path(); + } + if (!file_exists($file)) { throw new Kohana_404_Exception(); } - header('Last-Modified: '.gmdate('D, d M Y H:i:s T', $item->updated)); header("Pragma:"); // Check that the content hasn't expired or it wasn't changed since cached expires::check(2592000, $item->updated); diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index f78a7018..a6d1806c 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -278,9 +278,10 @@ class Theme_View_Core extends Gallery_View { } if (Session::instance()->get("debug")) { - if ($function != "head") { + if ($function != "head" && $function != "body_attributes") { array_unshift( - $blocks, "<div class=\"g-annotated-theme-block g-annotated-theme-block_$function g-clear-fix\">" . + $blocks, + "<div class=\"g-annotated-theme-block g-annotated-theme-block_$function g-clear-fix\">" . "<div class=\"title\">$function</div>"); $blocks[] = "</div>"; } diff --git a/modules/slideshow/helpers/slideshow_theme.php b/modules/slideshow/helpers/slideshow_theme.php index 163d2bd8..6aaf371c 100644 --- a/modules/slideshow/helpers/slideshow_theme.php +++ b/modules/slideshow/helpers/slideshow_theme.php @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class slideshow_theme_Core { - static function head($theme) { + static function page_bottom($theme) { $proto = (empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] === "off") ? "http" : "https"; return "<script src=\"$proto://apps.cooliris.com/slideshow/go.js\" " . "type=\"text/javascript\"></script>"; diff --git a/system/helpers/expires.php b/system/helpers/expires.php index 81468ce3..d510ba7c 100644 --- a/system/helpers/expires.php +++ b/system/helpers/expires.php @@ -82,7 +82,6 @@ class expires_Core { { $last_modified = $now; } - $max_age = $expires - time(); if ($modified <= $last_modified) { |