Skip to content

Commit

Permalink
Merge pull request poweradmin#247 from NTX/master
Browse files Browse the repository at this point in the history
Fix for wrong zone appending to subnet PTR records
  • Loading branch information
Sebastian Sellmeier committed Mar 9, 2016
2 parents 8099c26 + f400889 commit d735d41
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inc/dns.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function validate_input($rid, $zid, $type, &$content, &$name, &$prio, &$ttl) {

$zone = get_zone_name_from_id($zid); // TODO check for return

if (!(preg_match("/$zone$/i", $name))) {
if (!endsWith(strtolower($zone), strtolower($name))) {
if (isset($name) && $name != "") {
$name = $name . "." . $zone;
} else {
Expand Down
15 changes: 15 additions & 0 deletions inc/toolkit.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -819,3 +819,18 @@ function logout($msg = "", $type = "") {
auth($msg, $type);
exit;
}

/** Matches end of string
*
* Matches end of string (haystack) against another string (needle)
*
* @param string $needle
* @param string $haystack
*
* @return true if ends with specified string, otherwise false
*/
function endsWith($needle, $haystack) {
$length = strlen($haystack);
$nLength = strlen($needle);
return $nLength <= $length && strncmp(substr($haystack, -$nLength), $needle, $nLength) === 0;
}

0 comments on commit d735d41

Please sign in to comment.