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") { include_once "./include/top_header.php"; print "<table width='100%' align='center'><tr><td><pre>" . htmlspecialchars($xml_data) . "</pre></td></tr></table>"; include_once "./include/bottom_footer.php"; } 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_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_save() { global $export_types; if (isset($_POST["save_component_export"])) { $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") { include_once "./include/top_header.php"; print "<table width='100%' align='center'><tr><td><pre>" . htmlspecialchars($xml_data) . "</pre></td></tr></table>"; include_once "./include/bottom_footer.php"; } elseif ($_POST["output_format"] == "2") { header("Content-type: application/xml"); print $xml_data; } elseif ($_POST["output_format"] == "3") { 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_save() { global $export_types; if (isset($_POST["save_component_export"])) { $xml_data = get_item_xml($_POST["export_type"], $_POST["export_item_id"], (((isset($_POST["include_deps"]) ? $_POST["include_deps"] : "") == "") ? false : true)); if (get_request_var_post("output_format") == "1") { include_once(CACTI_BASE_PATH . "/include/top_header.php"); print "<table class='wp100 center'><tr><td><pre>" . htmlspecialchars($xml_data) . "</pre></td></tr></table>"; include_once(CACTI_BASE_PATH . "/include/bottom_footer.php"); }elseif (get_request_var_post("output_format") == "2") { header("Content-type: application/xml"); print $xml_data; }elseif (get_request_var_post("output_format") == "3") { 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 generate_data_source_path($local_data_id) { global $config; $host_part = ""; $ds_part = ""; $extended_paths = read_config_option("extended_paths"); /* try any prepend the name with the host description */ $host = db_fetch_row("SELECT\n\t\thost.id,\n\t\thost.description\n\t\tFROM (host, data_local)\n\t\tWHERE data_local.host_id=host.id\n\t\tAND data_local.id={$local_data_id}\n\t\tLIMIT 1"); $host_name = $host["description"]; $host_id = $host["id"]; /* put it all together using the local_data_id at the end */ if ($extended_paths == "on") { $new_path = "<path_rra>/{$host_id}/{$local_data_id}.rrd"; } else { if (!empty($host_name)) { $host_part = strtolower(clean_up_file_name($host_name)) . "_"; } /* then try and use the internal DS name to identify it */ $data_source_rrd_name = db_fetch_cell("SELECT data_source_name\n\t\t\tFROM data_template_rrd\n\t\t\tWHERE local_data_id={$local_data_id}\n\t\t\tORDER BY id"); if (!empty($data_source_rrd_name)) { $ds_part = strtolower(clean_up_file_name($data_source_rrd_name)); } else { $ds_part = "ds"; } $new_path = "<path_rra>/{$host_part}{$ds_part}" . "_" . "{$local_data_id}.rrd"; } /* update our changes to the db */ db_execute("UPDATE data_template_data SET data_source_path='{$new_path}' WHERE local_data_id={$local_data_id}"); return $new_path; }
function generate_data_source_path($local_data_id) { global $config; $host_part = ''; $ds_part = ''; $extended_paths = read_config_option('extended_paths'); /* try any prepend the name with the host description */ $host = db_fetch_row_prepared('SELECT host.id, host.description FROM (host, data_local) WHERE data_local.host_id = host.id AND data_local.id = ? LIMIT 1', array($local_data_id)); $host_name = $host['description']; $host_id = $host['id']; /* put it all together using the local_data_id at the end */ if ($extended_paths == 'on') { $new_path = "<path_rra>/{$host_id}/{$local_data_id}.rrd"; } else { if (!empty($host_name)) { $host_part = strtolower(clean_up_file_name($host_name)) . '_'; } /* then try and use the internal DS name to identify it */ $data_source_rrd_name = db_fetch_cell_prepared('SELECT data_source_name FROM data_template_rrd WHERE local_data_id = ? ORDER BY id', array($local_data_id)); if (!empty($data_source_rrd_name)) { $ds_part = strtolower(clean_up_file_name($data_source_rrd_name)); } else { $ds_part = 'ds'; } $new_path = "<path_rra>/{$host_part}{$ds_part}" . '_' . "{$local_data_id}.rrd"; } /* update our changes to the db */ db_execute_prepared('UPDATE data_template_data SET data_source_path = ? WHERE local_data_id = ?', array($new_path, $local_data_id)); return $new_path; }
function generate_data_source_path($local_data_id) { $host_part = ""; $ds_part = ""; /* try any prepend the name with the host description */ $host_name = db_fetch_cell("select host.description from host, data_local where data_local.host_id=host.id and data_local.id=$local_data_id"); if (!empty($host_name)) { $host_part = strtolower(clean_up_file_name($host_name)) . "_"; } /* then try and use the internal DS name to identify it */ $data_source_rrd_name = db_fetch_cell("select data_source_name from data_template_rrd where local_data_id=$local_data_id order by id"); if (!empty($data_source_rrd_name)) { $ds_part = strtolower(clean_up_file_name($data_source_rrd_name)); }else{ $ds_part = "ds"; } /* put it all together using the local_data_id at the end */ $new_path = "<path_rra>/$host_part$ds_part" . "_" . "$local_data_id.rrd"; /* update our changes to the db */ db_execute("update data_template_data set data_source_path='$new_path' where local_data_id=$local_data_id"); return $new_path; }
function generate_data_source_path($local_data_id) { global $config; $device_part = ""; $ds_part = ""; $extended_paths = read_config_option("extended_paths"); /* try any prepend the name with the device description */ $device = db_fetch_row("SELECT device.id, device.description FROM (device, data_local) WHERE data_local.device_id=device.id AND data_local.id=$local_data_id LIMIT 1"); $device_name = $device["description"]; $device_id = $device["id"]; /* put it all together using the local_data_id at the end */ if ($extended_paths == CHECKED) { $new_path = "<path_rra>/$device_id/$local_data_id.rrd"; }else{ if (!empty($device_name)) { $device_part = strtolower(clean_up_file_name($device_name)) . "_"; } /* then try and use the internal DS name to identify it */ $data_source_rrd_name = db_fetch_cell("SELECT data_source_name FROM data_template_rrd WHERE local_data_id=$local_data_id ORDER BY id"); if (!empty($data_source_rrd_name)) { $ds_part = strtolower(clean_up_file_name($data_source_rrd_name)); }else{ $ds_part = "ds"; } $new_path = "<path_rra>/$device_part$ds_part" . "_" . "$local_data_id.rrd"; } /* update our changes to the db */ db_execute("UPDATE data_template_data SET data_source_path='$new_path' WHERE local_data_id=$local_data_id"); return $new_path; }