Adds PHP support checks to index page.

This commit is contained in:
Lars Jung 2012-03-25 22:49:05 +02:00
parent eda1a3b6ac
commit c173d74d06
6 changed files with 113 additions and 20 deletions

View file

@ -89,6 +89,18 @@ html.h5ai-splash {
margin-top: 0.6em;
line-height: 1.4em;
}
.test-label {
}
.test-result {
font-weight: bold;
&.test-passed {
color: #5a5;
}
&.test-failed {
color: #a55;
}
}
pre.prettyprint.nice, code.prettyprint.nice {
font-family: "Ubuntu Mono", Ubuntu, Arial, sans;
font-size: 0.95em;

View file

@ -21,11 +21,10 @@
<body>
<header>
<h1><span class="logo-h">h</span><span class="logo-5"><img src="/_h5ai/images/html5.png" alt="5" title="HTML 5" /></span><span class="logo-a">a</span><span class="logo-i">i</span></h1>
<h2>· version %BUILD_VERSION% ·</h2>
</header>
<section>
<p>
<span class="h5ai">h5ai</span> %BUILD_VERSION% is provided under the terms of the <a target="_blank" href="http://github.com/lrsjng/h5ai/blob/master/LICENSE.txt">MIT License</a>.
</p>
<h2>Links</h2>
<p>
<ul>
<li>Project page: <a target="_blank" href="http://larsjung.de/h5ai">http://larsjung.de/h5ai</a></li>
@ -35,6 +34,14 @@
<p>
To report a bug or make a feature request please create <a target="_blank" href="http://github.com/lrsjng/h5ai/issues/new">a new issue</a>.
</p>
<h2>Checks</h2>
<p>
<ul>
<li id="test-php"><span class="test-label">PHP</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>
</p>
<h2>Contact</h2>
<p>
<img class="gravatar" src="http://www.gravatar.com/avatar/0340cc810fd79ee143476d4ad51fac9f?s=80" width="80" height="80" />
@ -43,10 +50,6 @@
<a target="_blank" href="http://twitter.com/lrsjng">@lrsjng</a>
</p>
</section>
<section>
<pre id="config-file">
</pre>
</section>
<script src="/_h5ai/config.js"></script>
<script src="/_h5ai/js/scripts.js"></script>
</body>

View file

@ -97,6 +97,8 @@
// @include "Html.js"
// @include "Extended.js"
// @include "splash.js"
$(init);
}(jQuery, H5AI_CONFIG));

View file

@ -1,8 +1,6 @@
(function (window, $) {
(function ($, h5ai) {
'use strict';
/*jslint browser: true, confusion: true, white: true */
/*global jQuery */
var deobfuscate = function () {
@ -15,16 +13,55 @@
$this.replaceWith($a);
});
},
configFile = function () {
handleChecksResponse = function (response) {
$('#config-file').text(JSON.stringify(H5AI_CONFIG.options));
if (response) {
$('#test-php .test-result').addClass('test-passed').text('passed');
if (response.zips === 0) {
$('#test-zips .test-result').addClass('test-passed').text('passed');
} else {
$('#test-zips .test-result').addClass('test-failed').text('failed (' + response.zips + ')');
}
if (response.thumbs === 0) {
$('#test-thumbs .test-result').addClass('test-passed').text('passed');
} else {
$('#test-thumbs .test-result').addClass('test-failed').text('failed (' + response.thumbs + ')');
}
} else {
$('#test-php .test-result').addClass('test-failed').text('failed');
$('#test-zips .test-result').addClass('test-failed').text('failed');
$('#test-thumbs .test-result').addClass('test-failed').text('failed');
}
},
checks = function () {
$.ajax({
url: h5ai.core.api(),
data: {
action: 'checks'
},
type: 'POST',
dataType: 'json',
success: function (response) {
handleChecksResponse(response);
},
error: function () {
handleChecksResponse();
}
});
},
init = function () {
deobfuscate();
configFile();
h5ai.isSplash = $('html').hasClass('h5ai-splash');
if (h5ai.isSplash) {
deobfuscate();
checks();
}
};
$(init);
}(window, jQuery));
}(jQuery, h5ai));

View file

@ -17,7 +17,3 @@
// h5ai
// ----
// @include "inc/H5ai.js"
// info
// ----
// @include "inc/splash.js"

View file

@ -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");
}