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

PHP get_hash_data_template函数代码示例

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

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



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

示例1: data_template_item_save

/**
 * data_template_item_save	- save data to table data_template_rrd
 */
function data_template_item_save() {
	require_once(CACTI_BASE_PATH . "/include/data_source/data_source_constants.php");

	if (isset($_POST["save_component_item"])) {
		/* ================= input validation ================= */
		input_validate_input_number(get_request_var_post("data_template_id"));
		/* ==================================================== */

		/* save: data_template_rrd */
		$save["id"] = $_POST["data_template_rrd_id"];
		$save["hash"] = get_hash_data_template($_POST["data_template_rrd_id"], "data_template_item");
		$save["local_data_template_rrd_id"] = 0;
		$save["local_data_id"] = 0;
		$save["data_template_id"] = $_POST["data_template_id"];

		$save["t_rrd_maximum"] = form_input_validate((isset($_POST["t_rrd_maximum"]) ? $_POST["t_rrd_maximum"] : ""), "t_rrd_maximum", "", true, 3);
		$save["rrd_maximum"] = form_input_validate($_POST["rrd_maximum"], "rrd_maximum", "^(-?([0-9]+(\.[0-9]*)?|[0-9]*\.[0-9]+)([eE][+\-]?[0-9]+)?)|U$", (isset($_POST["t_rrd_maximum"]) ? true : false), 3);
		$save["t_rrd_minimum"] = form_input_validate((isset($_POST["t_rrd_minimum"]) ? $_POST["t_rrd_minimum"] : ""), "t_rrd_minimum", "", true, 3);
		$save["rrd_minimum"] = form_input_validate($_POST["rrd_minimum"], "rrd_minimum", "^(-?([0-9]+(\.[0-9]*)?|[0-9]*\.[0-9]+)([eE][+\-]?[0-9]+)?)|U$", (isset($_POST["t_rrd_minimum"]) ? true : false), 3);
		$save["t_rrd_compute_rpn"] = form_input_validate((isset($_POST["t_rrd_compute_rpn"]) ? $_POST["t_rrd_compute_rpn"] : ""), "t_rrd_compute_rpn", "", true, 3);
		/* rrd_compute_rpn requires input only for COMPUTE data source type */
		$save["rrd_compute_rpn"] = form_input_validate($_POST["rrd_compute_rpn"], "rrd_compute_rpn", "", ((isset($_POST["t_rrd_compute_rpn"]) || ($_POST["data_source_type_id"] != DATA_SOURCE_TYPE_COMPUTE)) ? true : false), 3);
		$save["t_rrd_heartbeat"] = form_input_validate((isset($_POST["t_rrd_heartbeat"]) ? $_POST["t_rrd_heartbeat"] : ""), "t_rrd_heartbeat", "", true, 3);
		$save["rrd_heartbeat"] = form_input_validate($_POST["rrd_heartbeat"], "rrd_heartbeat", "^[0-9]+$", (isset($_POST["t_rrd_heartbeat"]) ? true : false), 3);
		$save["t_data_source_type_id"] = form_input_validate((isset($_POST["t_data_source_type_id"]) ? $_POST["t_data_source_type_id"] : ""), "t_data_source_type_id", "", true, 3);
		$save["data_source_type_id"] = form_input_validate($_POST["data_source_type_id"], "data_source_type_id", "", true, 3);
		$save["t_data_source_name"] = form_input_validate((isset($_POST["t_data_source_name"]) ? $_POST["t_data_source_name"] : ""), "t_data_source_name", "", true, 3);
		$save["data_source_name"] = form_input_validate($_POST["data_source_name"], "data_source_name", "^[a-zA-Z0-9_]{1,19}$", (isset($_POST["t_data_source_name"]) ? true : false), 3);
		$save["t_data_input_field_id"] = form_input_validate((isset($_POST["t_data_input_field_id"]) ? $_POST["t_data_input_field_id"] : ""), "t_data_input_field_id", "", true, 3);
		$save["data_input_field_id"] = form_input_validate((isset($_POST["data_input_field_id"]) ? $_POST["data_input_field_id"] : "0"), "data_input_field_id", "", true, 3);

		if (!is_error_message()) {

			$data_template_rrd_id = sql_save($save, "data_template_rrd");

			if ($data_template_rrd_id) {
				raise_message(1);
				push_out_data_source_item($data_template_rrd_id);
			}else{
				raise_message(2);
			}
		}

		if (is_error_message()) {
			header("Location: data_templates_items.php?action=item_edit&item_id=" . (empty($data_template_rrd_id) ? $_POST["data_template_rrd_id"] : $data_template_rrd_id) . "&id=" . $_POST["data_template_id"]);
		}else{
			header("Location: data_templates.php?action=template_edit&id=" . $_POST["data_template_id"]);
		}
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:53,代码来源:data_templates_items.php


示例2: db_fetch_assoc

    echo "NOTE: Repairing Data Templates\n";
} else {
    echo "NOTE: Performing Check of Data Templates\n";
}
$damaged_template_ids = db_fetch_assoc("SELECT DISTINCT data_template_id FROM data_template_rrd WHERE hash='' AND local_data_id=0");
if (sizeof($damaged_template_ids)) {
    foreach ($damaged_template_ids as $id) {
        $template_name = db_fetch_cell("SELECT name FROM data_template WHERE id=" . $id["data_template_id"]);
        echo "NOTE: Data Template '{$template_name}' is Damaged and can be repaired\n";
    }
    $damaged_templates = db_fetch_assoc("SELECT * FROM data_template_rrd WHERE hash='' AND local_data_id=0");
    if (sizeof($damaged_templates)) {
        echo "NOTE: -- Damaged Data Templates Objects Found is '" . sizeof($damaged_templates) . "'\n";
        if ($execute) {
            foreach ($damaged_templates as $template) {
                $hash = get_hash_data_template($template["local_data_template_rrd_id"], "data_template_item");
                db_execute("UPDATE data_template_rrd SET hash='{$hash}' WHERE id=" . $template["id"]);
            }
        }
    }
} else {
    echo "NOTE: No Damaged Data Templates Found\n";
}
/* reset the array */
$damaged_templates = array();
/* repair graph templates */
if ($execute) {
    echo "NOTE: Repairing Graph Templates\n";
} else {
    echo "NOTE: Performing Check of Graph Templates\n";
}
开发者ID:teddywen,项目名称:cacti,代码行数:31,代码来源:repair_templates.php


示例3: data_source_to_data_template

/** data_source_to_data_template - converts a data source to a data template
   @param int $local_data_id 		- the id of the data source to be converted
   @param string $data_source_title - the data source title to use for the new data template. the variable
	<ds_title> will be substituted for the current data source title */
function data_source_to_data_template($local_data_id, $data_source_title) {
	/* create a new graph template entry */
	db_execute("insert into data_template (id,name,hash) values (0,'" . str_replace("<ds_title>", db_fetch_cell("select name from data_template_data where local_data_id=$local_data_id"), $data_source_title) . "','" .  get_hash_data_template(0) . "')");
	$data_template_id = db_fetch_insert_id();

	/* update graph to point to the new template */
	db_execute("update data_template_data set local_data_id=0,local_data_template_data_id=0,data_template_id=$data_template_id where local_data_id=$local_data_id");
	db_execute("update data_template_rrd set local_data_id=0,local_data_template_rrd_id=0,data_template_id=$data_template_id where local_data_id=$local_data_id");

	/* create hashes for the data template items */
	$items = db_fetch_assoc("select id from data_template_rrd where data_template_id='$data_template_id' and local_data_id=0");
	for ($j=0; $j<count($items); $j++) {
		db_execute("update data_template_rrd set hash='" . get_hash_data_template($items[$j]["id"], "data_template_item") . "' where id=" . $items[$j]["id"]);
	}

	/* delete the old graph local entry */
	db_execute("delete from data_local where id=$local_data_id");
	db_execute("delete from poller_item where local_data_id=$local_data_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: template_rrd_add

function template_rrd_add()
{
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    input_validate_input_number(get_request_var("local_data_id"));
    /* ==================================================== */
    $hash = get_hash_data_template(0, "data_template_item");
    db_execute("insert into data_template_rrd (hash,data_template_id,rrd_maximum,rrd_minimum,rrd_heartbeat,data_source_type_id,\n\t\tdata_source_name) values ('{$hash}'," . $_GET["id"] . ",100,0,600,1,'ds')");
    $data_template_rrd_id = db_fetch_insert_id();
    /* add this data template item to each data source using this data template */
    $children = db_fetch_assoc("select local_data_id from data_template_data where data_template_id=" . $_GET["id"] . " and local_data_id>0");
    if (sizeof($children) > 0) {
        foreach ($children as $item) {
            db_execute("insert into data_template_rrd (local_data_template_rrd_id,local_data_id,data_template_id,rrd_maximum,rrd_minimum,rrd_heartbeat,data_source_type_id,\n\t\t\tdata_source_name) values ({$data_template_rrd_id}," . $item["local_data_id"] . "," . $_GET["id"] . ",100,0,600,1,'ds')");
        }
    }
    header("Location: data_templates.php?action=template_edit&id=" . $_GET["id"] . "&view_rrd={$data_template_rrd_id}");
}
开发者ID:teddywen,项目名称:cacti,代码行数:18,代码来源:data_templates.php


示例6: 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


示例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_data_source

function duplicate_data_source($_local_data_id, $_data_template_id, $data_source_title) {
	require_once(CACTI_BASE_PATH . "/lib/data_source/data_source_info.php");

	if (!empty($_local_data_id)) {
		$data_local = db_fetch_row("select * from data_local where id=$_local_data_id");
		$data_template_data = db_fetch_row("select * from data_template_data where local_data_id=$_local_data_id");
		$data_template_rrds = db_fetch_assoc("select * from data_template_rrd where local_data_id=$_local_data_id");

		$data_input_datas = db_fetch_assoc("select * from data_input_data where data_template_data_id=" . $data_template_data["id"]);
		$data_template_data_rras = db_fetch_assoc("select * from data_template_data_rra where data_template_data_id=" . $data_template_data["id"]);

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

		$local_data_id = sql_save($save, "data_local");

		$data_template_data["name"] = str_replace(__("<ds_title>"), $data_template_data["name"], $data_source_title);
	}elseif (!empty($_data_template_id)) {
		$data_template = db_fetch_row("select * from data_template where id=$_data_template_id");
		$data_template_data = db_fetch_row("select * from data_template_data where data_template_id=$_data_template_id and local_data_id=0");
		$data_template_rrds = db_fetch_assoc("select * from data_template_rrd where data_template_id=$_data_template_id and local_data_id=0");

		$data_input_datas = db_fetch_assoc("select * from data_input_data where data_template_data_id=" . $data_template_data["id"]);
		$data_template_data_rras = db_fetch_assoc("select * from data_template_data_rra where data_template_data_id=" . $data_template_data["id"]);

		/* create new entry: data_template */
		$save["id"] = 0;
		$save["hash"] = get_hash_data_template(0);
		$save["name"] = str_replace(__("<template_title>"), $data_template["name"], $data_source_title);

		$data_template_id = sql_save($save, "data_template");
	}

	unset($save);
	$struct_data_source = data_source_form_list();
	unset($struct_data_source["rra_id"]);
	unset($struct_data_source["data_source_path"]);
	reset($struct_data_source);

	/* create new entry: data_template_data */
	$save["id"] = 0;
	$save["local_data_id"] = (isset($local_data_id) ? $local_data_id : 0);
	$save["local_data_template_data_id"] = (isset($data_template_data["local_data_template_data_id"]) ? $data_template_data["local_data_template_data_id"] : 0);
	$save["data_template_id"] = (!empty($_local_data_id) ? $data_template_data["data_template_id"] : $data_template_id);
	$save["name_cache"] = $data_template_data["name_cache"];

	while (list($field, $array) = each($struct_data_source)) {
		$save{$field} = $data_template_data{$field};

		if ($array["flags"] != "ALWAYSTEMPLATE") {
			$save{"t_" . $field} = $data_template_data{"t_" . $field};
		}
	}

	$data_template_data_id = sql_save($save, "data_template_data");

	/* create new entry(s): data_template_rrd */
	if (sizeof($data_template_rrds) > 0) {
		$struct_data_source_item = data_source_item_form_list();
		foreach ($data_template_rrds as $data_template_rrd) {
			unset($save);
			reset($struct_data_source_item);

			$save["id"]                         = 0;
			$save["local_data_id"]              = (isset($local_data_id) ? $local_data_id : 0);
			$save["local_data_template_rrd_id"] = (isset($data_template_rrd["local_data_template_rrd_id"]) ? $data_template_rrd["local_data_template_rrd_id"] : 0);
			$save["data_template_id"]           = (!empty($_local_data_id) ? $data_template_rrd["data_template_id"] : $data_template_id);
			if ($save["local_data_id"] == 0) {
				$save["hash"]                   = get_hash_data_template($data_template_rrd["local_data_template_rrd_id"], "data_template_item");
			} else {
				$save["hash"] = '';
			}

			while (list($field, $array) = each($struct_data_source_item)) {
				$save{$field} = $data_template_rrd{$field};
			}

			$data_template_rrd_id = sql_save($save, "data_template_rrd");
		}
	}

	/* create new entry(s): data_input_data */
	if (sizeof($data_input_datas) > 0) {
	foreach ($data_input_datas as $data_input_data) {
		db_execute("insert into data_input_data (data_input_field_id,data_template_data_id,t_value,value) values
			(" . $data_input_data["data_input_field_id"] . ",$data_template_data_id,'" . $data_input_data["t_value"] .
			"','" . $data_input_data["value"] . "')");
	}
	}

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


示例9: 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($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";
            $j = 0;
            if (sizeof($snmp_query_graph_rrd_sv) > 0) {
                foreach ($snmp_query_graph_rrd_sv as $item2) {
                    $hash["data_query_sv_data_source"] = get_hash_version("data_query_sv_data_source") . get_hash_data_query($item2["id"], "data_query_sv_data_source");
                    $xml_text .= "\t\t\t\t<hash_" . $hash["data_query_sv_data_source"] . ">\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<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<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_data_source"] . ">\n";
                    $j++;
                }
            }
            $xml_text .= "\t\t\t</sv_data_source>\n";
            $xml_text .= "\t\t</hash_" . $hash["data_query_graph"] . ">\n";
            $i++;
        }
    }
    $xml_text .= "\t</graphs>\n";
    $xml_text .= "</hash_" . $hash["data_query"] . ">";
    return $xml_text;
}
开发者ID:teddywen,项目名称:cacti,代码行数:98,代码来源:export.php


示例10: duplicate_data_source

function duplicate_data_source($_local_data_id, $_data_template_id, $data_source_title)
{
    global $struct_data_source, $struct_data_source_item;
    if (!empty($_local_data_id)) {
        $data_local = db_fetch_row("select * from data_local where id={$_local_data_id}");
        $data_template_data = db_fetch_row("select * from data_template_data where local_data_id={$_local_data_id}");
        $data_template_rrds = db_fetch_assoc("select * from data_template_rrd where local_data_id={$_local_data_id}");
        $data_input_datas = db_fetch_assoc("select * from data_input_data where data_template_data_id=" . $data_template_data["id"]);
        $data_template_data_rras = db_fetch_assoc("select * from data_template_data_rra where data_template_data_id=" . $data_template_data["id"]);
        /* create new entry: data_local */
        $save["id"] = 0;
        $save["data_template_id"] = $data_local["data_template_id"];
        $save["host_id"] = $data_local["host_id"];
        $save["snmp_query_id"] = $data_local["snmp_query_id"];
        $save["snmp_index"] = $data_local["snmp_index"];
        $local_data_id = sql_save($save, "data_local");
        $data_template_data["name"] = str_replace("<ds_title>", $data_template_data["name"], $data_source_title);
    } elseif (!empty($_data_template_id)) {
        $data_template = db_fetch_row("select * from data_template where id={$_data_template_id}");
        $data_template_data = db_fetch_row("select * from data_template_data where data_template_id={$_data_template_id} and local_data_id=0");
        $data_template_rrds = db_fetch_assoc("select * from data_template_rrd where data_template_id={$_data_template_id} and local_data_id=0");
        $data_input_datas = db_fetch_assoc("select * from data_input_data where data_template_data_id=" . $data_template_data["id"]);
        $data_template_data_rras = db_fetch_assoc("select * from data_template_data_rra where data_template_data_id=" . $data_template_data["id"]);
        /* create new entry: data_template */
        $save["id"] = 0;
        $save["hash"] = get_hash_data_template(0);
        $save["name"] = str_replace("<template_title>", $data_template["name"], $data_source_title);
        $data_template_id = sql_save($save, "data_template");
    }
    unset($save);
    unset($struct_data_source["rra_id"]);
    unset($struct_data_source["data_source_path"]);
    reset($struct_data_source);
    /* create new entry: data_template_data */
    $save["id"] = 0;
    $save["local_data_id"] = isset($local_data_id) ? $local_data_id : 0;
    $save["local_data_template_data_id"] = isset($data_template_data["local_data_template_data_id"]) ? $data_template_data["local_data_template_data_id"] : 0;
    $save["data_template_id"] = !empty($_local_data_id) ? $data_template_data["data_template_id"] : $data_template_id;
    $save["name_cache"] = $data_template_data["name_cache"];
    while (list($field, $array) = each($struct_data_source)) {
        $save[$field] = $data_template_data[$field];
        if ($array["flags"] != "ALWAYSTEMPLATE") {
            $save["t_" . $field] = $data_template_data["t_" . $field];
        }
    }
    $data_template_data_id = sql_save($save, "data_template_data");
    /* create new entry(s): data_template_rrd */
    if (sizeof($data_template_rrds) > 0) {
        foreach ($data_template_rrds as $data_template_rrd) {
            unset($save);
            reset($struct_data_source_item);
            $save["id"] = 0;
            $save["local_data_id"] = isset($local_data_id) ? $local_data_id : 0;
            $save["local_data_template_rrd_id"] = isset($data_template_rrd["local_data_template_rrd_id"]) ? $data_template_rrd["local_data_template_rrd_id"] : 0;
            $save["data_template_id"] = !empty($_local_data_id) ? $data_template_rrd["data_template_id"] : $data_template_id;
            if ($save["local_data_id"] == 0) {
                $save["hash"] = get_hash_data_template($data_template_rrd["local_data_template_rrd_id"], "data_template_item");
            } else {
                $save["hash"] = '';
            }
            while (list($field, $array) = each($struct_data_source_item)) {
                $save[$field] = $data_template_rrd[$field];
            }
            $data_template_rrd_id = sql_save($save, "data_template_rrd");
        }
    }
    /* create new entry(s): data_input_data */
    if (sizeof($data_input_datas) > 0) {
        foreach ($data_input_datas as $data_input_data) {
            db_execute("insert into data_input_data (data_input_field_id,data_template_data_id,t_value,value) values\n\t\t\t(" . $data_input_data["data_input_field_id"] . ",{$data_template_data_id},'" . $data_input_data["t_value"] . "','" . $data_input_data["value"] . "')");
        }
    }
    /* create new entry(s): data_template_data_rra */
    if (sizeof($data_template_data_rras) > 0) {
        foreach ($data_template_data_rras as $data_template_data_rra) {
            db_execute("insert into data_template_data_rra (data_template_data_id,rra_id) values ({$data_template_data_id},\n\t\t\t" . $data_template_data_rra["rra_id"] . ")");
        }
    }
    if (!empty($_local_data_id)) {
        update_data_source_title_cache($local_data_id);
    }
}
开发者ID:songchin,项目名称:Cacti,代码行数:82,代码来源:utility.php


示例11: template_rrd_add


                      

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP get_hash_graph_template函数代码示例发布时间:2022-05-15
下一篇:
PHP get_hash_data_query函数代码示例发布时间: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