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

PHP inject_form_variables函数代码示例

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

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



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

示例1: inject_form_variables

function inject_form_variables(&$form_array, $arg1 = array(), $arg2 = array(), $arg3 = array(), $arg4 = array()) {
	$check_fields = array("value", "array", "friendly_name", "description", "sql", "sql_print", "form_id", "items");

	/* loop through each available field */
	while (list($field_name, $field_array) = each($form_array)) {
		/* loop through each sub-field that we are going to check for variables */
		foreach ($check_fields as $field_to_check) {
			if (isset($field_array[$field_to_check]) && (is_array($form_array[$field_name][$field_to_check]))) {
				/* if the field/sub-field combination is an array, resolve it recursively */
				$form_array[$field_name][$field_to_check] = inject_form_variables($form_array[$field_name][$field_to_check], $arg1);
			}elseif (isset($field_array[$field_to_check]) && (!is_array($field_array[$field_to_check])) && (ereg("\|(arg[123]):([a-zA-Z0-9_]*)\|", $field_array[$field_to_check], $matches))) {
				/* an empty field name in the variable means don't treat this as an array */
				if ($matches[2] == "") {
					if (is_array(${$matches[1]})) {
						/* the existing value is already an array, leave it alone */
						$form_array[$field_name][$field_to_check] = ${$matches[1]};
					}else{
						/* the existing value is probably a single variable */
						$form_array[$field_name][$field_to_check] = str_replace($matches[0], ${$matches[1]}, $field_array[$field_to_check]);
					}
				}else{
					/* copy the value down from the array/key specified in the variable */
					$form_array[$field_name][$field_to_check] = str_replace($matches[0], ((isset(${$matches[1]}{$matches[2]})) ? ${$matches[1]}{$matches[2]} : ""), $field_array[$field_to_check]);
				}
			}
		}
	}

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


示例2: syslog_action_edit

function syslog_action_edit()
{
    global $colors, $message_types, $syslog_freqs, $syslog_times;
    include dirname(__FILE__) . "/config.php";
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    input_validate_input_number(get_request_var("type"));
    /* ==================================================== */
    if (isset($_GET["id"])) {
        $report = syslog_db_fetch_row("SELECT *\n\t\t\tFROM `" . $syslogdb_default . "`.`syslog_reports`\n\t\t\tWHERE id=" . $_GET["id"]);
        $header_label = "[edit: " . $report["name"] . "]";
    } else {
        $header_label = "[new]";
        $report["name"] = "New Report Record";
    }
    html_start_box("<strong>Report Edit</strong> {$header_label}", "100%", $colors["header"], "3", "center", "");
    $fields_syslog_report_edit = array("spacer0" => array("method" => "spacer", "friendly_name" => "Report Details"), "name" => array("method" => "textbox", "friendly_name" => "Report Name", "description" => "Please describe this Report.", "value" => "|arg1:name|", "max_length" => "250"), "enabled" => array("method" => "drop_array", "friendly_name" => "Enabled?", "description" => "Is this Report Enabled?", "value" => "|arg1:enabled|", "array" => array("on" => "Enabled", "" => "Disabled"), "default" => "on"), "type" => array("method" => "drop_array", "friendly_name" => "String Match Type", "description" => "Define how you would like this string matched.", "value" => "|arg1:type|", "array" => $message_types, "default" => "matchesc"), "message" => array("method" => "textbox", "friendly_name" => "Syslog Message Match String", "description" => "The matching component of the syslog message.", "value" => "|arg1:message|", "default" => "", "max_length" => "255"), "timespan" => array("method" => "drop_array", "friendly_name" => "Report Frequency", "description" => "How often should this Report be sent to the distribution list?", "value" => "|arg1:timespan|", "array" => $syslog_freqs, "default" => "del"), "timepart" => array("method" => "drop_array", "friendly_name" => "Send Time", "description" => "What time of day should this report be sent?", "value" => "|arg1:timepart|", "array" => $syslog_times, "default" => "del"), "message" => array("friendly_name" => "Syslog Message Match String", "description" => "The matching component of the syslog message.", "method" => "textbox", "max_length" => "255", "value" => "|arg1:message|", "default" => ""), "body" => array("friendly_name" => "Report Body Text", "textarea_rows" => "5", "textarea_cols" => "60", "description" => "The information that will be contained in the body of the report.", "method" => "textarea", "class" => "textAreaNotes", "value" => "|arg1:body|", "default" => ""), "email" => array("friendly_name" => "Report e-mail Addresses", "textarea_rows" => "3", "textarea_cols" => "60", "description" => "Comma delimited list of e-mail addresses to send the report to.", "method" => "textarea", "class" => "textAreaNotes", "value" => "|arg1:email|", "default" => ""), "notes" => array("friendly_name" => "Report Notes", "textarea_rows" => "3", "textarea_cols" => "60", "description" => "Space for Notes on the Report", "method" => "textarea", "class" => "textAreaNotes", "value" => "|arg1:notes|", "default" => ""), "id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "_id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "save_component_report" => array("method" => "hidden", "value" => "1"));
    draw_edit_form(array("config" => array("form_name" => "chk"), "fields" => inject_form_variables($fields_syslog_report_edit, isset($report) ? $report : array())));
    html_end_box();
    form_save_button("syslog_reports.php", "", "id");
}
开发者ID:khoimt,项目名称:cacti-sample,代码行数:21,代码来源:syslog_reports.php


示例3: template_edit

function template_edit()
{
    global $struct_data_source, $struct_data_source_item, $data_source_types, $fields_data_template_template_edit;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    input_validate_input_number(get_request_var("view_rrd"));
    /* ==================================================== */
    if (!empty($_GET["id"])) {
        $template_data = db_fetch_row("select * from data_template_data where data_template_id=" . $_GET["id"] . " and local_data_id=0");
        $template = db_fetch_row("select * from data_template where id=" . $_GET["id"]);
        $header_label = "[edit: " . $template["name"] . "]";
    } else {
        $header_label = "[new]";
    }
    html_start_box("<strong>Data Templates</strong> " . htmlspecialchars($header_label), "100%", "", "3", "center", "");
    draw_edit_form(array("config" => array(), "fields" => inject_form_variables($fields_data_template_template_edit, isset($template) ? $template : array(), isset($template_data) ? $template_data : array(), $_GET)));
    html_end_box();
    html_start_box("<strong>Data Source</strong>", "100%", "", "3", "center", "");
    /* make sure 'data source path' doesn't show up for a template... we should NEVER template this field */
    unset($struct_data_source["data_source_path"]);
    $form_array = array();
    while (list($field_name, $field_array) = each($struct_data_source)) {
        $form_array += array($field_name => $struct_data_source[$field_name]);
        if ($field_array["flags"] == "ALWAYSTEMPLATE") {
            $form_array[$field_name]["description"] = "<em>This field is always templated.</em>";
        } else {
            $form_array[$field_name]["description"] = "";
            $form_array[$field_name]["sub_checkbox"] = array("name" => "t_" . $field_name, "friendly_name" => "Use Per-Data Source Value (Ignore this Value)", "value" => isset($template_data["t_" . $field_name]) ? $template_data["t_" . $field_name] : "");
        }
        $form_array[$field_name]["value"] = isset($template_data[$field_name]) ? $template_data[$field_name] : "";
        $form_array[$field_name]["form_id"] = isset($template_data) ? $template_data["data_template_id"] : "0";
    }
    draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => inject_form_variables($form_array, isset($template_data) ? $template_data : array())));
    html_end_box();
    /* fetch ALL rrd's for this data source */
    if (!empty($_GET["id"])) {
        $template_data_rrds = db_fetch_assoc("select id,data_source_name from data_template_rrd where data_template_id=" . $_GET["id"] . " and local_data_id=0 order by data_source_name");
    }
    /* select the first "rrd" of this data source by default */
    if (empty($_GET["view_rrd"])) {
        $_GET["view_rrd"] = isset($template_data_rrds[0]["id"]) ? $template_data_rrds[0]["id"] : "0";
    }
    /* get more information about the rrd we chose */
    if (!empty($_GET["view_rrd"])) {
        $template_rrd = db_fetch_row("select * from data_template_rrd where id=" . $_GET["view_rrd"]);
    }
    $i = 0;
    if (isset($template_data_rrds)) {
        if (sizeof($template_data_rrds) > 1) {
            /* draw the data source tabs on the top of the page */
            print "\t<table class='tabs' width='100%' cellspacing='0' cellpadding='3' align='center'>\n\t\t\t\t<tr>\n";
            foreach ($template_data_rrds as $template_data_rrd) {
                $i++;
                print "\t<td " . ($template_data_rrd["id"] == $_GET["view_rrd"] ? "class='tabSelected tab'" : "class='tabNotSelected tab'") . " width='" . (strlen($template_data_rrd["data_source_name"]) * 9 + 50) . "' align='center'>\n\t\t\t\t\t\t\t<span class='textHeader'><a href='" . htmlspecialchars("data_templates.php?action=template_edit&id=" . $_GET["id"] . "&view_rrd=" . $template_data_rrd["id"]) . "'>{$i}: " . htmlspecialchars($template_data_rrd["data_source_name"]) . "</a> <a href='" . htmlspecialchars("data_templates.php?action=rrd_remove&id=" . $template_data_rrd["id"] . "&data_template_id=" . $_GET["id"]) . "'><img src='images/delete_icon.gif' border='0' alt='Delete'></a></span>\n\t\t\t\t\t\t</td>\n\n\t\t\t\t\t\t<td width='1'></td>\n";
            }
            print "\n\t\t\t\t<td></td>\n\n\t\t\t\t</tr>\n\t\t\t</table>\n";
        } elseif (sizeof($template_data_rrds) == 1) {
            $_GET["view_rrd"] = $template_data_rrds[0]["id"];
        }
    }
    html_start_box("", "100%", "", "3", "center", "");
    print "\t<tr class='cactiTableTitle'>\n\t\t\t<td class='textHeaderDark'>\n\t\t\t\t<strong>Data Source Item</strong> [" . (isset($template_rrd) ? htmlspecialchars($template_rrd["data_source_name"]) : "") . "]\n\t\t\t</td>\n\t\t\t<td class='textHeaderDark' align='right'>\n\t\t\t\t" . (!empty($_GET["id"]) ? "<strong><a class='linkOverDark' href='" . htmlspecialchars("data_templates.php?action=rrd_add&id=" . $_GET["id"]) . "'>New</a>&nbsp;</strong>" : "") . "\n\t\t\t</td>\n\t\t</tr>\n";
    /* data input fields list */
    if (empty($template_data["data_input_id"]) || db_fetch_cell("select type_id from data_input where id=" . $template_data["data_input_id"]) != "1" && db_fetch_cell("select type_id from data_input where id=" . $template_data["data_input_id"]) != "5") {
        unset($struct_data_source_item["data_input_field_id"]);
    } else {
        $struct_data_source_item["data_input_field_id"]["sql"] = "select id,CONCAT(data_name,' - ',name) as name from data_input_fields where data_input_id=" . $template_data["data_input_id"] . " and input_output='out' and update_rra='on' order by data_name,name";
    }
    $form_array = array();
    while (list($field_name, $field_array) = each($struct_data_source_item)) {
        $form_array += array($field_name => $struct_data_source_item[$field_name]);
        $form_array[$field_name]["description"] = "";
        $form_array[$field_name]["value"] = isset($template_rrd) ? $template_rrd[$field_name] : "";
        $form_array[$field_name]["sub_checkbox"] = array("name" => "t_" . $field_name, "friendly_name" => "Use Per-Data Source Value (Ignore this Value)", "value" => isset($template_rrd) ? $template_rrd["t_" . $field_name] : "");
    }
    draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => $form_array + array("data_template_rrd_id" => array("method" => "hidden", "value" => isset($template_rrd) ? $template_rrd["id"] : "0"))));
    html_end_box();
    $i = 0;
    if (!empty($_GET["id"])) {
        /* get each INPUT field for this data input source */
        $fields = db_fetch_assoc("select * from data_input_fields where data_input_id=" . $template_data["data_input_id"] . " and input_output='in' order by name");
        html_start_box("<strong>Custom Data</strong> [data input: " . htmlspecialchars(db_fetch_cell("select name from data_input where id=" . $template_data["data_input_id"])) . "]", "100%", "", "3", "center", "");
        /* loop through each field found */
        if (sizeof($fields) > 0) {
            foreach ($fields as $field) {
                $data_input_data = db_fetch_row("select t_value,value from data_input_data where data_template_data_id=" . $template_data["id"] . " and data_input_field_id=" . $field["id"]);
                if (sizeof($data_input_data) > 0) {
                    $old_value = $data_input_data["value"];
                } else {
                    $old_value = "";
                }
                form_alternate_row();
                ?>
				<td width="50%">
					<strong><?php 
                print $field["name"];
                ?>
</strong><br>
					<?php 
                form_checkbox("t_value_" . $field["data_name"], $data_input_data["t_value"], "Use Per-Data Source Value (Ignore this Value)", "", "", $_GET["id"]);
//.........这里部分代码省略.........
开发者ID:teddywen,项目名称:cacti,代码行数:101,代码来源:data_templates.php


示例4: host_edit

function host_edit()
{
    global $fields_host_edit, $reindex_types;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request('id'));
    /* ==================================================== */
    api_plugin_hook('host_edit_top');
    if (!empty($_REQUEST['id'])) {
        $host = db_fetch_row_prepared('SELECT * FROM host WHERE id = ?', array($_REQUEST['id']));
        $header_label = '[edit: ' . htmlspecialchars($host['description']) . ']';
    } else {
        $header_label = '[new]';
    }
    if (!empty($host['id'])) {
        ?>
		<table width='100%' align='center'>
			<tr>
				<td class='textInfo' colspan='2'>
					<?php 
        print htmlspecialchars($host['description']);
        ?>
 (<?php 
        print htmlspecialchars($host['hostname']);
        ?>
)
				</td>
				<td rowspan='2' class='textInfo' valign='top' align='right'>
					<span class='linkMarker'>*</span><a class='hyperLink' href='<?php 
        print htmlspecialchars('graphs_new.php?host_id=' . $host['id']);
        ?>
'>Create Graphs for this Device</a><br>
					<span class='linkMarker'>*</span><a class='hyperLink' href='<?php 
        print htmlspecialchars('data_sources.php?host_id=' . $host['id'] . '&ds_rows=30&filter=&template_id=-1&method_id=-1&page=1');
        ?>
'>Data Source List</a><br>
					<span class='linkMarker'>*</span><a class='hyperLink' href='<?php 
        print htmlspecialchars('graphs.php?host_id=' . $host['id'] . '&graph_rows=30&filter=&template_id=-1&page=1');
        ?>
'>Graph List</a>
					<?php 
        api_plugin_hook('device_edit_top_links');
        ?>
				</td>
			</tr>
			<tr>
				<td valign='top' class='textHeader'>
					<div id='ping_results'>Pinging Device&nbsp;<i style='font-size:12px;' class='fa fa-spin fa-spinner'></i><br><br></div>
				</td>
			</tr>
		</table>
		<?php 
    }
    html_start_box("<strong>Device</strong> {$header_label}", '100%', '', '3', 'center', '');
    /* preserve the host template id if passed in via a GET variable */
    if (!empty($_REQUEST['host_template_id'])) {
        $fields_host_edit['host_template_id']['value'] = $_REQUEST['host_template_id'];
    }
    draw_edit_form(array('config' => array('form_name' => 'chk'), 'fields' => inject_form_variables($fields_host_edit, isset($host) ? $host : array())));
    /* we have to hide this button to make a form change in the main form trigger the correct
     * submit action */
    echo "<div style='display:none;'><input type='submit' value='Default Submit Button'></div>";
    html_end_box();
    ?>
	<script type="text/javascript">
	<!--

	// default snmp information
	var snmp_community       = $('#snmp_community').val();
	var snmp_username        = $('#snmp_username').val();
	var snmp_password        = $('#snmp_password').val();
	var snmp_auth_protocol   = $('#snmp_auth_protocol').val();
	var snmp_priv_passphrase = $('#snmp_priv_passphrase').val();
	var snmp_priv_protocol   = $('#snmp_priv_protocol').val();
	var snmp_context         = $('#snmp_context').val();
	var snmp_port            = $('#snmp_port').val();
	var snmp_timeout         = $('#snmp_timeout').val();
	var max_oids             = $('#max_oids').val();

	// default ping methods
	var ping_method    = $('#ping_method').val();
	var ping_port      = $('#ping_port').val();
	var ping_timeout   = $('#ping_timeout').val();
	var ping_retries   = $('#ping_retries').val();

	function setPing() {
		availability_method = $('#availability_method').val();
		ping_method         = $('#ping_method').val();

		switch(availability_method) {
		case '0': // none
			$('#row_ping_method').css('display', 'none');
			$('#row_ping_port').css('display', 'none');
			$('#row_ping_timeout').css('display', 'none');
			$('#row_ping_retries').css('display', 'none');

			break;
		case '2': // snmp
		case '5': // snmp sysDesc
		case '6': // snmp getNext
			$('#row_ping_method').css('display', 'none');
//.........这里部分代码省略.........
开发者ID:MrWnn,项目名称:cacti,代码行数:101,代码来源:host.php


示例5: mactrack_site_edit

function mactrack_site_edit()
{
    global $fields_mactrack_site_edit;
    /* ================= input validation ================= */
    get_filter_request_var('site_id');
    /* ==================================================== */
    display_output_messages();
    if (!isempty_request_var('site_id')) {
        $site = db_fetch_row('SELECT * FROM mac_track_sites WHERE site_id=' . get_request_var('site_id'));
        $header_label = __('MacTrack Site [edit: %s]', $site['site_name']);
    } else {
        $header_label = __('MacTrack Site [new]');
    }
    form_start('mactrack_sites.php');
    html_start_box($header_label, '100%', '', '3', 'center', '');
    draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => inject_form_variables($fields_mactrack_site_edit, isset($site) ? $site : array())));
    html_end_box();
    form_save_button('mactrack_sites.php', 'return', 'site_id');
}
开发者ID:Cacti,项目名称:plugin_mactrack,代码行数:19,代码来源:mactrack_sites.php


示例6: ds_edit

function ds_edit()
{
    global $colors, $struct_data_source, $struct_data_source_item, $data_source_types;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    /* ==================================================== */
    $use_data_template = true;
    $host_id = 0;
    if (!empty($_GET["id"])) {
        $data_local = db_fetch_row("select host_id,data_template_id from data_local where id='" . $_GET["id"] . "'");
        $data = db_fetch_row("select * from data_template_data where local_data_id='" . $_GET["id"] . "'");
        if (isset($data_local["data_template_id"]) && $data_local["data_template_id"] >= 0) {
            $data_template = db_fetch_row("select id,name from data_template where id='" . $data_local["data_template_id"] . "'");
            $data_template_data = db_fetch_row("select * from data_template_data where data_template_id='" . $data_local["data_template_id"] . "' and local_data_id=0");
        } else {
            $_SESSION["sess_messages"] = 'Data Source "' . $_GET["id"] . '" does not exist.';
            header("Location: data_sources.php");
            exit;
        }
        $header_label = "[edit: " . get_data_source_title($_GET["id"]) . "]";
        if (empty($data_local["data_template_id"])) {
            $use_data_template = false;
        }
    } else {
        $header_label = "[new]";
        $use_data_template = false;
    }
    /* handle debug mode */
    if (isset($_GET["debug"])) {
        if ($_GET["debug"] == "0") {
            kill_session_var("ds_debug_mode");
        } elseif ($_GET["debug"] == "1") {
            $_SESSION["ds_debug_mode"] = true;
        }
    }
    include_once "./include/top_header.php";
    if (!empty($_GET["id"])) {
        ?>
		<table width="100%" align="center">
			<tr>
				<td class="textInfo" colspan="2" valign="top">
					<?php 
        print get_data_source_title($_GET["id"]);
        ?>
				</td>
				<td class="textInfo" align="right" valign="top">
					<span style="color: #c16921;">*<a href='data_sources.php?action=ds_edit&id=<?php 
        print isset($_GET["id"]) ? $_GET["id"] : 0;
        ?>
&debug=<?php 
        print isset($_SESSION["ds_debug_mode"]) ? "0" : "1";
        ?>
'>Turn <strong><?php 
        print isset($_SESSION["ds_debug_mode"]) ? "Off" : "On";
        ?>
</strong> Data Source Debug Mode.</a>
				</td>
			</tr>
		</table>
		<br>
		<?php 
    }
    html_start_box("<strong>Data Template Selection</strong> {$header_label}", "100%", $colors["header"], "3", "center", "");
    $form_array = array("data_template_id" => array("method" => "drop_sql", "friendly_name" => "Selected Data Template", "description" => "The name given to this data template.", "value" => isset($data_template) ? $data_template["id"] : "0", "none_value" => "None", "sql" => "select id,name from data_template order by name"), "host_id" => array("method" => "drop_sql", "friendly_name" => "Host", "description" => "Choose the host that this graph belongs to.", "value" => isset($_GET["host_id"]) ? $_GET["host_id"] : $data_local["host_id"], "none_value" => "None", "sql" => "select id,CONCAT_WS('',description,' (',hostname,')') as name from host order by description,hostname"), "_data_template_id" => array("method" => "hidden", "value" => isset($data_template) ? $data_template["id"] : "0"), "_host_id" => array("method" => "hidden", "value" => empty($data_local["host_id"]) ? isset($_GET["host_id"]) ? $_GET["host_id"] : "0" : $data_local["host_id"]), "_data_input_id" => array("method" => "hidden", "value" => isset($data["data_input_id"]) ? $data["data_input_id"] : "0"), "data_template_data_id" => array("method" => "hidden", "value" => isset($data) ? $data["id"] : "0"), "local_data_template_data_id" => array("method" => "hidden", "value" => isset($data) ? $data["local_data_template_data_id"] : "0"), "local_data_id" => array("method" => "hidden", "value" => isset($data) ? $data["local_data_id"] : "0"));
    draw_edit_form(array("config" => array(), "fields" => $form_array));
    html_end_box();
    /* only display the "inputs" area if we are using a data template for this data source */
    if (!empty($data["data_template_id"])) {
        $template_data_rrds = db_fetch_assoc("select * from data_template_rrd where local_data_id=" . $_GET["id"] . " order by data_source_name");
        html_start_box("<strong>Supplemental Data Template Data</strong>", "100%", $colors["header"], "3", "center", "");
        draw_nontemplated_fields_data_source($data["data_template_id"], $data["local_data_id"], $data, "|field|", "<strong>Data Source Fields</strong>", true, true, 0);
        draw_nontemplated_fields_data_source_item($data["data_template_id"], $template_data_rrds, "|field|_|id|", "<strong>Data Source Item Fields</strong>", true, true, true, 0);
        draw_nontemplated_fields_custom_data($data["id"], "value_|id|", "<strong>Custom Data</strong>", true, true, 0);
        form_hidden_box("save_component_data", "1", "");
        html_end_box();
    }
    if ((isset($_GET["id"]) || isset($_GET["new"])) && empty($data["data_template_id"])) {
        html_start_box("<strong>Data Source</strong>", "100%", $colors["header"], "3", "center", "");
        $form_array = array();
        while (list($field_name, $field_array) = each($struct_data_source)) {
            $form_array += array($field_name => $struct_data_source[$field_name]);
            if (!($use_data_template == false || !empty($data_template_data["t_" . $field_name]) || $field_array["flags"] == "NOTEMPLATE")) {
                $form_array[$field_name]["description"] = "";
            }
            $form_array[$field_name]["value"] = isset($data[$field_name]) ? $data[$field_name] : "";
            $form_array[$field_name]["form_id"] = empty($data["id"]) ? "0" : $data["id"];
            if (!($use_data_template == false || !empty($data_template_data["t_" . $field_name]) || $field_array["flags"] == "NOTEMPLATE")) {
                $form_array[$field_name]["method"] = "template_" . $form_array[$field_name]["method"];
            }
        }
        draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => inject_form_variables($form_array, isset($data) ? $data : array())));
        html_end_box();
        /* fetch ALL rrd's for this data source */
        if (!empty($_GET["id"])) {
            $template_data_rrds = db_fetch_assoc("select id,data_source_name from data_template_rrd where local_data_id=" . $_GET["id"] . " order by data_source_name");
        }
        /* select the first "rrd" of this data source by default */
        if (empty($_GET["view_rrd"])) {
            $_GET["view_rrd"] = isset($template_data_rrds[0]["id"]) ? $template_data_rrds[0]["id"] : "0";
        }
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:odp-svn,代码行数:101,代码来源:data_sources.php


示例7: syslog_action_edit

function syslog_action_edit()
{
    global $colors, $message_types, $severities;
    include dirname(__FILE__) . "/config.php";
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    input_validate_input_number(get_request_var("type"));
    /* ==================================================== */
    if (isset($_GET["id"]) && $_GET["action"] == "edit") {
        $alert = syslog_db_fetch_row("SELECT *\n\t\t\tFROM `" . $syslogdb_default . "`.`syslog_alert`\n\t\t\tWHERE id=" . $_GET["id"]);
        $header_label = "[edit: " . $alert["name"] . "]";
    } else {
        if (isset($_GET["id"]) && $_GET["action"] == "newedit") {
            $syslog_rec = syslog_db_fetch_row("SELECT * FROM `" . $syslogdb_default . "`.`syslog` WHERE seq=" . $_GET["id"] . " AND logtime='" . $_GET["date"] . "'");
            $header_label = "[new]";
            if (sizeof($syslog_rec)) {
                $alert["message"] = $syslog_rec["message"];
            }
            $alert["name"] = "New Alert Rule";
        } else {
            $header_label = "[new]";
            $alert["name"] = "New Alert Rule";
        }
    }
    $alert_retention = read_config_option("syslog_alert_retention");
    if ($alert_retention != '' && $alert_retention > 0 && $alert_retention < 365) {
        $repeat_end = $alert_retention * 24 * 60 / 5;
    }
    $repeatarray = array(0 => 'Not Set', 1 => '5 Minutes', 2 => '10 Minutes', 3 => '15 Minutes', 4 => '20 Minutes', 6 => '30 Minutes', 8 => '45 Minutes', 12 => '1 Hour', 24 => '2 Hours', 36 => '3 Hours', 48 => '4 Hours', 72 => '6 Hours', 96 => '8 Hours', 144 => '12 Hours', 288 => '1 Day', 576 => '2 Days', 2016 => '1 Week', 4032 => '2 Weeks', 8640 => 'Month');
    if ($repeat_end) {
        foreach ($repeatarray as $i => $value) {
            if ($i > $repeat_end) {
                unset($repeatarray[$i]);
            }
        }
    }
    html_start_box("<strong>Alert Edit</strong> {$header_label}", "100%", $colors["header"], "3", "center", "");
    $fields_syslog_alert_edit = array("spacer0" => array("method" => "spacer", "friendly_name" => "Alert Details"), "name" => array("method" => "textbox", "friendly_name" => "Alert Name", "description" => "Please describe this Alert.", "value" => "|arg1:name|", "max_length" => "250", "size" => 80), "severity" => array("method" => "drop_array", "friendly_name" => "Severity", "description" => "What is the Severity Level of this Alert?", "value" => "|arg1:severity|", "array" => $severities, "default" => "1"), "method" => array("method" => "drop_array", "friendly_name" => "Reporting Method", "description" => "Define how to Alert on the syslog messages.", "value" => "|arg1:method|", "array" => array("0" => "Individual", "1" => "Threshold"), "default" => "0"), "num" => array("method" => "textbox", "friendly_name" => "Threshold", "description" => "For the 'Threshold' method, If the number seen is above this value\n\t\tan Alert will be triggered.", "value" => "|arg1:num|", "size" => "4", "max_length" => "10", "default" => "1"), "type" => array("method" => "drop_array", "friendly_name" => "String Match Type", "description" => "Define how you would like this string matched.  If using the SQL Expression type you may use any valid SQL expression\n\t\tto generate the alarm.  Available fields include 'message', 'facility', 'priority', and 'host'.", "value" => "|arg1:type|", "array" => $message_types, "on_change" => "changeTypes()", "default" => "matchesc"), "message" => array("friendly_name" => "Syslog Message Match String", "description" => "The matching component of the syslog message.", "textarea_rows" => "2", "textarea_cols" => "70", "method" => "textarea", "class" => "textAreaNotes", "value" => "|arg1:message|", "default" => ""), "enabled" => array("method" => "drop_array", "friendly_name" => "Alert Enabled", "description" => "Is this Alert Enabled?", "value" => "|arg1:enabled|", "array" => array("on" => "Enabled", "" => "Disabled"), "default" => "on"), "repeat_alert" => array("friendly_name" => "Re-Alert Cycle", "method" => "drop_array", "array" => $repeatarray, "default" => "0", "description" => "Do not resend this alert again for the same host, until this amount of time has elapsed. For threshold\n\t\tbased alarms, this applies to all hosts.", "value" => "|arg1:repeat_alert|"), "notes" => array("friendly_name" => "Alert Notes", "textarea_rows" => "5", "textarea_cols" => "70", "description" => "Space for Notes on the Alert", "method" => "textarea", "class" => "textAreaNotes", "value" => "|arg1:notes|", "default" => ""), "spacer1" => array("method" => "spacer", "friendly_name" => "Alert Actions"), "open_ticket" => array("method" => "drop_array", "friendly_name" => "Open Ticket", "description" => "Should a Help Desk Ticket be opened for this Alert", "value" => "|arg1:open_ticket|", "array" => array("on" => "Yes", "" => "No"), "default" => ""), "email" => array("method" => "textarea", "friendly_name" => "E-Mails to Notify", "textarea_rows" => "5", "textarea_cols" => "70", "description" => "Please enter a comma delimited list of e-mail addresses to inform.  If you\n\t\twish to send out e-mail to a recipient in SMS format, please prefix that recipient's e-mail address\n\t\twith <b>'sms@'</b>.  For example, if the recipients SMS address is <b>'[email protected]'</b>, you would\n\t\tenter it as <b>'sms@[email protected]'</b> and it will be formatted as an SMS message.", "class" => "textAreaNotes", "value" => "|arg1:email|", "max_length" => "255"), "command" => array("friendly_name" => "Alert Command", "textarea_rows" => "5", "textarea_cols" => "70", "description" => "When an Alert is triggered, run the following command.  The following replacement variables\n\t\tare available <b>'&lt;HOSTNAME&gt;'</b>, <b>'&lt;ALERTID&gt;'</b>, <b>'&lt;MESSAGE&gt;'</b>,\n\t\t<b>'&lt;FACILITY&gt;'</b>, <b>'&lt;PRIORITY&gt;'</b>, <b>'&lt;SEVERITY&gt;'</b>.  Please\n\t\tnote that <b>'&lt;HOSTNAME&gt;'</b> is only available on individual thresholds.", "method" => "textarea", "class" => "textAreaNotes", "value" => "|arg1:command|", "default" => ""), "id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "_id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "save_component_alert" => array("method" => "hidden", "value" => "1"));
    echo "<form method='post' autocomplete='off' onsubmit='changeTypes()' action='syslog_alerts.php' name='chk'>";
    draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => inject_form_variables($fields_syslog_alert_edit, isset($alert) ? $alert : array())));
    html_end_box();
    form_save_button("syslog_alerts.php", "", "id");
    ?>
	<script type='text/javascript'>
	function changeTypes() {
		if (document.getElementById('type').value == 'sql') {
			document.getElementById('message').rows = 6;
		}else{
			document.getElementById('message').rows = 2;
		}
	}
	</script>
	<?php 
}
开发者ID:khoimt,项目名称:cacti-sample,代码行数:54,代码来源:syslog_alerts.php


示例8: data_query_edit

function data_query_edit() {
	global $colors, $fields_data_query_edit, $config;

	if (!empty($_GET["id"])) {
		$snmp_query = db_fetch_row("select * from snmp_query where id=" . $_GET["id"]);
		$header_label = "[edit: " . $snmp_query["name"] . "]";
	}else{
		$header_label = "[new]";
	}

	html_start_box("<strong>Data Queries</strong> $header_label", "98%", $colors["header"], "3", "center", "");

	draw_edit_form(array(
		"config" => array(),
		"fields" => inject_form_variables($fields_data_query_edit, (isset($snmp_query) ? $snmp_query : array()))
		));

	html_end_box();

	if (!empty($snmp_query["id"])) {
		$xml_filename = str_replace("<path_cacti>", $config["base_path"], $snmp_query["xml_path"]);

		if ((file_exists($xml_filename)) && (is_file($xml_filename))) {
			$text = "<font color='#0d7c09'><strong>Successfully located XML file</strong></font>";
			$xml_file_exists = true;
		}else{
			$text = "<font color='#ff0000'><strong>Could not locate XML file.</strong></font>";
			$xml_file_exists = false;
		}

		html_start_box("", "98%", "aaaaaa", "3", "center", "");
		print "<tr bgcolor='#f5f5f5'><td>$text</td></tr>";
		html_end_box();

		if ($xml_file_exists == true) {
			html_start_box("<strong>Associated Graph Templates</strong>", "98%", $colors["header"], "3", "center", "data_queries.php?action=item_edit&snmp_query_id=" . $snmp_query["id"]);

			print "	<tr bgcolor='#" . $colors["header_panel"] . "'>
					<td><span style='color: white; font-weight: bold;'>Name</span></td>
					<td><span style='color: white; font-weight: bold;'>Graph Template Name</span></td>
					<td></td>
				</tr>";

			$snmp_query_graphs = db_fetch_assoc("select
				snmp_query_graph.id,
				graph_templates.name as graph_template_name,
				snmp_query_graph.name
				from snmp_query_graph
				left join graph_templates on snmp_query_graph.graph_template_id=graph_templates.id
				where snmp_query_graph.snmp_query_id=" . $snmp_query["id"] . "
				order by snmp_query_graph.name");

			$i = 0;
			if (sizeof($snmp_query_graphs) > 0) {
			foreach ($snmp_query_graphs as $snmp_query_graph) {
				form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); $i++;
				?>
					<td>
						<strong><a href="data_queries.php?action=item_edit&id=<?php print $snmp_query_graph["id"];?>&snmp_query_id=<?php print $snmp_query["id"];?>"><?php print $snmp_query_graph["name"];?></a></strong>
					</td>
					<td>
						<?php print $snmp_query_graph["graph_template_name"];?>
					</td>
					<td align="right">
						<a href="data_queries.php?action=item_remove&id=<?php print $snmp_query_graph["id"];?>&snmp_query_id=<?php print $snmp_query["id"];?>"><img src="images/delete_icon.gif" width="10" height="10" border="0" alt="Delete"></a>
					</td>
				</tr>
				<?php
			}
			}else{
				print "<tr><td><em>No Graph Templates Defined.</em></td></tr>";
			}

			html_end_box();
		}
	}

	form_save_button("data_queries.php");
}
开发者ID:songchin,项目名称:Cacti,代码行数:79,代码来源:data_queries.php


示例9: data_edit

function data_edit()
{
    global $fields_data_input_edit;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_request('id'));
    /* ==================================================== */
    if (!empty($_REQUEST['id'])) {
        $data_input = db_fetch_row_prepared('SELECT * FROM data_input WHERE id = ?', array(get_request_var_request('id')));
        $header_label = '[edit: ' . htmlspecialchars($data_input['name']) . ']';
    } else {
        $header_label = '[new]';
    }
    html_start_box("<strong>Data Input Methods</strong> {$header_label}", '100%', '', '3', 'center', '');
    draw_edit_form(array('config' => array(), 'fields' => inject_form_variables($fields_data_input_edit, isset($data_input) ? $data_input : array())));
    html_end_box();
    if (!empty($_REQUEST['id'])) {
        html_start_box('<strong>Input Fields</strong>', '100%', '', '3', 'center', 'data_input.php?action=field_edit&type=in&data_input_id=' . htmlspecialchars(get_request_var_request('id')));
        print "<tr class='tableHeader'>";
        DrawMatrixHeaderItem('Name', '', 1);
        DrawMatrixHeaderItem('Field Order', '', 1);
        DrawMatrixHeaderItem('Friendly Name', '', 2);
        print '</tr>';
        $fields = db_fetch_assoc_prepared("SELECT id, data_name, name, sequence FROM data_input_fields WHERE data_input_id = ? AND input_output = 'in' ORDER BY sequence, data_name", array(get_request_var_request('id')));
        $i = 0;
        if (sizeof($fields) > 0) {
            foreach ($fields as $field) {
                form_alternate_row('', true);
                ?>
				<td>
					<a class="linkEditMain" href="<?php 
                print htmlspecialchars('data_input.php?action=field_edit&id=' . $field['id'] . '&data_input_id=' . $_REQUEST['id']);
                ?>
"><?php 
                print htmlspecialchars($field['data_name']);
                ?>
</a>
				</td>
				<td>
					<?php 
                print $field['sequence'];
                if ($field['sequence'] == '0') {
                    print ' (Not In Use)';
                }
                ?>
				</td>
				<td>
					<?php 
                print htmlspecialchars($field['name']);
                ?>
				</td>
				<td align="right">
					<a href="<?php 
                print htmlspecialchars('data_input.php?action=field_remove&id=' . $field['id'] . '&data_input_id=' . $_REQUEST['id']);
                ?>
"><img src="images/delete_icon.gif" style="height:10px;width:10px;" border="0" alt="Delete"></a>
				</td>
			</tr>
		<?php 
            }
        } else {
            print '<tr><td><em>No Input Fields</em></td></tr>';
        }
        html_end_box();
        html_start_box('<strong>Output Fields</strong>', '100%', '', '3', 'center', 'data_input.php?action=field_edit&type=out&data_input_id=' . $_REQUEST['id']);
        print "<tr class='tableHeader'>";
        DrawMatrixHeaderItem('Name', '', 1);
        DrawMatrixHeaderItem('Field Order', '', 1);
        DrawMatrixHeaderItem('Friendly Name', '', 1);
        DrawMatrixHeaderItem('Update RRA', '', 2);
        print '</tr>';
        $fields = db_fetch_assoc_prepared("SELECT id, name, data_name, update_rra, sequence FROM data_input_fields WHERE data_input_id = ? and input_output = 'out' ORDER BY sequence, data_name", array(get_request_var_request('id')));
        $i = 0;
        if (sizeof($fields) > 0) {
            foreach ($fields as $field) {
                form_alternate_row('', true);
                ?>
				<td>
					<a class="linkEditMain" href="<?php 
                print htmlspecialchars('data_input.php?action=field_edit&id=' . $field['id'] . '&data_input_id=' . $_REQUEST['id']);
                ?>
"><?php 
                print htmlspecialchars($field['data_name']);
                ?>
</a>
				</td>
				<td>
					<?php 
                print $field['sequence'];
                if ($field['sequence'] == '0') {
                    print ' (Not In Use)';
                }
                ?>
				</td>
				<td>
					<?php 
                print htmlspecialchars($field['name']);
                ?>
				</td>
				<td>
					<?php 
//.........这里部分代码省略.........
开发者ID:MrWnn,项目名称:cacti,代码行数:101,代码来源:data_input.php


示例10: graph_template_display_general

该文章已有0人参与评论

请发表评论

全部评论

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