From 86e6990d7e6f5634f83ef2a125e14cf08bac1dc0 Mon Sep 17 00:00:00 2001 From: Marius Cramer <m.cramer@pixcept.de> Date: Fri, 22 May 2015 18:46:29 +0200 Subject: [PATCH] - checked and fixed usage of empty() --- install/dist/lib/centos52.lib.php | 3 ++- install/dist/lib/centos53.lib.php | 4 ++-- install/dist/lib/centos70.lib.php | 2 +- install/dist/lib/fedora.lib.php | 2 +- install/dist/lib/opensuse.lib.php | 2 +- install/lib/installer_base.lib.php | 2 +- interface/lib/app.inc.php | 2 +- interface/lib/classes/tform_base.inc.php | 4 ++-- server/lib/classes/file.inc.php | 2 +- server/plugins-available/mailman_plugin.inc.php | 4 ++-- 10 files changed, 14 insertions(+), 13 deletions(-) diff --git a/install/dist/lib/centos52.lib.php b/install/dist/lib/centos52.lib.php index 911152804e..7e7cf7354d 100644 --- a/install/dist/lib/centos52.lib.php +++ b/install/dist/lib/centos52.lib.php @@ -51,7 +51,7 @@ class installer extends installer_dist { if (trim($line) != '' && substr($line, 0, 1) != '#') { @list($key, $value) = @explode("=", $line); - if (!empty($value)) + if (isset($value) && $value !== '') { $key = rtrim($key); $old_options[$key] = trim($value); @@ -112,6 +112,7 @@ class installer extends installer_dist { // amavisd user config file $configfile = 'fedora_amavisd_conf'; + if(!is_dir($conf["amavis"]["config_dir"])) mkdir($conf["amavis"]["config_dir"]); if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf', $conf["amavis"]["config_dir"].'/amavisd.conf~'); if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/amavisd.conf~'); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "tpl/".$configfile.".master"); diff --git a/install/dist/lib/centos53.lib.php b/install/dist/lib/centos53.lib.php index 0ac99f266a..81156da9dc 100644 --- a/install/dist/lib/centos53.lib.php +++ b/install/dist/lib/centos53.lib.php @@ -51,7 +51,7 @@ class installer extends installer_dist { if (trim($line) != '' && substr($line, 0, 1) != '#') { @list($key, $value) = @explode("=", $line); - if (!empty($value)) + if (isset($value) && $value !== '') { $key = rtrim($key); $old_options[$key] = trim($value); @@ -112,9 +112,9 @@ class installer extends installer_dist { // amavisd user config file $configfile = 'fedora_amavisd_conf'; + if(!is_dir($conf["amavis"]["config_dir"])) mkdir($conf["amavis"]["config_dir"]); if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf', $conf["amavis"]["config_dir"].'/amavisd.conf~'); if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/amavisd.conf~'); - if(!is_dir($conf["amavis"]["config_dir"])) mkdir($conf["amavis"]["config_dir"]); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "tpl/".$configfile.".master"); $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content); $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content); diff --git a/install/dist/lib/centos70.lib.php b/install/dist/lib/centos70.lib.php index 9cee55ff2d..54542dd69b 100644 --- a/install/dist/lib/centos70.lib.php +++ b/install/dist/lib/centos70.lib.php @@ -51,7 +51,7 @@ class installer extends installer_dist { if (trim($line) != '' && substr($line, 0, 1) != '#') { @list($key, $value) = @explode("=", $line); - if (!empty($value)) + if (isset($value) && $value !== '') { $key = rtrim($key); $old_options[$key] = trim($value); diff --git a/install/dist/lib/fedora.lib.php b/install/dist/lib/fedora.lib.php index f017ea544e..658af9bcb5 100644 --- a/install/dist/lib/fedora.lib.php +++ b/install/dist/lib/fedora.lib.php @@ -51,7 +51,7 @@ class installer_dist extends installer_base { if (trim($line) != '' && substr($line, 0, 1) != '#') { @list($key, $value) = @explode("=", $line); - if (!empty($value)) + if (isset($value) && $value !== '') { $key = rtrim($key); $old_options[$key] = trim($value); diff --git a/install/dist/lib/opensuse.lib.php b/install/dist/lib/opensuse.lib.php index b452c2f2e1..ec278b9c11 100644 --- a/install/dist/lib/opensuse.lib.php +++ b/install/dist/lib/opensuse.lib.php @@ -67,7 +67,7 @@ class installer_dist extends installer_base { if (trim($line) != '' && substr($line, 0, 1) != '#') { @list($key, $value) = @explode("=", $line); - if (!empty($value)) + if (isset($value) && $value !== '') { $key = rtrim($key); $old_options[$key] = trim($value); diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index f867f04df8..12fc8a066a 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -616,7 +616,7 @@ class installer_base { if (trim($line) != '' && substr($line, 0, 1) != '#') { @list($key, $value) = @explode("=", $line); - if (!empty($value)) + if (isset($value) && $value !== '') { $key = rtrim($key); $old_options[$key] = trim($value); diff --git a/interface/lib/app.inc.php b/interface/lib/app.inc.php index 949f1643cf..e23b6cab70 100755 --- a/interface/lib/app.inc.php +++ b/interface/lib/app.inc.php @@ -240,7 +240,7 @@ class app { } $this->_language_inc = 1; } - if(!empty($this->_wb[$text])) { + if(isset($this->_wb[$text]) && $this->wb[$text] !== '') { $text = $this->_wb[$text]; } else { if($this->_conf['debug_language']) { diff --git a/interface/lib/classes/tform_base.inc.php b/interface/lib/classes/tform_base.inc.php index 749ea5c708..f5de5585f3 100644 --- a/interface/lib/classes/tform_base.inc.php +++ b/interface/lib/classes/tform_base.inc.php @@ -447,7 +447,7 @@ class tform_base { if(is_array($field['value'])) { foreach($field['value'] as $k => $v) { $selected = ($k == $val)?' SELECTED':''; - if(!empty($this->wordbook[$v])) + if(isset($this->wordbook[$v])) $v = $this->wordbook[$v]; $out .= "<option value='$k'$selected>".$this->lng($v)."</option>\r\n"; } @@ -881,7 +881,7 @@ class tform_base { } break; case 'NOTEMPTY': - if(empty($field_value)) { + if(!isset($field_value) || $field_value === '') { $errmsg = $validator['errmsg']; if(isset($this->wordbook[$errmsg])) { $this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n"; diff --git a/server/lib/classes/file.inc.php b/server/lib/classes/file.inc.php index a5f4c84d56..eadb38b789 100644 --- a/server/lib/classes/file.inc.php +++ b/server/lib/classes/file.inc.php @@ -190,7 +190,7 @@ class file{ // @ext_save : 1 for YES, 0 for NO - meaning it will filter out system files or not (such as .htaccess) $dirname = realpath($dirname); - if (!$exts || empty($exts) || $exts == '') { + if (empty($exts)) { $exts = array('jpg', 'gif', 'jpeg', 'png'); } if ($handle = opendir($dirname)) { diff --git a/server/plugins-available/mailman_plugin.inc.php b/server/plugins-available/mailman_plugin.inc.php index 9ebb2aa9a7..0d282f50bf 100644 --- a/server/plugins-available/mailman_plugin.inc.php +++ b/server/plugins-available/mailman_plugin.inc.php @@ -115,7 +115,7 @@ class mailman_plugin { function update_config() { global $app, $conf; - copy($this->mailman_config_dir.'mm_cfg.py', $this->mailman_config_dir.'mm_cfg.py'); + copy($this->mailman_config_dir.'mm_cfg.py', $this->mailman_config_dir.'mm_cfg.py~'); // load the server configuration options $app->uses('getconf'); @@ -136,7 +136,7 @@ class mailman_plugin { if (strlen($line) && substr($line, 0, 1) != '#') { list($key, $value) = explode("=", $line); - if (!empty($value)) + if ($value && $value !== '') { $key = rtrim($key); $old_options[$key] = trim($value); -- GitLab