diff --git a/www/include/configuration/configObject/host/DB-Func.php b/www/include/configuration/configObject/host/DB-Func.php index 45b3f3f71f8..c20bb8f8475 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,15 @@ 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..5bfadcb153e 100644 --- a/www/include/options/media/images/formDirectory.php +++ b/www/include/options/media/images/formDirectory.php @@ -113,10 +113,10 @@ ########################################################## # Var information to format the element # -$attrsText = array("size"=>"30"); -$attrsSelect = array("size"=>"5", "multiple"=>"1", "cols"=>"40"); +$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"); +$attrsTextarea = array("rows" => "5", "cols" => "40"); # ## Form begin 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();