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

PHP get_hash_data_query函数代码示例

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

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



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

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


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


示例3: form_save

function form_save() {
	if (isset($_POST["save_component_snmp_query"])) {
		$save["id"] = $_POST["id"];
		$save["hash"] = get_hash_data_query($_POST["id"]);
		$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
		$save["description"] = form_input_validate($_POST["description"], "description", "", true, 3);
		$save["xml_path"] = form_input_validate($_POST["xml_path"], "xml_path", "", false, 3);
		$save["data_input_id"] = $_POST["data_input_id"];

		if (!is_error_message()) {
			$snmp_query_id = sql_save($save, "snmp_query");

			if ($snmp_query_id) {
				raise_message(1);
			}else{
				raise_message(2);
			}
		}

		if ((is_error_message()) || (empty($_POST["id"]))) {
			header("Location: data_queries.php?action=edit&id=" . (empty($snmp_query_id) ? $_POST["id"] : $snmp_query_id));
		}else{
			header("Location: data_queries.php");
		}
	}elseif (isset($_POST["save_component_snmp_query_item"])) {
		$redirect_back = false;

		$save["id"] = $_POST["id"];
		$save["hash"] = get_hash_data_query($_POST["id"], "data_query_graph");
		$save["snmp_query_id"] = $_POST["snmp_query_id"];
		$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
		$save["graph_template_id"] = $_POST["graph_template_id"];

		if (!is_error_message()) {
			$snmp_query_graph_id = sql_save($save, "snmp_query_graph");

			if ($snmp_query_graph_id) {
				raise_message(1);

				/* if the user changed the graph template, go through and delete everything that
				was associated with the old graph template */
				if ($_POST["graph_template_id"] != $_POST["_graph_template_id"]) {
					db_execute("delete from snmp_query_graph_rrd_sv where snmp_query_graph_id=$snmp_query_graph_id");
					db_execute("delete from snmp_query_graph_sv where snmp_query_graph_id=$snmp_query_graph_id");
					$redirect_back = true;
				}

				db_execute("delete from snmp_query_graph_rrd where snmp_query_graph_id=$snmp_query_graph_id");

				while (list($var, $val) = each($_POST)) {
					if (eregi("^dsdt_([0-9]+)_([0-9]+)_check", $var)) {
						$data_template_id = ereg_replace("^dsdt_([0-9]+)_([0-9]+).+", "\\1", $var);
						$data_template_rrd_id = ereg_replace("^dsdt_([0-9]+)_([0-9]+).+", "\\2", $var);

						db_execute ("replace into snmp_query_graph_rrd (snmp_query_graph_id,data_template_id,data_template_rrd_id,snmp_field_name) values($snmp_query_graph_id,$data_template_id,$data_template_rrd_id,'" . $_POST{"dsdt_" . $data_template_id . "_" . $data_template_rrd_id . "_snmp_field_output"} . "')");
					}elseif ((eregi("^svds_([0-9]+)_x", $var, $matches)) && (!empty($_POST{"svds_" . $matches[1] . "_text"})) && (!empty($_POST{"svds_" . $matches[1] . "_field"}))) {
						/* suggested values -- data templates */
						$sequence = get_sequence(0, "sequence", "snmp_query_graph_rrd_sv", "snmp_query_graph_id=" . $_POST["id"]  . " and data_template_id=" . $matches[1] . " and field_name='" . $_POST{"svds_" . $matches[1] . "_field"} . "'");
						$hash = get_hash_data_query(0, "data_query_sv_data_source");
						db_execute("insert into snmp_query_graph_rrd_sv (hash,snmp_query_graph_id,data_template_id,sequence,field_name,text) values ('$hash'," . $_POST["id"] . "," . $matches[1] . ",$sequence,'" . $_POST{"svds_" . $matches[1] . "_field"} . "','" . $_POST{"svds_" . $matches[1] . "_text"} . "')");

						$redirect_back = true;
						clear_messages();
					}elseif ((eregi("^svg_x", $var)) && (!empty($_POST{"svg_text"})) && (!empty($_POST{"svg_field"}))) {
						/* suggested values -- graph templates */
						$sequence = get_sequence(0, "sequence", "snmp_query_graph_sv", "snmp_query_graph_id=" . $_POST["id"] . " and field_name='" . $_POST{"svg_field"} . "'");
						$hash = get_hash_data_query(0, "data_query_sv_graph");
						db_execute("insert into snmp_query_graph_sv (hash,snmp_query_graph_id,sequence,field_name,text) values ('$hash'," . $_POST["id"] . ",$sequence,'" . $_POST{"svg_field"} . "','" . $_POST{"svg_text"} . "')");

						$redirect_back = true;
						clear_messages();
					}
				}
			}else{
				raise_message(2);
			}
		}

		if ((is_error_message()) || (empty($_POST["id"])) || ($redirect_back == true)) {
			header("Location: data_queries.php?action=item_edit&id=" . (empty($snmp_query_graph_id) ? $_POST["id"] : $snmp_query_graph_id) . "&snmp_query_id=" . $_POST["snmp_query_id"]);
		}else{
			header("Location: data_queries.php?action=edit&id=" . $_POST["snmp_query_id"]);
		}
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:85,代码来源:data_queries.php


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


示例5: form_save

function form_save()
{
    if (isset($_POST['save_component_snmp_query'])) {
        $save['id'] = $_POST['id'];
        $save['hash'] = get_hash_data_query($_POST['id']);
        $save['name'] = form_input_validate($_POST['name'], 'name', '', false, 3);
        $save['description'] = form_input_validate($_POST['description'], 'description', '', true, 3);
        $save['xml_path'] = form_input_validate($_POST['xml_path'], 'xml_path', '', false, 3);
        $save['data_input_id'] = $_POST['data_input_id'];
        if (!is_error_message()) {
            $snmp_query_id = sql_save($save, 'snmp_query');
            if ($snmp_query_id) {
                raise_message(1);
            } else {
                raise_message(2);
            }
        }
        header('Location: data_queries.php?action=edit&id=' . (empty($snmp_query_id) ? $_POST['id'] : $snmp_query_id));
    } elseif (isset($_POST['save_component_snmp_query_item'])) {
        /* ================= input validation ================= */
        input_validate_input_number(get_request_var_post('id'));
        /* ==================================================== */
        $redirect_back = false;
        $save['id'] = $_POST['id'];
        $save['hash'] = get_hash_data_query($_POST['id'], 'data_query_graph');
        $save['snmp_query_id'] = $_POST['snmp_query_id'];
        $save['name'] = form_input_validate($_POST['name'], 'name', '', false, 3);
        $save['graph_template_id'] = $_POST['graph_template_id'];
        if (!is_error_message()) {
            $snmp_query_graph_id = sql_save($save, 'snmp_query_graph');
            if ($snmp_query_graph_id) {
                raise_message(1);
                /* if the user changed the graph template, go through and delete everything that
                			was associated with the old graph template */
                if ($_POST['graph_template_id'] != $_POST['_graph_template_id']) {
                    db_execute_prepared('DELETE FROM snmp_query_graph_rrd_sv WHERE snmp_query_graph_id = ?', array($snmp_query_graph_id));
                    db_execute_prepared('DELETE FROM snmp_query_graph_sv WHERE snmp_query_graph_id = ?', array($snmp_query_graph_id));
                    $redirect_back = true;
                }
                db_execute_prepared('DELETE FROM snmp_query_graph_rrd WHERE snmp_query_graph_id = ?', array($snmp_query_graph_id));
                while (list($var, $val) = each($_POST)) {
                    if (preg_match('/^dsdt_([0-9]+)_([0-9]+)_check/i', $var)) {
                        $data_template_id = preg_replace('/^dsdt_([0-9]+)_([0-9]+).+/', "\\1", $var);
                        $data_template_rrd_id = preg_replace('/^dsdt_([0-9]+)_([0-9]+).+/', "\\2", $var);
                        db_execute_prepared('REPLACE INTO snmp_query_graph_rrd (snmp_query_graph_id, data_template_id, data_template_rrd_id, snmp_field_name) VALUES (?, ?, ?, ?)', array($snmp_query_graph_id, $data_template_id, $data_template_rrd_id, $_POST['dsdt_' . $data_template_id . '_' . $data_template_rrd_id . '_snmp_field_output']));
                    } elseif (preg_match('/^svds_([0-9]+)_x/i', $var, $matches) && !empty($_POST['svds_' . $matches[1] . '_text']) && !empty($_POST['svds_' . $matches[1] . '_field'])) {
                        /* suggested values -- data templates */
                        $sequence = get_sequence(0, 'sequence', 'snmp_query_graph_rrd_sv', 'snmp_query_graph_id=' . $_POST['id'] . ' AND data_template_id=' . $matches[1] . " AND field_name='" . $_POST['svds_' . $matches[1] . '_field'] . "'");
                        $hash = get_hash_data_query(0, 'data_query_sv_data_source');
                        db_execute_prepared('INSERT INTO snmp_query_graph_rrd_sv (hash, snmp_query_graph_id, data_template_id, sequence, field_name, text) VALUES (?, ?, ?, ?, ?, ?)', array($hash, $_POST['id'], $matches[1], $sequence, $_POST['svds_' . $matches[1] . '_field'], $_POST['svds_' . $matches[1] . '_text']));
                        $redirect_back = true;
                        clear_messages();
                    } elseif (preg_match('/^svg_x/i', $var) && !empty($_POST['svg_text']) && !empty($_POST['svg_field'])) {
                        /* suggested values -- graph templates */
                        $sequence = get_sequence(0, 'sequence', 'snmp_query_graph_sv', 'snmp_query_graph_id=' . $_POST['id'] . " AND field_name='" . $_POST['svg_field'] . "'");
                        $hash = get_hash_data_query(0, 'data_query_sv_graph');
                        db_execute_prepared('INSERT INTO snmp_query_graph_sv (hash, snmp_query_graph_id, sequence, field_name, text) VALUES (?, ?, ?, ?, ?)', array($hash, $_POST['id'], $sequence, $_POST['svg_field'], $_POST['svg_text']));
                        $redirect_back = true;
                        clear_messages();
                    }
                }
                if (isset($_POST['header']) && $_POST['header'] == 'false') {
                    $header = '&header=false';
                } else {
                    $header = '';
                }
            } else {
                raise_message(2);
                $header = '';
            }
        }
        header('Location: data_queries.php?action=item_edit' . $header . '&id=' . (empty($snmp_query_graph_id) ? $_POST['id'] : $snmp_query_graph_id) . '&snmp_query_id=' . $_POST['snmp_query_id']);
    }
}
开发者ID:MrWnn,项目名称:cacti,代码行数:74,代码来源:data_queries.php


示例6: form_save

function form_save()
{
    global $cnn_id;
    if (isset($_POST["save_component_snmp_query"])) {
        input_validate_input_number(get_request_var_post("id"));
        input_validate_input_number(get_request_var_post("data_input_id"));
        $save["id"] = $_POST["id"];
        $save["hash"] = get_hash_data_query($_POST["id"]);
        $save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
        $save["description"] = form_input_validate($_POST["description"], "description", "", true, 3);
        $save["xml_path"] = form_input_validate($_POST["xml_path"], "xml_path", "", false, 3);
        $save["data_input_id"] = $_POST["data_input_id"];
        if (!is_error_message()) {
            $snmp_query_id = sql_save($save, "snmp_query");
            if ($snmp_query_id) {
                raise_message(1);
            } else {
                raise_message(2);
            }
        }
        header("Location: data_queries.php?action=edit&id=" . (empty($snmp_query_id) ? $_POST["id"] : $snmp_query_id));
    } elseif (isset($_POST["save_component_snmp_query_item"])) {
        /* ================= input validation ================= */
        input_validate_input_number(get_request_var_post("id"));
        input_validate_input_number(get_request_var_post("snmp_query_id"));
        input_validate_input_number(get_request_var_post("graph_template_id"));
        /* ==================================================== */
        $redirect_back = false;
        $save["id"] = $_POST["id"];
        $save["hash"] = get_hash_data_query($_POST["id"], "data_query_graph");
        $save["snmp_query_id"] = $_POST["snmp_query_id"];
        $save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
        $save["graph_template_id"] = $_POST["graph_template_id"];
        if (!is_error_message()) {
            $snmp_query_graph_id = sql_save($save, "snmp_query_graph");
            if ($snmp_query_graph_id) {
                raise_message(1);
                /* if the user changed the graph template, go through and delete everything that
                			was associated with the old graph template */
                if ($_POST["graph_template_id"] != $_POST["_graph_template_id"]) {
                    db_execute("delete from snmp_query_graph_rrd_sv where snmp_query_graph_id={$snmp_query_graph_id}");
                    db_execute("delete from snmp_query_graph_sv where snmp_query_graph_id={$snmp_query_graph_id}");
                    $redirect_back = true;
                }
                db_execute("delete from snmp_query_graph_rrd where snmp_query_graph_id={$snmp_query_graph_id}");
                while (list($var, $val) = each($_POST)) {
                    if (preg_match("/^dsdt_([0-9]+)_([0-9]+)_check/i", $var)) {
                        $data_template_id = preg_replace("/^dsdt_([0-9]+)_([0-9]+).+/", "\\1", $var);
                        $data_template_rrd_id = preg_replace("/^dsdt_([0-9]+)_([0-9]+).+/", "\\2", $var);
                        /* ================= input validation ================= */
                        input_validate_input_number($data_template_id);
                        input_validate_input_number($data_template_rrd_id);
                        /* ==================================================== */
                        db_execute("replace into snmp_query_graph_rrd (snmp_query_graph_id,data_template_id,data_template_rrd_id,snmp_field_name) values({$snmp_query_graph_id},{$data_template_id},{$data_template_rrd_id}," . $cnn_id->qstr($_POST["dsdt_" . $data_template_id . "_" . $data_template_rrd_id . "_snmp_field_output"]) . ")");
                    } elseif (preg_match("/^svds_([0-9]+)_x/i", $var, $matches) && !empty($_POST["svds_" . $matches[1] . "_text"]) && !empty($_POST["svds_" . $matches[1] . "_field"])) {
                        /* suggested values -- data templates */
                        /* ================= input validation ================= */
                        input_validate_input_number($matches[1]);
                        /* ==================================================== */
                        $sequence = get_sequence(0, "sequence", "snmp_query_graph_rrd_sv", "snmp_query_graph_id=" . $_POST["id"] . " and data_template_id=" . $matches[1] . " and field_name=" . $cnn_id->qstr($_POST["svds_" . $matches[1] . "_field"]));
                        $hash = get_hash_data_query(0, "data_query_sv_data_source");
                        db_execute("insert into snmp_query_graph_rrd_sv (hash,snmp_query_graph_id,data_template_id,sequence,field_name,text) values ('{$hash}'," . $_POST["id"] . "," . $matches[1] . ",{$sequence}," . $cnn_id->qstr($_POST["svds_" . $matches[1] . "_field"]) . "," . $cnn_id->qstr($_POST["svds_" . $matches[1] . "_text"]) . ")");
                        $redirect_back = true;
                        clear_messages();
                    } elseif (preg_match("/^svg_x/i", $var) && !empty($_POST["svg_text"]) && !empty($_POST["svg_field"])) {
                        /* suggested values -- graph templates */
                        $sequence = get_sequence(0, "sequence", "snmp_query_graph_sv", "snmp_query_graph_id=" . $_POST["id"] . " and field_name=" . $cnn_id->qstr($_POST["svg_field"]));
                        $hash = get_hash_data_query(0, "data_query_sv_graph");
                        db_execute("insert into snmp_query_graph_sv (hash,snmp_query_graph_id,sequence,field_name,text) values ('{$hash}'," . $_POST["id"] . ",{$sequence}," . $cnn_id->qstr($_POST["svg_field"]) . "," . $cnn_id->qstr($_POST["svg_text"]) . ")");
                        $redirect_back = true;
                        clear_messages();
                    }
                }
            } else {
                raise_message(2);
            }
        }
        header("Location: data_queries.php?action=item_edit&id=" . (empty($snmp_query_graph_id) ? $_POST["id"] : $snmp_query_graph_id) . "&snmp_query_id=" . $_POST["snmp_query_id"]);
    }
}
开发者ID:teddywen,项目名称:cacti,代码行数:80,代码来源:data_queries.php



注:本文中的get_hash_data_query函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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