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


PHP Addresses::count_subnet_addresses方法代码示例

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


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

示例1: _

print _('Subnet');
?>
</td>
        <td><?php 
print $Subnets->transform_to_dotted($subnet->subnet) . "/{$subnet->mask} ({$subnet->description})";
?>
</td>
    </tr>
    <!-- Mask -->
    <tr>
        <td class="middle"><?php 
print _('Number of IP addresses');
?>
</td>
        <td><?php 
print $Addresses->count_subnet_addresses($subnet->id);
?>
</td>
    </tr>
    </table>

    <!-- warning -->
    <div class="alert alert-warning">
    <?php 
print _('Truncating network will remove all IP addresses, that belong to selected subnet!');
?>
    </div>
</div>

<!-- footer -->
<div class="pFooter">
开发者ID:mwodz,项目名称:phpipam,代码行数:31,代码来源:truncate.php

示例2: foreach

 //check if subnet has slaves and set slaves flag true/false
 $slaves = $Subnets->has_slaves($s->id) ? true : false;
 # fetch all addresses and calculate usage
 if ($slaves) {
     $addresses = $Addresses->fetch_subnet_addresses_recursive($s->id, false);
     $slave_subnets = (array) $Subnets->fetch_subnet_slaves($s->id);
     // save count
     $addresses_cnt = gmp_strval(sizeof($addresses));
     # full ?
     if (sizeof($slave_subnets) > 0) {
         foreach ($slave_subnets as $ss) {
             if ($ss->isFull == 1) {
                 # calculate max
                 $max_hosts = $Subnets->get_max_hosts($ss->mask, $Subnets->identify_address($ss->subnet), true);
                 # count
                 $count_hosts = $Addresses->count_subnet_addresses($ss->id);
                 # add
                 $addresses_cnt = gmp_strval(gmp_add($addresses_cnt, gmp_sub($max_hosts, $count_hosts)));
             }
         }
     }
     $subnet_usage = $Subnets->calculate_subnet_usage($addresses_cnt, $s->mask, $s->subnet, $s->isFull);
     //Calculate free/used etc
 } else {
     # fetch addresses in subnet
     $addresses_cnt = $Addresses->count_subnet_addresses($s->id);
     # calculate usage
     $subnet_usage = $Subnets->calculate_subnet_usage($addresses_cnt, $s->mask, $s->subnet, $s->isFull);
 }
 # set additional threshold parameters
 $subnet_usage['usedhosts_percent'] = gmp_strval(gmp_sub(100, (int) round($subnet_usage['freehosts_percent'], 0)));
开发者ID:korhaldragonir,项目名称:phpipam,代码行数:31,代码来源:threshold.php

示例3: Subnets

# initialize objects
$Database = new Database_PDO();
$Subnets = new Subnets($Database);
$Addresses = new Addresses($Database);
$Tools = new Tools($Database);
$Result = new Result();
# fetch all subnets
$all_subnets = $Tools->fetch_all_objects("subnets");
# loop and check usage for each, make sure it does not have any parent
foreach ($all_subnets as $k => $s) {
    // marked as full should not be checked
    if ($s->isFull != 1) {
        // parent check
        if (!$Subnets->has_slaves($s->id)) {
            // count number of addresses
            $cnt = $Addresses->count_subnet_addresses($s->id);
            // calculate usage
            $usage = $Subnets->calculate_subnet_usage($cnt, $s->mask, $s->subnet, $s->isFull);
            // if more than $threshold report
            if ($usage['freehosts_percent'] < 100 - $limit) {
                // this subnet has high usage, save it to array
                $out[$k]['subnet'] = $Subnets->transform_address($s->subnet, "dotted") . "/" . $s->mask;
                $out[$k]['description'] = $s->description;
                $out[$k]['usage'] = $usage;
            }
        }
    }
}
# any fount
if (isset($out)) {
    // do something with output
开发者ID:korhaldragonir,项目名称:phpipam,代码行数:31,代码来源:find_full_subnets.php

示例4:

         $master = false;
         print "\t<td><a href='" . create_link("subnets", $f['sectionId'], $f['subnetId']) . "'><i class='fa fa-sfolder fa-sitemap' ></i>" . $Subnets->transform_to_dotted($f['subnet']) . "/{$f['mask']}</a></td>";
     }
 }
 print "\t<td>{$f['description']}</td>";
 print "\t<td><a href='" . create_link("subnets", $f['sectionId']) . "'>{$f['section']}</a></td>";
 # get vlan info
 if (strlen($f['vlanId']) > 0 && $f['vlanId'] != 0) {
     $vlan = $Tools->fetch_object("vlans", "vlanId", $f['vlanId']);
     print "\t<td>{$vlan->number}</td>";
 } else {
     print "\t<td>/</td>";
 }
 # usage
 if (!$master) {
     $address_count = $Addresses->count_subnet_addresses($f['subnetId']);
     $subnet_usage = $Subnets->calculate_subnet_usage(gmp_strval($address_count), $f['mask'], $f['subnet']);
 }
 # add address
 if ($master === true || $f['isFolder'] == 1 || $Subnets->reformat_number($subnet_usage['freehosts']) == "0") {
     $disabled = "disabled";
 } else {
     $disabled = "";
 }
 # remove
 print "\t<td class='actions'>";
 print "\t<div class='btn-group'>";
 print "\t<a class='btn btn-xs btn-default modIPaddr btn-success {$disabled}' href='' data-container='body' rel='tooltip' title='" . _('Add new IP address') . "' data-subnetId='{$f['subnetId']}' data-action='add' data-id=''><i class='fa fa-plus'></i></a>";
 print "\t<a class='btn btn-xs btn-default editFavourite' data-subnetId='{$f['subnetId']}' data-action='remove' data-from='widget'><i class='fa fa-star favourite-{$f['subnetId']}' rel='tooltip' title='" . _('Click to remove from favourites') . "'></i></a>";
 print "\t</div>";
 print " </td>";
开发者ID:netbuild,项目名称:phpipam,代码行数:31,代码来源:favourite_subnets.php


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