servnest/pg-act/ns/print.php

26 lines
843 B
PHP
Raw Normal View History

<?php
nsCheckZonePossession($_POST['zone']);
$data['zone_name'] = $_POST['zone'];
$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, 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.');