servnest/public/reg/print.php

52 lines
1.3 KiB
PHP

<?php require "../../common/html.php"; ?>
<form method="post">
<label for="domain">Domaine</label>
<select required="" name="domain" id="domain">
<option value="" disabled="" selected="">-</option>
<?php
if (isset($_SESSION['username']))
foreach (regListUserDomains($_SESSION['username']) as $domain)
echo " <option value='" . $domain . "'>" . $domain . "</option>\n";
?>
</select>
<br>
<input value="Afficher" type="submit">
</form>
<?php
switchToFormProcess();
regCheckDomainPossession($_POST['domain']);
$zoneContent = file_get_contents(CONF['reg']['registry_file']);
if ($zoneContent === false)
serverError("Unable to read registry file.");
?>
<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 (!str_ends_with($elements[0], $_POST['domain'])) continue; // Ignore records for other domains
if (!in_array($elements[2], ['A', 'AAAA', 'NS', 'DS'], true)) continue; // Ignore records generated by Knot
echo " <tr>\n";
foreach ($elements as $element)
echo " <td>" . htmlspecialchars($element) . "</td>\n";
echo " </tr>\n";
}
echo '</table>';
success();