Ejemplo n.º 1
0
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;'>&nbsp;&nbsp;&nbsp;+ {$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");
}
Ejemplo n.º 2
0
					}else{
						$type_text = " [new]";
					}
					echo "   $result_text " . $vals["title"] . " $type_text\n";

					$dep_text = ""; $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 = "Found Dependency: ";
							} else {
								$dep_status_text = "Unmet Dependency: ";
								$errors = true;
							}

							$dep_text .= "    + $dep_status_text " . hash_to_friendly_name($dep_hash, true) . "\n";
						}
					}

					/* dependency errors need to be reported */
					if ($errors) {
						echo $dep_text;
						exit(-1);
					}else{
						exit(0);
					}
				}
			}
		} else {
			echo "ERROR: file $filename is not readable, or does not exist\n\n";
			exit(1);
Ejemplo n.º 3
0
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\">&nbsp;&nbsp;&nbsp;+ $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");
}
Ejemplo n.º 4
0
function import()
{
    global $hash_type_names, $fields_template_import;
    ?>
	<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%', '', '3', 'center', '');
        print "<tr class='odd'><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} " . htmlspecialchars($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;'>&nbsp;&nbsp;&nbsp;+ {$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%', '', '3', 'center', '');
    draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $fields_template_import));
    html_end_box();
    form_hidden_box('save_component_import', '1', '');
    form_save_button('', 'import');
    ?>
<script language="JavaScript">

$(function() {
	changeRRA();
});

function changeRRA() {
	if ($('#import_rra_1').is(':checked')) {
		$('#row_rra_id').show();
	}else{
		$('#row_rra_id').hide();
	}
}

</script>
<?php 
}
Ejemplo n.º 5
0
function import()
{
    global $colors, $hash_type_names, $fields_template_import;
    ?>
	<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} " . htmlspecialchars($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;'>&nbsp;&nbsp;&nbsp;+ {$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", "");
    draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => $fields_template_import));
    html_end_box();
    form_hidden_box("save_component_import", "1", "");
    form_save_button("", "import");
    ?>
<script language="JavaScript">

changeRRA();

function changeRRA() {
	//alert("changed to '" + document.getElementById('import_rra_1').checked + "'");
	
	if ((document.getElementById('import_rra_1').checked == '1')) {
		document.getElementById('row_rra_id').style.display="";
	}else{
		document.getElementById('row_rra_id').style.display="none";
	}
}
</script>
<?php 
}