Skip to content

Commit f0ace5f

Browse files
author
Till Brehm
committed
Merge branch '6328-support-php-8-x' into 'develop'
Resolve "Support PHP 8.X" Closes #6328 See merge request ispconfig/ispconfig3!1602
2 parents 4e36ffb + 06111e8 commit f0ace5f

35 files changed

+250
-152
lines changed

install/install.php

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,9 @@
508508

509509
if($install_mode == 'standard' || strtolower($inst->simple_query('Configure Firewall Server', array('y', 'n'), 'y','configure_firewall')) == 'y') {
510510
//* Check for Firewall
511+
if(!isset($conf['firewall']['installed'])) {
512+
$conf['firewall']['installed'] = false;
513+
}
511514
if(!$conf['ufw']['installed'] && !$conf['firewall']['installed']) {
512515
$conf['ufw']['installed'] = $inst->force_configure_app('Ubuntu Firewall', ($install_mode == 'expert'));
513516
$conf['firewall']['installed'] = $inst->force_configure_app('Bastille Firewall', ($install_mode == 'expert'));
@@ -631,35 +634,35 @@
631634
$inst->detect_ips();
632635

633636
swriteln('Restarting services ...');
634-
if($conf['mysql']['installed'] == true && $conf['mysql']['init_script'] != '') system($inst->getinitcommand($conf['mysql']['init_script'], 'restart').' >/dev/null 2>&1');
635-
if($conf['postfix']['installed'] == true && $conf['postfix']['init_script'] != '') system($inst->getinitcommand($conf['postfix']['init_script'], 'restart'));
636-
if($conf['saslauthd']['installed'] == true && $conf['saslauthd']['init_script'] != '') system($inst->getinitcommand($conf['saslauthd']['init_script'], 'restart'));
637-
if($conf['amavis']['installed'] == true && $conf['amavis']['init_script'] != '') system($inst->getinitcommand($conf['amavis']['init_script'], 'restart'));
638-
if($conf['rspamd']['installed'] == true && $conf['rspamd']['init_script'] != '') system($inst->getinitcommand($conf['rspamd']['init_script'], 'restart'));
639-
if($conf['clamav']['installed'] == true && $conf['clamav']['init_script'] != '' && $conf['amavis']['installed'] == true) system($inst->getinitcommand($conf['clamav']['init_script'], 'restart'));
637+
if($conf['mysql']['installed'] == true && isset($conf['mysql']['init_script']) && $conf['mysql']['init_script'] != '') system($inst->getinitcommand($conf['mysql']['init_script'], 'restart').' >/dev/null 2>&1');
638+
if($conf['postfix']['installed'] == true && isset($conf['postfix']['init_script']) && $conf['postfix']['init_script'] != '') system($inst->getinitcommand($conf['postfix']['init_script'], 'restart'));
639+
if($conf['saslauthd']['installed'] == true && isset($conf['saslauthd']['init_script']) && $conf['saslauthd']['init_script'] != '') system($inst->getinitcommand($conf['saslauthd']['init_script'], 'restart'));
640+
if($conf['amavis']['installed'] == true && isset($conf['amavis']['init_script']) && $conf['amavis']['init_script'] != '') system($inst->getinitcommand($conf['amavis']['init_script'], 'restart'));
641+
if($conf['rspamd']['installed'] == true && isset($conf['rspamd']['init_script']) && $conf['rspamd']['init_script'] != '') system($inst->getinitcommand($conf['rspamd']['init_script'], 'restart'));
642+
if($conf['clamav']['installed'] == true && isset($conf['clamav']['init_script']) && $conf['clamav']['init_script'] != '' && $conf['amavis']['installed'] == true) system($inst->getinitcommand($conf['clamav']['init_script'], 'restart'));
640643
if($conf['courier']['installed'] == true){
641644
if($conf['courier']['courier-authdaemon'] != '') system($inst->getinitcommand($conf['courier']['courier-authdaemon'], 'restart'));
642645
if($conf['courier']['courier-imap'] != '') system($inst->getinitcommand($conf['courier']['courier-imap'], 'restart'));
643646
if($conf['courier']['courier-imap-ssl'] != '') system($inst->getinitcommand($conf['courier']['courier-imap-ssl'], 'restart'));
644647
if($conf['courier']['courier-pop'] != '') system($inst->getinitcommand($conf['courier']['courier-pop'], 'restart'));
645648
if($conf['courier']['courier-pop-ssl'] != '') system($inst->getinitcommand($conf['courier']['courier-pop-ssl'], 'restart'));
646649
}
647-
if($conf['dovecot']['installed'] == true && $conf['dovecot']['init_script'] != '') system($inst->getinitcommand($conf['dovecot']['init_script'], 'restart'));
648-
if($conf['mailman']['installed'] == true && $conf['mailman']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['mailman']['init_script'], 'restart').' >/dev/null 2>&1 &');
649-
if($conf['apache']['installed'] == true && $conf['apache']['init_script'] != '') system($inst->getinitcommand($conf['apache']['init_script'], 'restart'));
650+
if($conf['dovecot']['installed'] == true && isset($conf['dovecot']['init_script']) && $conf['dovecot']['init_script'] != '') system($inst->getinitcommand($conf['dovecot']['init_script'], 'restart'));
651+
if($conf['mailman']['installed'] == true && isset($conf['mailman']['init_script']) && $conf['mailman']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['mailman']['init_script'], 'restart').' >/dev/null 2>&1 &');
652+
if($conf['apache']['installed'] == true && isset($conf['apache']['init_script']) && $conf['apache']['init_script'] != '') system($inst->getinitcommand($conf['apache']['init_script'], 'restart'));
650653
//* Reload is enough for nginx
651654
if($conf['nginx']['installed'] == true){
652655
if($conf['nginx']['php_fpm_init_script'] != '') system($inst->getinitcommand($conf['nginx']['php_fpm_init_script'], 'reload'));
653-
if($conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'reload'));
656+
if(isset($conf['nginx']['init_script']) && $conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'reload'));
654657
}
655-
if($conf['pureftpd']['installed'] == true && $conf['pureftpd']['init_script'] != '') system($inst->getinitcommand($conf['pureftpd']['init_script'], 'restart'));
656-
if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '') system($inst->getinitcommand($conf['mydns']['init_script'], 'restart').' &> /dev/null');
657-
if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '') system($inst->getinitcommand($conf['powerdns']['init_script'], 'restart').' &> /dev/null');
658-
if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '') system($inst->getinitcommand($conf['bind']['init_script'], 'restart').' &> /dev/null');
659-
//if($conf['squid']['installed'] == true && $conf['squid']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['squid']['init_script'])) system($conf['init_scripts'].'/'.$conf['squid']['init_script'].' restart &> /dev/null');
660-
if($conf['nginx']['installed'] == true && $conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'restart').' &> /dev/null');
661-
if($conf['ufw']['installed'] == true && $conf['ufw']['init_script'] != '') system($inst->getinitcommand($conf['ufw']['init_script'], 'restart').' &> /dev/null');
662-
if($conf['xmpp']['installed'] == true && $conf['xmpp']['init_script'] != '') system($inst->getinitcommand($conf['xmpp']['init_script'], 'restart').' &> /dev/null');
658+
if($conf['pureftpd']['installed'] == true && isset($conf['pureftpd']['init_script']) && $conf['pureftpd']['init_script'] != '') system($inst->getinitcommand($conf['pureftpd']['init_script'], 'restart'));
659+
if($conf['mydns']['installed'] == true && isset($conf['mydns']['init_script']) && $conf['mydns']['init_script'] != '') system($inst->getinitcommand($conf['mydns']['init_script'], 'restart').' &> /dev/null');
660+
if($conf['powerdns']['installed'] == true && isset($conf['powerdns']['init_script']) && $conf['powerdns']['init_script'] != '') system($inst->getinitcommand($conf['powerdns']['init_script'], 'restart').' &> /dev/null');
661+
if($conf['bind']['installed'] == true && isset($conf['bind']['init_script']) && $conf['bind']['init_script'] != '') system($inst->getinitcommand($conf['bind']['init_script'], 'restart').' &> /dev/null');
662+
//if($conf['squid']['installed'] == true && isset($conf['squid']['init_script']) && $conf['squid']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['squid']['init_script'])) system($conf['init_scripts'].'/'.$conf['squid']['init_script'].' restart &> /dev/null');
663+
if($conf['nginx']['installed'] == true && isset($conf['nginx']['init_script']) && $conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'restart').' &> /dev/null');
664+
if($conf['ufw']['installed'] == true && isset($conf['ufw']['init_script']) && $conf['ufw']['init_script'] != '') system($inst->getinitcommand($conf['ufw']['init_script'], 'restart').' &> /dev/null');
665+
if($conf['xmpp']['installed'] == true && isset($conf['xmpp']['init_script']) && $conf['xmpp']['init_script'] != '') system($inst->getinitcommand($conf['xmpp']['init_script'], 'restart').' &> /dev/null');
663666

664667

665668
$inst->create_mount_script();

install/lib/classes/tpl.inc.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ private function _parseLoop ($varname)
931931
{
932932
array_push($this->_namespace, $varname);
933933
$tempvar = count($this->_namespace) - 1;
934-
$retstr = "for (\$_".$tempvar."=0 ; \$_".$tempvar." < count(\$this->_arrvars";
934+
$retstr = "for (\$_".$tempvar."=0 ; \$_".$tempvar." < \$this->_tpl_count(\$this->_arrvars";
935935
for ($i=0; $i < count($this->_namespace); $i++) {
936936
$retstr .= "['".$this->_namespace[$i]."']";
937937
if ($this->_namespace[$i] != $varname) $retstr .= "[\$_".$i."]";
@@ -1170,7 +1170,15 @@ private function _parse ($compress = '')
11701170

11711171
array_push($this->_currentincludedir, dirname($this->_tmplfilename));
11721172
$this->_includedepth++;
1173-
$success = @eval($this->_tmplfilep);
1173+
try {
1174+
$success = @eval($this->_tmplfilep);
1175+
} catch(Exception $ex) {
1176+
print $this->_tmplfilep;
1177+
throw $ex;
1178+
} catch(TypeError $ex) {
1179+
print $this->_tmplfilep;
1180+
throw $ex;
1181+
}
11741182
$this->_includedepth--;
11751183
array_pop($this->_currentincludedir);
11761184

@@ -1268,6 +1276,27 @@ private function _escape_hex($str = '', $entity = false) {
12681276
return $return;
12691277
}
12701278

1279+
/**
1280+
* Used during in evaled code to replace PHP count function for PHP 8 compatibility
1281+
* @var variable to be counted
1282+
*/
1283+
private function _tpl_count($var)
1284+
{
1285+
$retvar = 0;
1286+
if(isset($var)) {
1287+
if(is_array($var)) {
1288+
$retvar = count($var);
1289+
} elseif(is_null($var)) {
1290+
$retvar = 0;
1291+
} else {
1292+
$retvar = 1;
1293+
}
1294+
} else {
1295+
$retvar = 0;
1296+
}
1297+
return $retvar;
1298+
}
1299+
12711300
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
12721301
The following functions have no use and are included just so that if the user
12731302
is making use of vlibTemplateCache functions, this doesn't crash when changed to

install/lib/installer_base.lib.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ public function simple_query($query, $answers, $default, $name = '') {
8383
global $autoinstall, $autoupdate;
8484
$finished = false;
8585
do {
86-
if($name != '' && $autoinstall[$name] != '') {
86+
if($name != '' && isset($autoinstall[$name]) && $autoinstall[$name] != '') {
8787
if($autoinstall[$name] == 'default') {
8888
$input = $default;
8989
} else {
9090
$input = $autoinstall[$name];
9191
}
92-
} elseif($name != '' && $autoupdate[$name] != '') {
92+
} elseif($name != '' && isset($autoupdate[$name]) && $autoupdate[$name] != '') {
9393
if($autoupdate[$name] == 'default') {
9494
$input = $default;
9595
} else {
@@ -126,13 +126,13 @@ public function simple_query($query, $answers, $default, $name = '') {
126126

127127
public function free_query($query, $default, $name = '') {
128128
global $autoinstall, $autoupdate;
129-
if($name != '' && $autoinstall[$name] != '') {
129+
if($name != '' && isset($autoinstall[$name]) && $autoinstall[$name] != '') {
130130
if($autoinstall[$name] == 'default') {
131131
$input = $default;
132132
} else {
133133
$input = $autoinstall[$name];
134134
}
135-
} elseif($name != '' && $autoupdate[$name] != '') {
135+
} elseif($name != '' && isset($autoupdate[$name]) && $autoupdate[$name] != '') {
136136
if($autoupdate[$name] == 'default') {
137137
$input = $default;
138138
} else {
@@ -249,7 +249,7 @@ public function check_prerequisites() {
249249
$msg = '';
250250

251251
if(version_compare(phpversion(), '5.4', '<')) $msg .= "PHP Version 5.4 or newer is required. The currently used PHP version is ".phpversion().".\n";
252-
if(version_compare(phpversion(), '8.0', '>=')) $msg .= "PHP Version 8 is not supported yet. Change PHP version back to the default version of the OS. The currently used PHP version is ".phpversion().".\n";
252+
if(version_compare(phpversion(), '8.2', '>=')) $msg .= "PHP Version 8.2+ is not supported yet. Change PHP version back to the default version of the OS. The currently used PHP version is ".phpversion().".\n";
253253
if(!function_exists('curl_init')) $msg .= "PHP Curl Module is missing.\n";
254254
if(!function_exists('mysqli_connect')) $msg .= "PHP MySQLi Module is nmissing.\n";
255255
if(!function_exists('mb_detect_encoding')) $msg .= "PHP Multibyte Module (MB) is missing.\n";
@@ -1521,7 +1521,7 @@ public function configure_dovecot() {
15211521
}
15221522
$new_options[] = $value;
15231523
}
1524-
if ($configure_lmtp && $conf['mail']['content_filter'] === 'amavisd') {
1524+
if ($configure_lmtp && (!isset($conf['mail']['content_filter']) || $conf['mail']['content_filter'] === 'amavisd')) {
15251525
for ($i = 0; isset($new_options[$i]); $i++) {
15261526
if ($new_options[$i] == 'reject_unlisted_recipient') {
15271527
array_splice($new_options, $i+1, 0, array("check_recipient_access proxy:mysql:${config_dir}/mysql-verify_recipients.cf"));
@@ -1928,10 +1928,10 @@ public function configure_rspamd() {
19281928
}
19291929

19301930
$tpl->setVar('dkim_path', $mail_config['dkim_path']);
1931-
$tpl->setVar('rspamd_redis_servers', $mail_config['rspamd_redis_servers']);
1932-
$tpl->setVar('rspamd_redis_password', $mail_config['rspamd_redis_password']);
1933-
$tpl->setVar('rspamd_redis_bayes_servers', $mail_config['rspamd_redis_bayes_servers']);
1934-
$tpl->setVar('rspamd_redis_bayes_password', $mail_config['rspamd_redis_bayes_password']);
1931+
$tpl->setVar('rspamd_redis_servers', (isset($mail_config['rspamd_redis_servers']) ? $mail_config['rspamd_redis_servers'] : ''));
1932+
$tpl->setVar('rspamd_redis_password', (isset($mail_config['rspamd_redis_password']) ? $mail_config['rspamd_redis_password'] : ''));
1933+
$tpl->setVar('rspamd_redis_bayes_servers', (isset($mail_config['rspamd_redis_bayes_servers']) ? $mail_config['rspamd_redis_bayes_servers'] : ''));
1934+
$tpl->setVar('rspamd_redis_bayes_password', (isset($mail_config['rspamd_redis_bayes_password']) ? $mail_config['rspamd_redis_bayes_password'] : ''));
19351935
if(count($local_addrs) > 0) {
19361936
$tpl->setLoop('local_addrs', $local_addrs);
19371937
}
@@ -3031,12 +3031,15 @@ public function make_ispconfig_ssl_cert() {
30313031
$hook = $pre_hook . $renew_hook;
30323032
}
30333033

3034+
$which_certbot = shell_exec('which certbot /root/.local/share/letsencrypt/bin/letsencrypt /opt/eff.org/certbot/venv/bin/certbot letsencrypt');
3035+
30343036
// Get the default LE client name and version
3035-
$le_client = explode("\n", shell_exec('which certbot /root/.local/share/letsencrypt/bin/letsencrypt /opt/eff.org/certbot/venv/bin/certbot letsencrypt'));
3037+
$le_client = explode("\n", $which_certbot ? $which_certbot : '');
30363038
$le_client = reset($le_client);
30373039

3040+
$which_acme = shell_exec('which acme.sh /usr/local/ispconfig/server/scripts/acme.sh /root/.acme.sh/acme.sh');
30383041
// Check for Neilpang acme.sh as well
3039-
$acme = explode("\n", shell_exec('which acme.sh /usr/local/ispconfig/server/scripts/acme.sh /root/.acme.sh/acme.sh'));
3042+
$acme = explode("\n", $which_acme ? $which_acme : '');
30403043
$acme = reset($acme);
30413044

30423045
if((!$acme || !is_executable($acme)) && (!$le_client || !is_executable($le_client))) {

install/lib/mysql.lib.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ class db
6464
public function __destruct() {
6565
if($this->_iConnId) mysqli_close($this->_iConnId);
6666
}
67-
67+
6868
private function do_connect() {
6969
global $conf;
70+
71+
mysqli_report(MYSQLI_REPORT_OFF);
7072

7173
if($this->_iConnId) return true;
7274
$this->dbHost = $conf['mysql']['host'];
@@ -77,7 +79,7 @@ private function do_connect() {
7779
$this->dbCharset = $conf["mysql"]["charset"];
7880
$this->dbNewLink = false;
7981
$this->dbClientFlags = null;
80-
82+
8183
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort);
8284
$try = 0;
8385
while((!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5) {
@@ -92,19 +94,19 @@ private function do_connect() {
9294
$this->_sqlerror('Zugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible!');
9395
return false;
9496
}
95-
97+
9698
if($this->dbName) $this->setDBName($this->dbName);
9799

98100
$this->_setCharset();
99101
}
100-
102+
101103
public function setDBData($host, $user, $password, $port) {
102104
$this->dbHost = $host;
103105
$this->dbUser = $user;
104106
$this->dbPass = $password;
105107
$this->dbPort = $port;
106108
}
107-
109+
108110
public function setDBName($name) {
109111
$this->dbName = $name;
110112
$this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort);
@@ -114,7 +116,7 @@ public function setDBName($name) {
114116
return false;
115117
}
116118
}
117-
119+
118120
public function close() {
119121
if($this->_iConnId) mysqli_close($this->_iConnId);
120122
$this->_iConnId = null;
@@ -192,7 +194,7 @@ private function _setCharset() {
192194
}
193195

194196
private function _query($sQuery = '') {
195-
197+
196198
$aArgs = func_get_args();
197199
$this->do_connect();
198200

@@ -284,7 +286,7 @@ public function query($sQuery = '') {
284286
* @return array result row or NULL if none found
285287
*/
286288
public function queryOneRecord($sQuery = '') {
287-
289+
288290
$aArgs = func_get_args();
289291
if(!empty($aArgs)) {
290292
$sQuery = array_shift($aArgs);
@@ -293,7 +295,7 @@ public function queryOneRecord($sQuery = '') {
293295
}
294296
array_unshift($aArgs, $sQuery);
295297
}
296-
298+
297299
$oResult = call_user_func_array([&$this, 'query'], $aArgs);
298300
if(!$oResult) return null;
299301

@@ -534,7 +536,7 @@ function insert($tablename, $form, $debug = 0)
534536
if($debug == 1) echo "mySQL Error Message: ".$this->errorMessage;
535537
}
536538
}
537-
539+
538540
/* TODO: rewrite SQL */
539541
function update($tablename, $form, $bedingung, $debug = 0)
540542
{
@@ -761,14 +763,14 @@ public function mapType($metaType, $typeValue) {
761763
break;
762764
}
763765
}
764-
766+
765767
/**
766768
* Get the database type (mariadb or mysql)
767769
*
768770
* @access public
769771
* @return string 'mariadb' or string 'mysql'
770772
*/
771-
773+
772774
public function getDatabaseType() {
773775
$tmp = $this->queryOneRecord('SELECT VERSION() as version');
774776
if(stristr($tmp['version'],'mariadb')) {
@@ -777,15 +779,15 @@ public function getDatabaseType() {
777779
return 'mysql';
778780
}
779781
}
780-
782+
781783
/**
782784
* Get the database version
783785
*
784786
* @access public
785787
* @param bool $major_version_only = true will return the major version only, e.g. 8 for MySQL 8
786788
* @return string version number
787789
*/
788-
790+
789791
public function getDatabaseVersion($major_version_only = false) {
790792
$tmp = $this->queryOneRecord('SELECT VERSION() as version');
791793
$version = explode('-', $tmp['version']);

install/tpl/config.inc.php.master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ $revision = str_replace(array('Revision:','$',' '), '', $svn_revision);
5656
//** Application
5757
define('ISPC_APP_TITLE', 'ISPConfig');
5858
define('ISPC_APP_VERSION', '3.2dev');
59-
define('DEVSYSTEM', 0);
59+
define('DEVSYSTEM', false);
6060

6161

6262
//** Database

0 commit comments

Comments
 (0)