Revision 6c5d41c2
Added by Sjon Hortensius over 10 years ago
usr/local/www/status_dhcpv6_leases.php | ||
---|---|---|
93 | 93 |
|
94 | 94 |
include("head.inc"); |
95 | 95 |
|
96 |
?> |
|
97 |
|
|
98 |
<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> |
|
99 |
<?php include("fbegin.inc"); ?> |
|
100 |
<?php |
|
101 |
|
|
102 | 96 |
function leasecmp($a, $b) { |
103 | 97 |
return strcmp($a[$_GET['order']], $b[$_GET['order']]); |
104 | 98 |
} |
... | ... | |
311 | 305 |
$f = $f+2; |
312 | 306 |
break; |
313 | 307 |
case "client-hostname": |
314 |
if($data[$f+1] <> "") {
|
|
308 |
if($data[$f+1] != "") {
|
|
315 | 309 |
$entry['hostname'] = preg_replace('/"/','',$data[$f+1]); |
316 | 310 |
} else { |
317 | 311 |
$hostname = gethostbyaddr($entry['ip']); |
318 |
if($hostname <> "") {
|
|
312 |
if($hostname != "") {
|
|
319 | 313 |
$entry['hostname'] = $hostname; |
320 | 314 |
} |
321 | 315 |
} |
... | ... | |
380 | 374 |
/* only print pool status when we have one */ |
381 | 375 |
if(count($pools) > 0) { |
382 | 376 |
?> |
383 |
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp leases"> |
|
384 |
<tr> |
|
385 |
<td class="listhdrr"><?=gettext("Failover Group"); ?></a></td> |
|
386 |
<td class="listhdrr"><?=gettext("My State"); ?></a></td> |
|
387 |
<td class="listhdrr"><?=gettext("Since"); ?></a></td> |
|
388 |
<td class="listhdrr"><?=gettext("Peer State"); ?></a></td> |
|
389 |
<td class="listhdrr"><?=gettext("Since"); ?></a></td> |
|
390 |
</tr> |
|
377 |
<div class="panel panel-default"> |
|
378 |
<div class="panel-heading"><?=gettext('Pool status')?></div> |
|
379 |
<div class="panel-body"> |
|
380 |
<table class="table"> |
|
381 |
<thead> |
|
382 |
<tr> |
|
383 |
<th><?=gettext("Failover Group")?></a></th> |
|
384 |
<th><?=gettext("My State")?></a></th> |
|
385 |
<th><?=gettext("Since")?></a></th> |
|
386 |
<th><?=gettext("Peer State")?></a></th> |
|
387 |
<th><?=gettext("Since")?></a></th> |
|
388 |
</tr> |
|
389 |
</thead> |
|
390 |
<tbody> |
|
391 |
<? foreach ($pools as $data):?> |
|
392 |
<tr> |
|
393 |
<td><?=$data['name']?></td> |
|
394 |
<td><?=$data['mystate']?></td> |
|
395 |
<td><?=adjust_gmt($data['mydate'])?></td> |
|
396 |
<td><?=$data['peerstate']?></td> |
|
397 |
<td><?=adjust_gmt($data['peerdate'])?></td> |
|
398 |
</tr> |
|
399 |
<? endforeach?> |
|
400 |
</tbody> |
|
401 |
</table> |
|
402 |
</div> |
|
403 |
</div> |
|
391 | 404 |
<?php |
392 |
foreach ($pools as $data) { |
|
393 |
echo "<tr>\n"; |
|
394 |
echo "<td class=\"listlr\">{$fspans}{$data['name']}{$fspane}</td>\n"; |
|
395 |
echo "<td class=\"listr\">{$fspans}{$data['mystate']}{$fspane}</td>\n"; |
|
396 |
echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['mydate']) . "{$fspane}</td>\n"; |
|
397 |
echo "<td class=\"listr\">{$fspans}{$data['peerstate']}{$fspane}</td>\n"; |
|
398 |
echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['peerdate']) . "{$fspane}</td>\n"; |
|
399 |
echo "<td class=\"list\" valign=\"middle\" width=\"17\"> </td>\n"; |
|
400 |
echo "<td class=\"list\" valign=\"middle\" width=\"17\"> </td>\n"; |
|
401 |
echo "</tr>\n"; |
|
405 |
/* only print pool status when we have one */ |
|
402 | 406 |
} |
403 | 407 |
|
404 |
?>
|
|
405 |
</table>
|
|
408 |
if (empty($leases))
|
|
409 |
print '<div class="alert alert-warning" role="alert">'. gettext("No leases file found. Is the DHCP server active?") .'</div>';
|
|
406 | 410 |
|
407 |
<?php |
|
408 |
/* only print pool status when we have one */ |
|
409 |
} |
|
410 | 411 |
?> |
411 |
|
|
412 |
<br/> |
|
413 |
|
|
414 |
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp leases"> |
|
415 |
<tr> |
|
416 |
<td class="listhdrr"><a href="#"><?=gettext("IPv6 address"); ?></a></td> |
|
417 |
<td class="listhdrr"><a href="#"><?=gettext("IAID"); ?></a></td> |
|
418 |
<td class="listhdrr"><a href="#"><?=gettext("DUID"); ?></a></td> |
|
419 |
<td class="listhdrr"><a href="#"><?=gettext("Hostname/MAC"); ?></a></td> |
|
420 |
<td class="listhdrr"><a href="#"><?=gettext("Start"); ?></a></td> |
|
421 |
<td class="listhdrr"><a href="#"><?=gettext("End"); ?></a></td> |
|
422 |
<td class="listhdrr"><a href="#"><?=gettext("Online"); ?></a></td> |
|
423 |
<td class="listhdrr"><a href="#"><?=gettext("Lease Type"); ?></a></td> |
|
424 |
</tr> |
|
412 |
<div class="panel panel-default"> |
|
413 |
<div class="panel-heading"><?=gettext('Leases')?></div> |
|
414 |
<div class="panel-body"> |
|
415 |
<table class="table"> |
|
416 |
<thead> |
|
417 |
<tr> |
|
418 |
<th><!-- icon --></th> |
|
419 |
<th><?=gettext("IPv6 address")?></th> |
|
420 |
<th><?=gettext("IAID")?></th> |
|
421 |
<th><?=gettext("DUID")?></th> |
|
422 |
<th><?=gettext("MAC address")?></th> |
|
423 |
<th><?=gettext("Hostname")?></th> |
|
424 |
<th><?=gettext("Start")?></th> |
|
425 |
<th><?=gettext("End")?></th> |
|
426 |
<th><?=gettext("Online")?></th> |
|
427 |
<th><?=gettext("Lease Type")?></th> |
|
428 |
</tr> |
|
429 |
</thead> |
|
430 |
<tbody> |
|
425 | 431 |
<?php |
426 |
foreach ($leases as $data) { |
|
427 |
if (($data['act'] == "active") || ($data['act'] == "static") || ($_GET['all'] == 1)) { |
|
428 |
if ($data['act'] != "active" && $data['act'] != "static") { |
|
429 |
$fspans = "<span class=\"gray\">"; |
|
430 |
$fspane = " </span>"; |
|
431 |
} else { |
|
432 |
$fspans = ""; |
|
433 |
$fspane = " "; |
|
434 |
} |
|
432 |
foreach ($leases as $data): |
|
433 |
if ($data['act'] != "active" && $data['act'] != "static" && $_GET['all'] != 1) |
|
434 |
continue; |
|
435 | 435 |
|
436 |
if ($data['act'] == "static") { |
|
437 |
foreach ($config['dhcpdv6'] as $dhcpif => $dhcpifconf) { |
|
438 |
if(is_array($dhcpifconf['staticmap'])) { |
|
439 |
foreach ($dhcpifconf['staticmap'] as $staticent) { |
|
440 |
if ($data['ip'] == $staticent['ipaddr']) { |
|
441 |
$data['if'] = $dhcpif; |
|
442 |
break; |
|
443 |
} |
|
436 |
if ($data['act'] == 'active') |
|
437 |
$icon = 'icon-ok-circle'; |
|
438 |
elseif ($data['act'] == 'expired') |
|
439 |
$icon = 'icon-ban-circle'; |
|
440 |
else |
|
441 |
$icon = 'icon-remove-circle'; |
|
442 |
|
|
443 |
if ($data['act'] == "static") { |
|
444 |
foreach ($config['dhcpdv6'] as $dhcpif => $dhcpifconf) { |
|
445 |
if(is_array($dhcpifconf['staticmap'])) { |
|
446 |
foreach ($dhcpifconf['staticmap'] as $staticent) { |
|
447 |
if ($data['ip'] == $staticent['ipaddr']) { |
|
448 |
$data['if'] = $dhcpif; |
|
449 |
break; |
|
444 | 450 |
} |
445 | 451 |
} |
446 |
/* exit as soon as we have an interface */ |
|
447 |
if ($data['if'] != "") |
|
448 |
break; |
|
449 | 452 |
} |
450 |
} else { |
|
451 |
$data['if'] = convert_real_interface_to_friendly_interface_name(guess_interface_from_ip($data['ip'])); |
|
452 |
} |
|
453 |
echo "<tr>\n"; |
|
454 |
echo "<td class=\"listlr\">{$fspans}{$data['ip']}{$fspane}</td>\n"; |
|
455 |
echo "<td class=\"listr\">{$fspans}{$data['iaid']}{$fspane}</td>\n"; |
|
456 |
echo "<td class=\"listr\">{$fspans}{$data['duid']}{$fspane}</td>\n"; |
|
457 |
echo "<td class=\"listr\">{$fspans}"; |
|
458 |
if (!empty($data['hostname'])) { |
|
459 |
echo htmlentities($data['hostname']) . "<br />"; |
|
460 |
} |
|
461 |
|
|
462 |
$mac=trim($ndpdata[$data['ip']]['mac']); |
|
463 |
if (!empty($mac)) { |
|
464 |
$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]); |
|
465 |
print htmlentities($mac); |
|
466 |
if(isset($mac_man[$mac_hi])){ print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>"; } |
|
467 |
} |
|
468 |
|
|
469 |
echo "{$fspane} </td>\n"; |
|
470 |
if ($data['type'] != "static") { |
|
471 |
echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['start']) . "{$fspane}</td>\n"; |
|
472 |
echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['end']) . "{$fspane}</td>\n"; |
|
473 |
} else { |
|
474 |
echo "<td class=\"listr\">{$fspans} n/a {$fspane}</td>\n"; |
|
475 |
echo "<td class=\"listr\">{$fspans} n/a {$fspane}</td>\n"; |
|
476 |
} |
|
477 |
echo "<td class=\"listr\">{$fspans}{$data['online']}{$fspane}</td>\n"; |
|
478 |
echo "<td class=\"listr\">{$fspans}{$data['act']}{$fspane}</td>\n"; |
|
479 |
|
|
480 |
if ($data['type'] == "dynamic") { |
|
481 |
echo "<td valign=\"middle\"><a href=\"services_dhcpv6_edit.php?if={$data['if']}&duid={$data['duid']}&hostname={$data['hostname']}\">"; |
|
482 |
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></td>\n"; |
|
483 |
} else { |
|
484 |
echo "<td class=\"list\" valign=\"middle\">"; |
|
485 |
echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_plus_mo.gif\" width=\"17\" height=\"17\" border=\"0\" alt=\"add\" /></td>\n"; |
|
486 |
} |
|
487 |
|
|
488 |
/* Only show the button for offline dynamic leases */ |
|
489 |
if (($data['type'] == "dynamic") && ($data['online'] != "online")) { |
|
490 |
echo "<td class=\"list\" valign=\"middle\"><a href=\"status_dhcpv6_leases.php?deleteip={$data['ip']}&all=" . htmlspecialchars($_GET['all']) . "\">"; |
|
491 |
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></td>\n"; |
|
453 |
/* exit as soon as we have an interface */ |
|
454 |
if ($data['if'] != "") |
|
455 |
break; |
|
492 | 456 |
} |
493 |
echo "</tr>\n"; |
|
457 |
} else { |
|
458 |
$data['if'] = convert_real_interface_to_friendly_interface_name(guess_interface_from_ip($data['ip'])); |
|
494 | 459 |
} |
495 |
} |
|
460 |
|
|
461 |
$mac = trim($ndpdata[$data['ip']]['mac']); |
|
462 |
$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]); |
|
496 | 463 |
?> |
497 |
</table> |
|
498 |
<br/> |
|
499 |
<h3>Delegated Prefixes</h3> |
|
500 |
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="prefixes"> |
|
501 |
<tr> |
|
502 |
<td class="listhdrr"><a href="#"><?=gettext("IPv6 Prefix"); ?></a></td> |
|
503 |
<td class="listhdrr"><a href="#"><?=gettext("IAID"); ?></a></td> |
|
504 |
<td class="listhdrr"><a href="#"><?=gettext("DUID"); ?></a></td> |
|
505 |
<td class="listhdrr"><a href="#"><?=gettext("Start"); ?></a></td> |
|
506 |
<td class="listhdrr"><a href="#"><?=gettext("End"); ?></a></td> |
|
507 |
<td class="listhdrr"><a href="#"><?=gettext("State"); ?></a></td> |
|
508 |
</tr> |
|
464 |
<tr> |
|
465 |
<td><i class="icon <?=$icon?>"></i></td> |
|
466 |
<td><?=$data['ip']?></td> |
|
467 |
<td><?=$data['iaid']?></td> |
|
468 |
<td><?=$data['duid']?></td> |
|
469 |
<td> |
|
470 |
<?=$mac?> |
|
471 |
|
|
472 |
<? if(isset($mac_man[$mac_hi])):?> |
|
473 |
(<?=$mac_man[$mac_hi]?>) |
|
474 |
<?endif?> |
|
475 |
</td> |
|
476 |
<td><?=htmlentities($data['hostname'])?></td> |
|
477 |
<? if ($data['type'] != "static"):?> |
|
478 |
<td><?=adjust_gmt($data['start'])?></td> |
|
479 |
<td><?=adjust_gmt($data['end'])?></td> |
|
480 |
<? else: ?> |
|
481 |
<td>n/a</td> |
|
482 |
<td>n/a</td> |
|
483 |
<? endif; ?> |
|
484 |
<td><?=$data['online']?></td> |
|
485 |
<td><?=$data['act']?></td> |
|
486 |
<td> |
|
487 |
<? if ($data['type'] == "dynamic"): ?> |
|
488 |
<a class="btn btn-xs btn-primary" href="services_dhcpv6_edit.php?if=<?=$data['if']?>&duid=<?=$data['duid']?>&hostname=<?=htmlspecialchars($data['hostname'])?>"> |
|
489 |
<?=gettext("add static mapping")?> |
|
490 |
</a> |
|
491 |
<? endif; ?> |
|
492 |
|
|
493 |
<a class="btn btn-xs btn-success" href="services_wol_edit.php?if=<?=$data['if']?>&mac=<?=$data['mac']?>&descr=<?=htmlentities($data['hostname'])?>"> |
|
494 |
add WOL mapping |
|
495 |
</a> |
|
496 |
|
|
497 |
<? if ($data['type'] == "dynamic" && $data['online'] != "online"):?> |
|
498 |
<a class="btn btn-xs btn-danger" href="status_dhcpv6_leases.php?deleteip=<?=$data['ip']?>&all=<?=intval($_GET['all'])?>"> |
|
499 |
delete lease |
|
500 |
</a> |
|
501 |
<? endif?> |
|
502 |
</td> |
|
503 |
<? endforeach; ?> |
|
504 |
</tr> |
|
505 |
</tbody> |
|
506 |
</table> |
|
507 |
</div> |
|
508 |
</div> |
|
509 |
|
|
510 |
<div class="panel panel-default"> |
|
511 |
<div class="panel-heading"><?=gettext('Delegated Prefixes')?></div> |
|
512 |
<div class="panel-body"> |
|
513 |
<table class="table"> |
|
514 |
<thead> |
|
515 |
<tr> |
|
516 |
<th><?=gettext("IPv6 Prefix")?></th> |
|
517 |
<th><?=gettext("IAID")?></th> |
|
518 |
<th><?=gettext("DUID")?></th> |
|
519 |
<th><?=gettext("Start")?></th> |
|
520 |
<th><?=gettext("End")?></th> |
|
521 |
<th><?=gettext("State")?></th> |
|
522 |
</tr> |
|
523 |
</thead> |
|
524 |
<tbody> |
|
509 | 525 |
<?php |
510 |
foreach ($prefixes as $data) { |
|
511 |
if (($data['act'] == "active") || ($data['act'] == "static") || ($_GET['all'] == 1)) { |
|
512 |
if ($data['act'] != "active" && $data['act'] != "static") { |
|
513 |
$fspans = "<span class=\"gray\">"; |
|
514 |
$fspane = " </span>"; |
|
515 |
} else { |
|
516 |
$fspans = ""; |
|
517 |
$fspane = " "; |
|
518 |
} |
|
526 |
foreach ($prefixes as $data): |
|
527 |
if ($data['act'] != "active" && $data['act'] != "static" && $_GET['all'] != 1) |
|
528 |
continue; |
|
519 | 529 |
|
520 |
if ($data['act'] == "static") { |
|
521 |
foreach ($config['dhcpdv6'] as $dhcpif => $dhcpifconf) { |
|
522 |
if(is_array($dhcpifconf['staticmap'])) { |
|
523 |
foreach ($dhcpifconf['staticmap'] as $staticent) { |
|
524 |
if ($data['ip'] == $staticent['ipaddr']) { |
|
525 |
$data['if'] = $dhcpif; |
|
526 |
break; |
|
527 |
} |
|
530 |
if ($data['act'] == 'active') |
|
531 |
$icon = 'icon-ok-circle'; |
|
532 |
elseif ($data['act'] == 'expired') |
|
533 |
$icon = 'icon-ban-circle'; |
|
534 |
else |
|
535 |
$icon = 'icon-remove-circle'; |
|
536 |
|
|
537 |
if ($data['act'] == "static") { |
|
538 |
foreach ($config['dhcpdv6'] as $dhcpif => $dhcpifconf) { |
|
539 |
if(is_array($dhcpifconf['staticmap'])) { |
|
540 |
foreach ($dhcpifconf['staticmap'] as $staticent) { |
|
541 |
if ($data['ip'] == $staticent['ipaddr']) { |
|
542 |
$data['if'] = $dhcpif; |
|
543 |
break; |
|
528 | 544 |
} |
529 | 545 |
} |
530 |
/* exit as soon as we have an interface */ |
|
531 |
if ($data['if'] != "") |
|
532 |
break; |
|
533 | 546 |
} |
534 |
} else { |
|
535 |
$data['if'] = convert_real_interface_to_friendly_interface_name(guess_interface_from_ip($data['ip'])); |
|
536 |
} |
|
537 |
echo "<tr>\n"; |
|
538 |
if ($mappings[$data['iaid'] . $data['duid']]) { |
|
539 |
$dip = "<br />Routed To: {$mappings[$data['iaid'] . $data['duid']]}"; |
|
540 |
} |
|
541 |
echo "<td class=\"listlr\">{$fspans}{$data['prefix']}{$dip}{$fspane}</td>\n"; |
|
542 |
echo "<td class=\"listr\">{$fspans}{$data['iaid']}{$fspane}</td>\n"; |
|
543 |
echo "<td class=\"listr\">{$fspans}{$data['duid']}{$fspane}</td>\n"; |
|
544 |
if ($data['type'] != "static") { |
|
545 |
echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['start']) . "{$fspane}</td>\n"; |
|
546 |
echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['end']) . "{$fspane}</td>\n"; |
|
547 |
} else { |
|
548 |
echo "<td class=\"listr\">{$fspans} n/a {$fspane}</td>\n"; |
|
549 |
echo "<td class=\"listr\">{$fspans} n/a {$fspane}</td>\n"; |
|
547 |
/* exit as soon as we have an interface */ |
|
548 |
if ($data['if'] != "") |
|
549 |
break; |
|
550 | 550 |
} |
551 |
echo "<td class=\"listr\">{$fspans}{$data['act']}{$fspane}</td>\n"; |
|
552 |
echo "</tr>\n"; |
|
551 |
} else { |
|
552 |
$data['if'] = convert_real_interface_to_friendly_interface_name(guess_interface_from_ip($data['ip'])); |
|
553 |
} |
|
554 |
|
|
555 |
{ |
|
556 |
$dip = ""; |
|
553 | 557 |
} |
554 |
} |
|
555 | 558 |
?> |
556 |
</table> |
|
557 |
<br/> |
|
558 |
<form action="status_dhcpv6_leases.php" method="get"> |
|
559 |
<input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" /> |
|
559 |
<tr> |
|
560 |
<td><i class="icon <?=$icon?>"></i></td> |
|
561 |
<td> |
|
562 |
<?=$data['prefix']?> |
|
563 |
<? if ($mappings[$data['iaid'] . $data['duid']]): ?> |
|
564 |
<br /> |
|
565 |
<?=gettext('Routed To')?>: <?=$mappings[$data['iaid'] . $data['duid']]?> |
|
566 |
<? endif; ?> |
|
567 |
</td> |
|
568 |
<td><?=$data['iaid']?></td> |
|
569 |
<td><?=$data['duid']?></td> |
|
570 |
<? if ($data['type'] != "static"):?> |
|
571 |
<td><?=adjust_gmt($data['start'])?></td> |
|
572 |
<td><?=adjust_gmt($data['end'])?></td> |
|
573 |
<? else: ?> |
|
574 |
<td>n/a</td> |
|
575 |
<td>n/a</td> |
|
576 |
<? endif; ?> |
|
577 |
<td><?=$data['act']?></td> |
|
578 |
<? endforeach; ?> |
|
579 |
</tr> |
|
580 |
</tbody> |
|
581 |
</table> |
|
582 |
</div> |
|
583 |
</div> |
|
584 |
|
|
560 | 585 |
<?php if ($_GET['all']): ?> |
561 |
<input type="hidden" name="all" value="0" /> |
|
562 |
<input type="submit" class="formbtn" value="<?=gettext("Show active and static leases only"); ?>" /> |
|
586 |
<a class="btn btn-default" href="status_dhcpv6_leases.php?all=0"><?=gettext("Show active and static leases only")?></a> |
|
563 | 587 |
<?php else: ?> |
564 |
<input type="hidden" name="all" value="1" /> |
|
565 |
<input type="submit" class="formbtn" value="<?=gettext("Show all configured leases"); ?>" /> |
|
566 |
<?php endif; ?> |
|
567 |
</form> |
|
568 |
<?php if($leases == 0): ?> |
|
569 |
<p><strong><?=gettext("No leases file found. Is the DHCP server active"); ?>?</strong></p> |
|
570 |
<?php endif; ?> |
|
571 |
|
|
572 |
<?php include("fend.inc"); ?> |
|
573 |
</body> |
|
574 |
</html> |
|
588 |
<a class="btn btn-default" href="status_dhcpv6_leases.php?all=1"><?=gettext("Show all configured leases")?></a> |
|
589 |
<?php endif; |
|
590 |
|
|
591 |
include("foot.inc"); |
Also available in: Unified diff
Converted status_dhcpv6_leases, 2 minor tweaks in status_dhcp_leases