Project

General

Profile

Download (14.5 KB) Statistics
| Branch: | Tag: | Revision:
1 4d875b4f Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4 b9546722 Chris Buechler
	status_dhcp_leases.php
5 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
6 13d193c2 Scott Ullrich
	Copyright (C) 2004-2009 Scott Ullrich
7 5b237745 Scott Ullrich
	All rights reserved.
8 4d875b4f Scott Ullrich
9 3c4cddc7 Phil Davis
	originally part of m0n0wall (http://m0n0.ch/wall)
10 4d875b4f Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
	All rights reserved.
12
13 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
14
	modification, are permitted provided that the following conditions are met:
15 4d875b4f Scott Ullrich
16 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
17
	   this list of conditions and the following disclaimer.
18 4d875b4f Scott Ullrich
19 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
20
	   notice, this list of conditions and the following disclaimer in the
21
	   documentation and/or other materials provided with the distribution.
22 4d875b4f Scott Ullrich
23 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
	POSSIBILITY OF SUCH DAMAGE.
33
*/
34
35 13d193c2 Scott Ullrich
/*
36
	pfSense_BUILDER_BINARIES:	/usr/bin/awk	/bin/cat	/usr/sbin/arp	/usr/bin/wc	/usr/bin/grep
37
	pfSense_MODULE:	dhcpserver
38
*/
39
40 6b07c15a Matthew Grooms
##|+PRIV
41
##|*IDENT=page-status-dhcpleases
42
##|*NAME=Status: DHCP leases page
43
##|*DESCR=Allow access to the 'Status: DHCP leases' page.
44 b9546722 Chris Buechler
##|*MATCH=status_dhcp_leases.php*
45 6b07c15a Matthew Grooms
##|-PRIV
46
47 5b237745 Scott Ullrich
require("guiconfig.inc");
48 7d1e0109 Joecowboy
require_once("config.inc");
49 b63695db Scott Ullrich
50 f75d8a89 Carlos Eduardo Ramos
$pgtitle = array(gettext("Status"),gettext("DHCP leases"));
51 b32dd0a6 jim-p
$shortcut_section = "dhcp";
52 972e5568 jim-p
53
$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases";
54
55
if (($_GET['deleteip']) && (is_ipaddr($_GET['deleteip']))) {
56 f6a11dac jim-p
	/* Stop DHCPD */
57 972e5568 jim-p
	killbyname("dhcpd");
58
59 f6a11dac jim-p
	/* Read existing leases */
60 f6fef11d Phil Davis
	/* $leases_contents has the lines of the file, including the newline char at the end of each line. */
61 d579e3db smos
	$leases_contents = file($leasesfile);
62 972e5568 jim-p
	$newleases_contents = array();
63
	$i=0;
64
	while ($i < count($leases_contents)) {
65 f6a11dac jim-p
		/* Find the lease(s) we want to delete */
66 f6fef11d Phil Davis
		if ($leases_contents[$i] == "lease {$_GET['deleteip']} {\n") {
67 f6a11dac jim-p
			/* Skip to the end of the lease declaration */
68 972e5568 jim-p
			do {
69
				$i++;
70 f6fef11d Phil Davis
			} while ($leases_contents[$i] != "}\n");
71 972e5568 jim-p
		} else {
72 f6a11dac jim-p
			/* It's a line we want to keep, copy it over. */
73 972e5568 jim-p
			$newleases_contents[] = $leases_contents[$i];
74
		}
75
		$i++;
76
	}
77
78 f6a11dac jim-p
	/* Write out the new leases file */
79 972e5568 jim-p
	$fd = fopen($leasesfile, 'w');
80
	fwrite($fd, implode("\n", $newleases_contents));
81
	fclose($fd);
82
83 f6a11dac jim-p
	/* Restart DHCP Service */
84 972e5568 jim-p
	services_dhcpd_configure();
85 b9546722 Chris Buechler
	header("Location: status_dhcp_leases.php?all={$_GET['all']}");
86 972e5568 jim-p
}
87
88 b63695db Scott Ullrich
include("head.inc");
89
90 5b237745 Scott Ullrich
?>
91
92
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
93
<?php include("fbegin.inc"); ?>
94
<?php
95
96
function leasecmp($a, $b) {
97 fff9ee45 Phil Davis
	return strcmp($a[$_GET['order']], $b[$_GET['order']]);
98 5742ca5e Scott Ullrich
}
99
100
function adjust_gmt($dt) {
101 fff9ee45 Phil Davis
	global $config;
102 e085eba5 Joecowboy
	$dhcpd = $config['dhcpd'];
103 d8b37f91 Renato Botelho
	foreach ($dhcpd as $dhcpditem) {
104
		$dhcpleaseinlocaltime = $dhcpditem['dhcpleaseinlocaltime'];
105 fff9ee45 Phil Davis
		if ($dhcpleaseinlocaltime == "yes")
106 df321263 Joecowboy
			break;
107
	}
108 e085eba5 Joecowboy
	if ($dhcpleaseinlocaltime == "yes") {
109 d8b37f91 Renato Botelho
		$ts = strtotime($dt . " GMT");
110 7d1e0109 Joecowboy
		return strftime("%Y/%m/%d %I:%M:%S%p", $ts);
111 d8b37f91 Renato Botelho
	} else
112
		return $dt;
113 5b237745 Scott Ullrich
}
114
115 428d20c4 Seth Mos
function remove_duplicate($array, $field)
116
{
117 fff9ee45 Phil Davis
	foreach ($array as $sub)
118
		$cmp[] = $sub[$field];
119
	$unique = array_unique(array_reverse($cmp,true));
120
	foreach ($unique as $k => $rien)
121
		$new[] = $array[$k];
122
	return $new;
123 5b237745 Scott Ullrich
}
124
125 428d20c4 Seth Mos
$awk = "/usr/bin/awk";
126
/* this pattern sticks comments into a single array item */
127
$cleanpattern = "'{ gsub(\"#.*\", \"\");} { gsub(\";\", \"\"); print;}'";
128
/* We then split the leases file by } */
129 b4f7282c Seth Mos
$splitpattern = "'BEGIN { RS=\"}\";} {for (i=1; i<=NF; i++) printf \"%s \", \$i; printf \"}\\n\";}'";
130 5b237745 Scott Ullrich
131 428d20c4 Seth Mos
/* stuff the leases file in a proper format into a array by line */
132 13d193c2 Scott Ullrich
exec("/bin/cat {$leasesfile} | {$awk} {$cleanpattern} | {$awk} {$splitpattern}", $leases_content);
133 428d20c4 Seth Mos
$leases_count = count($leases_content);
134 468b0d65 Seth Mos
exec("/usr/sbin/arp -an", $rawdata);
135 6ccefb28 jim-p
$arpdata_ip = array();
136
$arpdata_mac = array();
137 468b0d65 Seth Mos
foreach ($rawdata as $line) {
138
	$elements = explode(' ',$line);
139
	if ($elements[3] != "(incomplete)") {
140
		$arpent = array();
141 6ccefb28 jim-p
		$arpdata_ip[] = trim(str_replace(array('(',')'),'',$elements[1]));
142
		$arpdata_mac[] = strtolower(trim($elements[3]));
143 468b0d65 Seth Mos
	}
144
}
145 d579e3db smos
unset($rawdata);
146 428d20c4 Seth Mos
$pools = array();
147 5b237745 Scott Ullrich
$leases = array();
148
$i = 0;
149 b4f7282c Seth Mos
$l = 0;
150
$p = 0;
151 5b237745 Scott Ullrich
152
// Put everything together again
153 d579e3db smos
foreach($leases_content as $lease) {
154 428d20c4 Seth Mos
	/* split the line by space */
155 d579e3db smos
	$data = explode(" ", $lease);
156 428d20c4 Seth Mos
	/* walk the fields */
157
	$f = 0;
158
	$fcount = count($data);
159 73a96698 Phil Davis
	/* with less than 20 fields there is nothing useful */
160 b4f7282c Seth Mos
	if($fcount < 20) {
161
		$i++;
162
		continue;
163
	}
164 428d20c4 Seth Mos
	while($f < $fcount) {
165 b4f7282c Seth Mos
		switch($data[$f]) {
166
			case "failover":
167 97752da5 jim-p
				$pools[$p]['name'] = trim($data[$f+2], '"');
168
				$pools[$p]['name'] = "{$pools[$p]['name']} (" . convert_friendly_interface_to_friendly_descr(substr($pools[$p]['name'], 5)) . ")";
169 b4f7282c Seth Mos
				$pools[$p]['mystate'] = $data[$f+7];
170
				$pools[$p]['peerstate'] = $data[$f+14];
171
				$pools[$p]['mydate'] = $data[$f+10];
172
				$pools[$p]['mydate'] .= " " . $data[$f+11];
173
				$pools[$p]['peerdate'] = $data[$f+17];
174
				$pools[$p]['peerdate'] .= " " . $data[$f+18];
175
				$p++;
176
				$i++;
177
				continue 3;
178
			case "lease":
179
				$leases[$l]['ip'] = $data[$f+1];
180
				$leases[$l]['type'] = "dynamic";
181
				$f = $f+2;
182
				break;
183
			case "starts":
184
				$leases[$l]['start'] = $data[$f+2];
185
				$leases[$l]['start'] .= " " . $data[$f+3];
186
				$f = $f+3;
187
				break;
188
			case "ends":
189
				$leases[$l]['end'] = $data[$f+2];
190
				$leases[$l]['end'] .= " " . $data[$f+3];
191
				$f = $f+3;
192
				break;
193
			case "tstp":
194
				$f = $f+3;
195
				break;
196
			case "tsfp":
197
				$f = $f+3;
198
				break;
199
			case "atsfp":
200
				$f = $f+3;
201
				break;
202
			case "cltt":
203
				$f = $f+3;
204
				break;
205
			case "binding":
206 428d20c4 Seth Mos
				switch($data[$f+2]) {
207 b4f7282c Seth Mos
					case "active":
208
						$leases[$l]['act'] = "active";
209 428d20c4 Seth Mos
						break;
210 b4f7282c Seth Mos
					case "free":
211
						$leases[$l]['act'] = "expired";
212
						$leases[$l]['online'] = "offline";
213 428d20c4 Seth Mos
						break;
214 b4f7282c Seth Mos
					case "backup":
215
						$leases[$l]['act'] = "reserved";
216
						$leases[$l]['online'] = "offline";
217 428d20c4 Seth Mos
						break;
218
				}
219 b4f7282c Seth Mos
				$f = $f+1;
220
				break;
221
			case "next":
222
				/* skip the next binding statement */
223
				$f = $f+3;
224
				break;
225 dc073abd jim-p
			case "rewind":
226 042578fd jim-p
				/* skip the rewind binding statement */
227 dc073abd jim-p
				$f = $f+3;
228
				break;
229 b4f7282c Seth Mos
			case "hardware":
230
				$leases[$l]['mac'] = $data[$f+2];
231
				/* check if it's online and the lease is active */
232 6ccefb28 jim-p
				if (in_array($leases[$l]['ip'], $arpdata_ip)) {
233 468b0d65 Seth Mos
					$leases[$l]['online'] = 'online';
234
				} else {
235
					$leases[$l]['online'] = 'offline';
236 14cf741d Scott Ullrich
				}
237 b4f7282c Seth Mos
				$f = $f+2;
238
				break;
239
			case "client-hostname":
240
				if($data[$f+1] <> "") {
241
					$leases[$l]['hostname'] = preg_replace('/"/','',$data[$f+1]);
242
				} else {
243
					$hostname = gethostbyaddr($leases[$l]['ip']);
244
					if($hostname <> "") {
245
						$leases[$l]['hostname'] = $hostname;
246
					}
247
				}
248
				$f = $f+1;
249
				break;
250
			case "uid":
251
				$f = $f+1;
252
				break;
253 14cf741d Scott Ullrich
		}
254 428d20c4 Seth Mos
		$f++;
255 14cf741d Scott Ullrich
	}
256 b4f7282c Seth Mos
	$l++;
257 428d20c4 Seth Mos
	$i++;
258 d579e3db smos
	/* slowly chisel away at the source array */
259
	array_shift($leases_content);
260 5b237745 Scott Ullrich
}
261 d579e3db smos
/* remove the old array */
262
unset($lease_content);
263 428d20c4 Seth Mos
264
/* remove duplicate items by mac address */
265 9255cbc5 Seth Mos
if(count($leases) > 0) {
266 b4f7282c Seth Mos
	$leases = remove_duplicate($leases,"ip");
267 9255cbc5 Seth Mos
}
268 b4f7282c Seth Mos
269 9255cbc5 Seth Mos
if(count($pools) > 0) {
270
	$pools = remove_duplicate($pools,"name");
271
	asort($pools);
272
}
273 428d20c4 Seth Mos
274 9252431c Scott Ullrich
foreach($config['interfaces'] as $ifname => $ifarr) {
275 fff9ee45 Phil Davis
	if (is_array($config['dhcpd'][$ifname]) &&
276 b9ed163d Ermal Luçi
		is_array($config['dhcpd'][$ifname]['staticmap'])) {
277 f5bea142 Phil Davis
		$staticmap_array_index = 0;
278 9252431c Scott Ullrich
		foreach($config['dhcpd'][$ifname]['staticmap'] as $static) {
279
			$slease = array();
280
			$slease['ip'] = $static['ipaddr'];
281
			$slease['type'] = "static";
282
			$slease['mac'] = $static['mac'];
283 f5bea142 Phil Davis
			$slease['if'] = $ifname;
284 aedd7929 jim-p
			$slease['start'] = "";
285
			$slease['end'] = "";
286 08cf5428 Scott Ullrich
			$slease['hostname'] = htmlentities($static['hostname']);
287 9252431c Scott Ullrich
			$slease['act'] = "static";
288 6ccefb28 jim-p
			$slease['online'] = in_array(strtolower($slease['mac']), $arpdata_mac) ? 'online' : 'offline';
289 f5bea142 Phil Davis
			$slease['staticmap_array_index'] = $staticmap_array_index;
290 9252431c Scott Ullrich
			$leases[] = $slease;
291 f5bea142 Phil Davis
			$staticmap_array_index++;
292 9252431c Scott Ullrich
		}
293
	}
294
}
295 5b237745 Scott Ullrich
296
if ($_GET['order'])
297
	usort($leases, "leasecmp");
298 428d20c4 Seth Mos
299
/* only print pool status when we have one */
300
if(count($pools) > 0) {
301 5b237745 Scott Ullrich
?>
302 2871ce84 Colin Fleming
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp leases">
303 428d20c4 Seth Mos
  <tr>
304 f75d8a89 Carlos Eduardo Ramos
    <td class="listhdrr"><?=gettext("Failover Group"); ?></a></td>
305
    <td class="listhdrr"><?=gettext("My State"); ?></a></td>
306
    <td class="listhdrr"><?=gettext("Since"); ?></a></td>
307
    <td class="listhdrr"><?=gettext("Peer State"); ?></a></td>
308
    <td class="listhdrr"><?=gettext("Since"); ?></a></td>
309 428d20c4 Seth Mos
  </tr>
310
<?php
311
foreach ($pools as $data) {
312
	echo "<tr>\n";
313 2871ce84 Colin Fleming
	echo "<td class=\"listlr\">{$fspans}{$data['name']}{$fspane}</td>\n";
314
	echo "<td class=\"listr\">{$fspans}{$data['mystate']}{$fspane}</td>\n";
315
	echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['mydate']) . "{$fspane}</td>\n";
316
	echo "<td class=\"listr\">{$fspans}{$data['peerstate']}{$fspane}</td>\n";
317
	echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['peerdate']) . "{$fspane}</td>\n";
318 428d20c4 Seth Mos
	echo "<td class=\"list\" valign=\"middle\" width=\"17\">&nbsp;</td>\n";
319
	echo "<td class=\"list\" valign=\"middle\" width=\"17\">&nbsp;</td>\n";
320
	echo "</tr>\n";
321
}
322
323
?>
324
</table>
325
326
<?php
327
/* only print pool status when we have one */
328
}
329
?>
330
331 2871ce84 Colin Fleming
<br/>
332 428d20c4 Seth Mos
333 2871ce84 Colin Fleming
<table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp leases">
334 5b237745 Scott Ullrich
  <tr>
335 f75d8a89 Carlos Eduardo Ramos
    <td class="listhdrr"><a href="#"><?=gettext("IP address"); ?></a></td>
336
    <td class="listhdrr"><a href="#"><?=gettext("MAC address"); ?></a></td>
337
    <td class="listhdrr"><a href="#"><?=gettext("Hostname"); ?></a></td>
338
    <td class="listhdrr"><a href="#"><?=gettext("Start"); ?></a></td>
339
    <td class="listhdrr"><a href="#"><?=gettext("End"); ?></a></td>
340
    <td class="listhdrr"><a href="#"><?=gettext("Online"); ?></a></td>
341
    <td class="listhdrr"><a href="#"><?=gettext("Lease Type"); ?></a></td>
342 5b237745 Scott Ullrich
	</tr>
343
<?php
344 57f2840e Evgeny
// Load MAC-Manufacturer table
345
$mac_man = load_mac_manufacturer_table();
346 5b237745 Scott Ullrich
foreach ($leases as $data) {
347 9252431c Scott Ullrich
	if (($data['act'] == "active") || ($data['act'] == "static") || ($_GET['all'] == 1)) {
348
		if ($data['act'] != "active" && $data['act'] != "static") {
349 5b237745 Scott Ullrich
			$fspans = "<span class=\"gray\">";
350 2871ce84 Colin Fleming
			$fspane = "&nbsp;</span>";
351 5b237745 Scott Ullrich
		} else {
352 2871ce84 Colin Fleming
			$fspans = "";
353
			$fspane = "&nbsp;";
354 5b237745 Scott Ullrich
		}
355 fff9ee45 Phil Davis
		$lip = ip2ulong($data['ip']);
356 f5bea142 Phil Davis
		if ($data['act'] != "static") {
357 8d8f0090 jim-p
			foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf) {
358
				if (!is_array($dhcpifconf['range']))
359
					continue;
360 fff9ee45 Phil Davis
				if (($lip >= ip2ulong($dhcpifconf['range']['from'])) && ($lip <= ip2ulong($dhcpifconf['range']['to']))) {
361
					$data['if'] = $dhcpif;
362
					break;
363
				}
364 5b2177e4 Scott Ullrich
			}
365 fff9ee45 Phil Davis
		}
366 5b237745 Scott Ullrich
		echo "<tr>\n";
367 fff9ee45 Phil Davis
		echo "<td class=\"listlr\">{$fspans}{$data['ip']}{$fspane}</td>\n";
368
		$mac=$data['mac'];
369 57f2840e Evgeny
		$mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]);
370 fff9ee45 Phil Davis
		if ($data['online'] != "online") {
371 57f2840e Evgeny
			if(isset($mac_man[$mac_hi])){ // Manufacturer for this MAC is defined
372 fff9ee45 Phil Davis
				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";
373
			} else {
374
				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";
375 57f2840e Evgeny
			}
376 fff9ee45 Phil Davis
		} else {
377 57f2840e Evgeny
			if(isset($mac_man[$mac_hi])){ // Manufacturer for this MAC is defined
378 2871ce84 Colin Fleming
				echo "<td class=\"listr\">{$fspans}{$mac}<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>{$fspane}</td>\n";
379 fff9ee45 Phil Davis
			} else {
380
				echo "<td class=\"listr\">{$fspans}{$data['mac']}{$fspane}</td>\n";
381 57f2840e Evgeny
			}
382 fff9ee45 Phil Davis
		}
383
		echo "<td class=\"listr\">{$fspans}"  . htmlentities($data['hostname']) . "{$fspane}</td>\n";
384
		if ($data['type'] != "static") {
385
			echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['start']) . "{$fspane}</td>\n";
386
			echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['end']) . "{$fspane}</td>\n";
387
		} else {
388
			echo "<td class=\"listr\">{$fspans} n/a {$fspane}</td>\n";
389
			echo "<td class=\"listr\">{$fspans} n/a {$fspane}</td>\n";
390
		}
391
		echo "<td class=\"listr\">{$fspans}{$data['online']}{$fspane}</td>\n";
392
		echo "<td class=\"listr\">{$fspans}{$data['act']}{$fspane}</td>\n";
393
		echo "<td valign=\"middle\">&nbsp;";
394 9252431c Scott Ullrich
		if ($data['type'] == "dynamic") {
395 2871ce84 Colin Fleming
			echo "<a href=\"services_dhcp_edit.php?if={$data['if']}&amp;mac={$data['mac']}&amp;hostname={$data['hostname']}\">";
396
			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";
397 9252431c Scott Ullrich
		} else {
398 f5bea142 Phil Davis
			echo "<a href=\"services_dhcp_edit.php?if={$data['if']}&amp;id={$data['staticmap_array_index']}\">";
399 73a96698 Phil Davis
			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";
400 9252431c Scott Ullrich
		}
401
402 fff9ee45 Phil Davis
		echo "<a href=\"services_wol_edit.php?if={$data['if']}&amp;mac={$data['mac']}&amp;descr={$data['hostname']}\">";
403 2871ce84 Colin Fleming
		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";
404 f6a11dac jim-p
405
		/* Only show the button for offline dynamic leases */
406
		if (($data['type'] == "dynamic") && ($data['online'] != "online")) {
407 2871ce84 Colin Fleming
			echo "<a href=\"status_dhcp_leases.php?deleteip={$data['ip']}&amp;all=" . htmlspecialchars($_GET['all']) . "\">";
408
			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";
409 f6a11dac jim-p
		}
410 fff9ee45 Phil Davis
	echo "</td></tr>\n";
411 5b237745 Scott Ullrich
	}
412
}
413 428d20c4 Seth Mos
414 5b237745 Scott Ullrich
?>
415
</table>
416 2871ce84 Colin Fleming
<br/>
417 3ae16b9b Colin Fleming
<form action="status_dhcp_leases.php" method="get">
418 2871ce84 Colin Fleming
<input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" />
419 5b237745 Scott Ullrich
<?php if ($_GET['all']): ?>
420 2871ce84 Colin Fleming
<input type="hidden" name="all" value="0" />
421
<input type="submit" class="formbtn" value="<?=gettext("Show active and static leases only"); ?>" />
422 5b237745 Scott Ullrich
<?php else: ?>
423 2871ce84 Colin Fleming
<input type="hidden" name="all" value="1" />
424
<input type="submit" class="formbtn" value="<?=gettext("Show all configured leases"); ?>" />
425 5b237745 Scott Ullrich
<?php endif; ?>
426
</form>
427 428d20c4 Seth Mos
<?php if($leases == 0): ?>
428 f75d8a89 Carlos Eduardo Ramos
<p><strong><?=gettext("No leases file found. Is the DHCP server active"); ?>?</strong></p>
429 5b237745 Scott Ullrich
<?php endif; ?>
430 fda1fdae Scott Ullrich
431 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
432
</body>
433
</html>