diff --git a/src/_h5ai/server/php/inc/class-app.php b/src/_h5ai/server/php/inc/class-app.php index d401b7ba..88c685f9 100644 --- a/src/_h5ai/server/php/inc/class-app.php +++ b/src/_h5ai/server/php/inc/class-app.php @@ -238,10 +238,28 @@ class App { } - public function get_fallback() { + private function get_current_path() { + + $uri_parts = parse_url(getenv("REQUEST_URI")); + $current_href = Util::normalize_path($uri_parts["path"], true); + $current_path = $this->to_path($current_href); + + if (!is_dir($current_path)) { + $current_path = Util::normalize_path(dirname($current_path), false); + } + + return $current_path; + } + + + public function get_fallback($path = null) { + + if (!$path) { + $path = $this->get_current_path(); + } $cache = array(); - $folder = Item::get($this, CURRENT_PATH, $cache); + $folder = Item::get($this, $path, $cache); $items = $folder->get_content($cache); uasort($items, array("Item", "cmp")); diff --git a/src/_h5ai/server/php/inc/class-bootstrap.php b/src/_h5ai/server/php/inc/class-bootstrap.php index 4122868d..36901e97 100644 --- a/src/_h5ai/server/php/inc/class-bootstrap.php +++ b/src/_h5ai/server/php/inc/class-bootstrap.php @@ -90,17 +90,6 @@ class Bootstrap { define("ROOT_HREF", Util::normalize_path(dirname(APP_HREF), true)); define("ROOT_PATH", Util::normalize_path(dirname(APP_PATH), false)); - $uri_parts = parse_url(getenv("REQUEST_URI")); - $current_href = Util::normalize_path($uri_parts["path"], true); - $rel_href = substr($current_href, strlen(ROOT_HREF)); - $current_path = Util::normalize_path(ROOT_PATH . "/" . rawurldecode($rel_href)); - if (!is_dir($current_path)) { - $current_href = Util::normalize_path(dirname($current_href), true); - $current_path = Util::normalize_path(dirname($current_path), false); - } - define("CURRENT_HREF", $current_href); - define("CURRENT_PATH", $current_path); - $index_href = null; if (@is_readable(Util::normalize_path(APP_PATH . "/server/php/index.php", false))) { $index_href = Util::normalize_path(APP_HREF . "/server/php/index.php", false);