print.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <form method="post">
  2. <label for="domain">Domaine</label>
  3. <select required="" name="domain" id="domain">
  4. <option value="" disabled="" selected="">-</option>
  5. <?php
  6. if (isset($_SESSION['username']))
  7. foreach (regListUserDomains($_SESSION['username']) as $domain)
  8. echo ' <option value="' . $domain . '">' . $domain . '</option>' . LF;
  9. ?>
  10. </select>
  11. <br>
  12. <input value="Afficher" type="submit">
  13. </form>
  14. <?php
  15. if (processForm()) {
  16. regCheckDomainPossession($_POST['domain']);
  17. $zoneContent = file_get_contents(CONF['reg']['registry_file']);
  18. if ($zoneContent === false)
  19. output(500, 'Unable to read registry file.');
  20. ?>
  21. <table>
  22. <tr>
  23. <th>Domaine</th>
  24. <th>TTL</th>
  25. <th>Type</th>
  26. <th>Contenu</th>
  27. </tr>
  28. <?php
  29. foreach(explode(LF, $zoneContent) as $zoneLine) {
  30. if (str_starts_with($zoneLine, ';')) continue; // Ignore comments
  31. if (empty($zoneLine)) continue;
  32. $elements = preg_split('/[\t ]+/', $zoneLine, 4);
  33. if (!str_ends_with($elements[0], $_POST['domain'])) continue; // Ignore records for other domains
  34. if (!in_array($elements[2], ['A', 'AAAA', 'NS', 'DS'], true)) continue; // Ignore records generated by Knot
  35. echo ' <tr>' . LF;
  36. foreach ($elements as $element)
  37. echo ' <td><code>' . htmlspecialchars($element) . '</code></td>' . LF;
  38. echo ' </tr>' . LF;
  39. }
  40. echo '</table>';
  41. output(200);
  42. }