本文整理汇总了PHP中Subnets::is_subnet_inside_subnet方法的典型用法代码示例。如果您正苦于以下问题:PHP Subnets::is_subnet_inside_subnet方法的具体用法?PHP Subnets::is_subnet_inside_subnet怎么用?PHP Subnets::is_subnet_inside_subnet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subnets
的用法示例。
在下文中一共展示了Subnets::is_subnet_inside_subnet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cmp_subnets
}
}
# sort by mask size
function cmp_subnets($a, $b)
{
if ($a['subnet_dec'] == $b['subnet_dec']) {
return 0;
}
return $a['subnet_dec'] < $b['subnet_dec'] ? -1 : 1;
}
usort($subnets_all, "cmp_subnets");
# recompute parents
foreach ($subnets_all as $k => $s) {
foreach ($subnets_all as $sb) {
if ($sb['subnet_dec'] !== $s['subnet_dec'] && $sb['mask'] !== $s['mask']) {
if ($Subnets->is_subnet_inside_subnet($s['subnet'], $sb['subnet'])) {
$subnets_all[$k]['master'] = $sb['subnet'];
}
}
}
}
# import each
if (isset($subnets_all)) {
foreach ($subnets_all as $s) {
# set new POST
$_POST = $s;
# create csrf token
$_POST['csrf_cookie'] = $User->csrf_cookie("create", "subnet");
# permissions
$subnet['permissions'] = $section->permissions;
# check for master
示例2: foreach
print "</tr>";
print "<tbody id=device-{$deviceid}>";
foreach ($query_result as $ip) {
//get bitmask
foreach ($masks as $k => $n) {
if ($n->netmask == $ip['mask']) {
$ip['bitmask'] = $k;
break;
}
}
$overlap = false;
// check for overlapping
if (isset($subnet)) {
if ($subnet->isFolder != "1") {
// check
if ($Subnets->is_subnet_inside_subnet("{$ip['subnet']}/{$ip['bitmask']}", $Subnets->transform_address($subnet->subnet, "dotted") . "/" . $subnet->mask) === false) {
$overlap = true;
}
// same mask
if ($ip['subnet'] == $Subnets->transform_address($subnet->subnet, "dotted") && $ip['bitmask'] == $subnet->mask) {
$overlap = true;
}
}
}
// check overlapping
if ($overlap === false) {
$dc++;
print "<tr id='tr-{$m}'>";
//ip
print "<td>{$ip['subnet']}/{$ip['bitmask']}</td>";
//section, description, hidden