function import() { global $colors, $hash_type_names; ?> <form method="post" action="templates_import.php" enctype="multipart/form-data"> <?php if (isset($_SESSION["import_debug_info"]) && is_array($_SESSION["import_debug_info"])) { html_start_box("<strong>Import Results</strong>", "100%", "aaaaaa", "3", "center", ""); print "<tr bgcolor='#" . $colors["form_alternate1"] . "'><td><p class='textArea'>Cacti has imported the following items:</p>"; while (list($type, $type_array) = each($_SESSION["import_debug_info"])) { print "<p><strong>" . $hash_type_names[$type] . "</strong></p>"; while (list($index, $vals) = each($type_array)) { if ($vals["result"] == "success") { $result_text = "<span style='color: green;'>[success]</span>"; } else { $result_text = "<span style='color: red;'>[fail]</span>"; } if ($vals["type"] == "update") { $type_text = "<span style='color: gray;'>[update]</span>"; } else { $type_text = "<span style='color: blue;'>[new]</span>"; } print "<span style='font-family: monospace;'>{$result_text} " . $vals["title"] . " {$type_text}</span><br>\n"; $dep_text = ""; $there_are_dep_errors = false; if (isset($vals["dep"]) && sizeof($vals["dep"]) > 0) { while (list($dep_hash, $dep_status) = each($vals["dep"])) { if ($dep_status == "met") { $dep_status_text = "<span style='color: navy;'>Found Dependency:</span>"; } else { $dep_status_text = "<span style='color: red;'>Unmet Dependency:</span>"; $there_are_dep_errors = true; } $dep_text .= "<span style='font-family: monospace;'> + {$dep_status_text} " . hash_to_friendly_name($dep_hash, true) . "</span><br>\n"; } } /* only print out dependency details if they contain errors; otherwise it would get too long */ if ($there_are_dep_errors == true) { print $dep_text; } } } print "</td></tr>"; html_end_box(); kill_session_var("import_debug_info"); } html_start_box("<strong>Import Templates</strong>", "100%", $colors["header"], "3", "center", ""); form_alternate_row_color($colors["form_alternate1"], $colors["form_alternate2"], 0); ?> <td width="50%"> <font class="textEditTitle">Import Template from Local File</font><br> If the XML file containing template data is located on your local machine, select it here. </td> <td> <input type="file" name="import_file"> </td> </tr> <?php form_alternate_row_color($colors["form_alternate1"], $colors["form_alternate2"], 1); ?> <td width="50%"> <font class="textEditTitle">Import Template from Text</font><br> If you have the XML file containing template data as text, you can paste it into this box to import it. </td> <td> <?php form_text_area("import_text", "", "10\t", "50", ""); ?> </td> </tr> <?php form_alternate_row_color($colors["form_alternate1"], $colors["form_alternate2"], 0); ?> <td width="50%"> <font class="textEditTitle">Import RRA Settings</font><br> Choose whether to allow Cacti to import custom RRA settings from imported templates or whether to use the defaults for this installation. </td> <td> <?php form_radio_button("import_rra", 1, 1, "Use defaults for this installation (Recommended)", 1); echo "<br />"; form_radio_button("import_rra", 1, 2, "Use custom RRA settings from the template", 1); ?> </td> </tr> <?php form_hidden_box("save_component_import", "1", ""); html_end_box(); form_save_button("templates_import.php", "save"); }
function draw_edit_control($field_name, &$field_array) { switch ($field_array["method"]) { case 'textbox': form_text_box($field_name, $field_array["value"], isset($field_array["default"]) ? $field_array["default"] : "", $field_array["max_length"], isset($field_array["size"]) ? $field_array["size"] : "40", "text", isset($field_array["form_id"]) ? $field_array["form_id"] : ""); break; case 'filepath': form_filepath_box($field_name, $field_array["value"], isset($field_array["default"]) ? $field_array["default"] : "", $field_array["max_length"], isset($field_array["size"]) ? $field_array["size"] : "40", "text", isset($field_array["form_id"]) ? $field_array["form_id"] : ""); break; case 'dirpath': form_dirpath_box($field_name, $field_array["value"], isset($field_array["default"]) ? $field_array["default"] : "", $field_array["max_length"], isset($field_array["size"]) ? $field_array["size"] : "40", "text", isset($field_array["form_id"]) ? $field_array["form_id"] : ""); break; case 'textbox_password': form_text_box($field_name, $field_array["value"], isset($field_array["default"]) ? $field_array["default"] : "", $field_array["max_length"], isset($field_array["size"]) ? $field_array["size"] : "40", "password"); print "<br>"; form_text_box($field_name . "_confirm", $field_array["value"], isset($field_array["default"]) ? $field_array["default"] : "", $field_array["max_length"], isset($field_array["size"]) ? $field_array["size"] : "40", "password"); break; case 'textarea': form_text_area($field_name, $field_array["value"], $field_array["textarea_rows"], $field_array["textarea_cols"], isset($field_array["default"]) ? $field_array["default"] : "", isset($field_array["class"]) ? $field_array["class"] : "", isset($field_array["on_change"]) ? $field_array["on_change"] : ""); break; case 'drop_array': form_dropdown($field_name, $field_array["array"], "", "", $field_array["value"], isset($field_array["none_value"]) ? $field_array["none_value"] : "", isset($field_array["default"]) ? $field_array["default"] : "", isset($field_array["class"]) ? $field_array["class"] : "", isset($field_array["on_change"]) ? $field_array["on_change"] : ""); break; case 'drop_sql': form_dropdown($field_name, db_fetch_assoc($field_array["sql"]), "name", "id", $field_array["value"], isset($field_array["none_value"]) ? $field_array["none_value"] : "", isset($field_array["default"]) ? $field_array["default"] : "", isset($field_array["class"]) ? $field_array["class"] : "", isset($field_array["on_change"]) ? $field_array["on_change"] : ""); break; case 'drop_multi': form_multi_dropdown($field_name, $field_array["array"], db_fetch_assoc($field_array["sql"]), "id", isset($field_array["class"]) ? $field_array["class"] : "", isset($field_array["on_change"]) ? $field_array["on_change"] : ""); break; case 'drop_multi_rra': form_multi_dropdown($field_name, array_rekey(db_fetch_assoc("select id,name from rra order by timespan"), "id", "name"), empty($field_array["form_id"]) ? db_fetch_assoc($field_array["sql_all"]) : db_fetch_assoc($field_array["sql"]), "id", isset($field_array["class"]) ? $field_array["class"] : "", isset($field_array["on_change"]) ? $field_array["on_change"] : ""); break; case 'drop_tree': grow_dropdown_tree($field_array["tree_id"], $field_name, $field_array["value"]); break; case 'drop_color': form_color_dropdown($field_name, $field_array["value"], "None", isset($field_array["default"]) ? $field_array["default"] : "", isset($field_array["class"]) ? $field_array["class"] : "", isset($field_array["on_change"]) ? $field_array["on_change"] : ""); break; case 'checkbox': form_checkbox($field_name, $field_array["value"], $field_array["friendly_name"], isset($field_array["default"]) ? $field_array["default"] : "", isset($field_array["form_id"]) ? $field_array["form_id"] : "", isset($field_array["class"]) ? $field_array["class"] : "", isset($field_array["on_change"]) ? $field_array["on_change"] : ""); break; case 'checkbox_group': while (list($check_name, $check_array) = each($field_array["items"])) { form_checkbox($check_name, $check_array["value"], $check_array["friendly_name"], isset($check_array["default"]) ? $check_array["default"] : "", isset($check_array["form_id"]) ? $check_array["form_id"] : "", isset($field_array["class"]) ? $field_array["class"] : "", isset($check_array["on_change"]) ? $check_array["on_change"] : (isset($field_array["on_change"]) ? $field_array["on_change"] : "")); print "<br>"; } break; case 'radio': while (list($radio_index, $radio_array) = each($field_array["items"])) { form_radio_button($field_name, $field_array["value"], $radio_array["radio_value"], $radio_array["radio_caption"], isset($field_array["default"]) ? $field_array["default"] : "", isset($field_array["class"]) ? $field_array["class"] : "", isset($field_array["on_change"]) ? $field_array["on_change"] : ""); print "<br>"; } break; case 'custom': print $field_array["value"]; break; case 'template_checkbox': print "<em>" . html_boolean_friendly($field_array["value"]) . "</em>"; form_hidden_box($field_name, $field_array["value"], ""); break; case 'template_drop_array': print "<em>" . $field_array["array"][$field_array["value"]] . "</em>"; form_hidden_box($field_name, $field_array["value"], ""); break; case 'template_drop_multi_rra': $items = db_fetch_assoc($field_array["sql_print"]); if (sizeof($items) > 0) { foreach ($items as $item) { print htmlspecialchars($item["name"], ENT_QUOTES) . "<br>"; } } break; case 'font': form_font_box($field_name, $field_array["value"], isset($field_array["default"]) ? $field_array["default"] : "", $field_array["max_length"], isset($field_array["size"]) ? $field_array["size"] : "40", "text", isset($field_array["form_id"]) ? $field_array["form_id"] : ""); break; case 'file': form_file($field_name, isset($field_array["size"]) ? $field_array["size"] : "40"); break; default: print "<em>" . htmlspecialchars($field_array["value"], ENT_QUOTES) . "</em>"; form_hidden_box($field_name, $field_array["value"], ""); break; } }
function import() { global $colors, $hash_type_names; ?> <form action="templates_import.php" method="post" enctype="multipart/form-data"> <?php if ((isset($_SESSION["import_debug_info"])) && (is_array($_SESSION["import_debug_info"]))) { html_start_box("<strong>" . __("Import Results") . "</strong>", "100", "aaaaaa", "3", "center", "", true); print "<tr class='rowAlternate1'><td><p class='textArea'>" . __("Cacti has imported the following items:") . "</p>"; while (list($type, $type_array) = each($_SESSION["import_debug_info"])) { print "<p><strong>" . $hash_type_names[$type] . "</strong></p>"; while (list($index, $vals) = each($type_array)) { if ($vals["result"] == "success") { $result_text = "<span class=\"success\">" . __("[success]") . "</span>"; }else{ $result_text = "<span class=\"fail\">" . __("[fail]") . "</span>"; } if ($vals["type"] == "update") { $type_text = "<span class=\"unknown\">" . __("[update]") . "</span>"; }else{ $type_text = "<span class=\"new\">" . __("[new]") . "</span>"; } print "<span class=\"log\">$result_text " . $vals["title"] . " $type_text</span><br>\n"; $dep_text = ""; $there_are_dep_errors = false; if ((isset($vals["dep"])) && (sizeof($vals["dep"]) > 0)) { while (list($dep_hash, $dep_status) = each($vals["dep"])) { if ($dep_status == "met") { $dep_status_text = "<span class=\"dependant\">" . __("Found Dependency:") . "</span>"; }else{ $dep_status_text = "<span class=\"fail\">" . __("Unmet Dependency:") . "</span>"; $there_are_dep_errors = true; } $dep_text .= "<span class=\"log\"> + $dep_status_text " . hash_to_friendly_name($dep_hash, true) . "</span><br>\n"; } } /* only print out dependency details if they contain errors; otherwise it would get too long */ if ($there_are_dep_errors == true) { print $dep_text; } } } print "</td></tr>"; html_end_box(false); kill_session_var("import_debug_info"); } html_start_box("<strong>" . __("Import Templates") . "</strong>", "100", $colors["header"], "3", "center", ""); form_alternate_row_color("file"); ?> <td width="50%"> <font class="textEditTitle"><?php print __("Import Template from Local File");?></font><br> <?php print __("If the XML file containing template data is located on your local machine, select it here.");?> </td> <td> <input type="file" size="60" name="import_file"> </td> </tr> <?php form_alternate_row_color("text"); ?> <td width="50%"> <font class="textEditTitle"><?php print __("Import Template from Text");?></font><br> <?php print __("If you have the XML file containing template data as text, you can paste it into this box to import it.");?> </td> <td style="padding-right:10px;"> <?php form_text_area("import_text", "", "10 ", "60", "");?> </td> </tr> <?php form_alternate_row_color("rra"); ?> <td width="50%"> <font class="textEditTitle"><?php print __("Import RRA Settings");?></font><br> <?php print __("Choose whether to allow Cacti to import custom RRA settings from imported templates or whether to use the defaults for this installation.");?> </td> <td> <?php form_radio_button("import_rra", 1, 1, __("Use defaults for this installation (Recommended)"), 1); echo "<br>"; form_radio_button("import_rra", 1, 2, __("Use custom RRA settings from the template"), 1); ?> </td> </tr> <?php html_end_box(); form_hidden_box("save_component_import","1",""); form_save_button_alt("", "save", "import"); }
function _package_import_field__text($field_name, $field_value = "") { require_once(CACTI_BASE_PATH . "/lib/sys/html_form.php"); ?> <tr class="<?php echo field_get_row_style();?>"> <td width="50%" class="field-row"> <span class="textEditTitle"><?php echo _("Import Package from File");?></span><br> <?php echo _("Browse to the package XML file to import it into Cacti");?> </td> <td class="field-row" colspan="2"> <?php form_text_area($field_name, $field_value, "10", "50", "");?> </td> </tr> <?php }
function draw_edit_control($field_name, &$field_array) { require_once(CACTI_BASE_PATH . "/lib/sys/html_tree.php"); switch ($field_array["method"]) { case 'textbox': form_text_box($field_name, $field_array["value"], ((isset($field_array["default"])) ? $field_array["default"] : ""), $field_array["max_length"], ((isset($field_array["size"])) ? $field_array["size"] : "40"), "text", ((isset($field_array["form_id"])) ? $field_array["form_id"] : "")); break; case 'textbox_password': form_text_box($field_name, $field_array["value"], ((isset($field_array["default"])) ? $field_array["default"] : ""), $field_array["max_length"], ((isset($field_array["size"])) ? $field_array["size"] : "40"), "password"); print "<br>"; form_text_box($field_name . "_confirm", $field_array["value"], ((isset($field_array["default"])) ? $field_array["default"] : ""), $field_array["max_length"], ((isset($field_array["size"])) ? $field_array["size"] : "40"), "password"); break; case 'textbox_password_single': form_text_box($field_name, $field_array["value"], ((isset($field_array["default"])) ? $field_array["default"] : ""), $field_array["max_length"], ((isset($field_array["size"])) ? $field_array["size"] : "40"), "password"); print "<br>"; break; case 'textbox_sv': form_text_box_sv($field_name, $field_array["value"], $field_array["url_moveup"], $field_array["url_movedown"], $field_array["url_delete"], $field_array["url_add"], ((isset($field_array["force_blank_field"])) ? $field_array["force_blank_field"] : false), ((isset($field_array["max_length"])) ? $field_array["max_length"] : "255"), ((isset($field_array["size"])) ? $field_array["size"] : "40")); print "<input type='hidden' name='cacti_js_dropdown_redirect_x' value='' id='cacti_js_dropdown_redirect_x'>\n"; break; case 'textarea': form_text_area($field_name, $field_array["value"], $field_array["textarea_rows"], $field_array["textarea_cols"], ((isset($field_array["default"])) ? $field_array["default"] : "")); break; case 'drop_array': form_dropdown($field_name, $field_array["array"], "", "", $field_array["value"], ((isset($field_array["none_value"])) ? $field_array["none_value"] : ""), ((isset($field_array["default"])) ? $field_array["default"] : ""), "", ((isset($field_array["trim_length"])) ? $field_array["trim_length"] : "0"), ((isset($field_array["js_onchange"])) ? $field_array["js_onchange"] : "")); break; case 'drop_array_js': form_dropdown($field_name, $field_array["array"], "", "", $field_array["value"], ((isset($field_array["none_value"])) ? $field_array["none_value"] : ""), ((isset($field_array["default"])) ? $field_array["default"] : ""), "", ((isset($field_array["trim_length"])) ? $field_array["trim_length"] : "0"), "submit_redirect(\"" . $field_array["form_index"] . "\", \"" . htmlspecialchars($field_array["redirect_url"]) . "\", document.forms[" . $field_array["form_index"] . "].$field_name.options[document.forms[" . $field_array["form_index"] . "].$field_name.selectedIndex].value)"); print "<input type='hidden' name='cacti_js_dropdown_redirect_x' value='' id='cacti_js_dropdown_redirect_x'>\n"; break; case 'drop_sql': form_dropdown($field_name, db_fetch_assoc($field_array["sql"]), "name", "id", $field_array["value"], ((isset($field_array["none_value"])) ? $field_array["none_value"] : ""), ((isset($field_array["default"])) ? $field_array["default"] : ""), "", ((isset($field_array["trim_length"])) ? $field_array["trim_length"] : "0"), ((isset($field_array["js_onchange"])) ? $field_array["js_onchange"] : "")); break; case 'drop_multi': form_multi_dropdown($field_name, $field_array["array"], db_fetch_assoc($field_array["sql"]), "id"); break; case 'drop_multi_rra': form_multi_dropdown($field_name, array_rekey(db_fetch_assoc("select id,name from rra order by timespan"), "id", "name"), (empty($field_array["form_id"]) ? db_fetch_assoc($field_array["sql_all"]) : db_fetch_assoc($field_array["sql"])), "id"); break; case 'drop_tree': grow_dropdown_tree($field_array["tree_id"], $field_name, $field_array["value"]); break; case 'drop_color': form_color_dropdown($field_name, $field_array["array"], $field_array["value"], ((isset($field_array["none_value"])) ? $field_array["none_value"] : ""), ((isset($field_array["default"])) ? $field_array["default"] : ""), ((isset($field_array["js_onchange"])) ? $field_array["js_onchange"] : "")); break; case 'checkbox': form_checkbox($field_name, $field_array["value"], $field_array["friendly_name"], ((isset($field_array["default"])) ? $field_array["default"] : ""), ((isset($field_array["form_id"])) ? $field_array["form_id"] : ""), ((isset($field_array["js_onclick"])) ? $field_array["js_onclick"] : "")); break; case 'checkbox_group': while (list($check_name, $check_array) = each($field_array["items"])) { form_checkbox($check_name, $check_array["value"], $check_array["friendly_name"], ((isset($check_array["default"])) ? $check_array["default"] : ""), ((isset($check_array["form_id"])) ? $check_array["form_id"] : "")); print "<br>"; } break; case 'radio': while (list($radio_index, $radio_array) = each($field_array["items"])) { form_radio_button($field_name, $field_array["value"], $radio_array["radio_value"], $radio_array["radio_caption"], ((isset($field_array["default"])) ? $field_array["default"] : "")); print "<br>"; } break; case 'custom': print $field_array["value"]; break; case 'template_checkbox': print "<em>" . html_boolean_friendly($field_array["value"]) . "</em>"; form_hidden_box($field_name, $field_array["value"], ""); break; case 'template_drop_array': print "<em>" . $field_array["array"]{$field_array["value"]} . "</em>"; form_hidden_box($field_name, $field_array["value"], ""); break; case 'template_drop_multi_rra': $items = db_fetch_assoc($field_array["sql_print"]); if (sizeof($items) > 0) { foreach ($items as $item) { print $item["name"] . "<br>"; } } break; default: print "<em>" . $field_array["value"] . "</em>"; form_hidden_box($field_name, $field_array["value"], ""); break; } }