本文整理汇总了PHP中format_mac函数的典型用法代码示例。如果您正苦于以下问题:PHP format_mac函数的具体用法?PHP format_mac怎么用?PHP format_mac使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了format_mac函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: array
$params = array('port_id' => $port_id, 'mac_address' => $clean_mac, 'ip_address' => $ip, 'ip_version' => $ip_version);
dbInsert($params, 'ip_mac');
print_debug("Added MAC address " . format_mac($clean_mac) . " for {$ip}");
//log_event("MAC added: $ip : " . format_mac($clean_mac), $device, "port", $port_id);
echo "+";
}
}
}
// Remove expired ARP/NDP entries
$remove_mac_ids = array();
foreach ($cache_arp as $entry) {
$entry_mac_id = $entry['mac_id'];
$entry_mac = $entry['mac_address'];
$entry_ip = $entry['ip_address'];
$entry_version = $entry['ip_version'];
$entry_if = $entry['ifIndex'];
$entry_port_id = $interface[$entry_if];
if (!isset($mac_table[$entry_if][$entry_version][$entry_ip])) {
$remove_mac_ids[] = $entry_mac_id;
//dbDelete('ip_mac', 'mac_id = ?', array($entry_mac_id));
print_debug("Removed MAC address " . format_mac($entry_mac) . " for {$entry_ip}");
//log_event("MAC removed: $entry_ip : " . format_mac($entry_mac), $device, "port", $entry['port_id']);
echo "-";
}
}
if (count($remove_mac_ids)) {
dbDelete('ip_mac', '1' . generate_query_values($remove_mac_ids, 'mac_id'));
}
echo PHP_EOL;
unset($interface, $remove_mac_ids);
// EOF
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:arp-table.inc.php
示例2: check_str
$sql .= "v_domains as d2 ";
$sql .= "where ";
$sql .= "d1.domain_uuid = d2.domain_uuid and ";
$sql .= "d1.device_username = '" . check_str($_GET["username"]) . "' ";
if ($_GET['domain_uuid'] != '') {
$sql .= "and d2.domain_uuid = '" . check_str($_GET['domain_uuid']) . "' ";
}
if ($_GET['device_uuid'] != '') {
$sql .= "and d1.device_uuid <> '" . check_str($_GET["device_uuid"]) . "' ";
}
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['domain_name'] != '') {
echo $text['message-duplicate_username'] . (if_group("superadmin") ? ": " . format_mac($row['device_mac_address']) . ($_SESSION["domain_name"] != $row["domain_name"] ? " (" . $row["domain_name"] . ")" : null) : null);
}
}
unset($prep_statement);
}
exit;
}
//include the device class
require_once "app/devices/resources/classes/device.php";
//action add or update
if (isset($_REQUEST["id"])) {
$action = "update";
$device_uuid = check_str($_REQUEST["id"]);
} else {
$action = "add";
}
开发者ID:urueedi,项目名称:fusionpbx,代码行数:31,代码来源:device_edit.php
示例3: elseif
} elseif ($sort == "out") {
$sort = "bytes_output_rate";
} else {
$sort = "bps";
}
}
$mas = dbFetchRows("SELECT *, (bytes_input_rate + bytes_output_rate) AS bps,\n (pkts_input_rate + pkts_output_rate) AS pps\n FROM `mac_accounting`\n LEFT JOIN `mac_accounting-state` ON `mac_accounting`.ma_id = `mac_accounting-state`.ma_id\n WHERE `mac_accounting`.port_id = ?\n ORDER BY {$sort} DESC LIMIT 0," . $topn, array($port));
$port = get_port_by_id($port);
$device = device_by_id_cache($port['device_id']);
$pluses = "";
$iter = '0';
$rrd_options .= " COMMENT:' In\\: Current Maximum Total Out\\: Current Maximum Total\\\\n'";
foreach ($mas as $ma) {
$this_rrd = get_rrd_path($device, "mac_acc-" . $port['ifIndex'] . "-" . $ma['vlan_id'] . "-" . $ma['mac'] . ".rrd");
if (is_file($this_rrd)) {
$mac = format_mac($ma['mac']);
$name = $mac;
$addy = dbFetchRow("SELECT * FROM ipv4_mac where mac_address = ? AND port_id = ?", array($ma['mac'], $ma['port_id']));
if ($addy) {
$name = $addy['ipv4_address'] . " (" . $mac . ")";
$peer = dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D\n WHERE A.ipv4_address = ? AND I.port_id = A.port_id AND D.device_id = I.device_id", array($addy['ipv4_address']));
if ($peer) {
$name = $peer['hostname'] . " " . short_ifname($port['ifDescr'], NULL, FALSE) . " (" . $mac . ")";
}
if (dbFetchCell("SELECT COUNT(*) FROM bgpPeers WHERE device_id = ? AND bgpPeerIdentifier = ?", array($ma['device_id'], $addy['ipv4_address']))) {
$peer_info = dbFetchRow("SELECT * FROM bgpPeers WHERE device_id = ? AND bgpPeerIdentifier = ?", array($ma['device_id'], $addy['ipv4_address']));
$name .= " - AS" . $peer_info['bgpPeerRemoteAs'];
}
if ($peer_info) {
$asn = "AS" . $peer_info['bgpPeerRemoteAs'];
$astext = $peer_info['astext'];
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:mac_acc_total.inc.php
示例4: snmp_audit
//.........这里部分代码省略.........
if (empty($details->model)) {
$details->model = my_snmp_get($ip, $credentials, "1.3.6.1.2.1.25.3.2.1.3.1");
}
// serial
if (empty($details->serial)) {
$details->serial = my_snmp_get($ip, $credentials, "1.3.6.1.2.1.47.1.1.1.1.11");
}
if (empty($details->serial)) {
$details->serial = my_snmp_get($ip, $credentials, "1.3.6.1.2.1.47.1.1.1.1.11.1");
}
if (empty($details->serial)) {
$details->serial = my_snmp_get($ip, $credentials, "1.3.6.1.2.1.47.1.1.1.1.11.1.0");
}
# generic snmp
if (empty($details->serial)) {
$details->serial = my_snmp_get($ip, $credentials, "1.3.6.1.2.1.43.5.1.1.17.1");
}
# below is another generic attempt - works for my NetGear Cable Modem
if (empty($details->serial)) {
$details->serial = my_snmp_get($ip, $credentials, "1.3.6.1.4.1.4491.2.4.1.1.1.3.0");
}
$log->message = 'snmp_helper::snmp_audit thinks ' . $ip . ' is a type:' . $details->type . ' model:' . $details->model . ' serial:' . $details->serial;
stdlog($log);
// subnet
if (empty($details->subnet)) {
$details->subnet = my_snmp_get($ip, $credentials, "1.3.6.1.2.1.4.20.1.3." . $details->ip);
}
// mac address
if (empty($details->mac_address)) {
$interface_number = my_snmp_get($ip, $credentials, "1.3.6.1.2.1.4.20.1.2." . $ip);
snmp_set_valueretrieval(SNMP_VALUE_LIBRARY);
$details->mac_address = my_snmp_get($ip, $credentials, "1.3.6.1.2.1.2.2.1.6." . $interface_number);
snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
$details->mac_address = format_mac($details->mac_address);
}
// last attempt at a MAC - just use whatever's in the first interface MAC
if (empty($details->mac_address)) {
snmp_set_valueretrieval(SNMP_VALUE_LIBRARY);
$details->mac_address = my_snmp_get($ip, $credentials, "1.3.6.1.2.1.2.2.1.6.1");
snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
$details->mac_address = format_mac($details->mac_address);
}
$log->message = 'snmp_helper::snmp_audit MAC Address for ' . $ip . ' is ' . $details->mac_address;
stdlog($log);
// type
if (empty($details->type) or $details->type == 'network printer') {
$h = my_snmp_get($ip, $credentials, "1.3.6.1.2.1.25.3.2.1.2.1");
if ($h == '1.3.6.1.2.1.25.3.1.5') {
# we have a printer
$details->type = 'network printer';
$i = my_snmp_walk($ip, $credentials, "1.3.6.1.2.1.43.13.4.1.10.1");
if (count($i) > 0) {
$details->printer_duplex = 'n';
for ($k = 0; $k < count($i); $k++) {
if (mb_strpos($i[$k], "Duplex") !== false) {
$details->printer_duplex = 'y';
}
}
}
if (empty($details->manufacturer)) {
$hex = my_snmp_walk($ip, $credentials, "1.3.6.1.2.1.43.8.2.1.14.1");
if (count($hex) > 0) {
if (isset($hex[1])) {
if (mb_strpos($hex[1], "Hex-STRING: ") !== false) {
$hex[1] = str_replace("Hex-STRING: ", "", $hex[1]);
for ($i = 0; $i < strlen($hex[1]); $i++) {
开发者ID:Opmantek,项目名称:open-audit,代码行数:67,代码来源:snmp_helper.php
示例5: zeropad
$matches[3] = 'ff';
$matches[4] = 'fe';
}
$mac = zeropad($matches[3]);
for ($i = 4; $i <= 8; $i++) {
$mac .= ':' . zeropad($matches[$i]);
}
$clean_mac = str_replace(':', '', $mac);
$mac_table[$if][$ip_version][$ip] = $clean_mac;
if (isset($old_table[$if][$ip_version][$ip])) {
$old_mac = $old_table[$if][$ip_version][$ip];
if ($clean_mac != $old_mac && $clean_mac != '' && $old_mac != '') {
if ($debug) {
echo "Changed MAC address for {$ip} from {$old_mac} to {$clean_mac}\n";
}
log_event("MAC changed: {$ip} : " . format_mac($old_mac) . " -> " . format_mac($clean_mac), $device, "port", $port_id);
dbUpdate(array('mac_address' => $clean_mac), 'ip_mac', 'port_id = ? AND ip_address = ?', array($port_id, $ip));
echo ".";
}
} else {
$params = array('port_id' => $port_id, 'mac_address' => $clean_mac, 'ip_address' => $ip, 'ip_version' => $ip_version);
dbInsert($params, 'ip_mac');
if ($debug) {
echo "Add MAC {$clean_mac}\n";
}
//log_event("MAC added: $ip : " . format_mac($clean_mac), $device, "port", $port_id);
echo "+";
}
}
}
// Remove expired ARP/NDP entries
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:arp-table.inc.php
示例6: get_rrd_path
echo "</pre>";
}
if (is_array($ma)) {
if ($auth || port_permitted($ma['port_id'])) {
$rrd_filename = get_rrd_path($device, "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 .= " :: " . format_mac($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:skive,项目名称:observium,代码行数:31,代码来源:auth.inc.php
示例7: print_arptable
//.........这里部分代码省略.........
}
break;
}
}
}
if (isset($vars['sort'])) {
switch ($vars['sort']) {
case "port":
$sort = " ORDER BY `I`.`port_label`";
break;
case "ip_version":
$sort = " ORDER BY `ip_version`";
break;
case "ip":
case "address":
$sort = " ORDER BY `ip_address`";
break;
case "mac":
default:
$sort = " ORDER BY `mac_address`";
}
}
// 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 .= $sort;
$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 = generate_box_open();
$string .= '<table class="table table-striped table-hover table-condensed">' . PHP_EOL;
$cols = array('mac' => 'MAC Address', 'ip' => 'IP Address', 'device' => 'Device', 'port' => 'Port', '!remote_device' => 'Remote Device', '!remote_port' => 'Remote Port');
if (!$list['device']) {
unset($cols['device']);
}
if (!$list['port']) {
unset($cols['port']);
}
if (!$short) {
$string .= get_table_header($cols, $vars);
// Currently sorting is not available
}
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 style="width: 160px;" class="entity">' . generate_popup_link('mac', format_mac($entry['mac_address'])) . '</td>' . PHP_EOL;
$string .= ' <td style="width: 140px;">' . generate_popup_link('ip', $ip_address) . '</td>' . PHP_EOL;
if ($list['device']) {
$dev = device_by_id_cache($entry['device_id']);
$string .= ' <td class="entity" style="white-space: 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, $entry['port_label_short']) . ' ' . $port_error . '</td>' . PHP_EOL;
}
$string .= ' <td class="entity" style="width: 200px;">' . $arp_name . '</td>' . PHP_EOL;
$string .= ' <td class="entity">' . $arp_if . '</td>' . PHP_EOL;
$string .= ' </tr>' . PHP_EOL;
}
$string .= ' </tbody>' . PHP_EOL;
$string .= '</table>';
$string .= generate_box_close();
// Print pagination header
if ($pagination) {
$string = pagination($vars, $count) . $string . pagination($vars, $count);
}
// Print ARP/NDP table
echo $string;
}
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:arptable.inc.php
示例8: print_fdbtable
/**
* Display FDB table.
*
* @param array $vars
* @return none
*
*/
function print_fdbtable($vars)
{
// With pagination? (display page numbers in header)
$pagination = isset($vars['pagination']) && $vars['pagination'];
pagination($vars, 0, TRUE);
// Get default pagesize/pageno
$pageno = $vars['pageno'];
$pagesize = $vars['pagesize'];
$start = $pagesize * $pageno - $pagesize;
$param = array();
$where = ' WHERE 1 ';
foreach ($vars as $var => $value) {
if ($value != '') {
$cond = array();
switch ($var) {
case 'device':
case 'device_id':
$where .= generate_query_values($value, 'I.device_id');
break;
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':
$where .= generate_query_values($value, 'F.vlan_id');
break;
case 'vlan_name':
$where .= generate_query_values($value, 'V.vlan_name');
break;
case 'address':
$where .= ' AND F.`mac_address` LIKE ?';
# FIXME hm? mres in a dbFacile parameter?
$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 style="width: 160px;">' . format_mac($entry['mac_address']) . '</td>' . PHP_EOL;
if ($list['device']) {
$dev = device_by_id_cache($entry['device_id']);
$string .= ' <td class="entity" style="white-space: 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;
}
//.........这里部分代码省略.........
开发者ID:skive,项目名称:observium,代码行数:101,代码来源:fdbtable.inc.php
示例9: foreach
echo "\t<a href='device_edit.php' alt='" . $text['button-add'] . "'>" . $v_link_label_add . "</a>\n";
}
} else {
echo "\t \n";
}
echo "</td>\n";
echo "<tr>\n";
if (count($devices) > 0) {
foreach ($devices as $row) {
$tr_link = permission_exists('device_edit') ? "href='device_edit.php?id=" . $row['device_uuid'] . "'" : null;
echo "<tr " . $tr_link . ">\n";
if ($_GET['showall'] && permission_exists('device_all')) {
echo "\t<td valign='top' class='" . $row_style[$c] . "'>" . $_SESSION['domains'][$row['domain_uuid']]['domain_name'] . "</td>\n";
}
echo "\t<td valign='top' class='" . $row_style[$c] . "'>";
echo permission_exists('device_edit') ? "<a href='device_edit.php?id=" . $row['device_uuid'] . "'>" . format_mac($row['device_mac_address']) . "</a>" : format_mac($row['device_mac_address']);
echo "\t</td>\n";
echo "\t<td valign='top' class='" . $row_style[$c] . "'>" . $row['device_label'] . " </td>\n";
if ($device_alternate) {
echo "\t<td valign='top' class='" . $row_style[$c] . "'>\n";
if (strlen($row['device_uuid_alternate']) > 0) {
echo "\t\t<a href='device_edit.php?id=" . $row['device_uuid_alternate'] . "' alt=''>" . $row['alternate_label'] . "</a>\n";
}
echo "\t</td>\n";
}
echo "\t<td valign='top' class='" . $row_style[$c] . "'>" . $row['device_vendor'] . " </td>\n";
echo "\t<td valign='top' class='" . $row_style[$c] . "'>" . $row['device_template'] . " </td>\n";
echo "\t<td valign='top' class='" . $row_style[$c] . "'>" . $text['label-' . $row['device_enabled']] . " </td>\n";
echo "\t<td valign='top' class='row_stylebg'>" . $row['device_description'] . " </td>\n";
echo "\t<td class='list_control_icons'>";
if (permission_exists('device_edit')) {
开发者ID:kpabijanskas,项目名称:fusionpbx,代码行数:31,代码来源:devices.php
示例10: humanize_port
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);
// If we can get the device data from the global cache, do it, else pull it from the db (mostly for external scripts)
if (is_array($GLOBALS['cache']['devices']['id'][$port['device_id']])) {
$device =& $GLOBALS['cache']['devices']['id'][$port['device_id']];
} else {
$device = device_by_id_cache($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'] = format_mac($port['ifPhysAddress']);
// Here definition override for ifDescr, because Calix switch ifDescr <> ifName since fw 2.2
// Note, only for 'calix' os now
if ($os == 'calix') {
unset($config['os'][$os]['ifname']);
$version_parts = explode('.', $device['version']);
if ($version_parts[0] > 2 || $version_parts[0] == 2 && $version_parts[1] > 1) {
$config['os'][$os]['ifname'] = 1;
}
}
if (isset($config['os'][$os]['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['ifIndex'];
} else {
$port['label'] = $port['ifDescr'];
}
}
// 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['row_class'] = "warning";
$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.
//.........这里部分代码省略.........
开发者ID:skive,项目名称:observium,代码行数:101,代码来源:rewrites.inc.php
示例11: 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'), '', $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地址</th>' . PHP_EOL;
$string .= ' <th>IP地址</th>' . PHP_EOL;
if ($list['device']) {
$string .= ' <th>设备</th>' . PHP_EOL;
}
if ($list['port']) {
$string .= ' <th>接口</th>' . PHP_EOL;
}
$string .= ' <th>远程设备</th>' . PHP_EOL;
$string .= ' <th>远程接口</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 = '自设备';
}
if ($arp_host['port_id'] == $entry['port_id']) {
$arp_if = '自端口';
}
$string .= ' <tr>' . PHP_EOL;
$string .= ' <td style="width: 160px;">' . generate_popup_link('mac', format_mac($entry['mac_address'])) . '</td>' . PHP_EOL;
$string .= ' <td style="width: 140px;">' . $ip_address . '</td>' . PHP_EOL;
if ($list['device']) {
$dev = device_by_id_cache($entry['device_id']);
$string .= ' <td class="entity" style="white-space: 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">错误</span>', 'port_errors');
}
$string .= ' <td class="entity">' . generate_port_link($entry, short_ifname($entry['label'])) . ' ' . $port_error . '</td>' . PHP_EOL;
}
$string .= ' <td class="entity" style="width: 200px;">' . $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
示例12: print_fdbtable
//.........这里部分代码省略.........
$where .= generate_query_values($value, 'I.device_id');
break;
case 'port':
case 'port_id':
$where .= generate_query_values($value, 'I.port_id');
break;
case 'interface':
case 'port_name':
$where .= generate_query_values($value, 'I.ifDescr', 'LIKE%');
break;
case 'vlan_id':
$where .= generate_query_values($value, 'F.vlan_id');
break;
case 'vlan_name':
$where .= generate_query_values($value, 'V.vlan_name');
break;
case 'address':
$where .= generate_query_values(str_replace(array(':', ' ', '-', '.', '0x'), '', $value), 'F.mac_address', '%LIKE%');
break;
}
}
}
if (isset($vars['sort'])) {
switch ($vars['sort']) {
case "vlan_id":
$sort = " ORDER BY `V`.`vlan_vlan`";
break;
case "vlan_name":
$sort = " ORDER BY `V`.`vlan_name`";
break;
case "port":
$sort = " ORDER BY `I`.`port_label`";
break;
case "mac":
default:
$sort = " ORDER BY `mac_address`";
}
}
// 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 .= $sort;
$query .= " LIMIT {$start},{$pagesize}";
// Query addresses
$entries = dbFetchRows($query, $param);
// Query 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 = generate_box_open();
$string .= '<table class="table table-striped table-hover table-condensed">' . PHP_EOL;
$cols = array('device' => 'Device', 'mac' => array('MAC Address', 'style="width: 160px;"'), 'status' => array('Status', 'style="width: 100px;"'), 'port' => 'Port', 'vlan_id' => 'VLAN ID', 'vlan_name' => 'VLAN NAME');
if (!$list['device']) {
unset($cols['device']);
}
if (!$list['port']) {
unset($cols['port']);
}
if (!$short) {
$string .= get_table_header($cols, $vars);
// Currently sorting is not available
}
foreach ($entries as $entry) {
humanize_port($entry);
$string .= ' <tr>' . PHP_EOL;
if ($list['device']) {
$dev = device_by_id_cache($entry['device_id']);
$string .= ' <td class="entity" style="white-space: nowrap;">' . generate_device_link($dev) . '</td>' . PHP_EOL;
}
$string .= ' <td>' . generate_popup_link('mac', format_mac($entry['mac_address'])) . '</td>' . PHP_EOL;
$string .= ' <td>' . $entry['fdb_status'] . '</td>' . PHP_EOL;
if ($list['port']) {
$string .= ' <td class="entity">' . generate_port_link($entry, $entry['port_label_short']) . ' ' . $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>';
$string .= generate_box_close();
// Print pagination header
if ($pagination) {
$string = pagination($vars, $count) . $string . pagination($vars, $count);
}
// Print FDB table
echo $string;
}
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:fdbtable.inc.php
示例13: fdb_info
function fdb_info(&$irc, &$data)
{
global $config;
$hostname = $data->messageex[1];
if (count($data->messageex) >= 3) {
$ifname = $data->messageex[2];
} else {
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Error: Missing port name");
}
mysql_connect($config['db_host'], $config['db_user'], $config['db_pass']);
mysql_select_db($config['db_name']);
$device = dbFetchRow("SELECT * FROM `devices` WHERE `hostname` = ?", array($hostname));
if (!$device) {
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, "Error: Bad or Missing hostname, use .listdevices to show all devices.");
} else {
$sql = "SELECT `vlans_fdb`.mac_address AS mac_address, GROUP_CONCAT(`vlans_fdb`.vlan_id SEPARATOR '|') AS vlan_id FROM `vlans_fdb`";
$sql .= " LEFT JOIN `ports` ON `ports`.port_id = `vlans_fdb`.port_id AND ports.device_id = `vlans_fdb`.device_id";
$sql .= " WHERE (ports.`ifName` = ? OR ports.`ifDescr` = ?) AND `vlans_fdb`.device_id = ?";
$sql .= " GROUP BY mac_address";
$fdb = dbFetchRows($sql, array($ifname, $ifname, $device['device_id']));
foreach ($fdb as $mac) {
$message .= $sep . format_mac($mac["mac_address"]) . "(vlans [{$mac['vlan_id']}])";
$sep = ", ";
}
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, $message);
echo "FDB\t\t{$hostname}\t{$ifname}\n";
}
mysql_close();
}
开发者ID:Natolumin,项目名称:observium,代码行数:29,代码来源:irc.php
示例14: testFormatMac
/**
* @dataProvider providerFormatMac
*/
public function testFormatMac($value, $result)
{
$this->assertSame($result, format_mac($value));
}
开发者ID:skive,项目名称:observium,代码行数:7,代码来源:IncludesCommonTest.php
示例15: print_dot1xtable
/**
* Display dot1x sessions
*
* @param array $vars
* @return none
*
*/
function print_dot1xtable($vars)
{
// With pagination? (display page numbers in header)
$pagination = isset($vars['pagination']) && $vars['pagination'];
pagination($vars, 0, TRUE);
// Get default pagesize/pageno
$pageno = $vars['pageno'];
$pagesize = $vars['pagesize'];
$start = $pagesize * $pageno - $pagesize;
$param = array();
$where = ' WHERE 1 ';
foreach ($vars as $var => $value) {
if ($value != '') {
switch ($var) {
case 'device':
case 'device_id':
$where .= generate_query_values($value, 'device_id');
break;
case 'address':
if (isset($vars['searchby']) && $vars['searchby'] == 'ip') {
$value = trim($value);
$where .= generate_query_values($value, 'ipv4_addr', '%LIKE%');
} else {
if (isset($vars['searchby']) && $vars['searchby'] == 'mac') {
$value = str_replace(array(':', ' ', '-', '.', '0x'), '', $value);
$where .= generate_query_values($value, 'M.mac_addr', '%LIKE%');
} else {
$value = trim($value);
$where .= generate_query_values($value, 'username', '%LIKE%');
}
}
break;
}
}
}
// Check permissions
$query_permitted = generate_query_permitted(array('device'), array('device_table' => 'M'));
$query = 'FROM `wifi_sessions` AS M ';
$query .= 'LEFT JOIN `wifi_radios` AS I ON I.`wifi_radio_id` = M.`radio_id` ';
$query .= $where . $query_permitted;
$query_count = 'SELECT COUNT(`wifi_session_id`) ' . $query;
$query = 'SELECT *, M.`mac_addr` AS `session_mac` ' . $query;
$query .= ' ORDER BY M.`timestamp` DESC';
$query .= " LIMIT {$start},{$pagesize}";
// Query wireless sessions table
$entries = dbFetchRows($query, $param);
// Query wireless sessions table count
if ($pagination) {
$count = dbFetchCell($query_count, $param);
}
$aps_db = dbFetchRows("SELECT `wifi_accesspoint_id`, `name`, `ap_number` FROM `wifi_accesspoints`");
foreach ($aps_db as $ap_db) {
$aps_sorted_db[$ap_db['wifi_accesspoint_id']] = $ap_db;
}
$list = array('device' => FALSE, 'port' => FALSE);
// A radio is like a port
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 = generate_box_open();
$string .= '<table class="table 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;
$string .= ' <th>Username</th>' . PHP_EOL;
$string .= ' <th>SSID/VLAN</th>' . PHP_EOL;
$string .= ' <th>Last Seen</th>' . PHP_EOL;
if ($list['device']) {
$string .= ' <th>Device</th>' . PHP_EOL;
}
if ($list['port']) {
$string .= ' <th>Interface/AP</th>' . PHP_EOL;
}
$string .= ' </tr>' . PHP_EOL;
$string .= ' </thead>' . PHP_EOL;
}
$string .= ' &l
|
请发表评论