<link href="../../plugins/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body class="skin-blue">
<div class="wrapper">
<?php
top_header();
//function in include/dashboardFunctions.php
?>
<?php
sidebar();
//function in include/dashboardFunctions.php
?>
<?php
editDeleteSubCategory();
//function in include/adminFunctions.php
?>
<?php
footer();
function form_actions()
{
global $host_actions;
/* ================= input validation ================= */
input_validate_input_regex(get_request_var_post('drp_action'), '^([a-zA-Z0-9_]+)$');
/* ==================================================== */
/* if we are to save this form, instead of display it */
if (isset($_POST['selected_items'])) {
$selected_items = unserialize(stripslashes($_POST['selected_items']));
if ($_POST['drp_action'] == '1') {
/* delete */
db_execute('DELETE FROM host_template WHERE ' . array_to_sql_or($selected_items, 'id'));
db_execute('DELETE FROM host_template_snmp_query WHERE ' . array_to_sql_or($selected_items, 'host_template_id'));
db_execute('DELETE FROM host_template_graph WHERE ' . array_to_sql_or($selected_items, 'host_template_id'));
/* "undo" any device that is currently using this template */
db_execute('UPDATE host SET host_template_id=0 WHERE ' . array_to_sql_or($selected_items, 'host_template_id'));
} elseif ($_POST['drp_action'] == '2') {
/* duplicate */
for ($i = 0; $i < count($selected_items); $i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
duplicate_host_template($selected_items[$i], $_POST['title_format']);
}
}
header('Location: host_templates.php');
exit;
}
/* setup some variables */
$host_list = '';
$i = 0;
/* loop through each of the host templates selected on the previous page and get more info about them */
while (list($var, $val) = each($_POST)) {
if (preg_match('/^chk_([0-9]+)$/', $var, $matches)) {
/* ================= input validation ================= */
input_validate_input_number($matches[1]);
/* ==================================================== */
$host_list .= '<li>' . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM host_template WHERE id = ?'), array($matches[1])) . '<br>';
$host_array[$i] = $matches[1];
$i++;
}
}
top_header();
html_start_box('<strong>' . $host_actions[$_POST['drp_action']] . '</strong>', '60%', '', '3', 'center', '');
print "<form action='host_templates.php' autocomplete='off' method='post'>\n";
if (isset($host_array) && sizeof($host_array)) {
if ($_POST['drp_action'] == '1') {
/* delete */
print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>Are you sure you want to delete the following Device Template(s)? All Devices currently associated\n\t\t\t\t\t\twith these Device Template(s) will lose that assocation.</p>\n\t\t\t\t\t\t<p><ul>{$host_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Delete Device Template(s)'>";
} elseif ($_POST['drp_action'] == '2') {
/* duplicate */
print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Device Template(s) will be duplicated. You can\n\t\t\t\t\t\toptionally change the title format for the new Device Template(s).</p>\n\t\t\t\t\t\t<p><ul>{$host_list}</ul></p>\n\t\t\t\t\t\t<p><strong>Title Format:</strong><br>";
form_text_box('title_format', '<template_title> (1)', '', '255', '30', 'text');
print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
$save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Duplicate Device Template(s)'>";
}
} else {
print "<tr><td class='even'><span class='textError'>You must select at least one host template.</span></td></tr>\n";
$save_html = "<input type='button' value='Return' onClick='window.history.back()'>";
}
print "\t<tr>\n\t\t\t<td align='right' class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($host_array) ? serialize($host_array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . $_POST['drp_action'] . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n\t\t";
html_end_box();
bottom_footer();
}
function field_remove()
{
global $registered_cacti_names;
/* ================= input validation ================= */
input_validate_input_number(get_request_var_request('id'));
input_validate_input_number(get_request_var_request('data_input_id'));
/* ==================================================== */
if (read_config_option('deletion_verification') == 'on' && !isset($_REQUEST['confirm'])) {
top_header();
form_confirm('Are You Sure?', "Are you sure you want to delete the field <strong>'" . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM data_input_fields WHERE id = ?', array(get_request_var_request('id'))), ENT_QUOTES) . "'</strong>?", htmlspecialchars('data_input.php?action=edit&id=' . $_REQUEST['data_input_id']), htmlspecialchars('data_input.php?action=field_remove&id=' . $_REQUEST['id'] . '&data_input_id=' . $_REQUEST['data_input_id']));
bottom_footer();
exit;
}
if (read_config_option('deletion_verification') == '' || isset($_REQUEST['confirm'])) {
/* get information about the field we're going to delete so we can re-order the seqs */
$field = db_fetch_row_prepared('SELECT input_output,data_input_id FROM data_input_fields WHERE id = ?', array(get_request_var_request('id')));
db_execute_prepared('DELETE FROM data_input_fields WHERE id = ?', array(get_request_var_request('id')));
db_execute_prepared('DELETE FROM data_input_data WHERE data_input_field_id = ?', array(get_request_var_request('id')));
/* when a field is deleted; we need to re-order the field sequences */
if ($field['input_output'] == 'in' && preg_match_all('/<([_a-zA-Z0-9]+)>/', db_fetch_cell_prepared('SELECT input_string FROM data_input WHERE id = ?', array($field['data_input_id'])), $matches)) {
$j = 0;
for ($i = 0; $i < count($matches[1]); $i++) {
if (in_array($matches[1][$i], $registered_cacti_names) == false) {
$j++;
db_execute_prepared("UPDATE data_input_fields SET sequence = ? WHERE data_input_id = ? AND input_output = 'in' AND data_name = ?", array($j, $field['data_input_id'], $matches[1][$i]));
}
}
}
}
}
//.........这里部分代码省略.........
} elseif ($_POST['drp_action'] == '7') {
/* resize graphs */
input_validate_input_number(get_request_var_post('graph_width'));
input_validate_input_number(get_request_var_post('graph_height'));
for ($i = 0; $i < count($selected_items); $i++) {
/* ================= input validation ================= */
input_validate_input_number($selected_items[$i]);
/* ==================================================== */
api_resize_graphs($selected_items[$i], $_POST['graph_width'], $_POST['graph_height']);
}
} else {
api_plugin_hook_function('graphs_action_execute', $_POST['drp_action']);
}
/* update snmpcache */
snmpagent_graphs_action_bottom(array($_POST['drp_action'], $selected_items));
api_plugin_hook_function('graphs_action_bottom', array($_POST['drp_action'], $selected_items));
header('Location: graphs.php');
exit;
}
/* setup some variables */
$graph_list = '';
$i = 0;
/* loop through each of the graphs selected on the previous page and get more info about them */
while (list($var, $val) = each($_POST)) {
if (preg_match('/^chk_([0-9]+)$/', $var, $matches)) {
/* ================= input validation ================= */
input_validate_input_number($matches[1]);
/* ==================================================== */
$graph_list .= '<li>' . htmlspecialchars(get_graph_title($matches[1])) . '</li>';
$graph_array[$i] = $matches[1];
$i++;
}
}
top_header();
/* add a list of tree names to the actions dropdown */
add_tree_names_to_actions_array();
html_start_box('<strong>' . $graph_actions[$_POST['drp_action']] . '</strong>', '60%', '', '3', 'center', '');
print "<form action='graphs.php' method='post'>\n";
if (isset($graph_array) && sizeof($graph_array)) {
if ($_POST['drp_action'] == '1') {
/* delete */
$graphs = array();
/* find out which (if any) data sources are being used by this graph, so we can tell the user */
if (isset($graph_array) && sizeof($graph_array)) {
$data_sources = db_fetch_assoc('select
data_template_data.local_data_id,
data_template_data.name_cache
from (data_template_rrd,data_template_data,graph_templates_item)
where graph_templates_item.task_item_id=data_template_rrd.id
and data_template_rrd.local_data_id=data_template_data.local_data_id
and ' . array_to_sql_or($graph_array, 'graph_templates_item.local_graph_id') . '
and data_template_data.local_data_id > 0
group by data_template_data.local_data_id
order by data_template_data.name_cache');
}
print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Graph(s) will be deleted. Please note, Data Source(s) should be deleted only if they are only used by these Graph(s)\n\t\t\t\t\t\tand not others.</p>\n\t\t\t\t\t\t<p><ul>{$graph_list}</ul></p>";
if (isset($data_sources) && sizeof($data_sources)) {
print "<tr><td class='textArea'><p>The following Data Source(s) are in use by these Graph(s):</p>\n";
print '<ul>';
foreach ($data_sources as $data_source) {
print '<li><strong>' . $data_source['name_cache'] . "</strong></li>\n";
}
print '</ul>';
print '<br>';
form_radio_button('delete_type', '1', '2', "Leave the Data Source(s) untouched. Not applicable for Graphs created under 'New Graphs' or WHERE the Graphs were created automatically.", '2');
print '<br>';
function mactrack_macw_remove()
{
global $config;
/* ================= input validation ================= */
get_filter_request_var('mac_id');
/* ==================================================== */
if (read_config_option('remove_verification') == 'on' && !isset_request_var('confirm')) {
top_header();
form_confirm(__('Are You Sure?'), __('Are you sure you want to delete the watched Mac Address %s?', db_fetch_cell_prepared('SELECT name FROM mac_track_macwatch WHERE mac_id=?', array(get_request_var('mac_id')))), 'mactrack_macwatch.php', 'mactrack_macwatch.php?action=remove&mac_id=' . get_request_var('mac_id'));
bottom_footer();
exit;
}
if (read_config_option('remove_verification') == '' || isset_request_var('confirm')) {
api_mactrack_macw_remove(get_request_var('mac_id'));
}
}
请发表评论