• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP get_hash_graph_template函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_hash_graph_template函数的典型用法代码示例。如果您正苦于以下问题:PHP get_hash_graph_template函数的具体用法?PHP get_hash_graph_template怎么用?PHP get_hash_graph_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_hash_graph_template函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: form_save

function form_save()
{
    if (isset($_POST["save_component_input"]) && !is_error_message()) {
        $graph_input_values = array();
        $selected_graph_items = array();
        $save["id"] = $_POST["graph_template_input_id"];
        $save["hash"] = get_hash_graph_template($_POST["graph_template_input_id"], "graph_template_input");
        $save["graph_template_id"] = $_POST["graph_template_id"];
        $save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
        $save["description"] = form_input_validate($_POST["description"], "description", "", true, 3);
        $save["column_name"] = form_input_validate($_POST["column_name"], "column_name", "", true, 3);
        if (!is_error_message()) {
            $graph_template_input_id = sql_save($save, "graph_template_input");
            if ($graph_template_input_id) {
                raise_message(1);
                /* list all graph items from the db so we can compare them with the current form */
                $db_selected_graph_item = array_rekey(db_fetch_assoc("select graph_template_item_id from graph_template_input_defs where graph_template_input_id={$graph_template_input_id}"), "graph_template_item_id", "graph_template_item_id");
                /* list all select graph items for use down below */
                while (list($var, $val) = each($_POST)) {
                    if (preg_match("/^i_(\\d+)\$/", $var, $matches)) {
                        /* ================= input validation ================= */
                        input_validate_input_number($matches[1]);
                        /* ==================================================== */
                        $selected_graph_items[$matches[1]] = $matches[1];
                        if (isset($db_selected_graph_item[$matches[1]])) {
                            /* is selected and exists in the db; old item */
                            $old_members[$matches[1]] = $matches[1];
                        } else {
                            /* is selected and does not exist the db; new item */
                            $new_members[$matches[1]] = $matches[1];
                        }
                    }
                }
                if (isset($new_members) && sizeof($new_members) > 0) {
                    while (list($item_id, $item_id) = each($new_members)) {
                        push_out_graph_input($graph_template_input_id, $item_id, isset($new_members) ? $new_members : array());
                    }
                }
                db_execute("delete from graph_template_input_defs where graph_template_input_id={$graph_template_input_id}");
                if (sizeof($selected_graph_items) > 0) {
                    foreach ($selected_graph_items as $graph_template_item_id) {
                        db_execute("insert into graph_template_input_defs (graph_template_input_id,graph_template_item_id)\n\t\t\t\t\t\tvalues ({$graph_template_input_id},{$graph_template_item_id})");
                    }
                }
            } else {
                raise_message(2);
            }
        }
        if (is_error_message()) {
            header("Location: graph_templates_inputs.php?action=input_edit&graph_template_input_id=" . (empty($graph_template_input_id) ? $_POST["graph_template_input_id"] : $graph_template_input_id) . "&graph_template_id=" . $_POST["graph_template_id"]);
            exit;
        } else {
            header("Location: graph_templates.php?action=template_edit&id=" . $_POST["graph_template_id"]);
            exit;
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:odp-svn,代码行数:57,代码来源:graph_templates_inputs.php


示例2: db_fetch_assoc

    echo "NOTE: Repairing Graph Templates\n";
} else {
    echo "NOTE: Performing Check of Graph Templates\n";
}
$damaged_template_ids = db_fetch_assoc("SELECT DISTINCT graph_template_id FROM graph_template_input WHERE hash=''");
if (sizeof($damaged_template_ids)) {
    foreach ($damaged_template_ids as $id) {
        $template_name = db_fetch_cell("SELECT name FROM graph_templates WHERE id=" . $id["graph_template_id"]);
        echo "NOTE: Graph Template '{$template_name}' is Damaged and can be repaired\n";
    }
    $damaged_templates = db_fetch_assoc("SELECT * FROM graph_template_input WHERE hash=''");
    if (sizeof($damaged_templates)) {
        echo "NOTE: -- Damaged Graph Templates Objects Found is '" . sizeof($damaged_templates) . "'\n";
        if ($execute) {
            foreach ($damaged_templates as $template) {
                $hash = get_hash_graph_template(0, "graph_template_input");
                db_execute("UPDATE graph_template_input SET hash='{$hash}' WHERE id=" . $template["id"]);
            }
        }
    }
} else {
    echo "NOTE: No Damaged Graph Templates Found\n";
}
/* display_help - displays the usage of the function */
function display_help()
{
    print "Cacti Database Template Repair Tool v1.0, Copyright 2004-2015 - The Cacti Group\n\n";
    print "usage: repair_templates.php --execute [--help]\n\n";
    print "--execute        - Perform the repair\n";
    print "--help           - display this help message\n";
}
开发者ID:teddywen,项目名称:cacti,代码行数:31,代码来源:repair_templates.php


示例3: graph_to_graph_template

/** graph_to_graph_template - converts a graph to a graph template
   @param int $local_graph_id - the id of the graph to be converted
   @param string $graph_title - the graph title to use for the new graph template. the variable
	<graph_title> will be substituted for the current graph title */
function graph_to_graph_template($local_graph_id, $graph_title) {
	/* create a new graph template entry */
	db_execute("insert into graph_templates (id,name,hash) values (0,'" . str_replace("<graph_title>", db_fetch_cell("select title from graph_templates_graph where local_graph_id=$local_graph_id"), $graph_title) . "','" . get_hash_graph_template(0) . "')");
	$graph_template_id = db_fetch_insert_id();

	/* update graph to point to the new template */
	db_execute("update graph_templates_graph set local_graph_id=0,local_graph_template_graph_id=0,graph_template_id=$graph_template_id where local_graph_id=$local_graph_id");
	db_execute("update graph_templates_item set local_graph_id=0,local_graph_template_item_id=0,graph_template_id=$graph_template_id,task_item_id=0 where local_graph_id=$local_graph_id");

	/* create hashes for the graph template items */
	$items = db_fetch_assoc("select id from graph_templates_item where graph_template_id='$graph_template_id' and local_graph_id=0");
	for ($j=0; $j<count($items); $j++) {
		db_execute("update graph_templates_item set hash='" . get_hash_graph_template($items[$j]["id"], "graph_template_item") . "' where id=" . $items[$j]["id"]);
	}

	/* delete the old graph local entry */
	db_execute("delete from graph_local where id=$local_graph_id");
	db_execute("delete from graph_tree_items where local_graph_id=$local_graph_id");
}
开发者ID:songchin,项目名称:Cacti,代码行数:23,代码来源:template.php


示例4: get_hash_version

function &data_query_to_xml($data_query_id) {
	global $fields_data_query_edit, $fields_data_query_item_edit;

	$hash["data_query"] = get_hash_version("data_query") . get_hash_data_query($data_query_id);
	$xml_text = "";

	$snmp_query = db_fetch_row("select * from snmp_query where id=$data_query_id");
	$snmp_query_graph = db_fetch_assoc("select * from snmp_query_graph where snmp_query_id=$data_query_id");

	if (empty($snmp_query["id"])) {
		return "Invalid data query.";
	}

	$xml_text .= "<hash_" . $hash["data_query"] . ">\n";

	/* XML Branch: <> */
	reset($fields_data_query_edit);
	while (list($field_name, $field_array) = each($fields_data_query_edit)) {
		if (($field_name == "data_input_id") && (!empty($snmp_query{$field_name}))) {
			$xml_text .= "\t<$field_name>hash_" . get_hash_version("data_input_method") . get_hash_data_input($snmp_query{$field_name}) . "</$field_name>\n";
		}else{
			if (($field_array["method"] != "hidden_zero") && ($field_array["method"] != "hidden")) {
				$xml_text .= "\t<$field_name>" . xml_character_encode($snmp_query{$field_name}) . "</$field_name>\n";
			}
		}
	}

	/* XML Branch: <graphs> */

	$xml_text .= "\t<graphs>\n";

	$i = 0;
	if (sizeof($snmp_query_graph) > 0) {
	foreach ($snmp_query_graph as $item) {
		$hash["data_query_graph"] = get_hash_version("data_query_graph") . get_hash_data_query($item["id"], "data_query_graph");

		$xml_text .= "\t\t<hash_" . $hash["data_query_graph"] . ">\n";

		reset($fields_data_query_item_edit);
		while (list($field_name, $field_array) = each($fields_data_query_item_edit)) {
			if (($field_name == "graph_template_id") && (!empty($item{$field_name}))) {
				$xml_text .= "\t\t\t<$field_name>hash_" . get_hash_version("graph_template") . get_hash_graph_template($item{$field_name}) . "</$field_name>\n";
			}else{
				if (($field_array["method"] != "hidden_zero") && ($field_array["method"] != "hidden")) {
					$xml_text .= "\t\t\t<$field_name>" . xml_character_encode($item{$field_name}) . "</$field_name>\n";
				}
			}
		}

		$snmp_query_graph_rrd_sv = db_fetch_assoc("select * from snmp_query_graph_rrd_sv where snmp_query_graph_id=" . $item["id"] . " order by sequence");
		$snmp_query_graph_sv = db_fetch_assoc("select * from snmp_query_graph_sv where snmp_query_graph_id=" . $item["id"] . " order by sequence");
		$snmp_query_graph_rrd = db_fetch_assoc("select * from snmp_query_graph_rrd where snmp_query_graph_id=" . $item["id"] . " and data_template_id > 0");

		/* XML Branch: <graphs/rrd> */

		$xml_text .= "\t\t\t<rrd>\n";

		$i = 0;
		if (sizeof($snmp_query_graph_rrd) > 0) {
		foreach ($snmp_query_graph_rrd as $item2) {
			$xml_text .= "\t\t\t\t<item_" . str_pad(strval($i), 3, "0", STR_PAD_LEFT) . ">\n";

			$xml_text .= "\t\t\t\t\t<snmp_field_name>" . $item2{"snmp_field_name"} . "</snmp_field_name>\n";
			$xml_text .= "\t\t\t\t\t<data_template_id>hash_" . get_hash_version("data_template") . get_hash_data_template($item2{"data_template_id"}) . "</data_template_id>\n";
			$xml_text .= "\t\t\t\t\t<data_template_rrd_id>hash_" . get_hash_version("data_template_item") . get_hash_data_template($item2{"data_template_rrd_id"}, "data_template_item") . "</data_template_rrd_id>\n";

			$xml_text .= "\t\t\t\t</item_" . str_pad(strval($i), 3, "0", STR_PAD_LEFT) . ">\n";

			$i++;
		}
		}

		$xml_text .= "\t\t\t</rrd>\n";

		/* XML Branch: <graphs/sv_graph> */

		$xml_text .= "\t\t\t<sv_graph>\n";

		$j = 0;
		if (sizeof($snmp_query_graph_sv) > 0) {
		foreach ($snmp_query_graph_sv as $item2) {
			$hash["data_query_sv_graph"] = get_hash_version("data_query_sv_graph") . get_hash_data_query($item2["id"], "data_query_sv_graph");

			$xml_text .= "\t\t\t\t<hash_" . $hash["data_query_sv_graph"] . ">\n";

			$xml_text .= "\t\t\t\t\t<field_name>" . xml_character_encode($item2{"field_name"}) . "</field_name>\n";
			$xml_text .= "\t\t\t\t\t<sequence>" . $item2{"sequence"} . "</sequence>\n";
			$xml_text .= "\t\t\t\t\t<text>" . xml_character_encode($item2{"text"}) . "</text>\n";

			$xml_text .= "\t\t\t\t</hash_" . $hash["data_query_sv_graph"] . ">\n";

			$j++;
		}
		}

		$xml_text .= "\t\t\t</sv_graph>\n";

		/* XML Branch: <graphs/sv_data_source> */

		$xml_text .= "\t\t\t<sv_data_source>\n";
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:export.php


示例5: upgrade_to_0_8_4


//.........这里部分代码省略.........
	db_execute("update snmp_query set hash='8ffa36c1864124b38bcda2ae9bd61f46' where id=6;");
	db_execute("update snmp_query_graph set hash='a0b3e7b63c2e66f9e1ea24a16ff245fc' where id=15;");
	db_execute("update snmp_query_graph_rrd_sv set hash='cb09784ba05e401a3f1450126ed1e395' where id=69;");
	db_execute("update snmp_query_graph_sv set hash='f21b23df740bc4a2d691d2d7b1b18dba' where id=30;");
	db_execute("update snmp_query set hash='30ec734bc0ae81a3d995be82c73f46c1' where id=7;");
	db_execute("update snmp_query_graph set hash='f6db4151aa07efa401a0af6c9b871844' where id=17;");
	db_execute("update snmp_query_graph_rrd_sv set hash='42277993a025f1bfd85374d6b4deeb60' where id=92;");
	db_execute("update snmp_query_graph_sv set hash='d99f8db04fd07bcd2260d246916e03da' where id=40;");
	db_execute("update snmp_query set hash='9343eab1f4d88b0e61ffc9d020f35414' where id=8;");
	db_execute("update snmp_query_graph set hash='46c4ee688932cf6370459527eceb8ef3' where id=18;");
	db_execute("update snmp_query_graph_rrd_sv set hash='a3f280327b1592a1a948e256380b544f' where id=93;");
	db_execute("update snmp_query_graph_sv set hash='9852782792ede7c0805990e506ac9618' where id=38;");
	db_execute("update snmp_query set hash='0d1ab53fe37487a5d0b9e1d3ee8c1d0d' where id=9;");
	db_execute("update snmp_query_graph set hash='4a515b61441ea5f27ab7dee6c3cb7818' where id=19;");
	db_execute("update snmp_query_graph_rrd_sv set hash='b5a724edc36c10891fa2a5c370d55b6f' where id=94;");
	db_execute("update snmp_query_graph_sv set hash='fa2f07ab54fce72eea684ba893dd9c95' where id=39;");
	db_execute("update host_template set hash='4855b0e3e553085ed57219690285f91f' where id=1;");
	db_execute("update host_template set hash='07d3fe6a52915f99e642d22e27d967a4' where id=3;");
	db_execute("update host_template set hash='4e5dc8dd115264c2e9f3adb725c29413' where id=4;");
	db_execute("update host_template set hash='cae6a879f86edacb2471055783bec6d0' where id=5;");
	db_execute("update host_template set hash='9ef418b4251751e09c3c416704b01b01' where id=6;");
	db_execute("update host_template set hash='5b8300be607dce4f030b026a381b91cd' where id=7;");
	db_execute("update host_template set hash='2d3e47f416738c2d22c87c40218cc55e' where id=8;");
	db_execute("update rra set hash='c21df5178e5c955013591239eb0afd46' where id=1;");
	db_execute("update rra set hash='0d9c0af8b8acdc7807943937b3208e29' where id=2;");
	db_execute("update rra set hash='6fc2d038fb42950138b0ce3e9874cc60' where id=3;");
	db_execute("update rra set hash='e36f3adb9f152adfa5dc50fd2b23337e' where id=4;");

	$item = db_fetch_assoc("select id from cdef");
	for ($i=0; $i<count($item); $i++) {
		db_execute("update cdef set hash='" . get_hash_cdef($item[$i]["id"]) . "' where id=" . $item[$i]["id"] . ";");
		$item2 = db_fetch_assoc("select id from cdef_items where cdef_id=" . $item[$i]["id"]);
		for ($j=0; $j<count($item2); $j++) {
			db_execute("update cdef_items set hash='" . get_hash_cdef($item2[$j]["id"], "cdef_item") . "' where id=" . $item2[$j]["id"] . ";");
		}
	}

	$item = db_fetch_assoc("select id from graph_templates_gprint");
	for ($i=0; $i<count($item); $i++) {
		db_execute("update graph_templates_gprint set hash='" . get_hash_gprint($item[$i]["id"]) . "' where id=" . $item[$i]["id"] . ";");
	}

	$item = db_fetch_assoc("select id from data_input");
	for ($i=0; $i<count($item); $i++) {
		db_execute("update data_input set hash='" . get_hash_data_input($item[$i]["id"]) . "' where id=" . $item[$i]["id"] . ";");
		$item2 = db_fetch_assoc("select id from data_input_fields where data_input_id=" . $item[$i]["id"]);
		for ($j=0; $j<count($item2); $j++) {
			db_execute("update data_input_fields set hash='" . get_hash_data_input($item2[$j]["id"], "data_input_field") . "' where id=" . $item2[$j]["id"] . ";");
		}
	}

	$item = db_fetch_assoc("select id from data_template");
	for ($i=0; $i<count($item); $i++) {
		db_execute("update data_template set hash='" . get_hash_data_template($item[$i]["id"]) . "' where id=" . $item[$i]["id"] . ";");
		$item2 = db_fetch_assoc("select id from data_template_rrd where data_template_id=" . $item[$i]["id"] . " and local_data_id=0");
		for ($j=0; $j<count($item2); $j++) {
			db_execute("update data_template_rrd set hash='" . get_hash_data_template($item2[$j]["id"], "data_template_item") . "' where id=" . $item2[$j]["id"] . ";");
		}
	}

	$item = db_fetch_assoc("select id from graph_templates");
	for ($i=0; $i<count($item); $i++) {
		db_execute("update graph_templates set hash='" . get_hash_graph_template($item[$i]["id"]) . "' where id=" . $item[$i]["id"] . ";");
		$item2 = db_fetch_assoc("select id from graph_templates_item where graph_template_id=" . $item[$i]["id"] . " and local_graph_id=0");
		for ($j=0; $j<count($item2); $j++) {
			db_execute("update graph_templates_item set hash='" . get_hash_graph_template($item2[$j]["id"], "graph_template_item") . "' where id=" . $item2[$j]["id"] . ";");
		}
		$item2 = db_fetch_assoc("select id from graph_template_input where graph_template_id=" . $item[$i]["id"]);
		for ($j=0; $j<count($item2); $j++) {
			db_execute("update graph_template_input set hash='" . get_hash_graph_template($item2[$j]["id"], "graph_template_input") . "' where id=" . $item2[$j]["id"] . ";");
		}
	}

	$item = db_fetch_assoc("select id from snmp_query");
	for ($i=0; $i<count($item); $i++) {
		db_execute("update snmp_query set hash='" . get_hash_data_query($item[$i]["id"]) . "' where id=" . $item[$i]["id"] . ";");
		$item2 = db_fetch_assoc("select id from snmp_query_graph where snmp_query_id=" . $item[$i]["id"]);
		for ($j=0; $j<count($item2); $j++) {
			db_execute("update snmp_query_graph set hash='" . get_hash_data_query($item2[$j]["id"], "data_query_graph") . "' where id=" . $item2[$j]["id"] . ";");
			$item3 = db_fetch_assoc("select id from snmp_query_graph_rrd_sv where snmp_query_graph_id=" . $item2[$j]["id"]);
			for ($k=0; $k<count($item3); $k++) {
				db_execute("update snmp_query_graph_rrd_sv set hash='" . get_hash_data_query($item3[$k]["id"], "data_query_sv_data_source") . "' where id=" . $item3[$k]["id"] . ";");
			}
			$item3 = db_fetch_assoc("select id from snmp_query_graph_sv where snmp_query_graph_id=" . $item2[$j]["id"]);
			for ($k=0; $k<count($item3); $k++) {
				db_execute("update snmp_query_graph_sv set hash='" . get_hash_data_query($item3[$k]["id"], "data_query_sv_graph") . "' where id=" . $item3[$k]["id"] . ";");
			}
		}
	}

	$item = db_fetch_assoc("select id from host_template");
	for ($i=0; $i<count($item); $i++) {
		db_execute("update host_template set hash='" . get_hash_host_template($item[$i]["id"]) . "' where id=" . $item[$i]["id"] . ";");
	}

	$item = db_fetch_assoc("select id from rra");
	for ($i=0; $i<count($item); $i++) {
		db_execute("update rra set hash='" . get_hash_round_robin_archive($item[$i]["id"]) . "' where id=" . $item[$i]["id"] . ";");
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:0_8_3_to_0_8_4.php


示例6: form_save

function form_save() {
	if (isset($_POST["save_component_item"])) {
		/* ================= input validation ================= */
		input_validate_input_number(get_request_var_post("graph_template_id"));
		input_validate_input_number(get_request_var_post("task_item_id"));
		/* ==================================================== */

		global $graph_item_types;

		$items[0] = array();

		if ($graph_item_types{$_POST["graph_type_id"]} == "LEGEND") {
			/* this can be a major time saver when creating lots of graphs with the typical
			GPRINT LAST/AVERAGE/MAX legends */
			$items = array(
				0 => array(
					"color_id" => "0",
					"graph_type_id" => "9",
					"consolidation_function_id" => "4",
					"text_format" => "Current:",
					"hard_return" => ""
					),
				1 => array(
					"color_id" => "0",
					"graph_type_id" => "9",
					"consolidation_function_id" => "1",
					"text_format" => "Average:",
					"hard_return" => ""
					),
				2 => array(
					"color_id" => "0",
					"graph_type_id" => "9",
					"consolidation_function_id" => "3",
					"text_format" => "Maximum:",
					"hard_return" => "on"
					));
		}

		foreach ($items as $item) {
			/* generate a new sequence if needed */
			if (empty($_POST["sequence"])) {
				$_POST["sequence"] = get_sequence($_POST["sequence"], "sequence", "graph_templates_item", "graph_template_id=" . $_POST["graph_template_id"] . " and local_graph_id=0");
			}

			$save["id"] = $_POST["graph_template_item_id"];
			$save["hash"] = get_hash_graph_template($_POST["graph_template_item_id"], "graph_template_item");
			$save["graph_template_id"] = $_POST["graph_template_id"];
			$save["local_graph_id"] = 0;
			$save["task_item_id"] = form_input_validate($_POST["task_item_id"], "task_item_id", "", true, 3);
			$save["color_id"] = form_input_validate((isset($item["color_id"]) ? $item["color_id"] : $_POST["color_id"]), "color_id", "", true, 3);
			/* if alpha is disabled, use invisible_alpha instead */
			if (!isset($_POST["alpha"])) {$_POST["alpha"] = $_POST["invisible_alpha"];}
			$save["alpha"] = form_input_validate((isset($item["alpha"]) ? $item["alpha"] : $_POST["alpha"]), "alpha", "", true, 3);
			$save["graph_type_id"] = form_input_validate((isset($item["graph_type_id"]) ? $item["graph_type_id"] : $_POST["graph_type_id"]), "graph_type_id", "", true, 3);
			$save["cdef_id"] = form_input_validate($_POST["cdef_id"], "cdef_id", "", true, 3);
			$save["consolidation_function_id"] = form_input_validate((isset($item["consolidation_function_id"]) ? $item["consolidation_function_id"] : $_POST["consolidation_function_id"]), "consolidation_function_id", "", true, 3);
			$save["text_format"] = form_input_validate((isset($item["text_format"]) ? $item["text_format"] : $_POST["text_format"]), "text_format", "", true, 3);
			$save["value"] = form_input_validate($_POST["value"], "value", "", true, 3);
			$save["hard_return"] = form_input_validate(((isset($item["hard_return"]) ? $item["hard_return"] : (isset($_POST["hard_return"]) ? $_POST["hard_return"] : ""))), "hard_return", "", true, 3);
			$save["gprint_id"] = form_input_validate($_POST["gprint_id"], "gprint_id", "", true, 3);
			$save["sequence"] = $_POST["sequence"];

			if (!is_error_message()) {
				/* Before we save the item, let's get a look at task_item_id <-> input associations */
				$orig_data_source_graph_inputs = db_fetch_assoc("select
					graph_template_input.id,
					graph_template_input.name,
					graph_templates_item.task_item_id
					from (graph_template_input,graph_template_input_defs,graph_templates_item)
					where graph_template_input.id=graph_template_input_defs.graph_template_input_id
					and graph_template_input_defs.graph_template_item_id=graph_templates_item.id
					and graph_template_input.graph_template_id=" . $save["graph_template_id"] . "
					and graph_template_input.column_name='task_item_id'
					group by graph_templates_item.task_item_id");

				$orig_data_source_to_input = array_rekey($orig_data_source_graph_inputs, "task_item_id", "id");

				$graph_template_item_id = sql_save($save, "graph_templates_item");

				if ($graph_template_item_id) {
					raise_message(1);

					if (!empty($save["task_item_id"])) {
						/* old item clean-up.  Don't delete anything if the item <-> task_item_id association remains the same. */
						if ($_POST["_task_item_id"] != $_POST["task_item_id"]) {
							/* It changed.  Delete any old associations */
							db_execute("delete from graph_template_input_defs where graph_template_item_id=$graph_template_item_id");

							/* Input for current data source exists and has changed.  Update the association */
							if (isset($orig_data_source_to_input{$save["task_item_id"]})) {
								db_execute("replace into graph_template_input_defs (graph_template_input_id,
								graph_template_item_id) values (" . $orig_data_source_to_input{$save["task_item_id"]}
								. ",$graph_template_item_id)");
							}
						}

						/* an input for the current data source does NOT currently exist, let's create one */
						if (!isset($orig_data_source_to_input{$save["task_item_id"]})) {
							$ds_name = db_fetch_cell("select data_source_name from data_template_rrd where id=" . $_POST["task_item_id"]);

//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:graph_templates_items.php


示例7: upgrade_to_0_8_6a

function upgrade_to_0_8_6a()
{
    /* fix import/export template bug */
    $item = db_fetch_assoc("select id from data_template");
    for ($i = 0; $i < count($item); $i++) {
        db_execute("update data_template set hash='" . get_hash_data_template($item[$i]["id"]) . "' where id=" . $item[$i]["id"] . ";");
        $item2 = db_fetch_assoc("select id from data_template_rrd where data_template_id=" . $item[$i]["id"] . " and local_data_id=0");
        for ($j = 0; $j < count($item2); $j++) {
            db_execute("update data_template_rrd set hash='" . get_hash_data_template($item2[$j]["id"], "data_template_item") . "' where id=" . $item2[$j]["id"] . ";");
        }
    }
    $item = db_fetch_assoc("select id from graph_templates");
    for ($i = 0; $i < count($item); $i++) {
        db_execute("update graph_templates set hash='" . get_hash_graph_template($item[$i]["id"]) . "' where id=" . $item[$i]["id"] . ";");
        $item2 = db_fetch_assoc("select id from graph_templates_item where graph_template_id=" . $item[$i]["id"] . " and local_graph_id=0");
        for ($j = 0; $j < count($item2); $j++) {
            db_execute("update graph_templates_item set hash='" . get_hash_graph_template($item2[$j]["id"], "graph_template_item") . "' where id=" . $item2[$j]["id"] . ";");
        }
        $item2 = db_fetch_assoc("select id from graph_template_input where graph_template_id=" . $item[$i]["id"]);
        for ($j = 0; $j < count($item2); $j++) {
            db_execute("update graph_template_input set hash='" . get_hash_graph_template($item2[$j]["id"], "graph_template_input") . "' where id=" . $item2[$j]["id"] . ";");
        }
    }
    /* clean up data template item orphans left behind by the graph->graph template bug */
    $graph_templates = db_fetch_assoc("select id from graph_templates");
    if (sizeof($graph_templates) > 0) {
        foreach ($graph_templates as $graph_template) {
            /* find non-templated graph template items */
            $non_templated_items = array_rekey(db_fetch_assoc("select\n\t\t\t\tgraph_template_input_defs.graph_template_item_id\n\t\t\t\tfrom (graph_template_input,graph_template_input_defs)\n\t\t\t\twhere graph_template_input_defs.graph_template_input_id=graph_template_input.id\n\t\t\t\tand graph_template_input.column_name = 'task_item_id'\n\t\t\t\tand graph_template_input.graph_template_id = '" . $graph_template["id"] . "'"), "graph_template_item_id", "graph_template_item_id");
            /* find all graph items */
            $graph_template_items = db_fetch_assoc("select\n\t\t\t\tgraph_templates_item.id,\n\t\t\t\tgraph_templates_item.task_item_id\n\t\t\t\tfrom graph_templates_item\n\t\t\t\twhere graph_templates_item.graph_template_id = '" . $graph_template["id"] . "'\n\t\t\t\tand graph_templates_item.local_graph_id = 0");
            if (sizeof($graph_template_items) > 0) {
                foreach ($graph_template_items as $graph_template_item) {
                    if (!isset($non_templated_items[$graph_template_item["id"]])) {
                        if ($graph_template_item["task_item_id"] > 0) {
                            $dest_dti = db_fetch_row("select local_data_id from data_template_rrd where id = '" . $graph_template_item["task_item_id"] . "'");
                            /* it's an orphan! */
                            if (!isset($dest_dti["local_data_id"]) || $dest_dti["local_data_id"] > 0) {
                                /* clean graph template */
                                db_execute("update graph_templates_item set task_item_id = 0 where id = '" . $graph_template_item["id"] . "' and local_graph_id = 0 and graph_template_id = '" . $graph_template["id"] . "'");
                                /* clean attached graphs */
                                db_execute("update graph_templates_item set task_item_id = 0 where local_graph_template_item_id = '" . $graph_template_item["id"] . "' and local_graph_id > 0 and graph_template_id = '" . $graph_template["id"] . "'");
                            }
                        }
                    }
                }
            }
        }
    }
    /* make sure the 'host_graph' table is populated (problem from 0.8.4) */
    $hosts = db_fetch_assoc("select id,host_template_id from host where host_template_id > 0");
    if (sizeof($hosts) > 0) {
        foreach ($hosts as $host) {
            $graph_templates = db_fetch_assoc("select graph_template_id from host_template_graph where host_template_id=" . $host["host_template_id"]);
            if (sizeof($graph_templates) > 0) {
                foreach ($graph_templates as $graph_template) {
                    db_execute("replace into host_graph (host_id,graph_template_id) values (" . $host["id"] . "," . $graph_template["graph_template_id"] . ")");
                }
            }
        }
    }
}
开发者ID:andrei1489,项目名称:cacti,代码行数:62,代码来源:0_8_6_to_0_8_6a.php


示例8: duplicate_graph

function duplicate_graph($_local_graph_id, $_graph_template_id, $graph_title) {
	require_once(CACTI_BASE_PATH . "/lib/graph/graph_info.php");

	if (!empty($_local_graph_id)) {
		$graph_local = db_fetch_row("select * from graph_local where id=$_local_graph_id");
		$graph_template_graph = db_fetch_row("select * from graph_templates_graph where local_graph_id=$_local_graph_id");
		$graph_template_items = db_fetch_assoc("select * from graph_templates_item where local_graph_id=$_local_graph_id");

		/* create new entry: graph_local */
		$save["id"] = 0;
		$save["graph_template_id"] = $graph_local["graph_template_id"];
		$save["device_id"] = $graph_local["device_id"];
		$save["snmp_query_id"] = $graph_local["snmp_query_id"];
		$save["snmp_index"] = $graph_local["snmp_index"];

		$local_graph_id = sql_save($save, "graph_local");

		$graph_template_graph["title"] = str_replace(__("<graph_title>"), $graph_template_graph["title"], $graph_title);
	}elseif (!empty($_graph_template_id)) {
		$graph_template = db_fetch_row("select * from graph_templates where id=$_graph_template_id");
		$graph_template_graph = db_fetch_row("select * from graph_templates_graph where graph_template_id=$_graph_template_id and local_graph_id=0");
		$graph_template_items = db_fetch_assoc("select * from graph_templates_item where graph_template_id=$_graph_template_id and local_graph_id=0");
		$graph_template_inputs = db_fetch_assoc("select * from graph_template_input where graph_template_id=$_graph_template_id");

		/* create new entry: graph_templates */
		$save["id"] = 0;
		$save["hash"] = get_hash_graph_template(0);
		$save["name"] = str_replace(__("<template_title>"), $graph_template["name"], $graph_title);

		$graph_template_id = sql_save($save, "graph_templates");
	}

	unset($save);
	$struct_graph = graph_form_list();
	reset($struct_graph);

	/* create new entry: graph_templates_graph */
	$save["id"] = 0;
	$save["local_graph_id"] = (isset($local_graph_id) ? $local_graph_id : 0);
	$save["local_graph_template_graph_id"] = (isset($graph_template_graph["local_graph_template_graph_id"]) ? $graph_template_graph["local_graph_template_graph_id"] : 0);
	$save["graph_template_id"] = (!empty($_local_graph_id) ? $graph_template_graph["graph_template_id"] : $graph_template_id);
	$save["title_cache"] = $graph_template_graph["title_cache"];

	reset($struct_graph);
	while (list($field, $array) = each($struct_graph)) {
		$save{$field} = $graph_template_graph{$field};
		$save{"t_" . $field} = $graph_template_graph{"t_" . $field};
	}

	$graph_templates_graph_id = sql_save($save, "graph_templates_graph");

	/* create new entry(s): graph_templates_item */
	if (sizeof($graph_template_items) > 0) {
		$struct_graph_item = graph_item_form_list();
	foreach ($graph_template_items as $graph_template_item) {
		unset($save);
		reset($struct_graph_item);

		$save["id"] = 0;
		/* save a hash only for graph_template copy operations */
		$save["hash"] = (!empty($_graph_template_id) ? get_hash_graph_template(0, "graph_template_item") : 0);
		$save["local_graph_id"] = (isset($local_graph_id) ? $local_graph_id : 0);
		$save["graph_template_id"] = (!empty($_local_graph_id) ? $graph_template_item["graph_template_id"] : $graph_template_id);
		$save["local_graph_template_item_id"] = (isset($graph_template_item["local_graph_template_item_id"]) ? $graph_template_item["local_graph_template_item_id"] : 0);

		while (list($field, $array) = each($struct_graph_item)) {
			$save{$field} = $graph_template_item{$field};
		}

		$graph_item_mappings{$graph_template_item["id"]} = sql_save($save, "graph_templates_item");
	}
	}

	if (!empty($_graph_template_id)) {
		/* create new entry(s): graph_template_input (graph template only) */
		if (sizeof($graph_template_inputs) > 0) {
		foreach ($graph_template_inputs as $graph_template_input) {
			unset($save);

			$save["id"]                = 0;
			$save["graph_template_id"] = $graph_template_id;
			$save["name"]              = $graph_template_input["name"];
			$save["description"]       = $graph_template_input["description"];
			$save["column_name"]       = $graph_template_input["column_name"];
			$save["hash"]              = get_hash_graph_template(0, "graph_template_input");

			$graph_template_input_id   = sql_save($save, "graph_template_input");

			$graph_template_input_defs = db_fetch_assoc("select * from graph_template_input_defs where graph_template_input_id=" . $graph_template_input["id"]);

			/* create new entry(s): graph_template_input_defs (graph template only) */
			if (sizeof($graph_template_input_defs) > 0) {
			foreach ($graph_template_input_defs as $graph_template_input_def) {
				db_execute("insert into graph_template_input_defs (graph_template_input_id,graph_template_item_id)
					values ($graph_template_input_id," . $graph_item_mappings{$graph_template_input_def["graph_template_item_id"]} . ")");
			}
			}
		}
		}
	}
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:utility.php


示例9: form_save

function form_save()
{
    if (isset($_POST["save_component_template"])) {
        $save1["id"] = $_POST["graph_template_id"];
        $save1["hash"] = get_hash_graph_template($_POST["graph_template_id"]);
        $save1["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
        $save2["id"] = $_POST["graph_template_graph_id"];
        $save2["local_graph_template_graph_id"] = 0;
        $save2["local_graph_id"] = 0;
        $save2["t_image_format_id"] = isset($_POST["t_image_format_id"]) ? $_POST["t_image_format_id"] : "";
        $save2["image_format_id"] = form_input_validate($_POST["image_format_id"], "image_format_id", "", true, 3);
        $save2["t_title"] = form_input_validate(isset($_POST["t_title"]) ? $_POST["t_title"] : "", "t_title", "", true, 3);
        $save2["title"] = form_input_validate($_POST["title"], "title", "", isset($_POST["t_title"]) ? true : false, 3);
        $save2["t_height"] = form_input_validate(isset($_POST["t_height"]) ? $_POST["t_height"] : "", "t_height", "", true, 3);
        $save2["height"] = form_input_validate($_POST["height"], "height", "^[0-9]+\$", isset($_POST["t_height"]) ? true : false, 3);
        $save2["t_width"] = form_input_validate(isset($_POST["t_width"]) ? $_POST["t_width"] : "", "t_width", "", true, 3);
        $save2["width"] = form_input_validate($_POST["width"], "width", "^[0-9]+\$", isset($_POST["t_width"]) ? true : false, 3);
        $save2["t_upper_limit"] = form_input_validate(isset($_POST["t_upper_limit"]) ? $_POST["t_upper_limit"] : "", "t_upper_limit", "", true, 3);
        $save2["upper_limit"] = form_input_validate($_POST["upper_limit"], "upper_limit", "^(-?([0-9]+(\\.[0-9]*)?|[0-9]*\\.[0-9]+)([eE][+\\-]?[0-9]+)?)|U\$", isset($_POST["t_upper_limit"]) ? true : false, 3);
        $save2["t_lower_limit"] = form_input_validate(isset($_POST["t_lower_limit"]) ? $_POST["t_lower_limit"] : "", "t_lower_limit", "", true, 3);
        $save2["lower_limit"] = form_input_validate($_POST["lower_limit"], "lower_limit", "^(-?([0-9]+(\\.[0-9]*)?|[0-9]*\\.[0-9]+)([eE][+\\-]?[0-9]+)?)|U\$", isset($_POST["t_lower_limit"]) ? true : false, 3);
        $save2["t_vertical_label"] = form_input_validate(isset($_POST["t_vertical_label"]) ? $_POST["t_vertical_label"] : "", "t_vertical_label", "", true, 3);
        $save2["vertical_label"] = form_input_validate($_POST["vertical_label"], "vertical_label", "", true, 3);
        $save2["t_slope_mode"] = form_input_validate(isset($_POST["t_slope_mode"]) ? $_POST["t_slope_mode"] : "", "t_slope_mode", "", true, 3);
        $save2["slope_mode"] = form_input_validate(isset($_POST["slope_mode"]) ? $_POST["slope_mode"] : "", "slope_mode", "", true, 3);
        $save2["t_auto_scale"] = form_input_validate(isset($_POST["t_auto_scale"]) ? $_POST["t_auto_scale"] : "", "t_auto_scale", "", true, 3);
        $save2["auto_scale"] = form_input_validate(isset($_POST["auto_scale"]) ? $_POST["auto_scale"] : "", "auto_scale", "", true, 3);
        $save2["t_auto_scale_opts"] = form_input_validate(isset($_POST["t_auto_scale_opts"]) ? $_POST["t_auto_scale_opts"] : "", "t_auto_scale_opts", "", true, 3);
        $save2["auto_scale_opts"] = form_input_validate($_POST["auto_scale_opts"], "auto_scale_opts", "", true, 3);
        $save2["t_auto_scale_log"] = form_input_validate(isset($_POST["t_auto_scale_log"]) ? $_POST["t_auto_scale_log"] : "", "t_auto_scale_log", "", true, 3);
        $save2["auto_scale_log"] = form_input_validate(isset($_POST["auto_scale_log"]) ? $_POST["auto_scale_log"] : "", "auto_scale_log", "", true, 3);
        $save2["t_scale_log_units"] = form_input_validate(isset($_POST["t_scale_log_units"]) ? $_POST["t_scale_log_units"] : "", "t_scale_log_units", "", true, 3);
        $save2["scale_log_units"] = form_input_validate(isset($_POST["scale_log_units"]) ? $_POST["scale_log_units"] : "", "scale_log_units", "", true, 3);
        $save2["t_auto_scale_rigid"] = form_input_validate(isset($_POST["t_auto_scale_rigid"]) ? $_POST["t_auto_scale_rigid"] : "", "t_auto_scale_rigid", "", true, 3);
        $save2["auto_scale_rigid"] = form_input_validate(isset($_POST["auto_scale_rigid"]) ? $_POST["auto_scale_rigid"] : "", "auto_scale_rigid", "", true, 3);
        $save2["t_auto_padding"] = form_input_validate(isset($_POST["t_auto_padding"]) ? $_POST["t_auto_padding"] : "", "t_auto_padding", "", true, 3);
        $save2["auto_padding"] = form_input_validate(isset($_POST["auto_padding"]) ? $_POST["auto_padding"] : "", "auto_padding", "", true, 3);
        $save2["t_base_value"] = form_input_validate(isset($_POST["t_base_value"]) ? $_POST["t_base_value"] : "", "t_base_value", "", true, 3);
        $save2["base_value"] = form_input_validate($_POST["base_value"], "base_value", "^[0-9]+\$", isset($_POST["t_base_value"]) ? true : false, 3);
        $save2["t_export"] = form_input_validate(isset($_POST["t_export"]) ? $_POST["t_export"] : "", "t_export", "", true, 3);
        $save2["export"] = form_input_validate(isset($_POST["export"]) ? $_POST["export"] : "", "export", "", true, 3);
        $save2["t_unit_value"] = form_input_validate(isset($_POST["t_unit_value"]) ? $_POST["t_unit_value"] : "", "t_unit_value", "", true, 3);
        $save2["unit_value"] = form_input_validate($_POST["unit_value"], "unit_value", "", true, 3);
        $save2["t_unit_exponent_value"] = form_input_validate(isset($_POST["t_unit_exponent_value"]) ? $_POST["t_unit_exponent_value"] : "", "t_unit_exponent_value", "", true, 3);
        $save2["unit_exponent_value"] = form_input_validate($_POST["unit_exponent_value"], "unit_exponent_value", "^-?[0-9]+\$", true, 3);
        if (!is_error_message()) {
            $graph_template_id = sql_save($save1, "graph_templates");
            if ($graph_template_id) {
                raise_message(1);
            } else {
                raise_message(2);
            }
        }
        if (!is_error_message()) {
            $save2["graph_template_id"] = $graph_template_id;
            $graph_template_graph_id = sql_save($save2, "graph_templates_graph");
            if ($graph_template_graph_id) {
                raise_message(1);
                push_out_graph($graph_template_graph_id);
            } else {
                raise_message(2);
            }
        }
    }
    if (is_error_message() || empty($_POST["graph_template_id"])) {
        header("Location: graph_templates.php?action=template_edit&id=" . (empty($graph_template_id) ? $_POST["graph_template_id"] : $graph_template_id));
    } else {
        header("Location: graph_templates.php");
    }
}
开发者ID:songchin,项目名称:Cacti,代码行数:70,代码来源:graph_templates.php


示例10: data_query_to_xml

function data_query_to_xml($data_query_id)
{
    global $fields_data_query_edit, $fields_data_query_item_edit, $export_errors;
    $hash["data_query"] = get_hash_version("data_query") . get_hash_data_query($data_query_id);
    $xml_text = "";
    $snmp_query = db_fetch_row("select * from snmp_query where id={$data_query_id}");
    $snmp_query_graph = db_fetch_assoc("select * from snmp_query_graph where snmp_query_id={$data_query_id}");
    if (empty($snmp_query["id"])) {
        $export_errors++;
        raise_message(28);
        cacti_log("ERROR: Invalid Data Query found during Export.  Please run database repair script to identify and/or correct.", false, "WEBUI");
        return;
    }
    $xml_text .= "<hash_" . $hash["data_query"] . ">\n";
    /* XML Branch: <> */
    reset($fields_data_query_edit);
    while (list($field_name, $field_array) = each($fields_data_query_edit)) {
        if ($field_name == "data_input_id" && !empty($snmp_query[$field_name])) {
            $xml_text .= "\t<{$field_name}>hash_" . get_hash_version("data_input_method") . get_hash_data_input($snmp_query[$field_name]) . "</{$field_name}>\n";
        } else {
            if ($field_array["method"] != "hidden_zero" && $field_array["method"] != "hidden") {
                $xml_text .= "\t<{$field_name}>" . xml_character_encode($snmp_query[$field_name]) . "</{$field_name}>\n";
            }
        }
    }
    /* XML Branch: <graphs> */
    $xml_text .= "\t<graphs>\n";
    $i = 0;
    if (sizeof($snmp_query_graph) > 0) {
        foreach ($snmp_query_graph as $item) {
            $hash["data_query_graph"] = get_hash_version("data_query_graph") . get_hash_data_query($item["id"], "data_query_graph");
            $xml_text .= "\t\t<hash_" . $hash["data_query_graph"] . ">\n";
            reset($fields_data_query_item_edit);
            while (list($field_name, $field_array) = each($fie 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_hash_host_template函数代码示例发布时间:2022-05-15
下一篇:
PHP get_hash_data_template函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap