Project

General

Profile

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