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

bulk_registration.php 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 bulk zone registration
  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. $owner = "-1";
  33. if ((isset($_POST['owner'])) && (v_num($_POST['owner']))) {
  34. $owner = $_POST['owner'];
  35. }
  36. $dom_type = "NATIVE";
  37. if (isset($_POST["dom_type"]) && (in_array($_POST['dom_type'], $server_types))) {
  38. $dom_type = $_POST["dom_type"];
  39. }
  40. if (isset($_POST['domains'])) {
  41. $domains = explode("\r\n", $_POST['domains']);
  42. foreach ($domains as $key => $domain) {
  43. $domain = trim($domain);
  44. if ($domain == '') {
  45. unset($domains[$key]);
  46. } else {
  47. $domains[$key] = $domain;
  48. }
  49. }
  50. } else {
  51. $domains = array();
  52. }
  53. if (isset($_POST['zone_template'])) {
  54. $zone_template = $_POST['zone_template'];
  55. } else {
  56. $zone_template = "none";
  57. }
  58. /*
  59. Check user permissions
  60. */
  61. (do_hook('verify_permission' , 'zone_master_add' )) ? $zone_master_add = "1" : $zone_master_add = "0";
  62. (do_hook('verify_permission' , 'user_view_others' )) ? $perm_view_others = "1" : $perm_view_others = "0";
  63. if (isset($_POST['submit']) && $zone_master_add == "1") {
  64. $error = false;
  65. foreach ($domains as $domain) {
  66. if (!is_valid_hostname_fqdn($domain, 0)) {
  67. error($domain . ' failed - ' . ERR_DNS_HOSTNAME);
  68. } elseif (domain_exists($domain)) {
  69. error($domain . " failed - " . ERR_DOMAIN_EXISTS);
  70. $error = true;
  71. } elseif (add_domain($domain, $owner, $dom_type, '', $zone_template)) {
  72. success("<a href=\"edit.php?id=" . get_zone_id_from_name($domain) . "\">" . $domain . " - " . SUC_ZONE_ADD . '</a>');
  73. }
  74. }
  75. if (false === $error) {
  76. unset($domains, $owner, $dom_type, $zone_template);
  77. }
  78. }
  79. if ($zone_master_add != "1") {
  80. error(ERR_PERM_ADD_ZONE_MASTER);
  81. } else {
  82. echo " <h2>" . _('Bulk registration') . "</h2>\n";
  83. $available_zone_types = array("MASTER", "NATIVE");
  84. $users = do_hook('show_users');
  85. $zone_templates = get_list_zone_templ($_SESSION['userid']);
  86. echo " <form method=\"post\" action=\"bulk_registration.php\">\n";
  87. echo " <table>\n";
  88. echo " <tr>\n";
  89. echo " <td class=\"n\" width=\"100\">" . _('Owner') . ":</td>\n";
  90. echo " <td class=\"n\">\n";
  91. echo " <select name=\"owner\">\n";
  92. /*
  93. Display list of users to assign zone to if creating
  94. user has the proper permission to do so.
  95. */
  96. foreach ($users as $user) {
  97. if ($user['id'] === $_SESSION['userid']) {
  98. echo " <option value=\"" . $user['id'] . "\" selected>" . $user['fullname'] . "</option>\n";
  99. } elseif ($perm_view_others == "1") {
  100. echo " <option value=\"" . $user['id'] . "\">" . $user['fullname'] . "</option>\n";
  101. }
  102. }
  103. echo " </select>\n";
  104. echo " </td>\n";
  105. echo " </tr>\n";
  106. echo " <tr>\n";
  107. echo " <td class=\"n\">" . _('Type') . ":</td>\n";
  108. echo " <td class=\"n\">\n";
  109. echo " <select name=\"dom_type\">\n";
  110. foreach ($available_zone_types as $type) {
  111. echo " <option value=\"" . $type . "\">" . strtolower($type) . "</option>\n";
  112. }
  113. echo " </select>\n";
  114. echo " </td>\n";
  115. echo " </tr>\n";
  116. echo " <tr>\n";
  117. echo " <td class=\"n\">" . _('Template') . ":</td>\n";
  118. echo " <td class=\"n\">\n";
  119. echo " <select name=\"zone_template\">\n";
  120. echo " <option value=\"none\">none</option>\n";
  121. foreach ($zone_templates as $zone_template) {
  122. echo " <option value=\"" . $zone_template['id'] . "\">" . $zone_template['name'] . "</option>\n";
  123. }
  124. echo " </select>\n";
  125. echo " </td>\n";
  126. echo " </tr>\n";
  127. echo " <tr>\n";
  128. echo " <td class=\"n\">" . _('Zones') . ":</td>\n";
  129. echo " <td class=\"n\">\n";
  130. echo " <ul id=\"domain_names\" style=\"list-style-type:none; padding:0 \">\n";
  131. echo " <li>" . _('Type one domain per line') . ":</li>\n";
  132. echo " <li><textarea class=\"input\" name=\"domains\" rows=\"10\" cols=\"30\" style=\"width: 500px;\">";
  133. if (isset($error) && isset($_POST['domains'])) {
  134. echo $_POST['domains'];
  135. }
  136. echo "</textarea></li>\n";
  137. echo " </ol>\n";
  138. echo " </td>\n";
  139. echo " </tr>\n";
  140. echo " <tr>\n";
  141. echo " <td class=\"n\">&nbsp;</td>\n";
  142. echo " <td class=\"n\">\n";
  143. echo " <input type=\"submit\" class=\"button\" name=\"submit\" value=\"" . _('Add zones') . "\">\n";
  144. echo " </td>\n";
  145. echo " </tr>\n";
  146. echo " </table>\n";
  147. echo " </form>\n";
  148. }
  149. include_once("inc/footer.inc.php");