}
} else {
    if (inarr_isset(array('delete_ckecks', 'selected_checks'))) {
        foreach ($_REQUEST['selected_checks'] as $chk_id) {
            if (isset($_REQUEST['dchecks'][$chk_id]['dcheckid'])) {
                $_REQUEST['dchecks_deleted'][] = $_REQUEST['dchecks'][$chk_id]['dcheckid'];
            }
            unset($_REQUEST['dchecks'][$chk_id]);
        }
    } else {
        if (inarr_isset('save')) {
            if (inarr_isset('druleid')) {
                /* update */
                $msg_ok = S_DISCOVERY_RULE_UPDATED;
                $msg_fail = S_CANNOT_UPDATE_DISCOVERY_RULE;
                $result = update_discovery_rule($_REQUEST["druleid"], $_REQUEST["proxy_hostid"], $_REQUEST['name'], $_REQUEST['iprange'], $_REQUEST['delay'], $_REQUEST['status'], $_REQUEST['dchecks'], $_REQUEST['uniqueness_criteria'], $_REQUEST['dchecks_deleted']);
                $druleid = $_REQUEST["druleid"];
            } else {
                /* add new */
                $msg_ok = S_DISCOVERY_RULE_ADDED;
                $msg_fail = S_CANNOT_ADD_DISCOVERY_RULE;
                $druleid = add_discovery_rule($_REQUEST["proxy_hostid"], $_REQUEST['name'], $_REQUEST['iprange'], $_REQUEST['delay'], $_REQUEST['status'], $_REQUEST['dchecks'], $_REQUEST['uniqueness_criteria']);
                $result = $druleid;
            }
            show_messages($result, $msg_ok, $msg_fail);
            if ($result) {
                // result - OK
                add_audit(!isset($_REQUEST['druleid']) ? AUDIT_ACTION_ADD : AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_DISCOVERY_RULE, '[' . $druleid . '] ' . $_REQUEST['name']);
                unset($_REQUEST['form']);
            }
        } else {
示例#2
0
    $new_dcheck = array('type' => $_REQUEST['new_check_type'], 'ports' => $_REQUEST['new_check_ports'], 'key' => $_REQUEST['new_check_key'], 'snmp_community' => $_REQUEST['new_check_snmp_community']);
    if (!str_in_array($new_dcheck, $_REQUEST['dchecks'])) {
        $_REQUEST['dchecks'][] = $new_dcheck;
    }
} else {
    if (inarr_isset(array('delete_ckecks', 'selected_checks'))) {
        foreach ($_REQUEST['selected_checks'] as $chk_id) {
            unset($_REQUEST['dchecks'][$chk_id]);
        }
    } else {
        if (inarr_isset('save')) {
            if (inarr_isset('druleid')) {
                /* update */
                $msg_ok = S_DISCOVERY_RULE_UPDATED;
                $msg_fail = S_CANNOT_UPDATE_DISCOVERY_RULE;
                $result = update_discovery_rule($_REQUEST["druleid"], $_REQUEST["proxy_hostid"], $_REQUEST['name'], $_REQUEST['iprange'], $_REQUEST['delay'], $_REQUEST['status'], $_REQUEST['dchecks']);
                $druleid = $_REQUEST["druleid"];
            } else {
                /* add new */
                $msg_ok = S_DISCOVERY_RULE_ADDED;
                $msg_fail = S_CANNOT_ADD_DISCOVERY_RULE;
                $druleid = add_discovery_rule($_REQUEST["proxy_hostid"], $_REQUEST['name'], $_REQUEST['iprange'], $_REQUEST['delay'], $_REQUEST['status'], $_REQUEST['dchecks']);
                $result = $druleid;
            }
            show_messages($result, $msg_ok, $msg_fail);
            if ($result) {
                // result - OK
                add_audit(!isset($_REQUEST["druleid"]) ? AUDIT_ACTION_ADD : AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_DISCOVERY_RULE, '[' . $druleid . '] ' . $_REQUEST['name']);
                unset($_REQUEST["form"]);
            }
        } else {