dns.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. $dns = new \dns($_POST);
  3. //reload everything after a post to get a new state
  4. if (!empty($_POST)) {
  5. $dns = new \dns();
  6. }
  7. ?>
  8. <style>
  9. .active2 {
  10. background-color: #CCCCCC;
  11. }
  12. </style>
  13. <script>
  14. $(function() {
  15. $(".delete_local_mapping").click(function (e) {
  16. var mapping_id = $(this).data("mapping_id");
  17. $.post( "/api.php", { action: "deleteLocalZoneMapping", mapping_id: mapping_id })
  18. .done(function( data ) {
  19. document.location.href="/dns";
  20. });
  21. return false;
  22. });
  23. });
  24. </script>
  25. <?php if ($dns->error != null) { ?>
  26. <div class="jumbotron content" style="display:block;">
  27. Error: <?= $dns->error ?><br />
  28. </div>
  29. <?php } //endif ?>
  30. <?php if ($dns->needs_update) { ?>
  31. <div class="jumbotron content" style="display:block;">
  32. <form method="POST" action="/dns" /><input type="submit" class="btn btn-warning btn-lg" value="Apply changes" name="applyChanges" />
  33. </div>
  34. <?php } //endif ?>
  35. <div class="jumbotron content" style="display:block;">
  36. <h2>Host Mappings</h2>
  37. <?php
  38. if (count($dns->local_zones) > 0) {
  39. foreach ($dns->local_zones as $zone) {
  40. ?>
  41. <br />
  42. <br />
  43. <a name="<?= $zone['zone'] ?>"></a>
  44. <h4>Zone: <em> <?= $zone['zone'] ?></em> <?php if ($zone['primary_zone'] == 1) { echo "(primary zone)"; } ?></h4>
  45. <?php
  46. if (isset($dns->clone_zones[$zone['zone']])) {
  47. echo "Clone zones: ".implode(",",$dns->clone_zones[$zone['zone']]);
  48. }
  49. ?>
  50. <p>
  51. <form method="POST" action="/dns#<?= $zone['zone'] ?>">
  52. <input type="hidden" name="zone" value="<?= $zone['zone'] ?>" />
  53. <input type="text" name="new_local_zone_mapping" placeholder="hostname" />
  54. <input type="text" name="new_local_zone_mapping_ip" placeholder="ip" />
  55. <input class="btn btn-primary btn-xs" type="submit" value="Add Mapping" />
  56. </form>
  57. </p>
  58. <hr />
  59. <table class="table" border="0">
  60. <thead>
  61. <tr>
  62. <th>
  63. hostname
  64. </th>
  65. <th>
  66. address
  67. </th>
  68. <th>
  69. &nbsp;
  70. </th>
  71. </tr>
  72. </thead>
  73. <?php
  74. if (isset($dns->local_zone_mappings[$zone['zone']])) {
  75. ?>
  76. <tbody>
  77. <?php
  78. $i = 0;
  79. $last_hostname = "";
  80. foreach ($dns->local_zone_mappings[$zone['zone']] as $mapping) {
  81. if ($last_hostname != $mapping['hostname']) {
  82. $i++;
  83. $last_hostname = $mapping['hostname'];
  84. }
  85. ?>
  86. <tr <?php if ($i % 2 == 0) { ?>class="active2"<?php } ?>>
  87. <td>
  88. <?= $mapping['hostname'] ?>
  89. </td>
  90. <td>
  91. <?= $mapping['ip'] ?>
  92. </td>
  93. <td>
  94. <button type="button" class="delete_local_mapping" data-mapping_id='<?= $mapping['id'] ?>' aria-label="Delete">
  95. <span style="color:red;" aria-hidden="true">&times;</span>
  96. </button>
  97. </td>
  98. </tr>
  99. <?php
  100. } //foreachend
  101. ?>
  102. </tbody>
  103. <?php } //endif ?>
  104. </table>
  105. <?php
  106. } //foreachend
  107. } //if end
  108. ?>
  109. <br /><br />
  110. <hr />
  111. <h2>Add Zones</h2>
  112. <p>
  113. <h4>Local Zone</h4><br />
  114. <form method="POST" action="/dns">
  115. <input type="text" name="new_local_zone" placeholder="domain.name" />
  116. <select name="new_local_zone_type">
  117. <option value='transparent'>Transparent</option>
  118. <option value='static'>Static</option>
  119. </select>
  120. <input class="btn btn-primary btn-xs" type="submit" value="Add Local Zone" />
  121. </form>
  122. <br />
  123. <h4>Clone Zone</h4><br />
  124. <form method="POST" action="/dns">
  125. <input type="text" name="clone_zone" placeholder="domain.name" />
  126. <select name="target_zone">
  127. <?php
  128. if (count($dns->local_zones) > 0) {
  129. foreach ($dns->local_zones as $zone) {
  130. ?>
  131. <option value='<?= $zone['zone'] ?>'><?= $zone['zone'] ?></option>
  132. <?php
  133. }
  134. }
  135. ?>
  136. </select>
  137. <input class="btn btn-primary btn-xs" type="submit" value="Add Clone Zone" />
  138. </form>
  139. </p>
  140. <hr />
  141. <br />
  142. </div>
  143. <div class="jumbotron content" style="display:block;">
  144. <div class="form-group">
  145. <label for="custom_config">Custom Unbound Configuration:</label>
  146. <form method="POST" action="/dns">
  147. <textarea id="custom_config" class="form-control" rows="20" name="custom_config"><?= $dns->custom_config ?></textarea><br />
  148. <input class="btn btn-primary btn-xs" type="submit" value="Save Custom Config" />
  149. </form>
  150. </div>
  151. </div>