mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-28 14:04:45 -04:00
Enhanced feature checks.
This commit is contained in:
parent
0d22407a2d
commit
972be7677c
4 changed files with 24 additions and 54 deletions
|
@ -23,7 +23,7 @@
|
||||||
version %BUILD_VERSION%
|
version %BUILD_VERSION%
|
||||||
<h2>server supports</h2>
|
<h2>server supports</h2>
|
||||||
<ul id="tests">
|
<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-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>
|
<li id="test-thumbs"><span class="test-label">thumbnails</span><span class="test-result"></span></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -2,26 +2,22 @@
|
||||||
(function ($, h5ai) {
|
(function ($, h5ai) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var handleChecksResponse = function (response) {
|
var setCheckResult = function (id, result) {
|
||||||
|
|
||||||
if (response) {
|
var $ele = $(id).find('.test-result');
|
||||||
$('#test-php .test-result').addClass('test-passed').text('yes');
|
|
||||||
if (response.zips === 0) {
|
if (result) {
|
||||||
$('#test-zips .test-result').addClass('test-passed').text('yes');
|
$ele.addClass('test-passed').text('yes');
|
||||||
} else {
|
} else {
|
||||||
$('#test-zips .test-result').addClass('test-failed').text('no').attr('title', 'error-code: ' + response.zips);
|
$ele.addClass('test-failed').text('no');
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
} 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');
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
handleChecksResponse = function (response) {
|
||||||
|
|
||||||
|
setCheckResult('#test-php', response && response.php);
|
||||||
|
setCheckResult('#test-zips', response && response.zips);
|
||||||
|
setCheckResult('#test-thumbs', response && response.thumbs);
|
||||||
|
},
|
||||||
checks = function () {
|
checks = function () {
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
|
@ -145,43 +145,11 @@ else if ($action === "getzip") {
|
||||||
|
|
||||||
else if ($action === "checks") {
|
else if ($action === "checks") {
|
||||||
|
|
||||||
function checkZipSupport () {
|
$response = array(
|
||||||
|
'php' => true,
|
||||||
if (!class_exists("ZipArchive")) {
|
'zips' => class_exists("ZipArchive"),
|
||||||
return 1;
|
'thumbs' => GD_VERSION != "GD_VERSION"
|
||||||
}
|
);
|
||||||
|
|
||||||
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);
|
echo json_encode($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,12 @@ class ZipIt {
|
||||||
private $h5ai;
|
private $h5ai;
|
||||||
|
|
||||||
|
|
||||||
|
public static function isUsable() {
|
||||||
|
|
||||||
|
return class_exists("ZipArchive");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function __construct($h5ai) {
|
public function __construct($h5ai) {
|
||||||
|
|
||||||
$this->h5ai = $h5ai;
|
$this->h5ai = $h5ai;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue