From 28b41056e3ea962dce1ad017a3c0a60252195e7a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 27 May 2009 15:07:27 -0700 Subject: Restructure things so that the application is now just another module. Kohana makes this type of transition fairly straightforward in that all controllers/helpers/etc are still located in the cascading filesystem without any extra effort, except that I've temporarily added a hack to force modules/gallery into the module path. Rename what's left of "core" to be "application" so that it conforms more closely to the Kohana standard (basically, just application/config/config.php which is the minimal thing that you need in the application directory) There's still considerable work left to be done here. --- core/controllers/file_proxy.php | 120 ---------------------------------------- 1 file changed, 120 deletions(-) delete mode 100644 core/controllers/file_proxy.php (limited to 'core/controllers/file_proxy.php') diff --git a/core/controllers/file_proxy.php b/core/controllers/file_proxy.php deleted file mode 100644 index f3c5f109..00000000 --- a/core/controllers/file_proxy.php +++ /dev/null @@ -1,120 +0,0 @@ -input->server("REQUEST_URI"); - $request_uri = preg_replace("/\?.*/", "", $request_uri); - - // var_uri: http://example.com/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) { - kohana::show_404(); - } - - $file = substr($request_uri, strlen($var_uri)); - - // Make sure that we don't leave the var dir - if (strpos($file, "..") !== false) { - kohana::show_404(); - } - - // We only handle var/resizes and var/albums - $paths = explode("/", $file); - $type = $paths[0]; - if ($type != "resizes" && $type != "albums" && $type != "thumbs") { - kohana::show_404(); - } - - // If the last element is .album.jpg, pop that off since it's not a real item - if ($paths[count($paths)-1] == ".album.jpg") { - array_pop($paths); - } - if ($paths[count($paths)-1] == "") { - array_pop($paths); - } - - // Find all items that match the level and name, then iterate over those to find a match. - // In most cases we'll get it in one. Note that for the level calculation, we just count the - // size of $paths. $paths includes the type ("thumbs", etc) but it doesn't include the root, - // so it's a wash. - $count = count($paths); - $compare_file = VARPATH . $file; - $item = null; - foreach (ORM::factory("item") - ->where("name", $paths[$count - 1]) - ->where("level", $count) - ->find_all() as $match) { - if ($type == "albums") { - $match_file = $match->file_path(); - } else if ($type == "resizes") { - $match_file = $match->resize_path(); - } else { - $match_file = $match->thumb_path(); - } - if ($match_file == $compare_file) { - $item = $match; - break; - } - } - - if (!$item) { - kohana::show_404(); - } - - // Make sure we have access to the item - if (!access::can("view", $item)) { - kohana::show_404(); - } - - // Make sure we have view_full access to the original - if ($type == "albums" && !access::can("view_full", $item)) { - kohana::show_404(); - } - - // Don't try to load a directory - if ($type == "albums" && $item->is_album()) { - kohana::show_404(); - } - - if (!file_exists($match_file)) { - kohana::show_404(); - } - - // Dump out the image - header("Content-Type: $item->mime_type"); - Kohana::close_buffers(false); - $fd = fopen($match_file, "rb"); - fpassthru($fd); - fclose($fd); - } -} -- cgit v1.2.3