summaryrefslogtreecommitdiffstats
path: root/usr/local/www/status_dhcpv6_leases.php
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-05-15 11:40:50 +0545
committerPhil Davis <phil.davis@inf.org>2015-05-15 11:40:50 +0545
commit42b0c92129b93ca6d182f4904ec92708c9a8c750 (patch)
tree7d396b83ba7920878bb6e8f42ae5907e9518c003 /usr/local/www/status_dhcpv6_leases.php
parentc8f1c7bd70cd156f23a59400e5c738ef8bf5281b (diff)
downloadpfsense-42b0c92129b93ca6d182f4904ec92708c9a8c750.zip
pfsense-42b0c92129b93ca6d182f4904ec92708c9a8c750.tar.gz
Code style WWW Status
Diffstat (limited to 'usr/local/www/status_dhcpv6_leases.php')
-rw-r--r--usr/local/www/status_dhcpv6_leases.php107
1 files changed, 57 insertions, 50 deletions
diff --git a/usr/local/www/status_dhcpv6_leases.php b/usr/local/www/status_dhcpv6_leases.php
index d91b803..c82a93a 100644
--- a/usr/local/www/status_dhcpv6_leases.php
+++ b/usr/local/www/status_dhcpv6_leases.php
@@ -111,8 +111,9 @@ function adjust_gmt($dt) {
$dhcpdv6 = $config['dhcpdv6'];
foreach ($dhcpdv6 as $dhcpv6leaseinlocaltime) {
$dhcpv6leaseinlocaltime = $dhcpv6leaseinlocaltime['dhcpv6leaseinlocaltime'];
- if ($dhcpv6leaseinlocaltime == "yes")
+ if ($dhcpv6leaseinlocaltime == "yes") {
break;
+ }
}
}
@@ -124,17 +125,19 @@ function adjust_gmt($dt) {
$offset = $this_tz->getOffset($dhcp_lt);
$ts = $ts + $offset;
return strftime("%Y/%m/%d %I:%M:%S%p", $ts);
- }
- else
+ } else {
return strftime("%Y/%m/%d %H:%M:%S", $ts);
+ }
}
function remove_duplicate($array, $field) {
- foreach ($array as $sub)
+ foreach ($array as $sub) {
$cmp[] = $sub[$field];
+ }
$unique = array_unique(array_reverse($cmp,true));
- foreach ($unique as $k => $rien)
+ foreach ($unique as $k => $rien) {
$new[] = $array[$k];
+ }
return $new;
}
@@ -208,12 +211,12 @@ while($i < $leases_count) {
$f = 0;
$fcount = count($data);
/* with less then 12 fields there is nothing useful */
- if($fcount < 12) {
+ if ($fcount < 12) {
$i++;
continue;
}
while($f < $fcount) {
- switch($data[$f]) {
+ switch ($data[$f]) {
case "failover":
$pools[$p]['name'] = $data[$f+2];
$pools[$p]['mystate'] = $data[$f+7];
@@ -285,7 +288,7 @@ while($i < $leases_count) {
$f = $f+3;
break;
case "binding":
- switch($data[$f+2]) {
+ switch ($data[$f+2]) {
case "active":
$entry['act'] = "active";
break;
@@ -311,11 +314,11 @@ while($i < $leases_count) {
$f = $f+2;
break;
case "client-hostname":
- if($data[$f+1] <> "") {
+ if ($data[$f+1] <> "") {
$entry['hostname'] = preg_replace('/"/','',$data[$f+1]);
} else {
$hostname = gethostbyaddr($entry['ip']);
- if($hostname <> "") {
+ if ($hostname <> "") {
$entry['hostname'] = $hostname;
}
}
@@ -338,23 +341,23 @@ while($i < $leases_count) {
$is_prefix = false;
}
-if(count($leases) > 0) {
+if (count($leases) > 0) {
$leases = remove_duplicate($leases,"ip");
}
-if(count($prefixes) > 0) {
+if (count($prefixes) > 0) {
$prefixes = remove_duplicate($prefixes,"prefix");
}
-if(count($pools) > 0) {
+if (count($pools) > 0) {
$pools = remove_duplicate($pools,"name");
asort($pools);
}
-foreach($config['interfaces'] as $ifname => $ifarr) {
+foreach ($config['interfaces'] as $ifname => $ifarr) {
if (is_array($config['dhcpdv6'][$ifname]) &&
- is_array($config['dhcpdv6'][$ifname]['staticmap'])) {
- foreach($config['dhcpdv6'][$ifname]['staticmap'] as $static) {
+ is_array($config['dhcpdv6'][$ifname]['staticmap'])) {
+ foreach ($config['dhcpdv6'][$ifname]['staticmap'] as $static) {
$slease = array();
$slease['ip'] = $static['ipaddrv6'];
$slease['type'] = "static";
@@ -374,11 +377,12 @@ foreach($config['interfaces'] as $ifname => $ifarr) {
}
}
-if ($_GET['order'])
+if ($_GET['order']) {
usort($leases, "leasecmp");
+}
/* only print pool status when we have one */
-if(count($pools) > 0) {
+if (count($pools) > 0) {
?>
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp leases">
<tr>
@@ -389,18 +393,17 @@ if(count($pools) > 0) {
<td class="listhdrr"><?=gettext("Since"); ?></a></td>
</tr>
<?php
-foreach ($pools as $data) {
- echo "<tr>\n";
- echo "<td class=\"listlr\">{$fspans}{$data['name']}{$fspane}</td>\n";
- echo "<td class=\"listr\">{$fspans}{$data['mystate']}{$fspane}</td>\n";
- echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['mydate']) . "{$fspane}</td>\n";
- echo "<td class=\"listr\">{$fspans}{$data['peerstate']}{$fspane}</td>\n";
- echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['peerdate']) . "{$fspane}</td>\n";
- echo "<td class=\"list\" valign=\"middle\" width=\"17\">&nbsp;</td>\n";
- echo "<td class=\"list\" valign=\"middle\" width=\"17\">&nbsp;</td>\n";
- echo "</tr>\n";
-}
-
+ foreach ($pools as $data) {
+ echo "<tr>\n";
+ echo "<td class=\"listlr\">{$fspans}{$data['name']}{$fspane}</td>\n";
+ echo "<td class=\"listr\">{$fspans}{$data['mystate']}{$fspane}</td>\n";
+ echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['mydate']) . "{$fspane}</td>\n";
+ echo "<td class=\"listr\">{$fspans}{$data['peerstate']}{$fspane}</td>\n";
+ echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['peerdate']) . "{$fspane}</td>\n";
+ echo "<td class=\"list\" valign=\"middle\" width=\"17\">&nbsp;</td>\n";
+ echo "<td class=\"list\" valign=\"middle\" width=\"17\">&nbsp;</td>\n";
+ echo "</tr>\n";
+ }
?>
</table>
@@ -412,15 +415,15 @@ foreach ($pools as $data) {
<br/>
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp leases">
- <tr>
- <td class="listhdrr"><a href="#"><?=gettext("IPv6 address"); ?></a></td>
- <td class="listhdrr"><a href="#"><?=gettext("IAID"); ?></a></td>
- <td class="listhdrr"><a href="#"><?=gettext("DUID"); ?></a></td>
- <td class="listhdrr"><a href="#"><?=gettext("Hostname/MAC"); ?></a></td>
- <td class="listhdrr"><a href="#"><?=gettext("Start"); ?></a></td>
- <td class="listhdrr"><a href="#"><?=gettext("End"); ?></a></td>
- <td class="listhdrr"><a href="#"><?=gettext("Online"); ?></a></td>
- <td class="listhdrr"><a href="#"><?=gettext("Lease Type"); ?></a></td>
+ <tr>
+ <td class="listhdrr"><a href="#"><?=gettext("IPv6 address"); ?></a></td>
+ <td class="listhdrr"><a href="#"><?=gettext("IAID"); ?></a></td>
+ <td class="listhdrr"><a href="#"><?=gettext("DUID"); ?></a></td>
+ <td class="listhdrr"><a href="#"><?=gettext("Hostname/MAC"); ?></a></td>
+ <td class="listhdrr"><a href="#"><?=gettext("Start"); ?></a></td>
+ <td class="listhdrr"><a href="#"><?=gettext("End"); ?></a></td>
+ <td class="listhdrr"><a href="#"><?=gettext("Online"); ?></a></td>
+ <td class="listhdrr"><a href="#"><?=gettext("Lease Type"); ?></a></td>
</tr>
<?php
foreach ($leases as $data) {
@@ -435,7 +438,7 @@ foreach ($leases as $data) {
if ($data['act'] == "static") {
foreach ($config['dhcpdv6'] as $dhcpif => $dhcpifconf) {
- if(is_array($dhcpifconf['staticmap'])) {
+ if (is_array($dhcpifconf['staticmap'])) {
foreach ($dhcpifconf['staticmap'] as $staticent) {
if ($data['ip'] == $staticent['ipaddr']) {
$data['if'] = $dhcpif;
@@ -444,8 +447,9 @@ foreach ($leases as $data) {
}
}
/* exit as soon as we have an interface */
- if ($data['if'] != "")
+ if ($data['if'] != "") {
break;
+ }
}
} else {
$data['if'] = convert_real_interface_to_friendly_interface_name(guess_interface_from_ip($data['ip']));
@@ -463,7 +467,9 @@ foreach ($leases as $data) {
if (!empty($mac)) {
$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
print htmlentities($mac);
- if(isset($mac_man[$mac_hi])){ print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>"; }
+ if (isset($mac_man[$mac_hi])) {
+ print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>";
+ }
}
echo "{$fspane}&nbsp;</td>\n";
@@ -519,7 +525,7 @@ foreach ($prefixes as $data) {
if ($data['act'] == "static") {
foreach ($config['dhcpdv6'] as $dhcpif => $dhcpifconf) {
- if(is_array($dhcpifconf['staticmap'])) {
+ if (is_array($dhcpifconf['staticmap'])) {
foreach ($dhcpifconf['staticmap'] as $staticent) {
if ($data['ip'] == $staticent['ipaddr']) {
$data['if'] = $dhcpif;
@@ -528,8 +534,9 @@ foreach ($prefixes as $data) {
}
}
/* exit as soon as we have an interface */
- if ($data['if'] != "")
+ if ($data['if'] != "") {
break;
+ }
}
} else {
$data['if'] = convert_real_interface_to_friendly_interface_name(guess_interface_from_ip($data['ip']));
@@ -556,16 +563,16 @@ foreach ($prefixes as $data) {
</table>
<br/>
<form action="status_dhcpv6_leases.php" method="get">
-<input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" />
+ <input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" />
<?php if ($_GET['all']): ?>
-<input type="hidden" name="all" value="0" />
-<input type="submit" class="formbtn" value="<?=gettext("Show active and static leases only"); ?>" />
+ <input type="hidden" name="all" value="0" />
+ <input type="submit" class="formbtn" value="<?=gettext("Show active and static leases only"); ?>" />
<?php else: ?>
-<input type="hidden" name="all" value="1" />
-<input type="submit" class="formbtn" value="<?=gettext("Show all configured leases"); ?>" />
+ <input type="hidden" name="all" value="1" />
+ <input type="submit" class="formbtn" value="<?=gettext("Show all configured leases"); ?>" />
<?php endif; ?>
</form>
-<?php if($leases == 0): ?>
+<?php if ($leases == 0): ?>
<p><strong><?=gettext("No leases file found. Is the DHCP server active"); ?>?</strong></p>
<?php endif; ?>
OpenPOWER on IntegriCloud