mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-29 14:35:18 -04:00
More refactorings.
This commit is contained in:
parent
bd65025a4c
commit
b8b6d32a33
7 changed files with 207 additions and 84 deletions
|
@ -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 = "<table>";
|
||||
$html .= "<tr><th></th><th><span>Name</span></th><th><span>Last modified</span></th><th><span>Size</span></th></tr>";
|
||||
if ($folder->get_parent($cache)) {
|
||||
$html .= "<tr><td></td><td><a href=\"..\">Parent Directory</a></td><td></td><td></td></tr>";
|
||||
$html .= "<tr><td>[^]</td><td><a href=\"..\">Parent Directory</a></td><td></td><td></td></tr>";
|
||||
}
|
||||
foreach ($entries as $entry) {
|
||||
$html .= "<tr>";
|
||||
|
@ -256,6 +244,108 @@ class App {
|
|||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
public function get_types() {
|
||||
|
||||
return load_commented_json($this->app_abs_path . "/conf/types.json");
|
||||
}
|
||||
|
||||
|
||||
public function get_l10n_list() {
|
||||
|
||||
$langs = array();
|
||||
$l10nDir = $this->app_abs_path . "/conf/l10n";
|
||||
if (is_dir($l10nDir)) {
|
||||
if ($dir = opendir($l10nDir)) {
|
||||
while (($file = readdir($dir)) !== false) {
|
||||
if (ends_with($file, ".json")) {
|
||||
$translations = load_commented_json($l10nDir . "/" . $file);
|
||||
$langs[basename($file, ".json")] = $translations["lang"];
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
}
|
||||
}
|
||||
ksort($langs);
|
||||
return $langs;
|
||||
}
|
||||
|
||||
|
||||
public function get_l10n($iso_codes) {
|
||||
|
||||
if (!is_array($iso_codes)) {
|
||||
$iso_codes = func_get_args();
|
||||
}
|
||||
|
||||
$result = array();
|
||||
foreach ($iso_codes as $iso_code) {
|
||||
if ($iso_code !== "") {
|
||||
$file = $this->app_abs_path . "/conf/l10n/" . $iso_code . ".json";
|
||||
$result[$iso_code] = load_commented_json($file);
|
||||
$result[$iso_code]["isoCode"] = $iso_code;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function get_server_checks() {
|
||||
|
||||
$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($this->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;
|
||||
|
||||
return array(
|
||||
"php" => $php,
|
||||
"cache" => $cache,
|
||||
"thumbs" => $gd,
|
||||
"archive" => $archive,
|
||||
"tar" => $tar,
|
||||
"zip" => $zip,
|
||||
"convert" => $convert,
|
||||
"ffmpeg" => $ffmpeg,
|
||||
"du" => $du
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function get_server_details() {
|
||||
|
||||
return array(
|
||||
"backend" => "php",
|
||||
"apiHref" => $this->app_abs_href . "server/php/api.php",
|
||||
"name" => strtolower(preg_replace("/\\/.*$/", "", getenv("SERVER_SOFTWARE"))),
|
||||
"version" => strtolower(preg_replace("/^.*\\//", "", preg_replace("/\\s.*$/", "", getenv("SERVER_SOFTWARE"))))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function get_customizations($abs_href) {
|
||||
|
||||
$abs_path = $this->get_abs_path($abs_href);
|
||||
|
||||
$file = $abs_path . "/" . App::$FILE_PREFIX . ".header.html";
|
||||
$header = is_string($file) && file_exists($file) ? file_get_contents($file) : null;
|
||||
$file = $abs_path . "/" . App::$FILE_PREFIX . ".footer.html";
|
||||
$footer = is_string($file) && file_exists($file) ? file_get_contents($file) : null;
|
||||
|
||||
return array(
|
||||
"header" => $header,
|
||||
"footer" => $footer
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue