function form_actions() { global $colors, $host_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 */ 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 (ereg("^chk_([0-9]+)$", $var, $matches)) { /* ================= input validation ================= */ input_validate_input_number($matches[1]); /* ==================================================== */ $host_list .= "<li>" . db_fetch_cell("select name from host_template where id=" . $matches[1]) . "<br>"; $host_array[$i] = $matches[1]; } $i++; } include_once("./include/top_header.php"); html_start_box("<strong>" . $host_actions{$_POST["drp_action"]} . "</strong>", "60%", $colors["header_panel"], "3", "center", ""); print "<form action='host_templates.php' method='post'>\n"; if ($_POST["drp_action"] == "1") { /* delete */ print " <tr> <td class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'> <p>Are you sure you want to delete the following host templates? All devices currently attached this these host templates will lose their template assocation.</p> <p>$host_list</p> </td> </tr>\n "; }elseif ($_POST["drp_action"] == "2") { /* duplicate */ print " <tr> <td class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'> <p>When you click save, the following host templates will be duplicated. You can optionally change the title format for the new host templates.</p> <p>$host_list</p> <p><strong>Title Format:</strong><br>"; form_text_box("title_format", "<template_title> (1)", "", "255", "30", "text"); print "</p> </td> </tr>\n "; } if (!isset($host_array)) { print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one host template.</span></td></tr>\n"; $save_html = ""; }else{ $save_html = "<input type='image' src='images/button_yes.gif' alt='Save' align='absmiddle'>"; } print " <tr> <td align='right' bgcolor='#eaeaea'> <input type='hidden' name='action' value='actions'> <input type='hidden' name='selected_items' value='" . (isset($host_array) ? serialize($host_array) : '') . "'> <input type='hidden' name='drp_action' value='" . $_POST["drp_action"] . "'> <a href='host_templates.php'><img src='images/button_no.gif' alt='Cancel' align='absmiddle' border='0'></a> $save_html </td> </tr> "; html_end_box(); include_once("./include/bottom_footer.php"); }
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 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 = sanitize_unserialize_selected_items($_POST['selected_items']); if ($selected_items != false) { 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++) { 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("select name from host_template where id=" . $matches[1])) . "</li>"; $host_array[$i] = $matches[1]; $i++; } } include_once "./include/top_header.php"; 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 Host Template(s)? All Devices currently associated\n\t\t\t\t\t\twith these Host 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 Host 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 Host Template(s) will be duplicated. You can\n\t\t\t\t\t\toptionally change the title format for the new Host 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 Host 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(); include_once "./include/bottom_footer.php"; }