103 lines
2.5 KiB
PHP
103 lines
2.5 KiB
PHP
<?php require "../../common/html.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
|
|
|
|
switchToFormProcess();
|
|
|
|
nsCheckZonePossession($_POST['zone']);
|
|
|
|
$zoneContent = file_get_contents(CONF['ns']['knot_zones_path'] . '/' . $_POST['zone'] . 'zone');
|
|
if ($zoneContent === false)
|
|
serverError("Unable to read zone file.");
|
|
|
|
if ($_POST['print'] === 'raw') {
|
|
echo '<pre>' . htmlspecialchars($zoneContent) . '</pre>';
|
|
success();
|
|
}
|
|
|
|
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], ['CAA', 'A', 'AAAA', 'MX', 'NS', 'SRV', 'SSHFP', 'TLSA', 'TXT'], true)) continue; // Ignore records generated by Knot
|
|
echo ' <tr>';
|
|
foreach ($elements as $element)
|
|
echo ' <td>' . htmlspecialchars($element) . '</td>';
|
|
echo ' </tr>';
|
|
}
|
|
echo '</table>';
|
|
}
|
|
|
|
if ($_POST['print'] === 'ds') {
|
|
|
|
$found = preg_match("#\n" . preg_quote($_POST['zone']) . "\s+0\s+CDS\s+([0-9]{1,5})\s+([0-9]{1,2})\s+([0-9])\s+([0-9A-F]{64})\n#", $zoneContent, $matches);
|
|
if ($found !== 1)
|
|
serverError("Unable to get public key record from zone file.");
|
|
|
|
$tag = $matches[1];
|
|
$algo = $matches[2];
|
|
$digestType = $matches[3];
|
|
$digest = $matches[4];
|
|
|
|
?>
|
|
|
|
<dl>
|
|
<dt>Zone</dt>
|
|
<dd>
|
|
<code><?= $_POST['zone'] ?></code>
|
|
</dd>
|
|
<dt>Tag</dt>
|
|
<dd>
|
|
<code><?= $tag ?></code>
|
|
</dd>
|
|
<dt>Algorithme</dt>
|
|
<dd>
|
|
<code><?= $algo ?></code><?php if ($algo === "15") echo " (Ed25519)"; ?>
|
|
</dd>
|
|
<dt>Type de condensat</dt>
|
|
<dd>
|
|
<code><?= $digestType ?></code><?php if ($digestType === "2") echo " (SHA-256)"; ?>
|
|
</dd>
|
|
<dt>Condensat</dt>
|
|
<dd>
|
|
<code><?= $digest ?></code>
|
|
</dd>
|
|
</dl>
|
|
|
|
<?php
|
|
success();
|
|
}
|
|
?>
|