本文整理汇总了PHP中rewrite_ifname函数的典型用法代码示例。如果您正苦于以下问题:PHP rewrite_ifname函数的具体用法?PHP rewrite_ifname怎么用?PHP rewrite_ifname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rewrite_ifname函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: humanize_port
* @subpackage webui
* @copyright (C) 2006-2014 Adam Armstrong
*
*/
# This file prints a table row for each interface
$port['device_id'] = $device['device_id'];
$port['hostname'] = $device['hostname'];
$if_id = $port['port_id'];
humanize_port($port);
if ($port['ifInErrors_delta'] > 0 || $port['ifOutErrors_delta'] > 0) {
$error_img = generate_port_link($port, "<img src='images/16/chart_curve_error.png' alt='接口错误' border=0>", "port_errors");
} else {
$error_img = "";
}
echo "<tr valign=top onmouseover=\"this.style.backgroundColor='{$list_highlight}';\" onmouseout=\"this.style.backgroundColor='{$row_colour}';\"\nonclick=\"location.href='device/" . $device['device_id'] . "/port/" . $port['port_id'] . "/'\" style='cursor: pointer;'>\n <td valign=top width=350>";
echo " <span class=entity-title>\n " . generate_port_link($port, $port['ifIndex'] . ". " . rewrite_ifname($port['label'])) . "\n </span><br /><span class=small>" . $port['ifAlias'] . "</span>";
if ($port['ifAlias']) {
echo "<br />";
}
unset($break);
if ($port_details) {
foreach (dbFetchRows("SELECT * FROM `ipv4_addresses` WHERE `port_id` = ?", array($port['port_id'])) as $ip) {
echo "{$break} <a class=small href=\"javascript:popUp('netcmd.php?cmd=whois&query=" . $ip['ipv4_address'] . "')\">" . $ip['ipv4_address'] . "/" . $ip['ipv4_prefixlen'] . "</a>";
$break = ",";
}
foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `port_id` = ?", array($port['port_id'])) as $ip6) {
}
echo "{$break} <a class=small href=\"javascript:popUp('netcmd.php?cmd=whois&query=" . $ip6['ipv6_address'] . "')\">" . Net_IPv6::compress($ip6['ipv6_address']) . "/" . $ip6['ipv6_prefixlen'] . "</a>";
$break = ",";
}
echo "</span>";
示例2: rewrite_ifname
$mac = $port['ifPhysAddress'];
}
$color = "black";
if ($port['ifAdminStatus'] == "down") {
$status = "<span class='grey'>禁用</span>";
} else {
if ($port['ifAdminStatus'] == "up") {
if ($port['ifOperStatus'] == "down" || $port['ifOperStatus'] == "lowerLayerDown") {
$status = "<span class='red'>启用 / 已断开</span>";
} else {
$status = "<span class='green'>启用 / 已连接</span>";
}
}
}
$i = 1;
$inf = rewrite_ifname($ifname);
echo "<div style='clear: both;'>";
if ($vars['subview'] == "top10") {
include "macaccounting_top10.inc.php";
} else {
$query = "SELECT *, `mac_accounting`.`ma_id` as `ma_id` FROM `mac_accounting` LEFT JOIN `mac_accounting-state` ON `mac_accounting`.`ma_id` = `mac_accounting-state`.`ma_id` WHERE port_id = ?";
$param = array($port['port_id']);
if ($vars['subview'] != minigraphs) {
if ($vars['subview'] == "graphs") {
$table_class = "table-striped-two";
} else {
$table_class = "table-striped";
}
echo '<table class="table table-hover table-condensed table-rounded table-bordered ' . $table_class . '">';
echo ' <thead>';
echo '<tr>';
示例3: foreach
$('#form-reset').click(function(event) {
// reset objects in the form to their previous values
event.preventDefault();
$('#ignoreport')[0].reset();
});
});
</script>
<?php
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `deleted` = '0' AND `device_id` = ? ORDER BY `ifIndex` ", array($device['device_id'])) as $port) {
humanize_port($port);
///print_vars($port);
echo '<tr class="' . $port['row_class'] . '">';
echo "<td>" . $port['ifIndex'] . "</td>";
echo "<td>" . rewrite_ifname($port['label']) . "<br />" . htmlentities($port['ifAlias']) . "</td>";
echo "<td>" . $port['human_type'] . "<br />";
echo '<span>' . htmlentities($port['admin_status']) . '</span> / <span name="operstatus_' . $port['port_id'] . '" class="' . $port['row_class'] . '">' . htmlentities($port['ifOperStatus']) . '</span></td>';
echo '<td style="vertical-align: middle;">';
echo "<input type=checkbox data-toggle='switch-revert' id='disabled_" . $port['port_id'] . "' name='disabled_" . $port['port_id'] . "'" . ($port['disabled'] ? ' checked' : '') . ">";
echo "<input type=hidden name='olddis_" . $port['port_id'] . "' value=" . ($port['disabled'] ? 1 : 0) . ">";
echo "</td>";
echo '<td style="vertical-align: middle;">';
echo "<input type=checkbox data-toggle='switch-revert' id='ignore_" . $port['port_id'] . "' name='ignore_" . $port['port_id'] . "'" . ($port['ignore'] ? ' checked' : '') . ">";
echo "<input type=hidden name='oldign_" . $port['port_id'] . "' value=" . ($port['ignore'] ? 1 : 0) . ">";
echo "</td>";
# echo('<td> <input class="input-mini" name="threshold_perc_in-'.$port['port_id'].'" size="3" value="'.$port['threshold_perc_in'].'"></input>');
# echo('<br /><input class="input-mini" name="threshold_perc_out-'.$port['port_id'].'" size="3" value="'.$port['threshold_perc_out'].'"></input></td>');
# echo('<td> <input class="input-mini" name="threshold_bps_in-'.$port['port_id'].'" size="3" value="'.$port['threshold_bps_in'].'"></input>');
# echo('<br /><input class="input-mini" name="threshold_bps_out-'.$port['port_id'].'" size="3" value="'.$port['threshold_bps_out'].'"></input></td>');
# echo('<td> <input class="input-mini" name="threshold_pps_in-'.$port['port_id'].'" size="3" value="'.$port['threshold_pps_in'].'"></input>');
示例4: foreach
<h2>端口权限</h2>
<?php
if (count($user_permissions['port'])) {
foreach (array_keys($user_permissions['port']) as $entity_id) {
$port = get_port_by_id($entity_id);
$device = device_by_id_cache($port['device_id']);
$emptyCheck = true;
$count++;
$devicebtn = '<button class="btn"><i class="oicon-servers"></i> ' . generate_device_link($device) . '</button>';
if (empty($port['ifAlias'])) {
$portalias = "";
} else {
$portalias = " - " . $port['ifAlias'] . "";
}
$portbtn = '<button class="btn">' . generate_port_link($port, '<i class="oicon-network-ethernet"></i> ' . rewrite_ifname($port['label']) . $portalias) . '</button>';
$del_url = generate_url(array('page' => 'edituser', 'action' => 'perm_del', 'user_id' => $vars['user_id'], 'entity_type' => 'port', 'entity_id' => $entity_id));
echo ' <div class="btn-group" style="margin: 5px;">';
echo ' <button class="btn btn-danger" style="color: #fff;" onclick="location.href=\'' . $del_url . '\';"><i class="icon-minus-sign icon-white"></i> 删除</button>';
echo ' ' . $devicebtn;
echo ' ' . $portbtn;
echo ' </div>';
}
} else {
echo '<div class="alert alert-danger">无权限</div>';
}
?>
<hr />
<h3>授予新的端口权限</h3>
示例5: unset
$graph_array['from'] = $vars['from'];
$graph_array['to'] = $vars['to'];
} else {
$graph_array['from'] = $config['time']['day'];
$graph_array['to'] = $config['time']['now'];
}
$graph_array['height'] = 100;
$graph_array['width'] = 210;
$graph_array['id'] = $port['port_id'];
$graph_array['type'] = $graph_type;
$graph_array['legend'] = "no";
$link_array = $graph_array;
$link_array['page'] = "graphs";
unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link = generate_url($link_array);
$overlib_content = generate_overlib_content($graph_array, $port['hostname'] . ' - ' . rewrite_ifname($port['label'], FALSE));
$graph_array['title'] = "yes";
$graph_array['width'] = $width;
$graph_array['height'] = $height;
$graph = generate_graph_tag($graph_array);
echo "<div style='display: block; padding: 1px; margin: 2px; min-width: " . $width_div . "px; max-width:" . $width_div . "px; min-height:" . $height_div . "px; max-height:" . $height_div . "; text-align: center; float: left; background-color: #f5f5f5;'>";
echo overlib_link($link, $graph, $overlib_content);
echo "</div>";
# echo("<div style='display: block; padding: 1px; margin: 2px; min-width: 393px; max-width:393px; min-height:180px; max-height:180px; text-align: center; float: left; background-color: #f5f5f5;'>
# <a href='".generate_port_url($port)."/' onmouseover=\"return overlib('\
# <div style=\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\'>".$device['hostname']." - ".$port['ifDescr']."</div>\
# <img src=\'graph.php?type=$graph_type&id=".$port['port_id']."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=450&height=150&title=yes\'>\
# ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >".
# "<img src='graph.php?type=$graph_type&id=".$port['port_id']."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=315&height=110&legend=no&title=yes'>
# </a>
# </div>");
示例6: generate_ap_link
function generate_ap_link($args, $text = NULL, $type = NULL, $escape = FALSE)
{
global $config;
humanize_port($args);
if (!$text) {
$text = rewrite_ifname($args['port_label'], !$escape);
}
// Negative escape flag for exclude double escape
if ($type) {
$args['graph_type'] = $type;
}
if (!isset($args['graph_type'])) {
$args['graph_type'] = 'port_bits';
}
if (!isset($args['hostname'])) {
$args = array_merge($args, device_by_id_cache($args['device_id']));
}
$content = "<div class=entity-title>" . $args['text'] . " - " . rewrite_ifname($args['port_label'], !$escape) . "</div>";
if ($args['ifAlias']) {
$content .= $args['ifAlias'] . "<br />";
}
$content .= "<div style=\\'width: 850px\\'>";
$graph_array['type'] = $args['graph_type'];
$graph_array['legend'] = "yes";
$graph_array['height'] = "100";
$graph_array['width'] = "340";
$graph_array['to'] = $config['time']['now'];
$graph_array['from'] = $config['time']['day'];
$graph_array['id'] = $args['accesspoint_id'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['time']['week'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['time']['month'];
$content .= generate_graph_tag($graph_array);
$graph_array['from'] = $config['time']['year'];
$content .= generate_graph_tag($graph_array);
$content .= "</div>";
$url = generate_ap_url($args);
if (port_permitted($args['interface_id'], $args['device_id'])) {
return overlib_link($url, $text, $content, $class, $escape);
} else {
return rewrite_ifname($text);
}
}
示例7: foreach
<th style="width: 250px;"><span style="font-weight: bold;" class="interface">客户</span></th>
<th style="width: 150px;">设备</th>
<th style="width: 100px;">接口</th>
<th style="width: 100px;">速率</th>
<th style="width: 100px;">线路</th>
<th>备注</th>
</tr>
</thead>
<?php
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' GROUP BY `port_descr_descr` ORDER BY `port_descr_descr`") as $customer) {
$customer_name = $customer['port_descr_descr'];
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = ?", array($customer['port_descr_descr'])) as $port) {
$device = device_by_id_cache($port['device_id']);
unset($class);
$ifname = rewrite_ifname($device['ifDescr']);
$ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
if ($device['os'] == "ios") {
if ($port['ifTrunk']) {
$vlan = "<span class=small><span class=red>" . $port['ifTrunk'] . "</span></span>";
} elseif ($port['ifVlan']) {
$vlan = "<span class=small><span class=blue>VLAN " . $port['ifVlan'] . "</span></span>";
} else {
$vlan = "";
}
}
echo '
<tr>
<td style="width: 250px;"><span style="font-weight: bold;" class="interface">' . $customer_name . '</span></td>
<td style="width: 150px;">' . generate_device_link($device) . '</td>
<td style="width: 100px;">' . generate_port_link($port, short_ifname($port['ifDescr'])) . '</td>
示例8: dbFetchRows
// Query addresses
$results = dbFetchRows($query, $param);
if (count($results)) {
$found = 1;
foreach ($results as $result) {
$addr_ports[$result['port_id']][] = $result;
}
echo '<li class="nav-header">IPs found: ' . count($results) . ' (on ' . count($addr_ports) . ' ports)</li>';
# foreach ($addr_ports as $port_id => $result)
foreach ($results as $result) {
$port = get_port_by_id_cache($result['port_id']);
$device = device_by_id_cache($port['device_id']);
echo '<li class="divider" style="margin: 0px;"></li>';
echo '<li>';
echo '<a href="' . generate_port_url($port) . '">';
$descr = $device['hostname'] . ' | ' . rewrite_ifname($port['label']);
$name = $result['ipv4_address'] . '/' . $result['ipv4_prefixlen'];
if (strlen($name) > 35) {
$name = substr($name, 0, 35) . "...";
}
/// FIXME: once we have alerting, colour this to the sensor's status
$tab_colour = '#194B7F';
// FIXME: This colour pulled from functions.inc.php humanize_device, maybe set it centrally in definitions?
echo '<dl style="border-left: 10px solid ' . $tab_colour . '; " class="dl-horizontal dl-search">
<dt style="padding-left: 10px; text-align: center;">
<i class="oicon-magnifier-zoom-actual"></i></dt>
<dd><strong>' . highlight_search(htmlentities($name)) . '<br />
<small>' . htmlentities($descr) . '</small></strong></dd>
</dl>';
}
echo "</a></li>";
示例9: generate_url
echo '>';
if ($vars['sort'] == $col['sort']) {
echo $col['head'] . ' *';
} else {
echo '<a href="' . generate_url($vars, array('sort' => $col['sort'])) . '">' . $col['head'] . '</a>';
}
echo "</th>";
}
echo " </tr></thead>";
$ports_disabled = 0;
$ports_down = 0;
$ports_up = 0;
$ports_total = 0;
foreach ($ports as $port) {
$device = device_by_id_cache($port['device_id']);
#&$GLOBALS['cache']['devices']['id'][$port['device_id']];
$ports_total++;
humanize_port($port);
if ($port['in_errors'] > 0 || $port['out_errors'] > 0) {
$error_img = generate_port_link($port, "<img src='images/16/chart_curve_error.png' alt='接口错误' border=0>", errors);
} else {
$error_img = "";
}
$port['bps_in'] = formatRates($port['ifInOctets_rate'] * 8);
$port['bps_out'] = formatRates($port['ifOutOctets_rate'] * 8);
$port['pps_in'] = format_si($port['ifInUcastPkts_rate']) . "pps";
$port['pps_out'] = format_si($port['ifOutUcastPkts_rate']) . "pps";
echo "<tr class='ports " . $port['row_class'] . "'>\n <td style='background-color: " . $port['table_tab_colour'] . ";'></td>\n <td></td>\n <td><span class=entity>" . generate_device_link($device, short_hostname($device['hostname'], "20")) . "</span><br />\n <span class=em>" . truncate($port['location'], 32, "") . "</span></td>\n\n <td><span class=entity>" . generate_port_link($port, rewrite_ifname($port['label'])) . " " . $error_img . "</span><br />\n <span class=em>" . truncate($port['ifAlias'], 50, '') . "</span></td>" . '<td> <i class="icon-circle-arrow-down" style="' . $port['bps_in_style'] . '"></i> <span class="small" style="' . $port['bps_in_style'] . '">' . formatRates($port['in_rate']) . '</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['bps_out_style'] . '"></i> <span class="small" style="' . $port['bps_out_style'] . '">' . formatRates($port['out_rate']) . '</span><br /></td>' . '<td> <i class="icon-circle-arrow-down" style="' . $port['bps_in_style'] . '"></i> <span class="small" style="' . $port['bps_in_style'] . '">' . $port['ifInOctets_perc'] . '%</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['bps_out_style'] . '"></i> <span class="small" style="' . $port['bps_out_style'] . '">' . $port['ifOutOctets_perc'] . '%</span><br /></td>' . '<td><i class="icon-circle-arrow-down" style="' . $port['pps_in_style'] . '"></i> <span class="small" style="' . $port['pps_in_style'] . '">' . format_bi($port['ifInUcastPkts_rate']) . 'pps</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['pps_out_style'] . '"></i> <span class="small" style="' . $port['pps_out_style'] . '">' . format_bi($port['ifOutUcastPkts_rate']) . 'pps</span></td>' . "<td>" . $port['human_speed'] . "<br />" . $port['ifMtu'] . "</td>\n <td >" . $port['human_type'] . "<br />" . $port['human_mac'] . "</td>\n </tr>\n";
}
echo '</td></tr></table>';
echo pagination($vars, count($ports));
示例10: elseif
if ($port_id) {
$vars['id'] = $port_id;
}
} elseif (!empty($vars['ifalias'])) {
// Get port by ifAlias
$port_id = get_port_id_by_ifAlias($device['device_id'], $vars['ifalias']);
if ($port_id) {
$vars['id'] = $port_id;
}
}
} elseif (!empty($vars['circuit'])) {
// Get port by circuit id
$port_id = get_port_id_by_customer(array('circuit' => $vars['circuit']));
if ($port_id) {
$vars['id'] = $port_id;
}
}
}
if (is_numeric($vars['id']) && ($auth || port_permitted($vars['id']))) {
$port = get_port_by_id($vars['id']);
$device = device_by_id_cache($port['device_id']);
$title = generate_device_link($device);
$title .= " :: Port <b>" . generate_port_link($port) . "</b>";
$title_array = array();
$title_array[] = array('text' => $device['hostname'], 'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'])));
$title_array[] = array('text' => 'Ports', 'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'ports')));
$title_array[] = array('text' => rewrite_ifname($port['label']), 'url' => generate_url(array('page' => 'device', 'device' => $device['device_id'], 'tab' => 'port', 'port' => $port['port_id'])));
$graph_title = short_hostname($device['hostname']) . " :: " . strtolower(short_ifname($port['ifDescr'], NULL, FALSE));
$auth = TRUE;
$rrd_filename = get_port_rrdfilename($port, NULL, TRUE);
}
示例11: dbFetchRows
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage search
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
*
*/
/// SEARCH PORTS
$results = dbFetchRows("SELECT * FROM `ports`\n LEFT JOIN `devices` USING (`device_id`)\n WHERE (`ifAlias` LIKE ? OR `ifDescr` LIKE ?) {$query_permitted_port}\n ORDER BY `ifDescr` LIMIT {$query_limit}", array($query_param, $query_param));
if (count($results)) {
foreach ($results as $result) {
humanize_port($result);
$name = rewrite_ifname($result['ifDescr']);
if (strlen($name) > 35) {
$name = substr($name, 0, 35) . "...";
}
$description = $result['ifAlias'];
if (strlen($description) > 80) {
$description = substr($description, 0, 80) . "...";
}
$type = rewrite_iftype($result['ifType']);
if ($description) {
$type .= ' | ';
}
$port_search_results[] = array('url' => generate_port_url($result), 'name' => $name, 'colour' => $result['table_tab_colour'], 'icon' => '<img src="images/icons/' . $result['icon'] . '.png" />', 'data' => array(escape_html($result['hostname']), $type . highlight_search(escape_html($description))));
}
$search_results['ports'] = array('descr' => 'Ports found', 'results' => $port_search_results);
}
示例12: unset
$height = 102;
$height_div = 158;
}
}
$graph_array['height'] = 100;
$graph_array['width'] = 210;
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $port['port_id'];
$graph_array['type'] = $graph_type;
$graph_array['from'] = $config['time']['day'];
$graph_array['legend'] = "no";
$link_array = $graph_array;
$link_array['page'] = "graphs";
unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link = generate_url($link_array);
$overlib_content = generate_overlib_content($graph_array, $port['hostname'] . " - " . rewrite_ifname($port['label']));
$graph_array['title'] = "yes";
$graph_array['width'] = $width;
$graph_array['height'] = $height;
$graph = generate_graph_tag($graph_array);
echo "<div style='display: block; padding: 1px; margin: 2px; min-width: " . $width_div . "px; max-width:" . $width_div . "px; min-height:" . $height_div . "px; max-height:" . $height_div . "; text-align: center; float: left; background-color: #f5f5f5;'>";
echo overlib_link($link, $graph, $overlib_content);
echo "</div>";
# echo("<div style='display: block; padding: 1px; margin: 2px; min-width: 393px; max-width:393px; min-height:180px; max-height:180px; text-align: center; float: left; background-color: #f5f5f5;'>
# <a href='".generate_port_url($port)."/' onmouseover=\"return overlib('\
# <div style=\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\'>".$device['hostname']." - ".$port['ifDescr']."</div>\
# <img src=\'graph.php?type=$graph_type&id=".$port['port_id']."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=450&height=150&title=yes\'>\
# ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >".
# "<img src='graph.php?type=$graph_type&id=".$port['port_id']."&from=".$config['time']['day']."&to=".$config['time']['now']."&width=315&height=110&legend=no&title=yes'>
# </a>
# </div>");
示例13: short_ifname
function short_ifname($if, $len = NULL, $htmlentities = TRUE)
{
$len = is_numeric($len) ? (int) $len : FALSE;
$if = rewrite_ifname($if, $htmlentities);
$if = strtolower($if);
$if = array_str_replace($GLOBALS['rewrite_shortif'], $if);
if ($len) {
$if = truncate($if, $len, '');
}
return $if;
}
示例14: generate_port_row
function generate_port_row($port, $vars = array())
{
global $config, $cache;
$device = device_by_id_cache($port['device_id']);
humanize_port($port);
if (!isset($vars['view'])) {
$vars['view'] = "basic";
}
// Populate $port_adsl if the port has ADSL-MIB data
if (!isset($cache['ports_option']['ports_adsl']) || in_array($port['port_id'], $cache['ports_option']['ports_adsl'])) {
$port_adsl = dbFetchRow("SELECT * FROM `ports_adsl` WHERE `port_id` = ?", array($port['port_id']));
}
// Populate $port['tags'] with various tags to identify port statuses and features
// Port Errors
if ($port['ifInErrors_delta'] > 0 || $port['ifOutErrors_delta'] > 0) {
$port['tags'] .= generate_port_link($port, '<span class="label label-important">Errors</span>', 'port_errors');
}
// Port Deleted
if ($port['deleted'] == '1') {
$port['tags'] .= '<a href="' . generate_url(array('page' => 'deleted-ports')) . '"><span class="label label-important">Deleted</span></a>';
}
// Port CBQoS
if (isset($cache['ports_option']['ports_cbqos'])) {
if (in_array($port['port_id'], $cache['ports_option']['ports_cbqos'])) {
$port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'cbqos')) . '"><span class="label label-info">CBQoS</span></a>';
}
} else {
if (dbFetchCell("SELECT COUNT(*) FROM `ports_cbqos` WHERE `port_id` = ?", array($port['port_id']))) {
$port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'cbqos')) . '"><span class="label label-info">CBQoS</span></a>';
}
}
// Port MAC Accounting
if (isset($cache['ports_option']['mac_accounting'])) {
if (in_array($port['port_id'], $cache['ports_option']['mac_accounting'])) {
$port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'macaccounting')) . '"><span class="label label-info">MAC</span></a>';
}
} else {
if (dbFetchCell("SELECT COUNT(*) FROM `mac_accounting` WHERE `port_id` = ?", array($port['port_id']))) {
$port['tags'] .= '<a href="' . generate_port_url($port, array('view' => 'macaccounting')) . '"><span class="label label-info">MAC</span></a>';
}
}
// Populated formatted versions of port rates.
$port['bps_in'] = formatRates($port['ifInOctets_rate'] * 8);
$port['bps_out'] = formatRates($port['ifOutOctets_rate'] * 8);
$port['pps_in'] = format_si($port['ifInUcastPkts_rate']) . "pps";
$port['pps_out'] = format_si($port['ifOutUcastPkts_rate']) . "pps";
$string = '';
if ($vars['view'] == "basic" || $vars['view'] == "graphs") {
$table_cols = '8';
$string .= '<tr class="' . $port['row_class'] . '">
<td class="state-marker"></td>
<td style="width: 1px;"></td>';
if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
$table_cols++;
// Increment table columns by one to make sure graph line draws correctly
$string .= ' <td style="width: 200px;"><span class="entity">' . generate_device_link($device, short_hostname($device['hostname'], "20")) . '</span><br />
<span class="em">' . escape_html(truncate($port['location'], 32, "")) . '</span></td>';
}
$string .= ' <td><span class="entity">' . generate_port_link($port, rewrite_ifname($port['port_label'])) . ' ' . $port['tags'] . '</span><br />
<span class="em">' . escape_html(truncate($port['ifAlias'], 50, '')) . '</span></td>' . '<td style="width: 110px;"> <i class="icon-circle-arrow-down" style="' . $port['bps_in_style'] . '"></i> <span class="small" style="' . $port['bps_in_style'] . '">' . formatRates($port['in_rate']) . '</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['bps_out_style'] . '"></i> <span class="small" style="' . $port['bps_out_style'] . '">' . formatRates($port['out_rate']) . '</span><br /></td>' . '<td style="width: 90px;"> <i class="icon-circle-arrow-down" style="' . $port['bps_in_style'] . '"></i> <span class="small" style="' . $port['bps_in_style'] . '">' . $port['ifInOctets_perc'] . '%</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['bps_out_style'] . '"></i> <span class="small" style="' . $port['bps_out_style'] . '">' . $port['ifOutOctets_perc'] . '%</span><br /></td>' . '<td style="width: 110px;"><i class="icon-circle-arrow-down" style="' . $port['pps_in_style'] . '"></i> <span class="small" style="' . $port['pps_in_style'] . '">' . format_bi($port['ifInUcastPkts_rate']) . 'pps</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['pps_out_style'] . '"></i> <span class="small" style="' . $port['pps_out_style'] . '">' . format_bi($port['ifOutUcastPkts_rate']) . 'pps</span></td>' . '<td style="width: 110px;"><small>' . $port['human_speed'] . '<br />' . $port['ifMtu'] . '</small></td>
<td ><small>' . $port['human_type'] . '<br />' . $port['human_mac'] . '</small></td>
</tr>';
} else {
if ($vars['view'] == "details" || $vars['view'] == "detail") {
$table_cols = '9';
$string .= '<tr class="' . $port['row_class'] . '"';
if ($vars['tab'] != "port") {
$string .= ' onclick="openLink(\'' . generate_port_url($port) . '\')" style="cursor: pointer;"';
}
$string .= '>';
$string .= ' <td class="state-marker"></td>
<td style="width: 1px;"></td>';
if ($vars['page'] != "device" && $vars['popup'] != TRUE) {
$table_cols++;
// Increment table columns by one to make sure graph line draws correctly
$string .= ' <td width="200"><span class="entity">' . generate_device_link($device, short_hostname($device['hostname'], "20")) . '</span><br />
<span class="em">' . escape_html(truncate($port['location'], 32, "")) . '</span></td>';
}
$string .= '
<td style="min-width: 250px;">';
$string .= ' <span class="entity-title">
' . generate_port_link($port) . ' ' . $port['tags'] . '
</span><br /><span class="small">' . escape_html($port['ifAlias']) . '</span>';
if ($port['ifAlias']) {
$string .= '<br />';
}
unset($break);
if (!isset($cache['ports_option']['ipv4_addresses']) || in_array($port['port_id'], $cache['ports_option']['ipv4_addresses'])) {
foreach (dbFetchRows("SELECT * FROM `ipv4_addresses` WHERE `port_id` = ?", array($port['port_id'])) as $ip) {
$string .= $break . generate_popup_link('ip', $ip['ipv4_address'] . '/' . $ip['ipv4_prefixlen'], NULL, 'small');
$break = "<br />";
}
}
if (!isset($cache['ports_option']['ipv6_addresses']) || in_array($port['port_id'], $cache['ports_option']['ipv6_addresses'])) {
foreach (dbFetchRows("SELECT * FROM `ipv6_addresses` WHERE `port_id` = ?", array($port['port_id'])) as $ip6) {
$string .= $break . generate_popup_link('ip', $ip6['ipv6_address'] . '/' . $ip6['ipv6_prefixlen'], NULL, 'small');
$break = "<br />";
}
}
//$string .= '</span>';
//.........这里部分代码省略.........
示例15: generate_port_link
function generate_port_link($port, $text = NULL, $type = NULL, $escape = FALSE)
{
global $config;
humanize_port($port);
//if (!isset($port['html_class'])) { $port['html_class'] = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); }
//if (!isset($text)) { $text = rewrite_ifname($port['label'], !$escape); } // Negative escape flag for exclude double escape
// Fixme -- does this function even need alternative $text? I think not. It's a hangover from before label.
if (!isset($text)) {
$text = $port['label'];
}
if (port_permitted($port['port_id'], $port['device_id'])) {
$url = generate_port_url($port);
if ($escape) {
$text = escape_html($text);
}
return '<a href="' . $url . '" class="entity-popup ' . $port['html_class'] . '" data-eid="' . $port['port_id'] . '" data-etype="port">' . $text . '</a>';
} else {
return rewrite_ifname($text);
}
}