本文整理汇总了PHP中form_alternate_row函数的典型用法代码示例。如果您正苦于以下问题:PHP form_alternate_row函数的具体用法?PHP form_alternate_row怎么用?PHP form_alternate_row使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了form_alternate_row函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: draw_edit_form
function draw_edit_form($array)
{
if (sizeof($array) > 0) {
while (list($top_branch, $top_children) = each($array)) {
if ($top_branch == "config") {
$config_array = $top_children;
} elseif ($top_branch == "fields") {
$fields_array = $top_children;
}
}
}
$i = 0;
if (sizeof($fields_array) > 0) {
while (list($field_name, $field_array) = each($fields_array)) {
if ($i == 0) {
if (!isset($config_array["no_form_tag"])) {
print "<tr style='display:none;'><td><form method='post' autocomplete='off' action='" . (isset($config_array["post_to"]) ? $config_array["post_to"] : basename($_SERVER["PHP_SELF"])) . "'" . (isset($config_array["form_name"]) ? " name='" . $config_array["form_name"] . "'" : "") . (isset($config_array["enctype"]) ? " enctype='" . $config_array["enctype"] . "'" : "") . "></td></tr>\n";
}
}
if ($field_array["method"] == "hidden") {
form_hidden_box($field_name, $field_array["value"], isset($field_array["default"]) ? $field_array["default"] : "");
} elseif ($field_array["method"] == "hidden_zero") {
form_hidden_box($field_name, $field_array["value"], "0");
} elseif ($field_array["method"] == "spacer") {
if (isset($field_array['collapsible']) && $field_array['collapsible'] == 'true') {
$collapsible = true;
} else {
$collapsible = false;
}
print "<tr class='spacer tableHeader" . ($collapsible ? ' collapsible' : '') . "' id='row_{$field_name}'><td colspan='2' style='cursor:pointer;' class='tableSubHeaderColumn'>" . $field_array["friendly_name"] . ($collapsible ? "<div style='float:right;padding-right:4px;'><i class='fa fa-angle-double-up'></i></div>" : "") . "</td></tr>\n";
} else {
if (isset($config_array["force_row_color"])) {
print "<tr class='even-alternate'>";
} else {
form_alternate_row('row_' . $field_name);
}
print "<td width='" . (isset($config_array["left_column_width"]) ? $config_array["left_column_width"] : "50%") . "'>\n<font class='textEditTitle'>" . $field_array["friendly_name"] . "</font><br>\n";
if (isset($field_array["sub_checkbox"])) {
form_checkbox($field_array["sub_checkbox"]["name"], $field_array["sub_checkbox"]["value"], $field_array["sub_checkbox"]["friendly_name"], isset($field_array["sub_checkbox"]["default"]) ? $field_array["sub_checkbox"]["default"] : "", isset($field_array["sub_checkbox"]["form_id"]) ? $field_array["sub_checkbox"]["form_id"] : "", isset($field_array["sub_checkbox"]["class"]) ? $field_array["sub_checkbox"]["class"] : "", isset($field_array["sub_checkbox"]["on_change"]) ? $field_array["sub_checkbox"]["on_change"] : "");
}
print (isset($field_array["description"]) ? $field_array["description"] : "") . "</td>\n";
print "<td>";
draw_edit_control($field_name, $field_array);
print "</td>\n</tr>\n";
}
$i++;
}
}
}
开发者ID:MrWnn,项目名称:cacti,代码行数:49,代码来源:html_form.php
示例2: mikrotik_devices
//.........这里部分代码省略.........
$num_rows = get_request_var_request('rows');
}
$limit = ' LIMIT ' . $num_rows * (get_request_var_request('page') - 1) . ',' . $num_rows;
$sql_where = '';
if ($_REQUEST['status'] != '-1') {
$sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . ' hrs.host_status=' . $_REQUEST['status'];
}
$sql_join = '';
if ($_REQUEST['filter'] != '') {
$sql_where .= (strlen($sql_where) ? ' AND' : 'WHERE') . " h.description LIKE '%" . $_REQUEST['filter'] . "%' OR\n\t\t\th.hostname LIKE '%" . $_REQUEST['filter'] . "%'";
}
$sql = "SELECT hrs.*, h.hostname, h.description, h.disabled, trees.trees, queues.queues\n\t\tFROM plugin_mikrotik_system AS hrs\n\t\tINNER JOIN host AS h \n\t\tON h.id=hrs.host_id\n\t\tLEFT JOIN (SELECT host_id AS hid, count(*) AS trees FROM plugin_mikrotik_trees GROUP BY host_id) AS trees\n\t\tON trees.hid=hrs.host_id\n\t\tLEFT JOIN (SELECT host_id AS hid, count(*) AS queues FROM plugin_mikrotik_queues GROUP BY host_id) AS queues\n\t\tON queues.hid=hrs.host_id\n\t\t{$sql_join}\n\t\t{$sql_where}\n\t\tORDER BY " . get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") . " " . $limit;
//echo $sql;
$rows = db_fetch_assoc($sql);
$total_rows = db_fetch_cell("SELECT COUNT(*)\n\t\tFROM plugin_mikrotik_system AS hrs\n\t\tINNER JOIN host AS h\n\t\tON h.id=hrs.host_id\n\t\t{$sql_join}\n\t\t{$sql_where}");
$nav = html_nav_bar('mikrotik.php?action=devices', MAX_DISPLAY_PAGES, get_request_var_request('page'), $num_rows, $total_rows, 15, 'Devices', 'page', 'main');
print $nav;
$display_text = array('nosort' => array('display' => 'Actions', 'sort' => 'ASC', 'align' => 'left'), 'description' => array('display' => 'Name', 'sort' => 'ASC', 'align' => 'left'), 'host_status' => array('display' => 'Status', 'sort' => 'DESC', 'align' => 'center'), 'firmwareVersion' => array('display' => 'FW Ver', 'sort' => 'DESC', 'align' => 'right'), 'licVersion' => array('display' => 'Lic Ver', 'sort' => 'DESC', 'align' => 'right'), 'uptime' => array('display' => 'Uptime(d:h:m)', 'sort' => 'DESC', 'align' => 'right'), 'trees' => array('display' => 'Trees', 'sort' => 'DESC', 'align' => 'right'), 'users' => array('display' => 'Users', 'sort' => 'DESC', 'align' => 'right'), 'cpuPercent' => array('display' => 'CPU %', 'sort' => 'DESC', 'align' => 'right'), 'numCpus' => array('display' => 'CPUs', 'sort' => 'DESC', 'align' => 'right'), 'processes' => array('display' => 'Processes', 'sort' => 'DESC', 'align' => 'right'), 'memSize' => array('display' => 'Total Mem', 'sort' => 'DESC', 'align' => 'right'), 'memUsed' => array('display' => 'Used Mem', 'sort' => 'DESC', 'align' => 'right'), 'diskSize' => array('display' => 'Total Disk', 'sort' => 'DESC', 'align' => 'right'), 'diskUsed' => array('display' => 'Used Disk', 'sort' => 'DESC', 'align' => 'right'));
html_header_sort($display_text, get_request_var_request('sort_column'), get_request_var_request('sort_direction'), 'false');
/* set some defaults */
$url = $config['url_path'] . 'plugins/mikrotik/mikrotik.php';
$users = $config['url_path'] . 'plugins/mikrotik/images/view_users.gif';
$usersn = $config['url_path'] . 'plugins/mikrotik/images/view_users_none.gif';
$host = $config['url_path'] . 'plugins/mikrotik/images/view_hosts.gif';
$trees = $config['url_path'] . 'plugins/mikrotik/images/view_trees.gif';
$treesn = $config['url_path'] . 'plugins/mikrotik/images/view_trees_none.gif';
$queues = $config['url_path'] . 'plugins/mikrotik/images/view_queues.gif';
$queuesn = $config['url_path'] . 'plugins/mikrotik/images/view_queues_none.gif';
$interfaces = $config['url_path'] . 'plugins/mikrotik/images/view_interfaces.gif';
$dashboard = $config['url_path'] . 'plugins/mikrotik/images/view_dashboard.gif';
$graphs = $config['url_path'] . 'plugins/mikrotik/images/view_graphs.gif';
$nographs = $config['url_path'] . 'plugins/mikrotik/images/view_graphs_disabled.gif';
$hcpudq = read_config_option('mikrotik_dq_host_cpu');
if (sizeof($rows)) {
foreach ($rows as $row) {
$days = intval($row['uptime'] / (60 * 60 * 24 * 100));
$remainder = $row['uptime'] % (60 * 60 * 24 * 100);
$hours = intval($remainder / (60 * 60 * 100));
$remainder = $remainder % (60 * 60 * 100);
$minutes = intval($remainder / (60 * 100));
$found = db_fetch_cell('SELECT COUNT(*) FROM graph_local WHERE host_id=' . $row['host_id']);
form_alternate_row();
echo "<td style='white-space:nowrap;min-width:115px;text-align:left;'>";
//echo "<a style='padding:1px;' href='" . htmlspecialchars("$url?action=dashboard&reset=1&device=" . $row["host_id"]) . "'><img src='$dashboard' title='View Dashboard' align='absmiddle' border='0'></a>";
if ($row['users'] > 0) {
echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=users&reset=1&device=" . $row['host_id']) . "'><img src='{$users}' title='View Users' align='absmiddle' border='0' alt=''></a>";
} else {
echo "<img style='border:0px;padding:3px;' src='{$usersn}' title='No Users Found' align='absmiddle' alt=''>";
}
if ($row['queues'] > 0) {
echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=queues&reset=1&device=" . $row['host_id']) . "'><img src='{$queues}' title='View Simple Queue' align='absmiddle' border='0' alt=''></a>";
} else {
echo "<img style='border:0px;padding:3px;' src='{$queuesn}' title='No Simple Queues Found' align='absmiddle' alt=''>";
}
if ($row['trees'] > 0) {
echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=trees&reset=1&device=" . $row['host_id']) . "'><img src='{$trees}' title='View Queue Trees' align='absmiddle' border='0' alt=''></a>";
} else {
echo "<img style='border:0px;padding:3px;' src='{$treesn}' title='No Queue Trees Found' align='absmiddle' alt=''>";
}
echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=interfaces&reset=1&device=" . $row['host_id']) . "'><img src='{$interfaces}' title='View Interfaces' align='absmiddle' border='0' alt=''></a>";
if ($found) {
echo "<a class='hyperLink' href='" . htmlspecialchars("{$url}?action=graphs&reset=1&host_id=" . $row['host_id'] . "&style=selective&graph_add=&graph_list=&graph_template_id=0&filter=") . "'><img src='{$graphs}' title='View Graphs' align='absmiddle' border='0' alt=''></a>";
} else {
echo "<img src='{$nographs}' title='No Graphs Defined' align='absmiddle' border='0'>";
}
$graph_cpu = mikrotik_get_graph_url($hcpudq, $row['host_id'], '', $row['numCpus'], false);
$graph_cpup = mikrotik_get_graph_template_url(mikrotik_template_by_hash('7df474393f58bae8e8d6b85f10efad71'), $row['host_id'], round($row['cpuPercent'], 2), false);
$graph_users = mikrotik_get_graph_template_url(mikrotik_template_by_hash('99e37ff13139f586d257ba9a637d7340'), $row['host_id'], empty($rows['users']) ? '-' : $row['users'], false);
$graph_aproc = mikrotik_get_graph_template_url(mikrotik_template_by_hash('e797d967db24fd86341a8aa8c60fa9e0'), $row['host_id'], $row['host_status'] < 2 ? 'N/A' : $row['processes'], false);
$graph_disk = mikrotik_get_graph_template_url(mikrotik_template_by_hash('0ece13b90785aa04d1f554a093685948'), $row['host_id'], $row['host_status'] < 2 ? 'N/A' : round($row['diskUsed'], 2), false);
$graph_mem = mikrotik_get_graph_template_url(mikrotik_template_by_hash('4396ae857c4f9bc5ed1f26b5361e42d9'), $row['host_id'], $row['host_status'] < 2 ? 'N/A' : round($row['memUsed'], 2), false);
$graph_upt = mikrotik_get_graph_template_url(mikrotik_template_by_hash('7d8dc3050621a2cb937cac3895bc5d5b'), $row['host_id'], $row['host_status'] < 2 ? 'N/A' : mikrotik_format_uptime($days, $hours, $minutes), false);
if (api_plugin_user_realm_auth('host.php')) {
$host_url = "<a class='hyperLink' href='" . htmlspecialchars($config['url_path'] . 'host.php?action=edit&id=' . $row['host_id']) . "' title='Edit Hosts'>" . $row['hostname'] . '</a>';
} else {
$host_url = $row['hostname'];
}
echo '</td>';
echo "<td style='text-align:left;white-space:nowrap;'><strong>" . (strlen($_REQUEST['filter']) ? preg_replace('/(' . preg_quote(get_request_var_request('filter'), '/') . ')/i', "<span class='filteredValue'>\\1</span>", $row['description'] . '</strong> [' . $host_url . ']') : $row['description'] . '</strong> [' . $host_url . ']') . '</td>';
echo "<td style='text-align:center;'>" . get_colored_device_status($row['disabled'] == 'on' ? true : false, $row['host_status']) . '</td>';
echo "<td style='text-align:right;'>" . $row['firmwareVersion'] . '</td>';
echo "<td style='text-align:right;'>" . $row['licVersion'] . '</td>';
echo "<td style='text-align:right;'>" . $graph_upt . '</td>';
echo "<td style='text-align:right;'>" . (!empty($row['trees']) ? $row['trees'] : '-') . '</td>';
echo "<td style='text-align:right;'>" . $graph_users . '</td>';
echo "<td style='text-align:right;'>" . ($row['host_status'] < 2 ? 'N/A' : $graph_cpup) . '</td>';
echo "<td style='text-align:right;'>" . ($row['host_status'] < 2 ? 'N/A' : $graph_cpu) . '</td>';
echo "<td style='text-align:right;'>" . $graph_aproc . '</td>';
echo "<td style='text-align:right;'>" . mikrotik_memory($row['memSize']) . '</td>';
echo "<td style='text-align:right;'>" . $graph_mem . ' %</td>';
echo "<td style='text-align:right;'>" . mikrotik_memory($row['diskSize']) . '</td>';
echo "<td style='text-align:right;'>" . $graph_disk . ' %</td>';
form_end_row();
}
print $nav;
} else {
print '<tr><td colspan="5"><em>No Devices Found</em></td></tr>';
}
html_end_box();
}
开发者ID:TFyre,项目名称:plugin_mikrotik_new,代码行数:101,代码来源:mikrotik.php
示例3: graphs
function graphs()
{
global $item_rows;
/* ================= input validation ================= */
input_validate_input_number(get_request_var_request('host_id'));
input_validate_input_number(get_request_var_request('graph_type'));
input_validate_input_number(get_request_var_request('rows'));
/* ==================================================== */
/* clean up search string */
if (isset($_REQUEST['filter'])) {
$_REQUEST['filter'] = sanitize_search_string(get_request_var_request('filter'));
}
/* if the user pushed the 'clear' button */
if (isset($_REQUEST['clear_x'])) {
kill_session_var('sess_graphs_new_filter');
kill_session_var('sess_default_rows');
unset($_REQUEST['filter']);
unset($_REQUEST['rows']);
$changed = true;
} else {
/* if any of the settings changed, reset the page number */
$changed = false;
$changed += check_changed('host_id', 'sess_graphs_new_host_id');
$changed += check_changed('graph_type', 'sess_graphs_new_graph_type');
$changed += check_changed('filter', 'sess_graphs_new_filter');
$changed += check_changed('rows', 'sess_default_rows');
}
load_current_session_value('host_id', 'sess_graphs_new_host_id', db_fetch_cell('SELECT id FROM host ORDER BY description, hostname LIMIT 1'));
load_current_session_value('graph_type', 'sess_graphs_new_graph_type', read_config_option('default_graphs_new_dropdown'));
load_current_session_value('filter', 'sess_graphs_new_filter', '');
load_current_session_value('rows', 'sess_default_rows', read_config_option('num_rows_table'));
if (!empty($_REQUEST['host_id'])) {
$host = db_fetch_row_prepared('SELECT id, description, hostname, host_template_id FROM host WHERE id = ?', array($_REQUEST['host_id']));
$header = ' [ ' . htmlspecialchars($host['description']) . ' (' . htmlspecialchars($host['hostname']) . ') ' . (!empty($host['host_template_id']) ? htmlspecialchars(db_fetch_cell_prepared('SELECT name FROM host_template WHERE id = ?', array($host['host_template_id']))) : '') . ' ]';
} else {
$host = array();
$header = 'None Host Type';
}
$row_limit = get_request_var_request('rows');
html_start_box("<strong>New Graphs for</strong> {$header}", '100%', '', '3', 'center', '');
form_alternate_row();
print '<td class="even">';
?>
<script type='text/javascript'>
<!--
function applyFilter() {
strURL = '?graph_type=' + $('#graph_type').val();
strURL = strURL + '&host_id=' + $('#host_id').val();
strURL = strURL + '&filter=' + $('#filter').val();;
strURL = strURL + '&rows=' + $('#rows').val();;
document.location = strURL;
}
-->
</script>
<form name='form_graphs_new' action='graphs_new.php'>
<table width='100%' cellpadding='2' cellspacing='0' border='0' align='left'>
<tr>
<?php
print html_host_filter($_REQUEST['host_id']);
?>
<td style='white-space:nowrap;' width='1'>
Graph Types
</td>
<td width='1'>
<select id='graph_type' name='graph_type' onChange='applyFilter()'>
<option value='-2'<?php
if ($_REQUEST['graph_type'] == '-2') {
?>
selected<?php
}
?>
>All</option>
<option value='-1'<?php
if ($_REQUEST['graph_type'] == '-1') {
?>
selected<?php
}
?>
>Graph Template Based</option>
<?php
$snmp_queries = db_fetch_assoc_prepared('SELECT
snmp_query.id,
snmp_query.name,
snmp_query.xml_path
FROM (snmp_query, host_snmp_query)
WHERE host_snmp_query.snmp_query_id = snmp_query.id
AND host_snmp_query.host_id = ?
ORDER BY snmp_query.name', array($host['id']));
if (sizeof($snmp_queries) > 0) {
foreach ($snmp_queries as $query) {
print "<option value='" . $query['id'] . "'";
if ($_REQUEST['graph_type'] == $query['id']) {
print ' selected';
}
print '>' . $query['name'] . "</option>\n";
}
}
?>
//.........这里部分代码省略.........
开发者ID:MrWnn,项目名称:cacti,代码行数:101,代码来源:graphs_new.php
示例4: host
//.........这里部分代码省略.........
</select>
</td>
<td>
<input type="button" id='refresh' value="Go" title="Set/Refresh Filters">
</td>
<td>
<input type="button" id='clear' name="clear_x" value="Clear" title="Clear Filters">
</td>
</tr>
</table>
<input type='hidden' id='page' name='page' value='<?php
print $_REQUEST['page'];
?>
'>
</form>
</td>
</tr>
<?php
html_end_box();
/* form the 'where' clause for our main sql query */
if (strlen(get_request_var_request('filter'))) {
$sql_where = "where (host.hostname like '%%" . get_request_var_request('filter') . "%%' OR host.description like '%%" . get_request_var_request('filter') . "%%')";
} else {
$sql_where = '';
}
if (get_request_var_request('host_status') == '-1') {
/* Show all items */
} elseif (get_request_var_request('host_status') == '-2') {
$sql_where .= strlen($sql_where) ? " AND host.disabled='on'" : " WHERE host.disabled='on'";
} elseif (get_request_var_request('host_status') == '-3') {
$sql_where .= strlen($sql_where) ? " AND host.disabled=''" : " WHERE host.disabled=''";
} elseif (get_request_var_request('host_status') == '-4') {
$sql_where .= strlen($sql_where) ? " AND (host.status!='3' OR host.disabled='on')" : " WHERE (host.status!='3' OR host.disabled='on')";
} else {
$sql_where .= strlen($sql_where) ? ' AND (host.status=' . get_request_var_request('host_status') . " AND host.disabled = '')" : 'where (host.status=' . get_request_var_request('host_status') . " AND host.disabled = '')";
}
if (get_request_var_request('host_template_id') == '-1') {
/* Show all items */
} elseif (get_request_var_request('host_template_id') == '0') {
$sql_where .= strlen($sql_where) ? ' AND host.host_template_id=0' : ' WHERE host.host_template_id=0';
} elseif (!empty($_REQUEST['host_template_id'])) {
$sql_where .= strlen($sql_where) ? ' AND host.host_template_id=' . get_request_var_request('host_template_id') : ' WHERE host.host_template_id=' . get_request_var_request('host_template_id');
}
/* print checkbox form for validation */
print "<form name='chk' method='post' action='host.php'>\n";
html_start_box('', '100%', '', '3', 'center', '');
$total_rows = db_fetch_cell("SELECT\n\t\tCOUNT(host.id)\n\t\tFROM host\n\t\t{$sql_where}");
$sortby = get_request_var_request('sort_column');
if ($sortby == 'hostname') {
$sortby = 'INET_ATON(hostname)';
}
$sql_query = "SELECT host.*, graphs, data_sources\n\t\tFROM host\n\t\tLEFT JOIN (SELECT host_id, COUNT(*) AS graphs FROM graph_local GROUP BY host_id) AS gl\n\t\tON host.id=gl.host_id\n\t\tLEFT JOIN (SELECT host_id, COUNT(*) AS data_sources FROM data_local GROUP BY host_id) AS dl\n\t\tON host.id=dl.host_id\n\t\t{$sql_where}\n\t\tGROUP BY host.id\n\t\tORDER BY " . $sortby . ' ' . get_request_var_request('sort_direction') . '
LIMIT ' . get_request_var_request('rows') * (get_request_var_request('page') - 1) . ',' . get_request_var_request('rows');
$hosts = db_fetch_assoc($sql_query);
$nav = html_nav_bar('host.php?filter=' . get_request_var_request('filter') . '&host_template_id=' . get_request_var_request('host_template_id') . '&host_status=' . get_request_var_request('host_status'), MAX_DISPLAY_PAGES, get_request_var_request('page'), get_request_var_request('rows'), $total_rows, 13, 'Devices', 'page', 'main');
print $nav;
$display_text = array('description' => array('display' => 'Device Description', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'The name by which this Device will be referred to.'), 'hostname' => array('display' => 'Hostname', 'align' => 'left', 'sort' => 'ASC', 'tip' => 'Either an IP address, or hostname. If a hostname, it must be resolvable by either DNS, or from your hosts file.'), 'id' => array('display' => 'ID', 'align' => 'right', 'sort' => 'ASC', 'tip' => 'The internal database ID for this Device. Useful when performing automation or debugging.'), 'graphs' => array('display' => 'Graphs', 'align' => 'right', 'sort' => 'ASC', 'tip' => 'The total number of Graphs generated from this Device.'), 'data_sources' => array('display' => 'Data Sources', 'align' => 'right', 'sort' => 'ASC', 'tip' => 'The total number of Data Sources generated from this Device.'), 'status' => array('display' => 'Status', 'align' => 'center', 'sort' => 'ASC', 'tip' => 'The monitoring status of the Device based upon ping results. If this Device is a special type Device, by using the hostname "localhost", or due to the setting to not perform an Availability Check, it will always remain Up. When using cmd.php data collector, a Device with no Graphs, is not pinged by the data collector and will remain in an "Unknown" state.'), 'status_rec_date' => array('display' => 'In State', 'align' => 'right', 'sort' => 'ASC', 'tip' => 'The amount of time that this Device has been in its current state.'), 'snmp_sysUpTimeInstance' => array('display' => 'Uptime', 'align' => 'right', 'sort' => 'ASC', 'tip' => 'The current amount of time that the host has been up.'), 'polling_time' => array('display' => 'Poll Time', 'align' => 'right', 'sort' => 'ASC', 'tip' => 'The the amount of time it takes to collect data from this Device.'), 'cur_time' => array('display' => 'Current (ms)', 'align' => 'right', 'sort' => 'DESC', 'tip' => 'The current ping time in milliseconds to reach the Device.'), 'avg_time' => array('display' => 'Average (ms)', 'align' => 'right', 'sort' => 'DESC', 'tip' => 'The average ping time in milliseconds to reach the Device since the counters were cleared for this Device.'), 'availability' => array('display' => 'Availability', 'align' => 'right', 'sort' => 'ASC', 'tip' => 'The availability percentage based upon ping results insce the counters were cleared for this Device.'));
html_header_sort_checkbox($display_text, get_request_var_request('sort_column'), get_request_var_request('sort_direction'), false);
$i = 0;
if (sizeof($hosts) > 0) {
foreach ($hosts as $host) {
if ($host['disabled'] == '' && ($host['status'] == HOST_RECOVERING || $host['status'] == HOST_UP) && ($host['availability_method'] != AVAIL_NONE && $host['availability_method'] != AVAIL_PING)) {
$snmp_uptime = $host['snmp_sysUpTimeInstance'];
$days = intval($snmp_uptime / (60 * 60 * 24 * 100));
$remainder = $snmp_uptime % (60 * 60 * 24 * 100);
$hours = intval($remainder / (60 * 60 * 100));
$remainder = $remainder % (60 * 60 * 100);
$minutes = intval($remainder / (60 * 100));
$uptime = "{$days} d {$hours} h {$minutes} m";
} else {
$uptime = "N/A";
}
form_alternate_row('line' . $host['id'], true);
form_selectable_cell("<a class='linkEditMain' href='" . htmlspecialchars('host.php?action=edit&id=' . $host['id']) . "'>" . (strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter'), '/') . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($host['description'])) : htmlspecialchars($host['description'])) . '</a>', $host['id']);
form_selectable_cell(strlen(get_request_var_request('filter')) ? preg_replace('/(' . preg_quote(get_request_var_request('filter'), '/') . ')/i', "<span class='filteredValue'>\\1</span>", htmlspecialchars($host['hostname'])) : htmlspecialchars($host['hostname']), $host['id']);
form_selectable_cell($host['id'], $host['id'], '', 'text-align:right');
form_selectable_cell(number_format($host['graphs']), $host['id'], '', 'text-align:right');
form_selectable_cell(number_format($host['data_sources']), $host['id'], '', 'text-align:right');
form_selectable_cell(get_colored_device_status($host['disabled'] == 'on' ? true : false, $host['status']), $host['id'], '', 'text-align:center');
form_selectable_cell(get_timeinstate($host), $host['id'], '', 'text-align:right');
form_selectable_cell($uptime, $host['id'], '', 'text-align:right');
form_selectable_cell(round($host['polling_time'], 2), $host['id'], '', 'text-align:right');
form_selectable_cell(round($host['cur_time'], 2), $host['id'], '', 'text-align:right');
form_selectable_cell(round($host['avg_time'], 2), $host['id'], '', 'text-align:right');
form_selectable_cell(round($host['availability'], 2) . ' %', $host['id'], '', 'text-align:right');
form_checkbox_cell($host['description'], $host['id']);
form_end_row();
}
/* put the nav bar on the bottom as well */
print $nav;
} else {
print "<tr class='tableRow'><td colspan='11'><em>No Devices</em></td></tr>";
}
html_end_box(false);
/* add a list of tree names to the actions dropdown */
add_tree_names_to_actions_array();
/* draw the dropdown containing a list of available actions for this form */
draw_actions_dropdown($device_actions);
print "</form>\n";
}
开发者ID:MrWnn,项目名称:cacti,代码行数:101,代码来源:host.php
示例5: mactrack_site
function mactrack_site()
{
global $site_actions, $config, $item_rows;
mactrack_site_validate_req_vars();
if (get_request_var('rows') == -1) {
$row_limit = read_config_option('num_rows_table');
} elseif (get_request_var('rows') == -2) {
$row_limit = 999999;
} else {
$row_limit = get_request_var('rows');
}
html_start_box(__('MacTrack Site Filters'), '100%', '', '3', 'center', 'mactrack_sites.php?action=edit');
mactrack_site_filter();
html_end_box();
$sql_where = '';
$sites = mactrack_site_get_site_records($sql_where, $row_limit);
if (get_request_var('detail') == 'false') {
$total_rows = db_fetch_cell("SELECT\n\t\t\tCOUNT(mac_track_sites.site_id)\n\t\t\tFROM mac_track_sites\n\t\t\t{$sql_where}");
} else {
$total_rows = db_fetch_cell("SELECT count(*)\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.device_type_id");
}
if (get_request_var('detail') == 'false') {
$nav = html_nav_bar('mactrack_sites.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_filter_request_var('page'), $row_limit, $total_rows, 9, __('Sites'));
print $nav;
html_start_box('', '100%', '', '3', 'center', '');
$display_text = array('site_name' => array(__('Site Name'), 'ASC'), 'total_devices' => array(__('Devices'), 'DESC'), 'total_ips' => array(__('Total IP\'s'), 'DESC'), 'total_user_ports' => array(__('User Ports'), 'DESC'), 'total_oper_ports' => array(__('User Ports Up'), 'DESC'), 'total_macs' => array(__('MACS Found'), 'DESC'), 'total_device_errors' => array(__('Device Errors'), 'DESC'));
html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'));
$i = 0;
if (sizeof($sites)) {
foreach ($sites as $site) {
form_alternate_row('line' . $site['site_id'], true);
form_selectable_cell("<a class='linkEditMain' href='mactrack_sites.php?action=edit&site_id=" . $site['site_id'] . "'>" . (get_request_var('filter') != '' ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", $site['site_name']) : $site['site_name']) . '</a>', $site['site_id']);
form_selectable_cell(number_format_i18n($site['total_devices']), $site['site_id']);
form_selectable_cell(number_format_i18n($site['total_ips']), $site['site_id']);
form_selectable_cell(number_format_i18n($site['total_user_ports']), $site['site_id']);
form_selectable_cell(number_format_i18n($site['total_oper_ports']), $site['site_id']);
form_selectable_cell(number_format_i18n($site['total_macs']), $site['site_id']);
form_selectable_cell($site['total_device_errors'], $site['site_id']);
form_checkbox_cell($site['site_name'], $site['site_id']);
form_end_row();
}
} else {
print '<tr><td><em>' . __('No MacTrack Sites') . '</em></td></tr>';
}
html_end_box(false);
if (sizeof($sites)) {
print $nav;
}
} else {
$nav = html_nav_bar('mactrack_sites.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_filter_request_var('page'), $row_limit, $total_rows, 10, __('Sites'));
print $nav;
html_start_box('', '100%', '', '3', 'center', '');
$display_text = array('site_name' => array(__('Site Name'), 'ASC'), 'vendor' => array(__('Vendor'), 'ASC'), 'description' => array(__('Device Type'), 'DESC'), 'total_devices' => array(__('Total Devices'), 'DESC'), 'sum_ips_total' => array(__('Total IP\'s'), 'DESC'), 'sum_ports_total' => array(__('Total User Ports'), 'DESC'), 'sum_ports_active' => array(__('Total Oper Ports'), 'DESC'), 'sum_ports_trunk' => array(__('Total Trunks'), 'DESC'), 'sum_macs_active' => array(__('MACS Found'), 'DESC'));
html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'));
if (sizeof($sites)) {
foreach ($sites as $site) {
form_alternate_row();
?>
<td width=200>
<a class='linkEditMain' href='mactrack_sites.php?action=edit&site_id=<?php
print $site['site_id'];
?>
'><?php
print get_request_var('filter') != '' ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", $site['site_name']) : $site['site_name'];
?>
</a>
</td>
<td><?php
print get_request_var('filter') != '' ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", $site['vendor']) : $site['vendor'];
?>
</td>
<td><?php
print get_request_var('filter') != '' ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue'>\\1</span>", $site['description']) : $site['description'];
?>
</td>
<td><?php
print number_format_i18n($site['total_devices']);
?>
</td>
<td><?php
print number_format_i18n($site['sum_ips_total']);
?>
</td>
<td><?php
print number_format_i18n($site['sum_ports_total']);
?>
</td>
<td><?php
print number_format_i18n($site['sum_ports_active']);
?>
</td>
<td><?php
print number_format_i18n($site['sum_ports_trunk']);
?>
</td>
<td><?php
print number_format_i18n($site['sum_macs_active']);
?>
</td>
</tr>
//.........这里部分代码省略.........
开发者ID:Cacti,项目名称:plugin_mactrack,代码行数:101,代码来源:mactrack_sites.php
示例6: snmpagent_utilities_run_eventlog
//.........这里部分代码省略.........
" onChange='applyFilter()'>
</td>
<td>
Rows:
</td>
<td>
<select id='rows' name="rows" onChange="applyFilter()">
<option value="-1"<?php
if (get_request_var_request("rows") == "-1") {
?>
selected<?php
}
?>
>Default</option>
<?php
if (sizeof($item_rows) > 0) {
foreach ($item_rows as $key => $value) {
print "<option value='" . $key . "'";
if (get_request_var_request("rows") == $key) {
print " selected";
}
print ">" . htmlspecialchars($value) . "</option>\n";
}
}
?>
</select>
</td>
<td>
<input type="submit" id="refresh" name="go" value="Go" title="Set/Refresh Filters">
<input type="submit" id="clear" name="clear_x" value="Clear" title="Clear Filters">
<input type="submit" id="purge" name="purge_x" value="Purge" title="Purge Notification Log">
</td>
</tr>
</table>
<input type='hidden' id='page' name='page' value='<?php
print $_REQUEST['page'];
?>
'>
</form>
</td>
</tr>
<?php
html_end_box();
$sql_where = " 1";
/* filter by severity */
if (get_request_var_request("receiver") != "-1") {
$sql_where .= " AND snmpagent_notifications_log.manager_id='" . get_request_var_request("receiver") . "'";
}
/* filter by severity */
if (get_request_var_request("severity") == "-1") {
/* Show all items */
} elseif (!empty($_REQUEST["severity"])) {
$sql_where .= " AND snmpagent_notifications_log.severity='" . get_request_var_request("severity") . "'";
}
/* filter by search string */
if (get_request_var_request("filter") != "") {
$sql_where .= " AND (`varbinds` LIKE '%%" . get_request_var_request("filter") . "%%')";
}
$sql_where .= ' ORDER by `time` DESC';
$sql_query = "SELECT snmpagent_notifications_log.*, snmpagent_managers.hostname, snmpagent_cache.description FROM snmpagent_notifications_log\n\t\t\t\t\t INNER JOIN snmpagent_managers ON snmpagent_managers.id = snmpagent_notifications_log.manager_id\n\t\t\t\t\t LEFT JOIN snmpagent_cache ON snmpagent_cache.name = snmpagent_notifications_log.notification\n\t\t\t\t\t WHERE {$sql_where} LIMIT " . read_config_option("num_rows_data_source") * (get_request_var_request("page") - 1) . "," . read_config_option("num_rows_data_source");
/* print checkbox form for validation */
print "<form name='chk' method='post' action='managers.php'>\n";
html_start_box("", "100%", "", "3", "center", "");
$total_rows = db_fetch_cell("SELECT COUNT(*) FROM snmpagent_notifications_log WHERE {$sql_where}");
$logs = db_fetch_assoc($sql_query);
/* generate page list */
$nav = html_nav_bar("utilities.php?action=view_snmpagent_events&severity=" . get_request_var_request("severity") . "&receiver=" . get_request_var_request("receiver") . "&filter=" . get_request_var_request("filter"), MAX_DISPLAY_PAGES, get_request_var_request("page"), get_request_var_request("rows"), $total_rows, 11, '', 'page', 'main');
print $nav;
html_header(array(" ", "Time", "Receiver", "Notification", "Varbinds"));
if (sizeof($logs) > 0) {
foreach ($logs as $item) {
$varbinds = strlen(get_request_var_request("filter")) ? preg_replace("/(" . preg_quote(get_request_var_request("filter"), "/") . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $item["varbinds"]) : $item["varbinds"];
form_alternate_row('line' . $item["id"], false);
print "<td title='Severity Level: " . $severity_levels[$item["severity"]] . "' style='width:10px;background-color: " . $severity_colors[$item["severity"]] . ";border-top:1px solid white;border-bottom:1px solid white;'></td>";
print "<td style='white-space: nowrap;'>" . date("Y/m/d H:i:s", $item["time"]) . "</td>";
print "<td>" . $item["hostname"] . "</td>";
if ($item["description"]) {
print '<td><a href="#" title="<div class=\'header\'>' . $item["notification"] . '</div><div class=\'content preformatted\'>' . $item["description"] . '</div>" class="tooltip">' . $item["notification"] . '</a></td>';
} else {
print "<td>{$item["notification"]}</td>";
}
print "<td>{$varbinds}</td>";
form_end_row();
}
print $nav;
} else {
print "<tr><td><em>No SNMP Notification Log Entries</em></td></tr>";
}
html_end_box();
?>
<script language="javascript" type="text/javascript" >
$('.tooltip').tooltip({
track: true,
position: { collision: "flipfit" },
content: function() { return $(this).attr('title'); }
});
</script>
<?php
}
开发者ID:MrWnn,项目名称:cacti,代码行数:101,代码来源:utilities.php
示例7: ds
//.........这里部分代码省略.........
html_end_box();
/* form the 'where' clause for our main sql query */
if (strlen(get_request_var_request("filter"))) {
$sql_where1 = "AND (data_template_data.name_cache like '%%" . get_request_var_request("filter") . "%%'" . " OR data_template_data.local_data_id like '%%" . get_request_var_request("filter") . "%%'" . " OR data_template.name like '%%" . get_request_var_request("filter") . "%%'" . " OR data_input.name like '%%" . get_request_var_request("filter") . "%%')";
$sql_where2 = "AND (data_template_data.name_cache like '%%" . get_request_var_request("filter") . "%%'" . " OR data_template.name like '%%" . get_request_var_request("filter") . "%%')";
} else {
$sql_where1 = "";
$sql_where2 = "";
}
if (get_request_var_request("host_id") == "-1") {
/* Show all items */
} elseif (get_request_var_request("host_id") == "0") {
$sql_where1 .= " AND data_local.host_id=0";
$sql_where2 .= " AND data_local.host_id=0";
} elseif (!empty($_REQUEST["host_id"])) {
$sql_where1 .= " AND data_local.host_id=" . get_request_var_request("host_id");
$sql_where2 .= " AND data_local.host_id=" . get_request_var_request("host_id");
}
if (get_request_var_request("template_id") == "-1") {
/* Show all items */
} elseif (get_request_var_request("template_id") == "0") {
$sql_where1 .= " AND data_template_data.data_template_id=0";
$sql_where2 .= " AND data_template_data.data_template_id=0";
} elseif (!empty($_REQUEST["host_id"])) {
$sql_where1 .= " AND data_template_data.data_template_id=" . get_request_var_request("template_id");
$sql_where2 .= " AND data_template_data.data_template_id=" . get_request_var_request("template_id");
}
if (get_request_var_request("method_id") == "-1") {
/* Show all items */
} elseif (get_request_var_request("method_id") == "0") {
$sql_where1 .= " AND data_template_data.data_input_id=0";
$sql_where2 .= " AND data_template_data.data_input_id=0";
} elseif (!empty($_REQUEST["method_id"])) {
$sql_where1 .= " AND data_template_data.data_input_id=" . get_request_var_request("method_id");
$sql_where2 .= " AND data_template_data.data_input_id=" . get_request_var_request("method_id");
}
$total_rows = sizeof(db_fetch_assoc("SELECT\n\t\tdata_local.id\n\t\tFROM (data_local,data_template_data)\n\t\tLEFT JOIN data_input\n\t\tON (data_input.id=data_template_data.data_input_id)\n\t\tLEFT JOIN data_template\n\t\tON (data_local.data_template_id=data_template.id)\n\t\tWHERE data_local.id=data_template_data.local_data_id\n\t\t{$sql_where1}"));
$poller_intervals = array_rekey(db_fetch_assoc("SELECT data_template_data.local_data_id AS id,\n\t\tMin(data_template_data.rrd_step*rra.steps) AS poller_interval\n\t\tFROM data_template\n\t\tINNER JOIN (data_local\n\t\tINNER JOIN ((data_template_data_rra\n\t\tINNER JOIN data_template_data ON data_template_data_rra.data_template_data_id=data_template_data.id)\n\t\tINNER JOIN rra ON data_template_data_rra.rra_id = rra.id) ON data_local.id = data_template_data.local_data_id) ON data_template.id = data_template_data.data_template_id\n\t\t{$sql_where2}\n\t\tGROUP BY data_template_data.local_data_id"), "id", "poller_interval");
$data_sources = db_fetch_assoc("SELECT\n\t\tdata_template_data.local_data_id,\n\t\tdata_template_data.name_cache,\n\t\tdata_template_data.active,\n\t\tdata_input.name as data_input_name,\n\t\tdata_template.name as data_template_name,\n\t\tdata_local.host_id\n\t\tFROM (data_local,data_template_data)\n\t\tLEFT JOIN data_input\n\t\tON (data_input.id=data_template_data.data_input_id)\n\t\tLEFT JOIN data_template\n\t\tON (data_local.data_template_id=data_template.id)\n\t\tWHERE data_local.id=data_template_data.local_data_id\n\t\t{$sql_where1}\n\t\tORDER BY " . get_request_var_request("sort_column") . " " . get_request_var_request("sort_direction") . " LIMIT " . get_request_var_request("ds_rows") * (get_request_var_request("page") - 1) . "," . get_request_var_request("ds_rows"));
print "<form name='chk' method='post' action='data_sources.php'>\n";
html_start_box("", "100%", "", "3", "center", "");
$nav = html_nav_bar("data_sources.php?filter=" . get_request_var_request("filter") . "&host_id=" . get_request_var_request("host_id"), MAX_DISPLAY_PAGES, get_request_var_request("page"), get_request_var_request("ds_rows"), $total_rows, 7);
print $nav;
$display_text = array("name_cache" => array("Name", "ASC"), "local_data_id" => array("ID", "ASC"), "data_input_name" => array("Data Input Method", "ASC"), "nosort" => array("Poller Interval", "ASC"), "active" => array("Active", "ASC"), "data_template_name" => array("Template Name", "ASC"));
html_header_sort_checkbox($display_text, get_request_var_request("sort_column"), get_request_var_request("sort_direction"), false);
$i = 0;
if (sizeof($data_sources) > 0) {
foreach ($data_sources as $data_source) {
$data_source["data_template_name"] = htmlspecialchars($data_source["data_template_name"]);
$data_name_cache = title_trim(htmlspecialchars($data_source["name_cache"]), read_config_option("max_title_data_source"));
if (trim(get_request_var_request("filter") != "")) {
$data_name_cache = preg_replace("/(" . preg_quote(get_request_var_request("filter"), "/") . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", $data_name_cache);
}
/* keep copy of data source for comparison */
$data_source_orig = $data_source;
$data_source = api_plugin_hook_function('data_sources_table', $data_source);
/* we're escaping strings here, so no need to escape them on form_selectable_cell */
if (empty($data_source["data_template_name"])) {
$data_template_name = "<em>None</em>";
} elseif ($data_source_orig["data_template_name"] != $data_source["data_template_name"]) {
/* was changed by plugin, plugin has to take care for html-escaping */
$data_template_name = empty($data_source["data_template_name"]) ? "<em>None</em>" : $data_source["data_template_name"];
} elseif (trim(get_request_var_request("filter") != "")) {
/* we take care of html-escaping */
$data_template_name = preg_replace("/(" . preg_quote(get_request_var_request("filter"), "/") . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", htmlspecialchars($data_source['data_template_name']));
} else {
$data_template_name = htmlspecialchars($data_source["data_template_name"]);
}
if (empty($data_source["data_input_name"])) {
$data_input_name = "<em>None</em>";
} elseif ($data_source_orig["data_input_name"] != $data_source["data_input_name"]) {
/* was changed by plugin, plugin has to take care for html-escaping */
$data_input_name = empty($data_source["data_input_name"]) ? "<em>None</em>" : $data_source["data_input_name"];
} elseif (trim(get_request_var_request("filter") != "")) {
/* we take care of html-escaping */
$data_input_name = preg_replace("/(" . preg_quote(get_request_var_request("filter"), "/") . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", htmlspecialchars($data_source['data_input_name']));
} else {
$data_input_name = htmlspecialchars($data_source["data_input_name"]);
}
$poller_interval = isset($poller_intervals[$data_source["local_data_id"]]) ? $poller_intervals[$data_source["local_data_id"]] : 0;
form_alternate_row('line' . $data_source["local_data_id"], true);
form_selectable_cell("<a class='linkEditMain' href='" . htmlspecialchars("data_sources.php?action=ds_edit&id=" . $data_source["local_data_id"]) . "' title='" . htmlspecialchars($data_source["name_cache"], ENT_QUOTES) . "'>" . (get_request_var_request("filter") != "" ? preg_replace("/(" . preg_quote(get_request_var_request("filter"), "/") . ")/i", "<span style='background-color: #F8D93D;'>\\1</span>", title_trim(htmlspecialchars($data_source["name_cache"]), read_config_option("max_title_data_source"))) : title_trim(htmlspecialchars($data_source["name_cache"]), read_config_option("max_title_data_source"))) . "</a>", $data_source["local_data_id"]);
form_selectable_cell($data_source['local_data_id'], $data_source['local_data_id']);
form_selectable_cell($data_input_name, $data_source["local_data_id"]);
form_selectable_cell(get_poller_interval($poller_interval), $data_source["local_data_id"]);
form_selectable_cell($data_source['active'] == "on" ? "Yes" : "No", $data_source["local_data_id"]);
form_selectable_cell($data_template_name, $data_source["local_data_id"]);
form_checkbox_cell($data_source["name_cache"], $data_source["local_data_id"]);
form_end_row();
}
/* put the nav bar on the bottom as well */
print $nav;
} else {
print "<tr><td><em>No Data Sources</em></td></tr>";
}
html_end_box(false);
/* draw the dropdown containing a list of available actions for this form */
draw_acti
|
请发表评论