本文整理汇总了PHP中get_sequence函数的典型用法代码示例。如果您正苦于以下问题:PHP get_sequence函数的具体用法?PHP get_sequence怎么用?PHP get_sequence使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_sequence函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: form_save
function form_save()
{
if (isset($_POST['save_component_item'])) {
global $graph_item_types;
$items[0] = array();
if ($graph_item_types[$_POST['graph_type_id']] == 'LEGEND') {
/* this can be a major time saver when creating lots of graphs with the typical
GPRINT LAST/AVERAGE/MAX legends */
$items = array(0 => array('color_id' => '0', 'graph_type_id' => '9', 'consolidation_function_id' => '4', 'text_format' => 'Current:', 'hard_return' => ''), 1 => array('color_id' => '0', 'graph_type_id' => '9', 'consolidation_function_id' => '1', 'text_format' => 'Average:', 'hard_return' => ''), 2 => array('color_id' => '0', 'graph_type_id' => '9', 'consolidation_function_id' => '3', 'text_format' => 'Maximum:', 'hard_return' => 'on'));
}
foreach ($items as $item) {
/* generate a new sequence if needed */
if (empty($_POST['sequence'])) {
$_POST['sequence'] = get_sequence($_POST['sequence'], 'sequence', 'graph_templates_item', 'local_graph_id=' . $_POST['local_graph_id']);
}
$save['id'] = $_POST['graph_template_item_id'];
$save['graph_template_id'] = $_POST['graph_template_id'];
$save['local_graph_template_item_id'] = $_POST['local_graph_template_item_id'];
$save['local_graph_id'] = $_POST['local_graph_id'];
$save['task_item_id'] = form_input_validate($_POST['task_item_id'], 'task_item_id', '', true, 3);
$save['color_id'] = form_input_validate(isset($item['color_id']) ? $item['color_id'] : $_POST['color_id'], 'color_id', '', true, 3);
/* if alpha is disabled, use invisible_alpha instead */
if (!isset($_POST['alpha'])) {
$_POST['alpha'] = $_POST['invisible_alpha'];
}
$save['alpha'] = form_input_validate(isset($item['alpha']) ? $item['alpha'] : $_POST['alpha'], 'alpha', '', true, 3);
$save['graph_type_id'] = form_input_validate(isset($item['graph_type_id']) ? $item['graph_type_id'] : $_POST['graph_type_id'], 'graph_type_id', '', true, 3);
$save['cdef_id'] = form_input_validate($_POST['cdef_id'], 'cdef_id', '', true, 3);
$save['consolidation_function_id'] = form_input_validate(isset($item['consolidation_function_id']) ? $item['consolidation_function_id'] : $_POST['consolidation_function_id'], 'consolidation_function_id', '', true, 3);
$save['text_format'] = form_input_validate(isset($item['text_format']) ? $item['text_format'] : $_POST['text_format'], 'text_format', '', true, 3);
$save['value'] = form_input_validate($_POST['value'], 'value', '', true, 3);
$save['hard_return'] = form_input_validate(isset($item['hard_return']) ? $item['hard_return'] : (isset($_POST['hard_return']) ? $_POST['hard_return'] : ''), 'hard_return', '', true, 3);
$save['gprint_id'] = form_input_validate($_POST['gprint_id'], 'gprint_id', '', true, 3);
$save['sequence'] = $_POST['sequence'];
if (!is_error_message()) {
$graph_template_item_id = sql_save($save, 'graph_templates_item');
if ($graph_template_item_id) {
raise_message(1);
} else {
raise_message(2);
}
}
$_POST['sequence'] = 0;
}
if (is_error_message()) {
header('Location: graphs.php?action=item_edit&graph_template_item_id=' . (empty($graph_template_item_id) ? $_POST['graph_template_item_id'] : $graph_template_item_id) . '&id=' . $_POST['local_graph_id']);
exit;
} else {
header('Location: graphs.php?action=graph_edit&id=' . $_POST['local_graph_id']);
exit;
}
}
}
开发者ID:MrWnn,项目名称:cacti,代码行数:53,代码来源:graphs_items.php
示例2: form_save
function form_save()
{
if (isset($_POST["save_component_item"])) {
global $graph_item_types;
$items[0] = array();
if ($graph_item_types[$_POST["graph_type_id"]] == "LEGEND") {
/* this can be a major time saver when creating lots of graphs with the typical
GPRINT LAST/AVERAGE/MAX legends */
$items = array(0 => array("color_id" => "0", "graph_type_id" => "9", "consolidation_function_id" => "4", "text_format" => "Current:", "hard_return" => ""), 1 => array("color_id" => "0", "graph_type_id" => "9", "consolidation_function_id" => "1", "text_format" => "Average:", "hard_return" => ""), 2 => array("color_id" => "0", "graph_type_id" => "9", "consolidation_function_id" => "3", "text_format" => "Maximum:", "hard_return" => "on"));
}
foreach ($items as $item) {
/* generate a new sequence if needed */
if (empty($_POST["sequence"])) {
$_POST["sequence"] = get_sequence($_POST["sequence"], "sequence", "graph_templates_item", "local_graph_id=" . $_POST["local_graph_id"]);
}
$save["id"] = $_POST["graph_template_item_id"];
$save["graph_template_id"] = $_POST["graph_template_id"];
$save["local_graph_template_item_id"] = $_POST["local_graph_template_item_id"];
$save["local_graph_id"] = $_POST["local_graph_id"];
$save["task_item_id"] = form_input_validate($_POST["task_item_id"], "task_item_id", "", true, 3);
$save["color_id"] = form_input_validate(isset($item["color_id"]) ? $item["color_id"] : $_POST["color_id"], "color_id", "", true, 3);
/* if alpha is disabled, use invisible_alpha instead */
if (!isset($_POST["alpha"])) {
$_POST["alpha"] = $_POST["invisible_alpha"];
}
$save["alpha"] = form_input_validate(isset($item["alpha"]) ? $item["alpha"] : $_POST["alpha"], "alpha", "", true, 3);
$save["graph_type_id"] = form_input_validate(isset($item["graph_type_id"]) ? $item["graph_type_id"] : $_POST["graph_type_id"], "graph_type_id", "", true, 3);
$save["cdef_id"] = form_input_validate($_POST["cdef_id"], "cdef_id", "", true, 3);
$save["consolidation_function_id"] = form_input_validate(isset($item["consolidation_function_id"]) ? $item["consolidation_function_id"] : $_POST["consolidation_function_id"], "consolidation_function_id", "", true, 3);
$save["text_format"] = form_input_validate(isset($item["text_format"]) ? $item["text_format"] : $_POST["text_format"], "text_format", "", true, 3);
$save["value"] = form_input_validate($_POST["value"], "value", "", true, 3);
$save["hard_return"] = form_input_validate(isset($item["hard_return"]) ? $item["hard_return"] : (isset($_POST["hard_return"]) ? $_POST["hard_return"] : ""), "hard_return", "", true, 3);
$save["gprint_id"] = form_input_validate($_POST["gprint_id"], "gprint_id", "", true, 3);
$save["sequence"] = $_POST["sequence"];
if (!is_error_message()) {
$graph_template_item_id = sql_save($save, "graph_templates_item");
if ($graph_template_item_id) {
raise_message(1);
} else {
raise_message(2);
}
}
$_POST["sequence"] = 0;
}
if (is_error_message()) {
header("Location: graphs.php?action=item_edit&graph_template_item_id=" . (empty($graph_template_item_id) ? $_POST["graph_template_item_id"] : $graph_template_item_id) . "&id=" . $_POST["local_graph_id"]);
exit;
} else {
header("Location: graphs.php?action=graph_edit&id=" . $_POST["local_graph_id"]);
exit;
}
}
}
开发者ID:songchin,项目名称:Cacti,代码行数:53,代码来源:graphs_items.php
示例3: mactrack_snmp_item_edit
function mactrack_snmp_item_edit()
{
global $config;
global $fields_mactrack_snmp_item_edit;
include_once $config['base_path'] . '/plugins/mactrack/lib/mactrack_functions.php';
/* ================= input validation ================= */
get_filter_request_var('id');
get_filter_request_var('item_id');
/* ==================================================== */
# fetch the current mactrack snmp record
$snmp_option = db_fetch_row_prepared('SELECT * FROM mac_track_snmp WHERE id = ?', array(get_request_var('id')));
# if an existing item was requested, fetch data for it
if (get_request_var('item_id', '') !== '') {
$mactrack_snmp_item = db_fetch_row_prepared('SELECT * FROM mac_track_snmp_items WHERE id = ?', array(get_request_var('item_id')));
$header_label = __('SNMP Options [edit %s]', $snmp_option['name']);
} else {
$header_label = __('SNMP Options [new]');
$mactrack_snmp_item = array();
$mactrack_snmp_item['snmp_id'] = get_request_var('id');
$mactrack_snmp_item['sequence'] = get_sequence('', 'sequence', 'mac_track_snmp_items', 'snmp_id=' . get_request_var('id'));
}
form_start(basename($_SERVER['PHP_SELF']), 'mactrack_item_edit');
html_start_box($header_label, '100%', '', '3', 'center', '');
draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => inject_form_variables($fields_mactrack_snmp_item_edit, isset($mactrack_snmp_item) ? $mactrack_snmp_item : array())));
html_end_box();
form_hidden_box('item_id', isset_request_var('item_id') ? get_request_var('item_id') : '0', '');
form_hidden_box('id', isset($mactrack_snmp_item['snmp_id']) ? $mactrack_snmp_item['snmp_id'] : '0', '');
form_hidden_box('save_component_mactrack_snmp_item', '1', '');
form_save_button(htmlspecialchars('mactrack_snmp.php?action=edit&id=' . get_request_var('id')));
?>
<script type='text/javascript'>
$(function() {
setSNMP();
$('#snmp_version').change(function() {
setSNMP();
});
});
</script>
<?php
}
开发者ID:Cacti,项目名称:plugin_mactrack,代码行数:40,代码来源:mactrack_snmp.php
示例4: 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
示例5: 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
示例6: form_save
function form_save()
{
// make sure ids are numeric
if (isset($_POST["id"]) && !is_numeric($_POST["id"])) {
$_POST["id"] = 0;
}
if (isset($_POST["cdef_id"]) && !is_numeric($_POST["cdef_id"])) {
$_POST["cdef_id"] = 0;
}
if (isset($_POST["save_component_cdef"])) {
/* ================= input validation ================= */
input_validate_input_number(get_request_var_post('id'));
/* ==================================================== */
$save["id"] = $_POST["id"];
$save["hash"] = get_hash_cdef($_POST["id"]);
$save["name"] = form_input_validate($_POST["name"], "name", "", false, 3);
if (!is_error_message()) {
$cdef_id = sql_save($save, "cdef");
if ($cdef_id) {
raise_message(1);
} else {
raise_message(2);
}
}
header("Location: cdef.php?action=edit&id=" . (empty($cdef_id) ? $_POST["id"] : $cdef_id));
} elseif (isset($_POST["save_component_item"])) {
/* ================= input validation ================= */
input_validate_input_number(get_request_var_post('id'));
input_validate_input_number(get_request_var_post('cdef_id'));
input_validate_input_number(get_request_var_post('type'));
/* ==================================================== */
$sequence = get_sequence($_POST["id"], "sequence", "cdef_items", "cdef_id=" . $_POST["cdef_id"]);
$save["id"] = $_POST["id"];
$save["hash"] = get_hash_cdef($_POST["id"], "cdef_item");
$save["cdef_id"] = $_POST["cdef_id"];
$save["sequence"] = $sequence;
$save["type"] = $_POST["type"];
$save["value"] = $_POST["value"];
if (!is_error_message()) {
$cdef_item_id = sql_save($save, "cdef_items");
if ($cdef_item_id) {
raise_message(1);
} else {
raise_message(2);
}
}
if (is_error_message()) {
header("Location: cdef.php?action=item_edit&cdef_id=" . $_POST["cdef_id"] . "&id=" . (empty($cdef_item_id) ? $_POST["id"] : $cdef_item_id));
} else {
header("Location: cdef.php?action=edit&id=" . $_POST["cdef_id"]);
}
}
}
开发者ID:teddywen,项目名称:cacti,代码行数:53,代码来源:cdef.php
示例7: convert_readstrings
function convert_readstrings()
{
global $config;
include_once $config['base_path'] . '/lib/functions.php';
$sql = 'SELECT DISTINCT ' . 'snmp_readstrings, ' . 'snmp_version, ' . 'snmp_port, ' . 'snmp_timeout, ' . 'snmp_retries ' . 'FROM mac_track_devices';
$devices = db_fetch_assoc($sql);
if (sizeof($devices)) {
$i = 0;
foreach ($devices as $device) {
# create new SNMP Option Set
unset($save);
$save['id'] = 0;
$save['name'] = 'Custom_' . $i++;
$snmp_id = sql_save($save, 'mac_track_snmp');
# add each single option derived from readstrings
$read_strings = explode(':', $device['snmp_readstrings']);
if (sizeof($read_strings)) {
foreach ($read_strings as $snmp_readstring) {
unset($save);
$save['id'] = 0;
$save['snmp_id'] = $snmp_id;
$save['sequence'] = get_sequence('', 'sequence', 'mac_track_snmp_items', 'snmp_id=' . $snmp_id);
$save['snmp_readstring'] = $snmp_readstring;
$save['snmp_version'] = $device['snmp_version'];
$save['snmp_port'] = $device['snmp_port'];
$save['snmp_timeout'] = $device['snmp_timeout'];
$save['snmp_retries'] = $device['snmp_retries'];
$save['snmp_username'] = '';
$save['snmp_password'] = '';
$save['snmp_auth_protocol'] = '';
$save['snmp_priv_passphrase'] = '';
$save['snmp_priv_protocol'] = '';
$save['snmp_context'] = '';
$save['snmp_engine_id'] = '';
$save['max_oids'] = '';
$item_id = sql_save($save, 'mac_track_snmp_items');
}
}
# each readstring added as SNMP Option item
# now, let's find all devices, that used this snmp_readstrings
$sql = 'UPDATE mac_track_devices SET snmp_options=' . $snmp_id . " WHERE snmp_readstrings='" . $device['snmp_readstrings'] . "' AND snmp_version=" . $device['snmp_version'] . ' AND snmp_port=' . $device['snmp_port'] . ' AND snmp_timeout=' . $device['snmp_timeout'] . ' AND snmp_retries=' . $device['snmp_retries'];
$ok = db_execute($sql);
}
}
db_execute("REPLACE INTO settings (name,value) VALUES ('mt_convert_readstrings', 'on')");
# we keep the field:snmp_readstrings in mac_track_devices, it should be deprecated first
# next mactrack release may delete that field, then
}
开发者ID:Cacti,项目名称:plugin_mactrack,代码行数:48,代码来源:setup.php
示例8: form_save
function form_save() {
if (isset($_POST["save_component_item"])) {
/* ================= input validation ================= */
input_validate_input_number(get_request_var_post("graph_template_id"));
input_validate_input_number(get_request_var_post("task_item_id"));
/* ==================================================== */
global $graph_item_types;
$items[0] = array();
if ($graph_item_types{$_POST["graph_type_id"]} == "LEGEND") {
/* this can be a major time saver when creating lots of graphs with the typical
GPRINT LAST/AVERAGE/MAX legends */
$items = array(
0 => array(
"color_id" => "0",
"graph_type_id" => "9",
"consolidation_function_id" => "4",
"text_format" => "Current:",
"hard_return" => ""
),
1 => array(
"color_id" => "0",
"graph_type_id" => "9",
"consolidation_function_id" => "1",
"text_format" => "Average:",
"hard_return" => ""
),
2 => array(
"color_id" => "0",
"graph_type_id" => "9",
"consolidation_function_id" => "3",
"text_format" => "Maximum:",
"hard_return" => "on"
));
}
foreach ($items as $item) {
/* generate a new sequence if needed */
if (empty($_POST["sequence"])) {
$_POST["sequence"] = get_sequence($_POST["sequence"], "sequence", "graph_templates_item", "graph_template_id=" . $_POST["graph_template_id"] . " and local_graph_id=0");
}
$save["id"] = $_POST["graph_template_item_id"];
$save["hash"] = get_hash_graph_template($_POST["graph_template_item_id"], "graph_template_item");
$save["graph_template_id"] = $_POST["graph_template_id"];
$save["local_graph_id"] = 0;
$save["task_item_id"] = form_input_validate($_POST["task_item_id"], "task_item_id", "", true, 3);
$save["color_id"] = form_input_validate((isset($item["color_id"]) ? $item["color_id"] : $_POST["color_id"]), "color_id", "", true, 3);
/* if alpha is disabled, use invisible_alpha instead */
if (!isset($_POST["alpha"])) {$_POST["alpha"] = $_POST["invisible_alpha"];}
$save["alpha"] = form_input_validate((isset($item["alpha"]) ? $item["alpha"] : $_POST["alpha"]), "alpha", "", true, 3);
$save["graph_type_id"] = form_input_validate((isset($item["graph_type_id"]) ? $item["graph_type_id"] : $_POST["graph_type_id"]), "graph_type_id", "", true, 3);
$save["cdef_id"] = form_input_validate($_POST["cdef_id"], "cdef_id", "", true, 3);
$save["consolidation_function_id"] = form_input_validate((isset($item["consolidation_function_id"]) ? $item["consolidation_function_id"] : $_POST["consolidation_function_id"]), "consolidation_function_id", "", true, 3);
$save["text_format"] = form_input_validate((isset($item["text_format"]) ? $item["text_format"] : $_POST["text_format"]), "text_format", "", true, 3);
$save["value"] = form_input_validate($_POST["value"], "value", "", true, 3);
$save["hard_return"] = form_input_validate(((isset($item["hard_return"]) ? $item["hard_return"] : (isset($_POST["hard_return"]) ? $_POST["hard_return"] : ""))), "hard_return", "", true, 3);
$save["gprint_id"] = form_input_validate($_POST["gprint_id"], "gprint_id", "", true, 3);
$save["sequence"] = $_POST["sequence"];
if (!is_error_message()) {
/* Before we save the item, let's get a look at task_item_id <-> input associations */
$orig_data_source_graph_inputs = db_fetch_assoc("select
graph_template_input.id,
graph_template_input.name,
graph_templates_item.task_item_id
from (graph_template_input,graph_template_input_defs,graph_templates_item)
where graph_template_input.id=graph_template_input_defs.graph_template_input_id
and graph_template_input_defs.graph_template_item_id=graph_templates_item.id
and graph_template_input.graph_template_id=" . $save["graph_template_id"] . "
and graph_template_input.column_name='task_item_id'
group by graph_templates_item.task_item_id");
$orig_data_source_to_input = array_rekey($orig_data_source_graph_inputs, "task_item_id", "id");
$graph_template_item_id = sql_save($save, "graph_templates_item");
if ($graph_template_item_id) {
raise_message(1);
if (!empty($save["task_item_id"])) {
/* old item clean-up. Don't delete anything if the item <-> task_item_id association remains the same. */
if ($_POST["_task_item_id"] != $_POST["task_item_id"]) {
/* It changed. Delete any old associations */
db_execute("delete from graph_template_input_defs where graph_template_item_id=$graph_template_item_id");
/* Input for current data source exists and has changed. Update the association */
if (isset($orig_data_source_to_input{$save["task_item_id"]})) {
db_execute("replace into graph_template_input_defs (graph_template_input_id,
graph_template_item_id) values (" . $orig_data_source_to_input{$save["task_item_id"]}
. ",$graph_template_item_id)");
}
}
/* an input for the current data source does NOT currently exist, let's create one */
if (!isset($orig_data_source_to_input{$save["task_item_id"]})) {
$ds_name = db_fetch_cell("select data_source_name from data_template_rrd where id=" . $_POST["task_item_id"]);
//.........这里部分代码省略.........
开发者ID:songchin,项目名称:Cacti,代码行数:101,代码来源:graph_templates_items.php
示例9: mactrack_snmp_item_edit
function mactrack_snmp_item_edit() {
global $config, $colors;
global $fields_mactrack_snmp_item_edit;
#print "<pre>Post: "; print_r($_POST); print "Get: "; print_r($_GET); print "Request: "; print_r($_REQUEST); /*print "Session: "; print_r($_SESSION);*/ print "</pre>";
/* ================= input validation ================= */
input_validate_input_number(get_request_var("id"));
input_validate_input_number(get_request_var("item_id"));
/* ==================================================== */
# fetch the current mactrack snmp record
$snmp_option = db_fetch_row("SELECT * " .
"FROM mac_track_snmp " .
"WHERE id=" . get_request_var_request("id"));
# if an existing item was requested, fetch data for it
if (get_request_var_request("item_id", '') !== '') {
$mactrack_snmp_item = db_fetch_row("SELECT * " .
"FROM mac_track_snmp_items" .
" WHERE id=" . get_request_var_request("item_id"));
$header_label = "[edit SNMP Options: " . $snmp_option['name'] . "]";
}else{
$header_label = "[new SNMP Options: " . $snmp_option['name'] . "]";
$mactrack_snmp_item = array();
$mactrack_snmp_item["snmp_id"] = get_request_var_request("id");
$mactrack_snmp_item["sequence"] = get_sequence('', 'sequence', 'mac_track_snmp_items', 'snmp_id=' . get_request_var_request("id"));
}
print "<form method='post' action='" . basename($_SERVER["PHP_SELF"]) . "' name='mactrack_item_edit'>\n";
# ready for displaying the fields
html_start_box("<strong>SNMP Options</strong> $header_label", "100%", $colors["header"], "3", "center", "");
draw_edit_form(array(
"config" => array("no_form_tag" => true),
"fields" => inject_form_variables($fields_mactrack_snmp_item_edit, (isset($mactrack_snmp_item) ? $mactrack_snmp_item : array()))
));
html_end_box();
form_hidden_box("item_id", (isset($_GET["item_id"]) ? $_GET["item_id"] : "0"), "");
form_hidden_box("id", (isset($mactrack_snmp_item["snmp_id"]) ? $mactrack_snmp_item["snmp_id"] : "0"), "");
form_hidden_box("save_component_mactrack_snmp_item", "1", "");
mactrack_save_button(htmlspecialchars("mactrack_snmp.php?action=edit&id=" . get_request_var_request("id")));
print "<script type='text/javascript' src='" . URL_PATH . "plugins/mactrack/mactrack_snmp.js'></script>";
}
开发者ID:avillaverdec,项目名称:cacti,代码行数:46,代码来源:mactrack_snmp.php
示例10: find_genbank_from_id
function find_genbank_from_id($referent, &$item)
{
global $debug;
global $error;
$found = false;
if ($debug) {
echo '<div style="border: 1px solid #c7cfd5;background: rgb(255,255,153);padding:15px;">';
echo "<p><b>Find GenBank sequence from accession number</b></p>";
echo '<pre>';
print_r($values);
echo '</pre>';
echo '</div>';
}
$acc = '';
if (array_key_exists('genbank', $referent->id)) {
$acc = $referent->id['genbank'];
} else {
$acc = $referent->id['gi'];
}
//echo $acc;
if (get_sequence($acc, &$item) != 0) {
//print_r($item);
$found = true;
}
return $found;
}
开发者ID:rdmpage,项目名称:bioguid,代码行数:26,代码来源:openurl.php
示例11: form_save
//.........这里部分代码省略.........
$save["color_id"] = form_input_validate(((isset($item["color_id"]) ? $item["color_id"] : (isset($_POST["color_id"]) ? $_POST["color_id"] : 0))), "color_id", "^[0-9]+$", true, 3);
$save["alpha"] = form_input_validate(((isset($item["alpha"]) ? $item["alpha"] : (isset($_POST["alpha"]) ? $_POST["alpha"] : "FF"))), "alpha", "^[a-fA-F0-9]+$", true, 3);
$save["graph_type_id"] = form_input_validate(((isset($item["graph_type_id"]) ? $item["graph_type_id"] : (isset($_POST["graph_type_id"]) ? $_POST["graph_type_id"] : 0))), "graph_type_id", "^[0-9]+$", true, 3);
if (isset($_POST["line_width"]) || isset($item["line_width"])) {
$save["line_width"] = form_input_validate((isset($item["line_width"]) ? $item["line_width"] : $_POST["line_width"]), "line_width", "^[0-9]+[\.,]+[0-9]+$", true, 3);
}else { # make sure to transfer old LINEx style into line_width on save
switch ($save["graph_type_id"]) {
case GRAPH_ITEM_TYPE_LINE1:
$save["line_width"] = 1;
break;
case GRAPH_ITEM_TYPE_LINE2:
$save["line_width"] = 2;
break;
case GRAPH_ITEM_TYPE_LINE3:
$save["line_width"] = 3;
break;
default:
$save["line_width"] = 0;
}
}
$save["dashes"] = form_input_validate((isset($_POST["dashes"]) ? $_POST["dashes"] : ""), "dashes", "^[0-9]+[,0-9]*$", true, 3);
$save["dash_offset"] = form_input_validate((isset($_POST["dash_offset"]) ? $_POST["dash_offset"] : ""), "dash_offset", "^[0-9]+$", true, 3);
$save["cdef_id"] = form_input_validate(((isset($item["cdef_id"]) ? $item["cdef_id"] : (isset($_POST["cdef_id"]) ? $_POST["cdef_id"] : 0))), "cdef_id", "^[0-9]+$", true, 3);
$save["vdef_id"] = form_input_validate(((isset($item["vdef_id"]) ? $item["vdef_id"] : (isset($_POST["vdef_id"]) ? $_POST["vdef_id"] : 0))), "vdef_id", "^[0-9]+$", true, 3);
$save["shift"] = form_input_validate((isset($_POST["shift"]) ? $_POST["shift"] : ""), "shift", "^((on)|)$", true, 3);
$save["consolidation_function_id"] = form_input_validate(((isset($item["consolidation_function_id"]) ? $item["consolidation_function_id"] : (isset($_POST["consolidation_function_id"]) ? $_POST["consolidation_function_id"] : 0))), "consolidation_function_id", "^[0-9]+$", true, 3);
$save["textalign"] = form_input_validate((isset($_POST["textalign"]) ? $_POST["textalign"] : ""), "textalign", "^[a-z]+$", true, 3);
$save["text_format"] = form_input_validate(((isset($item["text_format"]) ? $item["text_format"] : (isset($_POST["text_format"]) ? $_POST["text_format"] : ""))), "text_format", "", true, 3);
$save["value"] = form_input_validate((isset($_POST["value"]) ? $_POST["value"] : ""), "value", "", true, 3);
$save["hard_return"] = form_input_validate(((isset($item["hard_return"]) ? $item["hard_return"] : (isset($_POST["hard_return"]) ? $_POST["hard_return"] : ""))), "hard_return", "", true, 3);
$save["gprint_id"] = form_input_validate(((isset($item["gprint_id"]) ? $item["gprint_id"] : (isset($_POST["gprint_id"]) ? $_POST["gprint_id"] : 0))), "gprint_id", "^[0-9]+$", true, 3);
/* generate a new sequence if needed */
if (empty($_POST["sequence"])) {
$_POST["sequence"] = get_sequence($_POST["sequence"], "sequence", "graph_templates_item", "graph_template_id=" . $_POST["graph_template_id"] . " and local_graph_id=0");
}
$save["sequence"] = form_input_validate($_POST["sequence"], "sequence", "^[0-9]+$", false, 3);
if (!is_error_message()) {
/* Before we save the item, let's get a look at task_item_id <-> input associations */
$orig_data_source_graph_inputs = db_fetch_assoc("select
graph_template_input.id,
graph_template_input.name,
graph_templates_item.task_item_id
from (graph_template_input,graph_template_input_defs,graph_templates_item)
where graph_template_input.id=graph_template_input_defs.graph_template_input_id
and graph_template_input_defs.graph_template_item_id=graph_templates_item.id
and graph_template_input.graph_template_id=" . $save["graph_template_id"] . "
and graph_template_input.column_name='task_item_id'
group by graph_templates_item.task_item_id");
$orig_data_source_to_input = array_rekey($orig_data_source_graph_inputs, "task_item_id", "id");
$graph_template_item_id = sql_save($save, "graph_templates_item");
if ($graph_template_item_id) {
raise_message(1);
if (!empty($save["task_item_id"])) {
/* old item clean-up. Don't delete anything if the item <-> task_item_id association remains the same. */
if ($_POST["hidden_task_item_id"] != $_POST["task_item_id"]) {
/* It changed. Delete any old associations */
db_execute("delete from graph_template_input_defs where graph_template_item_id=$graph_template_item_id");
/* Input for current data source exists and has changed. Update the association */
if (isset($orig_data_source_to_input{$save["task_item_id"]})) {
db_execute("REPLACE INTO graph_template_input_defs " .
开发者ID:songchin,项目名称:Cacti,代码行数:67,代码来源:graph_templates_items.php
示例12: form_save
function form_save()
{
if (isset($_POST['save_component_cdef'])) {
$save['id'] = form_input_validate($_POST['id'], 'id', '^[0-9]+$', false, 3);
$save['hash'] = get_hash_cdef($_POST['id']);
$save['name'] = form_input_validate($_POST['name'], 'name', '', false, 3);
if (!is_error_message()) {
$cdef_id = sql_save($save, 'cdef');
if ($cdef_id) {
raise_message(1);
} else {
raise_message(2);
}
}
header('Location: cdef.php?action=edit&id=' . (empty($cdef_id) ? $_POST['id'] : $cdef_id));
} elseif (isset($_POST['save_component_item'])) {
$sequence = get_sequence($_POST['id'], 'sequence', 'cdef_items', 'cdef_id=' . $_POST['cdef_id']);
$save['id'] = form_input_validate($_POST['id'], 'id', '^[0-9]+$', false, 3);
$save['hash'] = get_hash_cdef($_POST['id'], 'cdef_item');
$save['cdef_id'] = form_input_validate($_POST['cdef_id'], 'cdef_id', '^[0-9]+$', false, 3);
$save['sequence'] = $sequence;
$save['type'] = form_input_validate($_POST['type'], 'type', '^[0-9]+$', false, 3);
$save['value'] = form_input_validate($_POST['value'], 'value', '', false, 3);
if (!is_error_message()) {
$cdef_item_id = sql_save($save, 'cdef_items');
if ($cdef_item_id) {
raise_message(1);
} else {
raise_message(2);
}
}
if (is_error_message()) {
header('Location: cdef.php?action=item_edit&cdef_id=' . $_POST['cdef_id'] . '&id=' . (empty($cdef_item_id) ? $_POST['id'] : $cdef_item_id));
} else {
header('Lo
|
请发表评论