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.

delete_record.php 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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-2014 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 record deletions from zones
  24. *
  25. * @package Poweradmin
  26. * @copyright 2007-2010 Rejo Zenger <rejo@zenger.nl>
  27. * @copyright 2010-2014 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. $record_id = "-1";
  34. if (isset($_GET['id']) && v_num($_GET['id'])) {
  35. $record_id = $_GET['id'];
  36. }
  37. $confirm = "-1";
  38. if (isset($_GET['confirm']) && v_num($_GET['confirm'])) {
  39. $confirm = $_GET['confirm'];
  40. }
  41. if (verify_permission('zone_content_edit_others')) {
  42. $perm_content_edit = "all";
  43. } elseif (verify_permission('zone_content_edit_own')) {
  44. $perm_content_edit = "own";
  45. } else {
  46. $perm_content_edit = "none";
  47. }
  48. $zid = get_zone_id_from_record_id($_GET['id']);
  49. if ($zid == NULL) {
  50. header("Location: list_zones.php");
  51. exit;
  52. }
  53. $user_is_zone_owner = verify_user_is_owner_zoneid($zid);
  54. $zone_info = get_zone_info_from_id($zid);
  55. if ($record_id == "-1") {
  56. error(ERR_INV_INPUT);
  57. } else {
  58. if ($confirm == '1') {
  59. $record_info = get_record_from_id($record_id);
  60. if (delete_record($record_id)) {
  61. success("<a href=\"edit.php?id=" . $zid . "\">" . SUC_RECORD_DEL . "</a>");
  62. if (isset($record_info['prio'])) {
  63. log_info(sprintf('client_ip:%s user:%s operation:delete_record record_type:%s record:%s content:%s ttl:%s priority:%s',
  64. $_SERVER['REMOTE_ADDR'], $_SESSION["userlogin"],
  65. $record_info['type'], $record_info['name'], $record_info['content'], $record_info['ttl'], $record_info['prio'] ));
  66. } else {
  67. log_info(sprintf('client_ip:%s user:%s operation:delete_record record_type:%s record:%s content:%s ttl:%s',
  68. $_SERVER['REMOTE_ADDR'], $_SESSION["userlogin"],
  69. $record_info['type'], $record_info['name'], $record_info['content'], $record_info['ttl'] ));
  70. }
  71. delete_record_zone_templ($record_id);
  72. // update serial after record deletion
  73. update_soa_serial($zid);
  74. if ($pdnssec_use) {
  75. // do also rectify-zone
  76. if (dnssec_rectify_zone($zid)) {
  77. success(SUC_EXEC_PDNSSEC_RECTIFY_ZONE);
  78. }
  79. }
  80. }
  81. } else {
  82. $zone_id = recid_to_domid($record_id);
  83. $zone_name = get_zone_name_from_id($zone_id);
  84. $user_is_zone_owner = verify_user_is_owner_zoneid($zone_id);
  85. $record_info = get_record_from_id($record_id);
  86. echo " <h2>" . _('Delete record in zone') . " \"<a href=\"edit.php?id=" . $zid . "\">" . $zone_name . "</a>\"</h2>\n";
  87. if ($zone_info['type'] == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0") {
  88. error(ERR_PERM_EDIT_RECORD);
  89. } else {
  90. echo " <table>\n";
  91. echo " <tr>\n";
  92. echo " <th>Name</th>\n";
  93. echo " <th>Type</th>\n";
  94. echo " <th>Content</th>\n";
  95. if (isset($record_info['prio'])) {
  96. echo " <th>Priority</th>\n";
  97. }
  98. echo " <th>TTL</th>\n";
  99. echo " </tr>\n";
  100. echo " <tr>\n";
  101. echo " <td>" . $record_info['name'] . "</td>\n";
  102. echo " <td>" . $record_info['type'] . "</td>\n";
  103. echo " <td>" . $record_info['content'] . "</td>\n";
  104. if (isset($record_info['prio'])) {
  105. echo " <td>" . $record_info['prio'] . "</td>\n";
  106. }
  107. echo " <td>" . $record_info['ttl'] . "</td>\n";
  108. echo " </tr>\n";
  109. echo " </table>\n";
  110. if (($record_info['type'] == 'NS' && $record_info['name'] == $zone_name) || $record_info['type'] == 'SOA') {
  111. echo " <p>" . _('You are trying to delete a record that is needed for this zone to work.') . "</p>\n";
  112. }
  113. echo " <p>" . _('Are you sure?') . "</p>\n";
  114. echo " <input type=\"button\" class=\"button\" OnClick=\"location.href='delete_record.php?id=" . $record_id . "&amp;confirm=1'\" value=\"" . _('Yes') . "\">\n";
  115. echo " <input type=\"button\" class=\"button\" OnClick=\"location.href='edit.php?id=" . $zid . "'\" value=\"" . _('No') . "\">\n";
  116. }
  117. }
  118. }
  119. include_once("inc/footer.inc.php");