servnest/pg-act/ns/print.php

28 lines
885 B
PHP
Raw Permalink Normal View History

2023-07-17 19:15:18 +00:00
<?php declare(strict_types=1);
nsCheckZonePossession($_POST['zone']);
$data['zone_name'] = $_POST['zone'];
2023-04-28 13:39:05 +00:00
rateLimit();
$zone_content = file_get_contents(CONF['ns']['knot_zones_path'] . '/' . $data['zone_name'] . 'zone');
if ($zone_content === false)
output(500, 'Unable to read zone file.');
if ($_POST['print'] === 'raw')
$data['zone-raw'] = $zone_content;
elseif ($_POST['print'] === 'table')
$data['zone-table'] = parseZoneFile($zone_content, NS_ALLOWED_TYPES);
elseif ($_POST['print'] === 'ds') {
$found = preg_match('/^' . preg_quote($data['zone_name'], '/') . '[\t ]+0[\t ]+CDS[\t ]+(?<tag>[0-9]{1,5})[\t ]+(?<algo>[0-9]{1,2})[\t ]+(?<digest_type>[0-9])[\t ]+(?<digest>[0-9A-F]{64})$/Dm', $zone_content, $data['zone-ds']);
if ($found !== 1)
output(500, 'Unable to get public key record from zone file.');
}
else
output(403, 'Wrong <code>print</code> method.');