選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

edit_zone_templ.php 9.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. /* Poweradmin, a friendly web-based admin tool for PowerDNS.
  3. * See <http://www.poweradmin.org> for more details.
  4. *
  5. * Copyright 2007-2010 Rejo Zenger <rejo@zenger.nl>
  6. * Copyright 2010-2017 Poweradmin Development Team
  7. * <http://www.poweradmin.org/credits.html>
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * Script that handles zone templates editing
  24. *
  25. * @package Poweradmin
  26. * @copyright 2007-2010 Rejo Zenger <rejo@zenger.nl>
  27. * @copyright 2010-2017 Poweradmin Development Team
  28. * @license http://opensource.org/licenses/GPL-3.0 GPL
  29. */
  30. require_once("inc/toolkit.inc.php");
  31. include_once("inc/header.inc.php");
  32. $zone_templ_id = "-1";
  33. if (isset($_GET['id']) && v_num($_GET['id'])) {
  34. $zone_templ_id = $_GET['id'];
  35. }
  36. if ($zone_templ_id == "-1") {
  37. error(ERR_INV_INPUT);
  38. include_once("inc/footer.inc.php");
  39. exit;
  40. }
  41. /*
  42. Check permissions
  43. */
  44. $owner = get_zone_templ_is_owner($zone_templ_id, $_SESSION['userid']);
  45. if (isset($_POST['commit']) && $owner) {
  46. success(SUC_ZONE_TEMPL_UPD);
  47. foreach ($_POST['record'] as $record) {
  48. edit_zone_templ_record($record);
  49. }
  50. }
  51. if (isset($_POST['edit']) && $owner) {
  52. edit_zone_templ($_POST, $zone_templ_id);
  53. }
  54. if (isset($_POST['save_as'])) {
  55. if (zone_templ_name_exists($_POST['templ_name'])) {
  56. error(ERR_ZONE_TEMPL_EXIST);
  57. } elseif ($_POST['templ_name'] == '') {
  58. error(ERR_ZONE_TEMPL_IS_EMPTY);
  59. } else {
  60. success(SUC_ZONE_TEMPL_ADD);
  61. $templ_details = get_zone_templ_details($zone_templ_id);
  62. add_zone_templ_save_as($_POST['templ_name'], $_POST['templ_descr'], $_SESSION['userid'], $_POST['record']);
  63. }
  64. }
  65. if (isset($_POST['update_zones'])) {
  66. $zones = get_list_zone_use_templ($zone_templ_id, $_SESSION['userid']);
  67. success(SUC_ZONES_UPD);
  68. foreach ($zones as $zone) {
  69. update_zone_records($zone['id'], $zone_templ_id);
  70. }
  71. }
  72. if (!(do_hook('verify_permission' , 'zone_master_add' )) || !$owner) {
  73. error(ERR_PERM_EDIT_ZONE_TEMPL);
  74. } else {
  75. if (zone_templ_id_exists($zone_templ_id) == "0") {
  76. error(ERR_ZONE_TEMPL_NOT_EXIST);
  77. } else {
  78. $record_count = count_zone_templ_records($zone_templ_id);
  79. $templ_details = get_zone_templ_details($zone_templ_id);
  80. echo " <h2>" . _('Edit zone template') . " \"" . $templ_details['name'] . "\"</h2>\n";
  81. echo " <div class=\"showmax\">\n";
  82. show_pages($record_count, $iface_rowamount, $zone_templ_id);
  83. echo " </div>\n";
  84. $records = get_zone_templ_records($zone_templ_id, ROWSTART, $iface_rowamount, RECORD_SORT_BY);
  85. if ($records == "-1") {
  86. echo " <p>" . _("This template zone does not have any records yet.") . "</p>\n";
  87. } else {
  88. echo " <form method=\"post\" action=\"\">\n";
  89. echo " <table>\n";
  90. echo " <tr>\n";
  91. echo " <th>&nbsp;</th>\n";
  92. echo " <th><a href=\"edit_zone_templ.php?id=" . $zone_templ_id . "&amp;record_sort_by=name\">" . _('Name') . "</a></th>\n";
  93. echo " <th><a href=\"edit_zone_templ.php?id=" . $zone_templ_id . "&amp;record_sort_by=type\">" . _('Type') . "</a></th>\n";
  94. echo " <th><a href=\"edit_zone_templ.php?id=" . $zone_templ_id . "&amp;record_sort_by=content\">" . _('Content') . "</a></th>\n";
  95. echo " <th><a href=\"edit_zone_templ.php?id=" . $zone_templ_id . "&amp;record_sort_by=prio\">" . _('Priority') . "</a></th>\n";
  96. echo " <th><a href=\"edit_zone_templ.php?id=" . $zone_templ_id . "&amp;record_sort_by=ttl\">" . _('TTL') . "</a></th>\n";
  97. echo " </tr>\n";
  98. foreach ($records as $r) {
  99. echo " <tr>\n";
  100. echo " <td class=\"n\">\n";
  101. echo " <input type=\"hidden\" name=\"record[" . $r['id'] . "][rid]\" value=\"" . $r['id'] . "\">\n";
  102. echo " <a href=\"edit_zone_templ_record.php?id=" . $r['id'] . "&amp;zone_templ_id=" . $zone_templ_id . "\">
  103. <img src=\"images/edit.gif\" alt=\"[ " . _('Edit record') . " ]\"></a>\n";
  104. echo " <a href=\"delete_zone_templ_record.php?id=" . $r['id'] . "&amp;zone_templ_id=" . $zone_templ_id . "\">
  105. <img src=\"images/delete.gif\" ALT=\"[ " . _('Delete record') . " ]\" BORDER=\"0\"></a>\n";
  106. echo " </td>\n";
  107. echo " <td class=\"u\"><input class=\"wide\" name=\"record[" . $r['id'] . "][name]\" value=\"" . $r['name'] . "\"></td>\n";
  108. echo " <td class=\"u\">\n";
  109. echo " <select name=\"record[" . $r['id'] . "][type]\">\n";
  110. $found_selected_type = false;
  111. foreach (get_record_types() as $type_available) {
  112. if ($type_available == $r['type']) {
  113. $add = " SELECTED";
  114. $found_selected_type = true;
  115. } else {
  116. $add = "";
  117. }
  118. echo " <option" . $add . " value=\"" . $type_available . "\" >" . $type_available . "</option>\n";
  119. }
  120. if (!$found_selected_type) {
  121. echo " <option SELECTED value=\"" . htmlspecialchars($r['type']) . "\"><i>" . $r['type'] . "</i></option>\n";
  122. }
  123. echo " </select>\n";
  124. echo " </td>\n";
  125. echo " <td class=\"u\"><input class=\"wide\" name=\"record[" . $r['id'] . "][content]\" value='" . $r['content'] . "'></td>\n";
  126. if ($r['type'] == "MX" || $r['type'] == "SRV") {
  127. echo " <td class=\"u\"><input name=\"record[" . $r['id'] . "][prio]\" value=\"" . $r['prio'] . "\"></td>\n";
  128. } else {
  129. echo " <td class=\"n\">&nbsp;</td>\n";
  130. }
  131. echo " <td class=\"u\"><input name=\"record[" . $r['id'] . "][ttl]\" value=\"" . $r['ttl'] . "\"></td>\n";
  132. echo " </tr>\n";
  133. }
  134. echo " <tr>\n";
  135. echo " <td colspan=\"6\"><br><b>Hint:</b></td>\n";
  136. echo " </tr>\n";
  137. echo " <tr>\n";
  138. echo " <td colspan=\"6\">" . _('The following placeholders can be used in template records') . "</td>\n";
  139. echo " </tr>\n";
  140. echo " <tr>\n";
  141. echo " <td colspan=\"6\"><br>&nbsp;&nbsp;&nbsp;&nbsp; * [ZONE] - " . _('substituted with current zone name') . "<br>";
  142. echo "&nbsp;&nbsp;&nbsp;&nbsp; * [SERIAL] - " . _('substituted with current date and 2 numbers') . " (YYYYMMDD + 00)</td>\n";
  143. echo " </tr>\n";
  144. echo " <tr>\n";
  145. echo " <td colspan=\"6\"><br>Save as new template:</td>\n";
  146. echo " </tr>\n";
  147. echo " <tr>\n";
  148. echo " <th>" . _('Template Name') . "</th>\n";
  149. echo " <td><input class=\"wide\" type=\"text\" name=\"templ_name\" value=\"\"></td>\n";
  150. echo " </tr>\n";
  151. echo " <tr>\n";
  152. echo " <th>" . _('Template Description') . "</th>\n";
  153. echo " <td><input class=\"wide\" type=\"text\" name=\"templ_descr\" value=\"\"></td>\n";
  154. echo " </tr>\n";
  155. echo " </table>\n";
  156. echo " <input type=\"submit\" class=\"button\" name=\"commit\" value=\"" . _('Commit changes') . "\">\n";
  157. echo " <input type=\"reset\" class=\"button\" name=\"reset\" value=\"" . _('Reset changes') . "\">\n";
  158. echo " <input type=\"submit\" class=\"button\" name=\"save_as\" value=\"" . _('Save as template') . "\">\n";
  159. echo " <input type=\"submit\" class=\"button\" name=\"update_zones\" value=\"" . _('Update zones') . "\">\n";
  160. echo " </form>";
  161. }
  162. echo " <form method=\"post\" action=\"\">\n";
  163. echo " <table>\n";
  164. echo " <tr>\n";
  165. echo " <th>" . _('Name') . "</th>\n";
  166. echo " <td><input class=\"wide\" type=\"text\" name=\"templ_name\" value=\"" . $templ_details['name'] . "\"></td>\n";
  167. echo " </tr>\n";
  168. echo " <tr>\n";
  169. echo " <th>" . _('Description') . "</th>\n";
  170. echo " <td><input class=\"wide\" type=\"text\" name=\"templ_descr\" value=\"" . $templ_details['descr'] . "\"></td>\n";
  171. echo " </tr>\n";
  172. echo " </table>\n";
  173. echo " <input type=\"submit\" class=\"button\" name=\"edit\" value=\"" . _('Commit changes') . "\">\n";
  174. echo " </form>\n";
  175. echo " <input type=\"button\" class=\"button\" OnClick=\"location.href='add_zone_templ_record.php?id=" . $zone_templ_id . "'\" value=\"" . _('Add record') . "\">&nbsp;&nbsp\n";
  176. echo " <input type=\"button\" class=\"button\" OnClick=\"location.href='delete_zone_templ.php?id=" . $zone_templ_id . "'\" value=\"" . _('Delete zone template') . "\">\n";
  177. }
  178. }
  179. include_once("inc/footer.inc.php");