Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

delete_user.php 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 user deletion
  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. verify_permission('user_edit_own') ? $perm_edit_own = "1" : $perm_edit_own = "0";
  33. verify_permission('user_edit_others') ? $perm_edit_others = "1" : $perm_edit_others = "0";
  34. verify_permission('user_is_ueberuser') ? $perm_is_godlike = "1" : $perm_is_godlike = "0";
  35. if (!(isset($_GET['id']) && v_num($_GET['id']))) {
  36. error(ERR_INV_INPUT);
  37. include_once("inc/footer.inc.php");
  38. exit;
  39. } else {
  40. $uid = $_GET['id'];
  41. }
  42. if (isset($_POST['commit'])) {
  43. if (is_valid_user($uid)) {
  44. $zones = array();
  45. if (isset($_POST['zone'])) {
  46. $zones = $_POST['zone'];
  47. }
  48. if (delete_user($uid, $zones)) {
  49. success(SUC_USER_DEL);
  50. }
  51. } else {
  52. header("Location: users.php");
  53. exit;
  54. }
  55. } else {
  56. if (($uid != $_SESSION['userid'] && $perm_edit_others == "0") || ($uid == $_SESSION['userid'] && $perm_is_godlike == "0")) {
  57. error(ERR_PERM_DEL_USER);
  58. include_once("inc/footer.inc.php");
  59. exit;
  60. } else {
  61. $fullname = get_fullname_from_userid($uid);
  62. $zones = get_zones("own", $uid);
  63. echo " <h2>" . _('Delete user') . " \"" . $fullname . "\"</h2>\n";
  64. echo " <form method=\"post\" action=\"\">\n";
  65. echo " <table>\n";
  66. if (count($zones) > 0) {
  67. $users = show_users();
  68. echo " <tr>\n";
  69. echo " <td colspan=\"5\">\n";
  70. echo " " . _('You are about to delete a user. This user is owner for a number of zones. Please decide what to do with these zones.') . "\n";
  71. echo " </td>\n";
  72. echo " </tr>\n";
  73. echo " <tr>\n";
  74. echo " <th>" . _('Zone') . "</th>\n";
  75. echo " <th>" . _('Delete') . "</th>\n";
  76. echo " <th>" . _('Leave') . "</th>\n";
  77. echo " <th>" . _('Add new owner') . "</th>\n";
  78. echo " <th>" . _('Owner to be added') . "</th>\n";
  79. echo " </tr>\n";
  80. foreach ($zones as $zone) {
  81. echo " <input type=\"hidden\" name=\"zone[" . $zone['id'] . "][zid]\" value=\"" . $zone['id'] . "\">\n";
  82. echo " <tr>\n";
  83. echo " <td>" . $zone['name'] . "</td>\n";
  84. echo " <td><input type=\"radio\" name=\"zone[" . $zone['id'] . "][target]\" value=\"delete\"></td>\n";
  85. echo " <td><input type=\"radio\" name=\"zone[" . $zone['id'] . "][target]\" value=\"leave\" CHECKED></td>\n";
  86. echo " <td><input type=\"radio\" name=\"zone[" . $zone['id'] . "][target]\" value=\"new_owner\"></td>\n";
  87. echo " <td>\n";
  88. echo " <select name=\"zone[" . $zone['id'] . "][newowner]\">\n";
  89. foreach ($users as $user) {
  90. echo " <option value=\"" . $user["id"] . "\">" . $user["fullname"] . "</option>\n";
  91. }
  92. echo " </select>\n";
  93. echo " </td>\n";
  94. echo " </tr>\n";
  95. }
  96. }
  97. echo " <tr>\n";
  98. echo " <td colspan=\"5\">\n";
  99. echo " " . _('Really delete this user?') . "\n";
  100. echo " </td>\n";
  101. echo " </tr>\n";
  102. echo " </table>\n";
  103. echo " <input type=\"submit\" class=\"button\" name=\"commit\" value=\"" . _('Commit changes') . "\">\n";
  104. echo " </form>\n";
  105. }
  106. }
  107. include_once("inc/footer.inc.php");