summaryrefslogtreecommitdiffstats
path: root/usr/local/www/status_dhcp_leases.php
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@world.inf.org>2012-09-18 11:23:50 +0545
committerPhil Davis <phil.davis@world.inf.org>2012-09-18 11:23:50 +0545
commitf6fef11d6362786e7f4d35b307c4bb1c60ef4a80 (patch)
tree254832a8b80312edea010d128518f12e1777080a /usr/local/www/status_dhcp_leases.php
parentdb4fb43079eff00cb30b9babe011cb6c0af69105 (diff)
downloadpfsense-f6fef11d6362786e7f4d35b307c4bb1c60ef4a80.zip
pfsense-f6fef11d6362786e7f4d35b307c4bb1c60ef4a80.tar.gz
Fix deleting DHCP leases
This broke when the code was changed to suck the whole leases file into an array with: $leases_contents = file($leasesfile); Each array entry has the text of a line in the file AND the newline at the end of the line. So when matching array entries, the match has to expect the "\n" on the end.
Diffstat (limited to 'usr/local/www/status_dhcp_leases.php')
-rwxr-xr-xusr/local/www/status_dhcp_leases.php5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr/local/www/status_dhcp_leases.php b/usr/local/www/status_dhcp_leases.php
index c7a0c2d..45687b8 100755
--- a/usr/local/www/status_dhcp_leases.php
+++ b/usr/local/www/status_dhcp_leases.php
@@ -56,16 +56,17 @@ if (($_GET['deleteip']) && (is_ipaddr($_GET['deleteip']))) {
killbyname("dhcpd");
/* Read existing leases */
+ /* $leases_contents has the lines of the file, including the newline char at the end of each line. */
$leases_contents = file($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']} {") {
+ if ($leases_contents[$i] == "lease {$_GET['deleteip']} {\n") {
/* Skip to the end of the lease declaration */
do {
$i++;
- } while ($leases_contents[$i] != "}");
+ } while ($leases_contents[$i] != "}\n");
} else {
/* It's a line we want to keep, copy it over. */
$newleases_contents[] = $leases_contents[$i];
OpenPOWER on IntegriCloud