commit version 22.12.12447

This commit is contained in:
2023-01-01 22:36:12 -05:00
parent af1b03d79f
commit b948283a96
744 changed files with 620715 additions and 27381 deletions

View File

@ -6,7 +6,7 @@
*
* @package observium
* @subpackage web
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2022 Observium Limited
*
*/
@ -77,223 +77,6 @@ if (!$readonly && isset($vars['action']) &&
print_syslog_rules_table($vars);
function print_syslog_rules_table($vars)
{
if (isset($vars['la_id']))
{
$las = dbFetchRows("SELECT * FROM `syslog_rules` WHERE `la_id` = ?", array($vars['la_id']));
} else {
$las = dbFetchRows("SELECT * FROM `syslog_rules` ORDER BY `la_name`");
}
if (is_array($las) && count($las))
{
$modals = '';
$string = generate_box_open();
$string .= '<table class="table table-striped table-hover table-condensed">' . PHP_EOL;
$cols = array(
array(NULL, 'class="state-marker"'),
'name' => array('Name', 'style="width: 160px;"'),
'descr' => array('Description', 'style="width: 400px;"'),
'rule' => 'Rule',
'severity' => array('Severity', 'style="width: 60px;"'),
'disabled' => array('Status', 'style="width: 60px;"'),
'controls' => array('', 'style="width: 60px;"'),
);
$string .= get_table_header($cols, $vars);
foreach($las as $la)
{
if ($la['disable'] == 0) { $la['html_row_class'] = "up"; } else { $la['html_row_class'] = "disabled"; }
$string .= '<tr class="' . $la['html_row_class'] . '">';
$string .= '<td class="state-marker"></td>';
$string .= ' <td><strong><a href="'.generate_url(array('page' => 'syslog_rules', 'la_id' => $la['la_id'])).'">' . escape_html($la['la_name']) . '</a></strong></td>' . PHP_EOL;
$string .= ' <td><a href="'.generate_url(array('page' => 'syslog_rules', 'la_id' => $la['la_id'])).'">' . escape_html($la['la_descr']) . '</a></td>' . PHP_EOL;
$string .= ' <td><code>' . escape_html($la['la_rule']) . '</code></td>' . PHP_EOL;
$string .= ' <td>' . escape_html($la['la_severity']) . '</td>' . PHP_EOL;
$string .= ' <td>' . ($la['la_disable'] ? '<span class="label label-error">disabled</span>' : '<span class="label label-success">enabled</span>') . '</td>' . PHP_EOL;
$string .= ' <td style="text-align: right;">';
if ($_SESSION['userlevel'] >= 10)
{
$string .= '
<div class="btn-group btn-group-xs" role="group" aria-label="Rule actions">
<a class="btn btn-default" role="group" title="Edit" href="#modal-edit_syslog_rule_'.$la['la_id'].'" data-toggle="modal"><i class="icon-cog text-muted"></i></a>
<a class="btn btn-danger" role="group" title="Delete" href="#modal-delete_syslog_rule_'.$la['la_id'].'" data-toggle="modal"><i class="icon-trash"></i></a>
</div>';
}
$string .= '</td>';
$string .= ' </tr>' . PHP_EOL;
// Delete Rule Modal
$modal_args = array(
'id' => 'modal-delete_syslog_rule_' . $la['la_id'],
'title' => 'Delete Syslog Rule "'.escape_html($la['la_descr']).'"',
//'hide' => TRUE,
//'fade' => TRUE,
//'role' => 'dialog',
//'class' => 'modal-md',
);
$form = array('type' => 'horizontal',
'id' => 'delete_syslog_rule_' . $la['la_id'],
'userlevel' => 10, // Minimum user level for display form
'modal_args' => $modal_args, // !!! This generate modal specific form
//'help' => 'This will completely delete the rule and all associations and history.',
'class' => '', // Clean default box class!
'url' => generate_url(array('page' => 'syslog_rules'))
);
$form['fieldset']['body'] = array('class' => 'modal-body'); // Required this class for modal body!
$form['fieldset']['footer'] = array('class' => 'modal-footer'); // Required this class for modal footer!
$form['row'][0]['la_id'] = array(
'type' => 'hidden',
'fieldset' => 'body',
'value' => $la['la_id']);
$form['row'][0]['action'] = array(
'type' => 'hidden',
'fieldset' => 'body',
'value' => 'delete_syslog_rule');
$form['row'][5]['confirm'] = array(
'type' => 'checkbox',
'fieldset' => 'body',
'name' => 'Confirm',
'placeholder' => 'Yes, please delete this rule.',
'onchange' => "javascript: toggleAttrib('disabled', 'delete_button_".$la['la_id']."'); showDiv(!this.checked, 'warning_".$la['la_id']."_div');",
'value' => 'confirm');
$form['row'][6]['warning_'.$la['la_id']] = array(
'type' => 'html',
'fieldset' => 'body',
'html' => '<h4 class="alert-heading"><i class="icon-warning-sign"></i> Warning!</h4>' .
' This rule and all history will be completely deleted!',
'div_class' => 'alert alert-warning',
'div_style' => 'display:none;');
$form['row'][8]['close'] = array(
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Close',
'icon' => '',
'attribs' => array('data-dismiss' => 'modal',
'aria-hidden' => 'true'));
$form['row'][9]['delete_button_'.$la['la_id']] = array(
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Delete Rule',
'icon' => 'icon-trash icon-white',
//'right' => TRUE,
'class' => 'btn-danger',
'disabled' => TRUE,
'value' => 'delete_syslog_rule');
$modals .= generate_form_modal($form);
unset($form);
// Edit Rule Modal
$modal_args = array(
'id' => 'modal-edit_syslog_rule_' . $la['la_id'],
'title' => 'Edit Syslog Rule "'.escape_html($la['la_descr']).'"',
//'hide' => TRUE,
//'fade' => TRUE,
//'role' => 'dialog',
'class' => 'modal-lg',
);
$form = array('type' => 'horizontal',
'id' => 'edit_syslog_rule_' . $la['la_id'],
'userlevel' => 10, // Minimum user level for display form
'modal_args' => $modal_args, // !!! This generate modal specific form
//'help' => 'This will completely delete the rule and all associations and history.',
'class' => '', // Clean default box class!
'url' => generate_url(array('page' => 'syslog_rules'))
);
$form['fieldset']['body'] = array('class' => 'modal-body'); // Required this class for modal body!
$form['fieldset']['footer'] = array('class' => 'modal-footer'); // Required this class for modal footer!
$form['row'][0]['la_id'] = array(
'type' => 'hidden',
'fieldset' => 'body',
'value' => $la['la_id']);
$form['row'][3]['la_name'] = array(
'type' => 'text',
'fieldset' => 'body',
'name' => 'Rule Name',
'class' => 'input-xlarge',
'value' => escape_html($la['la_name']));
$form['row'][4]['la_descr'] = array(
'type' => 'textarea',
'fieldset' => 'body',
'name' => 'Description',
'class' => 'input-xxlarge',
//'style' => 'margin-bottom: 10px;',
'value' => escape_html($la['la_descr']));
$form['row'][5]['la_rule'] = array(
'type' => 'textarea',
'fieldset' => 'body',
'name' => 'Regular Expression',
'class' => 'input-xxlarge',
'value' => escape_html($la['la_rule']));
$form['row'][6]['la_disable'] = array(
'type' => 'switch-ng',
'fieldset' => 'body',
'name' => 'Status',
'on-text' => 'Disabled',
'on-color' => 'danger',
'off-text' => 'Enabled',
'off-color' => 'success',
'size' => 'small',
'value' => $la['la_disable']);
$form['row'][8]['close'] = array(
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Close',
'icon' => '',
'attribs' => array('data-dismiss' => 'modal',
'aria-hidden' => 'true'));
$form['row'][9]['action'] = array(
'type' => 'submit',
'fieldset' => 'footer',
'div_class' => '', // Clean default form-action class!
'name' => 'Save Changes',
'icon' => 'icon-ok icon-white',
//'right' => TRUE,
'class' => 'btn-primary',
'value' => 'edit_syslog_rule');
$modals .= generate_form_modal($form);
unset($form);
}
$string .= '</table>';
$string .= generate_box_close();
echo $string;
} else {
print_warning("There are currently no Syslog alerting filters defined.");
}
echo $modals;
}
if (isset($vars['la_id']))
{
// Pagination