当前位置: 首页>>代码示例>>PHP>>正文


PHP get_hash_host_template函数代码示例

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


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

示例1: form_save

function form_save()
{
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_post('host_template_id'));
    input_validate_input_number(get_request_var_post('snmp_query_id'));
    input_validate_input_number(get_request_var_post('graph_template_id'));
    /* ==================================================== */
    if (isset($_POST['save_component_template'])) {
        $redirect_back = false;
        $save['id'] = $_POST['id'];
        $save['hash'] = get_hash_host_template($_POST['id']);
        $save['name'] = form_input_validate($_POST['name'], 'name', '', false, 3);
        if (!is_error_message()) {
            $host_template_id = sql_save($save, 'host_template');
            if ($host_template_id) {
                raise_message(1);
                if (isset($_POST['add_gt_x'])) {
                    db_execute_prepared('REPLACE INTO host_template_graph (host_template_id, graph_template_id) VALUES (?, ?)', array($host_template_id, $_POST['graph_template_id']));
                    $redirect_back = true;
                } elseif (isset($_POST['add_dq_x'])) {
                    db_execute_prepared('REPLACE INTO host_template_snmp_query (host_template_id, snmp_query_id) VALUES (?, ?)', array($host_template_id, $_POST['snmp_query_id']));
                    $redirect_back = true;
                }
            } else {
                raise_message(2);
            }
        }
        header('Location: host_templates.php?action=edit&id=' . (empty($host_template_id) ? $_POST['id'] : $host_template_id));
    }
}
开发者ID:MrWnn,项目名称:cacti,代码行数:30,代码来源:host_templates.php

示例2: form_save

function form_save() {
	if (isset($_POST["save_component_template"])) {
		$redirect_back = false;

		$save["id"] = $_POST["id"];
		$save["hash"] = get_hash_host_template($_POST["id"]);
		$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);

		if (!is_error_message()) {
			$host_template_id = sql_save($save, "host_template");

			if ($host_template_id) {
				raise_message(1);

				if (isset($_POST["add_gt_x"])) {
					db_execute("replace into host_template_graph (host_template_id,graph_template_id) values($host_template_id," . $_POST["graph_template_id"] . ")");
					$redirect_back = true;
				}elseif (isset($_POST["add_dq_x"])) {
					db_execute("replace into host_template_snmp_query (host_template_id,snmp_query_id) values($host_template_id," . $_POST["snmp_query_id"] . ")");
					$redirect_back = true;
				}
			}else{
				raise_message(2);
			}
		}

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

示例3: get_hash_version

function &host_template_to_xml($host_template_id) {
	global $fields_host_template_edit;

	$hash = get_hash_version("host_template") . get_hash_host_template($host_template_id);
	$xml_text = "";

	$host_template = db_fetch_row("select * from host_template where id=$host_template_id");
	$host_template_graph = db_fetch_assoc("select * from host_template_graph where host_template_id=$host_template_id");
	$host_template_snmp_query = db_fetch_assoc("select * from host_template_snmp_query where host_template_id=$host_template_id");

	if (empty($host_template["id"])) {
		return "Invalid host template.";
	}

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

	/* XML Branch: <> */
	reset($fields_host_template_edit);
	while (list($field_name, $field_array) = each($fields_host_template_edit)) {
		if (($field_array["method"] != "hidden_zero") && ($field_array["method"] != "hidden")) {
			$xml_text .= "\t<$field_name>" . xml_character_encode($host_template{$field_name}) . "</$field_name>\n";
		}
	}

	/* XML Branch: <graph_templates> */
	$xml_text .= "\t<graph_templates>";

	$j = 0;
	if (sizeof($host_template_graph) > 0) {
	foreach ($host_template_graph as $item) {
		$xml_text .= "hash_" . get_hash_version("graph_template") . get_hash_graph_template($item["graph_template_id"]);

		if (($j+1) < sizeof($host_template_graph)) {
			$xml_text .= "|";
		}

		$j++;
	}
	}

	$xml_text .= "</graph_templates>\n";

	/* XML Branch: <data_queries> */
	$xml_text .= "\t<data_queries>";

	$j = 0;
	if (sizeof($host_template_snmp_query) > 0) {
	foreach ($host_template_snmp_query as $item) {
		$xml_text .= "hash_" . get_hash_version("data_query") . get_hash_data_query($item["snmp_query_id"]);

		if (($j+1) < sizeof($host_template_snmp_query)) {
			$xml_text .= "|";
		}

		$j++;
	}
	}

	$xml_text .= "</data_queries>\n";

	$xml_text .= "</hash_$hash>";

	return $xml_text;
}
开发者ID:songchin,项目名称:Cacti,代码行数:64,代码来源:export.php

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

示例5: duplicate_host_template

function duplicate_host_template($_host_template_id, $host_template_title) {
	global $fields_host_template_edit;

	$host_template = db_fetch_row("select * from host_template where id=$_host_template_id");
	$host_template_graphs = db_fetch_assoc("select * from host_template_graph where host_template_id=$_host_template_id");
	$host_template_data_queries = db_fetch_assoc("select * from host_template_data_query where host_template_id=$_host_template_id");

	/* substitute the title variable */
	$host_template["name"] = str_replace("<template_title>", $host_template["name"], $host_template_title);

	/* create new entry: host_template */
	$save["id"] = 0;
	$save["hash"] = get_hash_host_template(0);

	reset($fields_host_template_edit);
	while (list($field, $array) = each($fields_host_template_edit)) {
		if (!ereg("^hidden", $array["method"])) {
			$save[$field] = $host_template[$field];
		}
	}

	$host_template_id = sql_save($save, "host_template");

	/* create new entry(s): host_template_graph */
	if (sizeof($host_template_graphs) > 0) {
	foreach ($host_template_graphs as $host_template_graph) {
		db_execute("insert into host_template_graph (host_template_id,graph_template_id) values ($host_template_id," . $host_template_graph["graph_template_id"] . ")");
	}
	}

	/* create new entry(s): host_template_data_query */
	if (sizeof($host_template_data_queries) > 0) {
	foreach ($host_template_data_queries as $host_template_data_query) {
		db_execute("insert into host_template_data_query (host_template_id,data_query_id) values ($host_template_id," . $host_template_data_query["data_query_id"] . ")");
	}
	}
}
开发者ID:songchin,项目名称:Cacti,代码行数:37,代码来源:utility.php

示例6: host_template_to_xml

function host_template_to_xml($host_template_id)
{
    global $fields_host_template_edit, $export_errors;
    $hash = get_hash_version("host_template") . get_hash_host_template($host_template_id);
    $xml_text = "";
    $host_template = db_fetch_row("select * from host_template where id={$host_template_id}");
    $host_template_graph = db_fetch_assoc("select * from host_template_graph where host_template_id={$host_template_id}");
    $host_template_snmp_query = db_fetch_assoc("select * from host_template_snmp_query where host_template_id={$host_template_id}");
    if (empty($host_template["id"])) {
        $export_errors++;
        raise_message(28);
        cacti_log("ERROR: Invalid Host Template found during Export.  Please run database repair script to identify and/or correct.", false, "WEBUI");
        return;
    }
    $xml_text .= "<hash_{$hash}>\n";
    /* XML Branch: <> */
    reset($fields_host_template_edit);
    while (list($field_name, $field_array) = each($fields_host_template_edit)) {
        if ($field_array["method"] != "hidden_zero" && $field_array["method"] != "hidden") {
            $xml_text .= "\t<{$field_name}>" . xml_character_encode($host_template[$field_name]) . "</{$field_name}>\n";
        }
    }
    /* XML Branch: <graph_templates> */
    $xml_text .= "\t<graph_templates>";
    $j = 0;
    if (sizeof($host_template_graph) > 0) {
        foreach ($host_template_graph as $item) {
            $xml_text .= "hash_" . get_hash_version("graph_template") . get_hash_graph_template($item["graph_template_id"]);
            if ($j + 1 < sizeof($host_template_graph)) {
                $xml_text .= "|";
            }
            $j++;
        }
    }
    $xml_text .= "</graph_templates>\n";
    /* XML Branch: <data_queries> */
    $xml_text .= "\t<data_queries>";
    $j = 0;
    if (sizeof($host_template_snmp_query) > 0) {
        foreach ($host_template_snmp_query as $item) {
            $xml_text .= "hash_" . get_hash_version("data_query") . get_hash_data_query($item["snmp_query_id"]);
            if ($j + 1 < sizeof($host_template_snmp_query)) {
                $xml_text .= "|";
            }
            $j++;
        }
    }
    $xml_text .= "</data_queries>\n";
    $xml_text .= "</hash_{$hash}>";
    return $xml_text;
}
开发者ID:teddywen,项目名称:cacti,代码行数:51,代码来源:export.php

示例7: duplicate_host_template

function duplicate_host_template($_host_template_id, $host_template_title)
{
    global $fields_host_template_edit;
    $host_template = db_fetch_row("SELECT * FROM host_template WHERE id={$_host_template_id}");
    $host_template_graphs = db_fetch_assoc("SELECT * FROM host_template_graph WHERE host_template_id={$_host_template_id}");
    $host_template_data_queries = db_fetch_assoc("SELECT * FROM host_template_snmp_query WHERE host_template_id={$_host_template_id}");
    /* substitute the title variable */
    $host_template["name"] = str_replace("<template_title>", $host_template["name"], $host_template_title);
    /* create new entry: host_template */
    $save["id"] = 0;
    $save["hash"] = get_hash_host_template(0);
    reset($fields_host_template_edit);
    while (list($field, $array) = each($fields_host_template_edit)) {
        if (!preg_match("/^hidden/", $array["method"])) {
            $save[$field] = $host_template[$field];
        }
    }
    $host_template_id = sql_save($save, "host_template");
    /* create new entry(s): host_template_graph */
    if (sizeof($host_template_graphs) > 0) {
        foreach ($host_template_graphs as $host_template_graph) {
            db_execute("INSERT INTO host_template_graph (host_template_id,graph_template_id) VALUES ({$host_template_id}," . $host_template_graph["graph_template_id"] . ")");
        }
    }
    /* create new entry(s): host_template_snmp_query */
    if (sizeof($host_template_data_queries) > 0) {
        foreach ($host_template_data_queries as $host_template_data_query) {
            db_execute("INSERT INTO host_template_snmp_query (host_template_id,snmp_query_id) VALUES ({$host_template_id}," . $host_template_data_query["snmp_query_id"] . ")");
        }
    }
}
开发者ID:MrWnn,项目名称:cacti,代码行数:31,代码来源:utility.php


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