From 5b1e9636979b587193250d4dbb2a708a288b27c1 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Thu, 10 Jan 2019 20:51:37 +0000 Subject: Fix a string comparison which was using sizeof() instead of strlen() due to a new warning in PHP 7.2 - may not have worked properly before the warning anyway! --- dns.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dns.php b/dns.php index d2dcc19..a21b00f 100644 --- a/dns.php +++ b/dns.php @@ -122,8 +122,13 @@ function writezone($domain, $zonetext, $password = null) { // Reload the zone if we got this far $zonewrite = sshrun("echo -en \"$zonetext\" > " . ZONEROOT . "$domain" . ZONESUFFIX . " && echo $? || echo $?"); + // Remove any trailing newlines from the returned string + while ($zonewrite[strlen($zonewrite) - 1] == "\n") { + $zonewrite = $zonewrite[strlen($zonewrite) - 2]; + } + // If the return code was non-zero then fail - if ($zonewrite[sizeof($zonewrite) - 1] != "0") { + if ($zonewrite[strlen($zonewrite) - 1] != "0") { echo "

error: something went wrong when writing the zone file, please ask someone for help

"; die(); } -- cgit v1.2.3