本文整理汇总了PHP中db_fetch_row_prepared函数的典型用法代码示例。如果您正苦于以下问题:PHP db_fetch_row_prepared函数的具体用法?PHP db_fetch_row_prepared怎么用?PHP db_fetch_row_prepared使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_fetch_row_prepared函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collect_pppoe_users_api
function collect_pppoe_users_api(&$host)
{
$rows = array();
$api = new RouterosAPI();
$api->debug = false;
$rekey_array = array('host_id', 'name', 'index', 'userType', 'serverID', 'domain', 'bytesIn', 'bytesOut', 'packetsIn', 'packetsOut', 'curBytesIn', 'curBytesOut', 'curPacketsIn', 'curPacketsOut', 'prevBytesIn', 'prevBytesOut', 'prevPacketsIn', 'prevPacketsOut', 'present', 'last_seen');
// Put the queues into an array
$users = array_rekey(db_fetch_assoc_prepared("SELECT \n\t\thost_id, '0' AS `index`, '1' AS userType, '0' AS serverID, SUBSTRING(name, 7) AS name, '' AS domain,\n\t\tBytesIn AS bytesIn, BytesOut AS bytesOut, PacketsIn as packetsIn, PacketsOut AS packetsOut,\n\t\tcurBytesIn, curBytesOut, curPacketsIn, curPacketsOut, \n\t\tprevBytesIn, prevBytesOut, prevPacketsIn, prevPacketsOut, present, last_seen\n\t\tFROM plugin_mikrotik_queues \n\t\tWHERE host_id = ? \n\t\tAND name LIKE 'PPPOE-%'", array($host['id'])), 'name', $rekey_array);
$creds = db_fetch_row_prepared('SELECT * FROM plugin_mikrotik_credentials WHERE host_id = ?', array($host['id']));
$start = microtime(true);
if (sizeof($creds)) {
if ($api->connect($host['hostname'], $creds['user'], $creds['password'])) {
$api->write('/ppp/active/getall');
$read = $api->read(false);
$array = $api->parseResponse($read);
$end = microtime(true);
$sql = array();
cacti_log('MIKROTIK RouterOS API STATS: API Returned ' . sizeof($array) . ' PPPoe Users in ' . round($end - $start, 2) . ' seconds.', false, 'SYSTEM');
if (sizeof($array)) {
foreach ($array as $row) {
if (!isset($row['name'])) {
continue;
}
$name = strtoupper($row['name']);
if (isset($users[$name])) {
$user = $users[$name];
$user['mac'] = $row['caller-id'];
$user['ip'] = $row['address'];
$user['connectTime'] = uptimeToSeconds($row['uptime']);
$user['host_id'] = $host['id'];
$user['radius'] = $row['radius'] == 'true' ? 1 : 0;
$user['limitBytesIn'] = $row['limit-bytes-in'];
$user['limitBytesOut'] = $row['limit-bytes-out'];
$user['userType'] = 1;
$sql[] = '(' . $user['host_id'] . ',' . $user['index'] . ',' . $user['userType'] . ',' . $user['serverID'] . ',' . db_qstr($user['name']) . ',' . db_qstr($user['domain']) . ',' . db_qstr($user['mac']) . ',' . db_qstr($user['ip']) . ',' . $user['connectTime'] . ',' . $user['bytesIn'] . ',' . $user['bytesOut'] . ',' . $user['packetsIn'] . ',' . $user['packetsOut'] . ',' . $user['curBytesIn'] . ',' . $user['curBytesOut'] . ',' . $user['curPacketsIn'] . ',' . $user['curPacketsOut'] . ',' . $user['prevBytesIn'] . ',' . $user['prevBytesOut'] . ',' . $user['prevPacketsIn'] . ',' . $user['prevPacketsOut'] . ',' . $user['limitBytesIn'] . ',' . $user['limitBytesOut'] . ',' . $user['radius'] . ',' . $user['present'] . ',' . db_qstr($user['last_seen']) . ')';
}
}
if (sizeof($sql)) {
db_execute('INSERT INTO plugin_mikrotik_users
(host_id, `index`, userType, serverID, name, domain, mac, ip, connectTime,
bytesIn, bytesOut, packetsIn, packetsOut,
curBytesIn, curBytesOut, curPacketsIn, curPacketsOut,
prevBytesIn, prevBytesOut, prevPacketsIn, prevPacketsOut,
limitBytesIn, limitBytesOut, radius, present, last_seen)
VALUES ' . implode(', ', $sql) . '
ON DUPLICATE KEY UPDATE connectTime=VALUES(connectTime),
bytesIn=VALUES(bytesIn), bytesOut=VALUES(bytesOut),
packetsIn=VALUES(packetsIn), packetsOut=VALUES(packetsOut),
curBytesIn=VALUES(curBytesIn), curBytesOut=VALUES(curBytesOut),
curPacketsIn=VALUES(curPacketsIn), curPacketsOut=VALUES(curPacketsOut),
prevBytesIn=VALUES(prevBytesIn), prevBytesOut=VALUES(prevBytesOut),
prevPacketsIn=VALUES(prevPacketsIn), prevPacketsOut=VALUES(prevPacketsOut),
limitBytesIn=VALUES(limitBytesIn), limitBytesOut=VALUES(limitBytesOut),
radius=VALUES(radius), present=VALUES(present), last_seen=VALUES(last_seen)');
}
}
$idle_users = db_fetch_assoc_prepared('SELECT name
FROM plugin_mikrotik_users
WHERE last_seen < FROM_UNIXTIME(UNIX_TIMESTAMP() - ?)
AND present=1
AND host_id = ?', array(read_config_option('mikrotik_queues_freq'), $host['id']));
db_execute_prepared('UPDATE IGNORE plugin_mikrotik_users SET
bytesIn=0, bytesOut=0, packetsIn=0, packetsOut=0, connectTime=0,
curBytesIn=0, curBytesOut=0, curPacketsIn=0, curPacketsOut=0,
prevBytesIn=0, prevBytesOut=0, prevPacketsIn=0, prevPacketsOut=0, present=0
WHERE host_id = ?
AND userType = 1
AND last_seen < FROM_UNIXTIME(UNIX_TIMESTAMP() - ?)', array($host['id'], read_config_option('mikrotik_queues_freq')));
$api->disconnect();
} else {
cacti_log('ERROR:RouterOS @ ' . $host['description'] . ' Timed Out');
}
}
}
示例2: mactrack_view_get_site_records
function mactrack_view_get_site_records(&$sql_where, $row_limit, $apply_limits = TRUE)
{
/* create SQL where clause */
$device_type_info = db_fetch_row_prepared('SELECT * FROM mac_track_device_types WHERE device_type_id = ?', array(get_request_var('device_type_id')));
$sql_where = '';
/* form the 'where' clause for our main sql query */
if (get_request_var('filter') != '') {
if (get_request_var('detail') == 'false') {
$sql_where = "WHERE (mac_track_sites.site_name LIKE '%" . get_request_var('filter') . "%')";
} else {
$sql_where = "WHERE (mac_track_device_types.vendor LIKE '%" . get_request_var('filter') . "%' OR " . "mac_track_device_types.description LIKE '%" . get_request_var('filter') . "%' OR " . "mac_track_sites.site_name LIKE '%" . get_request_var('filter') . "%')";
}
}
if (sizeof($device_type_info)) {
$sql_where = ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.device_type_id=' . $device_type_info['device_type_id'] . ')';
}
if (get_request_var('site_id') != '-1' && get_request_var('detail')) {
$sql_where = ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.site_id=' . get_request_var('site_id') . ')';
}
if (get_request_var('detail') == 'false') {
$query_string = "SELECT *\n\t\t\tFROM mac_track_sites\n\t\t\t{$sql_where}\n\t\t\tORDER BY " . get_request_var('sort_column') . ' ' . get_request_var('sort_direction');
if ($apply_limits) {
$query_string .= ' LIMIT ' . $row_limit * (get_request_var('page') - 1) . ',' . $row_limit;
}
} else {
$query_string = "SELECT mac_track_sites.site_name, mac_track_sites.site_id,\n\t\t\tCount(mac_track_device_types.device_type_id) AS total_devices,\n\t\t\tmac_track_device_types.device_type_id,\n\t\t\tmac_track_device_types.device_type,\n\t\t\tmac_track_device_types.vendor,\n\t\t\tmac_track_device_types.description,\n\t\t\tSum(mac_track_devices.ips_total) AS sum_ips_total,\n\t\t\tSum(mac_track_devices.ports_total) AS sum_ports_total,\n\t\t\tSum(mac_track_devices.ports_active) AS sum_ports_active,\n\t\t\tSum(mac_track_devices.ports_trunk) AS sum_ports_trunk,\n\t\t\tSum(mac_track_devices.macs_active) AS sum_macs_active\n\t\t\tFROM (mac_track_device_types\n\t\t\tRIGHT JOIN mac_track_devices ON (mac_track_device_types.device_type_id = mac_track_devices.device_type_id))\n\t\t\tRIGHT JOIN mac_track_sites ON (mac_track_devices.site_id = mac_track_sites.site_id)\n\t\t\t{$sql_where}\n\t\t\tGROUP BY mac_track_sites.site_name, mac_track_device_types.vendor, mac_track_device_types.description\n\t\t\tHAVING (((Count(mac_track_device_types.device_type_id))>0))\n\t\t\tORDER BY " . get_request_var('sort_column') . ' ' . get_request_var('sort_direction');
if ($apply_limits) {
$query_string .= ' LIMIT ' . $row_limit * (get_request_var('page') - 1) . ',' . $row_limit;
}
}
return db_fetch_assoc($query_string);
}
示例3: api_poller_cache_item_add
function api_poller_cache_item_add($host_id, $host_field_override, $local_data_id, $rrd_step, $poller_action_id, $data_source_item_name, $num_rrd_items, $arg1 = '', $arg2 = '', $arg3 = '')
{
static $hosts = array();
if (!isset($hosts[$host_id])) {
$host = db_fetch_row_prepared('SELECT
host.id,
host.hostname,
host.snmp_community,
host.snmp_version,
host.snmp_username,
host.snmp_password,
host.snmp_auth_protocol,
host.snmp_priv_passphrase,
host.snmp_priv_protocol,
host.snmp_context,
host.snmp_port,
host.snmp_timeout,
host.disabled
FROM host
WHERE host.id = ?', array($host_id));
$hosts[$host_id] = $host;
} else {
$host = $hosts[$host_id];
}
/* the $host_field_override array can be used to override certain host fields in the poller cache */
if (isset($host)) {
$host = array_merge($host, $host_field_override);
}
if (isset($host['id']) || isset($host_id)) {
if (isset($host)) {
if ($host['disabled'] == 'on') {
return;
}
} else {
if ($poller_action_id == 0) {
return;
}
$host['id'] = 0;
$host['snmp_community'] = '';
$host['snmp_timeout'] = '';
$host['snmp_username'] = '';
$host['snmp_password'] = '';
$host['snmp_auth_protocol'] = '';
$host['snmp_priv_passphrase'] = '';
$host['snmp_priv_protocol'] = '';
$host['snmp_context'] = '';
$host['snmp_version'] = '';
$host['snmp_port'] = '';
$host['hostname'] = 'None';
}
if ($poller_action_id == 0) {
if ($host['snmp_version'] < 1 || $host['snmp_version'] > 3 || $host['snmp_community'] == '' && $host['snmp_version'] != 3) {
return;
}
}
$rrd_next_step = api_poller_get_rrd_next_step($rrd_step, $num_rrd_items);
return "({$local_data_id}, " . '0, ' . $host['id'] . ", {$poller_action_id}," . db_qstr($host['hostname']) . ",\n\t\t\t" . db_qstr($host['snmp_community']) . ', ' . db_qstr($host['snmp_version']) . ', ' . db_qstr($host['snmp_timeout']) . ",\n\t\t\t" . db_qstr($host['snmp_username']) . ', ' . db_qstr($host['snmp_password']) . ', ' . db_qstr($host['snmp_auth_protocol']) . ",\n\t\t\t" . db_qstr($host['snmp_priv_passphrase']) . ', ' . db_qstr($host['snmp_priv_protocol']) . ', ' . db_qstr($host['snmp_context']) . ",\n\t\t\t" . db_qstr($host['snmp_port']) . ', ' . db_qstr($data_source_item_name) . ', ' . db_qstr(clean_up_path(get_data_source_path($local_data_id, true))) . ",\n\t\t\t" . db_qstr($num_rrd_items) . ', ' . db_qstr($rrd_step) . ', ' . db_qstr($rrd_next_step) . ', ' . db_qstr($arg1) . ', ' . db_qstr($arg2) . ', ' . db_qstr($arg3) . ", '1')";
}
}
示例4: mactrack_view_get_device_records
function mactrack_view_get_device_records(&$sql_where, $row_limit, $apply_limits = TRUE)
{
$device_type_info = db_fetch_row_prepared('SELECT * FROM mac_track_device_types WHERE device_type_id = ?', array(get_request_var('device_type_id')));
/* if the device type is not the same as the type_id, then reset it */
if (sizeof($device_type_info) && get_request_var('type_id') != -1) {
if ($device_type_info['device_type'] != get_request_var('type_id')) {
$device_type_info = array();
}
} else {
if (get_request_var('device_type_id') == 0) {
$device_type_info = array('device_type_id' => 0, 'description' => __('Unknown Device Type'));
}
}
/* form the 'where' clause for our main sql query */
if (get_request_var('filter') != '') {
$sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . "(mac_track_devices.hostname LIKE '%" . get_request_var('filter') . "%' OR " . "mac_track_devices.notes LIKE '%" . get_request_var('filter') . "%' OR " . "mac_track_devices.device_name LIKE '%" . get_request_var('filter') . "%' OR " . "mac_track_sites.site_name LIKE '%" . get_request_var('filter') . "%')";
}
if (sizeof($device_type_info)) {
$sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.device_type_id=' . $device_type_info['device_type_id'] . ')';
}
if (get_request_var('status') == '-1') {
/* Show all items */
} elseif (get_request_var('status') == '-2') {
$sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.disabled="on")';
} elseif (get_request_var('status') == '5') {
$sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.host_id=0)';
} else {
$sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.snmp_status=' . get_request_var('status') . ') AND (mac_track_devices.disabled = "")';
}
/* scan types matching */
if (get_request_var('type_id') == '-1') {
/* Show all items */
} else {
$sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.scan_type=' . get_request_var('type_id') . ')';
}
/* device types matching */
if (get_request_var('device_type_id') == '-1') {
/* Show all items */
} elseif (get_request_var('device_type_id') == '-2') {
$sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_device_types.description="")';
} else {
$sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.device_type_id=' . get_request_var('device_type_id') . ')';
}
if (get_request_var('site_id') == '-1') {
/* Show all items */
} elseif (get_request_var('site_id') == '-2') {
$sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_sites.site_id IS NULL)';
} elseif (!isempty_request_var('site_id')) {
$sql_where .= ($sql_where != '' ? ' AND ' : 'WHERE ') . '(mac_track_devices.site_id=' . get_request_var('site_id') . ')';
}
$sql_query = "SELECT\n\t\tmac_track_devices.*,\n\t\tmac_track_device_types.description AS device_type,\n\t\tmac_track_sites.site_name\n\t\tFROM mac_track_sites\n\t\tRIGHT JOIN mac_track_devices ON (mac_track_devices.site_id=mac_track_sites.site_id)\n\t\tLEFT JOIN mac_track_device_types ON (mac_track_device_types.device_type_id=mac_track_devices.device_type_id)\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var('sort_column') . ' ' . get_request_var('sort_direction');
if ($apply_limits) {
$sql_query .= ' LIMIT ' . $row_limit * (get_request_var('page') - 1) . ',' . $row_limit;
}
return db_fetch_assoc($sql_query);
}
示例5: 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;
}
}
示例6: 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();
//.........这里部分代码省略.........
示例7: 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
//.........这里部分代码省略.........
示例8: mactrack_snmp_edit
function mactrack_snmp_edit()
{
global $config, $fields_mactrack_snmp_edit;
include_once $config['base_path'] . '/plugins/mactrack/lib/mactrack_functions.php';
/* ================= input validation ================= */
get_filter_request_var('id');
get_filter_request_var('page');
/* ==================================================== */
/* clean up rule name */
if (isset_request_var('name')) {
set_request_var('name', sanitize_search_string(get_request_var('name')));
}
/* remember these search fields in session vars so we don't have to keep passing them around */
load_current_session_value('page', 'sess_mactrack_edit_current_page', '1');
load_current_session_value('rows', 'sess_default_rows', read_config_option('num_rows_table'));
/* display the mactrack snmp option set */
$snmp_group = array();
if (!isempty_request_var('id')) {
$snmp_group = db_fetch_row_prepared('SELECT * FROM mac_track_snmp where id = ?', array(get_request_var('id')));
$header_label = __('SNMP Option Set [edit: %s]', $snmp_group['name']);
} else {
$header_label = __('SNMP Option Set [new]');
}
form_start('mactrack_snmp.php', 'mactrack_snmp_group');
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_edit, $snmp_group)));
html_end_box();
form_hidden_box('id', isset_request_var('id') ? get_request_var('id') : '0', '');
form_hidden_box('save_component_mactrack_snmp', '1', '');
if (!isempty_request_var('id')) {
$items = db_fetch_assoc_prepared('SELECT * FROM mac_track_snmp_items WHERE snmp_id= ? ORDER BY sequence', array(get_request_var('id')));
html_start_box(__('Mactrack SNMP Options'), '100%', '', '3', 'center', 'mactrack_snmp.php?action=item_edit&id=' . get_request_var('id'));
print "<tr class='tableHeader'>";
DrawMatrixHeaderItem(__('Item'), '', 1);
DrawMatrixHeaderItem(__('Version'), '', 1);
DrawMatrixHeaderItem(__('Community'), '', 1);
DrawMatrixHeaderItem(__('Port'), '', 1);
DrawMatrixHeaderItem(__('Timeout'), '', 1);
DrawMatrixHeaderItem(__('Retries'), '', 1);
DrawMatrixHeaderItem(__('Max OIDs'), '', 1);
DrawMatrixHeaderItem(__('Username'), '', 1);
DrawMatrixHeaderItem(__('Auth Proto'), '', 1);
DrawMatrixHeaderItem(__('Priv Proto'), '', 1);
DrawMatrixHeaderItem(__('Actions'), '', 1);
print '</tr>';
$i = 1;
if (sizeof($items)) {
foreach ($items as $item) {
form_alternate_row();
$form_data = '<td><a class="linkEditMain" href="' . htmlspecialchars('mactrack_snmp.php?action=item_edit&item_id=' . $item['id'] . '&id=' . $item['snmp_id']) . '">Item#' . $i . '</a></td>';
$form_data .= '<td>' . $item['snmp_version'] . '</td>';
$form_data .= '<td>' . ($item['snmp_version'] == 3 ? __('N/A') : $item['snmp_readstring']) . '</td>';
$form_data .= '<td>' . $item['snmp_port'] . '</td>';
$form_data .= '<td>' . $item['snmp_timeout'] . '</td>';
$form_data .= '<td>' . $item['snmp_retries'] . '</td>';
$form_data .= '<td>' . $item['max_oids'] . '</td>';
$form_data .= '<td>' . ($item['snmp_version'] == 3 ? $item['snmp_username'] : __('N/A')) . '</td>';
$form_data .= '<td>' . ($item['snmp_version'] == 3 ? $item['snmp_auth_protocol'] : __('N/A')) . '</td>';
$form_data .= '<td>' . ($item['snmp_version'] == 3 ? $item['snmp_priv_protocol'] : __('N/A')) . '</td>';
$form_data .= '<td class="right">' . ($i < sizeof($items) ? '<a class="remover fa fa-caret-down moveArrow" href="' . htmlspecialchars($config['url_path'] . 'plugins/mactrack/mactrack_snmp.php?action=item_movedown&item_id=' . $item["id"] . '&id=' . $item["snmp_id"]) . '"></a>' : '<span class="moveArrowNone"></span>') . ($i > 1 ? '<a class="remover fa fa-caret-up moveArrow" href="' . htmlspecialchars($config['url_path'] . 'plugins/mactrack/mactrack_snmp.php?action=item_moveup&item_id=' . $item["id"] . '&id=' . $item["snmp_id"]) . '"></a>' : '<span class="moveArrowNone"></span>');
$form_data .= '<a class="delete deleteMarker fa fa-remove" href="' . htmlspecialchars($config['url_path'] . 'plugins/mactrack/mactrack_snmp.php?action=item_remove&item_id=' . $item["id"] . '&id=' . $item["snmp_id"]) . '"></a>' . '</td></tr>';
print $form_data;
$i++;
}
} else {
print '<tr><td colspan="5"><em>' . __('No SNMP Items') . '</em></td></tr>';
}
html_end_box();
}
form_save_button('mactrack_snmp.php');
}
示例9: item_edit
function item_edit()
{
global $struct_graph_item, $graph_item_types, $consolidation_functions;
/* ================= input validation ================= */
input_validate_input_number(get_request_var_request('id'));
input_validate_input_number(get_request_var_request('host_id'));
input_validate_input_number(get_request_var_request('graph_template_id'));
input_validate_input_number(get_request_var_request('local_graph_id'));
input_validate_input_number(get_request_var_request('host_id'));
input_validate_input_number(get_request_var_request('data_template_id'));
/* ==================================================== */
/* remember these search fields in session vars so we don't have to keep passing them around */
load_current_session_value('local_graph_id', 'sess_local_graph_id', '');
load_current_session_value('host_id', 'sess_ds_host_id', '-1');
load_current_session_value('data_template_id', 'sess_data_template_id', '-1');
$id = !empty($_REQUEST['id']) ? '&id=' . $_REQUEST['id'] : '';
$host = db_fetch_row_prepared('SELECT hostname FROM host WHERE id = ?', array(get_request_var_request('host_id')));
html_start_box('<strong>Data Sources</strong> [host: ' . (empty($host['hostname']) ? 'No Device' : $host['hostname']) . ']', '100%', '', '3', 'center', '');
?>
<tr class='even noprint'>
<form name="form_graph_items" action="graphs_items.php">
<td>
<table cellpadding="2" cellspacing="0">
<tr>
<td width="50">
Device
</td>
<td>
<select name="cbo_host_id" onChange="window.location=document.form_graph_items.cbo_host_id.options[document.form_graph_items.cbo_host_id.selectedIndex].value">
<option value="graphs_items.php?action=item_edit<?php
print $id;
?>
&local_graph_id=<?php
print get_request_var_request('local_graph_id');
?>
&host_id=-1&data_template_id=<?php
print get_request_var_request('data_template_id');
?>
"<?php
if (get_request_var_request('host_id') == '-1') {
?>
selected<?php
}
?>
>Any</option>
<option value="graphs_items.php?action=item_edit<?php
print $id;
?>
&local_graph_id=<?php
print get_request_var_request('local_graph_id');
?>
&host_id=0&data_template_id=<?php
print get_request_var_request('data_template_id');
?>
"<?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='graphs_items.php?action=item_edit" . $id . '&local_graph_id=' . get_request_var_request('local_graph_id') . '&host_id=' . $host['id'] . '&data_template_id=' . get_request_var_request('data_template_id') . "'";
if (get_request_var_request('host_id') == $host['id']) {
print ' selected';
}
print '>' . $host['name'] . "</option>\n";
}
}
?>
</select>
</td>
</tr>
<tr>
<td style='white-space: nowrap;'>
Data Template
</td>
<td>
<select name="cbo_data_template_id" onChange="window.location=document.form_graph_items.cbo_data_template_id.options[document.form_graph_items.cbo_data_template_id.selectedIndex].value">
<option value="graphs_items.php?action=item_edit<?php
print $id;
?>
&local_graph_id=<?php
print get_request_var_request('local_graph_id');
?>
&data_template_id=-1&host_id=<?php
print get_request_var_request('host_id');
?>
"<?php
if (get_request_var_request('data_template_id') == '-1') {
?>
selected<?php
}
?>
>Any</option>
<option value="graphs_items.php?action=item_edit<?php
//.........这里部分代码省略.........
示例10: mactrack_log_action
function mactrack_log_action($message)
{
$user = db_fetch_row_prepared('SELECT username, full_name FROM user_auth WHERE id = ?', array($_SESSION['sess_user_id']));
cacti_log('MACTRACK: ' . $message . ", by '" . $user['full_name'] . '(' . $user['username'] . ")'", false, 'SYSTEM');
}
示例11: 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');
}
}
示例12: substitute_host_data
function substitute_host_data($string, $l_escape_string, $r_escape_string, $host_id)
{
if (!empty($host_id)) {
if (!isset($_SESSION['sess_host_cache_array'][$host_id])) {
$host = db_fetch_row_prepared('SELECT * FROM host WHERE id = ?', array($host_id));
$_SESSION['sess_host_cache_array'][$host_id] = $host;
}
$string = str_replace($l_escape_string . 'host_management_ip' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['hostname'], $string);
/* for compatability */
$string = str_replace($l_escape_string . 'host_hostname' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['hostname'], $string);
$string = str_replace($l_escape_string . 'host_description' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['description'], $string);
$string = str_replace($l_escape_string . 'host_notes' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['notes'], $string);
$string = str_replace($l_escape_string . 'host_polling_time' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['polling_time'], $string);
$string = str_replace($l_escape_string . 'host_avg_time' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['avg_time'], $string);
$string = str_replace($l_escape_string . 'host_cur_time' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['cur_time'], $string);
$string = str_replace($l_escape_string . 'host_availability' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['availability'], $string);
/* snmp connectivity information */
$string = str_replace($l_escape_string . 'host_snmp_community' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['snmp_community'], $string);
$string = str_replace($l_escape_string . 'host_snmp_version' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['snmp_version'], $string);
$string = str_replace($l_escape_string . 'host_snmp_username' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['snmp_username'], $string);
$string = str_replace($l_escape_string . 'host_snmp_password' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['snmp_password'], $string);
$string = str_replace($l_escape_string . 'host_snmp_auth_protocol' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['snmp_auth_protocol'], $string);
$string = str_replace($l_escape_string . 'host_snmp_priv_passphrase' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['snmp_priv_passphrase'], $string);
$string = str_replace($l_escape_string . 'host_snmp_priv_protocol' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['snmp_priv_protocol'], $string);
$string = str_replace($l_escape_string . 'host_snmp_context' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['snmp_context'], $string);
$string = str_replace($l_escape_string . 'host_snmp_port' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['snmp_port'], $string);
$string = str_replace($l_escape_string . 'host_snmp_timeout' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['snmp_timeout'], $string);
/* snmp system information */
$string = str_replace($l_escape_string . 'host_snmp_sysDescr' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['snmp_sysDescr'], $string);
$string = str_replace($l_escape_string . 'host_snmp_sysObjectID' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['snmp_sysObjectID'], $string);
$string = str_replace($l_escape_string . 'host_snmp_sysContact' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['snmp_sysContact'], $string);
$string = str_replace($l_escape_string . 'host_snmp_sysLocation' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['snmp_sysLocation'], $string);
$string = str_replace($l_escape_string . 'host_snmp_sysName' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['snmp_sysName'], $string);
$string = str_replace($l_escape_string . 'host_snmp_sysUpTimeInstance' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['snmp_sysUpTimeInstance'], $string);
$string = str_replace($l_escape_string . 'host_ping_retries' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['ping_retries'], $string);
$string = str_replace($l_escape_string . 'host_max_oids' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['max_oids'], $string);
$string = str_replace($l_escape_string . 'host_id' . $r_escape_string, $_SESSION['sess_host_cache_array'][$host_id]['id'], $string);
$temp = api_plugin_hook_function('substitute_host_data', array('string' => $string, 'l_escape_string' => $l_escape_string, 'r_escape_string' => $r_escape_string, 'host_id' => $host_id));
$string = $temp['string'];
}
return $string;
}
示例13: data_query_edit
function data_query_edit()
{
global $fields_data_query_edit, $config;
/* ================= input validation ================= */
input_validate_input_number(get_request_var_request('id'));
/* ==================================================== */
if (!empty($_REQUEST['id'])) {
$snmp_query = db_fetch_row_prepared('SELECT * FROM snmp_query WHERE id = ?', array($_REQUEST['id']));
$header_label = '[edit: ' . htmlspecialchars($snmp_query['name']) . ']';
} else {
$header_label = '[new]';
}
html_start_box("<strong>Data Queries</strong> {$header_label}", '100%', '', '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 class='txtErrorText'><strong>Could not locate XML file.</strong></font>";
$xml_file_exists = false;
}
html_start_box('', '100%', '', '3', 'center', '');
print "<tr class='tableRow'><td>{$text}</td></tr>";
html_end_box();
if ($xml_file_exists == true) {
html_start_box('<strong>Associated Graph Templates</strong>', '100%', '', '3', 'center', 'data_queries.php?action=item_edit&snmp_query_id=' . $snmp_query['id']);
print "<tr class='tableHeader'>\n\t\t\t\t\t<th class='textSubHeaderDark'>Name</th>\n\t\t\t\t\t<th class='textSubHeaderDark'>Graph Template Name</th>\n\t\t\t\t\t<th class='textSubHeaderDark' style='text-align:right;'>Mapping ID</th>\n\t\t\t\t\t<th width='40' style='text-align:right;'>Action</td>\n\t\t\t\t</tr>";
$snmp_query_graphs = db_fetch_assoc_prepared('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 = ?
ORDER BY snmp_query_graph.name', array($snmp_query['id']));
$i = 0;
if (sizeof($snmp_query_graphs) > 0) {
foreach ($snmp_query_graphs as $snmp_query_graph) {
form_alternate_row();
?>
<td>
<strong><a href="<?php
print htmlspecialchars('data_queries.php?action=item_edit&id=' . $snmp_query_graph['id'] . '&snmp_query_id=' . $snmp_query['id']);
?>
"><?php
print htmlspecialchars($snmp_query_graph['name']);
?>
</a></strong>
</td>
<td>
<?php
print htmlspecialchars($snmp_query_graph['graph_template_name']);
?>
</td>
<td style='text-align:right;'>
<?php
print $snmp_query_graph['id'];
?>
</td>
<td align="right">
<a href="<?php
print htmlspecialchars('data_queries.php?action=item_remove&id=' . $snmp_query_graph['id'] . '&snmp_query_id=' . $snmp_query['id']);
?>
"><img src="images/delete_icon.gif" style="height:10px;width:10px;" border="0" alt="Delete"></a>
</td>
</tr>
<?php
}
} else {
print "<tr class='tableRow'><td><em>No Graph Templates Defined.</em></td></tr>";
}
html_end_box();
}
}
form_save_button('data_queries.php', 'return');
}
示例14: color_edit
function color_edit()
{
global $fields_color_edit;
/* ================= input validation ================= */
input_validate_input_number(get_request_var_request('id'));
/* ==================================================== */
if (!empty($_REQUEST['id'])) {
$color = db_fetch_row_prepared('SELECT * FROM colors WHERE id = ?', array(get_request_var_request('id')));
$header_label = '[edit: ' . $color['hex'] . ']';
} else {
$header_label = '[new]';
}
html_start_box("<strong>Colors</strong> {$header_label}", '100%', '', '3', 'center', '');
draw_edit_form(array('config' => array(), 'fields' => inject_form_variables($fields_color_edit, isset($color) ? $color : array())));
html_end_box();
form_save_button('color.php');
}
示例15: update_system_mibs
function update_system_mibs($host_id)
{
$system_mibs = array('snmp_sysDescr' => '.1.3.6.1.2.1.1.1.0', 'snmp_sysObjectID' => '.1.3.6.1.2.1.1.2.0', 'snmp_sysUpTimeInstance' => '.1.3.6.1.2.1.1.3.0', 'snmp_sysContact' => '.1.3.6.1.2.1.1.4.0', 'snmp_sysName' => '.1.3.6.1.2.1.1.5.0', 'snmp_sysLocation' => '.1.3.6.1.2.1.1.6.0');
$h = db_fetch_row_prepared('SELECT * FROM host WHERE id = ?', array($host_id));
if (sizeof($h)) {
foreach ($system_mibs as $name => $oid) {
$value = cacti_snmp_get($h['hostname'], $h['snmp_community'], $oid, $h['snmp_version'], $h['snmp_username'], $h['snmp_password'], $h['snmp_auth_protocol'], $h['snmp_priv_passphrase'], $h['snmp_priv_protocol'], $h['snmp_context'], $h['snmp_port'], $h['snmp_timeout'], read_config_option('snmp_retries'), SNMP_CMDPHP);
if (!empty($value)) {
db_execute_prepared("UPDATE host SET {$name} = ? WHERE id = ?", array($value, $host_id));
}
}
}
}