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.

dnssec_add_key.php 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 add new supermaster servers
  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_id = "-1";
  33. if (isset($_GET['id']) && v_num($_GET['id'])) {
  34. $zone_id = $_GET['id'];
  35. }
  36. $user_is_zone_owner = do_hook('verify_user_is_owner_zoneid' , $zone_id );
  37. if ($user_is_zone_owner == "0") {
  38. error(ERR_PERM_VIEW_ZONE);
  39. include_once("inc/footer.inc.php");
  40. exit();
  41. }
  42. if (zone_id_exists($zone_id) == "0") {
  43. error(ERR_ZONE_NOT_EXIST);
  44. include_once("inc/footer.inc.php");
  45. exit();
  46. }
  47. $key_type = "";
  48. if (isset($_POST['key_type'])) {
  49. $key_type = $_POST['key_type'];
  50. if ($key_type != 'ksk' && $key_type != 'zsk') {
  51. error(ERR_INV_INPUT);
  52. include_once("inc/footer.inc.php");
  53. exit;
  54. }
  55. }
  56. $bits = "";
  57. if (isset($_POST["bits"])) {
  58. $bits = $_POST["bits"];
  59. $valid_values = array('2048', '1024', '768', '384', '256');
  60. if (!in_array($bits, $valid_values)) {
  61. error(ERR_INV_INPUT);
  62. include_once("inc/footer.inc.php");
  63. exit;
  64. }
  65. }
  66. $algorithm = "";
  67. if (isset($_POST["algorithm"])) {
  68. $algorithm = $_POST["algorithm"];
  69. $valid_algorithm = array('rsasha1', 'rsasha256', 'rsasha512', 'gost', 'ecdsa256', 'ecdsa384');
  70. if (!in_array($algorithm, $valid_algorithm)) {
  71. error(ERR_INV_INPUT);
  72. include_once("inc/footer.inc.php");
  73. exit;
  74. }
  75. }
  76. $domain_name = get_zone_name_from_id($zone_id);
  77. if (isset($_POST["submit"])) {
  78. if (dnssec_add_zone_key($domain_name, $key_type, $bits, $algorithm)) {
  79. success(SUC_EXEC_PDNSSEC_ADD_ZONE_KEY);
  80. } else {
  81. error(ERR_EXEC_PDNSSEC_ADD_ZONE_KEY);
  82. }
  83. }
  84. echo " <h2>" . _('Add key for zone '). $domain_name . "</h2>\n";
  85. echo " <form method=\"post\" action=\"dnssec_add_key.php?id=".$zone_id."\">\n";
  86. echo " <table>\n";
  87. echo " <tr>\n";
  88. echo " <td width=\"100\" class=\"n\">" . _('Key type') . "</td>\n";
  89. echo " <td class=\"n\">\n";
  90. echo " <select name=\"key_type\">\n";
  91. echo " <option value=\"\"></option>\n";
  92. echo " <option value=\"ksk\">KSK</option>\n";
  93. echo " <option value=\"zsk\">ZSK</option>\n";
  94. echo " </select>\n";
  95. echo " </td>\n";
  96. echo " </tr>\n";
  97. echo " <tr>\n";
  98. echo " <td class=\"n\">" . _('Bits in length') . "</td>\n";
  99. echo " <td class=\"n\">\n";
  100. echo " <select name=\"bits\">\n";
  101. echo " <option value=\"\"></option>\n";
  102. echo " <option value=\"2048\">2048</option>\n";
  103. echo " <option value=\"1024\">1024</option>\n";
  104. echo " <option value=\"768\">768</option>\n";
  105. echo " <option value=\"384\">384</option>\n";
  106. echo " <option value=\"256\">256</option>\n";
  107. echo " </select>\n";
  108. echo " </td>\n";
  109. echo " </tr>\n";
  110. echo " <tr>\n";
  111. echo " <td class=\"n\">" . _('Algorithm') . "</td>\n";
  112. echo " <td class=\"n\">\n";
  113. echo " <select name=\"algorithm\">\n";
  114. echo " <option value=\"\"></option>\n";
  115. echo " <option value=\"rsasha1\">".dnssec_shorthand_to_algorithm_name('rsasha1')."</option>\n";
  116. echo " <option value=\"rsasha256\">".dnssec_shorthand_to_algorithm_name('rsasha256')."</option>\n";
  117. echo " <option value=\"rsasha512\">".dnssec_shorthand_to_algorithm_name('rsasha512')."</option>\n";
  118. echo " <option value=\"gost\">".dnssec_shorthand_to_algorithm_name('gost')."</option>\n";
  119. echo " <option value=\"ecdsa256\">".dnssec_shorthand_to_algorithm_name('ecdsa256')."</option>\n";
  120. echo " <option value=\"ecdsa384\">".dnssec_shorthand_to_algorithm_name('ecdsa384')."</option>\n";
  121. echo " </select>\n";
  122. echo " </td>\n";
  123. echo " </tr>\n";
  124. echo " <tr>\n";
  125. echo " <td class=\"n\">&nbsp;</td>\n";
  126. echo " <td class=\"n\">\n";
  127. echo " <input type=\"submit\" class=\"button\" name=\"submit\" value=\"" . _('Add key') . "\">\n";
  128. echo " </td>\n";
  129. echo " </tr>\n";
  130. echo " </table>\n";
  131. echo " </form>\n";
  132. include_once("inc/footer.inc.php");