1<?php 2 3/** 4 * Script to edit / add / delete groups 5 *************************************************/ 6 7# verify that user is logged in 8$User->check_user_session(); 9# perm check 10$User->check_module_permissions ("dhcp", 1, true, false); 11 12# get subnets 13$leases4 = $DHCP->read_leases ("IPv4"); 14$leases6 = $DHCP->read_leases ("IPv6"); 15 16 17// this function returns single item as table item for subnets 18function print_leases ($s) { 19 // get user class 20 global $User; 21 // cast 22 $s = (object) $s; 23 // printed option to add defaults 24 $printed_options = array(); 25 26 $html[] = "<tr>"; 27 28 $html[] = " <td>".$s->address."</td>"; 29 $html[] = " <td>".$User->reformat_mac_address ($s->hwaddr, 1)."</td>"; 30 $html[] = " <td>".$s->subnet_id."</td>"; 31 $html[] = " <td>".$s->client_id."</td>"; 32 $html[] = " <td>".$s->valid_lifetime." s</td>"; 33 $html[] = " <td>".$s->expire."</td>"; 34 $html[] = " <td>".$s->state."</td>"; 35 $html[] = " <td>".$s->hostname."</td>"; 36 37 $html[] = " </td>"; 38 $html[] = "</tr>"; 39 // return 40 return $html; 41} 42?> 43 44<br> 45<h4><?php print _("Active leases"); ?></h4><hr> 46 47<!-- Manage --> 48<!-- Manage --> 49<?php if ($User->is_admin(false)) { ?> 50<?php if ($_GET['page']=="administration") { ?> 51 <a class='btn btn-sm btn-default btn-default btn-success dhcp-leases' data-action='add' data-id=''><i class='fa fa-plus'></i> <?php print _('Add'); ?></a> 52<?php } else { ?> 53 <a class='btn btn-sm btn-default btn-default btn-success' href="<?php print create_link ("administration", "dhcp", "leases"); ?>"><i class='fa fa-pencil'></i> <?php print _('Manage'); ?></a> 54<?php } ?> 55<?php } ?> 56<br> 57 58<!-- table --> 59<table id="zonesPrint" class="table sorted table-striped table-top table-td-top" data-cookie-id-table="dhcp_leases"> 60 61<!-- Headers --> 62<thead> 63<tr> 64 <th><?php print _('Address'); ?></th> 65 <th><?php print _('MAC'); ?></th> 66 <th><?php print _('Subnet id'); ?></th> 67 <th><?php print _('Client_id'); ?></th> 68 <th><?php print _('Lifetime'); ?></th> 69 <th><?php print _('Expires'); ?></th> 70 <th><?php print _('State'); ?></th> 71 <th><?php print _('Hostname'); ?></th> 72</tr> 73</thead> 74 75<!-- subnets --> 76<?php 77// v4 78$html[] = "<tr>"; 79$html[] = "<td class='th' colspan='8'>"._("IPv4 leases")."</td>"; 80$html[] = "</tr>"; 81 82// IPv4 not configured 83if ($leases4 === false) { 84 $html[] = "<tr>"; 85 $html[] = " <td colspan='8'>".$Result->show("info", _("IPv4 not configured on DHCP server"), false, false, true)."</td>"; 86 $html[] = "</tr>"; 87} 88// no subnets found 89elseif(sizeof($leases4)==0) { 90 $html[] = "<tr>"; 91 $html[] = " <td colspan='8'>".$Result->show("info", _("No IPv4 leases"), false, false, true)."</td>"; 92 $html[] = "</tr>"; 93} 94else { 95 foreach ($leases4 as $s) { 96 $html = array_merge($html, print_leases ($s)); 97 } 98} 99 100 101// v6 102$html[] = "<tr>"; 103$html[] = "<td class='th' colspan='8'>"._("IPv6 leases")."</td>"; 104$html[] = "</tr>"; 105 106// IPv4 not configured 107if ($leases6 === false) { 108 $html[] = "<tr>"; 109 $html[] = " <td colspan='8'>".$Result->show("info", _("IPv6 not configured on DHCP server"), false, false, true)."</td>"; 110 $html[] = "</tr>"; 111} 112// no subnets found 113elseif(sizeof($leases6)==0) { 114 $html[] = "<tr>"; 115 $html[] = " <td colspan='8'>".$Result->show("info", _("No IPv6 leases"), false, false, true)."</td>"; 116 $html[] = "</tr>"; 117} 118else { 119 foreach ($leases6 as $s) { 120 $html = array_merge($html, print_leases ($s)); 121 } 122} 123 124# print table 125print implode("\n", $html); 126?> 127</tbody> 128</table> 129