From 2691a6bbdc154db1f4492890e68989cc098fb945 Mon Sep 17 00:00:00 2001 From: jgen Date: Sat, 11 Mar 2017 18:34:36 -0800 Subject: [PATCH] Change PHP version check to use a configuration constant, rather than a hardcoded version in the code. (As it seems this hardcoded version number is easy to forget about, and then it doesn't actually get updated..) --- core/sys_config.inc.php | 2 +- core/util.inc.php | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/sys_config.inc.php b/core/sys_config.inc.php index 50ac40a6..abc00766 100644 --- a/core/sys_config.inc.php +++ b/core/sys_config.inc.php @@ -41,7 +41,7 @@ _d("TIMEZONE", null); // string timezone _d("CORE_EXTS", "bbcode,user,mail,upload,image,view,handle_pixel,ext_manager,setup,upgrade,handle_404,comment,tag_list,index,tag_edit,alias_editor"); // extensions to always enable _d("EXTRA_EXTS", ""); // string optional extra extensions _d("BASE_URL", null); // string force a specific base URL (default is auto-detect) - +_d("MIN_PHP_VERSION", '5.6');// string minium supported PHP version /* * Calculated settings - you should never need to change these diff --git a/core/util.inc.php b/core/util.inc.php index 29e525b3..64b49bee 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -1600,14 +1600,17 @@ function score_assert_handler($file, $line, $code, $desc = null) { /** @privatesection */ function _version_check() { - $min_version = "5.4.8"; - if(version_compare(PHP_VERSION, $min_version) == -1) { - print " -Currently SCore Engine doesn't support versions of PHP lower than $min_version -- -if your web host is running an older version, they are dangerously out of + if(MIN_PHP_VERSION) + { + if(version_compare(phpversion(), MIN_PHP_VERSION, ">=") == FALSE) { + print " +Shimmie (SCore Engine) does not support versions of PHP lower than ".MIN_PHP_VERSION." +(PHP reports that it is version ".phpversion().") +If your web host is running an older version, they are dangerously out of date and you should plan on moving elsewhere. "; - exit; + exit; + } } }