From c2bf71c58f72cb9a4b251c28dc251f95808ea5c3 Mon Sep 17 00:00:00 2001 From: Assan Diomande Date: Wed, 13 Oct 2021 16:08:10 +0200 Subject: [PATCH 1/6] problems fixed with PHP 8.0 --- .../configObject/host/DB-Func.php | 68 ++++++++++--------- .../configObject/service/DB-Func.php | 6 +- .../options/media/images/formDirectory.php | 2 +- www/include/options/media/images/images.php | 11 ++- .../options/media/images/listImg.ihtml | 1 + 5 files changed, 46 insertions(+), 42 deletions(-) diff --git a/www/include/configuration/configObject/host/DB-Func.php b/www/include/configuration/configObject/host/DB-Func.php index 45b3f3f71f8..9f4490a0a23 100644 --- a/www/include/configuration/configObject/host/DB-Func.php +++ b/www/include/configuration/configObject/host/DB-Func.php @@ -701,10 +701,10 @@ function updateHostInDB($host_id = null, $from_MC = false, $cfg = null) updateHostNotifs($host_id); } -# Function for updating notification interval options -# 1 - MC with deletion of existing options (Replacement) -# 2 - MC with addition of new options (incremental) -# 3 - Normal update + # Function for updating notification interval options + # 1 - MC with deletion of existing options (Replacement) + # 2 - MC with addition of new options (incremental) + # 3 - Normal update if ( isset($ret["mc_mod_notifopt_notification_interval"]["mc_mod_notifopt_notification_interval"]) && $ret["mc_mod_notifopt_notification_interval"]["mc_mod_notifopt_notification_interval"] @@ -719,10 +719,10 @@ function updateHostInDB($host_id = null, $from_MC = false, $cfg = null) updateHostNotifOptionInterval($host_id); } -# Function for updating first notification delay options -# 1 - MC with deletion of existing options (Replacement) -# 2 - MC with addition of new options (incremental) -# 3 - Normal update, default behavior + # Function for updating first notification delay options + # 1 - MC with deletion of existing options (Replacement) + # 2 - MC with addition of new options (incremental) + # 3 - Normal update, default behavior if ( isset($ret["mc_mod_notifopt_first_notification_delay"]["mc_mod_notifopt_first_notification_delay"]) && $ret["mc_mod_notifopt_first_notification_delay"]["mc_mod_notifopt_first_notification_delay"] @@ -738,15 +738,15 @@ function updateHostInDB($host_id = null, $from_MC = false, $cfg = null) } -# Function for updating first notification delay options + # Function for updating first notification delay options updateHostNotifOptionRecoveryNotificationDelay($host_id); -# Function for updating notification timeperiod options -# 1 - MC with deletion of existing options (Replacement) -# 2 - MC with addition of new options (incremental) -# 3 - Normal update + # Function for updating notification timeperiod options + # 1 - MC with deletion of existing options (Replacement) + # 2 - MC with addition of new options (incremental) + # 3 - Normal update if ( isset($ret["mc_mod_notifopt_timeperiod"]["mc_mod_notifopt_timeperiod"]) && $ret["mc_mod_notifopt_timeperiod"]["mc_mod_notifopt_timeperiod"] @@ -761,10 +761,10 @@ function updateHostInDB($host_id = null, $from_MC = false, $cfg = null) updateHostNotifOptionTimeperiod($host_id); } -# Function for updating host hg -# 1 - MC with deletion of existing hg -# 2 - MC with addition of new hg -# 3 - Normal update + # Function for updating host hg + # 1 - MC with deletion of existing hg + # 2 - MC with addition of new hg + # 3 - Normal update if (isset($ret["mc_mod_hhg"]["mc_mod_hhg"]) && $ret["mc_mod_hhg"]["mc_mod_hhg"]) { updateHostHostGroup($host_id); } elseif (isset($ret["mc_mod_hhg"]["mc_mod_hhg"]) && !$ret["mc_mod_hhg"]["mc_mod_hhg"]) { @@ -773,10 +773,10 @@ function updateHostInDB($host_id = null, $from_MC = false, $cfg = null) updateHostHostGroup($host_id); } -# Function for updating host hc -# 1 - MC with deletion of existing hc -# 2 - MC with addition of new hc -# 3 - Normal update + # Function for updating host hc + # 1 - MC with deletion of existing hc + # 2 - MC with addition of new hc + # 3 - Normal update if (isset($ret["mc_mod_hhc"]["mc_mod_hhc"]) && $ret["mc_mod_hhc"]["mc_mod_hhc"]) { updateHostHostCategory($host_id); } elseif (isset($ret["mc_mod_hhc"]["mc_mod_hhc"]) && !$ret["mc_mod_hhc"]["mc_mod_hhc"]) { @@ -785,10 +785,10 @@ function updateHostInDB($host_id = null, $from_MC = false, $cfg = null) updateHostHostCategory($host_id, $ret); } -# Function for updating host template -# 1 - MC with deletion of existing template -# 2 - MC with addition of new template -# 3 - Normal update + # Function for updating host template + # 1 - MC with deletion of existing template + # 2 - MC with addition of new template + # 3 - Normal update if (isset($ret["mc_mod_htpl"]["mc_mod_htpl"]) && $ret["mc_mod_htpl"]["mc_mod_htpl"]) { updateHostTemplateService($host_id); } elseif (isset($ret["mc_mod_htpl"]["mc_mod_htpl"]) && !$ret["mc_mod_htpl"]["mc_mod_htpl"]) { @@ -2316,7 +2316,6 @@ function updateHostTemplateService_MC($host_id = null) if (!$host_id) { return; } - $dbResult = $pearDB->query("SELECT host_register FROM host WHERE host_id = '" . (int)$host_id . "'"); $row = $dbResult->fetch(); if ($row["host_register"] == 0) { @@ -2329,13 +2328,16 @@ function updateHostTemplateService_MC($host_id = null) } $ret = $form->getSubmitValue("host_svTpls"); - for ($i = 0; $i < count($ret); $i++) { - if (!isset($svtpls[$ret[$i]])) { - $rq = "INSERT INTO host_service_relation "; - $rq .= "(hostgroup_hg_id, host_host_id, servicegroup_sg_id, service_service_id) "; - $rq .= "VALUES "; - $rq .= "(NULL, '" . (int)$host_id . "', NULL, '" . $ret[$i] . "')"; - $dbResult2 = $pearDB->query($rq); + + if (!empty($ret)) { + for ($i = 0; $i < count($ret); $i++) { + if (!isset($svtpls[$ret[$i]])) { + $rq = "INSERT INTO host_service_relation "; + $rq .= "(hostgroup_hg_id, host_host_id, servicegroup_sg_id, service_service_id) "; + $rq .= "VALUES "; + $rq .= "(NULL, '" . (int)$host_id . "', NULL, '" . $ret[$i] . "')"; + $dbResult2 = $pearDB->query($rq); + } } } } elseif ($centreon->user->get_version() >= 3) { diff --git a/www/include/configuration/configObject/service/DB-Func.php b/www/include/configuration/configObject/service/DB-Func.php index 7c1ae1781c0..93096795ff0 100644 --- a/www/include/configuration/configObject/service/DB-Func.php +++ b/www/include/configuration/configObject/service/DB-Func.php @@ -447,8 +447,8 @@ function divideHostGroupsToHostGroup($service_id) $query = "SELECT hostgroup_hg_id FROM host_service_relation " . "WHERE service_service_id = '" . $service_id . "' AND hostgroup_hg_id IS NOT NULL"; - $dbResult3 = $pearDB->query(); - while ($data = $dbResult3->fetch($query)) { + $dbResult3 = $pearDB->query($query); + while ($data = $dbResult3->fetch()) { $sv_id = multipleServiceInDB( array($service_id => "1"), array($service_id => "1"), @@ -1753,6 +1753,8 @@ function updateServiceNotifs($service_id = null, $ret = array()) // For massive change. incremental mode function updateServiceNotifs_MC($service_id = null) { + require_once "./include/common/javascript/commandGetArgs/cmdGetExample.php"; + if (!$service_id) { return; } diff --git a/www/include/options/media/images/formDirectory.php b/www/include/options/media/images/formDirectory.php index d714278b090..0f6bf355506 100644 --- a/www/include/options/media/images/formDirectory.php +++ b/www/include/options/media/images/formDirectory.php @@ -114,7 +114,7 @@ # Var information to format the element # $attrsText = array("size"=>"30"); -$attrsSelect = array("size"=>"5", "multiple"=>"1", "cols"=>"40"); +$attrsSelect = array("size"=>"5", "multiple"=>"1", "cols"=>"40","required"=>"true"); $attrsAdvSelect = array("style" => "width: 250px; height: 250px;"); $attrsTextarea = array("rows"=>"5", "cols"=>"40"); diff --git a/www/include/options/media/images/images.php b/www/include/options/media/images/images.php index 21d02bd5ebf..4552567a84d 100644 --- a/www/include/options/media/images/images.php +++ b/www/include/options/media/images/images.php @@ -59,12 +59,6 @@ FILTER_VALIDATE_INT ); -// If one data are not correctly typed in array, it will be set to false -$selectIds = filter_var_array( - $_GET["select"] ?? $_POST["select"] ?? array(), - FILTER_VALIDATE_INT -); - /* * Path to the cities dir */ @@ -95,6 +89,11 @@ require_once($path . "formDirectory.php"); break; case IMAGE_DELETE: + // If one data are not correctly typed in array, it will be set to false + $selectIds = filter_var_array( + $_GET["select"] ?? $_POST["select"] ?? array(), + FILTER_VALIDATE_INT + ); purgeOutdatedCSRFTokens(); if (isCSRFTokenValid()) { purgeCSRFToken(); diff --git a/www/include/options/media/images/listImg.ihtml b/www/include/options/media/images/listImg.ihtml index dad28120a48..b502bbac887 100644 --- a/www/include/options/media/images/listImg.ihtml +++ b/www/include/options/media/images/listImg.ihtml @@ -1,6 +1,7 @@
+ From 1174efb1ee720fca13a0d8ff8b33c48d74590445 Mon Sep 17 00:00:00 2001 From: Assan Diomande Date: Wed, 13 Oct 2021 17:12:01 +0200 Subject: [PATCH 2/6] fixed centreon-box suggestions --- www/include/configuration/configObject/host/DB-Func.php | 1 - www/include/options/media/images/formDirectory.php | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/www/include/configuration/configObject/host/DB-Func.php b/www/include/configuration/configObject/host/DB-Func.php index 9f4490a0a23..c20bb8f8475 100644 --- a/www/include/configuration/configObject/host/DB-Func.php +++ b/www/include/configuration/configObject/host/DB-Func.php @@ -2328,7 +2328,6 @@ function updateHostTemplateService_MC($host_id = null) } $ret = $form->getSubmitValue("host_svTpls"); - if (!empty($ret)) { for ($i = 0; $i < count($ret); $i++) { if (!isset($svtpls[$ret[$i]])) { diff --git a/www/include/options/media/images/formDirectory.php b/www/include/options/media/images/formDirectory.php index 0f6bf355506..ca699facd64 100644 --- a/www/include/options/media/images/formDirectory.php +++ b/www/include/options/media/images/formDirectory.php @@ -113,8 +113,8 @@ ########################################################## # Var information to format the element # -$attrsText = array("size"=>"30"); -$attrsSelect = array("size"=>"5", "multiple"=>"1", "cols"=>"40","required"=>"true"); +$attrsText = array("size" => "30"); +$attrsSelect = array("size"=>"5", "multiple"=>"1", "cols"=>"40", "required"=>"true"); $attrsAdvSelect = array("style" => "width: 250px; height: 250px;"); $attrsTextarea = array("rows"=>"5", "cols"=>"40"); From 5499f24984fff7d11429d607fe78c88f6311dccd Mon Sep 17 00:00:00 2001 From: Assan Diomande Date: Fri, 15 Oct 2021 09:54:09 +0200 Subject: [PATCH 3/6] resolved centreon-bot suggestions --- ldap-test.yml | 12 ++++++++++++ log/install_centreon.log | 19 +++++++++++++++++++ .../options/media/images/formDirectory.php | 4 ++-- 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 ldap-test.yml create mode 100644 log/install_centreon.log diff --git a/ldap-test.yml b/ldap-test.yml new file mode 100644 index 00000000000..5913ab553cf --- /dev/null +++ b/ldap-test.yml @@ -0,0 +1,12 @@ +version: '3.1' + +services: + openldap: + image: registry.centreon.com/mon-openldap:latest + ports: + - "389" + centreon-web-develop: + image: registry.centreon.com/mon-web-develop:centos7 + ports: + - 8082:80 + - 3310:3309 \ No newline at end of file diff --git a/log/install_centreon.log b/log/install_centreon.log new file mode 100644 index 00000000000..21b1ebaddee --- /dev/null +++ b/log/install_centreon.log @@ -0,0 +1,19 @@ +[./install.sh]:INFO: GREP=/usr/bin/grep +[./install.sh]:INFO: CAT=/usr/bin/cat +[./install.sh]:INFO: SED=/usr/bin/sed +[./install.sh]:INFO: CHMOD=/usr/bin/chmod +[./install.sh]:INFO: CHOWN=/usr/bin/chown +rm : OK +cp : OK +mv : OK +/usr/bin/chmod : OK +/usr/bin/chown : OK +echo : OK +more : FAIL +[./install.sh]:ERR: $binary not found in $PATH +mkdir : OK +find : OK +/usr/bin/grep : OK +/usr/bin/cat : OK +/usr/bin/sed : OK +Please check fail binary and retry : diff --git a/www/include/options/media/images/formDirectory.php b/www/include/options/media/images/formDirectory.php index ca699facd64..5bfadcb153e 100644 --- a/www/include/options/media/images/formDirectory.php +++ b/www/include/options/media/images/formDirectory.php @@ -114,9 +114,9 @@ # Var information to format the element # $attrsText = array("size" => "30"); -$attrsSelect = array("size"=>"5", "multiple"=>"1", "cols"=>"40", "required"=>"true"); +$attrsSelect = array("size" => "5", "multiple" => "1", "cols" => "40", "required" => "true"); $attrsAdvSelect = array("style" => "width: 250px; height: 250px;"); -$attrsTextarea = array("rows"=>"5", "cols"=>"40"); +$attrsTextarea = array("rows" => "5", "cols" => "40"); # ## Form begin From e7f3a87dd04338cab1596951fbd8d764838d7301 Mon Sep 17 00:00:00 2001 From: AssanDiomande Date: Fri, 15 Oct 2021 10:05:28 +0200 Subject: [PATCH 4/6] Delete ldap-test.yml --- ldap-test.yml | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 ldap-test.yml diff --git a/ldap-test.yml b/ldap-test.yml deleted file mode 100644 index 5913ab553cf..00000000000 --- a/ldap-test.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: '3.1' - -services: - openldap: - image: registry.centreon.com/mon-openldap:latest - ports: - - "389" - centreon-web-develop: - image: registry.centreon.com/mon-web-develop:centos7 - ports: - - 8082:80 - - 3310:3309 \ No newline at end of file From 71a367eb5ab06059afa8d9859d2bc304f0ab3ff5 Mon Sep 17 00:00:00 2001 From: AssanDiomande Date: Fri, 15 Oct 2021 11:09:13 +0200 Subject: [PATCH 5/6] Delete log --- log/install_centreon.log | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 log/install_centreon.log diff --git a/log/install_centreon.log b/log/install_centreon.log deleted file mode 100644 index 21b1ebaddee..00000000000 --- a/log/install_centreon.log +++ /dev/null @@ -1,19 +0,0 @@ -[./install.sh]:INFO: GREP=/usr/bin/grep -[./install.sh]:INFO: CAT=/usr/bin/cat -[./install.sh]:INFO: SED=/usr/bin/sed -[./install.sh]:INFO: CHMOD=/usr/bin/chmod -[./install.sh]:INFO: CHOWN=/usr/bin/chown -rm : OK -cp : OK -mv : OK -/usr/bin/chmod : OK -/usr/bin/chown : OK -echo : OK -more : FAIL -[./install.sh]:ERR: $binary not found in $PATH -mkdir : OK -find : OK -/usr/bin/grep : OK -/usr/bin/cat : OK -/usr/bin/sed : OK -Please check fail binary and retry : From f034308cef4c034b3f7dc99e2b47d8b19a21263b Mon Sep 17 00:00:00 2001 From: AssanDiomande Date: Mon, 18 Oct 2021 10:03:28 +0200 Subject: [PATCH 6/6] Update listImg.ihtml --- www/include/options/media/images/listImg.ihtml | 1 - 1 file changed, 1 deletion(-) diff --git a/www/include/options/media/images/listImg.ihtml b/www/include/options/media/images/listImg.ihtml index b502bbac887..dad28120a48 100644 --- a/www/include/options/media/images/listImg.ihtml +++ b/www/include/options/media/images/listImg.ihtml @@ -1,7 +1,6 @@
{t}Filters{/t}
-
{t}Filters{/t}