You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

edit_record.php 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 requests to edit zone records
  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. global $pdnssec_use;
  33. if (do_hook('verify_permission', 'zone_content_view_others')) {
  34. $perm_view = "all";
  35. } elseif (do_hook('verify_permission', 'zone_content_view_own')) {
  36. $perm_view = "own";
  37. } else {
  38. $perm_view = "none";
  39. }
  40. if (do_hook('verify_permission', 'zone_content_edit_others')) {
  41. $perm_content_edit = "all";
  42. } elseif (do_hook('verify_permission', 'zone_content_edit_own')) {
  43. $perm_content_edit = "own";
  44. } elseif (do_hook('verify_permission', 'zone_content_edit_own_as_client')) {
  45. $perm_content_edit = "own_as_client";
  46. } else {
  47. $perm_content_edit = "none";
  48. }
  49. if (do_hook('verify_permission', 'zone_meta_edit_others')) {
  50. $perm_meta_edit = "all";
  51. } elseif (do_hook('verify_permission', 'zone_meta_edit_own')) {
  52. $perm_meta_edit = "own";
  53. } else {
  54. $perm_meta_edit = "none";
  55. }
  56. $zid = get_zone_id_from_record_id($_GET['id']);
  57. $user_is_zone_owner = do_hook('verify_user_is_owner_zoneid' , $zid );
  58. $zone_type = get_domain_type($zid);
  59. $zone_name = get_zone_name_from_id($zid);
  60. if (isset($_POST["commit"])) {
  61. if ($zone_type == "SLAVE" || $perm_content_edit == "none" || ($perm_content_edit == "own" || $perm_content_edit == "own_as_client") && $user_is_zone_owner == "0") {
  62. error(ERR_PERM_EDIT_RECORD);
  63. } else {
  64. $old_record_info = get_record_from_id($_POST["rid"]);
  65. $ret_val = edit_record($_POST);
  66. if ($ret_val == "1") {
  67. if ($_POST['type'] != "SOA") {
  68. update_soa_serial($zid);
  69. }
  70. success(SUC_RECORD_UPD);
  71. $new_record_info = get_record_from_id($_POST["rid"]);
  72. log_info(sprintf('client_ip:%s user:%s operation:edit_record'
  73. .' old_record_type:%s old_record:%s old_content:%s old_ttl:%s old_priority:%s'
  74. .' record_type:%s record:%s content:%s ttl:%s priority:%s',
  75. $_SERVER['REMOTE_ADDR'], $_SESSION["userlogin"],
  76. $old_record_info['type'], $old_record_info['name'], $old_record_info['content'], $old_record_info['ttl'], $old_record_info['prio'],
  77. $new_record_info['type'], $new_record_info['name'], $new_record_info['content'], $new_record_info['ttl'], $new_record_info['prio']));
  78. if ($pdnssec_use) {
  79. if (dnssec_rectify_zone($zid)) {
  80. success(SUC_EXEC_PDNSSEC_RECTIFY_ZONE);
  81. }
  82. }
  83. }
  84. }
  85. }
  86. echo " <h2>" . _('Edit record in zone') . " \"<a href=\"edit.php?id=" . $zid . "\">" . $zone_name . "</a>\"</h2>\n";
  87. if ($perm_view == "none" || $perm_view == "own" && $user_is_zone_owner == "0") {
  88. error(ERR_PERM_VIEW_RECORD);
  89. } else {
  90. $record = get_record_from_id($_GET["id"]);
  91. echo " <form method=\"post\" action=\"edit_record.php?domain=" . $zid . "&amp;id=" . $_GET["id"] . "\">\n";
  92. echo " <table>\n";
  93. echo " <tr>\n";
  94. echo " <th>" . _('Name') . "</th>\n";
  95. echo " <th>&nbsp;</th>\n";
  96. echo " <th>" . _('Type') . "</th>\n";
  97. echo " <th>" . _('Content') . "</th>\n";
  98. echo " <th>" . _('Priority') . "</th>\n";
  99. echo " <th>" . _('TTL') . "</th>\n";
  100. echo " </tr>\n";
  101. if ($zone_type == "SLAVE" || $perm_content_edit == "none" || ($perm_content_edit == "own" || $perm_content_edit == "own_as_client") && $user_is_zone_owner == "0") {
  102. echo " <tr>\n";
  103. echo " <td>" . $record["name"] . "</td>\n";
  104. echo " <td>IN</td>\n";
  105. echo " <td>" . htmlspecialchars($record["type"]) . "</td>\n";
  106. echo " <td>" . htmlspecialchars($record['content']) . "</td>\n";
  107. echo " <td>" . htmlspecialchars($record["prio"]) . "</td>\n";
  108. echo " <td>" . htmlspecialchars($record["ttl"]) . "</td>\n";
  109. echo " </tr>\n";
  110. } else {
  111. echo " <tr>\n";
  112. echo " <td><input type=\"hidden\" name=\"rid\" value=\"" . $_GET["id"] . "\">\n";
  113. echo " <input type=\"hidden\" name=\"zid\" value=\"" . $zid . "\">\n";
  114. echo " <input type=\"text\" name=\"name\" value=\"" . htmlspecialchars(trim(str_replace($zone_name, '', $record["name"]), '.')) . "\" class=\"input\">." . $zone_name . "</td>\n";
  115. echo " <td>IN</td>\n";
  116. echo " <td>\n";
  117. echo " <select name=\"type\">\n";
  118. $found_selected_type = false;
  119. foreach (get_record_types() as $type_available) {
  120. if ($type_available == $record["type"]) {
  121. $add = " SELECTED";
  122. $found_selected_type = true;
  123. } else {
  124. $add = "";
  125. }
  126. echo " <option" . $add . " value=\"" . htmlspecialchars($type_available) . "\" >" . $type_available . "</option>\n";
  127. }
  128. if (!$found_selected_type)
  129. echo " <option SELECTED value=\"" . htmlspecialchars($record['type']) . "\"><i>" . $record['type'] . "</i></option>\n";
  130. echo " </select>\n";
  131. echo " </td>\n";
  132. echo " <td><input type=\"text\" name=\"content\" value=\"" . htmlspecialchars($record['content']) . "\" class=\"input\"></td>\n";
  133. echo " <td><input type=\"text\" name=\"prio\" value=\"" . htmlspecialchars($record["prio"]) . "\" class=\"sinput\"></td>\n";
  134. echo " <td><input type=\"text\" name=\"ttl\" value=\"" . htmlspecialchars($record["ttl"]) . "\" class=\"sinput\"></td>\n";
  135. echo " </tr>\n";
  136. }
  137. echo " </table>\n";
  138. echo " <input type=\"submit\" name=\"commit\" value=\"" . _('Commit changes') . "\" class=\"button\">&nbsp;&nbsp;\n";
  139. echo " <input type=\"reset\" name=\"reset\" value=\"" . _('Reset changes') . "\" class=\"button\">&nbsp;&nbsp;\n";
  140. echo " </form>\n";
  141. }
  142. include_once("inc/footer.inc.php");