mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-03-21 13:00:10 +01:00
Enhanced feature checks.
This commit is contained in:
parent
0d22407a2d
commit
972be7677c
@ -23,7 +23,7 @@
|
||||
version %BUILD_VERSION%
|
||||
<h2>server supports</h2>
|
||||
<ul id="tests">
|
||||
<li id="test-php"><span class="test-label">PHP</span><span class="test-result"></span></li>
|
||||
<li id="test-php"><span class="test-label">PHP variant</span><span class="test-result"></span></li>
|
||||
<li id="test-zips"><span class="test-label">zipped downloads</span><span class="test-result"></span></li>
|
||||
<li id="test-thumbs"><span class="test-label">thumbnails</span><span class="test-result"></span></li>
|
||||
</ul>
|
||||
|
@ -2,26 +2,22 @@
|
||||
(function ($, h5ai) {
|
||||
'use strict';
|
||||
|
||||
var handleChecksResponse = function (response) {
|
||||
var setCheckResult = function (id, result) {
|
||||
|
||||
if (response) {
|
||||
$('#test-php .test-result').addClass('test-passed').text('yes');
|
||||
if (response.zips === 0) {
|
||||
$('#test-zips .test-result').addClass('test-passed').text('yes');
|
||||
} else {
|
||||
$('#test-zips .test-result').addClass('test-failed').text('no').attr('title', 'error-code: ' + response.zips);
|
||||
}
|
||||
if (response.thumbs === 0) {
|
||||
$('#test-thumbs .test-result').addClass('test-passed').text('yes');
|
||||
} else {
|
||||
$('#test-thumbs .test-result').addClass('test-failed').text('no').attr('title', 'error-code: ' + response.thumbs);
|
||||
}
|
||||
var $ele = $(id).find('.test-result');
|
||||
|
||||
if (result) {
|
||||
$ele.addClass('test-passed').text('yes');
|
||||
} else {
|
||||
$('#test-php .test-result').addClass('test-failed').text('no');
|
||||
$('#test-zips .test-result').addClass('test-failed').text('no');
|
||||
$('#test-thumbs .test-result').addClass('test-failed').text('no');
|
||||
$ele.addClass('test-failed').text('no');
|
||||
}
|
||||
},
|
||||
handleChecksResponse = function (response) {
|
||||
|
||||
setCheckResult('#test-php', response && response.php);
|
||||
setCheckResult('#test-zips', response && response.zips);
|
||||
setCheckResult('#test-thumbs', response && response.thumbs);
|
||||
},
|
||||
checks = function () {
|
||||
|
||||
$.ajax({
|
||||
|
@ -145,43 +145,11 @@ 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());
|
||||
$response = array(
|
||||
'php' => true,
|
||||
'zips' => class_exists("ZipArchive"),
|
||||
'thumbs' => GD_VERSION != "GD_VERSION"
|
||||
);
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,12 @@ class ZipIt {
|
||||
private $h5ai;
|
||||
|
||||
|
||||
public static function isUsable() {
|
||||
|
||||
return class_exists("ZipArchive");
|
||||
}
|
||||
|
||||
|
||||
public function __construct($h5ai) {
|
||||
|
||||
$this->h5ai = $h5ai;
|
||||
|
Loading…
x
Reference in New Issue
Block a user