summaryrefslogtreecommitdiffstats
path: root/src/usr/local/www/status_dhcp_leases.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/local/www/status_dhcp_leases.php')
-rw-r--r--src/usr/local/www/status_dhcp_leases.php264
1 files changed, 127 insertions, 137 deletions
diff --git a/src/usr/local/www/status_dhcp_leases.php b/src/usr/local/www/status_dhcp_leases.php
index 4c37f21..c961eca 100644
--- a/src/usr/local/www/status_dhcp_leases.php
+++ b/src/usr/local/www/status_dhcp_leases.php
@@ -85,13 +85,10 @@ if (($_GET['deleteip']) && (is_ipaddr($_GET['deleteip']))) {
header("Location: status_dhcp_leases.php?all={$_GET['all']}");
}
-include("head.inc");
-
-?>
+// Load MAC-Manufacturer table
+$mac_man = load_mac_manufacturer_table();
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
-<?php include("fbegin.inc"); ?>
-<?php
+include("head.inc");
function leasecmp($a, $b) {
return strcmp($a[$_GET['order']], $b[$_GET['order']]);
@@ -312,146 +309,139 @@ if ($_GET['order']) {
/* only print pool status when we have one */
if (count($pools) > 0) {
?>
-<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp leases">
- <tr>
- <td class="listhdrr"><?=gettext("Failover Group"); ?></a></td>
- <td class="listhdrr"><?=gettext("My State"); ?></a></td>
- <td class="listhdrr"><?=gettext("Since"); ?></a></td>
- <td class="listhdrr"><?=gettext("Peer State"); ?></a></td>
- <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";
- }
-?>
-</table>
-
+<div class="panel panel-default">
+ <div class="panel-heading"><h2 class="panel-title"><?=gettext('Pool status')?></h2></div>
+ <div class="panel-body">
+ <table class="table">
+ <thead>
+ <tr>
+ <th><?=gettext("Failover Group")?></a></th>
+ <th><?=gettext("My State")?></a></th>
+ <th><?=gettext("Since")?></a></th>
+ <th><?=gettext("Peer State")?></a></th>
+ <th><?=gettext("Since")?></a></th>
+ </tr>
+ </thead>
+ <tbody>
+<? foreach ($pools as $data):?>
+ <tr>
+ <td><?=$data['name']?></td>
+ <td><?=$data['mystate']?></td>
+ <td><?=adjust_gmt($data['mydate'])?></td>
+ <td><?=$data['peerstate']?></td>
+ <td><?=adjust_gmt($data['peerdate'])?></td>
+ </tr>
+<? endforeach?>
+ </tbody>
+ </table>
+ </div>
+</div>
<?php
/* only print pool status when we have one */
}
?>
-
-<br/>
-
-<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp leases">
- <tr>
- <td class="listhdrr"><a href="#"><?=gettext("IP address"); ?></a></td>
- <td class="listhdrr"><a href="#"><?=gettext("MAC address"); ?></a></td>
- <td class="listhdrr"><a href="#"><?=gettext("Hostname"); ?></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>
+<div class="panel panel-default">
+ <div class="panel-heading"><h2 class="panel-title"><?=gettext('Leases')?></h2></div>
+ <div class="panel-body">
+ <table class="table">
+ <thead>
+ <tr>
+ <th><!-- icon --></th>
+ <th><?=gettext("IP address")?></th>
+ <th><?=gettext("MAC address")?></th>
+ <th><?=gettext("Hostname")?></th>
+ <th><?=gettext("Start")?></th>
+ <th><?=gettext("End")?></th>
+ <th><?=gettext("Online")?></th>
+ <th><?=gettext("Lease Type")?></th>
+ </tr>
+ </thead>
+ <tbody>
<?php
-// Load MAC-Manufacturer table
-$mac_man = load_mac_manufacturer_table();
-foreach ($leases as $data) {
- if (($data['act'] == "active") || ($data['act'] == "static" && !empty($data['ip'])) || ($_GET['all'] == 1)) {
- if ($data['act'] != "active" && $data['act'] != "static") {
- $fspans = "<span class=\"gray\">";
- $fspane = "&nbsp;</span>";
- } else {
- $fspans = "";
- $fspane = "&nbsp;";
- }
- $lip = ip2ulong($data['ip']);
- if ($data['act'] != "static") {
- foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf) {
- if (!is_array($dhcpifconf['range'])) {
- continue;
- }
- if (($lip >= ip2ulong($dhcpifconf['range']['from'])) && ($lip <= ip2ulong($dhcpifconf['range']['to']))) {
- $data['if'] = $dhcpif;
- break;
- }
- // Check if the IP is in the range of any DHCP pools
- if (is_array($dhcpifconf['pool'])) {
- foreach ($dhcpifconf['pool'] as $dhcppool) {
- if (is_array($dhcppool['range'])) {
- if (($lip >= ip2ulong($dhcppool['range']['from'])) && ($lip <= ip2ulong($dhcppool['range']['to']))) {
- $data['if'] = $dhcpif;
- break 2;
- }
- }
- }
- }
- }
- }
- echo "<tr>\n";
- echo "<td class=\"listlr\">{$fspans}{$data['ip']}{$fspane}</td>\n";
- $mac=$data['mac'];
- $mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
- if ($data['online'] != "online") {
- if (isset($mac_man[$mac_hi])) { // Manufacturer for this MAC is defined
- echo "<td class=\"listr\">{$fspans}<a href=\"services_wol.php?if={$data['if']}&amp;mac=$mac\" title=\"" . gettext("$mac - send Wake on LAN packet to this MAC address") ."\">{$mac}</a><br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>{$fspane}</td>\n";
- } else {
- echo "<td class=\"listr\">{$fspans}<a href=\"services_wol.php?if={$data['if']}&amp;mac={$data['mac']}\" title=\"" . gettext("send Wake on LAN packet to this MAC address") ."\">{$data['mac']}</a>{$fspane}</td>\n";
- }
- } else {
- if (isset($mac_man[$mac_hi])) { // Manufacturer for this MAC is defined
- echo "<td class=\"listr\">{$fspans}{$mac}<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>{$fspane}</td>\n";
- } else {
- echo "<td class=\"listr\">{$fspans}{$data['mac']}{$fspane}</td>\n";
- }
- }
- echo "<td class=\"listr\">{$fspans}" . htmlentities($data['hostname']) . "{$fspane}</td>\n";
- if ($data['type'] != "static") {
- echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['start']) . "{$fspane}</td>\n";
- echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['end']) . "{$fspane}</td>\n";
- } else {
- echo "<td class=\"listr\">{$fspans} n/a {$fspane}</td>\n";
- echo "<td class=\"listr\">{$fspans} n/a {$fspane}</td>\n";
- }
- echo "<td class=\"listr\">{$fspans}{$data['online']}{$fspane}</td>\n";
- echo "<td class=\"listr\">{$fspans}{$data['act']}{$fspane}</td>\n";
- echo "<td valign=\"middle\">&nbsp;";
- if ($data['type'] == "dynamic") {
- echo "<a href=\"services_dhcp_edit.php?if={$data['if']}&amp;mac={$data['mac']}&amp;hostname={$data['hostname']}\">";
- echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_plus.gif\" width=\"17\" height=\"17\" border=\"0\" title=\"" . gettext("add a static mapping for this MAC address") ."\" alt=\"add\" /></a>&nbsp;\n";
- } else {
- echo "<a href=\"services_dhcp_edit.php?if={$data['if']}&amp;id={$data['staticmap_array_index']}\">";
- echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_e.gif\" width=\"17\" height=\"17\" border=\"0\" title=\"" . gettext("edit the static mapping for this entry") ."\" alt=\"add\" />&nbsp;\n";
- }
-
- echo "<a href=\"services_wol_edit.php?if={$data['if']}&amp;mac={$data['mac']}&amp;descr={$data['hostname']}\">";
- echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_wol_all.gif\" width=\"17\" height=\"17\" border=\"0\" title=\"" . gettext("add a Wake on LAN mapping for this MAC address") ."\" alt=\"add\" /></a>&nbsp;\n";
+foreach ($leases as $data):
+ if ($data['act'] != "active" && $data['act'] != "static" && $_GET['all'] != 1)
+ continue;
- /* Only show the button for offline dynamic leases */
- if (($data['type'] == "dynamic") && ($data['online'] != "online")) {
- echo "<a href=\"status_dhcp_leases.php?deleteip={$data['ip']}&amp;all=" . htmlspecialchars($_GET['all']) . "\">";
- echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_x.gif\" width=\"17\" height=\"17\" border=\"0\" title=\"" . gettext("delete this DHCP lease") . "\" alt=\"delete\" /></a>&nbsp;\n";
+ if ($data['act'] == 'active')
+ $icon = 'icon-ok-circle';
+ elseif ($data['act'] == 'expired')
+ $icon = 'icon-ban-circle';
+ else
+ $icon = 'icon-remove-circle';
+
+ $lip = ip2ulong($data['ip']);
+ if ($data['act'] != "static") {
+ foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf) {
+ if (!is_array($dhcpifconf['range']))
+ continue;
+ if (($lip >= ip2ulong($dhcpifconf['range']['from'])) && ($lip <= ip2ulong($dhcpifconf['range']['to']))) {
+ $data['if'] = $dhcpif;
+ break;
+ }
}
- echo "</td></tr>\n";
}
-}
+ $mac = $data['mac'];
+ $mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
?>
-</table>
-<br/>
-<form action="status_dhcp_leases.php" method="get">
- <input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" />
+ <tr>
+ <td><i class="icon <?=$icon?>"></i></td>
+ <td><?=$data['ip']?></td>
+ <td>
+ <?=$mac?>
+
+ <? if(isset($mac_man[$mac_hi])):?>
+ (<?=$mac_man[$mac_hi]?>)
+ <?endif?>
+ </td>
+ <td><?=htmlentities($data['hostname'])?></td>
+<? if ($data['type'] != "static"):?>
+ <td><?=adjust_gmt($data['start'])?></td>
+ <td><?=adjust_gmt($data['end'])?></td>
+<? else: ?>
+ <td>n/a</td>
+ <td>n/a</td>
+<? endif; ?>
+ <td><?=$data['online']?></td>
+ <td><?=$data['act']?></td>
+ <td>
+<? if ($data['type'] == "dynamic"): ?>
+ <a class="btn btn-xs btn-primary" href="services_dhcp_edit.php?if=<?=$data['if']?>&amp;mac=<?=$data['mac']?>&amp;hostname=<?=htmlspecialchars($data['hostname'])?>">
+ <?=gettext("add static mapping")?>
+ </a>
+<? else: ?>
+ <a class="btn btn-xs btn-primary" href="services_dhcp_edit.php?if=<?=$data['if']?>&amp;id=<?=$data['staticmap_array_index']?>">
+ <?=gettext("edit static mapping")?>
+ </a>
+<? endif; ?>
+
+ <a class="btn btn-xs btn-success" href="services_wol_edit.php?if=<?=$data['if']?>&amp;mac=<?=$data['mac']?>&amp;descr=<?=htmlentities($data['hostname'])?>">
+ add WOL mapping
+ </a>
+
+<? if ($data['online'] != "online"):?>
+ <a class="btn btn-xs btn-warning" href="services_wol.php?if=<?=$data['if']?>&amp;mac=<?=$data['mac']?>">
+ send WOL packet
+ </a>
+<? endif; ?>
+
+<? if ($data['type'] == "dynamic" && $data['online'] != "online"):?>
+ <a class="btn btn-xs btn-danger" href="status_dhcp_leases.php?deleteip=<?=$data['ip']?>&amp;all=<?=intval($_GET['all'])?>">
+ delete lease
+ </a>
+<? endif?>
+ </td>
+<? endforeach; ?>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+</div>
+
<?php if ($_GET['all']): ?>
- <input type="hidden" name="all" value="0" />
- <input type="submit" class="formbtn" value="<?=gettext("Show active and static leases only"); ?>" />
+ <a class="btn btn-default" href="status_dhcp_leases.php?all=0"><?=gettext("Show active and static leases only")?></a>
<?php else: ?>
- <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): ?>
-<p><strong><?=gettext("No leases file found. Is the DHCP server active"); ?>?</strong></p>
-<?php endif; ?>
-
-<?php include("fend.inc"); ?>
-</body>
-</html>
+ <a class="btn btn-default" href="status_dhcp_leases.php?all=1"><?=gettext("Show all configured leases")?></a>
+<?php endif;
+
+include("foot.inc"); \ No newline at end of file
OpenPOWER on IntegriCloud