本文整理汇总了PHP中Subnets::transform_to_dotted方法的典型用法代码示例。如果您正苦于以下问题:PHP Subnets::transform_to_dotted方法的具体用法?PHP Subnets::transform_to_dotted怎么用?PHP Subnets::transform_to_dotted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subnets
的用法示例。
在下文中一共展示了Subnets::transform_to_dotted方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
# folder?
if ($master_subnet['isFolder'] == 1) {
$master_text = "<i class='fa fa-folder-o fa fa-gray'></i> {$master_subnet['description']}";
} else {
$master_text = "{$master_subnet['ip']}/{$master_subnet['mask']}";
}
}
//tr
print '<tr class="subnetSearch" subnetId="' . $line['id'] . '" sectionName="' . $section['name'] . '" sectionId="' . $section['id'] . '" link="' . $section['name'] . '|' . $line['id'] . '">' . "\n";
//section
print ' <td>' . $section['name'] . '</td>' . "\n";
//folder?
if ($line['isFolder'] == 1) {
print ' <td><a href="' . create_link("subnets", $line['sectionId'], $line['id']) . '"><i class="fa fa-folder-o fa fa-gray"></i> ' . $line['description'] . '</a></td>' . "\n";
} else {
print ' <td><a href="' . create_link("subnets", $line['sectionId'], $line['id']) . '">' . $Subnets->transform_to_dotted($line['subnet']) . '/' . $line['mask'] . '</a></td>' . "\n";
}
print ' <td><a href="' . create_link("subnets", $line['sectionId'], $line['id']) . '">' . $line['description'] . '</a></td>' . "\n";
//master
print ' <td>' . $master_text . '</td>' . "\n";
//vlan
print ' <td>' . @$vlan['number'] . '</td>' . "\n";
//requests
print ' <td>' . _($line['allowRequests']) . '</td>' . "\n";
# custom fields
if (sizeof($custom_subnet_fields) > 0) {
foreach ($custom_subnet_fields as $field) {
if (!in_array($field['name'], $hidden_subnet_fields)) {
$line[$field['name']] = $Result->create_links($line[$field['name']], $field['type']);
print "\t<td class='hidden-xs hidden-sm'>" . $line[$field['name']] . "</td>";
}
示例2: _
print _('Truncate subnet');
?>
</div>
<!-- content -->
<div class="pContent">
<table class="table table-noborder table-condensed">
<!-- subnet -->
<tr>
<td class="middle"><?php
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>
示例3: explode
# format and verify each record
foreach ($allSubnets as $subnet) {
//get sequential number
$m = str_replace("subnet-", "", $subnet);
//reformat subnet
$_temp = explode("/", $_POST['subnet-' . $m]);
//set subnet details for importing
$subnet_import['subnet'] = $Subnets->transform_to_decimal($_temp[0]);
$subnet_import['mask'] = $_temp[1];
$subnet_import['sectionId'] = $_POST['section-' . $m];
$subnet_import['description'] = $_POST['description-' . $m];
$subnet_import['vlanId'] = $_POST['vlan-' . $m];
$subnet_import['vrfId'] = $_POST['vrf-' . $m];
$subnet_import['showName'] = $_POST['showName-' . $m];
//cidr
if (strlen($err = $Subnets->verify_cidr($Subnets->transform_to_dotted($subnet_import['subnet']) . "/" . $subnet_import['mask'])) > 5) {
$errors[] = $err;
} else {
if (strlen($err = $Subnets->verify_subnet_overlapping($subnet_import['sectionId'], $Subnets->transform_to_dotted($subnet_import['subnet']) . "/" . $subnet_import['mask'], $subnet_import['vrfId'])) > 5) {
$errors[] = $err;
} else {
$subnets_to_insert[] = $subnet_import;
}
}
}
# print errors if they exist or success
if (isset($errors)) {
print '<div class="alert alert-danger alert-absolute">' . _('Please fix the following errors before inserting') . ':<hr>' . "\n";
foreach ($errors as $line) {
print $line . '<br>';
}
示例4: time
print "\t<td colspan='{$colspan['unused']}' class='unused'>{$unused['ip']} ({$unused['hosts']})</td>";
print "</tr>";
}
}
#
# print IP address
#
# ip - range
if (@$addresses[$n]->class == "compressed-range") {
print "<tr class='dhcp'>";
print "\t<td>";
# status icon
if ($subnet['pingSubnet'] == "1") {
print "\t\t<span class='status status-padded'></span>";
}
print $Subnets->transform_to_dotted($addresses[$n]->ip_addr) . ' - ' . $Subnets->transform_to_dotted($addresses[$n]->stopIP) . " (" . $addresses[$n]->numHosts . ")";
print $Addresses->address_type_format_tag($addresses[$n]->state);
print "\t</td>";
print "\t<td>" . $Addresses->address_type_index_to_type($addresses[$n]->state) . " (" . _("range") . ")</td>";
print "\t<td>" . $addresses[$n]->description . "</td>";
if ($colspan['dhcp'] != 0) {
print "\t<td colspan='{$colspan['dhcp']}' class='unused'></td>";
}
// tr ends after!
} else {
print "<tr>";
# status icon
if ($subnet['pingSubnet'] == "1") {
//calculate
$tDiff = time() - strtotime($addresses[$n]->lastSeen);
if ($addresses[$n]->excludePing == "1") {
示例5: foreach
$i = 1;
foreach ($firewallZone->network as $network) {
print '<tr>';
if ($i === 1) {
print '<td rowspan="' . $rowspan . '" style="width:150px;vertical-align:top">Networks</td>';
}
print '<td>';
print '<a class="btn btn-xs btn-danger editNetwork" style="margin-right:5px;" alt="' . _('Delete Network') . '" title="' . _('Delete Network') . '" data-action="delete" data-zoneId="' . $firewallZone->id . '" data-subnetId="' . $network->subnetId . '">';
print '<span><i class="fa fa-close"></i></span>';
print "</a>";
if ($network->subnetIsFolder == 1) {
print 'Folder: ' . $network->subnetDescription . '</td>';
} else {
# display network information with or without description
if ($network->subnetDescription) {
print $Subnets->transform_to_dotted($network->subnet) . '/' . $network->subnetMask . ' (' . $network->subnetDescription . ')</td>';
} else {
print $Subnets->transform_to_dotted($network->subnet) . '/' . $network->subnetMask . '</td>';
}
}
print '</tr>';
$i++;
}
}
?>
</table>
</div>
</form>
示例6: implode
}
$query[] = 'order by `ip_addr` ASC;';
//join
$query = implode("\n", $query);
}
# fetch records
$ipaddresses = $Database->getObjectsQuery($query);
# try to update dns records
foreach ($ipaddresses as $ip) {
# fetch subnet
$subnet = $Subnets->fetch_subnet("id", $ip->subnetId);
$nsid = $subnet === false ? false : $subnet->nameserverId;
# try to resolve
$hostname = $DNS->resolve_address($ip->ip_addr, null, true, $nsid);
# update if change
if ($hostname['name'] != $Subnets->transform_to_dotted($ip->ip_addr)) {
# values
$values = array("dns_name" => $hostname['name'], "id" => $ip->id);
# execute
if (!$Admin->object_modify("ipaddresses", "edit", "id", $values)) {
$Result->show_cli("Failed to update address " . $Subnets->transform_to_dotted($ip->ip_addr));
}
# set text
$res[] = 'updated ip address ' . $Subnets->transform_to_dotted($ip->ip_addr) . ' with hostname ' . $hostname['name'];
}
}
# if verbose print result so it can be emailed via cron!
if ($resolve_config['verbose'] == 1) {
foreach ($res as $line) {
print $line . "\n";
}
示例7: _
<div class="pContent">
<form id="editSubnetDetails">
<table class="editSubnetDetails table table-noborder table-condensed">
<!-- name -->
<tr>
<td class="middle"><?php
print _('Subnet');
?>
</td>
<td>
<?php
# set CIDR
if (isset($subnet_old_temp['subnet'])) {
$cidr = $Subnets->transform_to_dotted($subnet_old_temp['subnet']) . '/' . ($subnet_old_temp['mask'] + 1);
}
//for nested
if (@$_POST['location'] == "ipcalc") {
$cidr = $_POST['subnet'] . '/' . $_POST['bitmask'];
}
//from ipcalc
if ($_POST['action'] != "add") {
$cidr = $Subnets->transform_to_dotted($subnet_old_details['subnet']) . '/' . $subnet_old_details['mask'];
}
//editing existing
?>
<input type="text" class="form-control input-sm input-w-200" name="subnet" placeholder="<?php
print _('subnet in CIDR');
?>
" value="<?php
示例8:
if (!is_numeric($_POST['subnetId'])) {
$Result->show("danger", _("Invalid ID"), true, true);
}
# get subnet details
$subnet = $Subnets->fetch_subnet(null, $_POST['subnetId']);
# verify that user has write permissions for subnet
$subnetPerm = $Subnets->check_permission($User->user, $subnet->id);
if ($subnetPerm < 3) {
$Result->show("danger", _('You do not have permissions to resize subnet') . '!', true, true);
}
# check if it has slaves - if yes it cannot be splitted!
if ($Subnets->has_slaves($subnet->id)) {
$Result->show("danger", _('Only subnets that have no nested subnets can be splitted') . "!", true, true);
}
# calculate max mask
$max_new_mask = $Subnets->identify_address($Subnets->transform_to_dotted($subnet->subnet)) == "IPv4" ? 32 : 128;
# die if too small
if ($max_new_mask < $subnet->mask) {
$Result->show("danger", _("Subnet too small to be splitted"), true, true);
}
$n = 2;
# step
$m = 0;
# array id
//set mask options
for ($mask = $subnet->mask + 1; $mask <= $max_new_mask; $mask++) {
# set vars
$opts[$m]['mask'] = $mask;
$opts[$m]['number'] = $n;
$opts[$m]['max'] = $Subnets->get_max_hosts($mask, $Subnets->identify_address($Subnets->transform_to_dotted($subnet->subnet)));
# next
示例9: die
}
}
/**
* Select how to scan based on scan type.
*
* if ping/pear make threads, if fping than just check since it has built-in threading !
*/
# fping
if ($Scan->settings->scanPingType == "fping" && $argv[1] == "discovery") {
# fetch subnet
$subnet = $Subnets->fetch_subnet(null, $argv[2]);
$subnet !== false ?: die(json_encode(array("status" => 1, "error" => "Invalid subnet ID provided")));
//set exit flag to true
$Scan->ping_set_exit(false);
# set cidr
$subnet_cidr = $Subnets->transform_to_dotted($subnet->subnet) . "/" . $subnet->mask;
# execute
$retval = $Scan->ping_address_method_fping_subnet($subnet_cidr);
# errors
if ($retval == 3) {
die(json_encode(array("status" => 1, "error" => "invalid command line arguments")));
}
if ($retval == 4) {
die(json_encode(array("status" => 1, "error" => "system call failure")));
}
# parse result
if (sizeof(@$Scan->fping_result) == 0) {
die(json_encode(array("status" => 0, "values" => array("alive" => null))));
} else {
//check each line
foreach ($Scan->fping_result as $l) {
示例10:
// columns
if ($mapping->indicator == 0) {
print '<td><span class="fa fa-home" title="' . _('Own Zone') . '"></span></td>';
} else {
print '<td><span class="fa fa-group" title="' . _('Customer Zone') . '"></span></td>';
}
print '<td>' . $mapping->zone . '</td>';
print '<td>' . $mapping->alias . '</td>';
print '<td>' . $mapping->description . '</td>';
print '<td>' . $mapping->interface . '</td>';
//print '<td>'.$Subnets->transform_to_dotted($mapping->subnet).'/'.$mapping->subnetMask.'</td>';
print '<td>';
// check if there is a subnetId and if it is convertable to dotted decimal
if ($mapping->subnetId && $mapping->subnetDescription) {
if (!$mapping->subnetIsFolder) {
print '<a href="' . create_link("subnets", $mapping->sectionId, $mapping->subnetId) . '">' . $Subnets->transform_to_dotted($mapping->subnet) . '/' . $mapping->subnetMask . '</a>';
print '</td><td>';
print '<a href="' . create_link("subnets", $mapping->sectionId, $mapping->subnetId) . '">' . $mapping->subnetDescription . '</a>';
} else {
print '<a href="' . create_link("subnets", $mapping->sectionId, $mapping->subnetId) . '">Folder</a>';
print '</td><td>';
print '<a href="' . create_link("subnets", $mapping->sectionId, $mapping->subnetId) . '">' . $mapping->subnetDescription . '</a>';
}
} else {
print '</td><td>';
}
?>
</td>
<td><a href="<?php
create_link('tools', 'vlan', $mapping->domainId, $mapping->vlanId);
?>
示例11: date
$User->check_user_session();
//set filename
$filename = "phpipam_hosts_" . date("Y-m-d");
//fetch all addresses with hostname set
$hosts = $Tools->fetch_addresses_for_export();
//loop
if (sizeof($hosts) > 0) {
//details
$m = 0;
foreach ($hosts as $host) {
//fetch subnet and section details on change!
if (@$hosts[$m - 1]->subnetId != $hosts[$m]->subnetId) {
$subnet = (array) $Subnets->fetch_subnet(null, $host->subnetId);
$section = (array) $Sections->fetch_section(null, $subnet['sectionId']);
//first print subnet and section details
$res[] = "# {$subnet['description']} (" . $Subnets->transform_to_dotted($subnet['subnet']) . "/{$subnet['mask']}) - {$section['description']}";
}
//than address details
$diff = 17 - strlen($Subnets->transform_to_dotted($host->ip_addr));
//for print offset
$diff > 0 ?: ($diff = 3);
//IPv6 print offset
$res[] = $Subnets->transform_to_dotted($host->ip_addr) . str_repeat(" ", $diff) . "{$host->dns_name}";
//break
if ($hosts[$m]->subnetId != @$hosts[$m + 1]->subnetId) {
$res[] = "";
}
$m++;
//next index
}
}
示例12: foreach
continue;
}
// grab IP addresses
$ipaddresses = $Addresses->fetch_subnet_addresses($subnet['id']);
if (sizeof($ipaddresses) == 0) {
continue;
}
foreach ($ipaddresses as $ip) {
//cast
$ip = (array) $ip;
if (isset($_GET['section']) && $_GET['section'] == "on") {
$worksheet->write($lineCount, $rowCount, $section['name'], $format_text);
$rowCount++;
}
if (isset($_GET['ip_addr']) && $_GET['ip_addr'] == "on") {
$worksheet->write($lineCount, $rowCount, $Subnets->transform_to_dotted($ip['ip_addr']), $format_text);
$rowCount++;
}
if (isset($_GET['dns_name']) && $_GET['dns_name'] == "on") {
$worksheet->write($lineCount, $rowCount, $ip['dns_name'], $format_text);
$rowCount++;
}
if (isset($_GET['description']) && $_GET['description'] == "on") {
$worksheet->write($lineCount, $rowCount, $ip['description'], $format_text);
$rowCount++;
}
if (isset($_GET['subnet']) && $_GET['subnet'] == "on") {
$worksheet->write($lineCount, $rowCount, $subnet['ip'] . "/" . $subnet['mask'], $format_text);
$rowCount++;
}
if (isset($_GET['state']) && $_GET['state'] == "on") {
示例13: foreach
print "\t<th>" . _('VLAN') . "</th>";
print "\t<th></th>";
print "</tr>";
# subnets
foreach ($fsubnets as $f) {
# must be either subnet or folder
if (sizeof($f) > 0) {
print "<tr class='favSubnet-{$f['subnetId']}'>";
if ($f['isFolder'] == 1) {
$master = true;
print "\t<td><a href='" . create_link("folder", $f['sectionId'], $f['subnetId']) . "'><i class='fa fa-sfolder fa-folder'></i> {$f['description']}</a></td>";
} else {
//master?
if ($Subnets->has_slaves($f['subnetId'])) {
$master = true;
print "\t<td><a href='" . create_link("subnets", $f['sectionId'], $f['subnetId']) . "'><i class='fa fa-sfolder fa-folder-o'></i>" . $Subnets->transform_to_dotted($f['subnet']) . "/{$f['mask']}</a></td>";
} else {
$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
示例14:
<div class="pContent">
<!-- form -->
<form id="networkEdit">
<!-- table -->
<table class="table table-noborder table-condensed">
<?php
if ($_POST['action'] == 'delete') {
?>
<!-- delete warning and network information-->
<tr>
<td style="width:150px;">
<?php
$subnet = $Subnets->fetch_subnet('id', $_POST['subnetId']);
# display network information with or without description
if ($subnet->description) {
$network = $Subnets->transform_to_dotted($subnet->subnet) . '/' . $subnet->mask . ' (' . $subnet->description . ')';
} else {
$network = $Subnets->transform_to_dotted($subnet->subnet) . '/' . $subnet->mask;
}
$Result->show("warning", "<strong>" . _('Warning') . ":</strong><br>" . _("You are about to remove the following Network from the firewall zone:<br>" . $network), false);
?>
<input type="hidden" name="masterSubnetId" value="<?php
print $_POST['subnetId'];
?>
">
</td>
<?php
} else {
# add a network to the zone
?>
<tr>
示例15: StdClass
$Result->show("danger", _("Temporary sharing disabled"), true, true);
}
if ($_POST['type'] != "subnets" && $_POST['type'] != "ipaddresses") {
$Result->show("danger", _("Invalid type"), true, true);
}
if (!is_numeric($_POST['id'])) {
$Result->show("danger", _("Invalid ID"), true, true);
}
//fetch object details
$object = $Tools->fetch_object($_POST['type'], "id", $_POST['id']);
# set share details
$share = new StdClass();
//set details
if ($_POST['type'] == "subnets") {
$tmp[] = "Share type: subnet";
$tmp[] = $Subnets->transform_to_dotted($object->subnet) . "/{$object->mask}";
$tmp[] = $object->description;
} else {
$tmp[] = "Share type: IP address";
$tmp[] = $Subnets->transform_to_dotted($object->ip_addr);
$tmp[] = $object->description;
}
$share->details = implode("<br>", $tmp);
//set code and timeframe
@($share->code = md5(time()));
$share->validity = date("Y-m-d H:i:s", strtotime("+1 day"));
# set url for printing
$url = $Result->createURL() . create_link("temp_share", $share->code);
?>