mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-29 22:45:14 -04:00
Adds PHP support checks to index page.
This commit is contained in:
parent
eda1a3b6ac
commit
c173d74d06
6 changed files with 113 additions and 20 deletions
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
function safe_dirname($path, $endWithSlash = false) {
|
||||
|
||||
|
||||
$path = str_replace("\\", "/", dirname($path));
|
||||
return preg_match("#^(\w:)?/$#", $path) ? $path : (preg_replace('#/$#', '', $path) . ($endWithSlash ? "/" : ""));
|
||||
}
|
||||
|
@ -143,6 +143,49 @@ else if ($action === "getzip") {
|
|||
}
|
||||
|
||||
|
||||
else if ($action === "checks") {
|
||||
|
||||
function checkZipSupport () {
|
||||
|
||||
if (!class_exists("ZipArchive")) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
$zipFile = tempnam(sys_get_temp_dir(), "h5ai-zip-");
|
||||
$zip = new ZipArchive();
|
||||
|
||||
if (!$zip->open($zipFile, ZIPARCHIVE::CREATE)) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
$zip->addEmptyDir("/");
|
||||
$zip->close();
|
||||
|
||||
if (filesize($zipFile) === 0) {
|
||||
return 3;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return 4;
|
||||
};
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function checkGdSupport () {
|
||||
|
||||
if (GD_VERSION == "GD_VERSION") {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
$response = array('zips' => checkZipSupport(), 'thumbs' => checkGdSupport());
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
fail(1, "unsupported 'action' specified");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue