Repository navigation
Expand file tree
/
Copy pathsyslog_recommendations.php
More file actions
584 lines (488 loc) · 23.9 KB
/
Copy pathsyslog_recommendations.php
File metadata and controls
584 lines (488 loc) · 23.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2026 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDTool-based Graphing Solution |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/
// Console management of the syslog message recommendations.
chdir('../../');
include('./include/auth.php');
include_once('./plugins/syslog/includes/functions.php');
include_once('./plugins/syslog/includes/database.php');
include_once('./plugins/syslog/includes/recommendations.php');
if (!syslog_realm_allowed('Syslog Administration')) {
die(__('Permission denied.', 'syslog'));
}
syslog_connect();
set_default_action();
if ((isset_request_var('import') || isset_request_var('save_component_import')) && syslog_allow_edits()) {
set_request_var('action', 'import');
}
switch (get_request_var('action')) {
case 'save':
recommendation_save();
break;
case 'actions':
recommendation_actions();
break;
case 'export_all':
recommendation_export_all();
break;
case 'import':
if (isset_request_var('save_component_import')) {
recommendation_import();
} else {
top_header();
syslog_include_js();
recommendation_import_form();
bottom_footer();
}
break;
case 'edit':
top_header();
syslog_include_js();
recommendation_edit();
bottom_footer();
break;
default:
top_header();
syslog_include_js();
recommendation_list();
bottom_footer();
}
/**
* The bulk actions offered on the list.
*
* @return array<int, string> The action labels.
*/
function recommendation_actions_list(): array {
return [1 => __('Delete', 'syslog'), 2 => __('Export', 'syslog')];
}
/**
* The request filters shared by the list and the filtered export.
*
* @return array<string, array<string, mixed>> The filter definitions.
*/
function recommendation_filters(): array {
return [
'rows' => ['filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'],
'page' => ['filter' => FILTER_VALIDATE_INT, 'default' => '1'],
'filter' => ['filter' => FILTER_DEFAULT, 'pageset' => true, 'default' => ''],
'vendor' => ['filter' => FILTER_DEFAULT, 'pageset' => true, 'default' => '-1'],
'severity' => ['filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1'],
'sort_column' => ['filter' => FILTER_CALLBACK, 'default' => 'identifier', 'options' => ['options' => 'sanitize_search_string']],
'sort_direction' => ['filter' => FILTER_CALLBACK, 'default' => 'ASC', 'options' => ['options' => 'sanitize_search_string']]
];
}
/**
* Build the WHERE clause for the current filters.
*
* @return array{0: string, 1: list<mixed>} The clause (with leading WHERE, or empty) and its bind values.
*/
function recommendation_where(): array {
$where = [];
$params = [];
if ((string) get_request_var('filter') !== '') {
$like = '%' . get_request_var('filter') . '%';
$where[] = '(identifier LIKE ? OR vendor LIKE ? OR component LIKE ? OR message LIKE ? OR explanation LIKE ? OR recommended_action LIKE ?)';
$params = array_merge($params, array_fill(0, 6, $like));
}
if ((string) get_request_var('vendor') !== '-1') {
$where[] = 'vendor = ?';
$params[] = (string) get_request_var('vendor');
}
if ((string) get_request_var('severity') !== '-1') {
$where[] = 'severity = ?';
$params[] = (int) get_request_var('severity');
}
return [$where ? 'WHERE ' . implode(' AND ', $where) : '', $params];
}
/**
* Refuse to change data from anything but a POST, so Cacti's CSRF check covers every mutation.
*
* @return void
*/
function recommendation_require_post(): void {
if (($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST') {
header('Location: syslog_recommendations.php');
exit;
}
}
/**
* Add or update a recommendation from the edit form.
*
* @return void
*/
function recommendation_save(): void {
recommendation_require_post();
if (!syslog_allow_edits() || !isset_request_var('save_component_recommendation')) {
header('Location: syslog_recommendations.php');
return;
}
$id = (int) get_filter_request_var('id');
$return = 'syslog_recommendations.php?action=edit&id=' . $id;
$input = [];
foreach (['vendor', 'identifier', 'component', 'severity', 'message', 'explanation', 'recommended_action', 'reference'] as $field) {
$input[$field] = trim((string) get_nfilter_request_var($field));
}
$record = syslog_recommendation_normalize($input);
if ($record === null) {
raise_message('syslog_recommendation_invalid', __('Enter an identifier made of letters, digits and the characters _ . - / (it may start with %), and at least an explanation or a recommended action.', 'syslog'), MESSAGE_LEVEL_ERROR);
header('Location: ' . $return);
return;
}
$duplicate = syslog_db_fetch_cell_prepared('SELECT id FROM syslog_recommendations WHERE vendor = ? AND identifier = ? AND id <> ?',
[$record['vendor'], $record['identifier'], $id]);
if (!empty($duplicate)) {
raise_message('syslog_recommendation_duplicate', __('A recommendation for this vendor and identifier already exists.', 'syslog'), MESSAGE_LEVEL_ERROR);
header('Location: ' . $return);
return;
}
$values = [$record['vendor'], $record['identifier'], $record['component'], $record['severity'], $record['message'],
$record['explanation'], $record['recommended_action'], $record['reference']];
if ($id > 0) {
$ok = syslog_db_execute_prepared('UPDATE syslog_recommendations SET vendor = ?, identifier = ?, component = ?, severity = ?,
message = ?, explanation = ?, recommended_action = ?, reference = ? WHERE id = ?', array_merge($values, [$id]));
} else {
$ok = syslog_db_execute_prepared('INSERT INTO syslog_recommendations
(vendor, identifier, component, severity, message, explanation, recommended_action, reference)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)', $values);
}
if ($ok) {
raise_message(1);
header('Location: syslog_recommendations.php');
} else {
raise_message(2);
header('Location: ' . $return);
}
}
/**
* Confirm, then apply, the bulk delete and export actions.
*
* @return void
*/
function recommendation_actions(): void {
$actions = recommendation_actions_list();
get_filter_request_var('drp_action', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^[1-2]$/']]);
if (!isset($actions[get_request_var('drp_action')])) {
header('Location: syslog_recommendations.php');
return;
}
if (isset_request_var('selected_items')) {
recommendation_require_post();
$items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items'));
if (is_array($items)) {
$ids = array_values(array_filter(array_map('intval', $items), static fn ($id) => $id > 0));
if ($ids && get_request_var('drp_action') == '2') {
recommendation_send_export('WHERE id IN (' . implode(',', array_fill(0, count($ids), '?')) . ')', $ids);
return;
}
if ($ids && syslog_allow_edits()) {
syslog_db_execute_prepared('DELETE FROM syslog_recommendations WHERE id IN (' . implode(',', array_fill(0, count($ids), '?')) . ')', $ids);
}
}
header('Location: syslog_recommendations.php');
return;
}
$list = '';
$items = [];
foreach ($_POST as $name => $value) {
if (preg_match('/^chk_([0-9]+)$/', $name, $matches)) {
$identifier = syslog_db_fetch_cell_prepared('SELECT identifier FROM syslog_recommendations WHERE id = ?', [(int) $matches[1]]);
if ($identifier !== false && $identifier !== null) {
$items[] = (int) $matches[1];
$list .= '<li>' . html_escape($identifier) . '</li>';
}
}
}
if (!cacti_sizeof($items)) {
raise_message(40);
header('Location: syslog_recommendations.php');
return;
}
$export = get_request_var('drp_action') == '2';
top_header();
form_start('syslog_recommendations.php');
html_start_box($actions[get_request_var('drp_action')], '60%', false, 3, 'center', '');
print '<tr><td class="textArea"><p>' . ($export
? __('Click \'Continue\' to Export the following Recommendation(s).', 'syslog')
: __('Click \'Continue\' to Delete the following Recommendation(s).', 'syslog')) . '</p><div class="itemlist"><ul>' . $list . '</ul></div></td></tr>';
print '<tr><td align="right" class="saveRow"><input type="hidden" name="action" value="actions"><input type="hidden" name="selected_items" value="' . html_escape(serialize($items)) . '"><input type="hidden" name="drp_action" value="' . (int) get_request_var('drp_action') . '"><input type="button" value="' . __esc('Cancel', 'syslog') . '" class="cactiReturnTo"> <input type="submit" value="' . __esc('Continue', 'syslog') . '"></td></tr>';
html_end_box();
syslog_export_form_end($export);
bottom_footer();
}
/**
* Send recommendations as a JSON download.
*
* @param string $where The WHERE clause, or ''.
* @param array<int,mixed> $params The bind values.
*
* @return void
*/
function recommendation_send_export(string $where, array $params): void {
header('Content-Type: application/json; charset=UTF-8');
header('Content-Disposition: attachment; filename=syslog_recommendations_export.json');
syslog_recommendations_export($where, $params);
}
/**
* Export every recommendation that matches the list filters.
*
* @return void
*/
function recommendation_export_all(): void {
validate_store_request_vars(recommendation_filters(), 'sess_syslog_recommendations');
[$where, $params] = recommendation_where();
recommendation_send_export($where, $params);
}
/**
* Receive an import and report what happened.
*
* @return void
*/
function recommendation_import(): void {
recommendation_require_post();
if (!syslog_allow_edits()) {
header('Location: syslog_recommendations.php');
return;
}
if (function_exists('set_time_limit')) {
@set_time_limit(0);
}
$payload = syslog_recommendations_read_payload();
$parsed = $payload === false ? false : syslog_recommendations_parse($payload);
if ($parsed === false || !$parsed['records']) {
raise_message('syslog_import_error', __('Import rejected: the file is empty, too large, not valid JSON, or contains no usable recommendations.', 'syslog'), MESSAGE_LEVEL_ERROR);
header('Location: syslog_recommendations.php?action=import');
return;
}
$result = syslog_recommendations_store($parsed['records'], get_nfilter_request_var('duplicates') === 'overwrite');
raise_message('syslog_info', __esc('NOTE: Imported %d, updated %d and skipped %d existing Recommendation(s).', $result['imported'], $result['updated'], $result['skipped'], 'syslog'), MESSAGE_LEVEL_INFO);
if ($result['failed'] || $parsed['invalid']) {
raise_message('syslog_error', __esc('ERROR: %d Recommendation(s) were invalid or failed to import.', $result['failed'] + $parsed['invalid'], 'syslog'), MESSAGE_LEVEL_ERROR);
}
header('Location: syslog_recommendations.php');
}
/**
* Display the import form.
*
* @return void
*/
function recommendation_import_form(): void {
if (!syslog_allow_edits()) {
header('Location: syslog_recommendations.php');
exit;
}
$fields = [
'import_file' => [
'friendly_name' => __('Import Recommendations from Local File', 'syslog'),
'description' => __('Select a JSON file on your local machine. Use the Export function to see the expected format: a list of records with vendor, identifier, component, severity, message, explanation, recommended_action and reference.', 'syslog'),
'method' => 'file'
],
'import_text' => [
'method' => 'textarea',
'friendly_name' => __('Import Recommendations from Text', 'syslog'),
'description' => __('Alternatively, paste the JSON document into this box.', 'syslog'),
'value' => '',
'default' => '',
'textarea_rows' => '10',
'textarea_cols' => '80',
'class' => 'textAreaNotes'
],
'duplicates' => [
'method' => 'drop_array',
'friendly_name' => __('Existing Recommendations', 'syslog'),
'description' => __('A recommendation is the same as an existing one when its vendor and identifier match.', 'syslog'),
'array' => ['skip' => __('Keep the existing recommendation', 'syslog'), 'overwrite' => __('Replace it with the imported one', 'syslog')],
'value' => 'skip',
'default' => 'skip'
]
];
print "<form method='post' action='syslog_recommendations.php' enctype='multipart/form-data'>";
html_start_box(__('Import Recommendations', 'syslog'), '100%', false, 3, 'center', '');
draw_edit_form(['config' => ['no_form_tag' => true], 'fields' => $fields]);
html_end_box();
form_hidden_box('save_component_import', '1', '');
form_save_button('', 'import', 'id', false);
}
/**
* Display the edit form.
*
* @return void
*/
function recommendation_edit(): void {
$id = (int) get_filter_request_var('id');
$row = $id > 0 ? syslog_db_fetch_row_prepared('SELECT * FROM syslog_recommendations WHERE id = ?', [$id]) : [];
if (!cacti_sizeof($row)) {
$id = 0;
$row = ['vendor' => '', 'identifier' => '', 'component' => '', 'severity' => '', 'message' => '',
'explanation' => '', 'recommended_action' => '', 'reference' => ''];
}
$severities = ['' => __('Not specified', 'syslog')];
foreach (syslog_recommendation_severity_names() as $level => $name) {
$severities[$level] = $name;
}
$text = static fn (string $name, string $friendly, string $description, int $rows = 4): array => [
'method' => 'textarea', 'friendly_name' => $friendly, 'description' => $description,
'value' => '|arg1:' . $name . '|', 'textarea_rows' => $rows, 'textarea_cols' => 80, 'class' => 'textAreaNotes'
];
$fields = [
'spacer0' => ['method' => 'spacer', 'friendly_name' => __('Recommendation', 'syslog')],
'vendor' => ['method' => 'textbox', 'friendly_name' => __('Vendor', 'syslog'), 'description' => __('The supplier of the device or software that logs this message, for example Cisco or Juniper.', 'syslog'), 'value' => '|arg1:vendor|', 'size' => 40, 'max_length' => 64],
'identifier' => ['method' => 'textbox', 'friendly_name' => __('Identifier', 'syslog'), 'description' => __('The message code that appears in the syslog message, for example %LINK-3-UPDOWN or RPD_OSPF_NBRDOWN. The match is not case sensitive.', 'syslog'), 'value' => '|arg1:identifier|', 'size' => 60, 'max_length' => 190],
'component' => ['method' => 'textbox', 'friendly_name' => __('Component', 'syslog'), 'description' => __('The facility, module or subsystem that raises the message.', 'syslog'), 'value' => '|arg1:component|', 'size' => 40, 'max_length' => 64],
'severity' => ['method' => 'drop_array', 'friendly_name' => __('Severity', 'syslog'), 'description' => __('The severity the vendor documents for this message.', 'syslog'), 'array' => $severities, 'value' => '|arg1:severity|', 'default' => ''],
'message' => $text('message', __('Message', 'syslog'), __('The message format as documented, including its variable placeholders.', 'syslog'), 3),
'explanation' => $text('explanation', __('Explanation', 'syslog'), __('What the message means.', 'syslog')),
'recommended_action' => $text('recommended_action', __('Recommended Action', 'syslog'), __('What an operator should do about it.', 'syslog')),
'reference' => $text('reference', __('Reference', 'syslog'), __('Links to the vendor documentation, one per line.', 'syslog'), 2),
'id' => ['method' => 'hidden_zero', 'value' => '|arg1:id|'],
'save_component_recommendation' => ['method' => 'hidden', 'value' => '1']
];
$row['id'] = $id;
form_start('syslog_recommendations.php', 'syslog_recommendation_edit');
html_start_box($id ? __('Recommendation [edit]', 'syslog') : __('Recommendation [new]', 'syslog'), '100%', false, 3, 'center', '');
draw_edit_form(['config' => ['no_form_tag' => true], 'fields' => inject_form_variables($fields, $row)]);
html_end_box();
form_save_button('syslog_recommendations.php', '', 'id');
if (!syslog_allow_edits()) {
?>
<script <?php print plugin_syslog_csp_nonce(); ?>>
document.querySelectorAll('#syslog_recommendation_edit select,#syslog_recommendation_edit input,#syslog_recommendation_edit textarea').forEach(function (field) { field.disabled = true; });
</script>
<?php
}
}
/**
* Display the filterable list of recommendations.
*
* @return void
*/
function recommendation_list(): void {
global $item_rows;
validate_store_request_vars(recommendation_filters(), 'sess_syslog_recommendations');
$columns = ['identifier' => 'identifier', 'vendor' => 'vendor', 'component' => 'component', 'severity' => 'severity'];
if (!isset($columns[get_request_var('sort_column')])) {
set_request_var('sort_column', 'identifier');
}
if (!in_array(strtoupper((string) get_request_var('sort_direction')), ['ASC', 'DESC'], true)) {
set_request_var('sort_direction', 'ASC');
}
$vendors = array_column(syslog_db_fetch_assoc('SELECT DISTINCT vendor FROM syslog_recommendations ORDER BY vendor') ?: [], 'vendor');
$severities = syslog_recommendation_severity_names();
$edits = syslog_allow_edits();
html_start_box(__('Syslog Recommendations', 'syslog'), '100%', false, 3, 'center', $edits ? 'syslog_recommendations.php?action=edit' : '');
?>
<tr class='even'><td><form id='recommendation_filter' action='syslog_recommendations.php'><table class='filterTable' role='presentation'><tr>
<td><label for='filter'><?php print __('Search', 'syslog'); ?></label></td>
<td><input type='text' id='filter' size='25' value='<?php print html_escape_request_var('filter'); ?>'></td>
<td><label for='vendor'><?php print __('Vendor', 'syslog'); ?></label></td>
<td><select id='vendor'>
<option value='-1'<?php print (string) get_request_var('vendor') === '-1' ? ' selected' : ''; ?>><?php print __('All', 'syslog'); ?></option>
<?php foreach ($vendors as $vendor) { ?>
<option value='<?php print html_escape($vendor); ?>'<?php print (string) get_request_var('vendor') === $vendor ? ' selected' : ''; ?>><?php print $vendor === '' ? __('None', 'syslog') : html_escape($vendor); ?></option>
<?php } ?>
</select></td>
<td><label for='severity'><?php print __('Severity', 'syslog'); ?></label></td>
<td><select id='severity'>
<option value='-1'<?php print (string) get_request_var('severity') === '-1' ? ' selected' : ''; ?>><?php print __('All', 'syslog'); ?></option>
<?php foreach ($severities as $level => $name) { ?>
<option value='<?php print $level; ?>'<?php print (string) get_request_var('severity') === (string) $level ? ' selected' : ''; ?>><?php print html_escape($name); ?></option>
<?php } ?>
</select></td>
<td><label for='rows'><?php print __('Recommendations', 'syslog'); ?></label></td>
<td><select id='rows'><option value='-1'<?php print get_request_var('rows') == '-1' ? ' selected' : ''; ?>><?php print __('Default', 'syslog'); ?></option><?php
foreach ($item_rows as $key => $value) {
print '<option value="' . $key . '"' . (get_request_var('rows') == $key ? ' selected' : '') . '>' . $value . '</option>';
}
?></select></td>
<td><span>
<input id='refresh' type='button' value='<?php print __esc('Go', 'syslog'); ?>'>
<input id='clear' type='button' value='<?php print __esc('Clear', 'syslog'); ?>'>
<?php if ($edits) { ?><input id='import' type='button' value='<?php print __esc('Import', 'syslog'); ?>'><?php } ?>
<input id='export' type='button' value='<?php print __esc('Export', 'syslog'); ?>' title='<?php print __esc('Export every recommendation that matches the filters', 'syslog'); ?>'>
</span></td>
</tr></table></form>
<script <?php print plugin_syslog_csp_nonce(); ?>>
(function () {
var filter = document.getElementById('filter'), vendor = document.getElementById('vendor'),
severity = document.getElementById('severity'), rows = document.getElementById('rows');
function query() {
return new URLSearchParams({filter: filter.value, vendor: vendor.value, severity: severity.value, rows: rows.value});
}
function apply(clear) {
var q = clear ? 'clear=1' : query().toString();
window.location = 'syslog_recommendations.php?' + q;
}
document.getElementById('refresh').addEventListener('click', function () { apply(false); });
document.getElementById('clear').addEventListener('click', function () { apply(true); });
[vendor, severity, rows].forEach(function (el) { el.addEventListener('change', function () { apply(false); }); });
document.getElementById('recommendation_filter').addEventListener('submit', function (event) { event.preventDefault(); apply(false); });
var importButton = document.getElementById('import');
if (importButton) importButton.addEventListener('click', function () { window.location = 'syslog_recommendations.php?action=import'; });
// Download in a hidden frame so Cacti's page-unload spinner never starts.
document.getElementById('export').addEventListener('click', function () {
var q = query(); q.set('action', 'export_all');
document.getElementById('syslog_download').src = 'syslog_recommendations.php?' + q.toString();
});
}());
</script></td></tr>
<?php
html_end_box();
[$where, $params] = recommendation_where();
$rows = get_request_var('rows') == '-1' ? (int) read_config_option('num_rows_table') : (int) get_request_var('rows');
$rows = max(1, $rows);
$page = max(1, (int) get_request_var('page'));
$total_rows = (int) syslog_db_fetch_cell_prepared("SELECT COUNT(*) FROM syslog_recommendations $where", $params);
$sort = $columns[get_request_var('sort_column')];
$direction = strtoupper((string) get_request_var('sort_direction')) === 'DESC' ? 'DESC' : 'ASC';
$records = syslog_db_fetch_assoc_prepared("SELECT id, vendor, identifier, component, severity, explanation, recommended_action
FROM syslog_recommendations $where
ORDER BY $sort $direction, id
LIMIT " . (($page - 1) * $rows) . ", $rows", $params);
$records = is_array($records) ? $records : [];
$nav = html_nav_bar('syslog_recommendations.php?filter=' . urlencode((string) get_request_var('filter')), MAX_DISPLAY_PAGES, $page, $rows, $total_rows, 6, __('Recommendations', 'syslog'), 'page', 'main');
form_start('syslog_recommendations.php', 'chk');
print $nav;
html_start_box('', '100%', false, 3, 'center', '');
$display_text = [
'identifier' => [__('Identifier', 'syslog'), 'ASC'],
'vendor' => [__('Vendor', 'syslog'), 'ASC'],
'component' => [__('Component', 'syslog'), 'ASC'],
'severity' => [__('Severity', 'syslog'), 'ASC'],
'nosort_explanation' => ['display' => __('Explanation', 'syslog')],
'nosort_action' => ['display' => __('Recommended Action', 'syslog')]
];
html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false);
if (!$records) {
print '<tr><td colspan="7"><em>' . __('No recommendations found.', 'syslog') . '</em></td></tr>';
}
foreach ($records as $record) {
$id = (int) $record['id'];
form_alternate_row('line' . $id, true);
form_selectable_cell(filter_value(html_escape($record['identifier']), get_request_var('filter'), 'syslog_recommendations.php?action=edit&id=' . $id), $id);
form_selectable_cell(html_escape($record['vendor']), $id);
form_selectable_cell(html_escape($record['component']), $id);
form_selectable_cell($record['severity'] === null ? '' : html_escape($severities[(int) $record['severity']] ?? ''), $id);
form_selectable_cell(html_escape(title_trim(str_replace("\n", ' ', (string) $record['explanation']), 90)), $id);
form_selectable_cell(html_escape(title_trim(str_replace("\n", ' ', (string) $record['recommended_action']), 90)), $id);
form_checkbox_cell($record['identifier'], $id);
form_end_row();
}
html_end_box(false);
if ($records) {
print $nav;
}
draw_actions_dropdown(recommendation_actions_list());
form_end(false);
syslog_download_frame();
}