diff options
| author | Luke Bratch <luke@bratch.co.uk> | 2019-01-10 20:51:37 +0000 |
|---|---|---|
| committer | Luke Bratch <luke@bratch.co.uk> | 2019-01-10 20:51:37 +0000 |
| commit | 5b1e9636979b587193250d4dbb2a708a288b27c1 (patch) | |
| tree | fda51a995d15b698128c10ea0d1e80b9b60da299 | |
| parent | 5a9e4c10116b32a3f0c78c812977cb3519bbec92 (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.php | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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(); } |
