Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
fix(engine): Deletion of excess code from PR #7591 (#8196) (#8204)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpinsivy authored and loiclau committed Dec 30, 2019
1 parent 6bb9349 commit abf71cf
Showing 1 changed file with 5 additions and 67 deletions.
72 changes: 5 additions & 67 deletions www/include/configuration/configNagios/DB-Func.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,34 +219,6 @@ function insertNagiosInDB()
return ($nagios_id);
}

/**
* Calculate the sum of bitwise for a POST QuickForm array
*
* The array format
*
* array[key] => enable
* Key int the bit
* Enable 0|1 if the bit is activate
*
* if found the bit -1 (all) or 0 (none) activate return the value
*
* @param array $list The POST QuickForm table
* @return int The bitwise
*/
function calculateBitwise($list)
{
$bitwise = 0;
foreach ($list as $bit => $value) {
if ($value == 1) {
if ($bit === -1 || $bit === 0) {
return $bit;
}
$bitwise += $bit;
}
}
return $bitwise;
}

function insertNagios($ret = array(), $brokerTab = array())
{
global $form, $pearDB, $centreon;
Expand Down Expand Up @@ -302,7 +274,7 @@ function insertNagios($ret = array(), $brokerTab = array())
. "`admin_email` , `admin_pager` , `nagios_comment` , `nagios_activate`, "
. "`event_broker_options` , `translate_passive_host_checks`, "
. "`passive_host_checks_are_soft`, `check_for_orphaned_hosts`, `external_command_buffer_slots`, "
. "`cfg_file`, `log_pid`, `use_check_result_path`, `enable_macros_filter`, `macros_filter`) ";
. "`cfg_file`, `log_pid`, `use_check_result_path`) ";
$rq .= "VALUES (";
$rq .= "NULL, ";

Expand Down Expand Up @@ -1092,9 +1064,8 @@ function insertNagios($ret = array(), $brokerTab = array())
$rq .= "'0',";
}

// Calculate the sum of bitwise
if (isset($ret['event_broker_options']) && $ret['event_broker_options'] != null) {
$rq .= "'" . calculateBitwise($ret["event_broker_options"]) . "', ";
if (isset($ret["event_broker_options"]) && $ret["event_broker_options"] != null) {
$rq .= "'" . htmlentities($ret["event_broker_options"], ENT_QUOTES, "UTF-8") . "', ";
} else {
$rq .= "'-1', ";
}
Expand Down Expand Up @@ -1148,23 +1119,8 @@ function insertNagios($ret = array(), $brokerTab = array())
) {
$rq .= "'1',";
} else {
$rq .= "'0',";
}

if (isset($ret['enable_macros_filter']['enable_macros_filter'])
&& $ret['enable_macros_filter']['enable_macros_filter']) {
$rq .= "'1', ";
} else {
$rq .= "'0', ";
$rq .= "'0')";
}
/* Add whitelist macros to send to Centreon Broker */
$macrosFilter = trim(
join(
',',
array_map(function ($value) { return CentreonDB::escape($value); }, $_REQUEST['macros_filter'])
)
);
$rq .= "'" . $macrosFilter . "')";

$dbResult = $pearDB->query($rq);
$dbResult = $pearDB->query("SELECT MAX(nagios_id) FROM cfg_nagios");
Expand Down Expand Up @@ -2038,9 +1994,8 @@ function updateNagios($nagios_id = null)
$rq .= "nagios_comment = NULL, ";
}

/* Calculate the sum of bitwise */
if (isset($ret["event_broker_options"]) && $ret["event_broker_options"] != null) {
$rq .= "event_broker_options = '" . calculateBitwise($ret['event_broker_options']) . "', ";
$rq .= "event_broker_options = '" . htmlentities($ret["event_broker_options"], ENT_QUOTES, "UTF-8") . "', ";
} else {
$rq .= "event_broker_options = '-1', ";
}
Expand Down Expand Up @@ -2145,23 +2100,6 @@ function updateNagios($nagios_id = null)
$rq .= "use_check_result_path = '0', ";
}

if (isset($ret['enable_macros_filter']['enable_macros_filter'])
&& $ret['enable_macros_filter']['enable_macros_filter']
) {
$rq .= "enable_macros_filter = '1', ";
} else {
$rq .= "enable_macros_filter = '0', ";
}

/* Add whitelist macros to send to Centreon Broker */
$macrosFilter = trim(
join(
',',
array_map(function ($value) { return CentreonDB::escape($value); }, $_REQUEST['macros_filter'])
)
);
$rq .= "macros_filter = '" . $macrosFilter . "', ";

$rq .= "nagios_activate = '" . $ret["nagios_activate"]["nagios_activate"] . "' ";
$rq .= "WHERE nagios_id = '" . $nagios_id . "'";
$dbResult = $pearDB->query($rq);
Expand Down

0 comments on commit abf71cf

Please sign in to comment.