18 * You should have received a copy of the GNU General Public License |
18 * You should have received a copy of the GNU General Public License |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 */ |
20 */ |
21 |
21 |
22 require_once("inc/toolkit.inc.php"); |
22 require_once("inc/toolkit.inc.php"); |
|
23 include_once("inc/header.inc.php"); |
23 |
24 |
24 if (!level(5)) |
25 $master_ip = $_POST["master_ip"]; |
|
26 $ns_name = $_POST["ns_name"]; |
|
27 $account = $_POST["account"]; |
|
28 |
|
29 (verify_permission(supermaster_add)) ? $supermasters_add = "1" : $supermasters_add = "0"; |
|
30 |
|
31 if($_POST["submit"]) |
25 { |
32 { |
26 error(ERR_LEVEL_5); |
33 if (add_supermaster($master_ip, $ns_name, $account)) { |
27 } |
34 echo " <div class=\"success\">" . _('Successfully added supermaster.') . "</div>\n"; |
28 |
35 } else { |
29 if(isset($_POST["submit"])) |
36 $error = "1"; |
30 { |
|
31 $master_ip = (isset($_POST['master_ip']) ? $_POST["master_ip"] : ''); |
|
32 $ns_name = (isset($_POST['ns_name']) ? $_POST["ns_name"] : ''); |
|
33 $account = (isset($_POST["account"]) ? $_POST['account'] : ''); |
|
34 if (!isset($error)) |
|
35 { |
|
36 if (!is_valid_ip($master_ip) && !is_valid_ip6($master_ip)) |
|
37 { |
|
38 $error = _('Given master IP address is not valid IPv4 or IPv6.'); |
|
39 } |
|
40 elseif (!is_valid_hostname($ns_name)) |
|
41 { |
|
42 $error = _('Given hostname for NS record not valid.'); |
|
43 } |
|
44 elseif (!validate_account($account)) |
|
45 { |
|
46 $error = _('Account name is not valid (may contain only alpha chars).'); |
|
47 } |
|
48 else |
|
49 { |
|
50 if(add_supermaster($master_ip, $ns_name, $account)) |
|
51 { |
|
52 $success = _('Successfully added supermaster.'); |
|
53 } |
|
54 } |
|
55 } |
37 } |
56 } |
38 } |
57 |
39 |
58 include_once("inc/header.inc.php"); |
40 echo " <h2>" . _('Add supermaster') . "</h2>\n"; |
59 |
41 |
60 if ((isset($error)) && ($error != "")) |
42 if ( $supermasters_add != "1" ) { |
61 { |
43 echo " <p>" . _("You do not have the permission to add a new supermaster.") . "</p>\n"; |
62 ?><div class="error"><?php echo _('Error'); ?>: <?php echo $error; ?></div><?php |
44 } else { |
63 } |
45 echo " <form method=\"post\" action=\"add_supermaster.php\">\n"; |
64 elseif ((isset($success)) && ($success != "")) |
46 echo " <table>\n"; |
65 { |
47 echo " <tr>\n"; |
66 ?><div class="success"><?php echo $success; ?></div><?php |
48 echo " <td class=\"n\">" . _('IP address of supermaster') . "</td>\n"; |
67 } |
49 echo " <td class=\"n\">\n"; |
68 |
50 if ($error) { |
69 ?> |
51 echo " <input type=\"text\" class=\"input\" name=\"master_ip\" value=\"" . $master_ip . "\">\n"; |
70 <h2><?php echo _('Add supermaster'); ?></h2> |
52 } else { |
71 <form method="post" action="add_supermaster.php"> |
53 echo " <input type=\"text\" class=\"input\" name=\"master_ip\" value=\"\">\n"; |
72 <table> |
54 } |
73 <tr> |
55 echo " </td>\n"; |
74 <td class="n"><?php echo _('IP address of supermaster'); ?>:</td> |
56 echo " </tr>\n"; |
75 <td class="n"> |
57 echo " <tr>\n"; |
76 <input type="text" class="input" name="master_ip" value="<?php if (isset($error)) print $_POST["master_ip"]; ?>"> |
58 echo " <td class=\"n\">" . _('Hostname in NS record') . "</td>\n"; |
77 </td> |
59 echo " <td class=\"n\">\n"; |
78 </tr> |
60 if ($error) { |
79 <tr> |
61 echo " <input type=\"text\" class=\"input\" name=\"ns_name\" value=\"" . $ns_name . "\">\n"; |
80 <td class="n"><?php echo _('Hostname in NS record'); ?>:</td> |
62 } else { |
81 <td class="n"> |
63 echo " <input type=\"text\" class=\"input\" name=\"ns_name\" value=\"\">\n"; |
82 <input type="text" class="input" name="ns_name" value="<?php if (isset($error)) print $_POST["ns_name"]; ?>"> |
64 } |
83 </td> |
65 echo " </td>\n"; |
84 </tr> |
66 echo " </tr>\n"; |
85 <tr> |
67 echo " <tr>\n"; |
86 <td class="n"><?php echo _('Account'); ?>:</td> |
68 echo " <td class=\"n\">" . _('Account') . "</td>\n"; |
87 <td class="n"> |
69 echo " <td class=\"n\">\n"; |
88 <input type="text" class="input" name="account" value="<?php if (isset($error)) print $_POST["account"]; ?>"> |
70 if ($error) { |
89 </td> |
71 echo " <input type=\"text\" class=\"input\" name=\"account\" value=\"" . $account . "\">\n"; |
90 </tr> |
72 } else { |
91 <tr> |
73 echo " <input type=\"text\" class=\"input\" name=\"account\" value=\"\">\n"; |
92 <td class="n"> </td> |
74 } |
93 <td class="n"> |
75 echo " </td>\n"; |
94 <input type="submit" class="button" name="submit" value="<?php echo _('Add supermaster'); ?>"> |
76 echo " </tr>\n"; |
95 </td> |
77 echo " <tr>\n"; |
96 </tr> |
78 echo " <td class=\"n\"> </td>\n"; |
97 </table> |
79 echo " <td class=\"n\">\n"; |
98 </form> |
80 echo " <input type=\"submit\" class=\"button\" name=\"submit\" value=\"" . _('Add supermaster') . "\">\n"; |
99 <?php |
81 echo " </td>\n"; |
|
82 echo " </tr>\n"; |
|
83 echo " </table>\n"; |
|
84 echo " </form>\n"; |
|
85 } |
100 include_once("inc/footer.inc.php"); |
86 include_once("inc/footer.inc.php"); |
101 ?> |
87 ?> |