|
@@ -7,8 +7,8 @@ if (processForm() AND isset($_POST['zone-content'])) { // Update zone
|
|
|
$current_zone_content = file_get_contents(CONF['ns']['knot_zones_path'] . '/' . $_POST['zone'] . 'zone');
|
|
|
if ($current_zone_content === false)
|
|
|
output(500, 'Unable to read zone file.');
|
|
|
- if (preg_match('/^(?<soa>' . preg_quote($_POST['zone']) . '[\t ]+[0-9]{1,16}[\t ]+SOA[\t ]+.+)$/m', $current_zone_content, $matches) !== 1)
|
|
|
- output(500, 'Unable to get current serial from zone file.');
|
|
|
+ if (preg_match('/^(?<soa>' . preg_quote($_POST['zone'], '/') . '[\t ]+[0-9]{1,16}[\t ]+SOA[\t ]+.+)$/Dm', $current_zone_content, $matches) !== 1)
|
|
|
+ output(500, 'Unable to get current SOA record from zone file.');
|
|
|
|
|
|
// Generate new zone content
|
|
|
$new_zone_content = $matches['soa'] . LF;
|
|
@@ -16,7 +16,7 @@ if (processForm() AND isset($_POST['zone-content'])) { // Update zone
|
|
|
output(403, 'La zone n\'est pas autorisée à dépasser ' . ZONE_MAX_CHARACTERS . ' caractères.');
|
|
|
foreach (explode("\r\n", $_POST['zone-content']) as $line) {
|
|
|
if ($line === '') continue;
|
|
|
- if (preg_match('/^(?<domain>[a-z0-9@._-]+)(?:[\t ]+(?<ttl>[0-9]{1,16}))?(?:[\t ]+IN)?[\t ]+(?<type>[A-Z]{1,16})[\t ]+(?<value>.+)$/', $line, $matches) !== 1)
|
|
|
+ if (preg_match('/^(?<domain>[a-z0-9@._-]+)(?:[\t ]+(?<ttl>[0-9]{1,16}))?(?:[\t ]+IN)?[\t ]+(?<type>[A-Z]{1,16})[\t ]+(?<value>.+)$/D', $line, $matches) !== 1)
|
|
|
output(403, 'La zone est mal formatée (selon Niver).');
|
|
|
if (in_array($matches['type'], ALLOWED_TYPES, true) !== true)
|
|
|
output(403, 'Le type <code>' . $matches['type'] . '</code> n\'est pas autorisé.');
|
|
@@ -92,7 +92,7 @@ if (processForm()) { // Display zone
|
|
|
foreach(explode(LF, $zone_content) as $zone_line) {
|
|
|
if (empty($zone_line) OR str_starts_with($zone_line, ';'))
|
|
|
continue;
|
|
|
- if (preg_match('/^(?:(?:[a-z0-9_-]{1,63}\.){1,127})?' . preg_quote($_POST['zone'], '/') . '[\t ]+[0-9]{1,8}[\t ]+(?<type>[A-Z]{1,16})[\t ]+.+$/', $zone_line, $matches)) {
|
|
|
+ if (preg_match('/^(?:(?:[a-z0-9_-]{1,63}\.){1,127})?' . preg_quote($_POST['zone'], '/') . '[\t ]+[0-9]{1,8}[\t ]+(?<type>[A-Z]{1,16})[\t ]+.+$/D', $zone_line, $matches)) {
|
|
|
if (in_array($matches['type'], ALLOWED_TYPES, true) !== true)
|
|
|
continue;
|
|
|
$displayed_zone_content .= $zone_line . LF;
|