本文整理汇总了PHP中db_fetch_cell_prepared函数的典型用法代码示例。如果您正苦于以下问题:PHP db_fetch_cell_prepared函数的具体用法?PHP db_fetch_cell_prepared怎么用?PHP db_fetch_cell_prepared使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_fetch_cell_prepared函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_cdef_item_name
function get_cdef_item_name($cdef_item_id)
{
global $cdef_functions, $cdef_operators;
$cdef_item = db_fetch_row_prepared('SELECT type, value FROM cdef_items WHERE id = ?', array($cdef_item_id));
$current_cdef_value = $cdef_item['value'];
switch ($cdef_item['type']) {
case '1':
return $cdef_functions[$current_cdef_value];
break;
case '2':
return $cdef_operators[$current_cdef_value];
break;
case '4':
return $current_cdef_value;
break;
case '5':
return db_fetch_cell_prepared('SELECT name FROM cdef WHERE id = ?', array($current_cdef_value));
break;
case '6':
return $current_cdef_value;
break;
}
}
示例2: tree_remove
function tree_remove()
{
/* ================= input validation ================= */
input_validate_input_number(get_request_var_request('id'));
/* ==================================================== */
if (read_config_option('deletion_verification') == 'on' && !isset($_REQUEST['confirm'])) {
top_header();
form_confirm('Are You Sure?', "Are you sure you want to delete the tree <strong>'" . htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM graph_tree WHERE id = ?', array($_REQUEST['id'])), ENT_QUOTES) . "'</strong>?", htmlspecialchars('tree.php'), htmlspecialchars('tree.php?action=remove&id=' . $_REQUEST['id']));
bottom_footer();
exit;
}
if (read_config_option('deletion_verification') == '' || isset($_REQUEST['confirm'])) {
db_execute_prepared('DELETE FROM graph_tree WHERE id = ?', array($_REQUEST['id']));
db_execute_prepared('DELETE FROM graph_tree_items WHERE graph_tree_id = ?', array($_REQUEST['id']));
}
/* clear graph tree cache on save - affects current user only, other users should see changes in <5 minutes */
if (isset($_SESSION['dhtml_tree'])) {
unset($_SESSION['dhtml_tree']);
}
}
示例3: host_edit
//.........这里部分代码省略.........
}
if (!empty($host['id'])) {
html_start_box('<strong>Associated Graph Templates</strong>', '100%', '', '3', 'center', '');
html_header(array('Graph Template Name', 'Status'), 2);
$selected_graph_templates = db_fetch_assoc_prepared('SELECT
graph_templates.id,
graph_templates.name
FROM (graph_templates, host_graph)
WHERE graph_templates.id = host_graph.graph_template_id
AND host_graph.host_id = ?
ORDER BY graph_templates.name', array($_REQUEST['id']));
$available_graph_templates = db_fetch_assoc('SELECT
graph_templates.id, graph_templates.name
FROM snmp_query_graph RIGHT JOIN graph_templates
ON (snmp_query_graph.graph_template_id = graph_templates.id)
WHERE (((snmp_query_graph.name) Is Null)) ORDER BY graph_templates.name');
$i = 0;
if (sizeof($selected_graph_templates) > 0) {
foreach ($selected_graph_templates as $item) {
form_alternate_row('', true);
/* get status information for this graph template */
$is_being_graphed = sizeof(db_fetch_assoc_prepared('SELECT id FROM graph_local WHERE graph_template_id = ? AND host_id = ?', array($item['id'], $_REQUEST['id']))) > 0 ? true : false;
?>
<td style="padding: 4px;">
<strong><?php
print $i;
?>
)</strong> <?php
print htmlspecialchars($item['name']);
?>
</td>
<td>
<?php
print $is_being_graphed == true ? "<span style='color: green;'>Is Being Graphed</span> (<a href='" . htmlspecialchars('graphs.php?action=graph_edit&id=' . db_fetch_cell_prepared('SELECT id FROM graph_local WHERE graph_template_id = ? AND host_id = ? LIMIT 0,1', array($item['id'], $_REQUEST['id']))) . "'>Edit</a>)" : "<span style='color: #484848;'>Not Being Graphed</span>";
?>
</td>
<td align='right' nowrap>
<a href='<?php
print htmlspecialchars('host.php?action=gt_remove&id=' . $item['id'] . '&host_id=' . $_REQUEST['id']);
?>
'><img src='images/delete_icon_large.gif' title='Delete Graph Template Association' alt='Delete Graph Template Association' border='0' align='middle'></a>
</td>
<?php
form_end_row();
$i++;
}
} else {
print "<tr class='tableRow'><td colspan='2'><em>No associated graph templates.</em></td></tr>";
}
?>
<tr class='odd'>
<td class='saveRow' colspan="4">
<table cellspacing="0" cellpadding="1" width="100%">
<td nowrap>Add Graph Template:
<?php
form_dropdown('graph_template_id', $available_graph_templates, 'name', 'id', '', '', '');
?>
</td>
<td align="right">
<input type="submit" value="Add" name="add_gt_x" title="Add Graph Template to Device">
</td>
</table>
</td>
</tr>
<?php
示例4: add_host_based_graphs
function add_host_based_graphs()
{
global $config, $device_hashes, $device_query_hashes, $device_health_hashes;
debug('Adding Host Based Graphs');
/* check for host level graphs next data queries */
$host_cpu_dq = read_config_option('mikrotik_dq_host_cpu');
$host_users_dq = mikrotik_data_query_by_hash('ce63249e6cc3d52bc69659a3f32194fe');
$hosts = db_fetch_assoc("SELECT host_id, host.description, host.hostname \n\t\tFROM plugin_mikrotik_system\n\t\tINNER JOIN host\n\t\tON host.id=plugin_mikrotik_system.host_id\n\t\tWHERE host_status IN(0,3) AND host.disabled=''");
if (sizeof($hosts)) {
foreach ($hosts as $h) {
debug('Processing Host: ' . $h['description'] . ' [' . $h['hostname'] . ']');
foreach ($device_hashes as $hash) {
$template = mikrotik_template_by_hash($hash);
if (!empty($template)) {
debug('Processing ' . db_fetch_cell_prepared('SELECT name FROM graph_templates WHERE hash = ?', array($hash)));
mikrotik_gt_graph($h['host_id'], $template);
}
}
foreach ($device_query_hashes as $hash) {
$query = mikrotik_data_query_by_hash($hash);
if (!empty($query)) {
debug('Processing ' . db_fetch_cell_prepared('SELECT name FROM snmp_query WHERE hash = ?', array($hash)));
if ($hash == '7dd90372956af1dc8ec7b859a678f227') {
$exclusion = read_config_option('mikrotik_user_exclusion');
add_host_dq_graphs($h['host_id'], $query, 'userName', $exclusion, false);
} else {
add_host_dq_graphs($h['host_id'], $query);
}
}
}
$health = db_fetch_row_prepared('SELECT * FROM plugin_mikrotik_system_health WHERE host_id = ?', array($h['host_id']));
debug('Processing Health');
if (sizeof($health)) {
foreach ($device_health_hashes as $column => $hash) {
if (!empty($health[$column]) && $health[$column] != 'NULL') {
$template = mikrotik_template_by_hash($hash);
if (!empty($template)) {
debug('Processing ' . db_fetch_cell_prepared('SELECT name FROM graph_templates WHERE hash = ?', array($hash)));
mikrotik_gt_graph($h['host_id'], $template);
}
}
}
}
}
} else {
debug('No Hosts Found');
}
}
示例5: thold_add_graphs_action_execute
function thold_add_graphs_action_execute()
{
global $config;
include_once $config['base_path'] . '/plugins/thold/thold_functions.php';
$host_id = get_filter_request_var('host_id');
$local_graph_id = get_filter_request_var('local_data_id');
$thold_template_id = get_filter_request_var('thold_template_id');
$message = '';
$template = db_fetch_row_prepared('SELECT * FROM thold_template WHERE id = ?', array($thold_template_id));
$temp = db_fetch_row_prepared('SELECT dtr.*
FROM data_template_rrd AS dtr
LEFT JOIN graph_templates_item AS gti
ON gti.task_item_id=dtr.id
LEFT JOIN graph_local AS gl
ON gl.id=gti.local_graph_id
WHERE gl.id = ?', array($local_graph_id));
$data_template_id = $temp['data_template_id'];
$local_data_id = $temp['local_data_id'];
$data_source = db_fetch_row_prepared('SELECT * FROM data_local WHERE id = ?', array($local_data_id));
$data_template_id = $data_source['data_template_id'];
/* allow duplicate thresholds, but only from differing templates */
$existing = db_fetch_assoc('SELECT id
FROM thold_data
WHERE local_data_id=' . $local_data_id . '
AND data_template_rrd_id=' . $data_template_id . '
AND thold_template_id=' . $template['id'] . " AND template_enabled='on'");
if (count($existing) == 0 && count($template)) {
if ($local_graph_id) {
$rrdlookup = db_fetch_cell("SELECT id FROM data_template_rrd WHERE local_data_id={$local_data_id} ORDER BY id LIMIT 1");
$grapharr = db_fetch_row("SELECT graph_template_id FROM graph_templates_item WHERE task_item_id={$rrdlookup} AND local_graph_id = {$local_graph_id}");
$desc = db_fetch_cell_prepared('SELECT name_cache FROM data_template_data WHERE local_data_id = ? LIMIT 1', array($local_data_id));
$data_source_name = $template['data_source_name'];
$insert = array();
$name = thold_format_name($template, $local_graph_id, $local_data_id, $data_source_name);
$insert['name'] = $name;
$insert['host_id'] = $data_source['host_id'];
$insert['local_data_id'] = $local_data_id;
$insert['local_graph_id'] = $local_graph_id;
$insert['data_template_id'] = $data_template_id;
$insert['graph_template_id'] = $grapharr['graph_template_id'];
$insert['thold_hi'] = $template['thold_hi'];
$insert['thold_low'] = $template['thold_low'];
$insert['thold_fail_trigger'] = $template['thold_fail_trigger'];
$insert['thold_enabled'] = $template['thold_enabled'];
$insert['thold_warning_hi'] = $template['thold_warning_hi'];
$insert['thold_warning_low'] = $template['thold_warning_low'];
$insert['thold_warning_fail_trigger'] = $template['thold_warning_fail_trigger'];
$insert['bl_ref_time_range'] = $template['bl_ref_time_range'];
$insert['bl_pct_down'] = $template['bl_pct_down'];
$insert['bl_pct_up'] = $template['bl_pct_up'];
$insert['bl_fail_trigger'] = $template['bl_fail_trigger'];
$insert['bl_alert'] = $template['bl_alert'];
$insert['repeat_alert'] = $template['repeat_alert'];
$insert['notify_extra'] = $template['notify_extra'];
$insert['cdef'] = $template['cdef'];
$insert['thold_template_id'] = $template['id'];
$insert['template_enabled'] = 'on';
$rrdlist = db_fetch_assoc("SELECT id, data_input_field_id\n\t\t\t\tFROM data_template_rrd\n\t\t\t\tWHERE local_data_id='{$local_data_id}'\n\t\t\t\tAND data_source_name='{$data_source_name}'");
$int = array('id', 'data_template_id', 'data_source_id', 'thold_fail_trigger', 'bl_ref_time_range', 'bl_pct_down', 'bl_pct_up', 'bl_fail_trigger', 'bl_alert', 'repeat_alert', 'cdef');
foreach ($rrdlist as $rrdrow) {
$data_rrd_id = $rrdrow['id'];
$insert['data_template_rrd_id'] = $data_rrd_id;
$existing = db_fetch_assoc("SELECT id\n\t\t\t\t\tFROM thold_data\n\t\t\t\t\tWHERE local_data_id='{$local_data_id}'\n\t\t\t\t\tAND data_template_rrd_id='{$data_rrd_id}'\n\t\t\t\t\tAND thold_template_id='" . $template['id'] . "' AND template_enabled='on'");
if (count($existing) == 0) {
$insert['id'] = 0;
$id = sql_save($insert, 'thold_data');
if ($id) {
thold_template_update_threshold($id, $insert['template']);
$l = db_fetch_assoc("SELECT name FROM data_template where id={$data_template_id}");
$tname = $l[0]['name'];
$name = $data_source_name;
if ($rrdrow['data_input_field_id'] != 0) {
$l = db_fetch_assoc('SELECT name FROM data_input_fields where id=' . $rrdrow['data_input_field_id']);
$name = $l[0]['name'];
}
plugin_thold_log_changes($id, 'created', " {$tname} [{$name}]");
$message .= "Created threshold for the Graph '<i>{$tname}</i>' using the Data Source '<i>{$name}</i>'<br>";
}
}
}
}
}
if (strlen($message)) {
$_SESSION['thold_message'] = "<font size=-2>{$message}</font>";
} else {
$_SESSION['thold_message'] = "<font size=-2>" . __('Threshold(s) Already Exists - No Thresholds Created') . "</font>";
}
raise_message('thold_message');
if (isset($_SESSION['graph_return'])) {
$return_to = $_SESSION['graph_return'];
unset($_SESSION['graph_return']);
kill_session_var('graph_return');
header('Location: ' . $return_to . (strpos($return_to, '?') !== false ? '&' : '?') . 'header=false');
} else {
header('Location:' . $config['url_path'] . 'plugins/thold/thold.php?header=false');
}
}
示例6: boost_rrdtool_function_create
function boost_rrdtool_function_create($local_data_id, $initial_time, $show_source)
{
global $config;
include $config['include_path'] . '/global_arrays.php';
$data_source_path = get_data_source_path($local_data_id, true);
/* ok, if that passes lets check to make sure an rra does not already
exist, the last thing we want to do is overright data! */
if ($show_source != true) {
if (file_exists($data_source_path) == true) {
return -1;
}
}
/* the first thing we must do is make sure there is at least one
rra associated with this data source... *
UPDATE: As of version 0.6.6, we are splitting this up into two
SQL strings because of the multiple DS per RRD support. This is
not a big deal however since this function gets called once per
data source */
$rras = db_fetch_assoc_prepared('SELECT
data_template_data.rrd_step,
rra.x_files_factor,
rra.steps,
rra.rows,
rra_cf.consolidation_function_id,
(rra.rows * rra.steps) AS rra_order
FROM data_template_data
LEFT JOIN data_template_data_rra ON (data_template_data.id = data_template_data_rra.data_template_data_id)
LEFT JOIN rra ON (data_template_data_rra.rra_id = rra.id)
LEFT JOIN rra_cf ON (rra.id = rra_cf.rra_id)
WHERE data_template_data.local_data_id = ?
AND (rra.steps is not null OR rra.rows is not null)
ORDER BY rra_cf.consolidation_function_id, rra_order', array($local_data_id));
/* if we find that this DS has no RRA associated; get out. This would
* indicate that a data sources has been deleted
*/
if (sizeof($rras) <= 0) {
return false;
}
/* back off the initial time to allow updates */
$initial_time -= 300;
/* create the "--step" line */
$create_ds = RRD_NL . '--start ' . $initial_time . ' --step ' . $rras[0]['rrd_step'] . ' ' . RRD_NL;
/* query the data sources to be used in this .rrd file */
$data_sources = db_fetch_assoc_prepared('SELECT
data_template_rrd.id,
data_template_rrd.rrd_heartbeat,
data_template_rrd.rrd_minimum,
data_template_rrd.rrd_maximum,
data_template_rrd.data_source_type_id
FROM data_template_rrd
WHERE data_template_rrd.local_data_id = ?
ORDER BY local_data_template_rrd_id', array($local_data_id));
/* ONLY make a new DS entry if:
- There is multiple data sources and this item is not the main one.
- There is only one data source (then use it) */
if (sizeof($data_sources) > 0) {
foreach ($data_sources as $data_source) {
/* use the cacti ds name by default or the user defined one, if entered */
$data_source_name = get_data_source_item_name($data_source['id']);
if (empty($data_source['rrd_maximum'])) {
/* in case no maximum is given, use "Undef" value */
$data_source['rrd_maximum'] = 'U';
} elseif (strpos($data_source['rrd_maximum'], '|query_') !== false) {
$data_local = db_fetch_row_prepared('SELECT * FROM data_local WHERE id = ?', array($local_data_id));
if ($data_source['rrd_maximum'] == '|query_ifSpeed|' || $data_source['rrd_maximum'] == '|query_ifHighSpeed|') {
$highSpeed = db_fetch_cell_prepared("SELECT field_value\n\t\t\t\t\tFROM host_snmp_cache\n\t\t\t\t\tWHERE host_id = ?\n\t\t\t\t\tAND snmp_query_id = ?\n\t\t\t\t\tAND snmp_index = ?\n\t\t\t\t\tAND field_name = 'ifHighSpeed'", array($data_local['host_id'], $data_local['snmp_query_id'], $data_local['snmp_index']));
if (!empty($highSpeed)) {
$data_source['rrd_maximum'] = $highSpeed * 1000000;
} else {
$data_source['rrd_maximum'] = substitute_snmp_query_data('|query_ifSpeed|', $data_local['host_id'], $data_local['snmp_query_id'], $data_local['snmp_index']);
}
} else {
$data_source['rrd_maximum'] = substitute_snmp_query_data($data_source['rrd_maximum'], $data_local['host_id'], $data_local['snmp_query_id'], $data_local['snmp_index']);
}
} elseif ($data_source['rrd_maximum'] != 'U' && (int) $data_source['rrd_maximum'] <= (int) $data_source['rrd_minimum']) {
/* max > min required, but take care of an "Undef" value */
$data_source['rrd_maximum'] = (int) $data_source['rrd_minimum'] + 1;
}
/* min==max==0 won't work with rrdtool */
if ($data_source['rrd_minimum'] == 0 && $data_source['rrd_maximum'] == 0) {
$data_source['rrd_maximum'] = 'U';
}
$create_ds .= "DS:{$data_source_name}:" . $data_source_types[$data_source['data_source_type_id']] . ':' . $data_source['rrd_heartbeat'] . ':' . $data_source['rrd_minimum'] . ':' . $data_source['rrd_maximum'] . RRD_NL;
}
}
$create_rra = '';
/* loop through each available RRA for this DS */
foreach ($rras as $rra) {
$create_rra .= 'RRA:' . $consolidation_functions[$rra['consolidation_function_id']] . ':' . $rra['x_files_factor'] . ':' . $rra['steps'] . ':' . $rra['rows'] . RRD_NL;
}
/* check for structured path configuration, if in place verify directory
exists and if not create it.
*/
if (read_config_option('extended_paths') == 'on') {
if (!is_dir(dirname($data_source_path))) {
if (mkdir(dirname($data_source_path), 0775)) {
if ($config['cacti_server_os'] != 'win32') {
$owner_id = fileowner($config['rra_path']);
$group_id = filegroup($config['rra_path']);
if (chown(dirname($data_source_path), $owner_id) && chgrp(dirname($data_source_path), $group_id)) {
//.........这里部分代码省略.........
示例7: settings
function settings()
{
global $tabs_graphs, $settings_graphs, $current_user, $graph_views, $current_user;
/* you cannot have per-user graph settings if cacti's user management is not turned on */
if (read_config_option('auth_method') == 0) {
raise_message(6);
display_output_messages();
return;
}
if ($_REQUEST['action'] == 'edit') {
if (isset($_SERVER['HTTP_REFERER'])) {
$timespan_sel_pos = strpos($_SERVER['HTTP_REFERER'], '&predefined_timespan');
if ($timespan_sel_pos) {
$_SERVER['HTTP_REFERER'] = substr($_SERVER['HTTP_REFERER'], 0, $timespan_sel_pos);
}
}
$_SESSION['profile_referer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'graph_view.php';
}
print "<form method='post' action='auth_profile.php'>\n";
html_start_box('<strong>User Settings</strong>', '100%', '', '3', 'center', '');
$current_user = db_fetch_row_prepared('SELECT * FROM user_auth WHERE id = ?', array($_SESSION['sess_user_id']));
if (!sizeof($current_user)) {
return;
}
/* file: user_admin.php, action: user_edit (host) */
$fields_user = array('username' => array('method' => 'value', 'friendly_name' => 'User Name', 'description' => 'The login name for this user.', 'value' => '|arg1:username|', 'max_length' => '40', 'size' => '40'), 'full_name' => array('method' => 'textbox', 'friendly_name' => 'Full Name', 'description' => 'A more descriptive name for this user, that can include spaces or special characters.', 'value' => '|arg1:full_name|', 'max_length' => '120', 'size' => '60'), 'email_address' => array('method' => 'textbox', 'friendly_name' => 'E-Mail Address', 'description' => 'An E-Mail Address you be reached at.', 'value' => '|arg1:email_address|', 'max_length' => '60', 'size' => '60'));
draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => inject_form_variables($fields_user, isset($current_user) ? $current_user : array())));
html_end_box();
if (is_view_allowed('graph_settings') == true) {
if (read_config_option('auth_method') != 0) {
$settings_graphs['tree']['default_tree_id']['sql'] = get_graph_tree_array(true);
}
html_start_box('<strong>Graph Settings</strong>', '100%', '', '3', 'center', '');
while (list($tab_short_name, $tab_fields) = each($settings_graphs)) {
$collapsible = true;
print "<tr class='spacer tableHeader" . ($collapsible ? ' collapsible' : '') . "' id='row_{$tab_short_name}'><td colspan='2' style='cursor:pointer;' class='tableSubHeaderColumn'>" . $tabs_graphs[$tab_short_name] . ($collapsible ? "<div style='float:right;padding-right:4px;'><i class='fa fa-angle-double-up'></i></div>" : "") . "</td></tr>\n";
$form_array = array();
while (list($field_name, $field_array) = each($tab_fields)) {
$form_array += array($field_name => $tab_fields[$field_name]);
if (isset($field_array['items']) && is_array($field_array['items'])) {
while (list($sub_field_name, $sub_field_array) = each($field_array['items'])) {
if (graph_config_value_exists($sub_field_name, $_SESSION['sess_user_id'])) {
$form_array[$field_name]['items'][$sub_field_name]['form_id'] = 1;
}
$form_array[$field_name]['items'][$sub_field_name]['value'] = db_fetch_cell_prepared('SELECT value FROM settings_graphs WHERE name = ? AND user_id = ?', array($sub_field_name, $_SESSION['sess_user_id']));
}
} else {
if (graph_config_value_exists($field_name, $_SESSION['sess_user_id'])) {
$form_array[$field_name]['form_id'] = 1;
}
$form_array[$field_name]['value'] = db_fetch_cell_prepared('SELECT value FROM settings_graphs WHERE name = ? AND user_id = ?', array($field_name, $_SESSION['sess_user_id']));
}
}
draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array));
}
html_end_box();
}
?>
<script type="text/javascript">
<!--
var themeFonts=<?php
print read_config_option('font_method');
?>
;
function graphSettings() {
if (themeFonts == 1) {
$('#row_fonts').hide();
$('#row_custom_fonts').hide();
$('#row_title_size').hide();
$('#row_title_font').hide();
$('#row_legend_size').hide();
$('#row_legend_font').hide();
$('#row_axis_size').hide();
$('#row_axis_font').hide();
$('#row_unit_size').hide();
$('#row_unit_font').hide();
}else{
var custom_fonts = $('#custom_fonts').is(':checked');
switch(custom_fonts) {
case true:
$('#row_fonts').show();
$('#row_title_size').show();
$('#row_title_font').show();
$('#row_legend_size').show();
$('#row_legend_font').show();
$('#row_axis_size').show();
$('#row_axis_font').show();
$('#row_unit_size').show();
$('#row_unit_font').show();
break;
case false:
$('#row_fonts').show();
$('#row_title_size').hide();
$('#row_title_font').hide();
$('#row_legend_size').hide();
$('#row_legend_font').hide();
$('#row_axis_size').hide();
$('#row_axis_font').hide();
//.........这里部分代码省略.........
示例8: mactrack_snmp_remove
function mactrack_snmp_remove()
{
/* ================= input validation ================= */
get_filter_request_var('id');
/* ==================================================== */
if (read_config_option('deletion_verification') == 'on' && !isset_request_var('confirm')) {
general_header();
form_confirm(__('Are You Sure?'), __('Are you sure you want to delete the SNMP Option Set(s) %s?', db_fetch_cell_prepared('SELECT name FROM mactrack WHERE id = ?', array(get_request_var('id')))), 'mactrack_snmp.php', 'mactrack_snmp.php?action=remove&id=' . get_request_var('id'));
bottom_footer();
exit;
}
if (read_config_option('deletion_verification') == '' || isset_request_var('confirm')) {
db_execute_prepared('DELETE FROM mac_track_snmp_items WHERE snmp_id = ?', array(get_request_var('id')));
db_execute_prepared('DELETE FROM mac_track_snmp WHERE id = ?', array(get_request_var('id')));
}
}
示例9: api_reapply_suggested_data_source_title
function api_reapply_suggested_data_source_title($local_data_id)
{
global $config;
$data_template_data_id = db_fetch_cell_prepared('SELECT id FROM data_template_data WHERE local_data_id = ?', array($local_data_id));
if (empty($data_template_data_id)) {
return;
}
/* require query type data sources only (snmp_query_id > 0) */
$data_local = db_fetch_row_prepared('SELECT id, host_id, data_template_id, snmp_query_id, snmp_index FROM data_local WHERE snmp_query_id > 0 AND id = ?', array($local_data_id));
/* if this is not a data query graph, simply return */
if (!isset($data_local['host_id'])) {
return;
}
$snmp_query_graph_id = db_fetch_cell_prepared("SELECT \n\t\tdata_input_data.value FROM data_input_data \n\t\tJOIN data_input_fields ON (data_input_data.data_input_field_id = data_input_fields.id) \n\t\tJOIN data_template_data ON (data_template_data.id = data_input_data.data_template_data_id) \n\t\tWHERE data_input_fields.type_code = 'output_type' \n\t\tAND data_template_data.local_data_id = ?", array($data_local['id']));
/* no snmp query graph id found */
if ($snmp_query_graph_id == 0) {
return;
}
$suggested_values = db_fetch_assoc_prepared("SELECT \n\t\ttext, \n\t\tfield_name \n\t\tFROM snmp_query_graph_rrd_sv \n\t\tWHERE snmp_query_graph_id = ?\n\t\tAND data_template_id = ?\n\t\tAND field_name = 'name'\n\t\tORDER BY sequence", array($snmp_query_graph_id, $data_local['data_template_id']));
$suggested_values_data = array();
if (sizeof($suggested_values) > 0) {
foreach ($suggested_values as $suggested_value) {
if (!isset($suggested_values_data[$suggested_value['field_name']])) {
$subs_string = substitute_snmp_query_data($suggested_value['text'], $data_local['host_id'], $data_local['snmp_query_id'], $data_local['snmp_index'], read_config_option('max_data_query_field_length'));
/* if there are no '|query' characters, all of the substitutions were successful */
if (!substr_count($subs_string, '|query')) {
db_execute_prepared('UPDATE data_template_data SET ' . $suggested_value['field_name'] . ' = ? WHERE local_data_id = ?', array($suggested_value['text'], $local_data_id));
/* once we find a working value for that very field, stop */
$suggested_values_data[$suggested_value['field_name']] = true;
}
}
}
}
}
示例10: thold_edit
function thold_edit()
{
global $config;
if (isset_request_var('id')) {
$thold_data = db_fetch_row_prepared('SELECT *
FROM thold_data
WHERE id = ?', array(get_request_var('id')));
} elseif (isset_request_var('local_data_id') && isset_request_var('local_graph_id') && isset_request_var('host_id') && isset_request_var('data_template_id') && isset_request_var('data_template_rrd_id')) {
$thold_data['id'] = '0';
$thold_data['local_data_id'] = get_filter_request_var('local_data_id');
$thold_data['local_graph_id'] = get_filter_request_var('local_graph_id');
$thold_data['data_template_id'] = get_filter_request_var('data_template_id');
$thold_data['host_id'] = get_filter_request_var('host_id');
$thold_data['data_template_rrd_id'] = get_filter_request_var('data_template_rrd_id');
$thold_data['thold_template_id'] = get_filter_request_var('thold_template_id');
} else {
exit;
}
$desc = db_fetch_cell_prepared('SELECT name_cache
FROM data_template_data
WHERE local_data_id = ?
LIMIT 1', array($thold_data['local_data_id']));
$rrdsql = array_rekey(db_fetch_assoc_prepared("SELECT id \n\t\tFROM data_template_rrd \n\t\tWHERE local_data_id = ? ORDER BY id", array($thold_data['local_data_id'])), 'id', 'id');
$grapharr = db_fetch_assoc('SELECT DISTINCT local_graph_id
FROM graph_templates_item
WHERE task_item_id IN (' . implode(', ', $rrdsql) . ') AND graph_template_id>0');
if (empty($thold_data['local_graph_id'])) {
$thold_data['local_graph_id'] = db_fetch_cell_prepared('SELECT gl.id
FROM graph_local AS gl
INNER JOIN graph_templates_item AS gti
ON gl.id=gti.local_graph_id
INNER JOIN data_template_rrd AS dtr
ON gti.task_item_id=dtr.id
WHERE dtr.local_data_id = ?
LIMIT 1', array($thold_data['local_data_id']));
}
if (empty($thold_data['data_template_rrd_id'])) {
$thold_data['data_template_rrd_id'] = db_fetch_cell_prepared('SELECT id
FROM data_template_rrd AS dtr
WHERE local_data_id = ?
LIMIT 1', array($thold_data['local_data_id']));
}
$dt_sql = 'SELECT DISTINCT dtr.local_data_id
FROM data_template_rrd AS dtr
LEFT JOIN graph_templates_item AS gti
ON gti.task_item_id=dtr.id
LEFT JOIN graph_local AS gl
ON gl.id=gti.local_graph_id
WHERE gl.id=' . $thold_data['local_graph_id'];
$template_data_rrds = db_fetch_assoc("SELECT td.id AS thold_id, dtr.id, dtr.data_source_name, dtr.local_data_id \n\t\tFROM data_template_rrd AS dtr\n\t\tLEFT JOIN thold_data AS td\n\t\tON dtr.id=td.data_template_rrd_id\n\t\tWHERE dtr.local_data_id IN ({$dt_sql}) \n\t\tORDER BY dtr.id");
form_start('thold.php', 'thold');
html_start_box(__('Graph Data'), '100%', '', '3', 'center', '');
?>
<tr>
<td class='textArea'>
<?php
if (isset($banner)) {
echo $banner . '<br><br>';
}
?>
<?php
print __('Data Source Description:');
?>
<br><?php
echo $desc;
?>
<br><br>
<?php
print __('Associated Graph (graphs that use this RRD):');
?>
<br>
<select name='element'>
<?php
foreach ($grapharr as $g) {
$graph_desc = db_fetch_row_prepared('SELECT local_graph_id, title, title_cache
FROM graph_templates_graph
WHERE local_graph_id = ?', array($g['local_graph_id']));
echo "<option value='" . $graph_desc['local_graph_id'] . "'";
if ($graph_desc['local_graph_id'] == $thold_data['local_graph_id']) {
echo ' selected';
}
echo '>' . $graph_desc['local_graph_id'] . ' - ' . $graph_desc['title_cache'] . " </option>\n";
}
?>
</select>
<br>
<br>
</td>
<td class='textArea'>
<img id='graphimage' src='<?php
echo htmlspecialchars($config['url_path'] . 'graph_image.php?local_graph_id=' . $thold_data['local_graph_id'] . '&rra_id=0&graph_start=-32400&graph_height=140&graph_width=500');
?>
'>
</td>
</tr>
<?php
html_end_box();
$template_rrd = db_fetch_row_prepared('SELECT *
FROM data_template_rrd
WHERE id = ?', array($thold_data['data_template_rrd_id']));
//.........这里部分代码省略.........
示例11: db_fetch_cell
function db_fetch_cell($sql, $col_name = '', $log = TRUE, $db_conn = FALSE)
{
return db_fetch_cell_prepared($sql, array(), $col_name, $log, $db_conn);
}
示例12: form_actions
function form_actions()
{
global $config, $mactrack_view_macs_actions;
/* ================= input validation ================= */
get_filter_request_var('drp_action');
/* ==================================================== */
/* if we are to save this form, instead of display it */
if (isset_request_var('selected_items')) {
$selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items'));
if ($selected_items != false) {
if (get_request_var('drp_action') == '1') {
/* Authorize */
if (sizeof($selected_items)) {
foreach ($selected_items as $mac) {
$mac = sanitize_search_string($mac);
api_mactrack_authorize_mac_addresses($mac);
}
}
} elseif (get_request_var('drp_action') == '2') {
/* Revoke */
$errors = '';
if (sizeof($selected_items)) {
foreach ($selected_items as $mac) {
$mac = sanitize_search_string($mac);
$mac_found = db_fetch_cell_prepared('SELECT mac_address FROM mac_track_macauth WHERE mac_address = ?', array($mac));
if ($mac_found) {
api_mactrack_revoke_mac_addresses($mac);
} else {
$errors .= ', ' . $mac;
}
}
}
if ($errors) {
$_SESSION['sess_messages'] = __('The following MAC Addresses Could not be revoked because they are members of Group Authorizations %s', $errors);
}
}
}
header('Location: mactrack_view_macs.php');
exit;
}
/* setup some variables */
$mac_address_list = '';
$delim = read_config_option('mt_mac_delim');
/* loop through each of the device types selected on the previous page and get more info about them */
while (list($var, $val) = each($_POST)) {
if (substr($var, 0, 4) == 'chk_') {
$matches = substr($var, 4);
/* clean up the mac_address */
if (isset($matches)) {
$matches = sanitize_search_string($matches);
$parts = explode('-', $matches);
$mac = str_replace('_', $delim, $parts[0]);
}
if (!isset($mac_address_array[$mac])) {
$mac_address_list .= '<li>' . $mac . '</li>';
$mac_address_array[$mac] = $mac;
}
}
}
top_header();
html_start_box($mactrack_view_macs_actions[get_request_var('drp_action')], '60%', '', '3', 'center', '');
form_start('mmactrack_view_macs.php');
if (get_request_var('drp_action') == '1') {
/* Authorize Macs */
print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Are you sure you want to Authorize the following MAC Addresses?') . "</p>\n\t\t\t\t\t<p>{$mac_address_list}</p>\n\t\t\t\t</td>\n\t\t\t</tr>";
} elseif (get_request_var('drp_action') == '2') {
/* Revoke Macs */
print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Are you sure you want to Revoke the following MAC Addresses?') . "</p>\n\t\t\t\t\t<p>{$mac_address_list}</p>\n\t\t\t\t</td>\n\t\t\t</tr>";
}
if (!isset($mac_address_array)) {
print "<tr><td class='even'><span class='textError'>" . __('You must select at least one MAC Address.') . "</span></td></tr>\n";
$save_html = '';
} else {
if (!mactrack_check_user_realm(2122)) {
print "<tr><td clsas='even'><span class='textError'>" . __('You are not permitted to change Mac Authorizations.') . "</span></td></tr>\n";
$save_html = '';
} else {
$save_html = "<input type='submit' name='save' value='" . __('Yes') . "'>";
}
}
print "<tr>\n\t\t<td colspan='2' class='saveRow'>\n\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t<input type='hidden' name='selected_items' value='" . (isset($mac_address_array) ? serialize($mac_address_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>" . (strlen($save_html) ? "\n\t\t\t<input type='submit' name='cancel' value='" . __('No') . "'>\n\t\t\t{$save_html}" : "<input type='submit' name='cancel' value='" . __('Return') . "'>") . "\n\t\t</td>\n\t</tr>";
html_end_box();
bottom_footer();
}
示例13: mactrack_device_remove
function mactrack_device_remove()
{
global $config;
/* ================= input validation ================= */
get_filter_request_var('device_id');
get_filter_request_var('type_id');
/* ==================================================== */
if (read_config_option('remove_verification') == 'on' && !isset_request_var('confirm')) {
top_header();
form_confirm(__('Are You Sure?'), __('Are you sure you want to delete the host %s', db_fetch_cell_prepared('SELECT device_name FROM host WHERE id = ?', array(get_request_var('device_id')))), 'mactrack_devices.php', 'mactrack_devices.php?action=remove&id=' . get_request_var('device_id'));
bottom_footer();
exit;
}
if (read_config_option('remove_verification') == '' || isset_request_var('confirm')) {
api_mactrack_device_remove(get_request_var('device_id'));
}
}
示例14: mactrack_get_vendor_name
function mactrack_get_vendor_name($mac)
{
$vendor_mac = substr($mac, 0, 8);
$vendor_name = db_fetch_cell_prepared('SELECT vendor_name FROM mac_track_oui_database WHERE vendor_mac = ?', array($vendor_mac));
if (strlen($vendor_name)) {
return $vendor_name;
} else {
return __('Unknown');
}
}
示例15: html_host_filter
function html_host_filter($host_id)
{
$theme = read_config_option('selected_theme');
if ($theme == 'classic') {
?>
<td width='50'>
Device
</td>
<td width='1'>
<select id='host_id' name='host_id' onChange='applyFilter()'>
<option value='-1'<?php
if (get_request_var_request('host_id') == '-1') {
?>
selected<?php
}
?>
>Any</option>
<option value='0'<?php
if (get_request_var_request('host_id') == '0') {
?>
selected<?php
}
?>
>None</option>
<?php
$hosts = db_fetch_assoc("SELECT id, CONCAT_WS('',description,' (',hostname,')') AS name FROM host ORDER BY description, hostname");
if (sizeof($hosts) > 0) {
foreach ($hosts as $host) {
print "<option value='" . $host['id'] . "'";
if (get_request_var_request('host_id') == $host['id']) {
print ' selected';
}
print '>' . title_trim(htmlspecialchars($host['name']), 40) . "</option>\n";
}
}
?>
</select>
</td>
<?php
} else {
if ($host_id > 0) {
$hostname = db_fetch_cell_prepared("SELECT description FROM host WHERE id = ?", array($host_id));
} elseif ($host_id == 0) {
$hostname = 'None';
} else {
$hostname = 'Any';
}
?>
<td width='50'>
Device
</td>
<td width='1'>
<span id='host_wrapper' style='width:200px;' class='ui-selectmenu-button ui-widget ui-state-default ui-corner-all'>
<span id='host_click' class='ui-icon ui-icon-triangle-1-s'></span>
<input size='28' id='host' value='<?php
print $hostname;
?>
'>
</span>
<input type='hidden' id='host_id' name='host_id' value='<?php
print $host_id;
?>
'>
</td>
<?php
}
}