Update PHP Version check during Setup.

Hubzilla 4.0 requires PHP7. The oldest still supported PHP branch is 7.1.
So check during Setup for PHP >= 7.1.
This commit is contained in:
Klaus Weidenbach 2019-02-21 20:07:46 +01:00
parent 938e8110ca
commit 3f13c85b64

View File

@ -39,7 +39,7 @@ class Setup extends \Zotlabs\Web\Controller {
ini_set('display_errors', '1'); ini_set('display_errors', '1');
// $baseurl/setup/testrewrite to test if rewrite in .htaccess is working // $baseurl/setup/testrewrite to test if rewrite in .htaccess is working
if (argc() == 2 && argv(1) == "testrewrite") { if(argc() == 2 && argv(1) == 'testrewrite') {
echo 'ok'; echo 'ok';
killme(); killme();
} }
@ -63,7 +63,6 @@ class Setup extends \Zotlabs\Web\Controller {
return; return;
// implied break; // implied break;
case 3: case 3:
$urlpath = \App::get_path();
$dbhost = trim($_POST['dbhost']); $dbhost = trim($_POST['dbhost']);
$dbport = intval(trim($_POST['dbport'])); $dbport = intval(trim($_POST['dbport']));
$dbuser = trim($_POST['dbuser']); $dbuser = trim($_POST['dbuser']);
@ -89,7 +88,6 @@ class Setup extends \Zotlabs\Web\Controller {
return; return;
// implied break; // implied break;
case 4: case 4:
$urlpath = \App::get_path();
$dbhost = trim($_POST['dbhost']); $dbhost = trim($_POST['dbhost']);
$dbport = intval(trim($_POST['dbport'])); $dbport = intval(trim($_POST['dbport']));
$dbuser = trim($_POST['dbuser']); $dbuser = trim($_POST['dbuser']);
@ -162,7 +160,6 @@ class Setup extends \Zotlabs\Web\Controller {
* *
* @return string parsed HTML output * @return string parsed HTML output
*/ */
function get() { function get() {
$o = ''; $o = '';
@ -213,10 +210,10 @@ class Setup extends \Zotlabs\Web\Controller {
} }
if(x(\App::$data, 'txt') && strlen(\App::$data['txt'])) { if(x(\App::$data, 'txt') && strlen(\App::$data['txt'])) {
$db_return_text .= $this->manual_config($a); $db_return_text .= $this->manual_config();
} }
if ($db_return_text != "") { if($db_return_text != '') {
$tpl = get_markup_template('install.tpl'); $tpl = get_markup_template('install.tpl');
return replace_macros($tpl, array( return replace_macros($tpl, array(
'$title' => $install_title, '$title' => $install_title,
@ -278,7 +275,6 @@ class Setup extends \Zotlabs\Web\Controller {
$dbtype = intval(trim($_POST['dbtype'])); $dbtype = intval(trim($_POST['dbtype']));
$phpath = trim($_POST['phpath']); $phpath = trim($_POST['phpath']);
$adminmail = trim($_POST['adminmail']); $adminmail = trim($_POST['adminmail']);
$siteurl = trim($_POST['siteurl']);
$tpl = get_markup_template('install_db.tpl'); $tpl = get_markup_template('install_db.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, array(
@ -320,7 +316,6 @@ class Setup extends \Zotlabs\Web\Controller {
$phpath = trim($_POST['phpath']); $phpath = trim($_POST['phpath']);
$adminmail = trim($_POST['adminmail']); $adminmail = trim($_POST['adminmail']);
$siteurl = trim($_POST['siteurl']);
$timezone = ((x($_POST,'timezone')) ? ($_POST['timezone']) : 'America/Los_Angeles'); $timezone = ((x($_POST,'timezone')) ? ($_POST['timezone']) : 'America/Los_Angeles');
@ -363,12 +358,12 @@ class Setup extends \Zotlabs\Web\Controller {
* @param string $help optional help string * @param string $help optional help string
*/ */
function check_add(&$checks, $title, $status, $required, $help = '') { function check_add(&$checks, $title, $status, $required, $help = '') {
$checks[] = array( $checks[] = [
'title' => $title, 'title' => $title,
'status' => $status, 'status' => $status,
'required' => $required, 'required' => $required,
'help' => $help 'help' => $help
); ];
} }
/** /**
@ -380,8 +375,8 @@ class Setup extends \Zotlabs\Web\Controller {
function check_php(&$phpath, &$checks) { function check_php(&$phpath, &$checks) {
$help = ''; $help = '';
if(version_compare(PHP_VERSION, '5.5') < 0) { if(version_compare(PHP_VERSION, '7.1') < 0) {
$help .= t('PHP version 5.5 or greater is required.'); $help .= t('PHP version 7.1 or greater is required.');
$this->check_add($checks, t('PHP version'), false, false, $help); $this->check_add($checks, t('PHP version'), false, false, $help);
} }
@ -419,6 +414,7 @@ class Setup extends \Zotlabs\Web\Controller {
$result = trim(shell_exec($cmd)); $result = trim(shell_exec($cmd));
else else
$help .= t('Unable to check command line PHP, as shell_exec() is disabled. This is required.') . EOL; $help .= t('Unable to check command line PHP, as shell_exec() is disabled. This is required.') . EOL;
$passed2 = (($result == $str) ? true : false); $passed2 = (($result == $str) ? true : false);
if(!$passed2) { if(!$passed2) {
$help .= t('The command line version of PHP on your system does not have "register_argc_argv" enabled.'). EOL; $help .= t('The command line version of PHP on your system does not have "register_argc_argv" enabled.'). EOL;
@ -666,7 +662,6 @@ class Setup extends \Zotlabs\Web\Controller {
$help .= t('If your certificate is not recognized, members of other sites (who may themselves have valid certificates) will get a warning message on their own site complaining about security issues.') . EOL; $help .= t('If your certificate is not recognized, members of other sites (who may themselves have valid certificates) will get a warning message on their own site complaining about security issues.') . EOL;
$help .= t('This can cause usability issues elsewhere (not just on your own site) so we must insist on this requirement.') .EOL; $help .= t('This can cause usability issues elsewhere (not just on your own site) so we must insist on this requirement.') .EOL;
$help .= t('Providers are available that issue free certificates which are browser-valid.'). EOL; $help .= t('Providers are available that issue free certificates which are browser-valid.'). EOL;
$help .= t('If you are confident that the certificate is valid and signed by a trusted authority, check to see if you have failed to install an intermediate cert. These are not normally required by browsers, but are required for server-to-server communications.') . EOL; $help .= t('If you are confident that the certificate is valid and signed by a trusted authority, check to see if you have failed to install an intermediate cert. These are not normally required by browsers, but are required for server-to-server communications.') . EOL;
$this->check_add($checks, t('SSL certificate validation'), false, true, $help); $this->check_add($checks, t('SSL certificate validation'), false, true, $help);
@ -687,10 +682,9 @@ class Setup extends \Zotlabs\Web\Controller {
/** /**
* @brief * @brief
* *
* @param App &$a
* @return string with paresed HTML * @return string with paresed HTML
*/ */
function manual_config(&$a) { function manual_config() {
$data = htmlspecialchars(\App::$data['txt'], ENT_COMPAT, 'UTF-8'); $data = htmlspecialchars(\App::$data['txt'], ENT_COMPAT, 'UTF-8');
$o = t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.'); $o = t('The database configuration file ".htconfig.php" could not be written. Please use the enclosed text to create a configuration file in your web server root.');
$o .= "<textarea rows=\"24\" cols=\"80\" >$data</textarea>"; $o .= "<textarea rows=\"24\" cols=\"80\" >$data</textarea>";
@ -707,7 +701,12 @@ class Setup extends \Zotlabs\Web\Controller {
} }
} }
/**
* @brief Executes the SQL install script and create database tables.
*
* @param dba_driver $db (unused)
* @return boolean|string false on success or error message as string
*/
function load_database($db) { function load_database($db) {
$str = file_get_contents(\DBA::$dba->get_install_script()); $str = file_get_contents(\DBA::$dba->get_install_script());
$arr = explode(';', $str); $arr = explode(';', $str);
@ -767,7 +766,7 @@ class Setup extends \Zotlabs\Web\Controller {
/** /**
* @brief * @brief
* *
* @param unknown $v * @param array $v
* @param array $c * @param array $c
* @return array * @return array
*/ */