Add fast PHP version check and exit.

This commit is contained in:
Lars Jung 2015-05-06 12:28:50 +02:00
parent d4e349f260
commit 85be66886a
4 changed files with 29 additions and 14 deletions

View file

@ -162,6 +162,12 @@ modulejs.define('main/info', ['$', 'config'], function ($, config) {
function init() { function init() {
if (config.err === 'ERR_PHP') {
$(testsTemp).appendTo('#content');
addTest('PHP version', config.msg, false, config.ver);
return;
}
addLogin(); addLogin();
if (setup.AS_ADMIN) { if (setup.AS_ADMIN) {
addTests(); addTests();

View file

@ -0,0 +1,8 @@
<?php
/*********************************************************************
SHA1 hash of the info page password, the preset password is the
empty string. You might change it to keep this information private.
Online hash generator: http://www.sha1.cz/
*********************************************************************/
define("PASSHASH", "da39a3ee5e6b4b0d3255bfef95601890afd80709");

View file

@ -19,7 +19,7 @@ class Bootstrap {
$api->apply(); $api->apply();
} else { } else {
define("FALLBACK", $app->get_fallback()); define("FALLBACK", $app->get_fallback());
normalized_require_once("page"); normalized_require_once("inc/page");
} }
} }
@ -30,8 +30,6 @@ class Bootstrap {
setlocale(LC_CTYPE, "en_US.UTF-8"); setlocale(LC_CTYPE, "en_US.UTF-8");
date_default_timezone_set(@date_default_timezone_get()); date_default_timezone_set(@date_default_timezone_get());
define("MIN_PHP_VERSION", "5.4.0");
define("HAS_MIN_PHP_VERSION", version_compare(PHP_VERSION, MIN_PHP_VERSION) >= 0);
define("HAS_PHP_EXIF", function_exists("exif_thumbnail")); define("HAS_PHP_EXIF", function_exists("exif_thumbnail"));
$has_php_jpeg = false; $has_php_jpeg = false;
if (function_exists("gd_info")) { if (function_exists("gd_info")) {

View file

@ -1,24 +1,27 @@
<?php <?php
define("MIN_PHP_VERSION", "5.4.0");
define("HAS_MIN_PHP_VERSION", version_compare(PHP_VERSION, MIN_PHP_VERSION) >= 0);
if (!HAS_MIN_PHP_VERSION) {
/********************************************************************* header("Content-type: application/json;charset=utf-8");
SHA1 hash of the info page password, the preset password is the echo json_encode(array(
empty string. You might change it to keep this information private. "err" => "ERR_PHP",
Online hash generator: http://www.sha1.cz/ "msg" => "PHP " . MIN_PHP_VERSION . "+ required, only found " . PHP_VERSION,
*********************************************************************/ "ver" => PHP_VERSION
define("PASSHASH", "da39a3ee5e6b4b0d3255bfef95601890afd80709"); ));
exit;
}
function normalized_require_once($lib) { function normalized_require_once($lib) {
require_once(preg_replace("#[\\\\/]+#", "/", dirname(__FILE__) . "/inc/${lib}.php")); require_once(preg_replace("#[\\\\/]+#", "/", dirname(__FILE__) . "/${lib}.php"));
} }
function __autoload($class_name) { function __autoload($class_name) {
normalized_require_once("class-" . strtolower($class_name)); normalized_require_once("inc/class-" . strtolower($class_name));
} }
normalized_require_once("config");
Bootstrap::run(); Bootstrap::run();