summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-01-10 20:51:37 +0000
committerLuke Bratch <luke@bratch.co.uk>2019-01-10 20:51:37 +0000
commit5b1e9636979b587193250d4dbb2a708a288b27c1 (patch)
treefda51a995d15b698128c10ea0d1e80b9b60da299
parent5a9e4c10116b32a3f0c78c812977cb3519bbec92 (diff)
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!
-rw-r--r--dns.php7
1 files changed, 6 insertions, 1 deletions
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 "<p>error: something went wrong when writing the zone file, please ask someone for help</p>";
die();
}