当前位置: 首页>>代码示例>>PHP>>正文


PHP formatMac函数代码示例

本文整理汇总了PHP中formatMac函数的典型用法代码示例。如果您正苦于以下问题:PHP formatMac函数的具体用法?PHP formatMac怎么用?PHP formatMac使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了formatMac函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate_port_link

    if (!$ignore) {
        if ($entry['ifInErrors'] > 0 || $entry['ifOutErrors'] > 0) {
            $error_img = generate_port_link($entry, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", port_errors);
        } else {
            $error_img = '';
        }
        $arp_host = dbFetchRow('SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id', array($entry['ipv4_address']));
        if ($arp_host) {
            $arp_name = generate_device_link($arp_host);
        } else {
            unset($arp_name);
        }
        if ($arp_host) {
            $arp_if = generate_port_link($arp_host);
        } else {
            unset($arp_if);
        }
        if ($arp_host['device_id'] == $entry['device_id']) {
            $arp_name = 'Localhost';
        }
        if ($arp_host['port_id'] == $entry['port_id']) {
            $arp_if = 'Local port';
        }
        $response[] = array('mac_address' => formatMac($entry['mac_address']), 'ipv4_address' => $entry['ipv4_address'], 'hostname' => generate_device_link($entry), 'interface' => generate_port_link($entry, makeshortif(fixifname(ifLabel($entry['label'])))) . ' ' . $error_img, 'remote_device' => $arp_name, 'remote_interface' => $arp_if);
    }
    //end if
    unset($ignore);
}
//end foreach
$output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total);
echo _json_encode($output);
开发者ID:greggcz,项目名称:librenms,代码行数:31,代码来源:arp-search.inc.php

示例2: foreach

             $tbl->setHeaders(array('Port name', 'Status', 'IPv4 Address', 'Speed In', 'Speed Out', 'Packets In', 'Packets Out', 'Speed', 'Duplex', 'Type', 'MAC Address', 'MTU'));
             foreach (dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ?', array($options['d'])) as $port) {
                 if ($port['ifOperStatus'] == 'up') {
                     $port['in_rate'] = $port['ifInOctets_rate'] * 8;
                     $port['out_rate'] = $port['ifOutOctets_rate'] * 8;
                     $in_perc = @round($port['in_rate'] / $port['ifSpeed'] * 100);
                     $out_perc = @round($port['in_rate'] / $port['ifSpeed'] * 100);
                 }
                 if ($port['ifSpeed']) {
                     $port_speed = humanspeed($port['ifSpeed']);
                 }
                 if ($port[ifDuplex] != 'unknown') {
                     $port_duplex = $port['ifDuplex'];
                 }
                 if ($port['ifPhysAddress'] && $port['ifPhysAddress'] != '') {
                     $port_mac = formatMac($port['ifPhysAddress']);
                 }
                 if ($port['ifMtu'] && $port['ifMtu'] != '') {
                     $port_mtu = $port['ifMtu'];
                 }
                 $tbl->addRow(array($port['ifDescr'], $port['ifOperStatus'], '', formatRates($port['in_rate']), formatRates($port['out_rate']), format_bi($port['ifInUcastPkts_rate']) . 'pps', format_bi($port['ifOutUcastPkts_rate']) . 'pps', $port_speed, $port_duplex, '', $port_mac, $port_mtu));
             }
             //end foreach
             echo $tbl->getTable();
         } else {
             echo $options['list'];
             echo "Usage of console-ui.php:\n\n            -l      What log type we want to see:\n            eventlog = Event log messages\n            syslog = Syslog messages\n\n            -d      Specify the device id to filter results\n\n            --list   What to list\n            devices = list devices and device id's\n\n            --device-stats      Lists the port statistics for a given device\n\n            Examples:\n            #1 php console-ui.php -l eventlog -d 1\n            #2 php console-ui.php --list=devices\n\n            ";
             exit;
         }
     }
 }
开发者ID:rasssta,项目名称:librenms,代码行数:31,代码来源:console-ui.php

示例3: print_arptable


//.........这里部分代码省略.........
                    break;
                case 'address':
                    if (isset($vars['searchby']) && $vars['searchby'] == 'ip') {
                        $where .= ' AND `ip_address` LIKE ?';
                        $value = trim($value);
                        ///FIXME. Need another conversion ("2001:b08:b08" -> "2001:0b08:0b08") -- mike
                        if (Net_IPv6::checkIPv6($value)) {
                            $value = Net_IPv6::uncompress($value, true);
                        }
                        $param[] = '%' . $value . '%';
                    } else {
                        $where .= ' AND `mac_address` LIKE ?';
                        $param[] = '%' . str_replace(array(':', ' ', '-', '.', '0x'), '', mres($value)) . '%';
                    }
                    break;
            }
        }
    }
    // Show ARP tables only for permitted ports
    $query_permitted = generate_query_permitted(array('port'), array('port_table' => 'I'));
    $query = 'FROM `ip_mac` AS M ';
    $query .= 'LEFT JOIN `ports` AS I ON I.`port_id` = M.`port_id` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(`mac_id`) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY M.`mac_address`';
    $query .= " LIMIT {$start},{$pagesize}";
    // Query ARP/NDP table addresses
    $entries = dbFetchRows($query, $param);
    // Query ARP/NDP table address count
    if ($pagination) {
        $count = dbFetchCell($query_count, $param);
    }
    $list = array('device' => FALSE, 'port' => FALSE);
    if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'search') {
        $list['device'] = TRUE;
    }
    if (!isset($vars['port']) || empty($vars['port']) || $vars['page'] == 'search') {
        $list['port'] = TRUE;
    }
    $string = '<table class="table table-bordered table-striped table-hover table-condensed">' . PHP_EOL;
    if (!$short) {
        $string .= '  <thead>' . PHP_EOL;
        $string .= '    <tr>' . PHP_EOL;
        $string .= '      <th>MAC Address</th>' . PHP_EOL;
        $string .= '      <th>IP Address</th>' . PHP_EOL;
        if ($list['device']) {
            $string .= '      <th>Device</th>' . PHP_EOL;
        }
        if ($list['port']) {
            $string .= '      <th>Interface</th>' . PHP_EOL;
        }
        $string .= '      <th>Remote Device</th>' . PHP_EOL;
        $string .= '      <th>Remote Interface</th>' . PHP_EOL;
        $string .= '    </tr>' . PHP_EOL;
        $string .= '  </thead>' . PHP_EOL;
    }
    $string .= '  <tbody>' . PHP_EOL;
    foreach ($entries as $entry) {
        humanize_port($entry);
        $ip_version = $entry['ip_version'];
        $ip_address = $ip_version == 6 ? Net_IPv6::compress($entry['ip_address']) : $entry['ip_address'];
        $arp_host = dbFetchRow('SELECT * FROM `ipv' . $ip_version . '_addresses` AS A
                           LEFT JOIN `ports` AS I ON A.`port_id` = I.`port_id`
                           LEFT JOIN `devices` AS D ON D.`device_id` = I.`device_id`
                           WHERE A.`ipv' . $ip_version . '_address` = ?', array($ip_address));
        $arp_name = $arp_host ? generate_device_link($arp_host) : '';
        $arp_if = $arp_host ? generate_port_link($arp_host) : '';
        if ($arp_host['device_id'] == $entry['device_id']) {
            $arp_name = 'Self Device';
        }
        if ($arp_host['port_id'] == $entry['port_id']) {
            $arp_if = 'Self Port';
        }
        $string .= '  <tr>' . PHP_EOL;
        $string .= '    <td width="160">' . formatMac($entry['mac_address']) . '</td>' . PHP_EOL;
        $string .= '    <td width="140">' . $ip_address . '</td>' . PHP_EOL;
        if ($list['device']) {
            $dev = device_by_id_cache($entry['device_id']);
            $string .= '    <td class="entity" nowrap>' . generate_device_link($dev) . '</td>' . PHP_EOL;
        }
        if ($list['port']) {
            if ($entry['ifInErrors_delta'] > 0 || $entry['ifOutErrors_delta'] > 0) {
                $port_error = generate_port_link($entry, '<span class="label label-important">Errors</span>', 'port_errors');
            }
            $string .= '    <td class="entity">' . generate_port_link($entry, short_ifname($entry['label'])) . ' ' . $port_error . '</td>' . PHP_EOL;
        }
        $string .= '    <td class="entity" width="200">' . $arp_name . '</td>' . PHP_EOL;
        $string .= '    <td class="entity">' . $arp_if . '</td>' . PHP_EOL;
        $string .= '  </tr>' . PHP_EOL;
    }
    $string .= '  </tbody>' . PHP_EOL;
    $string .= '</table>';
    // Print pagination header
    if ($pagination) {
        $string = pagination($vars, $count) . $string . pagination($vars, $count);
    }
    // Print ARP/NDP table
    echo $string;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:arptable.inc.php

示例4: foreach

if (isset($current)) {
    $limit_low = $current * $rowCount - $rowCount;
    $limit_high = $rowCount;
}
if ($rowCount != -1) {
    $sql .= " LIMIT {$limit_low},{$limit_high}";
}
$sql = "SELECT *,`I`.`ifDescr` AS `interface` {$sql}";
foreach (dbFetchRows($sql, $param) as $interface) {
    $speed = humanspeed($interface['ifSpeed']);
    $type = humanmedia($interface['ifType']);
    if ($_POST['search_type'] == 'ipv6') {
        list($prefix, $length) = explode("/", $interface['ipv6_network']);
        $address = Net_IPv6::compress($interface['ipv6_address']) . '/' . $length;
    } elseif ($_POST['search_type'] == 'mac') {
        $address = formatMac($interface['ifPhysAddress']);
    } else {
        list($prefix, $length) = explode("/", $interface['ipv4_network']);
        $address = $interface['ipv4_address'] . '/' . $length;
    }
    if ($interface['in_errors'] > 0 || $interface['out_errors'] > 0) {
        $error_img = generate_port_link($interface, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", errors);
    } else {
        $error_img = "";
    }
    if (port_permitted($interface['port_id'])) {
        $interface = ifLabel($interface, $interface);
        $response[] = array('hostname' => generate_device_link($interface), 'interface' => generate_port_link($interface) . ' ' . $error_img, 'address' => $address, 'description' => $interface['ifAlias']);
    }
}
$output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total);
开发者ID:job,项目名称:librenms,代码行数:31,代码来源:address-search.inc.php

示例5: safename

        echo "</pre>";
    }
    if (is_array($ma)) {
        if ($auth || port_permitted($ma['port_id'])) {
            $rrd_filename = $config['rrd_dir'] . "/" . $ma['hostname'] . "/" . safename("mac_acc-" . $ma['ifIndex'] . "-" . $ma['vlan_id'] . "-" . $ma['mac'] . ".rrd");
            if ($debug) {
                echo $rrd_filename;
            }
            if (is_file($rrd_filename)) {
                if ($debug) {
                    echo "exists";
                }
                $port = get_port_by_id($ma['port_id']);
                $device = device_by_id_cache($port['device_id']);
                $title = generate_device_link($device);
                $title .= " :: Port  " . generate_port_link($port);
                $title .= " :: Mac Accounting";
                $title .= " :: " . formatMac($ma['mac']);
                $auth = TRUE;
            } else {
                #     graph_error("file not found");
            }
        } else {
            #    graph_error("unauthenticated");
        }
    } else {
        #   graph_error("entry not found");
    }
} else {
    #  graph_error("invalid id");
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:auth.inc.php

示例6: unset

        } else {
            unset($arp_name);
        }
        if ($arp_host) {
            $arp_if = generate_port_link($arp_host);
        } else {
            unset($arp_if);
        }
        if ($arp_host['device_id'] == $entry['device_id']) {
            $arp_name = "Localhost";
        }
        if ($arp_host['port_id'] == $entry['port_id']) {
            $arp_if = "Local port";
        }
        echo '<tr>
        <td>' . formatMac($entry['mac_address']) . '</td>
        <td>' . $entry['ipv4_address'] . '</td>
            <td>' . generate_device_link($entry) . '</td>
        <td>' . generate_port_link($entry, makeshortif(fixifname($entry['ifDescr']))) . ' ' . $error_img . '</td>
            <td>' . $arp_name . '</td>
        <td>' . $arp_if . '</td>
            </tr>';
    }
    unset($ignore);
}
if ($count % $results > 0) {
    echo '    <tr>
         <td colspan="6" align="center">' . generate_pagination($count, $results, $page_number) . '</td>
     </tr>';
}
echo '</table>
开发者ID:CumulusNetworks,项目名称:cldemo-archive,代码行数:31,代码来源:arp.inc.php

示例7: generate_port_url

} else {
    echo "</td><td width=150 onclick=\"location.href='" . generate_port_url($port) . "'\" >";
    if ($port['ifType'] && $port['ifType'] != '') {
        echo '<span class=box-desc>' . fixiftype($port['ifType']) . '</span>';
    } else {
        echo '-';
    }
    echo '<br />';
    if ($ifHardType && $ifHardType != '') {
        echo '<span class=box-desc>' . $ifHardType . '</span>';
    } else {
        echo '-';
    }
    echo "</td><td width=150 onclick=\"location.href='" . generate_port_url($port) . "'\" >";
    if ($port['ifPhysAddress'] && $port['ifPhysAddress'] != '') {
        echo '<span class=box-desc>' . formatMac($port['ifPhysAddress']) . '</span>';
    } else {
        echo '-';
    }
    echo '<br />';
    if ($port['ifMtu'] && $port['ifMtu'] != '') {
        echo '<span class=box-desc>MTU ' . $port['ifMtu'] . '</span>';
    } else {
        echo '-';
    }
}
//end if
echo '</td>';
echo '<td width=375 valign=top class="interface-desc">';
$neighborsCount = 0;
$nbLinks = 0;
开发者ID:Tatermen,项目名称:librenms,代码行数:31,代码来源:print-interface.inc.php

示例8: print_fdbtable


//.........这里部分代码省略.........
                case 'port':
                case 'port_id':
                    $where .= ' AND I.`port_id` = ?';
                    $param[] = $value;
                    break;
                case 'interface':
                    $where .= ' AND I.`ifDescr` LIKE ?';
                    $param[] = $value;
                    break;
                case 'vlan_id':
                    if (!is_array($value)) {
                        $value = array($value);
                    }
                    foreach ($value as $v) {
                        $cond[] = '?';
                        $param[] = $v;
                    }
                    $where .= " AND F.`vlan_id` IN (";
                    $where .= implode(', ', $cond);
                    $where .= ')';
                    break;
                case 'vlan_name':
                    if (!is_array($value)) {
                        $value = array($value);
                    }
                    foreach ($value as $v) {
                        $cond[] = '?';
                        $param[] = $v;
                    }
                    $where .= " AND V.`vlan_name` IN (";
                    $where .= implode(', ', $cond);
                    $where .= ')';
                    break;
                case 'address':
                    $where .= ' AND F.`mac_address` LIKE ?';
                    $param[] = '%' . str_replace(array(':', ' ', '-', '.', '0x'), '', mres($value)) . '%';
                    break;
            }
        }
    }
    // Show FDB tables only for permitted ports
    $query_permitted = generate_query_permitted(array('port'), array('port_table' => 'I'));
    $query = 'FROM `vlans_fdb` AS F ';
    $query .= 'LEFT JOIN `vlans` as V ON V.`vlan_vlan` = F.`vlan_id` AND V.`device_id` = F.`device_id` ';
    $query .= 'LEFT JOIN `ports` AS I ON I.`port_id` = F.`port_id` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(*) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY F.`mac_address`';
    $query .= " LIMIT {$start},{$pagesize}";
    // Query addresses
    $entries = dbFetchRows($query, $param);
    // Query address count
    if ($pagination) {
        $count = dbFetchCell($query_count, $param);
    }
    $list = array('device' => FALSE);
    if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'search') {
        $list['device'] = TRUE;
    }
    $string = '<table class="table table-bordered table-striped table-hover table-condensed">' . PHP_EOL;
    if (!$short) {
        $string .= '  <thead>' . PHP_EOL;
        $string .= '    <tr>' . PHP_EOL;
        $string .= '      <th>MAC Address</th>' . PHP_EOL;
        if ($list['device']) {
            $string .= '      <th>Device</th>' . PHP_EOL;
        }
        $string .= '      <th>Interface</th>' . PHP_EOL;
        $string .= '      <th>VLAN ID</th>' . PHP_EOL;
        $string .= '      <th>VLAN Name</th>' . PHP_EOL;
        $string .= '    </tr>' . PHP_EOL;
        $string .= '  </thead>' . PHP_EOL;
    }
    $string .= '  <tbody>' . PHP_EOL;
    foreach ($entries as $entry) {
        humanize_port($entry);
        $string .= '  <tr>' . PHP_EOL;
        $string .= '    <td width="160">' . formatMac($entry['mac_address']) . '</td>' . PHP_EOL;
        if ($list['device']) {
            $dev = device_by_id_cache($entry['device_id']);
            $string .= '    <td class="entity" nowrap>' . generate_device_link($dev) . '</td>' . PHP_EOL;
        }
        if ($entry['ifInErrors_delta'] > 0 || $entry['ifOutErrors_delta'] > 0) {
            $port_error = generate_port_link($entry, '<span class="label label-important">Errors</span>', 'port_errors');
        }
        $string .= '    <td class="entity">' . generate_port_link($entry, short_ifname($entry['label'])) . ' ' . $port_error . '</td>' . PHP_EOL;
        $string .= '    <td>Vlan' . $entry['vlan_vlan'] . '</td>' . PHP_EOL;
        $string .= '    <td>' . $entry['vlan_name'] . '</td>' . PHP_EOL;
        $string .= '  </tr>' . PHP_EOL;
    }
    $string .= '  </tbody>' . PHP_EOL;
    $string .= '</table>';
    // Print pagination header
    if ($pagination) {
        $string = pagination($vars, $count) . $string . pagination($vars, $count);
    }
    // Print FDB table
    echo $string;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:fdbtable.inc.php

示例9: displaySetupPage

function displaySetupPage($mac, &$s20Table, $myUrl)
{
    global $daysOfWeek;
    $devData = $s20Table[$mac];
    $timerName = $devData['name'];
    ?>

<div style="text-align:center">
<h2> 
<form action="<?php 
    echo $myUrl;
    ?>
" method="post">
<?php 
    if (array_key_exists('off', $s20Table[$mac])) {
        echo $timerName;
        $isActive = 0;
    } else {
        $isActive = 1;
        ?>

        <input type = "text" name="newName" value="<?php 
        echo $timerName;
        ?>
" id="inputName">
<?php 
    }
    if (isset($devData['st']) && $devData['st'] >= 0 && !array_key_exists('off', $s20Table[$mac])) {
        $stDisplay = $devData['st'] ? "greenCircle100px.png" : "redCircle100px.png";
        echo '<img src="' . IMG_PATH . $stDisplay . '" style="width:0.8em;position:relative;top:0.1em;left:0.3em;">';
    }
    $nnext = $devData['next'];
    if ($isActive) {
        echo '<br><div id="mayEdit">Socket name above is editable</div>';
    }
    ?>
 
</h2>
<p>
<hr>





    <input type="submit" name="toMainPage" value="back<?php 
    echo $mac;
    ?>
"  
    id="backButton"> 

<?php 
    if ($isActive) {
        ?>

<div>
        Number of next events displayed in main page for this timer: 
<select name="numberOfNextEvents">        
<?php 
        for ($i = 0; $i < 8; $i++) {
            echo '<option value="' . $i . '"' . ($nnext == $i ? ' selected="selected"' : ' ') . '>' . $i . '</option>' . "\n";
        }
        ?>
</select>

<p>
<hr>
<?php 
        $ip = getIpFromMac($mac, $s20Table);
        $dev = $s20Table[$mac];
        $time = $dev['time'];
        $serverTime = $dev['serverTime'];
        $tz = $dev['timeZone'];
        $serverTzS = date_default_timezone_get();
        $serverTz = timezone_open($serverTzS);
        $serverTzOffset = $serverTz->getOffset(new DateTime());
        echo '<div id="socketTime"></div>';
        echo '<div id="serverTime"></div>';
        echo "<hr>";
        ?>
S20 mac address - 
<?php 
        echo formatMac($mac);
        ?>
<hr>
<script>
var socketTimeRef = <?php 
        echo $time;
        ?>
;
var serverTimeRef = <?php 
        echo $serverTime;
        ?>
;
var socketTz  = <?php 
        echo $tz;
        ?>
;
var serverTz  = <?php 
        echo $serverTzOffset;
//.........这里部分代码省略.........
开发者ID:intfrr,项目名称:orvfms,代码行数:101,代码来源:setup_page.php

示例10: foreach

    $query .= " AND P.device_id = ?";
    $param[] = $_POST['device_id'];
}
if ($_POST['interface']) {
    $query .= " AND P.ifDescr LIKE ?";
    $param[] = $_POST['interface'];
}
$query .= " ORDER BY P.ifPhysAddress";
echo '<tr><th>Device</a></th><th>Interface</th><th>MAC Address</th><th>Description</th></tr>';
foreach (dbFetchRows($query, $param) as $entry) {
    if (!$ignore) {
        $speed = humanspeed($entry['ifSpeed']);
        $type = humanmedia($entry['ifType']);
        if ($entry['in_errors'] > 0 || $entry['out_errors'] > 0) {
            $error_img = generate_port_link($entry, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", errors);
        } else {
            $error_img = "";
        }
        if (port_permitted($entry['port_id'])) {
            $interface = ifLabel($interface, $interface);
            echo '<tr>
          <td>' . generate_device_link($entry) . '</td>
          <td>' . generate_port_link($entry, makeshortif(fixifname($entry['ifDescr']))) . ' ' . $error_img . '</td>
          <td>' . formatMac($entry['ifPhysAddress']) . '</td>
          <td>' . $entry['ifAlias'] . "</td>\n        </tr>\n";
        }
    }
    unset($ignore);
}
echo "</table>";
echo '</div>';
开发者ID:CumulusNetworks,项目名称:cldemo-archive,代码行数:31,代码来源:mac.inc.php

示例11: generate_port_link

            $error_img = generate_port_link($entry, "<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>", errors);
        } else {
            $error_img = "";
        }
        $arp_host = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($entry['ipv4_address']));
        if ($arp_host) {
            $arp_name = generate_device_link($arp_host);
        } else {
            unset($arp_name);
        }
        if ($arp_host) {
            $arp_if = generate_port_link($arp_host);
        } else {
            unset($arp_if);
        }
        if ($arp_host['device_id'] == $entry['device_id']) {
            $arp_name = "Localhost";
        }
        if ($arp_host['port_id'] == $entry['port_id']) {
            $arp_if = "Local port";
        }
        echo '<tr>
        <td width="160">' . formatMac($entry['mac_address']) . '</td>
        <td width="200" class="entity">' . generate_device_link($entry) . '</td>
        <td class="entity">' . generate_port_link($entry, makeshortif(fixifname($entry['ifDescr']))) . ' ' . $error_img . '</td>
        <td class="entity">VLAN' . $entry['vlan_vlan'] . '</td>
        <td class="entity">' . $entry['vlan_name'] . '</td>
            </tr>';
    }
}
echo "</table>";
开发者ID:RomanBogachev,项目名称:observium,代码行数:31,代码来源:fdb.inc.php

示例12: print_mac_addresses

/**
 * Display Interface MACs addresses.
 *
 * Display pages with MAC addresses from device Interfaces.
 *
 * @param array $vars
 * @return none
 *
 */
function print_mac_addresses($vars)
{
    // With pagination? (display page numbers in header)
    $pagination = isset($vars['pagination']) && $vars['pagination'];
    $pageno = isset($vars['pageno']) && !empty($vars['pageno']) ? $vars['pageno'] : 1;
    $pagesize = isset($vars['pagesize']) && !empty($vars['pagesize']) ? $vars['pagesize'] : 10;
    $start = $pagesize * $pageno - $pagesize;
    $param = array();
    $where = ' WHERE 1 ';
    foreach ($vars as $var => $value) {
        if ($value != '') {
            switch ($var) {
                case 'device':
                case 'device_id':
                    $where .= ' AND `device_id` = ?';
                    $param[] = $value;
                    break;
                case 'interface':
                    $where .= ' AND `ifDescr` LIKE ?';
                    $param[] = $value;
                    break;
                case 'address':
                    $where .= ' AND `ifPhysAddress` LIKE ?';
                    $param[] = '%' . str_replace(array(':', ' ', '-', '.', '0x'), '', mres($value)) . '%';
                    break;
            }
        }
    }
    $where .= ' AND `ifPhysAddress` IS NOT NULL';
    //Exclude empty MACs
    // Show MACs only for permitted ports
    $query_permitted = generate_query_permitted(array('port'));
    $query = 'FROM `ports` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(*) ' . $query;
    $query = 'SELECT * ' . $query;
    $query .= ' ORDER BY `ifPhysAddress`';
    $query .= " LIMIT {$start},{$pagesize}";
    // Query addresses
    $entries = dbFetchRows($query, $param);
    // Query address count
    if ($pagination) {
        $count = dbFetchCell($query_count, $param);
    }
    $list = array('device' => FALSE);
    if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'search') {
        $list['device'] = TRUE;
    }
    $string = '<table class="table table-bordered table-striped table-hover table-condensed">' . PHP_EOL;
    if (!$short) {
        $string .= '  <thead>' . PHP_EOL;
        $string .= '    <tr>' . PHP_EOL;
        if ($list['device']) {
            $string .= '      <th>Device</th>' . PHP_EOL;
        }
        $string .= '      <th>Interface</th>' . PHP_EOL;
        $string .= '      <th>MAC Address</th>' . PHP_EOL;
        $string .= '      <th>Description</th>' . PHP_EOL;
        $string .= '    </tr>' . PHP_EOL;
        $string .= '  </thead>' . PHP_EOL;
    }
    $string .= '  <tbody>' . PHP_EOL;
    foreach ($entries as $entry) {
        if (port_permitted($entry['port_id'])) {
            humanize_port($entry);
            $string .= '  <tr>' . PHP_EOL;
            if ($list['device']) {
                $dev = device_by_id_cache($entry['device_id']);
                $string .= '    <td class="entity" nowrap>' . generate_device_link($dev) . '</td>' . PHP_EOL;
            }
            if ($entry['ifInErrors_delta'] > 0 || $entry['ifOutErrors_delta'] > 0) {
                $port_error = generate_port_link($entry, '<span class="label label-important">Errors</span>', 'port_errors');
            }
            $string .= '    <td class="entity">' . generate_port_link($entry, short_ifname($entry['label'])) . ' ' . $port_error . '</td>' . PHP_EOL;
            $string .= '    <td width="160">' . formatMac($entry['ifPhysAddress']) . '</td>' . PHP_EOL;
            $string .= '    <td>' . $entry['ifAlias'] . '</td>' . PHP_EOL;
            $string .= '  </tr>' . PHP_EOL;
        }
    }
    $string .= '  </tbody>' . PHP_EOL;
    $string .= '</table>';
    // Print pagination header
    if ($pagination) {
        $string = pagination($vars, $count) . $string . pagination($vars, $count);
    }
    // Print MAC addresses
    echo $string;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:97,代码来源:mac_addresses.inc.php

示例13: dbFetchRow

if (is_numeric($vars['id'])) {
    $acc = dbFetchRow('SELECT * FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.ma_id = ? AND I.port_id = M.port_id AND I.device_id = D.device_id', array($vars['id']));
    if ($debug) {
        echo '<pre>';
        print_r($acc);
        echo '</pre>';
    }
    if (is_array($acc)) {
        if ($auth || port_permitted($acc['port_id'])) {
            d_echo($config['rrd_dir'] . '/' . $acc['hostname'] . '/' . safename('cip-' . $acc['ifIndex'] . '-' . $acc['mac'] . '.rrd'));
            if (is_file($config['rrd_dir'] . '/' . $acc['hostname'] . '/' . safename('cip-' . $acc['ifIndex'] . '-' . $acc['mac'] . '.rrd'))) {
                d_echo('exists');
                $rrd_filename = $config['rrd_dir'] . '/' . $acc['hostname'] . '/' . safename('cip-' . $acc['ifIndex'] . '-' . $acc['mac'] . '.rrd');
                $port = get_port_by_id($acc['port_id']);
                $device = device_by_id_cache($port['device_id']);
                $title = generate_device_link($device);
                $title .= ' :: Port  ' . generate_port_link($port);
                $title .= ' :: ' . formatMac($acc['mac']);
                $auth = true;
            } else {
                graph_error('file not found');
            }
        } else {
            graph_error('unauthenticated');
        }
    } else {
        graph_error('entry not found');
    }
} else {
    graph_error('invalid id');
}
开发者ID:samyscoub,项目名称:librenms,代码行数:31,代码来源:auth.inc.php

示例14: humanize_port

/**
 * Humanize port.
 *
 * Returns a the $port array with processed information:
 * label, humans_speed, human_type, html_class and human_mac
 * row_class, table_tab_colour
 *
 * @param array $ports
 * @return array $ports
 *
 */
function humanize_port(&$port)
{
    global $config, $cache;
    // Exit if already humanized
    if ($port['humanized']) {
        return;
    }
    // Process port data to make it pretty for printing. EVOLUTION, BITCHES.
    // Lots of hacky shit will end up here with if (os);
    $device =& $GLOBALS['cache']['devices']['id'][$port['device_id']];
    $os = $device['os'];
    $port['human_speed'] = humanspeed($port['ifSpeed']);
    $port['human_type'] = rewrite_iftype($port['ifType']);
    $port['html_class'] = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
    $port['human_mac'] = formatMac($port['ifPhysAddress']);
    if (isset($config['os'][$os]['ifname'])) {
        $port['label'] = $port['ifName'];
        if ($port['ifName'] == "") {
            $port['label'] = $port['ifDescr'];
        } else {
            $port['label'] = $port['ifName'];
        }
    } elseif (isset($config['os'][$os]['ifalias'])) {
        $port['label'] = $port['ifAlias'];
    } else {
        $port['label'] = $port['ifDescr'];
        if (isset($config['os'][$os]['ifindex'])) {
            $port['label'] = $port['label'] . " " . $port['ifIndex'];
        }
    }
    // Set entity variables for use by code which uses entities
    $port['entity_name'] = $port['label'];
    $port['entity_shortname'] = $port['label'];
    $port['entity_descr'] = $port['ifAlias'];
    if ($device['os'] == "speedtouch") {
        list($port['label']) = explode("thomson", $port['label']);
    }
    $port['table_tab_colour'] = "#aaaaaa";
    $port['row_class'] = "";
    // Default
    $port['admin_status'] = $port['ifAdminStatus'];
    if ($port['ifAdminStatus'] == "down") {
        $port['admin_status'] = 'disabled';
        $port['icon'] = 'port-disabled';
    } elseif ($port['ifAdminStatus'] == "up") {
        $port['admin_status'] = 'enabled';
        switch ($port['ifOperStatus']) {
            case 'down':
                $port['table_tab_colour'] = "#cc0000";
                $port['row_class'] = "error";
                $port['icon'] = 'port-down';
                break;
            case 'monitoring':
                // This is monitoring ([e|r]span) ports
                $port['table_tab_colour'] = "#008C00";
                $port['row_class'] = "success";
                $port['icon'] = 'port-up';
                break;
            case 'lowerLayerDown':
                $port['table_tab_colour'] = "#ff6600";
                $port['row_class'] = "warning";
                $port['icon'] = 'port-down';
                break;
            case 'testing':
                $port['table_tab_colour'] = "#85004b";
                $port['row_class'] = "info";
                $port['icon'] = 'port-ignored';
                break;
            case 'up':
                $port['table_tab_colour'] = "#194B7F";
                $port['row_class'] = "";
                $port['icon'] = 'port-up';
                break;
        }
    }
    // If the device is down, colour the row/tab as 'warning' meaning that the entity is down because of something below it.
    if ($device['status'] == '0') {
        $port['table_tab_colour'] = "#ff6600";
        $port['row_class'] = "warning";
        $port['icon'] = 'port-ignored';
    }
    $port['in_rate'] = $port['ifInOctets_rate'] * 8;
    $port['out_rate'] = $port['ifOutOctets_rate'] * 8;
    // Colour in bps based on speed if > 50, else by UI convention.
    $in_perc = round($port['in_rate'] / $port['ifSpeed'] * 100);
    if ($port['in_rate'] == 0) {
        $port['bps_in_style'] = '';
    } elseif ($in_perc < '50') {
        $port['bps_in_style'] = 'color: #008C00;';
//.........这里部分代码省略.........
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:rewrites.php

示例15: fixiftype

} else {
    echo "</td><td width=150>";
    if ($port['ifType'] && $port['ifType'] != "") {
        echo "<span class=box-desc>" . fixiftype($port['ifType']) . "</span>";
    } else {
        echo "-";
    }
    echo "<br />";
    if ($ifHardType && $ifHardType != "") {
        echo "<span class=box-desc>" . $ifHardType . "</span>";
    } else {
        echo "-";
    }
    echo "</td><td width=150>";
    if ($port['ifPhysAddress'] && $port['ifPhysAddress'] != "") {
        echo "<span class=box-desc>" . formatMac($port['ifPhysAddress']) . "</span>";
    } else {
        echo "-";
    }
    echo "<br />";
    if ($port['ifMtu'] && $port['ifMtu'] != "") {
        echo "<span class=box-desc>MTU " . $port['ifMtu'] . "</span>";
    } else {
        echo "-";
    }
}
echo "</td>";
echo "<td width=375 valign=top class=interface-desc>";
if (strpos($port['label'], "oopback") === false && !$graph_type) {
    foreach (dbFetchRows("SELECT * FROM `links` AS L, `ports` AS I, `devices` AS D WHERE L.local_port_id = ? AND L.remote_port_id = I.port_id AND I.device_id = D.device_id", array($if_id)) as $link) {
        #         echo("<img src='images/16/connect.png' align=absmiddle alt='Directly Connected' /> " . generate_port_link($link, makeshortif($link['label'])) . " on " . generate_device_link($link, shorthost($link['hostname'])) . "</a><br />");
开发者ID:REAP720801,项目名称:librenms,代码行数:31,代码来源:print-interface.inc.php


注:本文中的formatMac函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。