Define cacti system paths as constants for better code checking (#5120)

This also provides a full run of src-fixer against all files to
ensure all code is now in alignment.

Closes #5120
This commit is contained in:
Mark Brugnoli-Vinten committed 2023-01-01 01:03:15 +00:00
1 parent e98d3b0226
commit 8b29d12cc9
334 files changed
+20896 -16626

No files matched your search

+49 -38
View File
@@ -46,18 +46,21 @@ switch (get_request_var('action')) {
gprint_presets_edit();
bottom_footer();
break;
default:
top_header();
gprint_presets();
bottom_footer();
break;
}
/* --------------------------
The Save Function
The Save Function
-------------------------- */
function form_save() {
@@ -83,6 +86,7 @@ function form_save() {
if (is_error_message()) {
header('Location: gprint_presets.php?action=edit&id=' . (empty($gprint_preset_id) ? get_nfilter_request_var('id') : $gprint_preset_id));
exit;
} else {
header('Location: gprint_presets.php');
@@ -93,7 +97,7 @@ function form_save() {
}
/* -----------------------------------
gprint_presets - GPRINT Presets
gprint_presets - GPRINT Presets
----------------------------------- */
function form_actions() {
@@ -119,7 +123,8 @@ function form_actions() {
}
/* setup some variables */
$gprint_list = ''; $i = 0;
$gprint_list = '';
$i = 0;
/* loop through each of the graphs selected on the previous page and get more info about them */
foreach ($_POST as $var => $val) {
@@ -155,7 +160,8 @@ function form_actions() {
} else {
raise_message(40);
header('Location: gprint_presets.php');
exit;
exit;
}
print "<tr>
@@ -183,7 +189,7 @@ function gprint_presets_edit() {
if (!isempty_request_var('id')) {
$gprint_preset = db_fetch_row_prepared('SELECT * FROM graph_templates_gprint WHERE id = ?', array(get_request_var('id')));
$header_label = __esc('GPRINT Presets [edit: %s]', $gprint_preset['name']);
$header_label = __esc('GPRINT Presets [edit: %s]', $gprint_preset['name']);
} else {
$header_label = __('GPRINT Presets [new]');
}
@@ -210,31 +216,31 @@ function gprint_presets() {
/* ================= input validation and session storage ================= */
$filters = array(
'rows' => array(
'filter' => FILTER_VALIDATE_INT,
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'page' => array(
'filter' => FILTER_VALIDATE_INT,
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'filter' => array(
'filter' => FILTER_DEFAULT,
'filter' => FILTER_DEFAULT,
'pageset' => true,
'default' => ''
),
'sort_column' => array(
'filter' => FILTER_CALLBACK,
'filter' => FILTER_CALLBACK,
'default' => 'name',
'options' => array('options' => 'sanitize_search_string')
),
'sort_direction' => array(
'filter' => FILTER_CALLBACK,
'filter' => FILTER_CALLBACK,
'default' => 'ASC',
'options' => array('options' => 'sanitize_search_string')
),
'has_graphs' => array(
'filter' => FILTER_VALIDATE_REGEXP,
'filter' => FILTER_VALIDATE_REGEXP,
'options' => array('options' => array('regexp' => '(true|false)')),
'pageset' => true,
'default' => read_config_option('default_has') == 'on' ? 'true':'false'
@@ -269,19 +275,23 @@ function gprint_presets() {
</td>
<td>
<select id='rows' onChange='applyFilter()'>
<option value='-1'<?php print (get_request_var('rows') == '-1' ? ' selected>':'>') . __('Default');?></option>
<option value='-1'<?php print(get_request_var('rows') == '-1' ? ' selected>':'>') . __('Default');?></option>
<?php
if (cacti_sizeof($item_rows)) {
foreach ($item_rows as $key => $value) {
print "<option value='" . $key . "'"; if (get_request_var('rows') == $key) { print ' selected'; } print '>' . html_escape($value) . "</option>\n";
print "<option value='" . $key . "'";
if (get_request_var('rows') == $key) {
print ' selected';
} print '>' . html_escape($value) . "</option>\n";
}
}
?>
?>
</select>
</td>
<td>
<span>
<input type="checkbox" id='has_graphs' <?php print (get_request_var('has_graphs') == 'true' ? 'checked':'');?>>
<input type="checkbox" id='has_graphs' <?php print(get_request_var('has_graphs') == 'true' ? 'checked':'');?>>
<label for='has_graphs'><?php print __('Has Graphs');?></label>
</span>
</td>
@@ -362,7 +372,7 @@ function gprint_presets() {
) AS rs");
$sql_order = get_order_string();
$sql_limit = ' LIMIT ' . ($rows*(get_request_var('page')-1)) . ',' . $rows;
$sql_limit = ' LIMIT ' . ($rows * (get_request_var('page') - 1)) . ',' . $rows;
$gprint_list = db_fetch_assoc("SELECT rs.*,
SUM(CASE WHEN local_graph_id=0 THEN 1 ELSE 0 END) AS templates,
@@ -383,32 +393,32 @@ function gprint_presets() {
$display_text = array(
'name' => array(
'display' => __('GPRINT Preset Name'),
'align' => 'left',
'sort' => 'ASC',
'tip' => __('The name of this GPRINT Preset.')
'align' => 'left',
'sort' => 'ASC',
'tip' => __('The name of this GPRINT Preset.')
),
'gprint_text' => array(
'display' => __('Format'),
'align' => 'right',
'sort' => 'ASC',
'tip' => __('The GPRINT format string.')
'align' => 'right',
'sort' => 'ASC',
'tip' => __('The GPRINT format string.')
),
'nosort' => array(
'display' => __('Deletable'),
'align' => 'right',
'tip' => __('GPRINTs that are in use cannot be Deleted. In use is defined as being referenced by either a Graph or a Graph Template.')
'align' => 'right',
'tip' => __('GPRINTs that are in use cannot be Deleted. In use is defined as being referenced by either a Graph or a Graph Template.')
),
'graphs' => array(
'display' => __('Graphs Using'),
'align' => 'right',
'sort' => 'DESC',
'tip' => __('The number of Graphs using this GPRINT.')
'align' => 'right',
'sort' => 'DESC',
'tip' => __('The number of Graphs using this GPRINT.')
),
'templates' => array(
'display' => __('Templates Using'),
'align' => 'right',
'sort' => 'DESC',
'tip' => __('The number of Graphs Templates using this GPRINT.')
'align' => 'right',
'sort' => 'DESC',
'tip' => __('The number of Graphs Templates using this GPRINT.')
)
);
@@ -423,6 +433,7 @@ function gprint_presets() {
html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false);
$i = 0;
if (cacti_sizeof($gprint_list)) {
foreach ($gprint_list as $gp) {
if ($gp['graphs'] == 0 && $gp['templates'] == 0) {
@@ -431,17 +442,17 @@ function gprint_presets() {
$disabled = true;
}
form_alternate_row('line' . $gp['id'], false, $disabled);
form_alternate_row('line' . $gp['id'], false, $disabled);
form_selectable_cell(filter_value($gp['name'], get_request_var('filter'), 'gprint_presets.php?action=edit&id=' . $gp['id']), $gp['id']);
form_selectable_ecell($gp['gprint_text'], $gp['id'], '', 'right');
form_selectable_cell($disabled ? __('No'):__('Yes'), $gp['id'], '', 'right');
form_selectable_cell(number_format_i18n($gp['graphs'], '-1'), $gp['id'], '', 'right');
form_selectable_cell(number_format_i18n($gp['templates'], '-1'), $gp['id'], '', 'right');
form_checkbox_cell($gp['name'], $gp['id'], $disabled);
form_end_row();
form_selectable_ecell($gp['gprint_text'], $gp['id'], '', 'right');
form_selectable_cell($disabled ? __('No'):__('Yes'), $gp['id'], '', 'right');
form_selectable_cell(number_format_i18n($gp['graphs'], '-1'), $gp['id'], '', 'right');
form_selectable_cell(number_format_i18n($gp['templates'], '-1'), $gp['id'], '', 'right');
form_checkbox_cell($gp['name'], $gp['id'], $disabled);
form_end_row();
}
} else {
print "<tr class='tableRow'><td colspan='" . (cacti_sizeof($display_text)+1) . "'><em>" . __('No GPRINT Presets') . "</em></td></tr>\n";
print "<tr class='tableRow'><td colspan='" . (cacti_sizeof($display_text) + 1) . "'><em>" . __('No GPRINT Presets') . "</em></td></tr>\n";
}
html_end_box(false);