diff --git a/src/_h5ai/server/php/inc/core/class-app.php b/src/_h5ai/server/php/inc/core/class-app.php index e007fc1f..d5166539 100644 --- a/src/_h5ai/server/php/inc/core/class-app.php +++ b/src/_h5ai/server/php/inc/core/class-app.php @@ -10,7 +10,7 @@ class App { $this->request = $request; $this->setup = $setup; - $this->options = Util::load_commented_json($this->setup->get("APP_PATH") . "/conf/options.json"); + $this->options = Util::load_commented_json($this->setup->get('APP_PATH') . '/conf/options.json'); } public function get_request() { @@ -28,28 +28,28 @@ class App { return $this->options; } - public function query_option($keypath = "", $default = null) { + public function query_option($keypath = '', $default = null) { return Util::array_query($this->options, $keypath, $default); } public function get_types() { - return Util::load_commented_json($this->setup->get("APP_PATH") . "/conf/types.json"); + return Util::load_commented_json($this->setup->get('APP_PATH') . '/conf/types.json'); } public function login_admin($pass) { - $key = $this->setup->get("AS_ADMIN_SESSION_KEY"); - $hash = $this->setup->get("PASSHASH"); + $key = $this->setup->get('AS_ADMIN_SESSION_KEY'); + $hash = $this->setup->get('PASSHASH'); - $_SESSION[$key] = strcasecmp(hash("sha512", $pass), $hash) === 0; + $_SESSION[$key] = strcasecmp(hash('sha512', $pass), $hash) === 0; return $_SESSION[$key]; } public function logout_admin() { - $key = $this->setup->get("AS_ADMIN_SESSION_KEY"); + $key = $this->setup->get('AS_ADMIN_SESSION_KEY'); $_SESSION[$key] = false; return $_SESSION[$key]; @@ -57,32 +57,32 @@ class App { public function to_href($path, $trailing_slash = true) { - $rel_path = substr($path, strlen($this->setup->get("ROOT_PATH"))); - $parts = explode("/", $rel_path); + $rel_path = substr($path, strlen($this->setup->get('ROOT_PATH'))); + $parts = explode('/', $rel_path); $encoded_parts = []; foreach ($parts as $part) { - if ($part != "") { + if ($part != '') { $encoded_parts[] = rawurlencode($part); } } - return Util::normalize_path($this->setup->get("ROOT_HREF") . implode("/", $encoded_parts), $trailing_slash); + return Util::normalize_path($this->setup->get('ROOT_HREF') . implode('/', $encoded_parts), $trailing_slash); } public function to_path($href) { - $rel_href = substr($href, strlen($this->setup->get("ROOT_HREF"))); - return Util::normalize_path($this->setup->get("ROOT_PATH") . "/" . rawurldecode($rel_href)); + $rel_href = substr($href, strlen($this->setup->get('ROOT_HREF'))); + return Util::normalize_path($this->setup->get('ROOT_PATH') . '/' . rawurldecode($rel_href)); } public function is_hidden($name) { // always hide - if ($name === "." || $name === "..") { + if ($name === '.' || $name === '..') { return true; } - foreach ($this->query_option("view.hidden", []) as $re) { + foreach ($this->query_option('view.hidden', []) as $re) { $re = Util::wrap_pattern($re); if (preg_match($re, $name)) { return true; @@ -100,7 +100,7 @@ class App { if ( $this->is_hidden($name) || $this->is_hidden($this->to_href($path) . $name) - || (!is_readable($path .'/'. $name) && $this->query_option("view.hideIf403", false)) + || (!is_readable($path . '/' . $name) && $this->query_option('view.hideIf403', false)) ) { continue; } @@ -121,18 +121,18 @@ class App { return false; } - if ($path === $this->setup->get("APP_PATH") || strpos($path, $this->setup->get("APP_PATH") . '/') === 0) { + if ($path === $this->setup->get('APP_PATH') || strpos($path, $this->setup->get('APP_PATH') . '/') === 0) { return false; } - foreach ($this->query_option("view.unmanaged", []) as $name) { - if (file_exists($path . "/" . $name)) { + foreach ($this->query_option('view.unmanaged', []) as $name) { + if (file_exists($path . '/' . $name)) { return false; } } - while ($path !== $this->setup->get("ROOT_PATH")) { - if (@is_dir($path . "/_h5ai/server")) { + while ($path !== $this->setup->get('ROOT_PATH')) { + if (@is_dir($path . '/_h5ai/server')) { return false; } $parent_path = Util::normalize_path(dirname($path)); @@ -167,7 +167,7 @@ class App { $folder = $folder->get_parent($cache); } - uasort($cache, ["Item", "cmp"]); + uasort($cache, ['Item', 'cmp']); $result = []; foreach ($cache as $p => $item) { $result[] = $item->to_json_object(); @@ -179,13 +179,13 @@ class App { public function get_langs() { $langs = []; - $l10n_path = $this->setup->get("APP_PATH") . "/conf/l10n"; + $l10n_path = $this->setup->get('APP_PATH') . '/conf/l10n'; if (is_dir($l10n_path)) { if ($dir = opendir($l10n_path)) { while (($file = readdir($dir)) !== false) { - if (Util::ends_with($file, ".json")) { - $translations = Util::load_commented_json($l10n_path . "/" . $file); - $langs[basename($file, ".json")] = $translations["lang"]; + if (Util::ends_with($file, '.json')) { + $translations = Util::load_commented_json($l10n_path . '/' . $file); + $langs[basename($file, '.json')] = $translations['lang']; } } closedir($dir); @@ -200,9 +200,9 @@ class App { $results = []; foreach ($iso_codes as $iso_code) { - $file = $this->setup->get("APP_PATH") . "/conf/l10n/" . $iso_code . ".json"; + $file = $this->setup->get('APP_PATH') . '/conf/l10n/' . $iso_code . '.json'; $results[$iso_code] = Util::load_commented_json($file); - $results[$iso_code]["isoCode"] = $iso_code; + $results[$iso_code]['isoCode'] = $iso_code; } return $results; @@ -214,7 +214,7 @@ class App { foreach ($requests as $req) { $thumb = new Thumb($this); - $hrefs[] = $thumb->thumb($req["type"], $req["href"], $req["width"], $req["height"]); + $hrefs[] = $thumb->thumb($req['type'], $req['href'], $req['width'], $req['height']); } return $hrefs; diff --git a/src/_h5ai/server/php/inc/core/class-fallback.php b/src/_h5ai/server/php/inc/core/class-fallback.php index cdd30355..d59924eb 100644 --- a/src/_h5ai/server/php/inc/core/class-fallback.php +++ b/src/_h5ai/server/php/inc/core/class-fallback.php @@ -9,8 +9,8 @@ class Fallback { private function get_current_path() { - $uri_parts = parse_url(getenv("REQUEST_URI")); - $current_href = Util::normalize_path($uri_parts["path"], true); + $uri_parts = parse_url(getenv('REQUEST_URI')); + $current_href = Util::normalize_path($uri_parts['path'], true); $current_path = $this->app->to_path($current_href); if (!is_dir($current_path)) { @@ -26,12 +26,12 @@ class Fallback { $path = $this->get_current_path(); } - $app_href = $this->app->get_setup()->get("APP_HREF"); + $app_href = $this->app->get_setup()->get('APP_HREF'); $cache = []; $folder = Item::get($this->app, $path, $cache); $items = $folder->get_content($cache); - uasort($items, ["Item", "cmp"]); + uasort($items, ['Item', 'cmp']); $html = "
"; $html .= " | " . basename($item->path) . " | "; - $html .= "" . date("Y-m-d H:i", $item->date) . " | "; - $html .= "" . ($item->size !== null ? intval($item->size / 1000) . " KB" : "" ) . " | "; + $html .= "" . date('Y-m-d H:i', $item->date) . " | "; + $html .= "" . ($item->size !== null ? intval($item->size / 1000) . ' KB' : '' ) . " | "; $html .= "