示例#1
0
function _package_field__create_type($field_name, $field_value = "", $field_id = 0) {
	require_once(CACTI_BASE_PATH . "/lib/sys/html_form.php");
	require_once(CACTI_BASE_PATH . "/lib/package/package_info.php");

	?>
	<tr class="<?php echo field_get_row_style();?>">
		<td width="50%" class="field-row">
			<span class="textEditTitle"><?php echo _("New Package Type");?></span><br>
			<?php echo _("How this package should be created.");?>
		</td>
		<td class="field-row" colspan="2">
			<table width="100%" cellspacing="0" cellpadding="2">
				<tr>
					<td width="1%">
						<?php form_radio_button($field_name, $field_value, "new", "", "new", "click_create_type_radio()");?>
					</td>
					<td>
						Create entirely new package
					</td>
				</tr>
				<tr>
					<td width="1%">
						<?php form_radio_button($field_name, $field_value, "existing", "", "new", "click_create_type_radio()");?>
					</td>
					<td>
						Create based on an existing package
					</td>
				</tr>
				<tr>
					<td>
					</td>
					<td>
						<?php form_dropdown($field_name . "_id", api_package_list(), "name", "id", "", "", "");?>
					</td>
				</tr>
			</table>
		</td>
	</tr>

	<script language="JavaScript">
	<!--
	function click_create_type_radio() {
		if (get_radio_value(document.forms[0].<?php echo $field_name;?>) == 'new') {
			select_radio_create_type_new();
		}else{
			select_radio_create_type_existing();
		}
	}

	function select_radio_create_type_new() {
		document.getElementById('<?php echo $field_name;?>_id').disabled = true;
	}

	function select_radio_create_type_existing() {
		document.getElementById('<?php echo $field_name;?>_id').disabled = false;
	}

	click_create_type_radio();
	-->
	</script>

	<?php
}
示例#2
0
function package() {
	$menu_items = array(
		"remove" => "Remove",
		"duplicate" => "Duplicate"
		);

	$filter_array = array();

	/* search field: filter (searches package name) */
	if (isset_get_var("search_filter")) {
		$filter_array["name"] = get_get_var("search_filter");
	}

	/* get a list of all packages on this page */
	$packages = api_package_list($filter_array);

	form_start("packages.php");

	$box_id = "1";
	html_start_box("<strong>" . _("Template Packages") . "</strong>", "packages.php?action=new");
	html_header_checkbox(array(_("Name"), _("Author"), _("Category")), $box_id);

	$i = 0;
	if (sizeof($packages) > 0) {
		foreach ($packages as $package) {
			?>
			<tr class="item" id="box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>" onClick="display_row_select('<?php echo $box_id;?>',document.forms[0],'box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>', 'box-<?php echo $box_id;?>-chk-<?php echo $package["id"];?>')" onMouseOver="display_row_hover('box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>')" onMouseOut="display_row_clear('box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>')">
				<td class="title">
					<a onClick="display_row_block('box-<?php echo $box_id;?>-row-<?php echo $package["id"];?>')" href="packages.php?action=view&id=<?php echo $package["id"];?>"><span id="box-<?php echo $box_id;?>-text-<?php echo $package["id"];?>"><?php echo html_highlight_words(get_get_var("search_filter"), $package["name"]);?></span></a>
				</td>
				<td>
					Ian Berry
				</td>
				<td>
					<?php echo $package["category"];?>
				</td>
				<td class="checkbox" align="center">
					<input type='checkbox' name='box-<?php echo $box_id;?>-chk-<?php echo $package["id"];?>' id='box-<?php echo $box_id;?>-chk-<?php echo $package["id"];?>' title="<?php echo $package["name"];?>">
				</td>
			</tr>
			<?php
		}
	}else{
		?>
		<tr class="empty">
			<td colspan="6">
				No template packages found.
			</td>
		</tr>
		<?php
	}
	html_box_toolbar_draw($box_id, "0", "3", HTML_BOX_SEARCH_NONE);
	html_end_box(false);

	//html_box_actions_menu_draw($box_id, "0", $menu_items);
	html_box_actions_area_create($box_id);

	form_hidden_box("action_post", "package_list");
	form_end();

	echo "<br />\n";

	form_start("packages.php", "import_package", true);

	html_start_box("<strong>" . _("Import Package") . "</strong>");

	_package_import_field__file("import_package_file");
	_package_import_field__text("import_package_text");

	?>
	<tr>
		<td style="border-top: 1px solid #b5b5b5; padding: 1px;" colspan="2">
			<table width="100%" cellpadding="2" cellspacing="0">
				<tr>
					<td align="right">
						&nbsp;<input type="image" src="<?php echo html_get_theme_images_path('button_import.gif');?>" alt="<?php echo _('Import');?>" name="package_import" align="absmiddle">
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<?php

	html_end_box();

	form_hidden_box("action", "save");
	form_hidden_box("action_post", "package_import");
	form_end();

	//print_a(htmlspecialchars(package_export("1")));

	?>

	<script language="JavaScript">
	<!--
	function action_area_handle_type(box_id, type, parent_div, parent_form) {
		if (type == 'remove') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to remove these data templates?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));

			action_area_update_header_caption(box_id, 'Remove Data Template');
			action_area_update_submit_caption(box_id, 'Remove');
			action_area_update_selected_rows(box_id, parent_form);
		}else if (type == 'duplicate') {
			parent_div.appendChild(document.createTextNode('Are you sure you want to duplicate these data templates?'));
			parent_div.appendChild(action_area_generate_selected_rows(box_id));
			parent_div.appendChild(action_area_generate_input('text', 'box-' + box_id + '-action-area-txt1', ''));

			action_area_update_header_caption(box_id, 'Duplicate Data Templates');
			action_area_update_submit_caption(box_id, 'Duplicate');
			action_area_update_selected_rows(box_id, parent_form);
		}
	}
	-->
	</script>

	<?php
}
示例#3
0
function host_edit()
{
    $_device_id = get_get_var_number("id");
    if (empty($_device_id)) {
        $header_label = "[new]";
    } else {
        $device = api_device_get($_device_id);
        /* get a list of each package that is associated with this device */
        $packages = api_device_package_list($_device_id);
        $header_label = "[edit: " . $device["description"] . "]";
    }
    if (!empty($device["id"])) {
        echo "<div>\n";
        echo $device["description"] . " (" . $device["hostname"] . ")<br />\n";
        echo _("SNMP Information") . "\n";
        if ($device["snmp_community"] == "" && $device["snmpv3_auth_username"] == "") {
            echo "<span style='color: #ab3f1e; font-weight: bold;'>" . _("SNMP not in use") . "</span>\n";
        } else {
            $snmp_system = cacti_snmp_get($device["hostname"], $device["snmp_community"], ".1.3.6.1.2.1.1.1.0", $device["snmp_version"], $device["snmpv3_auth_username"], $device["snmpv3_auth_password"], $device["snmpv3_auth_protocol"], $device["snmpv3_priv_passphrase"], $device["snmpv3_priv_protocol"], $device["snmp_port"], $device["snmp_timeout"], SNMP_WEBUI);
            if ($snmp_system == "") {
                echo "<span style='color: #ff0000; font-weight: bold;'>" . _("SNMP error") . "</span>\n";
            } else {
                $snmp_uptime = cacti_snmp_get($device["hostname"], $device["snmp_community"], ".1.3.6.1.2.1.1.3.0", $device["snmp_version"], $device["snmpv3_auth_username"], $device["snmpv3_auth_password"], $device["snmpv3_auth_protocol"], $device["snmpv3_priv_passphrase"], $device["snmpv3_priv_protocol"], $device["snmp_port"], $device["snmp_timeout"], SNMP_WEBUI);
                $snmp_hostname = cacti_snmp_get($device["hostname"], $device["snmp_community"], ".1.3.6.1.2.1.1.5.0", $device["snmp_version"], $device["snmpv3_auth_username"], $device["snmpv3_auth_password"], $device["snmpv3_auth_protocol"], $device["snmpv3_priv_passphrase"], $device["snmpv3_priv_protocol"], $device["snmp_port"], $device["snmp_timeout"], SNMP_WEBUI);
                $snmp_location = cacti_snmp_get($device["hostname"], $device["snmp_community"], ".1.3.6.1.2.1.1.6.0", $device["snmp_version"], $device["snmpv3_auth_username"], $device["snmpv3_auth_password"], $device["snmpv3_auth_protocol"], $device["snmpv3_priv_passphrase"], $device["snmpv3_priv_protocol"], $device["snmp_port"], $device["snmp_timeout"], SNMP_WEBUI);
                $snmp_contact = cacti_snmp_get($device["hostname"], $device["snmp_community"], ".1.3.6.1.2.1.1.4.0", $device["snmp_version"], $device["snmpv3_auth_username"], $device["snmpv3_auth_password"], $device["snmpv3_auth_protocol"], $device["snmpv3_priv_passphrase"], $device["snmpv3_priv_protocol"], $device["snmp_port"], $device["snmp_timeout"], SNMP_WEBUI);
                echo "<strong>System:</strong> {$snmp_system}<br>\n";
                $days = intval($snmp_uptime / (60 * 60 * 24 * 100));
                $remainder = $snmp_uptime % (60 * 60 * 24 * 100);
                $hours = intval($remainder / (60 * 60 * 100));
                $remainder = $remainder % (60 * 60 * 100);
                $minutes = intval($remainder / (60 * 100));
                echo "<strong>" . _("Uptime:") . "</strong> {$snmp_uptime}";
                echo "&nbsp;({$days} days, {$hours} hours, {$minutes} minutes)<br>\n";
                echo "<strong>" . _("Hostname:") . "</strong> {$snmp_hostname}<br>\n";
                echo "<strong>" . _("Location:") . "</strong> {$snmp_location}<br>\n";
                echo "<strong>" . _("Contact:") . "</strong> {$snmp_contact}<br>\n";
            }
        }
        ?>
		</span>
		</div>
		<div>
			<span style="color: #c16921;">*</span><a href="graphs_new.php?host_id=<?php 
        print $host["id"];
        ?>
"><?php 
        echo _("Create Graphs for this Host");
        ?>
</a>
		</div>
		<br />
		<?php 
    }
    form_start("devices.php", "form_device");
    html_start_box("<strong>" . _("Devices") . "</strong> {$header_label}");
    _device_field__description("description", isset($device["description"]) ? $device["description"] : "", isset($device["id"]) ? $device["id"] : "0");
    _device_field__hostname("hostname", isset($device["hostname"]) ? $device["hostname"] : "", isset($device["id"]) ? $device["id"] : "0");
    _device_field__host_template_id("host_template_id", isset($device["host_template_id"]) ? $device["host_template_id"] : "", isset($device["id"]) ? $device["id"] : "0");
    _device_field__poller_id("poller_id", isset($device["poller_id"]) ? $device["poller_id"] : "", isset($device["id"]) ? $device["id"] : "0");
    _device_field__disabled("disabled", isset($device["disabled"]) ? $device["disabled"] : "", isset($device["id"]) ? $device["id"] : "0");
    echo ui_html_box_heading_make("SNMP Options");
    _device_field__snmp_version("snmp_version", isset($device["snmp_version"]) ? $device["snmp_version"] : "", isset($device["id"]) ? $device["id"] : "0");
    _device_field__snmp_community("snmp_community", isset($device["snmp_community"]) ? $device["snmp_community"] : "", isset($device["id"]) ? $device["id"] : "0");
    _device_field__snmp_port("snmp_port", isset($device["snmp_port"]) ? $device["snmp_port"] : "", isset($device["id"]) ? $device["id"] : "0");
    _device_field__snmp_timeout("snmp_timeout", isset($device["snmp_timeout"]) ? $device["snmp_timeout"] : "", isset($device["id"]) ? $device["id"] : "0");
    echo ui_html_box_heading_make("SNMPv3 Authentication");
    _device_field__snmpv3_auth_username("snmpv3_auth_username", isset($device["snmpv3_auth_username"]) ? $device["snmpv3_auth_username"] : "", isset($device["id"]) ? $device["id"] : "0");
    _device_field__snmpv3_auth_password("snmpv3_auth_password", isset($device["snmpv3_auth_password"]) ? $device["snmpv3_auth_password"] : "", isset($device["id"]) ? $device["id"] : "0");
    _device_field__snmpv3_auth_protocol("snmpv3_auth_protocol", isset($device["snmpv3_auth_protocol"]) ? $device["snmpv3_auth_protocol"] : "", isset($device["id"]) ? $device["id"] : "0");
    _device_field__snmpv3_priv_passphrase("snmpv3_priv_passphrase", isset($device["snmpv3_priv_passphrase"]) ? $device["snmpv3_priv_passphrase"] : "", isset($device["id"]) ? $device["id"] : "0");
    _device_field__snmpv3_priv_protocol("snmpv3_priv_protocol", isset($device["snmpv3_priv_protocol"]) ? $device["snmpv3_priv_protocol"] : "", isset($device["id"]) ? $device["id"] : "0");
    html_end_box();
    if (isset($_GET["display_dq_details"]) && isset($_SESSION["debug_log"]["data_query"])) {
        html_start_box("<strong>" . _("Data Query Debug Information") . "</strong>");
        echo "<tr><td><span style='font-family: monospace;'>" . debug_log_return("data_query") . "</span></td></tr>";
        html_end_box();
    }
    if (!empty($_device_id)) {
        html_start_box("<strong>" . _("Assigned Packages") . "</strong>");
        html_header(array(_("Package Name")), 2);
        if (sizeof($packages) > 0) {
            foreach ($packages as $package) {
                ?>
				<tr class="item">
					<td style="padding: 4px;">
						<?php 
                echo $package["name"];
                ?>
					</td>
					<td align="right" style="padding: 4px;">
						<a href="devices.php?action=remove_package&id=<?php 
                echo $_device_id;
                ?>
&package_id=<?php 
                echo $package["id"];
                ?>
"><img src="<?php 
                echo html_get_theme_images_path("delete_icon_large.gif");
                ?>
" alt="<?php 
                echo _("Delete Package Assignment");
                ?>
" border="0" align="absmiddle"></a>
					</td>
				</tr>
				<?php 
            }
        } else {
            ?>
			<tr class="empty">
				<td colspan="2">
					No packages have been assigned to this device.
				</td>
			</tr>
			<?php 
        }
        ?>
		<tr>
			<td style="border-top: 1px solid #b5b5b5; padding: 1px;" colspan="2">
				<table width="100%" cellpadding="2" cellspacing="0">
					<tr>
						<td>
							Add package:
							<?php 
        form_dropdown("assoc_package_id", api_package_list(), "name", "id", "", "", "");
        ?>
						</td>
						<td align="right">
							&nbsp;<input type="image" src="<?php 
        echo html_get_theme_images_path('button_add.gif');
        ?>
" alt="<?php 
        echo _('Add');
        ?>
" name="assoc_package_add" align="absmiddle">
						</td>
					</tr>
				</table>
			</td>
		</tr>

		<?php 
        html_end_box();
    }
    form_hidden_box("id", $_device_id);
    form_hidden_box("action_post", "device_edit");
    form_save_button("devices.php", "save_device");
}