97 lines
2.5 KiB
PHP
97 lines
2.5 KiB
PHP
|
|
<form method="post">
|
|
<input type="radio" name="print" id="table" value="table" checked="">
|
|
<label for="table">Tableau de mes enregistrements</label>
|
|
<br>
|
|
<input type="radio" name="print" id="ds" value="ds">
|
|
<label for="ds">Enregistrement DS</label>
|
|
<br>
|
|
<input type="radio" name="print" id="raw" value="raw">
|
|
<label for="raw">Fichier de zone brut</label>
|
|
<br>
|
|
<label for="zone">Zone</label>
|
|
<select required="" name="zone" id="zone">
|
|
<option value="" disabled="" selected="">-</option>
|
|
<?php
|
|
if (isset($_SESSION['username']))
|
|
foreach (nsListUserZones($_SESSION['username']) as $zone)
|
|
echo " <option value='" . $zone . "'>" . $zone . "</option>\n";
|
|
?>
|
|
</select>
|
|
<br>
|
|
<input value="Afficher" type="submit">
|
|
</form>
|
|
|
|
<?php
|
|
|
|
if (processForm()) {
|
|
nsCheckZonePossession($_POST['zone']);
|
|
|
|
$zoneContent = file_get_contents(CONF['ns']['knot_zones_path'] . '/' . $_POST['zone'] . 'zone');
|
|
if ($zoneContent === false)
|
|
output(500, 'Unable to read zone file.');
|
|
|
|
if ($_POST['print'] === 'raw') {
|
|
echo '<pre>' . htmlspecialchars($zoneContent) . '</pre>';
|
|
output(200);
|
|
}
|
|
|
|
if ($_POST['print'] === 'table') { ?>
|
|
|
|
<table>
|
|
<tr>
|
|
<th>Domaine</th>
|
|
<th>TTL</th>
|
|
<th>Type</th>
|
|
<th>Contenu</th>
|
|
</tr>
|
|
<?php
|
|
foreach(explode("\n", $zoneContent) as $zoneLine) {
|
|
if (str_starts_with($zoneLine, ';')) continue; // Ignore comments
|
|
if (empty($zoneLine)) continue;
|
|
$elements = preg_split("#[\t ]+#", $zoneLine, 4);
|
|
if (!in_array($elements[2], ALLOWED_TYPES, true)) continue; // Ignore records generated by Knot
|
|
echo ' <tr>';
|
|
foreach ($elements as $element)
|
|
echo ' <td><code>' . htmlspecialchars($element) . '</code></td>';
|
|
echo ' </tr>';
|
|
}
|
|
echo '</table>';
|
|
}
|
|
|
|
if ($_POST['print'] === 'ds') {
|
|
|
|
$found = preg_match('/^' . preg_quote($_POST['zone']) . '[\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})$/m', $zoneContent, $matches);
|
|
if ($found !== 1)
|
|
output(500, 'Unable to get public key record from zone file.');
|
|
|
|
?>
|
|
|
|
<dl>
|
|
<dt>Zone</dt>
|
|
<dd>
|
|
<code><?= $_POST['zone'] ?></code>
|
|
</dd>
|
|
<dt>Tag</dt>
|
|
<dd>
|
|
<code><?= $matches['tag'] ?></code>
|
|
</dd>
|
|
<dt>Algorithme</dt>
|
|
<dd>
|
|
<code><?= $matches['algo'] ?></code><?php if ($matches['algo'] === '15') echo ' (Ed25519)'; ?>
|
|
</dd>
|
|
<dt>Type de condensat</dt>
|
|
<dd>
|
|
<code><?= $matches['digest_type'] ?></code><?php if ($matches['digest_type'] === '2') echo ' (SHA-256)'; ?>
|
|
</dd>
|
|
<dt>Condensat</dt>
|
|
<dd>
|
|
<code><?= $matches['digest'] ?></code>
|
|
</dd>
|
|
</dl>
|
|
|
|
<?php
|
|
output(200);
|
|
}
|
|
}
|