summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorjim-p <jim@pingle.org>2009-04-16 23:13:53 -0400
committerjim-p <jim@pingle.org>2009-04-16 23:20:28 -0400
commit972e55682340c16e9a4e24ddd6d11353befdb455 (patch)
tree1032b9e69c6edaff6fbb378af7fe49ca39ba6197 /usr
parentdfd6af96ceb762ac79dd55b554a9523245b7aa9e (diff)
downloadpfsense-972e55682340c16e9a4e24ddd6d11353befdb455.zip
pfsense-972e55682340c16e9a4e24ddd6d11353befdb455.tar.gz
Add ability to remove DHCP leases.
Use "x" icon to delete the lease. Said icon only appears next to "offline" dynamic leases
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/www/diag_dhcp_leases.php42
1 files changed, 40 insertions, 2 deletions
diff --git a/usr/local/www/diag_dhcp_leases.php b/usr/local/www/diag_dhcp_leases.php
index 78bde63..36ff16c 100755
--- a/usr/local/www/diag_dhcp_leases.php
+++ b/usr/local/www/diag_dhcp_leases.php
@@ -42,6 +42,41 @@
require("guiconfig.inc");
$pgtitle = array("Status","DHCP leases");
+
+$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases";
+
+if (($_GET['deleteip']) && (is_ipaddr($_GET['deleteip']))) {
+ // Stop DHCPD
+ killbyname("dhcpd");
+
+ // Read existing leases
+ $leases_contents = explode("\n", file_get_contents($leasesfile));
+ $newleases_contents = array();
+ $i=0;
+ while ($i < count($leases_contents)) {
+ // Find the lease(s) we want to delete
+ if ($leases_contents[$i] == "lease {$_GET['deleteip']} {") {
+ // Skip to the end of the lease declaration
+ do {
+ $i++;
+ } while ($leases_contents[$i] != "}");
+ } else {
+ // It's a line we want to keep, copy it over.
+ $newleases_contents[] = $leases_contents[$i];
+ }
+ $i++;
+ }
+
+ // Write out the new leases file
+ $fd = fopen($leasesfile, 'w');
+ fwrite($fd, implode("\n", $newleases_contents));
+ fclose($fd);
+
+ // Restart DHCP Service
+ services_dhcpd_configure();
+ header("Location: diag_dhcp_leases.php");
+}
+
include("head.inc");
?>
@@ -69,7 +104,6 @@ function remove_duplicate($array, $field)
return $new;
}
-$leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases";
$awk = "/usr/bin/awk";
/* this pattern sticks comments into a single array item */
$cleanpattern = "'{ gsub(\"#.*\", \"\");} { gsub(\";\", \"\"); print;}'";
@@ -332,7 +366,11 @@ foreach ($leases as $data) {
echo "<td class=\"listr\">{$fspans}{$data['act']}{$fspane}&nbsp;</td>\n";
if ($data['type'] == "dynamic") {
- echo "<td class=\"list\" valign=\"middle\"><a href=\"services_dhcp_edit.php?if={$data['if']}&mac={$data['mac']}&hostname={$data['hostname']}\">";
+ if ($data['online'] != "online") {
+ echo "<td class=\"list\" valign=\"middle\"><a href=\"diag_dhcp_leases.php?deleteip={$data['ip']}\">";
+ echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_x.gif\" width=\"17\" height=\"17\" border=\"0\" title=\"delete this dhcp lease\"></a></td>\n";
+ }
+ echo "<td valign=\"middle\"><a href=\"services_dhcp_edit.php?if={$data['if']}&mac={$data['mac']}&hostname={$data['hostname']}\">";
echo "<img src=\"/themes/{$g['theme']}/images/icons/icon_plus.gif\" width=\"17\" height=\"17\" border=\"0\" title=\"add a static mapping for this MAC address\"></a></td>\n";
} else {
echo "<td class=\"list\" valign=\"middle\">";
OpenPOWER on IntegriCloud