diff --git a/src/_h5ai/client/css/inc/apache-autoindex-table.less b/src/_h5ai/client/css/inc/fallback-table.less similarity index 97% rename from src/_h5ai/client/css/inc/apache-autoindex-table.less rename to src/_h5ai/client/css/inc/fallback-table.less index 65fad4cf..963775f8 100644 --- a/src/_h5ai/client/css/inc/apache-autoindex-table.less +++ b/src/_h5ai/client/css/inc/fallback-table.less @@ -1,7 +1,7 @@ #data-apache-autoindex, #data-php-no-js-fallback { max-width: 960px; - margin: 0 auto; + margin: 0 auto 80px auto; table { display: block; diff --git a/src/_h5ai/client/css/styles.less b/src/_h5ai/client/css/styles.less index 25a8fbb2..631aba7d 100644 --- a/src/_h5ai/client/css/styles.less +++ b/src/_h5ai/client/css/styles.less @@ -26,7 +26,7 @@ @import "inc/extended-grid"; // @import "inc/context-menu"; @import "inc/dropbox"; -@import "inc/apache-autoindex-table"; +@import "inc/fallback-table"; @import "inc/responsive"; diff --git a/src/_h5ai/client/js/inc/core/ajax.js b/src/_h5ai/client/js/inc/core/ajax.js index 40c9c35f..55f6f310 100644 --- a/src/_h5ai/client/js/inc/core/ajax.js +++ b/src/_h5ai/client/js/inc/core/ajax.js @@ -29,13 +29,14 @@ modulejs.define('core/ajax', ['$', 'amplify', 'base64', 'core/resource'], functi $.ajax({ url: resource.api(), data: { - action: 'getchecks' + action: 'get', + checks: true }, type: 'POST', dataType: 'json', success: function (json) { - callback(json); + callback(json.checks); }, error: function () { @@ -44,19 +45,21 @@ modulejs.define('core/ajax', ['$', 'amplify', 'base64', 'core/resource'], functi }); }, - getEntries = function (href, content, callback) { + getEntries = function (href, what, callback) { $.ajax({ url: resource.api(), data: { - action: 'getentries', - href: href, - content: content + action: 'get', + entries: true, + entriesHref: href, + entriesWhat: what }, + type: 'POST', dataType: 'json', success: function (json) { - callback(json); + callback(json.entries); }, error: function () { @@ -154,6 +157,7 @@ modulejs.define('core/ajax', ['$', 'amplify', 'base64', 'core/resource'], functi $.ajax({ url: url, + type: 'POST', dataType: 'html', success: function (html) { diff --git a/src/_h5ai/client/js/inc/core/refresh.js b/src/_h5ai/client/js/inc/core/refresh.js index a8271cee..c5f7dfb0 100644 --- a/src/_h5ai/client/js/inc/core/refresh.js +++ b/src/_h5ai/client/js/inc/core/refresh.js @@ -5,7 +5,7 @@ modulejs.define('core/refresh', ['_', 'core/mode', 'core/ajax', 'model/entry'], var found = {}; - _.each(json.entries, function (jsonEntry) { + _.each(json, function (jsonEntry) { found[jsonEntry.absHref] = true; Entry.get(jsonEntry.absHref, jsonEntry.time, jsonEntry.size, jsonEntry.status, jsonEntry.content); diff --git a/src/_h5ai/server/php/api.php b/src/_h5ai/server/php/api.php index 17107fe5..0a8d9f38 100644 --- a/src/_h5ai/server/php/api.php +++ b/src/_h5ai/server/php/api.php @@ -1,14 +1,76 @@ get_options(); +$app = $APP; +$options = $app->get_options(); list($action) = use_request_params(array("action")); -if ($action === "getthumbsrc") { +if ($action === "get") { + + $response = array(); + + if (array_key_exists("options", $_REQUEST)) { + + use_request_params("options"); + $response["options"] = $app->get_options(); + } + + if (array_key_exists("types", $_REQUEST)) { + + use_request_params("types"); + $response["types"] = $app->get_types(); + } + + if (array_key_exists("langs", $_REQUEST)) { + + use_request_params("langs"); + $response["langs"] = $app->get_l10n_list(); + } + + if (array_key_exists("l10n", $_REQUEST)) { + + list($iso_codes) = use_request_params("l10nCodes", "l10n"); + $iso_codes = explode(",", $iso_codes); + $response["l10n"] = $app->get_l10n($iso_codes); + } + + if (array_key_exists("checks", $_REQUEST)) { + + use_request_params("checks"); + $response["checks"] = $app->get_server_checks(); + } + + if (array_key_exists("server", $_REQUEST)) { + + use_request_params("server"); + $response["server"] = $app->get_server_details(); + } + + if (array_key_exists("custom", $_REQUEST)) { + + list($abs_href) = use_request_params("customHref", "custom"); + $response["custom"] = $app->get_customizations($abs_href); + } + + if (array_key_exists("entries", $_REQUEST)) { + + list($abs_href, $what) = use_request_params("entriesHref", "entriesWhat", "entries"); + $what = intval($what, 10); + $response["entries"] = $app->get_entries($abs_href, $what); + } + + if (count($_REQUEST)) { + $response["unused"] = $_REQUEST; + } + + json_exit($response); +} + + +else if ($action === "getthumbsrc") { if (!$options["thumbnails"]["enabled"]) { json_fail(1, "thumbnails disabled"); @@ -21,7 +83,7 @@ if ($action === "getthumbsrc") { list($type, $srcAbsHref, $mode, $width, $height) = use_request_params(array("type", "href", "mode", "width", "height")); - $thumb = new Thumb($h5ai); + $thumb = new Thumb($app); $thumbHref = $thumb->thumb($type, $srcAbsHref, $mode, $width, $height); if ($thumbHref === null) { json_fail(3, "thumbnail creation failed"); @@ -38,7 +100,7 @@ else if ($action === "archive") { list($execution, $format, $hrefs) = use_request_params(array("execution", "format", "hrefs")); normalized_require_once("/server/php/inc/Archive.php"); - $archive = new Archive($h5ai); + $archive = new Archive($app); $hrefs = explode(":", trim($hrefs)); $target = $archive->create($execution, $format, $hrefs); @@ -58,7 +120,7 @@ else if ($action === "getarchive") { list($id, $as) = use_request_params(array("id", "as")); json_fail(2, "file not found", !preg_match("/^package-/", $id)); - $target = $h5ai->get_cache_abs_path() . "/" . $id; + $target = $app->get_cache_abs_path() . "/" . $id; json_fail(3, "file not found", !file_exists($target)); header("Content-Type: application/octet-stream"); @@ -70,46 +132,6 @@ else if ($action === "getarchive") { } -else if ($action === "getchecks") { - - $php = version_compare(PHP_VERSION, "5.2.1") >= 0; - $archive = class_exists("PharData"); - $gd = false; - if (function_exists("gd_info")) { - $gdinfo = gd_info(); - $gd = array_key_exists("JPG Support", $gdinfo) && $gdinfo["JPG Support"] || array_key_exists("JPEG Support", $gdinfo) && $gdinfo["JPEG Support"]; - } - $cache = @is_writable($h5ai->get_cache_abs_path()); - $tar = @preg_match("/tar$/", `which tar`) > 0; - $zip = @preg_match("/zip$/", `which zip`) > 0; - $convert = @preg_match("/convert$/", `which convert`) > 0; - $ffmpeg = @preg_match("/ffmpeg$/", `which ffmpeg`) > 0; - $du = @preg_match("/du$/", `which du`) > 0; - - json_exit(array( - "php" => $php, - "cache" => $cache, - "thumbs" => $gd, - "archive" => $archive, - "tar" => $tar, - "zip" => $zip, - "convert" => $convert, - "ffmpeg" => $ffmpeg, - "du" => $du - )); -} - - -else if ($action === "getentries") { - - list($href, $content) = use_request_params(array("href", "content")); - - $content = intval($content, 10); - - json_exit(array("entries" => $h5ai->get_entries($href, $content))); -} - - else if ($action === "upload") { list($href) = use_request_params(array("href")); @@ -122,10 +144,10 @@ else if ($action === "upload") { json_fail(3, "something went wrong [" . $userfile["error"] . "]", $userfile["error"] !== 0); json_fail(4, "folders not supported", file_get_contents($userfile["tmp_name"]) === "null"); - $upload_dir = $h5ai->get_abs_path($href); - $code = $h5ai->get_http_code($href); + $upload_dir = $app->get_abs_path($href); + $code = $app->get_http_code($href); - json_fail(5, "upload dir no h5ai folder or ignored", $code !== "h5ai" || $h5ai->is_ignored($upload_dir)); + json_fail(5, "upload dir no h5ai folder or ignored", $code !== "h5ai" || $app->is_ignored($upload_dir)); $dest = $upload_dir . "/" . utf8_encode($userfile["name"]); @@ -150,13 +172,13 @@ else if ($action === "delete") { $d = normalize_path(dirname($href), true); $n = basename($href); - $code = $h5ai->get_http_code($d); + $code = $app->get_http_code($d); if ($code == 401) { } - if ($code == "h5ai" && !$h5ai->is_ignored($n)) { + if ($code == "h5ai" && !$app->is_ignored($n)) { - $absPath = $h5ai->get_abs_path($href); + $absPath = $app->get_abs_path($href); if (!unlink($absPath)) { $errors[] = $href; @@ -181,13 +203,13 @@ else if ($action === "rename") { $d = normalize_path(dirname($href), true); $n = basename($href); - $code = $h5ai->get_http_code($d); + $code = $app->get_http_code($d); if ($code == 401) { } - if ($code == "h5ai" && !$h5ai->is_ignored($n)) { + if ($code == "h5ai" && !$app->is_ignored($n)) { - $absPath = $h5ai->get_abs_path($href); + $absPath = $app->get_abs_path($href); $folder = normalize_path(dirname($absPath)); if (!rename($absPath, $folder . "/" . $name)) { diff --git a/src/_h5ai/server/php/inc/App.php b/src/_h5ai/server/php/inc/App.php index be2f21db..1012b24f 100644 --- a/src/_h5ai/server/php/inc/App.php +++ b/src/_h5ai/server/php/inc/App.php @@ -63,12 +63,6 @@ class App { } - public function get_options() { - - return $this->options; - } - - public function get_abs_href($abs_path = null, $trailing_slash = true) { if ($abs_path === null) { @@ -136,6 +130,12 @@ class App { } + public function get_options() { + + return $this->options; + } + + public function get_http_code($abs_href) { if (!is_dir($this->get_abs_path($abs_href))) { @@ -222,18 +222,6 @@ class App { date_default_timezone_set("UTC"); - // function _cmp_no_js_fallback($entry1, $entry2) { - - // if ($entry1->isFolder && !$entry2->isFolder) { - // return -1; - // } - // if (!$entry1->isFolder && $entry2->isFolder) { - // return 1; - // } - - // return strcasecmp($entry1->abs_href, $entry2->abs_href); - // } - $cache = array(); $folder = Entry::get($this, $this->abs_path, $cache); $entries = $folder->get_content($cache); @@ -242,7 +230,7 @@ class App { $html = "
Name | Last modified | Size | |
---|---|---|---|
Parent Directory | |||
[^] | Parent Directory | ||