Skip to content

Commit 6515e55

Browse files
committed
Fixed various PHP 8.x warnings
1 parent 4baa67a commit 6515e55

File tree

11 files changed

+38
-27
lines changed

11 files changed

+38
-27
lines changed

install/lib/installer_base.lib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3333,7 +3333,7 @@ public function make_ispconfig_ssl_cert() {
33333333
}
33343334

33353335
// If the LE SSL certs for this hostname exists
3336-
if(!is_dir($acme_cert_dir) || !file_exists($check_acme_file) || !$issued_successfully) {
3336+
if(!is_dir($acme_cert_dir) || !file_exists($check_acme_file) || !isset($issued_successfully) || !$issued_successfully) {
33373337
if(!$issued_successfully) {
33383338
swriteln('Could not issue letsencrypt certificate, falling back to self-signed.');
33393339
} else {

interface/lib/classes/db_mysql.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ public function getDatabaseSize($database_name) {
668668
$clientdb_user = ($conf['db_user']) ? $conf['db_user'] : NULL;
669669
$clientdb_password = ($conf['db_password']) ? $conf['db_password'] : NULL;
670670
$clientdb_port = ((int)$conf['db_port']) ? (int)$conf['db_port'] : NULL;
671-
$clientdb_flags = ($conf['db_flags'] !== NULL) ? $conf['db_flags'] : NULL;
671+
$clientdb_flags = (isset($conf['db_flags']) && $conf['db_flags'] !== NULL) ? $conf['db_flags'] : NULL;
672672

673673
require_once 'lib/mysql_clientdb.conf';
674674

interface/web/mail/mail_domain_edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ private function find_soa_domain($domain) {
730730
$soaDomain = $domain . '.';
731731
$soa = null;
732732
while ((!isset($soa) && (substr_count($soaDomain,'.') > 1))) {
733-
$soa = $app->db->queryOneRecord("SELECT id AS zone, sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, server_id, ttl, serial FROM dns_soa WHERE active = 'Y' AND origin = ?", $soaDomain);
733+
$soa = $app->db->queryOneRecord("SELECT `id` AS `zone`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `ttl`, `serial` FROM `dns_soa` WHERE `active` = 'Y' AND `origin` = ?", $soaDomain);
734734
$soaDomain = preg_replace("/^[^\.]+\./","",$soaDomain);
735735
}
736736
return $soa;

server/lib/app.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
/**
2+
/*
33
Copyright (c) 2007-2022, Till Brehm, projektfarm Gmbh
44
All rights reserved.
55
@@ -324,7 +324,7 @@ function log($msg, $priority = 0, $dblog = true) {
324324

325325
// Send an email to the administrator if the current priority demands it.
326326
if(isset($conf['admin_notify_priority']) && $priority >= $conf['admin_notify_priority'] && $conf['admin_mail'] != '') {
327-
if($conf['hostname'] != 'localhost' && $conf['hostname'] != '') {
327+
if(isset($conf['hostname']) && $conf['hostname'] != 'localhost' && $conf['hostname'] != '') {
328328
$hostname = $conf['hostname'];
329329
} else {
330330
$hostname = exec('hostname -f');

server/lib/classes/cron.d/100-monitor_clamav_log.inc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,17 @@ public function onRunJob() {
105105

106106
$tmp = explode("\n", $data);
107107
$lastLog = array();
108-
if (count($tmp) >= 2) {
108+
if (is_array($tmp) && count($tmp) >= 2) {
109109
if ($tmp[sizeof($tmp) - 1] == '') {
110110
/* the log ends with an empty line remove this */
111111
array_pop($tmp);
112112
}
113-
if (strpos($tmp[sizeof($tmp) - 1], '-------------') !== false) {
113+
if (isset($tmp[sizeof($tmp) - 1]) && strpos($tmp[sizeof($tmp) - 1], '-------------') !== false) {
114114
/* the log ends with "-----..." remove this */
115115
array_pop($tmp);
116116
}
117117
for ($i = sizeof($tmp) - 1; $i > 0; $i--) {
118-
if (strpos($tmp[$i], '---------') === false) {
118+
if (isset($tmp[$i]) && strpos($tmp[$i], '---------') === false) {
119119
/* no delimiter found, so add this to the last-log */
120120
$lastLog[] = $tmp[$i];
121121
} else {

server/lib/classes/cron.d/100-monitor_mem_usage.inc.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,16 @@ public function onRunJob() {
7575
$memInfo = explode("\n", $miData);
7676

7777
foreach ($memInfo as $line) {
78-
if (strlen($line) >= 1){
78+
if (!empty($line) && strlen($line) >= 1){
7979
$part = preg_split('/:/', $line);
80-
$key = trim($part[0]);
81-
$tmp = explode(' ', trim($part[1]));
82-
$value = 0;
83-
if (isset($tmp[1]) && $tmp[1] == 'kB')
84-
$value = $tmp[0] * 1024;
85-
$data[$key] = $value;
80+
if(is_array($part) && isset($part[0]) && isset($part[1])) {
81+
$key = trim($part[0]);
82+
$tmp = explode(' ', trim($part[1]));
83+
$value = 0;
84+
if (isset($tmp[1]) && $tmp[1] == 'kB')
85+
$value = $tmp[0] * 1024;
86+
$data[$key] = $value;
87+
}
8688
}
8789
}
8890

server/lib/classes/cron.d/100-monitor_system_update.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public function onRunJob() {
216216

217217
//* Ensure that output is encoded so that it does not break the serialize
218218
//$res['data']['output'] = htmlentities($res['data']['output']);
219-
$res['data']['output'] = $res['data']['output'] ? htmlentities($res['data']['output'], ENT_QUOTES, 'UTF-8') : null;
219+
$res['data']['output'] = (isset($res['data']['output']) && !empty($res['data']['output'])) ? htmlentities($res['data']['output'], ENT_QUOTES, 'UTF-8') : null;
220220

221221
/*
222222
* Insert the data into the database

server/lib/classes/cronjob.inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class cronjob {
4242
protected $_last_run = null;
4343
protected $_next_run = null;
4444
private $_running = false;
45+
protected $_tools = null;
4546

4647
// services for delayed restart/reload
4748
private $_delayed_restart_services = array();

server/lib/classes/system.inc.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -925,13 +925,18 @@ function mkdir($dirname, $allow_symlink = false, $mode = 0777, $recursive = fals
925925
}
926926

927927
function unlink($filename) {
928-
if(file_exists($filename) || is_link($filename)) {
928+
if(!empty($filename) && file_exists($filename) || is_link($filename)) {
929929
return unlink($filename);
930930
}
931931
}
932932

933933
function copy($file1, $file2) {
934-
return copy($file1, $file2);
934+
if(!empty($file1) && !empty($file2)) {
935+
return copy($file1, $file2);
936+
} else {
937+
return false;
938+
}
939+
935940
}
936941

937942
function move($file1, $file2) {
@@ -942,6 +947,7 @@ function move($file1, $file2) {
942947
}
943948

944949
function rmdir($path, $recursive=false) {
950+
global $app;
945951
// Disallow operating on root directory
946952
if(realpath($path) == '/') {
947953
$app->log("rmdir: afraid I might delete root: $path", LOGLEVEL_WARN);
@@ -1117,15 +1123,15 @@ function checkpath($path) {
11171123
function check_free_space($path, $limit = 0, &$free_space = 0) {
11181124
$path = rtrim($path, '/');
11191125

1120-
/**
1126+
/*
11211127
* Make sure that we have only existing directories in the path.
11221128
11231129
* Given a file name instead of a directory, the behaviour of the disk_free_space
11241130
function is unspecified and may differ between operating systems and PHP versions.
11251131
*/
11261132
while(!is_dir($path) && $path != '/') $path = realpath(dirname($path));
11271133

1128-
$free_space = disk_free_space($out);
1134+
$free_space = disk_free_space($path);
11291135

11301136
if (!$free_space) {
11311137
$free_space = 0;

server/plugins-available/apache2_plugin.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ function update($event_name, $data) {
848848

849849
// Get the client ID
850850
$client = $app->dbmaster->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = ?', $data['new']['sys_groupid']);
851-
$client_id = intval($client['client_id']);
851+
$client_id = (!empty($client))?intval($client['client_id']):0;
852852
unset($client);
853853

854854
// Remove old symlinks, if site is renamed

0 commit comments

Comments
 (0)