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


PHP Net_IPv6::uncompress方法代码示例

本文整理汇总了PHP中Net_IPv6::uncompress方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_IPv6::uncompress方法的具体用法?PHP Net_IPv6::uncompress怎么用?PHP Net_IPv6::uncompress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Net_IPv6的用法示例。


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

示例1: get_cache

function get_cache($host, $value)
{
    global $dev_cache;
    $host = strtolower(trim($host));
    // Check cache expiration
    $now = time();
    $expired = TRUE;
    if (isset($dev_cache[$host]['lastchecked'])) {
        if ($now - $dev_cache[$host]['lastchecked'] < 3600) {
            $expired = FALSE;
        }
        // will expire after 1 hour
    }
    if ($expired) {
        $dev_cache[$host]['lastchecked'] = $now;
    }
    if (!isset($dev_cache[$host][$value]) || $expired) {
        switch ($value) {
            case 'device_id':
                // Try by hostname
                $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM `devices` WHERE `hostname` = ? OR `sysName` = ?', array($host, $host));
                // If failed, try by IP
                if (!is_numeric($dev_cache[$host]['device_id'])) {
                    $ip = $host;
                    $ip_version = get_ip_version($ip);
                    if ($ip_version !== FALSE) {
                        if ($ip_version == 6) {
                            $ip = Net_IPv6::uncompress($ip, TRUE);
                        }
                        $address_count = dbFetchCell('SELECT COUNT(*) FROM `ipv' . $ip_version . '_addresses` WHERE `ipv' . $ip_version . '_address` = ?;', array($ip));
                        if ($address_count) {
                            $query = 'SELECT `device_id` FROM `ipv' . $ip_version . '_addresses` AS A, `ports` AS I WHERE A.`ipv' . $ip_version . '_address` = ? AND I.`port_id` = A.`port_id`';
                            // If more than one IP address, also check the status of the port.
                            if ($address_count > 1) {
                                $query .= " AND I.`ifOperStatus` = 'up'";
                            }
                            $dev_cache[$host]['device_id'] = dbFetchCell($query, array($ip));
                        }
                    }
                }
                break;
            case 'os':
            case 'version':
                $dev_cache[$host][$value] = dbFetchCell('SELECT `' . $value . '` FROM `devices` WHERE `device_id` = ?', array(get_cache($host, 'device_id')));
                break;
            case 'os_group':
                $os = get_cache($host, 'os');
                $dev_cache[$host]['os_group'] = isset($GLOBALS['config']['os'][$os]['group']) ? $GLOBALS['config']['os'][$os]['group'] : '';
                break;
            default:
                return NULL;
        }
    }
    return $dev_cache[$host][$value];
}
开发者ID:skive,项目名称:observium,代码行数:55,代码来源:syslog.inc.php

示例2: print_arptable

/**
 * Display ARP/NDP table addresses.
 *
 * Display pages with ARP/NDP tables addresses from devices.
 *
 * @param array $vars
 * @return none
 *
 */
function print_arptable($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 I.`device_id` = ?';
                    $param[] = $value;
                    break;
                case 'port':
                case 'port_id':
                    $where .= ' AND I.`port_id` = ?';
                    $param[] = $value;
                    break;
                case 'ip_version':
                    $where .= ' AND `ip_version` = ?';
                    $param[] = $value;
                    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));
//.........这里部分代码省略.........
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:arptable.inc.php

示例3: switch

 //  local(7)           ->  ifIndex
 switch ($lldp['lldpRemPortIdSubtype']) {
     case 'interfaceAlias':
         $id = snmp_hexstring($id);
         $remote_port_id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE (`ifAlias` = ? OR `ifDescr` = ?) AND `device_id` = ?", array($id, $if, $remote_device_id));
         break;
     case 'interfaceName':
         $remote_port_id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE (`ifName` = ?  OR `ifDescr` = ?) AND `device_id` = ?", array($id, $if, $remote_device_id));
         break;
     case 'macAddress':
         $remote_port_id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE `ifPhysAddress` = ? AND `device_id` = ?", array(strtolower(str_replace(array(' ', '-'), '', $id)), $remote_device_id));
         break;
     case 'networkAddress':
         $ip_version = get_ip_version($id);
         if ($ip_version) {
             $ip = $ip_version === 6 ? Net_IPv6::uncompress($id, TRUE) : $id;
             $remote_port_id = dbFetchCell("SELECT `port_id` FROM `ipv" . $ip_version . "_addresses` LEFT JOIN `ports` USING (`port_id`) WHERE `ipv" . $ip_version . "_address` = ? AND `device_id` = ?", array($ip, $remote_device_id));
         }
         break;
     case 'local':
         // local not always ifIndex or FIXME (see: http://jira.observium.org/browse/OBSERVIUM-1716)
         if (!ctype_digit($id)) {
             // Not sure what should be if $id ifName and it just numeric
             $remote_port_id = dbFetchCell("SELECT `port_id` FROM `ports` WHERE (`ifName`= ? OR `ifDescr` = ?) AND `device_id` = ?", array($id, $if, $remote_device_id));
         }
     case 'ifIndex':
         // These cases are handled by the ifDescr/ifIndex combination fallback below
     // These cases are handled by the ifDescr/ifIndex combination fallback below
     default:
         break;
 }
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:lldp-mib.inc.php

示例4: discover_new_device

function discover_new_device($hostname, $source = 'xdp', $protocol = NULL, $device = NULL, $snmp_port = 161)
{
    global $config;
    $source = strtolower($source);
    // Check if source is enabled for autodiscovery
    if ($config['autodiscovery'][$source]) {
        $flags = OBS_DNS_ALL;
        if (!$protocol) {
            $protocol = strtoupper($source);
        }
        print_cli_data("Try discovering host", "{$hostname} through {$protocol}", 3);
        // By first detect hostname is IP or domain name (IPv4/6 == 4/6, hostname == FALSE)
        $ip_version = get_ip_version($hostname);
        if ($ip_version) {
            // Hostname is IPv4/IPv6
            $use_ip = TRUE;
            $ip = $hostname;
        } else {
            $use_ip = FALSE;
            // Add "mydomain" configuration if this resolves, converts switch1 -> switch1.mydomain.com
            if (!empty($config['mydomain']) && isDomainResolves($hostname . '.' . $config['mydomain'], $flags)) {
                $hostname .= '.' . $config['mydomain'];
            }
            // Determine v4 vs v6
            $ip = gethostbyname6($hostname, $flags);
            if ($ip) {
                $ip_version = get_ip_version($ip);
                print_debug("Host {$hostname} resolved as {$ip}");
            } else {
                // No DNS records
                print_debug("Host {$hostname} not resolved, autodiscovery fails.");
                return FALSE;
            }
        }
        if ($ip_version == 6) {
            $flags = $flags ^ OBS_DNS_A;
            // Exclude IPv4
        }
        if (isset($config['autodiscovery']['ping_skip']) && $config['autodiscovery']['ping_skip']) {
            $flags = $flags | OBS_PING_SKIP;
            // Add skip pings flag
        }
        if (match_network($ip, $config['autodiscovery']['ip_nets'])) {
            print_debug("Host {$hostname} ({$ip}) founded inside configured nets, trying to add:");
            // By first check if pingable
            $pingable = isPingable($ip, $flags);
            if (!$pingable && (isset($config['autodiscovery']['ping_skip']) && $config['autodiscovery']['ping_skip'])) {
                $flags = $flags | OBS_PING_SKIP;
                // Add skip pings flag if allowed in config
                $pingable = TRUE;
            }
            if ($pingable) {
                // Check if device duplicated by IP
                $ip = $ip_version == 4 ? $ip : Net_IPv6::uncompress($ip, TRUE);
                $db = dbFetchRow('SELECT D.`hostname` FROM ipv' . $ip_version . '_addresses AS A
                         LEFT JOIN `ports`   AS P ON A.`port_id`   = P.`port_id`
                         LEFT JOIN `devices` AS D ON D.`device_id` = P.`device_id`
                         WHERE D.`disabled` = 0 AND A.`ipv' . $ip_version . '_address` = ?', array($ip));
                if ($db) {
                    print_debug('Already have device ' . $db['hostname'] . " with IP {$ip}");
                    return FALSE;
                }
                // Detect snmp transport, net-snmp needs udp6 for ipv6
                $snmp_transport = $ip_version == 4 ? 'udp' : 'udp6';
                $new_device = detect_device_snmpauth($ip, $snmp_port, $snmp_transport);
                if ($new_device) {
                    if ($use_ip) {
                        // Detect FQDN hostname
                        // by sysName
                        $snmphost = snmp_get($new_device, 'sysName.0', '-Oqv', 'SNMPv2-MIB');
                        if ($snmphost) {
                            $snmp_ip = gethostbyname6($snmphost, $flags);
                        }
                        if ($snmp_ip == $ip) {
                            $hostname = $snmphost;
                        } else {
                            // by PTR
                            $ptr = gethostbyaddr6($ip);
                            if ($ptr) {
                                $ptr_ip = gethostbyname6($ptr, $flags);
                            }
                            if ($ptr && $ptr_ip == $ip) {
                                $hostname = $ptr;
                            } else {
                                if ($config['autodiscovery']['require_hostname']) {
                                    print_debug("Device IP {$ip} does not seem to have FQDN.");
                                    return FALSE;
                                } else {
                                    $hostname = $ip_version == 4 ? $ip : Net_IPv6::compress($hostname, TRUE);
                                    // Always use compressed IPv6 name
                                }
                            }
                        }
                        print_debug("Device IP {$ip} linked to FQDN name: {$hostname}");
                    }
                    $new_device['hostname'] = $hostname;
                    if (!check_device_duplicated($new_device)) {
                        $snmp_v3 = array();
                        if ($new_device['snmp_version'] === 'v3') {
                            $snmp_v3['snmp_authlevel'] = $new_device['snmp_authlevel'];
//.........这里部分代码省略.........
开发者ID:Natolumin,项目名称:observium,代码行数:101,代码来源:functions.inc.php

示例5: foreach

foreach ($cache_arp as $entry) {
    $old_if = $entry['ifIndex'];
    $old_mac = $entry['mac_address'];
    $old_address = $entry['ip_address'];
    $old_version = $entry['ip_version'];
    $old_table[$old_if][$old_version][$old_address] = $old_mac;
}
$ipv4_pattern = '/\\[(\\d+)\\](?:\\[ipv4\\])?\\["?([\\d\\.]+)"?\\]\\s+([a-f\\d]+):([a-f\\d]+):([a-f\\d]+):([a-f\\d]+):([a-f\\d]+):([a-f\\d]{1,2})/i';
$ipv6_pattern = '/\\[(\\d+)\\](?:\\[ipv6\\])?\\["?([a-f\\d:]+)"?\\]\\s+(?:([a-f\\d]+):([a-f\\d]+):)?([a-f\\d]+):([a-f\\d]+):([a-f\\d]+):([a-f\\d]{1,2})/i';
foreach (explode("\n", $oid_data) as $data) {
    if (preg_match($ipv4_pattern, $data, $matches)) {
        $ip = $matches[2];
        $ip_version = 4;
    } elseif (preg_match($ipv6_pattern, $data, $matches)) {
        if (count(explode(':', $matches[2])) === 8) {
            $ip = Net_IPv6::uncompress($matches[2], TRUE);
        } else {
            $ip = hex2ip($matches[2]);
        }
        $ip_version = 6;
    } else {
        // In principle the such shouldn't be.
        continue;
    }
    $if = $matches[1];
    $port_id = $interface[$if];
    if ($ip & $port_id) {
        if ($matches[3] === '' && $matches[4] === '') {
            // Convert IPv4 to fake MAC for 6to4 tunnels
            //ipNetToPhysicalPhysAddress[27][ipv6]["20:02:c0:58:63:01:00:00:00:00:00:00:00:00:00:00"] 0:0:c0:58
            $matches[3] = 'ff';
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:arp-table.inc.php

示例6: uncompress_ipv6

function uncompress_ipv6($ip)
{
    // Singleton
    static $class = null;
    if ($class === null) {
        $class = new Net_IPv6();
    }
    return $class->uncompress($ip, true);
}
开发者ID:shupp,项目名称:VegaDNS,代码行数:9,代码来源:functions.php

示例7: discover_new_device

function discover_new_device($hostname, $source = 'xdp', $protocol = NULL, $device = NULL, $snmp_port = 161)
{
    global $config;
    $source = strtolower($source);
    if ($config['autodiscovery'][$source]) {
        if (!$protocol) {
            $protocol = strtoupper($source);
        }
        print_message("发现新主机 {$hostname} 通过 {$protocol}");
        // By first detect hostname is IP or domain name (IPv4/6 == 4/6, hostname == FALSE)
        $ip_version = get_ip_version($hostname);
        if ($ip_version) {
            // Hostname is IPv4/IPv6
            $use_ip = TRUE;
            $ip = $hostname;
        } else {
            $use_ip = FALSE;
            if (!empty($config['mydomain']) && isDomainResolves($hostname . '.' . $config['mydomain'])) {
                $hostname .= '.' . $config['mydomain'];
            }
            $ip = gethostbyname6($hostname);
            if ($ip) {
                $ip_version = get_ip_version($ip);
                print_debug("主机 {$hostname} 解析为 {$ip}");
            } else {
                // No DNS records
                print_debug("主机 {$hostname} 无法解析, 自动发现失败.");
                return FALSE;
            }
        }
        if (match_network($ip, $config['autodiscovery']['ip_nets'])) {
            print_debug("主机 {$hostname} ({$ip}) 内部网络创建配置, 尝试增加:");
            if (isPingable($ip)) {
                // Check if device duplicated by IP
                $ip = $ip_version == 4 ? $ip : Net_IPv6::uncompress($ip, TRUE);
                $db = dbFetchRow('SELECT D.`hostname` FROM ipv' . $ip_version . '_addresses AS A
                         LEFT JOIN `ports`   AS P ON A.`port_id`   = P.`port_id`
                         LEFT JOIN `devices` AS D ON D.`device_id` = P.`device_id`
                         WHERE D.`disabled` = 0 AND A.`ipv' . $ip_version . '_address` = ?', array($ip));
                if ($db) {
                    print_debug('已经有设备 ' . $db['hostname'] . " 包含 {$ip}");
                    return FALSE;
                }
                // Detect snmp transport
                $snmp_transport = $ip_version == 4 ? 'udp' : 'udp6';
                $new_device = detect_device_snmpauth($ip, $snmp_port, $snmp_transport);
                if ($new_device) {
                    if ($use_ip) {
                        // Detect FQDN hostname
                        // by sysName
                        $snmphost = snmp_get($new_device, "sysName.0", "-Oqv", "SNMPv2-MIB", mib_dirs());
                        if ($snmphost) {
                            $snmp_ip = gethostbyname6($snmphost);
                        }
                        if ($snmp_ip == $ip) {
                            $hostname = $snmphost;
                        } else {
                            // by PTR
                            $ptr = gethostbyaddr6($ip);
                            if ($ptr) {
                                $ptr_ip = gethostbyname6($ptr);
                            }
                            if ($ptr && $ptr_ip == $ip) {
                                $hostname = $ptr;
                            } else {
                                print_debug("设备 IP {$ip} 没有 FQDN 名称");
                                return FALSE;
                            }
                        }
                        print_debug("设备 IP {$ip} 发现 FQDN 名称: {$hostname}");
                    }
                    $new_device['hostname'] = $hostname;
                    if (!check_device_duplicated($new_device)) {
                        $snmp_v3 = array();
                        if ($new_device['snmp_version'] === 'v3') {
                            $snmp_v3['snmp_authlevel'] = $new_device['snmp_authlevel'];
                            $snmp_v3['snmp_authname'] = $new_device['snmp_authname'];
                            $snmp_v3['snmp_authpass'] = $new_device['snmp_authpass'];
                            $snmp_v3['snmp_authalgo'] = $new_device['snmp_authalgo'];
                            $snmp_v3['snmp_cryptopass'] = $new_device['snmp_cryptopass'];
                            $snmp_v3['snmp_cryptoalgo'] = $new_device['snmp_cryptoalgo'];
                        }
                        $remote_device_id = createHost($new_device['hostname'], $new_device['snmp_community'], $new_device['snmp_version'], $new_device['snmp_port'], $new_device['snmp_transport'], $snmp_v3);
                        if ($remote_device_id) {
                            $remote_device = device_by_id_cache($remote_device_id, 1);
                            if ($port) {
                                humanize_port($port);
                                log_event("设备自动发现通过 {$protocol} 在 " . $device['hostname'] . " (port " . $port['label'] . ")", $remote_device_id, 'port', $port['port_id']);
                            } else {
                                log_event("设备自动发现通过 {$protocol} 在 " . $device['hostname'], $remote_device_id, $protocol);
                            }
                            //array_push($GLOBALS['devices'], $remote_device); // createHost() already puth this
                            return $remote_device_id;
                        }
                    }
                }
            }
        } else {
            print_debug("IP {$ip} ({$hostname}) 不允许内部 \$config['autodiscovery']['ip_nets'] 位于 config.php");
        }
//.........这里部分代码省略.........
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:functions.inc.php

示例8: calculateIpCalcResult

/**
 * ipCalc calculations
 */
function calculateIpCalcResult($cidr)
{
    /* first verify address type */
    $type = IdentifyAddress($cidr);
    /* IPv4 */
    if ($type == "IPv4") {
        $net = Net_IPv4::parseAddress($cidr);
        //set ip address type
        $out['Type'] = 'IPv4';
        //calculate network details
        $out['IP address'] = $net->ip;
        // 192.168.0.50
        $out['Network'] = $net->network;
        // 192.168.0.0
        $out['Broadcast'] = $net->broadcast;
        // 192.168.255.255
        $out['Subnet bitmask'] = $net->bitmask;
        // 16
        $out['Subnet netmask'] = $net->netmask;
        // 255.255.0.0
        $out['Subnet wildcard'] = long2ip(~ip2long($net->netmask));
        //0.0.255.255
        //calculate min/max IP address
        $out['Min host IP'] = long2ip(ip2long($out['Network']) + 1);
        $out['Max host IP'] = long2ip(ip2long($out['Broadcast']) - 1);
        $out['Number of hosts'] = ip2long($out['Broadcast']) - ip2long($out['Min host IP']);
        //subnet class
        $out['Subnet Class'] = checkIpv4AddressType($out['Network'], $out['Broadcast']);
        //if IP == subnet clear the Host fields
        if ($out['IP address'] == $out['Network']) {
            $out['IP address'] = "/";
        }
    } else {
        //set ip address type
        $out['Type'] = 'IPv6';
        //calculate network details
        /*         $out['Host address']              = Net_IPv6::removeNetmaskSpec ( $cidr );  */
        $out['Host address'] = $cidr;
        $out['Host address'] = Net_IPv6::compress($out['Host address'], 1);
        $out['Host address (uncompressed)'] = Net_IPv6::uncompress($out['Host address']);
        $mask = Net_IPv6::getNetmaskSpec($cidr);
        $subnet = Net_IPv6::getNetmask($cidr);
        $out['Subnet prefix'] = Net_IPv6::compress($subnet) . '/' . $mask;
        $out['Prefix length'] = Net_IPv6::getNetmaskSpec($cidr);
        // get reverse DNS entries
        $out['Host Reverse DNS'] = calculateReverseDNS6($out['Host address (uncompressed)']);
        $out['Subnet Reverse DNS'] = calculateReverseDNS6($subnet, $mask);
        //if IP == subnet clear the Host fields and Host Reverse DNS
        if ($out['Host address'] == $out['Subnet prefix']) {
            $out['Host address'] = '/';
            $out['Host address (uncompressed)'] = '/';
            unset($out['Host Reverse DNS']);
        }
        //min / max hosts
        $maxIp = gmp_strval(gmp_add(gmp_sub(gmp_pow(2, 128 - $mask), 1), ip2long6($subnet)));
        $out['Min host IP'] = long2ip6(gmp_strval(gmp_add(ip2long6($subnet), 1)));
        $out['Max host IP'] = long2ip6($maxIp);
        $out['Number of hosts'] = MaxHosts($mask, 1);
        //address type
        $out['Address type'] = Net_IPv6::getAddressType($cidr);
        $out['Address type'] = checkIpv6AddressType($out['Address type']);
    }
    /* return results */
    return $out;
}
开发者ID:retexica,项目名称:phpipam,代码行数:68,代码来源:functions-tools.php

示例9: discover_new_device

function discover_new_device($hostname, $source = 'xdp', $protocol = NULL, $device = NULL, $port = 161)
{
    global $config;
    $source = strtolower($source);
    if ($config['autodiscovery'][$source]) {
        if (!$protocol) {
            $protocol = strtoupper($source);
        }
        print_message("Discovering new host {$hostname} through {$protocol}");
        // By first detect hostname is IP or domain name (IPv4/6 == 4/6, hostname == FALSE)
        $ip_version = get_ip_version($hostname);
        if ($ip_version) {
            // Hostname is IPv4/IPv6
            $use_ip = TRUE;
        } else {
            $use_ip = FALSE;
            if (!empty($config['mydomain']) && isDomainResolves($hostname . '.' . $config['mydomain'])) {
                $hostname .= '.' . $config['mydomain'];
            }
            $ip = gethostbyname6($hostname);
            if ($ip) {
                $ip_version = get_ip_version($ip);
                print_debug("Host {$hostname} resolved as {$ip}");
            } else {
                // No DNS records
                print_debug("Host {$hostname} not resolved, autodiscovery fails.");
                return FALSE;
            }
        }
        if (match_network($ip, $config['autodiscovery']['ip_nets'])) {
            print_debug("Host {$hostname} ({$ip}) founded inside configured nets, try to adding:");
            if (isPingable($ip)) {
                // Check if device duplicated by IP
                $ip = $ip_version == 4 ? $hostname : Net_IPv6::uncompress($hostname, TRUE);
                $db = dbFetchRow('SELECT D.`hostname` FROM ipv' . $ip_version . '_addresses AS A
                         LEFT JOIN `ports`   AS P ON A.`port_id`   = P.`port_id`
                         LEFT JOIN `devices` AS D ON D.`device_id` = P.`device_id`
                         WHERE D.`disabled` = 0 AND A.`ipv' . $ip_version . '_address` = ?', array($ip));
                if ($db) {
                    print_debug('Already have device ' . $db['hostname'] . " with {$ip}");
                    return FALSE;
                }
                // Detect snmp transport
                $transport = $ip_version == 4 ? 'udp' : 'udp6';
                $new_device = detect_device_snmpauth($ip, $port, $transport);
                if ($new_device) {
                    if ($use_ip) {
                        // Detect FQDN hostname
                        // by sysName
                        $snmphost = snmp_get($new_device, "sysName.0", "-Oqv", "SNMPv2-MIB", mib_dirs());
                        if ($snmphost) {
                            $snmp_ip = gethostbyname6($snmphost);
                        }
                        if ($snmp_ip == $ip) {
                            $hostname = $snmphost;
                        } else {
                            // by PTR
                            $ptr = gethostbyaddr6($ip);
                            if ($ptr) {
                                $ptr_ip = gethostbyname6($ptr);
                            }
                            if ($ptr && $ptr_ip == $ip) {
                                $hostname = $ptr;
                            } else {
                                print_debug("Device IP {$ip} not have FQDN name");
                                return FALSE;
                            }
                        }
                        print_debug("Device IP {$ip} founded FQDN name: {$hostname}");
                    }
                    $new_device['hostname'] = $hostname;
                    if (!check_device_duplicated($new_device)) {
                        $v3 = array();
                        if ($new_device['snmpver'] === 'v3') {
                            $v3['authlevel'] = $new_device['authlevel'];
                            $v3['authname'] = $new_device['authname'];
                            $v3['authpass'] = $new_device['authpass'];
                            $v3['authalgo'] = $new_device['authalgo'];
                            $v3['cryptopass'] = $new_device['cryptopass'];
                            $v3['cryptoalgo'] = $new_device['cryptoalgo'];
                        }
                        $remote_device_id = createHost($new_device['hostname'], $new_device['community'], $new_device['snmpver'], $new_device['port'], $new_device['transport'], $v3);
                        if ($remote_device_id) {
                            $remote_device = device_by_id_cache($remote_device_id, 1);
                            if ($port) {
                                humanize_port($port);
                                log_event("Device autodiscovered through {$protocol} on " . $device['hostname'] . " (port " . $port['label'] . ")", $remote_device_id, 'port', $port['port_id']);
                            } else {
                                log_event("Device autodiscovered through {$protocol} on " . $device['hostname'], $remote_device_id, $protocol);
                            }
                            //array_push($GLOBALS['devices'], $remote_device); // createHost() already puth this
                            return $remote_device_id;
                        }
                    }
                }
            }
        } else {
            print_debug("IP {$ip} ({$hostname}) not permitted inside \$config['autodiscovery']['ip_nets'] in config.php");
        }
        print_debug('Autodiscovery for host ' . $hostname . ' fails.');
//.........这里部分代码省略.........
开发者ID:skive,项目名称:observium,代码行数:101,代码来源:functions.inc.php

示例10: get_pseudowires_array

/**
 * Params:
 *
 * pagination, pageno, pagesize
 * device, port
 */
function get_pseudowires_array($vars)
{
    $array = array();
    // With pagination? (display page numbers in header)
    $array['pagination'] = isset($vars['pagination']) && $vars['pagination'];
    pagination($vars, 0, TRUE);
    // Get default pagesize/pageno
    $array['pageno'] = $vars['pageno'];
    $array['pagesize'] = $vars['pagesize'];
    $start = $array['pagesize'] * $array['pageno'] - $array['pagesize'];
    $pagesize = $array['pagesize'];
    // Begin query generate
    $param = array();
    $where = ' WHERE 1 ';
    foreach ($vars as $var => $value) {
        if ($value != '') {
            switch ($var) {
                case 'device':
                case 'device_a':
                    $where .= generate_query_values($value, 'device_id');
                    break;
                case 'port':
                case 'port_a':
                    $where .= generate_query_values($value, 'port_id');
                    break;
                    //case 'type':
                    //  $where .= generate_query_values($value, 'type');
                    //  break;
                    //case 'message':
                    //  $where .= generate_query_values($value, 'message', '%LIKE%');
                    //  break;
            }
        }
    }
    // Show pseudowires only for permitted devices and ports
    $query_permitted = generate_query_permitted(array('device', 'port'));
    $query = 'FROM `pseudowires` ';
    $query .= $where . $query_permitted;
    $query_count = 'SELECT COUNT(*) ' . $query;
    //$query_updated = 'SELECT MAX(`timestamp`) '.$query;
    $query = 'SELECT * ' . $query;
    //$query .= ' ORDER BY `event_id` DESC ';
    $query .= " LIMIT {$start},{$pagesize}";
    // Query pseudowires
    foreach (dbFetchRows($query, $param) as $entry) {
        if ($entry['peer_addr']) {
            $peer_addr = $entry['peer_addr'];
        } else {
            if ($entry['pwMplsPeerLdpID']) {
                $peer_addr = preg_replace('/:\\d+$/', '', $pw['pwMplsPeerLdpID']);
            }
        }
        $peer_addr_type = get_ip_version($peer_addr);
        if ($peer_addr_type) {
            if ($peer_addr_type == 6) {
                $peer_addr = Net_IPv6::uncompress($peer_addr, TRUE);
            }
            $peer_addr_type = 'ipv' . $peer_addr_type;
            $entry['peer_addr'] = $peer_addr;
            $entry['peer_addr_type'] = $peer_addr_type;
        } else {
            continue;
            // Peer address unknown
        }
        if (!is_array($cache_pseudowires['ips'][$peer_addr])) {
            $cache_pseudowires['ips'][$peer_addr]['port_id'] = dbFetchCell('SELECT `port_id` FROM `' . $peer_addr_type . '_addresses` WHERE `' . $peer_addr_type . '_address` = ? ' . generate_query_values($GLOBALS['cache']['ports']['pseudowires'], 'port_id') . ' LIMIT 1;', array($peer_addr));
            if (!is_numeric($cache_pseudowires['ips'][$peer_addr]['port_id'])) {
                $cache_pseudowires['ips'][$peer_addr]['port_id'] = dbFetchCell('SELECT `port_id` FROM `' . $peer_addr_type . '_addresses` WHERE `' . $peer_addr_type . '_address` = ? ' . $GLOBALS['cache']['where']['ports_permitted'] . ' LIMIT 1;', array($peer_addr));
                if (is_numeric($cache_pseudowires['ips'][$peer_addr]['port_id'])) {
                    // If we found port on remote device, than both devices in DB and will try to fix real port
                    $peer_port_tmp = get_port_by_id_cache($cache_pseudowires['ips'][$peer_addr]['port_id']);
                    $peer_port_fix = dbFetchCell('SELECT `port_id` FROM `pseudowires` WHERE `device_id` = ? AND `pwID` = ? LIMIT 1;', array($peer_port_tmp['device_id'], $entry['pwID']));
                    if (is_numeric($peer_port_fix)) {
                        $cache_pseudowires['ips'][$peer_addr]['port_id'] = $peer_port_fix;
                    }
                }
            }
            //$cache_pseudowires['ips'][$peer_addr]['host'] = $entry['reverse_dns'];
        }
        $entry['peer_port_id'] = $cache_pseudowires['ips'][$peer_addr]['port_id'];
        //$entry['peer_port']      = get_port_by_id_cache($entry['peer_port_id']);
        //$entry['peer_device_id'] = $entry['peer_port']['device_id'];
        //$entry['peer_device']    = device_by_id_cache($entry['peer_device_id']);
        $array['entries'][] = $entry;
    }
    // Query pseudowires count
    if ($array['pagination']) {
        $array['count'] = dbFetchCell($query_count, $param);
        $array['pagination_html'] = pagination($vars, $array['count']);
    } else {
        $array['count'] = count($array['entries']);
    }
    // Query for last timestamp
    //$array['updated'] = dbFetchCell($query_updated, $param);
//.........这里部分代码省略.........
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:101,代码来源:pseudowires.inc.php

示例11: dbFetchCell

 }
 $if_id = dbFetchCell('SELECT `port_id` FROM `ports` WHERE `ifDescr` = ? AND `device_id` = ? LIMIT 1;', array($pw['cpwVcName'], $device['device_id']));
 if (!is_numeric($if_id) && strpos($pw['cpwVcName'], '_')) {
     // IOS-XR some time use '_' instead '/'. http://jira.observium.org/browse/OBSERVIUM-246
     // cpwVcName.3221225526 = TenGigE0_3_0_6.438
     // ifDescr.84 = TenGigE0/3/0/6.438
     $if_id = dbFetchCell('SELECT `port_id` FROM `ports` WHERE `ifDescr` = ? AND `device_id` = ? LIMIT 1;', array(str_replace('_', '/', $pw['cpwVcName']), $device['device_id']));
 }
 if (!is_numeric($if_id) && strpos($pw['cpwVcMplsLocalLdpID'], ':')) {
     // Last (know) way for detect local port by MPLS LocalLdpID,
     // because IOS-XR some time use Remote IP instead ifDescr in cpwVcName
     // cpwVcName.3221225473 = STRING: 82.209.169.153,3055
     // cpwVcMplsLocalLdpID.3221225473 = STRING: 82.209.169.129:0
     list($local_addr) = explode(':', $pw['cpwVcMplsLocalLdpID']);
     if ($peer_addr_type == 'ipv6') {
         $local_addr = Net_IPv6::uncompress($local_addr, TRUE);
     }
     $if_id = dbFetchCell('SELECT `port_id` FROM `' . $peer_addr_type . '_addresses` LEFT JOIN `ports` USING (`port_id`) WHERE `' . $peer_addr_type . '_address` = ? AND `device_id` = ? LIMIT 1;', array($local_addr, $device['device_id']));
 }
 // Note, Cisco experimental 'cpwVc' oid prefix converted to 'pw' prefix as in rfc PW-STD-MIB
 $pws_new = array('device_id' => $device['device_id'], 'mib' => $mib, 'port_id' => $if_id, 'peer_device_id' => $remote_device, 'peer_addr' => $peer_addr, 'peer_rdns' => $peer_rdns, 'pwIndex' => $pw_id, 'pwType' => $pw['cpwVcType'], 'pwID' => $pw['cpwVcID'], 'pwOutboundLabel' => $pw['cpwVcOutboundVcLabel'], 'pwInboundLabel' => $pw['cpwVcInboundVcLabel'], 'pwPsnType' => $pw['cpwVcPsnType'], 'pwDescr' => $pw['cpwVcDescr'], 'pwRemoteIfString' => $pw['cpwVcRemoteIfString'], 'pwRowStatus' => $pw['cpwVcRowStatus']);
 if (!empty($pws_cache['pws_db'][$mib][$pw_id])) {
     $pws_old = $pws_cache['pws_db'][$mib][$pw_id];
     $pseudowire_id = $pws_old['pseudowire_id'];
     if (empty($pws_old['peer_device_id'])) {
         $pws_old['peer_device_id'] = array('NULL');
     }
     $update_array = array();
     //var_dump(array_keys($pws_new));
     foreach (array_keys($pws_new) as $column) {
         if ($pws_new[$column] != $pws_old[$column]) {
开发者ID:Natolumin,项目名称:observium,代码行数:31,代码来源:cisco-ietf-pw-mib.inc.php

示例12: get_cache

function get_cache($host, $value)
{
    global $dev_cache;
    if (empty($host)) {
        return;
    }
    // Check cache expiration
    $now = time();
    $expired = TRUE;
    if (isset($dev_cache[$host]['lastchecked'])) {
        if ($now - $dev_cache[$host]['lastchecked'] < 600) {
            $expired = FALSE;
        }
        // will expire after 10 min
    }
    if ($expired) {
        $dev_cache[$host]['lastchecked'] = $now;
    }
    if (!isset($dev_cache[$host][$value]) || $expired) {
        switch ($value) {
            case 'device_id':
                // Try by map in config
                if (isset($GLOBALS['config']['syslog']['host_map'][$host])) {
                    $new_host = $GLOBALS['config']['syslog']['host_map'][$host];
                    if (is_numeric($new_host)) {
                        // Check if device id exist
                        $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM `devices` WHERE `device_id` = ?', array($new_host));
                    } else {
                        $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM `devices` WHERE `hostname` = ? OR `sysName` = ?', array($new_host, $new_host));
                    }
                    // If syslog host map correct, return device id or try onward
                    if ($dev_cache[$host]['device_id']) {
                        return $dev_cache[$host]['device_id'];
                    }
                }
                // Try by hostname
                $dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM `devices` WHERE `hostname` = ? OR `sysName` = ?', array($host, $host));
                // If failed, try by IP
                if (!is_numeric($dev_cache[$host]['device_id'])) {
                    $ip = $host;
                    $ip_version = get_ip_version($ip);
                    if ($ip_version !== FALSE) {
                        if ($ip_version == 6 && preg_match('/::ffff:(\\d+\\.\\d+\\.\\d+\\.\\d+)/', $ip, $matches)) {
                            // IPv4 mapped to IPv6, like ::ffff:192.0.2.128
                            // See: http://jira.observium.org/browse/OBSERVIUM-1274
                            $ip = $matches[1];
                            $ip_version = 4;
                        } else {
                            if ($ip_version == 6) {
                                $ip = Net_IPv6::uncompress($ip, TRUE);
                            }
                        }
                        $address_count = dbFetchCell('SELECT COUNT(*) FROM `ipv' . $ip_version . '_addresses` WHERE `ipv' . $ip_version . '_address` = ?;', array($ip));
                        if ($address_count) {
                            $query = 'SELECT `device_id` FROM `ipv' . $ip_version . '_addresses` AS A, `ports` AS I WHERE A.`ipv' . $ip_version . '_address` = ? AND I.`port_id` = A.`port_id`';
                            // If more than one IP address, also check the status of the port.
                            if ($address_count > 1) {
                                $query .= " AND I.`ifOperStatus` = 'up'";
                            }
                            $dev_cache[$host]['device_id'] = dbFetchCell($query, array($ip));
                        }
                    }
                }
                break;
            case 'os':
            case 'version':
                if ($device_id = get_cache($host, 'device_id')) {
                    $dev_cache[$host][$value] = dbFetchCell('SELECT `' . $value . '` FROM `devices` WHERE `device_id` = ?', array($device_id));
                } else {
                    return NULL;
                }
                break;
            case 'os_group':
                $os = get_cache($host, 'os');
                $dev_cache[$host]['os_group'] = isset($GLOBALS['config']['os'][$os]['group']) ? $GLOBALS['config']['os'][$os]['group'] : '';
                break;
            default:
                return NULL;
        }
    }
    return $dev_cache[$host][$value];
}
开发者ID:Natolumin,项目名称:observium,代码行数:82,代码来源:syslog.inc.php

示例13: get_pseudowire_table

function get_pseudowire_table($vars)
{
    $sql = generate_pseudowire_query($vars);
    $entries = array();
    foreach (dbFetchRows($sql) as $entry) {
        if (!isset($GLOBALS['cache']['devices']['id'][$entry['device_id']])) {
            continue;
        }
        // Device hostname
        $entry['hostname'] = $GLOBALS['cache']['devices']['id'][$entry['device_id']]['hostname'];
        // Remote Peer
        $peer_addr = $entry['peer_addr'];
        $peer_addr_type = get_ip_version($peer_addr);
        if ($peer_addr_type && $entry['peer_device_id']) {
            if ($peer_addr_type == 6) {
                $peer_addr = Net_IPv6::uncompress($peer_addr, TRUE);
            }
            $peer_addr_type = 'ipv' . $peer_addr_type;
            //$entry['peer_addr']      = $peer_addr;
            //$entry['peer_addr_type'] = $peer_addr_type;
            if (!is_array($cache_pseudowires['ips'][$peer_addr])) {
                $cache_pseudowires['ips'][$peer_addr]['port_id'] = dbFetchCell('SELECT `port_id` FROM `' . $peer_addr_type . '_addresses` WHERE `' . $peer_addr_type . '_address` = ? ' . generate_query_values($GLOBALS['cache']['ports']['pseudowires'], 'port_id') . ' LIMIT 1;', array($peer_addr));
                if (!is_numeric($cache_pseudowires['ips'][$peer_addr]['port_id'])) {
                    // Separate entry for find correct port
                    $cache_pseudowires['ips'][$peer_addr]['port_id_fix'] = dbFetchCell('SELECT `port_id` FROM `' . $peer_addr_type . '_addresses` WHERE `' . $peer_addr_type . '_address` = ? ' . $GLOBALS['cache']['where']['ports_permitted'] . ' LIMIT 1;', array($peer_addr));
                }
                //$cache_pseudowires['ips'][$peer_addr]['host'] = $entry['reverse_dns'];
            }
            $entry['peer_port_id'] = $cache_pseudowires['ips'][$peer_addr]['port_id'];
            if (is_numeric($cache_pseudowires['ips'][$peer_addr]['port_id_fix'])) {
                // If we found port on remote device, than both devices in DB and will try to fix real port
                $peer_port_tmp = get_port_by_id_cache($cache_pseudowires['ips'][$peer_addr]['port_id_fix']);
                $peer_port_fix = dbFetchCell('SELECT `port_id` FROM `pseudowires` WHERE `device_id` = ? AND `pwID` = ? LIMIT 1;', array($peer_port_tmp['device_id'], $entry['pwID']));
                if (is_numeric($peer_port_fix)) {
                    $entry['peer_port_id'] = $peer_port_fix;
                } else {
                    $entry['peer_port_id'] = $cache_pseudowires['ips'][$peer_addr]['port_id_fix'];
                }
            }
            //r($entry['peer_port_id']);
            if ($entry['peer_port_id']) {
                $entry['peer_port'] = get_port_by_id_cache($entry['peer_port_id']);
                //r($entry['peer_port']);
                $entry['peer_device_id'] = $entry['peer_port']['device_id'];
                //r($entry['peer_device_id']);
                $entry['peer_device'] = device_by_id_cache($entry['peer_device_id']);
            }
        }
        $entry['hostname'] = $GLOBALS['cache']['devices']['id'][$entry['device_id']]['hostname'];
        // Attach hostname for sorting
        $entries[] = $entry;
    }
    // Sorting
    switch ($vars['sort_order']) {
        case 'desc':
            $sort_order = SORT_DESC;
            $sort_neg = SORT_ASC;
            break;
        case 'reset':
            unset($vars['sort'], $vars['sort_order']);
            // no break here
        // no break here
        default:
            $sort_order = SORT_ASC;
            $sort_neg = SORT_DESC;
    }
    switch ($vars['sort']) {
        case 'device':
            $entries = array_sort_by($entries, 'hostname', $sort_order, SORT_STRING);
            break;
        case 'pwid':
            $entries = array_sort_by($entries, 'pwID', $sort_order, SORT_NUMERIC);
            break;
        case 'pwtype':
            $entries = array_sort_by($entries, 'pwType', $sort_order, SORT_STRING, 'pwPsnType', $sort_order, SORT_STRING);
            //$pws = array_sort_by($pws, 'pwType',  $sort_order, SORT_STRING);
            break;
        case 'peer_addr':
            $entries = array_sort_by($entries, 'peer_addr', $sort_order, SORT_NUMERIC);
            break;
        case 'event':
            $entries = array_sort_by($entries, 'event', $sort_order, SORT_STRING);
            break;
        case 'uptime':
            $entries = array_sort_by($entries, 'pwUptime', $sort_order, SORT_NUMERIC);
            break;
        case 'last_change':
            $entries = array_sort_by($entries, 'last_change', $sort_neg, SORT_NUMERIC);
            break;
        case 'status':
            $entries = array_sort_by($entries, 'pwOperStatus', $sort_order, SORT_STRING);
            break;
        default:
            // Not sorted
    }
    return $entries;
}
开发者ID:Natolumin,项目名称:observium,代码行数:97,代码来源:pseudowire.inc.php

示例14: get_port_id_by_ip_cache

function get_port_id_by_ip_cache($device, $ip)
{
    global $cache;
    $ip_version = get_ip_version($ip);
    if (is_array($device) && isset($device['device_id'])) {
        $device_id = $device['device_id'];
    } else {
        if (is_numeric($device)) {
            $device_id = $device;
        }
    }
    if (!isset($device_id) || !$ip_version) {
        print_error("Invalid arguments passed into function get_port_id_by_ip_cache(). Please report to developers.");
        return FALSE;
    }
    if ($ip_version == 6) {
        $ip = Net_IPv6::uncompress($ip, TRUE);
    }
    if (isset($cache['port_ip'][$device_id][$ip])) {
        return $cache['port_ip'][$device_id][$ip];
    }
    $ips = dbFetchRows('SELECT `port_id`, `ifOperStatus`, `ifAdminStatus` FROM `ipv' . $ip_version . '_addresses`
                      LEFT JOIN `ports` USING(`port_id`)
                      WHERE `deleted` = 0 AND `device_id` = ? AND `ipv' . $ip_version . '_address` = ?', array($device_id, $ip));
    if (count($ips) === 1) {
        // Simple
        $port = current($ips);
        //return $port['port_id'];
    } else {
        foreach ($ips as $entry) {
            if ($entry['ifAdminStatus'] == 'up' && $entry['ifOperStatus'] == 'up') {
                // First UP entry
                $port = $entry;
                break;
            } else {
                if ($entry['ifAdminStatus'] == 'up') {
                    // Admin up, but port down or other state
                    $ips_up[] = $entry;
                } else {
                    // Admin down
                    $ips_down[] = $entry;
                }
            }
        }
        if (!isset($port)) {
            if ($ips_up) {
                $port = current($ips_up);
            } else {
                $port = current($ips_down);
            }
        }
    }
    $cache['port_ip'][$device_id][$ip] = $port['port_id'] ? $port['port_id'] : FALSE;
    return $cache['port_ip'][$device_id][$ip];
}
开发者ID:Natolumin,项目名称:observium,代码行数:55,代码来源:entities.inc.php

示例15: rtrim

if (!isset($config['mib_dir'])) {
    $config['mib_dir'] = $config['install_dir'] . '/mibs';
} else {
    $config['mib_dir'] = rtrim($config['mib_dir'], ' /');
}
// Old variable backwards compatibility
if (isset($config['rancid_configs']) && !is_array($config['rancid_configs'])) {
    $config['rancid_configs'] = array($config['rancid_configs']);
}
if (isset($config['auth_ldap_group']) && !is_array($config['auth_ldap_group'])) {
    $config['auth_ldap_group'] = array($config['auth_ldap_group']);
}
// Database currently stores v6 networks non-compressed, check for any compressed subnet and expand them
foreach ($config['ignore_common_subnet'] as $index => $content) {
    if (strstr($content, ':') !== FALSE) {
        $config['ignore_common_subnet'][$index] = Net_IPv6::uncompress($content);
    }
}
// Disable nonexistant features in CE, do not try to turn on, it will not give effect
if (OBSERVIUM_EDITION == 'community') {
    $config['enable_billing'] = 0;
    $config['poller-wrapper']['alerter'] = FALSE;
}
// If we're on SSL, let's properly detect it
// DOCME needs phpdoc block
// TESTME needs unit testing
// MOVEME to includes/common.inc.php
function is_ssl()
{
    if (isset($_SERVER['HTTPS'])) {
        if ('on' == strtolower($_SERVER['HTTPS'])) {
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:31,代码来源:definitions.inc.php


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