function ds_edit() { global $colors, $struct_data_source, $struct_data_source_item, $data_source_types; /* ================= input validation ================= */ input_validate_input_number(get_request_var("id")); /* ==================================================== */ $use_data_template = true; $host_id = 0; if (!empty($_GET["id"])) { $data_local = db_fetch_row("select host_id,data_template_id from data_local where id='" . $_GET["id"] . "'"); $data = db_fetch_row("select * from data_template_data where local_data_id='" . $_GET["id"] . "'"); if (isset($data_local["data_template_id"]) && $data_local["data_template_id"] >= 0) { $data_template = db_fetch_row("select id,name from data_template where id='" . $data_local["data_template_id"] . "'"); $data_template_data = db_fetch_row("select * from data_template_data where data_template_id='" . $data_local["data_template_id"] . "' and local_data_id=0"); } else { $_SESSION["sess_messages"] = 'Data Source "' . $_GET["id"] . '" does not exist.'; header("Location: data_sources.php"); exit; } $header_label = "[edit: " . get_data_source_title($_GET["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($_GET["debug"])) { if ($_GET["debug"] == "0") { kill_session_var("ds_debug_mode"); } elseif ($_GET["debug"] == "1") { $_SESSION["ds_debug_mode"] = true; } } include_once "./include/top_header.php"; if (!empty($_GET["id"])) { ?> <table width="100%" align="center"> <tr> <td class="textInfo" colspan="2" valign="top"> <?php print get_data_source_title($_GET["id"]); ?> </td> <td class="textInfo" align="right" valign="top"> <span style="color: #c16921;">*<a href='data_sources.php?action=ds_edit&id=<?php print isset($_GET["id"]) ? $_GET["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> </td> </tr> </table> <br> <?php } html_start_box("<strong>Data Template Selection</strong> {$header_label}", "100%", $colors["header"], "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" => "Host", "description" => "Choose the host that this graph belongs to.", "value" => isset($_GET["host_id"]) ? $_GET["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($_GET["host_id"]) ? $_GET["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("select * from data_template_rrd where local_data_id=" . $_GET["id"] . " order by data_source_name"); html_start_box("<strong>Supplemental Data Template Data</strong>", "100%", $colors["header"], "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($_GET["id"]) || isset($_GET["new"])) && empty($data["data_template_id"])) { html_start_box("<strong>Data Source</strong>", "100%", $colors["header"], "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($_GET["id"])) { $template_data_rrds = db_fetch_assoc("select id,data_source_name from data_template_rrd where local_data_id=" . $_GET["id"] . " order by data_source_name"); } /* select the first "rrd" of this data source by default */ if (empty($_GET["view_rrd"])) { $_GET["view_rrd"] = isset($template_data_rrds[0]["id"]) ? $template_data_rrds[0]["id"] : "0"; } /* get more information about the rrd we chose */ if (!empty($_GET["view_rrd"])) { $local_data_template_rrd_id = db_fetch_cell("select local_data_template_rrd_id from data_template_rrd where id=" . $_GET["view_rrd"]); $rrd = db_fetch_row("select * from data_template_rrd where id=" . $_GET["view_rrd"]); $rrd_template = db_fetch_row("select * from data_template_rrd where id={$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"] == $_GET["view_rrd"] ? "bgcolor='silver'" : "bgcolor='#DFDFDF'") . " nowrap='nowrap' 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='data_sources.php?action=ds_edit&id=" . $_GET["id"] . "&view_rrd=" . $template_data_rrd["id"] . "'>{$i}: " . $template_data_rrd["data_source_name"] . "</a>" . ($use_data_template == false ? " <a href='data_sources.php?action=rrd_remove&id=" . $template_data_rrd["id"] . "&local_data_id=" . $_GET["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) { $_GET["view_rrd"] = $template_data_rrds[0]["id"]; } } html_start_box("", "100%", $colors["header"], "3", "center", ""); print "\t<tr>\n\t\t\t\t<td bgcolor='#" . $colors["header"] . "' 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' bgcolor='" . $colors["header"] . "'>\n\t\t\t\t\t" . (!empty($_GET["id"]) && empty($data_template["id"]) ? "<strong><a class='linkOverDark' href='data_sources.php?action=rrd_add&id=" . $_GET["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("select type_id from data_input where id=" . $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", $_GET["view_rrd"], "0"); } /* display the debug mode box if the user wants it */ if (isset($_SESSION["ds_debug_mode"]) && isset($_GET["id"])) { ?> <table width="100%" align="center"> <tr> <td> <span class="textInfo">Data Source Debug</span><br> <pre><?php print rrdtool_function_create($_GET["id"], true, array()); ?> </pre> </td> </tr> </table> <?php } if (isset($_GET["id"]) || isset($_GET["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"); include_once "./include/bottom_footer.php"; }
break; case 'actions': form_actions(); break; case 'field_remove': field_remove(); header('Location: data_input.php?action=edit&id=' . $_REQUEST['data_input_id']); break; case 'field_edit': top_header(); field_edit(); bottom_footer(); break; case 'edit': top_header(); data_edit(); bottom_footer(); break; default: top_header(); data(); bottom_footer(); break; } /* -------------------------- The Save Function -------------------------- */ function form_save() { global $registered_cacti_names; if (isset($_POST['save_component_data_input'])) {
$action = ""; } if ($action == "add") { if (!empty($_POST)) { data_new($link, $_POST['name'], $_POST['value'], $_POST['discription'], $_POST['level']); header("Location: shop.php"); } include "../views/add_shop.php"; } else { if ($action == "edit") { if (!isset($_GET['id'])) { header("Location: shop.php"); } $id = (int) $_GET['id']; if (!empty($_POST) && $id > 0) { data_edit($link, $id, $_POST['name'], $_POST['value'], $_POST['discription'], $_POST['level']); header("Location: shop.php"); } $data = data_get($link, $id); include "../views/add_shop.php"; } else { if ($action == "delete") { $id = $_GET['id']; $data = data_delete($link, $id); header("Location: shop.php"); } else { $data = data_all($link); include "../moduls/data_admin.php"; } } }
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(); }
$action = ""; } if ($action == "add") { if (!empty($_POST)) { data_new($link, $_POST['min_wd'], $_POST['max_wd'], $_POST['critical_damage'], $_POST['special_dc'], $_POST['dodge_chance'], $_POST['min_swd'], $_POST['max_swd'], $_POST['critical_chance'], $_POST['health'], $_POST['armour']); header("Location: constant.php"); } include "../views/add_constant.php"; } else { if ($action == "edit") { if (!isset($_GET['id'])) { header("Location: constant.php"); } $id = (int) $_GET['id']; if (!empty($_POST) && $id > 0) { data_edit($link, $id, $_POST['min_wd'], $_POST['max_wd'], $_POST['critical_damage'], $_POST['special_dc'], $_POST['dodge_chance'], $_POST['min_swd'], $_POST['max_swd'], $_POST['critical_chance'], $_POST['health'], $_POST['armour']); header("Location: constant.php"); } $data = data_get($link, $id); include "../views/add_constant.php"; } else { if ($action == "delete") { $id = $_GET['id']; $data = data_delete($link, $id); header("Location: constant.php"); } else { $data = data_all($link); include "../moduls/data_c.php"; } } }
if ($action == "add") { if (!empty($_POST)) { $_POST['time'] = time(); data_new($link, $_POST['uid'], $_POST['name'], $_POST['time'], $_POST['level'], $_POST['expirience'], $_POST['energy'], $_POST['r_cash'], $_POST['v_cash']); header("Location: users.php"); } include "../views/add_user.php"; } else { if ($action == "edit") { if (!isset($_GET['id'])) { header("Location: users.php"); } $id = (int) $_GET['id']; if (!empty($_POST) && $id > 0) { $_POST['time'] = time(); data_edit($link, $id, $_POST['uid'], $_POST['name'], $_POST['time'], $_POST['level'], $_POST['expirience'], $_POST['energy'], $_POST['r_cash'], $_POST['v_cash']); header("Location: users.php"); } $data = data_get($link, $id); include "../views/add_user.php"; } else { if ($action == "delete") { $id = $_GET['id']; $data = data_delete($link, $id); header("Location: users.php"); } else { $data = data_all($link); include "../moduls/data_u.php"; } } }