function form_save() { global $export_types, $export_errors; /* ================= input validation ================= */ input_validate_input_number(get_request_var_post('export_item_id')); /* ==================================================== */ if (isset($_POST['save_component_export'])) { $export_errors = 0; $xml_data = get_item_xml($_POST['export_type'], $_POST['export_item_id'], (isset($_POST['include_deps']) ? $_POST['include_deps'] : '') == '' ? false : true); if ($_POST['output_format'] == '1') { top_header(); print "<table width='100%' align='center'><tr><td><pre>" . htmlspecialchars($xml_data) . '</pre></td></tr></table>'; bottom_footer(); } elseif ($_POST['output_format'] == '2') { header('Content-type: application/xml'); if ($export_errors) { echo "WARNING: Export Errors Encountered. Refresh Browser Window for Details!\n"; } print $xml_data; } elseif ($_POST['output_format'] == '3') { if ($export_errors) { header('Location: templates_export.php'); } else { header('Content-type: application/xml'); header('Content-Disposition: attachment; filename=cacti_' . $_POST['export_type'] . '_' . strtolower(clean_up_file_name(db_fetch_cell(str_replace('|id|', $_POST['export_item_id'], $export_types[$_POST['export_type']]['title_sql'])))) . '.xml'); print $xml_data; } } } }
function form_actions() { global $user_actions, $auth_realms; /* if we are to save this form, instead of display it */ if (isset($_POST['associate_host'])) { while (list($var, $val) = each($_POST)) { if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ if (get_request_var_post('drp_action') == '1') { db_execute_prepared('REPLACE INTO user_auth_perms (user_id, item_id, type) VALUES (?, ?, 3)', array(get_request_var_post('id'), $matches[1])); } else { db_execute_prepared('DELETE FROM user_auth_perms WHERE user_id = ? AND item_id = ? AND type = 3', array(get_request_var_post('id'), $matches[1])); } } } header('Location: user_admin.php?action=user_edit&tab=permsd&id=' . get_request_var_post('id')); exit; } elseif (isset($_POST['associate_graph'])) { while (list($var, $val) = each($_POST)) { if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ if (get_request_var_post('drp_action') == '1') { db_execute_prepared('REPLACE INTO user_auth_perms (user_id, item_id, type) VALUES (?, ?, 1)', array(get_request_var_post('id'), $matches[1])); } else { db_execute_prepared('DELETE FROM user_auth_perms WHERE user_id = ? AND item_id = ? AND type = 1', array(get_request_var_post('id'), $matches[1])); } } } header('Location: user_admin.php?action=user_edit&tab=permsg&id=' . get_request_var_post('id')); exit; } elseif (isset($_POST['associate_template'])) { while (list($var, $val) = each($_POST)) { if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ if (get_request_var_post('drp_action') == '1') { db_execute_prepared('REPLACE INTO user_auth_perms (user_id, item_id, type) VALUES (?, ?, 4)', array(get_request_var_post('id'), $matches[1])); } else { db_execute_prepared('DELETE FROM user_auth_perms WHERE user_id = ? AND item_id = ? AND type = 4', array(get_request_var_post('id'), $matches[1])); } } } header('Location: user_admin.php?action=user_edit&tab=permste&id=' . get_request_var_post('id')); exit; } elseif (isset($_POST['associate_groups'])) { while (list($var, $val) = each($_POST)) { if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ if (get_request_var_post('drp_action') == '1') { db_execute_prepared('REPLACE INTO user_auth_group_members (user_id, group_id) VALUES (?, ?)', array(get_request_var_post('id'), $matches[1])); } else { db_execute_prepared('DELETE FROM user_auth_group_members WHERE user_id = ? AND group_id = ?', array(get_request_var_post('id'), $matches[1])); } } } header('Location: user_admin.php?action=user_edit&tab=permsgr&id=' . get_request_var_post('id')); exit; } elseif (isset($_POST['associate_tree'])) { while (list($var, $val) = each($_POST)) { if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ if (get_request_var_post('drp_action') == '1') { db_execute_prepared('REPLACE INTO user_auth_perms (user_id, item_id, type) VALUES (?, ?, 2)', array(get_request_var_post('id'), $matches[1])); } else { db_execute_prepared('DELETE FROM user_auth_perms WHERE user_id = ? AND item_id = ? AND type = 2', array(get_request_var_post('id'), $matches[1])); } } } header('Location: user_admin.php?action=user_edit&tab=permstr&id=' . get_request_var_post('id')); exit; } elseif (isset($_POST['selected_items'])) { if (get_request_var_post('drp_action') != '2') { $selected_items = unserialize(stripslashes(get_request_var_post('selected_items'))); } if (get_request_var_post('drp_action') == '1') { /* delete */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ user_remove($selected_items[$i]); api_plugin_hook_function('user_remove', $selected_items[$i]); } } if (get_request_var_post('drp_action') == '2') { /* copy */ /* ================= input validation ================= */ input_validate_input_number(get_request_var_post('selected_items')); input_validate_input_number(get_request_var_post('new_realm')); /* ==================================================== */ $new_username = get_request_var_post('new_username'); $new_realm = get_request_var_post('new_realm', 0); $template_user = db_fetch_row_prepared('SELECT username, realm FROM user_auth WHERE id = ?', array(get_request_var_post('selected_items'))); $overwrite = array('full_name' => get_request_var_post('new_fullname')); if (strlen($new_username)) { if (sizeof(db_fetch_assoc_prepared('SELECT username FROM user_auth WHERE username = ? AND realm = ?', array($new_username, $new_realm)))) { raise_message(19); } else { if (user_copy($template_user['username'], $new_username, $template_user['realm'], $new_realm, false, $overwrite) === false) { raise_message(2); } else { raise_message(1); } } } } if (get_request_var_post('drp_action') == '3') { /* enable */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ user_enable($selected_items[$i]); } } if (get_request_var_post('drp_action') == '4') { /* disable */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ user_disable($selected_items[$i]); } } if (get_request_var_post('drp_action') == '5') { /* batch copy */ /* ================= input validation ================= */ input_validate_input_number(get_request_var_post('template_user')); /* ==================================================== */ $copy_error = false; $template = db_fetch_row_prepared('SELECT username, realm FROM user_auth WHERE id = ?', array(get_request_var_post('template_user'))); for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ $user = db_fetch_row_prepared('SELECT username, realm FROM user_auth WHERE id = ?', array($selected_items[$i])); if (isset($user) && isset($template)) { if (user_copy($template['username'], $user['username'], $template['realm'], $user['realm'], true) === false) { $copy_error = true; } } } if ($copy_error) { raise_message(2); } else { raise_message(1); } } header('Location: user_admin.php'); exit; } /* loop through each of the users and process them */ $user_list = ''; $user_array = array(); $i = 0; while (list($var, $val) = each($_POST)) { if (preg_match('/^chk_([0-9]+)$/', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ if (get_request_var_post('drp_action') != '2') { $user_list .= '<li>' . db_fetch_cell_prepared('SELECT username FROM user_auth WHERE id = ?', array($matches[1])) . '</li>'; } $user_array[$i] = $matches[1]; $i++; } } /* Check for deleting of Graph Export User */ if (get_request_var_post('drp_action') == '1' && isset($user_array) && sizeof($user_array)) { /* delete */ $exportuser = read_config_option('export_user_id'); if (in_array($exportuser, $user_array)) { raise_message(22); header('Location: user_admin.php'); exit; } } top_header(); html_start_box('<strong>' . $user_actions[get_request_var_post('drp_action')] . '</strong>', '40%', '', '3', 'center', ''); print "<form action='user_admin.php' method='post'>\n"; if (isset($user_array) && sizeof($user_array)) { if (get_request_var_post('drp_action') == '1' && sizeof($user_array)) { /* delete */ print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the selected User(s) will be deleted.</p>\n\t\t\t\t\t\t<p><ul>{$user_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Delete User(s)'>"; } $user_id = ''; if (get_request_var_post('drp_action') == '2' && sizeof($user_array)) { /* copy */ $user_id = $user_array[0]; $user_realm = db_fetch_cell_prepared('SELECT realm FROM user_auth WHERE id = ?', array($user_id)); print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\tWhen you click \"Continue\" the selected User will be copied to the new User below<br><br>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\tTemplate Username: <i>" . db_fetch_cell_prepared('SELECT username FROM user_auth WHERE id = ?', array($user_id)) . "</i>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\tUsername: "******"\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\tFull Name: "; print form_text_box('new_fullname', '', '', 35); print "\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\tRealm: \n"; print form_dropdown('new_realm', $auth_realms, '', '', $user_realm, '', 0); print "\t\t\t\t</td>\n\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Copy User'>"; } if (get_request_var_post('drp_action') == '3' && sizeof($user_array)) { /* enable */ print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\" the selected User(s) will be enabled.</p>\n\t\t\t\t\t\t<ul>{$user_list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Enable User(s)'>"; } if (get_request_var_post('drp_action') == '4' && sizeof($user_array)) { /* disable */ print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\" the selected User(s) will be disabled.</p>\n\t\t\t\t\t\t<ul>{$user_list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Disable User(s)'>"; } if (get_request_var_post('drp_action') == '5' && sizeof($user_array)) { /* batch copy */ $usernames = db_fetch_assoc('SELECT id, username FROM user_auth WHERE realm = 0 ORDER BY username'); print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>When you click \"Continue\" you will overwrite selected the User(s) settings with the selected template User settings and permissions? Original user Full Name, Password, Realm and Enable status will be retained, all other fields will be overwritten from Template User.<br><br></td>\n\t\t\t\t</tr><tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\tTemplate User: \n"; print form_dropdown('template_user', $usernames, 'username', 'id', '', '', 0); print "\t\t</td>\n\t\t\t\t</tr><tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>User(s) to update:\n\t\t\t\t\t\t<ul>{$user_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Reset User(s) Settings'>"; } } else { print "<tr><td class='even'><span class='textError'>You must select at least one user.</span></td></tr>\n"; $save_html = "<input type='button' value='Return' onClick='window.history.back()'>"; } print " <tr>\n\t\t\t<td align='right' class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>"; if (get_request_var_post('drp_action') == '2') { /* copy */ print "\t\t\t\t<input type='hidden' name='selected_items' value='" . $user_id . "'>\n"; } else { print "\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($user_array) ? serialize($user_array) : '') . "'>\n"; } print "\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var_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(); }
<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 utilities_clear_logfile() { load_current_session_value('refresh', 'sess_logfile_refresh', read_config_option('log_refresh_interval')); $refresh['seconds'] = get_request_var_request('refresh'); $refresh['page'] = 'utilities.php?action=view_logfile'; top_header(); $logfile = read_config_option('path_cactilog'); if ($logfile == '') { $logfile = './log/cacti.log'; } html_start_box('<strong>Clear Cacti Log File</strong>', '100%', '', '3', 'center', ''); if (file_exists($logfile)) { if (is_writable($logfile)) { $timestamp = date('m/d/Y h:i:s A'); $log_fh = fopen($logfile, 'w'); fwrite($log_fh, $timestamp . " - WEBUI: Cacti Log Cleared from Web Management Interface\n"); fclose($log_fh); print '<tr><td>Cacti Log File Cleared</td></tr>'; } else { print "<tr><td><font color='red'><b>Error: Unable to clear log, no write permissions.<b></font></td></tr>"; } } else { print "<tr><td><font color='red'><b>Error: Unable to clear log, file does not exist.</b></font></td></tr>"; } html_end_box(); }
function thold_add_select_host() { global $config; $host_id = get_filter_request_var('host_id'); $local_graph_id = get_filter_request_var('local_graph_id'); $data_template_rrd_id = get_filter_request_var('data_template_rrd_id'); $hosts = get_allowed_devices(); top_header(); form_start('thold.php?action=save', 'tholdform'); html_start_box(__('Threshold Creation Wizard'), '50%', '', '3', 'center', ''); if ($host_id == '') { print '<tr><td class="center">' . __('Please select a Device') . '</td></tr>'; } else { if ($local_graph_id == '') { print '<tr><td class="center">' . __('Please select a Graph') . '</td></tr>'; } else { if ($data_template_rrd_id == '') { print '<tr><td class="center">' . __('Please select a Data Source') . '</td></tr>'; } else { print '<tr><td class="center">' . __('Please press \'Create\' to activate your Threshold') . '</td></tr>'; } } } html_end_box(); html_start_box('', '50%', '', '3', 'center', ''); /* display the host dropdown */ ?> <tr><td><table class='filterTable' align='center'> <tr> <?php print html_host_filter(get_request_var('host_id')); ?> </tr><?php if ($host_id != '') { $graphs = get_allowed_graphs('gl.host_id=' . $host_id); ?> <tr> <td> <?php print __('Graph'); ?> </td> <td> <select id='local_graph_id' name='local_graph_id' onChange='applyFilter("graph")'> <option value=''></option><?php foreach ($graphs as $row) { echo "<option value='" . $row['local_graph_id'] . "'" . ($row['local_graph_id'] == $local_graph_id ? ' selected' : '') . '>' . htmlspecialchars($row['title_cache'], ENT_QUOTES) . '</option>'; } ?> </select> </td> </tr><?php } else { ?> <tr> <td> <input type='hidden' id='local_graph_id' name='local_graph_id' value=''> </td> </tr><?php } if ($local_graph_id != '') { $dt_sql = 'SELECT DISTINCT dtr.local_data_id FROM data_template_rrd AS dtr LEFT JOIN graph_templates_item AS gti ON gti.task_item_id=dtr.id LEFT JOIN graph_local AS gl ON gl.id=gti.local_graph_id WHERE gl.id = ' . $local_graph_id; $local_data_id = db_fetch_cell($dt_sql); $dss = db_fetch_assoc('SELECT DISTINCT id, data_source_name FROM data_template_rrd WHERE local_data_id IN (' . $dt_sql . ') ORDER BY data_source_name'); /* show the data source options */ ?> <tr> <td> <?php print __('Data Source'); ?> </td> <td> <input type='hidden' id='local_data_id' name='local_data_id' value='<?php print $local_data_id; ?> '> <select id='data_template_rrd_id' name='data_template_rrd_id' onChange='applyFilter("ds")'> <option value=''></option><?php foreach ($dss as $row) { echo "<option value='" . $row['id'] . "'" . ($row['id'] == $data_template_rrd_id ? ' selected' : '') . '>' . htmlspecialchars($row['data_source_name'], ENT_QUOTES) . '</option>'; } ?> </select> </td> </tr></table></td></tr><?php } else { ?> <tr> <td> <input type='hidden' id='data_template_rrd_id' name='data_template_rrd_id' value=''> </td> </tr></table></td></tr><?php } if ($data_template_rrd_id != '') { echo "<tr><td class='center' colspan='2'><input type='hidden' name='save' id='save' value='save'><input id='go' type='button' value='" . __('Create') . "' title='" . __('Create Threshold') . "'></td></tr>"; } else { echo "<tr><td class='center' colspan='2'></td></tr>"; } html_end_box(); form_end(); html_start_box('', '50%', '', '3', 'center', ''); if ($local_graph_id != '') { print "<tr><td style='text-align:center'><img id='graphi' src='../../graph_image.php?local_graph_id={$local_graph_id}&rra_id=0'></td></tr>"; } html_end_box(); ?> <script type='text/javascript'> function applyFilter(target) { strURL = 'thold.php?action=add&header=false&host_id=' + $('#host_id').val(); if (target != 'host_id') { strURL += '&local_graph_id=' + $('#local_graph_id').val(); } if (target == 'ds') { strURL += '&data_template_rrd_id=' + $('#data_template_rrd_id').val(); } loadPageNoHeader(strURL); } $(function() { $('#go').button().click(function() { strURL = $('#tholdform').attr('action'); json = $('input, select').serializeObject(); $.post(strURL, json).done(function(data) { $('#main').html(data); applySkin(); window.scrollTo(0, 0); }); }); }); </script> <?php }
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])); } } } } }
function form_actions() { global $config, $syslog_actions, $fields_syslog_action_edit; include dirname(__FILE__) . '/config.php'; get_filter_request_var('drp_action', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^([a-zA-Z0-9_]+)$/'))); /* if we are to save this form, instead of display it */ if (isset_request_var('selected_items')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { if (get_request_var('drp_action') == '1') { /* delete */ for ($i = 0; $i < count($selected_items); $i++) { api_syslog_removal_remove($selected_items[$i]); } } else { if (get_request_var('drp_action') == '2') { /* disable */ for ($i = 0; $i < count($selected_items); $i++) { api_syslog_removal_disable($selected_items[$i]); } } else { if (get_request_var('drp_action') == '3') { /* enable */ for ($i = 0; $i < count($selected_items); $i++) { api_syslog_removal_enable($selected_items[$i]); } } else { if (get_request_var('drp_action') == '4') { /* reprocess */ for ($i = 0; $i < count($selected_items); $i++) { api_syslog_removal_reprocess($selected_items[$i]); } } } } } } header('Location: syslog_removal.php?header=false'); exit; } top_header(); form_start('syslog_removal.php'); html_start_box($syslog_actions[get_request_var('drp_action')], '60%', '', '3', 'center', ''); /* setup some variables */ $removal_array = array(); $removal_list = ''; /* loop through each of the clusters 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]); /* ==================================================== */ $removal_info = syslog_db_fetch_cell("SELECT name FROM `" . $syslogdb_default . "`.`syslog_remove` WHERE id=" . $matches[1]); $removal_list .= '<li>' . $removal_info . '</li>'; $removal_array[] = $matches[1]; } } if (sizeof($removal_array)) { if (get_request_var('drp_action') == '1') { /* delete */ print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Click \'Continue\' to Delete the following Syslog Removal Rule(s).') . "</p>\n\t\t\t\t\t<ul>{$removal_list}</ul>"; print "</td></tr>\n\t\t\t\t</td>\n\t\t\t</tr>\n"; $title = __('Delete Syslog Removal Rule(s)'); } else { if (get_request_var('drp_action') == '2') { /* disable */ print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Click \'Continue\' to Disable the following Syslog Removal Rule(s).') . "</p>\n\t\t\t\t\t<ul>{$removal_list}</ul>"; print "</td></tr>\n\t\t\t\t</td>\n\t\t\t</tr>\n"; $title = __('Disable Syslog Removal Rule(s)'); } else { if (get_request_var('drp_action') == '3') { /* enable */ print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Click \'Continue\' to Enable the following Syslog Removal Rule(s).') . "</p>\n\t\t\t\t\t<ul>{$removal_list}</ul>"; print "</td></tr>\n\t\t\t\t</td>\n\t\t\t</tr>\n"; $title = __('Enable Syslog Removal Rule(s)'); } else { if (get_request_var('drp_action') == '4') { /* reprocess */ print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Click \'Continue\' to Re-process the following Syslog Removal Rule(s).') . "</p>\n\t\t\t\t\t<ul>{$removal_list}</ul>"; print "</td></tr>\n\t\t\t\t</td>\n\t\t\t</tr>\n"; $title = __('Retroactively Process Syslog Removal Rule(s)'); } } } } $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='{$title}'"; } else { print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Syslog Removal Rule.') . "</span></td></tr>\n"; $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>"; } print "\t<tr>\n\t\t<td align='right' class='saveRow'>\n\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t<input type='hidden' name='selected_items' value='" . (isset($removal_array) ? serialize($removal_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t{$save_html}\n\t\t</td>\n\t</tr>\n"; html_end_box(); form_end(); bottom_footer(); }
function ds_edit() { global $struct_data_source, $struct_data_source_item, $data_source_types; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); input_validate_input_number(get_request_var_request('host_id')); /* ==================================================== */ api_plugin_hook('data_source_edit_top'); $use_data_template = true; $host_id = 0; if (!empty($_REQUEST['id'])) { $data_local = db_fetch_row_prepared('SELECT host_id, data_template_id FROM data_local WHERE id = ?', array($_REQUEST['id'])); $data = db_fetch_row_prepared('SELECT * FROM data_template_data WHERE local_data_id = ?', array($_REQUEST['id'])); if (isset($data_local['data_template_id']) && $data_local['data_template_id'] >= 0) { $data_template = db_fetch_row_prepared('SELECT id, name FROM data_template WHERE id = ?', array($data_local['data_template_id'])); $data_template_data = db_fetch_row_prepared('SELECT * FROM data_template_data WHERE data_template_id = ? AND local_data_id = 0', array($data_local['data_template_id'])); } else { $_SESSION['sess_messages'] = 'Data Source "' . $_REQUEST['id'] . '" does not exist.'; header('Location: data_sources.php'); exit; } $header_label = '[edit: ' . htmlspecialchars(get_data_source_title($_REQUEST['id'])) . ']'; if (empty($data_local['data_template_id'])) { $use_data_template = false; } } else { $header_label = '[new]'; $use_data_template = false; } /* handle debug mode */ if (isset($_REQUEST['debug'])) { if ($_REQUEST['debug'] == '0') { kill_session_var('ds_debug_mode'); } elseif ($_REQUEST['debug'] == '1') { $_SESSION['ds_debug_mode'] = true; } } top_header(); if (!empty($_REQUEST['id'])) { ?> <table width='100%' align='center'> <tr> <td class='textInfo' colspan='2' valign='top'> <?php print htmlspecialchars(get_data_source_title($_REQUEST['id'])); ?> </td> <td class='textInfo' align='right' valign='top'> <span class='linkMarker'>*<a href='<?php print htmlspecialchars('data_sources.php?action=ds_edit&id=' . (isset($_REQUEST['id']) ? $_REQUEST['id'] : '0')); ?> &debug=<?php print isset($_SESSION['ds_debug_mode']) ? '0' : '1'; ?> '>Turn <strong><?php print isset($_SESSION['ds_debug_mode']) ? 'Off' : 'On'; ?> </strong> Data Source Debug Mode.</a><br> <?php if (!empty($data_template['id'])) { ?> <span class='linkMarker'>*<a href='<?php print htmlspecialchars('data_templates.php?action=template_edit&id=' . (isset($data_template['id']) ? $data_template['id'] : '0')); ?> '>Edit Data Template.</a><br><?php } if (!empty($_REQUEST['host_id']) || !empty($data_local['host_id'])) { ?> <span class='linkMarker'>*<a href='<?php print htmlspecialchars('host.php?action=edit&id=' . (isset($_REQUEST['host_id']) ? $_REQUEST['host_id'] : $data_local['host_id'])); ?> '>Edit Device.</a><br><?php } ?> </td> </tr> </table> <br> <?php } html_start_box("<strong>Data Template Selection</strong> {$header_label}", '100%', '', '3', 'center', ''); $form_array = array('data_template_id' => array('method' => 'drop_sql', 'friendly_name' => 'Selected Data Template', 'description' => 'The name given to this data template.', 'value' => isset($data_template) ? $data_template['id'] : '0', 'none_value' => 'None', 'sql' => 'SELECT id,name FROM data_template order by name'), 'host_id' => array('method' => 'drop_sql', 'friendly_name' => 'Device', 'description' => 'Choose the host that this graph belongs to.', 'value' => isset($_REQUEST['host_id']) ? $_REQUEST['host_id'] : $data_local['host_id'], 'none_value' => 'None', 'sql' => "SELECT id,CONCAT_WS('',description,' (',hostname,')') as name FROM host order by description,hostname"), '_data_template_id' => array('method' => 'hidden', 'value' => isset($data_template) ? $data_template['id'] : '0'), '_host_id' => array('method' => 'hidden', 'value' => empty($data_local['host_id']) ? isset($_REQUEST['host_id']) ? $_REQUEST['host_id'] : '0' : $data_local['host_id']), '_data_input_id' => array('method' => 'hidden', 'value' => isset($data['data_input_id']) ? $data['data_input_id'] : '0'), 'data_template_data_id' => array('method' => 'hidden', 'value' => isset($data) ? $data['id'] : '0'), 'local_data_template_data_id' => array('method' => 'hidden', 'value' => isset($data) ? $data['local_data_template_data_id'] : '0'), 'local_data_id' => array('method' => 'hidden', 'value' => isset($data) ? $data['local_data_id'] : '0')); draw_edit_form(array('config' => array(), 'fields' => $form_array)); html_end_box(); /* only display the "inputs" area if we are using a data template for this data source */ if (!empty($data['data_template_id'])) { $template_data_rrds = db_fetch_assoc_prepared('SELECT * FROM data_template_rrd WHERE local_data_id = ? ORDER BY data_source_name', array($_REQUEST['id'])); html_start_box('<strong>Supplemental Data Template Data</strong>', '100%', '', '3', 'center', ''); draw_nontemplated_fields_data_source($data['data_template_id'], $data['local_data_id'], $data, '|field|', '<strong>Data Source Fields</strong>', true, true, 0); draw_nontemplated_fields_data_source_item($data['data_template_id'], $template_data_rrds, '|field|_|id|', '<strong>Data Source Item Fields</strong>', true, true, true, 0); draw_nontemplated_fields_custom_data($data['id'], 'value_|id|', '<strong>Custom Data</strong>', true, true, 0); form_hidden_box('save_component_data', '1', ''); html_end_box(); } if ((isset($_REQUEST['id']) || isset($_REQUEST['new'])) && empty($data['data_template_id'])) { html_start_box('<strong>Data Source</strong>', '100%', '', '3', 'center', ''); $form_array = array(); while (list($field_name, $field_array) = each($struct_data_source)) { $form_array += array($field_name => $struct_data_source[$field_name]); if (!($use_data_template == false || !empty($data_template_data['t_' . $field_name]) || $field_array['flags'] == 'NOTEMPLATE')) { $form_array[$field_name]['description'] = ''; } $form_array[$field_name]['value'] = isset($data[$field_name]) ? $data[$field_name] : ''; $form_array[$field_name]['form_id'] = empty($data['id']) ? '0' : $data['id']; if (!($use_data_template == false || !empty($data_template_data['t_' . $field_name]) || $field_array['flags'] == 'NOTEMPLATE')) { $form_array[$field_name]['method'] = 'template_' . $form_array[$field_name]['method']; } } draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => inject_form_variables($form_array, isset($data) ? $data : array()))); html_end_box(); /* fetch ALL rrd's for this data source */ if (!empty($_REQUEST['id'])) { $template_data_rrds = db_fetch_assoc_prepared('SELECT id, data_source_name FROM data_template_rrd WHERE local_data_id = ? ORDER BY data_source_name', array($_REQUEST['id'])); } /* select the first "rrd" of this data source by default */ if (empty($_REQUEST['view_rrd'])) { $_REQUEST['view_rrd'] = isset($template_data_rrds[0]['id']) ? $template_data_rrds[0]['id'] : '0'; } /* get more information about the rrd we chose */ if (!empty($_REQUEST['view_rrd'])) { $local_data_template_rrd_id = db_fetch_cell_prepared('SELECT local_data_template_rrd_id FROM data_template_rrd WHERE id = ?', array($_REQUEST['view_rrd'])); $rrd = db_fetch_row_prepared('SELECT * FROM data_template_rrd WHERE id = ?', array($_REQUEST['view_rrd'])); $rrd_template = db_fetch_row_prepared('SELECT * FROM data_template_rrd WHERE id = ?', array($local_data_template_rrd_id)); $header_label = '[edit: ' . $rrd['data_source_name'] . ']'; } else { $header_label = ''; } $i = 0; if (isset($template_data_rrds)) { if (sizeof($template_data_rrds) > 1) { /* draw the data source tabs on the top of the page */ print "\t<table class='tabs' width='100%' cellspacing='0' cellpadding='3' align='center'>\n\t\t\t\t\t<tr>\n"; foreach ($template_data_rrds as $template_data_rrd) { $i++; print "\t<td " . ($template_data_rrd['id'] == $_REQUEST['view_rrd'] ? "class='even'" : "class='odd'") . " width='" . (strlen($template_data_rrd['data_source_name']) * 9 + 50) . "' align='center' class='tab'>\n\t\t\t\t\t\t\t\t<span class='textHeader'><a href='" . htmlspecialchars('data_sources.php?action=ds_edit&id=' . $_REQUEST['id'] . '&view_rrd=' . $template_data_rrd['id']) . "'>{$i}: " . htmlspecialchars($template_data_rrd['data_source_name']) . '</a>' . ($use_data_template == false ? " <a href='" . htmlspecialchars('data_sources.php?action=rrd_remove&id=' . $template_data_rrd['id'] . '&local_data_id=' . $_REQUEST['id']) . "'><img src='images/delete_icon.gif' border='0' alt='Delete'></a>" : '') . "</span>\n\t\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t\t<td width='1'></td>\n"; } print "\n\t\t\t\t\t<td></td>\n\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n"; } elseif (sizeof($template_data_rrds) == 1) { $_REQUEST['view_rrd'] = $template_data_rrds[0]['id']; } } html_start_box('', '100%', '', '3', 'center', ''); print "\t<tr>\n\t\t\t\t<td class='textHeaderDark'>\n\t\t\t\t\t<strong>Data Source Item</strong> {$header_label}\n\t\t\t\t</td>\n\t\t\t\t<td class='textHeaderDark' align='right'>\n\t\t\t\t\t" . (!empty($_REQUEST['id']) && empty($data_template['id']) ? "<strong><a class='linkOverDark' href='" . htmlspecialchars('data_sources.php?action=rrd_add&id=' . $_REQUEST['id']) . "'>New</a> </strong>" : '') . "\n\t\t\t\t</td>\n\t\t\t</tr>\n"; /* data input fields list */ if (empty($data['data_input_id']) || db_fetch_cell_prepared('SELECT type_id FROM data_input WHERE id = ?', array($data['data_input_id'])) > '1') { unset($struct_data_source_item['data_input_field_id']); } else { $struct_data_source_item['data_input_field_id']['sql'] = "SELECT id,CONCAT(data_name,' - ',name) as name FROM data_input_fields WHERE data_input_id=" . $data['data_input_id'] . " and input_output='out' and update_rra='on' order by data_name,name"; } $form_array = array(); while (list($field_name, $field_array) = each($struct_data_source_item)) { $form_array += array($field_name => $struct_data_source_item[$field_name]); if (!($use_data_template == false || $rrd_template['t_' . $field_name] == 'on')) { $form_array[$field_name]['description'] = ''; } $form_array[$field_name]['value'] = isset($rrd) ? $rrd[$field_name] : ''; if (!($use_data_template == false || $rrd_template['t_' . $field_name] == 'on')) { $form_array[$field_name]['method'] = 'template_' . $form_array[$field_name]['method']; } } draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => array('data_template_rrd_id' => array('method' => 'hidden', 'value' => isset($rrd) ? $rrd['id'] : '0'), 'local_data_template_rrd_id' => array('method' => 'hidden', 'value' => isset($rrd) ? $rrd['local_data_template_rrd_id'] : '0')) + $form_array)); html_end_box(); /* data source data goes here */ data_edit(); form_hidden_box('current_rrd', $_REQUEST['view_rrd'], '0'); } /* display the debug mode box if the user wants it */ if (isset($_SESSION['ds_debug_mode']) && isset($_REQUEST['id'])) { ?> <table width='100%' align='center'> <tr> <td> <span class='textInfo'>Data Source Debug</span><br> <pre><?php print @rrdtool_function_create($_REQUEST['id'], true); ?> </pre> </td> </tr> </table> <?php } if (isset($_REQUEST['id']) || isset($_REQUEST['new'])) { form_hidden_box('save_component_data_source', '1', ''); } else { form_hidden_box('save_component_data_source_new', '1', ''); } form_save_button('data_sources.php'); api_plugin_hook('data_source_edit_bottom'); bottom_footer(); }
function form_actions() { global $graph_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 */ if (!isset($_POST['delete_type'])) { $_POST['delete_type'] = 1; } for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ } switch ($_POST['delete_type']) { case '2': /* delete all data sources referenced by this graph */ $data_sources = array_rekey(db_fetch_assoc('SELECT data_template_data.local_data_id 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($selected_items, 'graph_templates_item.local_graph_id') . ' AND data_template_data.local_data_id > 0'), 'local_data_id', 'local_data_id'); if (sizeof($data_sources)) { api_data_source_remove_multi($data_sources); api_plugin_hook_function('data_source_remove', $data_sources); } break; } api_graph_remove_multi($selected_items); api_plugin_hook_function('graphs_remove', $selected_items); } elseif ($_POST['drp_action'] == '2') { /* change graph template */ input_validate_input_number(get_request_var_post('graph_template_id')); for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ change_graph_template($selected_items[$i], $_POST['graph_template_id'], true); } } elseif ($_POST['drp_action'] == '3') { /* duplicate */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ duplicate_graph($selected_items[$i], 0, $_POST['title_format']); } } elseif ($_POST['drp_action'] == '4') { /* graph -> graph template */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ graph_to_graph_template($selected_items[$i], $_POST['title_format']); } } elseif (preg_match('/^tr_([0-9]+)$/', $_POST['drp_action'], $matches)) { /* place on tree */ input_validate_input_number(get_request_var_post('tree_id')); input_validate_input_number(get_request_var_post('tree_item_id')); for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ api_tree_item_save(0, $_POST['tree_id'], TREE_ITEM_TYPE_GRAPH, $_POST['tree_item_id'], '', $selected_items[$i], read_graph_config_option('default_rra_id'), 0, 0, 0, false); } } elseif ($_POST['drp_action'] == '5') { /* change host */ input_validate_input_number(get_request_var_post('host_id')); for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ db_execute_prepared('UPDATE graph_local SET host_id = ? WHERE id = ?', array($_POST['host_id'], $selected_items[$i])); update_graph_title_cache($selected_items[$i]); } } elseif ($_POST['drp_action'] == '6') { /* reapply suggested naming */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ api_reapply_suggested_graph_title($selected_items[$i]); update_graph_title_cache($selected_items[$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>'; form_radio_button('delete_type', '2', '2', 'Delete all <strong>Data Source(s)</strong> referenced by these Graph(s).', '2'); print '<br>'; print '</td></tr>'; } print "\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 Graph(s)'>"; } elseif ($_POST['drp_action'] == '2') { /* change graph template */ print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>Choose a Graph Template and click \"Continue\" to change the Graph Template for\n\t\t\t\t\t\tthe following Graph(s). Be aware that all warnings will be suppressed during the\n\t\t\t\t\t\tconversion, so Graph data loss is possible.</p>\n\t\t\t\t\t\t<p><ul>{$graph_list}</ul></p>\n\t\t\t\t\t\t<p><strong>New Graph Template:</strong><br>"; form_dropdown('graph_template_id', db_fetch_assoc('SELECT graph_templates.id,graph_templates.name FROM graph_templates ORDER BY name'), 'name', 'id', '', '', '0'); 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='Change Graph Template'>"; } elseif ($_POST['drp_action'] == '3') { /* 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 Graph(s) will be duplicated. You can\n\t\t\t\t\t\toptionally change the title format for the new Graph(s).</p>\n\t\t\t\t\t\t<p><ul>{$graph_list}</ul></p>\n\t\t\t\t\t\t<p><strong>Title Format:</strong><br>"; form_text_box('title_format', '<graph_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 Graph(s)'>"; } elseif ($_POST['drp_action'] == '4') { /* graph -> graph template */ 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 converted into Graph Template(s).\n\t\t\t\t\t\tYou can optionally change the title format for the new Graph Template(s).</p>\n\t\t\t\t\t\t<p><ul>{$graph_list}</ul></p>\n\t\t\t\t\t\t<p><strong>Title Format:</strong><br>"; form_text_box('title_format', '<graph_title> Template', '', '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='Convert to Graph Template'>"; } elseif (preg_match('/^tr_([0-9]+)$/', $_POST['drp_action'], $matches)) { /* place on tree */ 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 placed under the Tree Branch selected below.</p>\n\t\t\t\t\t\t<p><ul>{$graph_list}</ul></p>\n\t\t\t\t\t\t<p><strong>Destination Branch:</strong><br>"; grow_dropdown_tree($matches[1], '0', 'tree_item_id', '0'); print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t<input type='hidden' name='tree_id' value='" . $matches[1] . "'>\n\n\t\t\t\t"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Place Graph(s) on Tree'>"; } elseif ($_POST['drp_action'] == '5') { /* change host */ print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>Choose a new Device for these Graph(s) and click \"Continue\"</p>\n\t\t\t\t\t\t<p><ul>{$graph_list}</ul></p>\n\t\t\t\t\t\t<p><strong>New Device:</strong><br>"; form_dropdown('host_id', db_fetch_assoc("SELECT id,CONCAT_WS('',description,' (',hostname,')') as name FROM host ORDER BY description,hostname"), 'name', 'id', '', '', '0'); 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='Change Graph(s) Associated Device'>"; } elseif ($_POST['drp_action'] == '6') { /* reapply suggested naming to host */ 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 have thier suggested naming convensions\n\t\t\t\t\t\trecalculated and applied to the Graph(s).</p>\n\t\t\t\t\t\t<p><ul>{$graph_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='Reapply Suggested Naming to Graph(s)'>"; } elseif ($_POST['drp_action'] == '7') { /* resize graphs */ 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 resized per your specifications.</p>\n\t\t\t\t\t\t<p><ul>{$graph_list}</ul></p>\n\t\t\t\t\t\t<p><strong>Graph Height:</strong><br>"; form_text_box('graph_height', '', '', '255', '30', 'text'); print '</p> <p><strong>Graph Width:</strong><br>'; form_text_box('graph_width', '', '', '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='Resize Selected Graph(s)'>"; } else { $save['drp_action'] = $_POST['drp_action']; $save['graph_list'] = $graph_list; $save['graph_array'] = isset($graph_array) ? $graph_array : array(); api_plugin_hook_function('graphs_action_prepare', $save); $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue'>"; } } else { print "<tr><td class='even'><span class='textError'>You must select at least one graph.</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($graph_array) ? serialize($graph_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 template_add() { if (!isset_request_var('save') || get_nfilter_request_var('save') == '') { $data_templates = array_rekey(db_fetch_assoc('SELECT id, name FROM data_template ORDER BY name'), 'id', 'name'); top_header(); form_start('thold_templates.php', 'tholdform'); html_start_box(__('Threshold Template Creation Wizard'), '50%', '', '3', 'center', ''); if (!isset_request_var('data_template_id')) { set_request_var('data_template_id', ''); } if (!isset_request_var('data_source_id')) { set_request_var('data_source_id', ''); } if (get_filter_request_var('data_template_id') == '') { print '<tr><td class="center">' . __('Please select a Data Template') . '</td></tr>'; } else { if (get_filter_request_var('data_source_id') == '') { print '<tr><td class="center">' . __('Please select a Data Source') . '</td></tr>'; } else { print '<tr><td class="center">' . __('Please press \'Create\' to create your Threshold Template') . '</td></tr>'; } } html_end_box(); html_start_box('', '50%', '', '3', 'center', ''); /* display the data template dropdown */ ?> <tr><td><table class='filterTable' align='center'> <tr> <td> <?php print __('Data Template'); ?> </td> <td> <select id='data_template_id' name='data_template_id' onChange='applyFilter("dt")'> <option value=''>None</option><?php foreach ($data_templates as $id => $name) { echo "<option value='" . $id . "'" . ($id == get_request_var('data_template_id') ? ' selected' : '') . '>' . htmlspecialchars($name, ENT_QUOTES) . '</option>'; } ?> </select> </td> </tr><?php if (get_request_var('data_template_id') != '') { $data_template_id = get_request_var('data_template_id'); $data_fields = array(); $temp = db_fetch_assoc_prepared('SELECT id, local_data_template_rrd_id, data_source_name, data_input_field_id FROM data_template_rrd WHERE local_data_template_rrd_id = 0 AND data_template_id = ?', array($data_template_id)); foreach ($temp as $d) { if ($d['data_input_field_id'] != 0) { $temp2 = db_fetch_assoc_prepared('SELECT name, data_name FROM data_input_fields WHERE id = ?', array($d['data_input_field_id'])); $data_fields[$d['id']] = $temp2[0]['data_name'] . ' (' . $temp2[0]['name'] . ')'; } else { $temp2[0]['name'] = $d['data_source_name']; $data_fields[$d['id']] = $temp2[0]['name']; } } /* display the data source dropdown */ ?> <tr> <td> <?php print __('Data Source'); ?> </td> <td> <select id='data_source_id' name='data_source_id' onChange='applyFilter("ds")'> <option value=''><?php print __('None'); ?> </option><?php foreach ($data_fields as $id => $name) { echo "<option value='" . $id . "'" . ($id == get_request_var('data_source_id') ? ' selected' : '') . '>' . htmlspecialchars($name, ENT_QUOTES) . '</option>'; } ?> </select> </td> </tr> <?php } else { echo "<tr><td><input type='hidden' id='data_source_id' value=''></td></tr>\n"; } if (get_request_var('data_source_id') != '') { echo "<tr><td colspan='2'><input type='hidden' name='action' value='add'><input id='save' type='hidden' name='save' value='save'><br><center><input id='go' type='button' value='" . __('Create') . "'></center></td></tr>"; } else { echo "<tr><td colspan=2><input type=hidden name=action value='add'><br><br><br></td></tr>"; } echo "</table></td></tr>\n"; html_end_box(); form_end(); ?> <script type='text/javascript'> function applyFilter(type) { if (type == 'dt' && $('#data_source_id')) { $('#data_source_id').val(''); } if ($('#save')) { $('#save').val(''); } loadPageNoHeader('thold_templates.php?action=add&header=false&data_template_id='+$('#data_template_id').val()+'&data_source_id='+$('#data_source_id').val()); } $(function() { $('#go').button().click(function() { strURL = $('#tholdform').attr('action'); json = $('input, select').serializeObject(); $.post(strURL, json).done(function(data) { $('#main').html(data); applySkin(); window.scrollTo(0, 0); }); }); }); </script> <?php bottom_footer(); } else { $data_template_id = get_filter_request_var('data_template_id'); $data_source_id = get_filter_request_var('data_source_id'); $save['id'] = ''; $save['hash'] = get_hash_thold_template(0); $temp = db_fetch_row('SELECT id, name FROM data_template WHERE id=' . $data_template_id . ' LIMIT 1'); $save['name'] = $temp['name']; $save['data_template_id'] = $data_template_id; $save['data_template_name'] = $temp['name']; $save['data_source_id'] = $data_source_id; $temp = db_fetch_row('SELECT id, local_data_template_rrd_id, data_source_name, data_input_field_id FROM data_template_rrd WHERE id = ' . $data_source_id . ' LIMIT 1'); $save['data_source_name'] = $temp['data_source_name']; $save['name'] .= ' [' . $temp['data_source_name'] . ']'; if ($temp['data_input_field_id'] != 0) { $temp2 = db_fetch_row('SELECT name FROM data_input_fields WHERE id = ' . $temp['data_input_field_id'] . ' LIMIT 1'); } else { $temp2['name'] = $temp['data_source_name']; } $save['data_source_friendly'] = $temp2['name']; $save['thold_enabled'] = 'on'; $save['thold_type'] = 0; $save['repeat_alert'] = read_config_option('alert_repeat'); $id = sql_save($save, 'thold_template'); if ($id) { plugin_thold_log_changes($id, 'modified_template', $save); Header("Location: thold_templates.php?action=edit&id={$id}&header=false"); exit; } else { raise_message('thold_save'); Header('Location: thold_templates.php?action=add&header=false'); exit; } } }
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')); } }
function form_actions() { global $graph_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 graph_templates WHERE " . array_to_sql_or($selected_items, "id")); $graph_template_input = db_fetch_assoc("SELECT id FROM graph_template_input WHERE " . array_to_sql_or($selected_items, "graph_template_id")); if (sizeof($graph_template_input) > 0) { foreach ($graph_template_input as $item) { db_execute("DELETE FROM graph_template_input_defs WHERE graph_template_input_id=" . $item["id"]); } } db_execute("DELETE FROM graph_template_input WHERE " . array_to_sql_or($selected_items, "graph_template_id")); db_execute("DELETE FROM graph_templates_graph WHERE " . array_to_sql_or($selected_items, "graph_template_id") . " AND local_graph_id=0"); db_execute("DELETE FROM graph_templates_item WHERE " . array_to_sql_or($selected_items, "graph_template_id") . " AND local_graph_id=0"); db_execute("DELETE FROM host_template_graph WHERE " . array_to_sql_or($selected_items, "graph_template_id")); /* "undo" any graph that is currently using this template */ db_execute("UPDATE graph_templates_graph SET local_graph_template_graph_id=0,graph_template_id=0 WHERE " . array_to_sql_or($selected_items, "graph_template_id")); db_execute("UPDATE graph_templates_item SET local_graph_template_item_id=0,graph_template_id=0 WHERE " . array_to_sql_or($selected_items, "graph_template_id")); db_execute("UPDATE graph_local SET graph_template_id=0 WHERE " . array_to_sql_or($selected_items, "graph_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_graph(0, $selected_items[$i], $_POST["title_format"]); } } header("Location: graph_templates.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(db_fetch_cell("SELECT name FROM graph_templates WHERE id=" . $matches[1])) . "<br>"; $graph_array[$i] = $matches[1]; $i++; } } top_header(); html_start_box("<strong>" . $graph_actions[$_POST["drp_action"]] . "</strong>", "60%", "", "3", "center", ""); print "<form action='graph_templates.php' method='post'>\n"; if (isset($graph_array) && sizeof($graph_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>When you click \"Continue\", the following Graph Template(s) will be deleted. Any Graph(s) associated with\n\t\t\t\t\t\tthe Template(s) will become individual Graph(s).</p>\n\t\t\t\t\t\t<p><ul>{$graph_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 Graph 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 Graph Template(s) will be duplicated. You can\n\t\t\t\t\t\toptionally change the title format for the new Graph Template(s).</p>\n\t\t\t\t\t\t<p><ul>{$graph_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 Graph Template(s)'>"; } } else { print "<tr><td class='even'><p><span class='textError'>ERROR: You must select at least one graph template.</span></p></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($graph_array) ? serialize($graph_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 input_remove() { /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); input_validate_input_number(get_request_var_request('graph_template_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 input item <strong>'" . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM graph_template_input WHERE id = ?', array(get_request_var_request('id'))), ENT_QUOTES) . "'</strong>? NOTE: Deleting this item will NOT affect graphs that use this template.", htmlspecialchars('graph_templates.php?action=template_edit&id=' . $_REQUEST['graph_template_id']), htmlspecialchars('graph_templates_inputs.php?action=input_remove&id=' . $_REQUEST['id'] . '&graph_template_id=' . $_REQUEST['graph_template_id'])); bottom_footer(); exit; } if (read_config_option('deletion_verification') == '' || isset($_REQUEST['confirm'])) { db_execute_prepared('DELETE FROM graph_template_input WHERE id = ?', array(get_request_var_request('id'))); db_execute_prepared('DELETE FROM graph_template_input_defs WHERE graph_template_input_id = ?', array(get_request_var_request('id'))); } }
function data_query_item_remove() { /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('id')); input_validate_input_number(get_request_var_request('snmp_query_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 Data Query Graph <strong>'" . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM snmp_query_graph WHERE id = ?', array($_REQUEST['id'])), ENT_QUOTES) . "'</strong>?", htmlspecialchars('data_queries.php?action=edit&id=' . $_REQUEST['snmp_query_id']), htmlspecialchars('data_queries.php?action=item_remove&id=' . $_REQUEST['id'] . '&snmp_query_id=' . $_REQUEST['snmp_query_id'])); bottom_footer(); exit; } if (read_config_option('deletion_verification') == '' || isset($_REQUEST['confirm'])) { db_execute_prepared('DELETE FROM snmp_query_graph WHERE id = ?', array($_REQUEST['id'])); db_execute_prepared('DELETE FROM snmp_query_graph_rrd WHERE snmp_query_graph_id = ?', array($_REQUEST['id'])); db_execute_prepared('DELETE FROM snmp_query_graph_rrd_sv WHERE snmp_query_graph_id = ?', array($_REQUEST['id'])); db_execute_prepared('DELETE FROM snmp_query_graph_sv WHERE snmp_query_graph_id = ?', array($_REQUEST['id'])); } }
function form_actions() { global $rra_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 rra WHERE ' . array_to_sql_or($selected_items, 'id')); db_execute('DELETE FROM rra_cf WHERE ' . array_to_sql_or($selected_items, 'rra_id')); } header('Location: rra.php'); exit; } /* setup some variables */ $rra_list = ''; $i = 0; /* loop through each of the rra 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]); /* ==================================================== */ $rra_list .= '<li>' . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM rra WHERE id = ?', array($matches[1]))) . '</li>'; $rra_array[$i] = $matches[1]; $i++; } } top_header(); print "<form action='rra.php' method='post'>\n"; html_start_box('<strong>' . $rra_actions[$_POST['drp_action']] . '</strong>', '60%', '', '3', 'center', ''); if (isset($rra_array) && sizeof($rra_array)) { if ($_POST['drp_action'] == '1') { /* delete */ print "\t<tr>\n\t\t\t\t\t<td class='textArea' class='odd'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the folling Round Robin Archive definition(s) will be deleted.</p>\n\t\t\t\t\t\t<ul>{$rra_list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Delete Round Robin Archive definition(s)'>"; } } else { print "<tr><td class='odd'><span class='textError'>You must select at least one Round Robin Archive definition.</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($rra_array) ? serialize($rra_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"; html_end_box(); bottom_footer(); }
function form_actions() { global $actions; /* 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 */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ domain_remove($selected_items[$i]); } } elseif ($_POST['drp_action'] == '2') { /* disable */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ domain_disable($selected_items[$i]); } } elseif ($_POST['drp_action'] == '3') { /* enable */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ domain_enable($selected_items[$i]); } } elseif ($_POST['drp_action'] == '4') { /* default */ if (sizeof($selected_items) > 1) { /* error message */ } else { for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ domain_default($selected_items[$i]); } } } header('Location: user_domains.php'); exit; } /* setup some variables */ $d_list = ''; $d_array = array(); /* loop through each of the data queries and process them */ while (list($var, $val) = each($_POST)) { if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ $d_list .= '<li>' . db_fetch_cell_prepared('SELECT domain_name FROM user_domains WHERE domain_id = ?', array($matches[1])) . '</li>'; $d_array[] = $matches[1]; } } top_header(); html_start_box('<strong>' . $actions[$_POST['drp_action']] . '</strong>', '60%', '', '3', 'center', ''); print "<form action='user_domains.php' method='post'>\n"; if (isset($d_array) && sizeof($d_array)) { if ($_POST['drp_action'] == '1') { /* delete */ print "\n\t\t\t\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 User Domain(s) will be deleted.</p>\n\t\t\t\t\t\t<p><ul>{$d_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Delete User Domain(s)'>"; } else { if ($_POST['drp_action'] == '2') { /* disable */ print "\n\t\t\t\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 User Domain(s) will be disabled.</p>\n\t\t\t\t\t\t<p><ul>{$d_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Disable User Domain(s)'>"; } else { if ($_POST['drp_action'] == '3') { /* enable */ print "\n\t\t\t\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 User Domain(s) will be enabled.</p>\n\t\t\t\t\t\t<p><ul>{$d_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Enabled User Domain(s)'>"; } else { if ($_POST['drp_action'] == '4') { /* default */ print "\n\t\t\t\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 User Domain will become the default.</p>\n\t\t\t\t\t\t<p><ul>{$d_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Make Selected Domain Default'>"; } } } } } else { print "<tr><td class='even'><span class='textError'>You must select at least one data input method.</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($d_array) ? serialize($d_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>"; html_end_box(); bottom_footer(); }
function tree_remove() { /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('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 tree <strong>'" . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM graph_tree WHERE id = ?', array($_REQUEST['id'])), ENT_QUOTES) . "'</strong>?", htmlspecialchars('tree.php'), htmlspecialchars('tree.php?action=remove&id=' . $_REQUEST['id'])); bottom_footer(); exit; } if (read_config_option('deletion_verification') == '' || isset($_REQUEST['confirm'])) { db_execute_prepared('DELETE FROM graph_tree WHERE id = ?', array($_REQUEST['id'])); db_execute_prepared('DELETE FROM graph_tree_items WHERE graph_tree_id = ?', array($_REQUEST['id'])); } /* clear graph tree cache on save - affects current user only, other users should see changes in <5 minutes */ if (isset($_SESSION['dhtml_tree'])) { unset($_SESSION['dhtml_tree']); } }
function form_actions() { global $colors, $user_actions, $fields_user_edit; /* ================= input validation ================= */ input_validate_input_number(get_request_var_post('drp_action')); /* ==================================================== */ /* 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 */ if (!isset($_POST['delete_type'])) { $_POST['delete_type'] = 2; } $data_sources_to_act_on = array(); $graphs_to_act_on = array(); $devices_to_act_on = array(); for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ $selected_items[$i] = sanitize_search_string($selected_items[$i]); /* ==================================================== */ $data_sources = db_fetch_assoc('SELECT data_local.id AS local_data_id FROM data_local WHERE ' . array_to_sql_or($selected_items, 'data_local.snmp_index') . "\n\t\t\t\t\tAND snmp_query_id='" . mikrotik_data_query_by_hash('ce63249e6cc3d52bc69659a3f32194fe') . "'"); if (sizeof($data_sources) > 0) { foreach ($data_sources as $data_source) { $data_sources_to_act_on[] = $data_source['local_data_id']; } } $graphs = db_fetch_assoc('SELECT graph_local.id AS local_graph_id FROM graph_local WHERE ' . array_to_sql_or($selected_items, 'graph_local.snmp_index') . "\n\t\t\t\t\tAND snmp_query_id='" . mikrotik_data_query_by_hash('ce63249e6cc3d52bc69659a3f32194fe') . "'"); if (sizeof($graphs) > 0) { foreach ($graphs as $graph) { $graphs_to_act_on[] = $graph['local_graph_id']; } } $devices_to_act_on[] = $selected_items[$i]; } api_data_source_remove_multi($data_sources_to_act_on); api_graph_remove_multi($graphs_to_act_on); db_execute("DELETE FROM plugin_mikrotik_users WHERE name IN ('" . implode("','", $devices_to_act_on) . "')"); } header('Location: mikrotik_users.php&header=false'); exit; } /* setup some variables */ $user_list = ''; /* loop through each of the user templates selected on the previous page and get more info about them */ while (list($var, $val) = each($_POST)) { if (preg_match('/^chk_([A-Z0-9]+)$/', $var, $matches)) { /* ================= input validation ================= */ $matches[1] = sanitize_search_string($matches[1]); /* ==================================================== */ $user_list .= '<li>' . $matches[1] . '</li>'; $user_array[] = $matches[1]; } } top_header(); html_start_box('<strong>' . $user_actions[$_POST['drp_action']] . '</strong>', '60%', '', '3', 'center', ''); print "<form action='mikrotik_users.php' autocomplete='off' method='post'>\n"; if (isset($user_array) && sizeof($user_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>When you click \"Continue\" the following Users(s) and their Graph(s) will be deleted.</p>\n\t\t\t\t\t\t<ul>" . $user_list . "</ul>"; print "</td></tr>\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='cactiReturnTo()'> <input type='submit' value='Continue' title='Delete Device(s)'>"; } } else { print "<tr><td><span class='textError'>You must select at least one User.</span></td></tr>\n"; $save_html = "<input type='button' value='Return' onClick='cactiReturnTo()'>"; } print "<tr class='saveRow'>\n\t\t<td colspan='2' align='right' bgcolor='#eaeaea'>\n\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t<input type='hidden' name='selected_items' value='" . (isset($user_array) ? serialize($user_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . $_POST["drp_action"] . "'>\n\t\t\t{$save_html}\n\t\t</td>\n\t</tr>\n"; html_end_box(); bottom_footer(); }
function mactrack_device_remove() { global $config; /* ================= input validation ================= */ get_filter_request_var('device_id'); get_filter_request_var('type_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 host %s', db_fetch_cell_prepared('SELECT device_name FROM host WHERE id = ?', array(get_request_var('device_id')))), 'mactrack_devices.php', 'mactrack_devices.php?action=remove&id=' . get_request_var('device_id')); bottom_footer(); exit; } if (read_config_option('remove_verification') == '' || isset_request_var('confirm')) { api_mactrack_device_remove(get_request_var('device_id')); } }
function syslog_uninstall_advisor() { global $config, $colors; include dirname(__FILE__) . '/config.php'; syslog_connect(); $syslog_exists = sizeof(syslog_db_fetch_row('SHOW TABLES FROM `' . $syslogdb_default . "` LIKE 'syslog'")); top_header(); $fields_syslog_update = array('uninstall_method' => array('method' => 'drop_array', 'friendly_name' => __('What uninstall method do you want to use?'), 'description' => __('When uninstalling syslog, you can remove everything, or only components, just in case you plan on re-installing in the future.'), 'value' => 'all', 'array' => array('all' => __('Remove Everything (Logs, Tables, Settings)'), 'syslog' => __('Syslog Data Only'))), 'mode' => array('method' => 'hidden', 'value' => 'uninstall'), 'id' => array('method' => 'hidden', 'value' => 'syslog')); print "<form action='plugins.php' method='get'>\n"; print "<table align='center' width='80%'><tr><td>\n"; html_start_box(__('Syslog Uninstall Preferences'), '100%', $colors['header'], '3', 'center', ''); draw_edit_form(array('config' => array(), 'fields' => inject_form_variables($fields_syslog_update, array()))); html_end_box(); syslog_confirm_button('uninstall', 'plugins.php', $syslog_exists); print "</td></tr></table>\n"; bottom_footer(); exit; }
function form_aggregated_actions() { global $config, $mactrack_view_agg_macs_actions; /* ================= input validation ================= */ get_filter_request_var('drp_action'); /* ==================================================== */ /* if we are to save this form, instead of display it */ if (isset_request_var('selected_items')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { if (get_request_var('drp_action') == '01') { /* Delete */ if (sizeof($selected_items)) { db_execute('DELETE FROM mac_track_aggregated_ports WHERE row_id IN (' . implode(',', $selected_items) . ')'); } } header('Location: mactrack_view_macs.php'); exit; } } /* setup some variables */ $row_array = array(); $mac_address_list = ''; $row_list = ''; $i = 0; $row_ids = ''; /* loop through each of the ports 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]); /* ==================================================== */ $row_array[] = $matches[1]; } } if (sizeof($row_array)) { $row_ids = implode(',', $row_array); $rows_info = db_fetch_assoc('SELECT device_name, mac_address, ip_address, port_number, count_rec FROM mac_track_aggregated_ports WHERE row_id IN (' . implode(',', $row_array) . ')'); if (isset($rows_info)) { foreach ($rows_info as $row_info) { $row_list .= '<li>' . __(' Dev.:%s IP.:%s MAC.:%s PORT.:%s Count.: [%s]', $row_info['device_name'], $row_info['ip_address'], $row_info['mac_address'], $row_info['port_number'], $row_info['count_rec']) . '</li>'; } } } top_header(); html_start_box($mactrack_view_agg_macs_actions[get_request_var('drp_action')], '60%', '', '3', 'center', ''); form_start('mactrack_view_macs.php'); if (!sizeof($row_array)) { print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Row.') . "</span></td></tr>\n"; $save_html = ""; } else { if (!mactrack_check_user_realm(2122)) { print "<tr><td class='even'><span class='textError'>" . __('You are not permitted to delete rows.') . "</span></td></tr>\n"; $save_html = ""; } else { $save_html = "<input type='submit' name='save' value='" . __('Yes') . "'>"; if (get_request_var('drp_action') == '1') { /* Delete Macs */ print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Are you sure you want to Delete the following rows from Aggregated table?') . "</p>\n\t\t\t\t\t<p><ul>{$row_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t</tr>"; } } } print "<tr>\n\t\t<td colspan='2' align='right' class='saveRow'>\n\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t<input type='hidden' name='selected_items' value='" . (isset($row_array) ? serialize($row_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>" . (strlen($save_html) ? "\n\t\t\t<input type='submit' name='cancel_x' value='No'>\n\t\t\t{$save_html}" : "<input type='submit' name='cancel' value='Return'>") . "\n\t\t</td>\n\t</tr>"; html_end_box(); bottom_footer(); }
function form_actions() { global $actions, $assoc_actions; /* ================= input validation ================= */ get_filter_request_var('id'); get_filter_request_var('drp_action', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^([a-zA-Z0-9_]+)$/'))); /* ================= input validation ================= */ /* if we are to save this form, instead of display it */ if (isset_request_var('selected_items')) { if (isset_request_var('save_list')) { if (get_request_var('drp_action') == '2') { /* delete */ schedule_delete(); } elseif (get_request_var('drp_action') == '1') { /* update */ schedule_update(); } header('Location: maint.php?header=false'); exit; } elseif (isset_request_var('save_hosts')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { if (get_request_var('drp_action') == '1') { /* associate */ for ($i = 0; $i < count($selected_items); $i++) { db_execute('REPLACE INTO plugin_maint_hosts (type, host, schedule) VALUES (1, ' . $selected_items[$i] . ', ' . get_request_var('id') . ')'); } } elseif (get_request_var('drp_action') == '2') { /* disassociate */ for ($i = 0; $i < count($selected_items); $i++) { db_execute('DELETE FROM plugin_maint_hosts WHERE type=1 AND host=' . $selected_items[$i] . ' AND schedule=' . get_request_var('id')); } } } header('Location: maint.php?action=edit&tab=hosts&header=false&id=' . get_request_var('id')); exit; } elseif (isset_request_var('save_webseer')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { if (get_request_var('drp_action') == '1') { /* associate */ for ($i = 0; $i < count($selected_items); $i++) { db_execute('REPLACE INTO plugin_maint_hosts (type, host, schedule) VALUES (2, ' . $selected_items[$i] . ', ' . get_request_var('id') . ')'); } } elseif (get_request_var('drp_action') == '2') { /* disassociate */ for ($i = 0; $i < count($selected_items); $i++) { db_execute('DELETE FROM plugin_maint_hosts WHERE type=2 AND host=' . $selected_items[$i] . ' AND schedule=' . get_request_var('id')); } } } header('Location: maint.php?action=edit&tab=webseer&header=false&id=' . get_request_var('id')); exit; } else { api_plugin_hook_function('maint_actions_execute'); } } /* setup some variables */ $list = ''; $array = array(); $list_name = ''; if (isset_request_var('id')) { $list_name = db_fetch_cell('SELECT name FROM plugin_maint_schedules WHERE id=' . get_request_var('id')); } if (isset_request_var('save_list')) { /* loop through each of the notification lists 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]); /* ==================================================== */ $list .= '<li><b>' . db_fetch_cell('SELECT name FROM plugin_maint_schedules WHERE id=' . $matches[1]) . '</b></li>'; $array[] = $matches[1]; } } top_header(); form_start('maint.php'); html_start_box($actions[get_request_var('drp_action')] . " {$list_name}", '60%', '', '3', 'center', ''); if (sizeof($array)) { if (get_request_var('drp_action') == '1') { /* update */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Update the following Maintenance Schedule(s).') . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Update Maintenance Schedule(s)') . "'>"; } elseif (get_request_var('drp_action') == '2') { /* delete */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Delete the following Maintenance Schedule(s). Any Devices(s) Associated with this Schedule will be Disassociated.') . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Delete Maintenance Schedule(s)') . "'>"; } } else { print "<tr><td><span class='textError'>" . __('You must select at least one Maintenance Schedule.') . "</span></td></tr>\n"; $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>"; } print "<tr class='saveRow'>\n\t\t\t<td>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='save_list' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; html_end_box(); form_end(); bottom_footer(); } elseif (isset_request_var('save_hosts')) { /* loop through each of the notification lists 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]); /* ==================================================== */ $list .= '<li><b>' . db_fetch_cell('SELECT description FROM host WHERE id=' . $matches[1]) . '</b></li>'; $array[] = $matches[1]; } } top_header(); form_start('maint.php'); html_start_box($assoc_actions[get_request_var('drp_action')] . ' ' . __('Device(s)'), '60%', '', '3', 'center', ''); if (sizeof($array)) { if (get_request_var('drp_action') == '1') { /* associate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to associate the following Device(s) with the Maintenance Schedule \'<b>%s</b>\'.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Associate Maintenance Schedule(s)') . "'>"; } elseif (get_request_var('drp_action') == '2') { /* disassociate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to disassociate the following Device(s) with the Maintenance Schedule \'<b>%s</b>\'.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Disassociate Maintenance Schedule(s)') . "'>"; } } else { print "<tr><td><span class='textError'>" . __('You must select at least one Device.') . "</span></td></tr>\n"; $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>"; } print "<tr class='saveRow'>\n\t\t\t<td>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='id' value='" . get_request_var('id') . "'>\n\t\t\t\t<input type='hidden' name='save_hosts' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; html_end_box(); form_end(); bottom_footer(); } elseif (isset_request_var('save_webseer')) { /* loop through each of the notification lists 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]); /* ==================================================== */ $list .= '<li><b>' . db_fetch_cell('SELECT description FROM host WHERE id=' . $matches[1]) . '</b></li>'; $array[] = $matches[1]; } } top_header(); html_start_box($assoc_actions[get_request_var('drp_action')] . ' ' . __('Device(s)'), '60%', '', '3', 'center', ''); form_start('maint.php'); if (sizeof($array)) { if (get_request_var('drp_action') == '1') { /* associate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to associate the Device(s) below with the Maintenance Schedule \'<b>%s</b>\'.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Associate Maintenance Schedule(s)') . "'>"; } elseif (get_request_var('drp_action') == '2') { /* disassociate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to disassociate the Devices(s) below with the Maintenance Schedule \'<b>%s</b>\'.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Disassociate Maintenance Schedule(s)') . "'>"; } } else { print "<tr><td><span class='textError'>" . __('You must select at least one Device.') . "</span></td></tr>\n"; $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>"; } print "<tr class='saveRow'>\n\t\t\t<td>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='id' value='" . get_request_var('id') . "'>\n\t\t\t\t<input type='hidden' name='save_webseer' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; form_end(); html_end_box(); bottom_footer(); } else { api_plugin_hook_function('maint_actions_prepare'); } }
function list_tholds() { global $thold_states, $config, $host_id, $timearray, $thold_types; $thold_actions = array(1 => __('Delete'), 2 => __('Disable'), 3 => __('Enable'), 4 => __('Reapply Suggested Names'), 5 => __('Propagate Template')); thold_request_validation(); /* if the number of rows is -1, set it to the default */ if (get_request_var('rows') == -1) { $rows = read_config_option('num_rows_table'); } else { $rows = get_request_var('rows'); } $statefilter = ''; if (isset_request_var('state')) { if (get_request_var('state') == '-1') { $statefilter = ''; } else { if (get_request_var('state') == '0') { $statefilter = "thold_data.thold_enabled='off'"; } if (get_request_var('state') == '2') { $statefilter = "thold_data.thold_enabled='on'"; } if (get_request_var('state') == '1') { $statefilter = '(thold_data.thold_alert!=0 OR thold_data.bl_alert>0)'; } if (get_request_var('state') == '3') { $statefilter = '((thold_data.thold_alert!=0 AND thold_data.thold_fail_count >= thold_data.thold_fail_trigger) OR (thold_data.bl_alert>0 AND thold_data.bl_fail_count >= thold_data.bl_fail_trigger))'; } } } top_header(); $sql_where = ''; $sort = get_request_var('sort_column'); $limit = ' LIMIT ' . $rows * (get_request_var('page') - 1) . ", {$rows}"; if (!isempty_request_var('host_id') && get_request_var('host_id') != '-1') { $sql_where .= (!strlen($sql_where) ? '(' : ' AND ') . "td.host_id = " . get_request_var('host_id'); } if (!isempty_request_var('data_template_id') && get_request_var('data_template_id') != '-1') { $sql_where .= (!strlen($sql_where) ? '(' : ' AND ') . "td.data_template_id = " . get_request_var('data_template_id'); } if ($statefilter != '') { $sql_where .= (!strlen($sql_where) ? '(' : ' AND ') . "{$statefilter}"; } if ($sql_where != '') { $sql_where .= ')'; } $tholds = get_allowed_thresholds($sql_where, $sort . ' ' . get_request_var('sort_direction'), $rows * (get_request_var('page') - 1) . ", {$rows}", $total_rows); $data_templates = db_fetch_assoc("SELECT DISTINCT data_template.id, data_template.name\n\t\tFROM data_template\n\t\tINNER JOIN thold_data \n\t\tON thold_data.data_template_id = data_template.id\n\t\tORDER BY data_template.name"); html_start_box(__('Threshold Management'), '100%', '', '3', 'center', 'thold.php?action=add'); ?> <tr class='even'> <td> <form id='listthold' action='thold.php' method='post'> <table class='filterTable'> <tr> <td> <?php print __('Search'); ?> </td> <td> <input type='text' id='filter' size='25' value='<?php print get_request_var('filter'); ?> '> </td> <?php print html_host_filter(get_request_var('host_id')); ?> <td> <?php print __('Template'); ?> </td> <td> <select id='data_template_id' onChange='applyFilter()'> <option value='-1'><?php print __('Any'); ?> </option> <?php foreach ($data_templates as $row) { echo "<option value='" . $row['id'] . "'" . (isset_request_var('data_template_id') && $row['id'] == get_request_var('data_template_id') ? ' selected' : '') . '>' . $row['name'] . '</option>'; } ?> </select> </td> <td> <?php print __('State'); ?> </td> <td> <select id='state' onChange='applyFilter()'> <option value='-1'<?php if (get_request_var('state') == '-1') { ?> selected<?php } ?> ><?php print __('All'); ?> </option> <option value='1'<?php if (get_request_var('state') == '1') { ?> selected<?php } ?> ><?php print __('Breached'); ?> </option> <option value='3'<?php if (get_request_var('state') == '3') { ?> selected<?php } ?> ><?php print __('Triggered'); ?> </option> <option value='2'<?php if (get_request_var('state') == '2') { ?> selected<?php } ?> ><?php print __('Enabled'); ?> </option> <option value='0'<?php if (get_request_var('state') == '0') { ?> selected<?php } ?> ><?php print __('Disabled'); ?> </option> </select> </td> <td> <input type='button' id='refresh' value='<?php print __('Go'); ?> ' title='<?php print __('Apply Filters'); ?> ' onClick='applyFilter()'> </td> <td> <input type='button' id='clear' value='<?php print __('Clear'); ?> ' title='<?php print __('Return to Defaults'); ?> ' onClick='clearFilter()'> </td> </tr> </table> <input type='hidden' name='search' value='search'> <input type='hidden' id='page' value='<?php print get_filter_request_var('page'); ?> '> </form> <script type='text/javascript'> function applyFilter() { strURL = 'thold.php?header=false&host_id=' + $('#host_id').val(); strURL += '&state=' + $('#state').val(); strURL += '&data_template_id=' + $('#data_template_id').val(); strURL += '&filter=' + $('#filter').val(); loadPageNoHeader(strURL); } function clearFilter() { strURL = 'thold.php?header=false&clear=1'; loadPageNoHeader(strURL); } $(function() { $('#listthold').submit(function(event) { event.preventDefault(); applyFilter(); }); }); </script> </td> </tr> <?php html_end_box(); $nav = html_nav_bar('thold.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 14, __('Thresholds'), 'page', 'main'); form_start('thold.php', 'chk'); print $nav; html_start_box('', '100%', '', '4', 'center', ''); $display_text = array('name' => array('display' => __('Name'), 'sort' => 'ASC', 'align' => 'left'), 'id' => array('display' => __('ID'), 'sort' => 'ASC', 'align' => 'right'), 'thold_type' => array('display' => __('Type'), 'sort' => 'ASC', 'align' => 'right'), 'data_source' => array('display' => __('DSName'), 'sort' => 'ASC', 'align' => 'right'), 'lastread' => array('display' => __('Current'), 'sort' => 'ASC', 'align' => 'right', 'tip' => __('The last measured value for the Data Source')), 'thold_hi' => array('display' => __('High'), 'sort' => 'ASC', 'align' => 'right', 'tip' => __('High Threshold values for Warning/Alert')), 'thold_low' => array('display' => __('Low'), 'sort' => 'ASC', 'align' => 'right', 'tip' => __('Low Threshold values for Warning/Alert')), 'nosort3' => array('display' => __('Trigger'), 'sort' => '', 'align' => 'right'), 'nosort4' => array('display' => __('Duration'), 'sort' => '', 'align' => 'right'), 'repeat_alert' => array('display' => __('Repeat'), 'sort' => 'ASC', 'align' => 'right'), 'thold_alert' => array('display' => __('Triggered'), 'sort' => 'ASC', 'align' => 'right'), 'template_enabled' => array('display' => __('Templated'), 'sort' => 'ASC', 'align' => 'right')); html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false); $c = 0; $i = 0; if (sizeof($tholds)) { foreach ($tholds as $thold_data) { $c++; $grapharr = db_fetch_row('SELECT DISTINCT graph_templates_item.local_graph_id FROM graph_templates_item, data_template_rrd WHERE (data_template_rrd.local_data_id=' . $thold_data['local_data_id'] . ' AND data_template_rrd.id=graph_templates_item.task_item_id)'); $local_graph_id = $grapharr['local_graph_id']; $alertstat = __('No'); $bgcolor = 'green'; if ($thold_data['thold_type'] == 0) { if ($thold_data['thold_alert'] != 0) { $alertstat = __('Yes'); if ($thold_data['thold_fail_count'] >= $thold_data['thold_fail_trigger']) { $bgcolor = 'red'; } elseif ($thold_data['thold_warning_fail_count'] >= $thold_data['thold_warning_fail_trigger']) { $bgcolor = 'warning'; } else { $bgcolor = 'yellow'; } } } elseif ($thold_data['thold_type'] == 2) { if ($thold_data['thold_alert'] != 0) { $alertstat = __('Yes'); if ($thold_data['thold_fail_count'] >= $thold_data['time_fail_trigger']) { $bgcolor = 'red'; } elseif ($thold_data['thold_warning_fail_count'] >= $thold_data['time_warning_fail_trigger']) { $bgcolor = 'warning'; } else { $bgcolor = 'yellow'; } } } else { if ($thold_data['bl_alert'] == 1) { $alertstat = __('baseline-LOW'); $bgcolor = $thold_data['bl_fail_count'] >= $thold_data['bl_fail_trigger'] ? 'orange' : 'yellow'; } elseif ($thold_data['bl_alert'] == 2) { $alertstat = __('baseline-HIGH'); $bgcolor = $thold_data['bl_fail_count'] >= $thold_data['bl_fail_trigger'] ? 'orange' : 'yellow'; } } $data_source = db_fetch_cell_prepared('SELECT data_source_name FROM data_template_rrd WHERE id = ?', array($thold_data['data_template_rrd_id'])); if ($thold_data['thold_enabled'] == 'off') { print "<tr class='selectable " . $thold_states['grey']['class'] . "' id='line" . $thold_data['id'] . "'>\n"; } else { print "<tr class='selectable " . $thold_states[$bgcolor]['class'] . "' id='line" . $thold_data['id'] . "'>\n"; } form_selectable_cell(filter_value($thold_data['name'] != '' ? $thold_data['name'] : $thold_data['name_cache'] . ' [' . $thold_data['data_source_name'] . ']', get_request_var('filter'), 'thold.php?action=edit&id=' . $thold_data['id']) . '</a>', $thold_data['id'], '', 'text-align:left'); form_selectable_cell($thold_data['id'], $thold_data['id'], '', 'text-align:right'); form_selectable_cell($thold_types[$thold_data['thold_type']], $thold_data['id'], '', 'text-align:right'); form_selectable_cell($data_source, $thold_data['id'], '', 'text-align:right'); switch ($thold_data['thold_type']) { case 0: form_selectable_cell(thold_format_number($thold_data['lastread']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['thold_warning_hi']) . ' / ' . thold_format_number($thold_data['thold_hi']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['thold_warning_low']) . ' / ' . thold_format_number($thold_data['thold_low']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell('<i>' . plugin_thold_duration_convert($thold_data['local_data_id'], $thold_data['thold_fail_trigger'], 'alert') . '</i>', $thold_data['id'], '', 'text-align:right'); form_selectable_cell(__('N/A'), $thold_data['id'], '', 'text-align:right'); break; case 1: form_selectable_cell(thold_format_number($thold_data['lastread']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['thold_warning_hi']) . ' / ' . thold_format_number($thold_data['thold_hi']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['thold_warning_low']) . ' / ' . thold_format_number($thold_data['thold_low']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell('<i>' . plugin_thold_duration_convert($thold_data['local_data_id'], $thold_data['bl_fail_trigger'], 'alert') . '</i>', $thold_data['id'], '', 'text-align:right'); form_selectable_cell($timearray[$thold_data['bl_ref_time_range'] / 300], $thold_data['id'], '', 'text-align:right'); break; case 2: form_selectable_cell(thold_format_number($thold_data['lastread']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['time_warning_hi']) . ' / ' . thold_format_number($thold_data['time_hi']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(thold_format_number($thold_data['time_warning_low']) . ' / ' . thold_format_number($thold_data['time_low']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell('<i>' . __('%d Triggers', $thold_data['time_fail_trigger']) . '</i>', $thold_data['id'], '', 'text-align:right'); form_selectable_cell('<i>' . plugin_thold_duration_convert($thold_data['local_data_id'], $thold_data['time_fail_length'], 'time') . '</i>', $thold_data['id'], '', 'text-align:right'); break; default: form_selectable_cell(thold_format_number($thold_data['lastread']), $thold_data['id'], '', 'text-align:right'); form_selectable_cell('- / -', $thold_data['id'], '', 'text-align:right'); form_selectable_cell('- / -', $thold_data['id'], '', 'text-align:right'); form_selectable_cell(__('N/A'), $thold_data['id'], '', 'text-align:right'); form_selectable_cell(__('N/A'), $thold_data['id'], '', 'text-align:right'); } form_selectable_cell($thold_data['repeat_alert'] == '' ? '' : plugin_thold_duration_convert($thold_data['local_data_id'], $thold_data['repeat_alert'], 'repeat'), $thold_data['id'], '', 'text-align:right'); form_selectable_cell($alertstat, $thold_data['id'], '', 'text-align:right'); if ($thold_data['thold_template_id'] != 0) { form_selectable_cell($thold_data['template_enabled'] == '' ? __('No') : __('Yes'), $thold_data['id'], '', 'text-align:right'); } else { form_selectable_cell(__('No'), $thold_data['id'], '', 'text-align:right'); } form_checkbox_cell($thold_data['name'], $thold_data['id'], '', 'text-align:left'); form_end_row(); } } else { print "<tr class='even'><td colspan='14'><center>" . __('No Thresholds') . "</center></td></tr>\n"; } html_end_box(false); if (sizeof($tholds)) { print $nav; } thold_legend(); draw_actions_dropdown($thold_actions); if (isset($host_id) && $host_id != '') { print "<input type='hidden' name='host_id' value='{$host_id}'>"; } form_end(); bottom_footer(); }
function mactrack_site_remove() { global $config; /* ================= input validation ================= */ get_filter_request_var('site_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 site <strong>'%s'</strong>?", db_fetch_cell('SELECT description FROM host WHERE id=' . get_request_var('device_id'))), 'mactrack_sites.php', 'mactrack_sites.php?action=remove&site_id=' . get_request_var('site_id')); bottom_footer(); exit; } if (read_config_option('remove_verification') == '' || isset_request_var('confirm')) { api_mactrack_site_remove(get_request_var('site_id')); } }
function form_actions() { global $actions, $assoc_actions; /* ================= input validation ================= */ get_filter_request_var('drp_action'); /* ==================================================== */ /* if we are to save this form, instead of display it */ if (isset_request_var('selected_items')) { if (isset_request_var('save_list')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { if (get_request_var('drp_action') == '1') { /* delete */ db_execute('DELETE FROM plugin_notification_lists WHERE ' . array_to_sql_or($selected_items, 'id')); db_execute('UPDATE host SET thold_send_email=0 WHERE thold_send_email=2 AND ' . array_to_sql_or($selected_items, 'thold_host_email')); db_execute('UPDATE host SET thold_send_email=1 WHERE thold_send_email=3 AND ' . array_to_sql_or($selected_items, 'thold_host_email')); db_execute('UPDATE host SET thold_host_email=0 WHERE ' . array_to_sql_or($selected_items, 'thold_host_email')); } elseif (get_request_var('drp_action') == '2') { /* duplicate */ // To Do } } header('Location: notify_lists.php?header=false'); exit; } elseif (isset_request_var('save_associate')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { get_filter_request_var('notification_action'); if (get_request_var('drp_action') == '1') { /* associate */ for ($i = 0; $i < count($selected_items); $i++) { /* set the notification list */ db_execute('UPDATE host SET thold_host_email=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); /* set the global/list election */ db_execute('UPDATE host SET thold_send_email=' . get_request_var('notification_action') . ' WHERE id=' . $selected_items[$i]); } } elseif (get_request_var('drp_action') == '2') { /* disassociate */ for ($i = 0; $i < count($selected_items); $i++) { /* set the notification list */ db_execute('UPDATE host SET thold_host_email=0 WHERE id=' . $selected_items[$i]); /* set the global/list election */ db_execute('UPDATE host SET thold_send_email=' . get_request_var('notification_action') . ' WHERE id=' . $selected_items[$i]); } } } header('Location: notify_lists.php?header=false&action=edit&tab=hosts&id=' . get_request_var('id')); exit; } elseif (isset_request_var('save_templates')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { get_filter_request_var('notification_action'); if (get_request_var('drp_action') == '1') { /* associate */ for ($i = 0; $i < count($selected_items); $i++) { if (get_request_var('notification_warning_action') > 0) { /* clear other settings */ if (get_request_var('notification_warning_action') == 1) { /* set the notification list */ db_execute('UPDATE thold_template SET notify_warning=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); /* clear other items */ db_execute("UPDATE thold_template SET notify_warning_extra='' WHERE id=" . $selected_items[$i]); } else { /* set the notification list */ db_execute('UPDATE thold_template SET notify_warning=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); } } if (get_request_var('notification_alert_action') > 0) { /* clear other settings */ if (get_request_var('notification_alert_action') == 1) { /* set the notification list */ db_execute('UPDATE thold_template SET notify_alert=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); /* clear other items */ db_execute("UPDATE thold_template SET notify_extra='' WHERE id=" . $selected_items[$i]); db_execute('DELETE FROM plugin_thold_template_contact WHERE template_id=' . $selected_items[$i]); } else { /* set the notification list */ db_execute('UPDATE thold_template SET notify_alert=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); } } } } elseif (get_request_var('drp_action') == '2') { /* disassociate */ for ($i = 0; $i < count($selected_items); $i++) { if (get_request_var('notification_warning_action') > 0) { /* set the notification list */ db_execute('UPDATE thold_template SET notify_warning=0 WHERE id=' . $selected_items[$i] . ' AND notify_warning=' . get_request_var('id')); } if (get_request_var('notification_alert_action') > 0) { /* set the notification list */ db_execute('UPDATE thold_template SET notify_alert=0 WHERE id=' . $selected_items[$i] . ' AND notify_alert=' . get_request_var('id')); } } } } header('Location: notify_lists.php?header=false&action=edit&tab=templates&id=' . get_request_var('id')); exit; } elseif (isset_request_var('save_tholds')) { $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items')); if ($selected_items != false) { get_filter_request_var('notification_action'); if (get_request_var('drp_action') == '1') { /* associate */ for ($i = 0; $i < count($selected_items); $i++) { if (get_request_var('notification_warning_action') > 0) { /* clear other settings */ if (get_request_var('notification_warning_action') == 1) { /* set the notification list */ db_execute('UPDATE thold_data SET notify_warning=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); /* clear other items */ db_execute("UPDATE thold_data SET notify_warning_extra='' WHERE id=" . $selected_items[$i]); } else { /* set the notification list */ db_execute('UPDATE thold_data SET notify_warning=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); } } if (get_request_var('notification_alert_action') > 0) { /* clear other settings */ if (get_request_var('notification_alert_action') == 1) { /* set the notification list */ db_execute('UPDATE thold_data SET notify_alert=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); /* clear other items */ db_execute("UPDATE thold_data SET notify_extra='' WHERE id=" . $selected_items[$i]); db_execute('DELETE FROM plugin_thold_threshold_contact WHERE thold_id=' . $selected_items[$i]); } else { /* set the notification list */ db_execute('UPDATE thold_data SET notify_alert=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]); } } } } elseif (get_request_var('drp_action') == '2') { /* disassociate */ for ($i = 0; $i < count($selected_items); $i++) { if (get_request_var('notification_warning_action') > 0) { /* set the notification list */ db_execute('UPDATE thold_data SET notify_warning=0 WHERE id=' . $selected_items[$i] . ' AND notify_warning=' . get_request_var('id')); } if (get_request_var('notification_alert_action') > 0) { /* set the notification list */ db_execute('UPDATE thold_data SET notify_alert=0 WHERE id=' . $selected_items[$i] . ' AND notify_alert=' . get_request_var('id')); } } } } header('Location: notify_lists.php?header=false&action=edit&tab=tholds&id=' . get_request_var('id')); exit; } } /* setup some variables */ $list = ''; $array = array(); $list_name = ''; if (isset_request_var('id')) { $list_name = db_fetch_cell('SELECT name FROM plugin_notification_lists WHERE id=' . get_filter_request_var('id')); } if (isset_request_var('save_list')) { /* loop through each of the notification lists 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]); /* ==================================================== */ $list .= '<li><b>' . db_fetch_cell('SELECT name FROM plugin_notification_lists WHERE id=' . $matches[1]) . '</b></li>'; $array[] = $matches[1]; } } top_header(); form_start('notify_lists.php'); html_start_box($actions[get_request_var('drp_action')] . " {$list_name}", '60%', '', '3', 'center', ''); print "<form action='notify_lists.php' method='post'>\n"; if (sizeof($array)) { if (get_request_var('drp_action') == '1') { /* delete */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Delete Notification Lists(s). Any Device(s) or Threshold(s) associated with the List(s) will be reverted to the default.') . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Delete Notification List(s)') . "'>"; } elseif (get_request_var('drp_action') == '2') { /* duplicate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Duplicate the following Notification List(s).') . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Duplicate Notification List(s)') . "'>"; } } else { print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Notification List.') . "</span></td></tr>\n"; $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>"; } print "<tr>\n\t\t\t\t<td class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='save_list' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; html_end_box(); form_end(); bottom_footer(); } elseif (isset_request_var('save_templates')) { /* loop through each of the notification lists 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]); /* ==================================================== */ $list .= '<li><b>' . db_fetch_cell('SELECT name FROM thold_template WHERE id=' . $matches[1]) . '</b></li>'; $array[] = $matches[1]; } } top_header(); form_start('notify_lists.php'); html_start_box(__('%s Threshold Template(s)', $assoc_actions[get_request_var('drp_action')]), '60%', '', '3', 'center', ''); if (sizeof($array)) { if (get_request_var('drp_action') == '1') { /* associate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Association the Notification List \'<b>%s</b>\' with the Threshold Template(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Warning Membership:') . "</b><br>"; form_dropdown('notification_warning_action', array(0 => __('No Change'), 1 => __('Notification List Only'), 2 => __('Notification List, Retain Other Settings')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t\t<p><b>" . __('Alert Membership:') . "</b><br>"; form_dropdown('notification_alert_action', array(0 => __('No Change'), 1 => __('Notification List Only'), 2 => __('Notification List, Retain Other Settings')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Associate Notification List(s)') . "'>"; } elseif (get_request_var('drp_action') == '2') { /* disassociate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Disassociate the Notification List \'<b>%s</b>\' from the Thresholds Template(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Warning Membership:') . "</b><br>"; form_dropdown('notification_warning_action', array(0 => __('No Change'), 1 => __('Remove List')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t\t<p><b>" . __('Alert Membership:') . "</b><br>"; form_dropdown('notification_alert_action', array(0 => __('No Change'), 1 => __('Remove List')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Disassociate Notification List(s)') . "'>"; } } else { print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Threshold Template.') . "</span></td></tr>\n"; $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>"; } print "\t<tr>\n\t\t\t\t<td class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='id' value='" . get_request_var('id') . "'>\n\t\t\t\t<input type='hidden' name='save_templates' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; html_end_box(); form_end(); bottom_footer(); } elseif (isset_request_var('save_tholds')) { /* loop through each of the notification lists 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]); /* ==================================================== */ $list .= '<li><b>' . db_fetch_cell('SELECT name FROM thold_data WHERE id=' . $matches[1]) . '</b></li>'; $array[] = $matches[1]; } } top_header(); form_start('notify_lists.php'); html_start_box(__('%s Threshold(s)', $assoc_actions[get_request_var('drp_action')]), '60%', '', '3', 'center', ''); if (sizeof($array)) { if (get_request_var('drp_action') == '1') { /* associate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Associate the Notification List \'<b>%s</b>\' with the Threshold(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Warning Membership:') . "</b><br>"; form_dropdown('notification_warning_action', array(0 => __('No Change'), 1 => __('Notification List Only'), 2 => __('Notification List, Retain Other Settings')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t\t<p><b>" . __('Alert Membership:') . "</b><br>"; form_dropdown('notification_alert_action', array(0 => __('No Change'), 1 => __('Notification List Only'), 2 => __('Notification List, Retain Other Settings')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Associate Notification List(s)') . "'>"; } elseif (get_request_var('drp_action') == '2') { /* disassociate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Disassociate the Notification List \'<b>%s</b>\' from the Thresholds(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Warning Membership:') . "</b><br>"; form_dropdown('notification_warning_action', array(0 => __('No Change'), 1 => __('Remove List')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t\t<p><b>" . __('Alert Membership:') . "</b><br>"; form_dropdown('notification_alert_action', array(0 => __('No Change'), 1 => __('Remove List')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Disassociate Notification List(s)') . "'>"; } } else { print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Threshold.') . "</span></td></tr>\n"; $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>"; } print "\t<tr>\n\t\t\t\t<td class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='id' value='" . get_request_var('id') . "'>\n\t\t\t\t<input type='hidden' name='save_tholds' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; html_end_box(); form_end(); bottom_footer(); } else { /* loop through each of the notification lists 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]); /* ==================================================== */ $list .= '<li>' . db_fetch_cell('SELECT description FROM host WHERE id=' . $matches[1]) . '</li>'; $array[] = $matches[1]; } } top_header(); form_start('notify_lists.php'); html_start_box($assoc_actions[get_request_var('drp_action')] . ' Device(s)', '60%', '', '3', 'center', ''); if (sizeof($array)) { if (get_request_var('drp_action') == '1') { /* associate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Associate the Notification List \'<b>%s</b>\' with the Device(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Resulting Membership:') . "<br>"; form_dropdown('notification_action', array(2 => __('Notification List Only'), 3 => __('Notification and Global Lists')), '', '', 2, '', ''); print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Associate Notification List(s)') . "'>"; } elseif (get_request_var('drp_action') == '2') { /* disassociate */ print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Disassociate the Notification List \'<b>%s</b>\' from the Device(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Resulting Membership:') . "</b><br>"; form_dropdown('notification_action', array(1 => __('Global List'), 0 => __('Disabled')), '', '', 1, '', ''); print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'> <input type='submit' value='" . __('Continue') . "' title='" . __('Disassociate Notification List(s)') . "'>"; } } else { print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Device.') . "</span></td></tr>\n"; $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>"; } print "<tr>\n\t\t\t\t<td class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='id' value='" . get_request_var('id') . "'>\n\t\t\t\t<input type='hidden' name='save_associate' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n"; html_end_box(); form_end(); bottom_footer(); } }
function host_remove() { global $config; /* ================= input validation ================= */ input_validate_input_number(get_request_var_request('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 host <strong>'" . htmlspecialchars(db_fetch_cell_prepared('SELECT description FROM host WHERE id = ?', array($_REQUEST['id']))) . "'</strong>?", htmlspecialchars('host.php'), htmlspecialchars('host.php?action=remove&id=' . $_REQUEST['id'])); bottom_footer(); exit; } if (read_config_option('deletion_verification') == '' || isset($_REQUEST['confirm'])) { api_device_remove($_REQUEST['id']); } }
function mactrack_utilities_recreate_aggregated_data() { global $config; 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 and recreate all the Aggregated Port to MAC to IP results from the system?'), 'mactrack_utilities.php', 'mactrack_utilities.php?action=mactrack_utilities_recreate_aggregated_data'); bottom_footer(); exit; } if (read_config_option('remove_verification') == '' || isset_request_var('confirm')) { $old_rows = db_fetch_cell('SELECT COUNT(*) FROM mac_track_aggregated_ports'); db_execute('TRUNCATE TABLE mac_track_aggregated_ports'); db_execute('INSERT INTO mac_track_aggregated_ports (site_id, device_id, hostname, device_name, vlan_id, vlan_name, mac_address, vendor_mac, ip_address, dns_hostname, port_number, port_name, date_last, first_scan_date, count_rec, authorized) SELECT site_id, device_id, hostname, device_name, vlan_id, vlan_name, mac_address, vendor_mac, ip_address, dns_hostname, port_number, port_name, max(scan_date), min(scan_date), count(*), authorized FROM mac_track_ports GROUP BY site_id,device_id, mac_address, port_number, ip_address, vlan_id, authorized'); $new_rows = db_fetch_cell('SELECT COUNT(*) FROM mac_track_aggregated_ports'); top_header(); mactrack_utilities(); html_start_box('Device Tracking Database Results', '100%', '', '3', 'center', ''); ?> <td> The following number of records have been removed from the aggergated table: <?php print $old_rows; ?> . And <?php print $new_rows; ?> number of record will be added. </td> <?php html_end_box(); } }
function host_new_graphs($host_id, $host_template_id, $selected_graphs_array) { /* we use object buffering on this page to allow redirection to another page if no fields are actually drawn */ ob_start(); top_header(); print "<form method='post' action='graphs_new.php'>\n"; $snmp_query_id = 0; $num_output_fields = array(); while (list($form_type, $form_array) = each($selected_graphs_array)) { while (list($form_id1, $form_array2) = each($form_array)) { if ($form_type == 'cg') { $graph_template_id = $form_id1; html_start_box("<strong>Create Graph from '" . db_fetch_cell_prepared('SELECT name FROM graph_templates WHERE id = ?', array($graph_template_id)) . "'", '100%', '', '3', 'center', ''); } elseif ($form_type == 'sg') { while (list($form_id2, $form_array3) = each($form_array2)) { /* ================= input validation ================= */ input_validate_input_number($snmp_query_id); /* ==================================================== */ $snmp_query_id = $form_id1; $snmp_query_graph_id = $form_id2; $num_graphs = sizeof($form_array3); $snmp_query = db_fetch_row_prepared('SELECT snmp_query.name, snmp_query.xml_path FROM snmp_query WHERE snmp_query.id = ?', array($snmp_query_id)); $graph_template_id = db_fetch_cell_prepared('SELECT graph_template_id FROM snmp_query_graph WHERE id = ?', array($snmp_query_graph_id)); } /* DRAW: Data Query */ html_start_box("<strong>Create {$num_graphs} Graph" . ($num_graphs > 1 ? 's' : '') . " from '" . db_fetch_cell_prepared('SELECT name FROM snmp_query WHERE id = ?', array($snmp_query_id)) . "'", '100%', '', '3', 'center', ''); } /* ================= input validation ================= */ input_validate_input_number($graph_template_id); /* ==================================================== */ $data_templates = db_fetch_assoc_prepared('SELECT data_template.name AS data_template_name, data_template_rrd.data_source_name, data_template_data.* FROM (data_template, data_template_rrd, data_template_data, graph_templates_item) WHERE graph_templates_item.task_item_id = data_template_rrd.id AND data_template_rrd.data_template_id = data_template.id AND data_template_data.data_template_id = data_template.id AND data_template_rrd.local_data_id = 0 AND data_template_data.local_data_id = 0 AND graph_templates_item.local_graph_id = 0 AND graph_templates_item.graph_template_id = ? GROUP BY data_template.id ORDER BY data_template.name', array($graph_template_id)); $graph_template = db_fetch_row_prepared('SELECT graph_templates.name AS graph_template_name, graph_templates_graph.* FROM (graph_templates, graph_templates_graph) WHERE graph_templates.id = graph_templates_graph.graph_template_id AND graph_templates.id = ? AND graph_templates_graph.local_graph_id = 0', array($graph_template_id)); $graph_template_name = db_fetch_cell_prepared('SELECT name FROM graph_templates WHERE id = ?', array($graph_template_id)); array_push($num_output_fields, draw_nontemplated_fields_graph($graph_template_id, $graph_template, "g_{$snmp_query_id}" . '_' . $graph_template_id . '_|field|', '<strong>Graph</strong> [Template: ' . $graph_template['graph_template_name'] . ']', false, false, isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0)); array_push($num_output_fields, draw_nontemplated_fields_graph_item($graph_template_id, 0, 'gi_' . $snmp_query_id . '_' . $graph_template_id . '_|id|_|field|', '<strong>Graph Items</strong> [Template: ' . $graph_template_name . ']', false)); /* DRAW: Data Sources */ if (sizeof($data_templates) > 0) { foreach ($data_templates as $data_template) { array_push($num_output_fields, draw_nontemplated_fields_data_source($data_template['data_template_id'], 0, $data_template, 'd_' . $snmp_query_id . '_' . $graph_template_id . '_' . $data_template['data_template_id'] . '_|field|', '<strong>Data Source</strong> [Template: ' . $data_template['data_template_name'] . ']', false, false, isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0)); $data_template_items = db_fetch_assoc_prepared('SELECT data_template_rrd.* FROM data_template_rrd WHERE data_template_rrd.data_template_id = ? AND local_data_id = 0', array($data_template['data_template_id'])); array_push($num_output_fields, draw_nontemplated_fields_data_source_item($data_template['data_template_id'], $data_template_items, 'di_' . $snmp_query_id . '_' . $graph_template_id . '_' . $data_template['data_template_id'] . '_|id|_|field|', '', false, false, false, isset($snmp_query_graph_id) ? $snmp_query_graph_id : 0)); array_push($num_output_fields, draw_nontemplated_fields_custom_data($data_template['id'], 'c_' . $snmp_query_id . '_' . $graph_template_id . '_' . $data_template['data_template_id'] . '_|id|', '<strong>Custom Data</strong> [Template: ' . $data_template['data_template_name'] . ']', false, false, $snmp_query_id)); } } html_end_box(); } } /* no fields were actually drawn on the form; just save without prompting the user */ if (array_sum($num_output_fields) == 0) { ob_end_clean(); /* since the user didn't actually click "Create" to POST the data; we have to pretend like they did here */ $_POST['host_template_id'] = $host_template_id; $_POST['host_id'] = $host_id; $_POST['save_component_new_graphs'] = '1'; $_POST['selected_graphs_array'] = serialize($selected_graphs_array); host_new_graphs_save(); header('Location: graphs_new.php?host_id=' . $_POST['host_id']); exit; } /* flush the current output buffer to the browser */ ob_end_flush(); form_hidden_box('host_template_id', $host_template_id, '0'); form_hidden_box('host_id', $host_id, '0'); form_hidden_box('save_component_new_graphs', '1', ''); print "<input type='hidden' name='selected_graphs_array' value='" . serialize($selected_graphs_array) . "'>\n"; if (!substr_count($_SERVER['HTTP_REFERER'], 'graphs_new')) { $_REQUEST['returnto'] = basename($_SERVER['HTTP_REFERER']); } load_current_session_value('returnto', 'sess_graphs_new_returnto', ''); form_save_button($_REQUEST['returnto']); bottom_footer(); }
function form_actions() { global $group_actions, $user_auth_realms; /* if we are to save this form, instead of display it */ if (isset($_POST['associate_host'])) { while (list($var, $val) = each($_POST)) { if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ if (get_request_var_post('drp_action') == '1') { db_execute_prepared('REPLACE INTO user_auth_group_perms (group_id, item_id, type) VALUES (?, ?, 3)', array(get_request_var_post('id'), $matches[1])); } else { db_execute_prepared('DELETE FROM user_auth_group_perms WHERE group_id = ? AND item_id = ? AND type = 3', array(get_request_var_post('id'), $matches[1])); } } } header('Location: user_group_admin.php?action=edit&tab=permsd&id=' . get_request_var_post('id')); exit; } elseif (isset($_POST['associate_graph'])) { while (list($var, $val) = each($_POST)) { if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ if (get_request_var_post('drp_action') == '1') { db_execute_prepared('REPLACE INTO user_auth_group_perms (group_id, item_id, type) VALUES (?, ?, 1)', array(get_request_var_post('id'), $matches[1])); } else { db_execute_prepared('DELETE FROM user_auth_group_perms WHERE group_id = ? AND item_id = ? AND type = 1', array(get_request_var_post('id'), $matches[1])); } } } header('Location: user_group_admin.php?action=edit&tab=permsg&id=' . get_request_var_post('id')); exit; } elseif (isset($_POST['associate_template'])) { while (list($var, $val) = each($_POST)) { if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ if (get_request_var_post('drp_action') == '1') { db_execute_prepared('REPLACE INTO user_auth_group_perms (group_id, item_id, type) VALUES (?, ?, 4)', array(get_request_var_post('id'), $matches[1])); } else { db_execute_prepared('DELETE FROM user_auth_group_perms WHERE group_id = ? AND item_id = ? AND type = 4', array(get_request_var_post('id'), $matches[1])); } } } header('Location: user_group_admin.php?action=edit&tab=permste&id=' . get_request_var_post('id')); exit; } elseif (isset($_POST['associate_tree'])) { while (list($var, $val) = each($_POST)) { if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ if (get_request_var_post('drp_action') == '1') { db_execute_prepared('REPLACE INTO user_auth_group_perms (group_id, item_id, type) VALUES (?, ?, 2)', array(get_request_var_post('id'), $matches[1])); } else { db_execute_prepared('DELETE FROM user_auth_group_perms WHERE group_id = ? AND item_id = ? AND type = 2', array(get_request_var_post('id'), $matches[1])); } } } header('Location: user_group_admin.php?action=edit&tab=permstr&id=' . get_request_var_post('id')); exit; } elseif (isset($_POST['associate_member'])) { while (list($var, $val) = each($_POST)) { if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ if (get_request_var_post('drp_action') == '1') { db_execute_prepared('REPLACE INTO user_auth_group_members (group_id, user_id) VALUES (?, ?)', array(get_request_var_post('id'), $matches[1])); } else { db_execute_prepared('DELETE FROM user_auth_group_members WHERE group_id = ? AND user_id = ?', array(get_request_var_post('id'), $matches[1])); } } } header('Location: user_group_admin.php?action=edit&tab=members&id=' . get_request_var_post('id')); exit; } elseif (isset($_POST['selected_items'])) { if (get_request_var_post('drp_action') != '2') { $selected_items = unserialize(stripslashes(get_request_var_post('selected_items'))); } if (get_request_var_post('drp_action') == '1') { /* delete */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ user_group_remove($selected_items[$i]); } } if (get_request_var_post('drp_action') == '3') { /* enable */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ user_group_enable($selected_items[$i]); } } if (get_request_var_post('drp_action') == '4') { /* disable */ for ($i = 0; $i < count($selected_items); $i++) { /* ================= input validation ================= */ input_validate_input_number($selected_items[$i]); /* ==================================================== */ user_group_disable($selected_items[$i]); } } header('Location: user_group_admin.php'); exit; } /* loop through each of the users and process them */ $group_list = ''; $group_array = array(); $i = 0; while (list($var, $val) = each($_POST)) { if (ereg('^chk_([0-9]+)$', $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ if (get_request_var_post('drp_action') != '2') { $group_list .= '<li>' . db_fetch_cell_prepared('SELECT name FROM user_auth_group WHERE id = ?', array($matches[1])) . '</li>'; } $group_array[$i] = $matches[1]; $i++; } } top_header(); html_start_box('<strong>' . $group_actions[get_request_var_post('drp_action')] . '</strong>', '60%', '', '3', 'center', ''); print "<form action='user_group_admin.php' method='post'>\n"; if (isset($group_array) && sizeof($group_array)) { if (get_request_var_post('drp_action') == '1' && sizeof($group_array)) { /* delete */ print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the selected User Group(s) will be deleted.</p>\n\t\t\t\t\t\t<p><ul>{$group_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Delete User Group(s)'>"; } $group_id = ''; if (get_request_var_post('drp_action') == '3' && sizeof($group_array)) { /* enable */ print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\" the selected User Group(s) will be enabled.</p>\n\t\t\t\t\t\t<p><ul>{$group_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Enable User Group(s)'>"; } if (get_request_var_post('drp_action') == '4' && sizeof($group_array)) { /* disable */ print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\" the selected User Group(s) will be disabled.</p>\n\t\t\t\t\t\t<p><ul>{$group_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n"; $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'> <input type='submit' value='Continue' title='Disable User Group(s)'>"; } } else { print "<tr><td class='even'><span class='textError'>You must select at least one Group.</span></td></tr>\n"; $save_html = "<input type='button' value='Return' onClick='window.history.back()'>"; } print " <tr>\n\t\t\t<td align='right' class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>"; if (get_request_var_post('drp_action') == '2') { /* copy */ print "\t\t\t\t<input type='hidden' name='selected_items' value='" . $group_id . "'>\n"; } else { print "\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($group_array) ? serialize($group_array) : '') . "'>\n"; } print "\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var_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(); }