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 $owner = "-1"; |
25 { |
26 if ((isset($_POST['owner'])) && (v_num($_POST['owner']))) { |
26 error(ERR_LEVEL_5); |
27 $owner = $_POST['owner']; |
27 |
|
28 } |
28 } |
29 |
29 |
30 if (isset($_POST["submit"])) |
30 $dom_type = "NATIVE"; |
31 { |
31 if (isset($_POST["dom_type"]) && (in_array($_POST['dom_type'], $server_types))) { |
32 $domain = (isset($_POST['domain']) ? trim($_POST["domain"]) : ''); |
32 $dom_type = $_POST["dom_type"]; |
33 $owner = (isset($_POST['owner']) ? $_POST["owner"] : 0 ); |
33 } |
34 $webip = (isset($_POST["webip"]) ? $_POST['webip'] : ''); |
34 |
35 $mailip = (isset($_POST["mailip"]) ? $_POST['mailip'] : ''); |
35 $domain = trim($_POST["domain"]); |
36 $empty = (isset($_POST["empty"]) ? $_POST['empty'] : 0); |
36 $webip = $_POST["webip"]; |
37 $dom_type = (isset($_POST["dom_type"]) ? $_POST["dom_type"] : "NATIVE"); |
37 $mailip = $_POST["mailip"]; |
38 if(!$empty) |
38 $empty = $_POST["empty"]; |
39 { |
39 |
|
40 (verify_permission(zone_master_add)) ? $zone_master_add = "1" : $zone_master_add = "0" ; |
|
41 |
|
42 if ($_POST['submit'] && $zone_master_add == "1" ) { |
|
43 |
|
44 // Boy. I will be happy when I have found the time to replace |
|
45 // this "template wanabee" code with something that is really |
|
46 // worth to be called "templating". Whoever wrote this should |
|
47 // be... should be... how can I say this politicaly correct? |
|
48 // 20080303/RZ |
|
49 |
|
50 if(!$empty) { |
40 $empty = 0; |
51 $empty = 0; |
41 if(!eregi('in-addr.arpa', $domain) && (!is_valid_ip($webip) || !is_valid_ip($mailip)) ) |
52 if(!eregi('in-addr.arpa', $domain) && (!is_valid_ip($webip) || !is_valid_ip($mailip)) ) { |
42 { |
53 error(_('Web or mail ip is invalid!')); |
43 $error = "Web or Mail ip is invalid!"; |
54 $error = "1"; |
44 } |
55 } |
45 } |
56 } |
46 if (!isset($error)) |
57 |
47 { |
58 if (!$error) { |
48 if (!is_valid_domain($domain)) |
59 if (!is_valid_domain($domain)) { |
49 { |
60 error(_('Zone name is invalid!')); |
50 $error = "Zone name is invalid!"; |
61 $error = "1"; |
51 } |
62 } elseif (domain_exists($domain)) { |
52 elseif (domain_exists($domain)) |
63 error(_('Zone already exists!!')); |
53 { |
64 $error = "1"; |
54 $error = "Zone already exists!"; |
65 } else { |
55 } |
66 if (add_domain($domain, $owner, $webip, $mailip, $empty, $dom_type, '')) { |
56 //elseif (isset($mailip) && is_valid_ip( |
67 success(SUC_ZONE_ADD); |
57 else |
68 unset($domain, $owner, $webip, $mailip, $empty, $dom_type); |
58 { |
69 } else { |
59 add_domain($domain, $owner, $webip, $mailip, $empty, $dom_type, ''); |
70 $error = "1"; |
60 $success = _('Successfully added master zone.'); |
71 } |
61 } |
72 } |
62 } |
73 } |
63 } |
74 } |
64 |
75 |
65 include_once("inc/header.inc.php"); |
76 echo " <h2>" . _('Add master zone') . "</h2>\n"; |
66 |
77 |
67 if ((isset($error)) && ($error != "")) |
78 if ( $zone_master_add != "1" ) { |
68 { |
79 echo " <p>" . _("You do not have the permission to add a new master zone.") . "</p>\n"; |
69 ?><div class="error"><?php echo _('Error'); ?>: <?php echo $error; ?></div><?php |
80 } else { |
70 } |
81 $available_zone_types = array("MASTER", "NATIVE"); |
71 elseif ((isset($success)) && ($success != "")) |
82 $users = show_users(); |
72 { |
|
73 ?><div class="success"><?php echo $success; ?></div><?php |
|
74 } |
|
75 |
83 |
76 ?> |
84 echo " <form method=\"post\" action=\"add_zone_master.php\">\n"; |
77 <h2>Add master zone</h2> |
85 echo " <table>\n"; |
78 <?php |
86 echo " <tr>\n"; |
79 |
87 echo " <td class=\"n\">" . _('Zone name') . ":</td>\n"; |
80 // Zone type set to master and native only, slave zones are created |
88 echo " <td class=\"n\">\n"; |
81 // on a different page. |
89 echo " <input type=\"text\" class=\"input\" name=\"domain\" value=\"" . $domain . "\">\n"; |
82 $zone_types = array("MASTER", "NATIVE"); |
90 echo " </td>\n"; |
83 $users = show_users(); |
91 echo " </tr>\n"; |
84 ?> |
92 echo " <tr>\n"; |
85 <form method="post" action="add_zone_master.php"> |
93 echo " <td class=\"n\">" . _('Web IP') . ":</td>\n"; |
86 <table> |
94 echo " <td class=\"n\">\n"; |
87 <tr> |
95 echo " <input type=\"text\" class=\"input\" name=\"webip\" value=\"" . $webip . "\">\n"; |
88 <td class="n"><?php echo _('Zone name'); ?>:</td> |
96 echo " </td>\n"; |
89 <td class="n"> |
97 echo " </tr>\n"; |
90 <input type="text" class="input" name="domain" value="<?php if (isset($error)) print $_POST["domain"]; ?>"> |
98 echo " <tr>\n"; |
91 </td> |
99 echo " <td class=\"n\">" . _('Mail IP') . ":</td>\n"; |
92 </tr> |
100 echo " <td class=\"n\">\n"; |
93 <tr> |
101 echo " <input type=\"text\" class=\"input\" name=\"mailip\" value=\"" . $mailip . "\">\n"; |
94 <td class="n"><?php echo _('Web IP'); ?>:</td> |
102 echo " </td>\n"; |
95 <td class="n"> |
103 echo " </tr>\n"; |
96 <input type="text" class="input" name="webip" value="<?php if (isset($error)) print $_POST["webip"]; ?>"> |
104 echo " <tr>\n"; |
97 </td> |
105 echo " <td class=\"n\">" . _('Owner') . ":</td>\n"; |
98 </tr> |
106 echo " <td class=\"n\">\n"; |
99 <tr> |
107 echo " <select name=\"owner\">\n"; |
100 <td class="n"><?php echo _('Mail IP'); ?>:</TD> |
108 foreach ($users as $user) { |
101 <td class="n"> |
109 echo " <option value=\"" . $user['id'] . "\">" . $user['fullname'] . "</option>\n"; |
102 <input type="text" class="input" name="mailip" value="<?php if (isset($error)) print $_POST["mailip"]; ?>"> |
|
103 </td> |
|
104 </tr> |
|
105 <tr> |
|
106 <td class="n"><?php echo _('Owner'); ?>:</td> |
|
107 <td class="n"> |
|
108 <select name="owner"> |
|
109 <?php |
|
110 foreach ($users as $u) |
|
111 { |
|
112 ?><option value="<?php echo $u['id'] ?>"><?php echo $u['fullname'] ?></option><?php |
|
113 } |
110 } |
114 ?> |
111 echo " </select>\n"; |
115 </select> |
112 echo " </td>\n"; |
116 </td> |
113 echo " </tr>\n"; |
117 </tr> |
114 echo " <tr>\n"; |
118 <tr> |
115 echo " <td class=\"n\">" . _('Zone type') . ":</td>\n"; |
119 <td class="n"><?php echo _('Zone type'); ?>:</td> |
116 echo " <td class=\"n\">\n"; |
120 <td class="n"> |
117 echo " <select name=\"dom_type\">\n"; |
121 <select name="dom_type"> |
118 foreach($available_zone_types as $type) { |
122 <?php |
119 echo " <option value=\"" . $type . "\">" . strtolower($type) . "</option>\n"; |
123 foreach($zone_types as $s) |
|
124 { |
|
125 ?><option value="<?php echo $s?>"><?php echo $s ?></option><?php |
|
126 } |
120 } |
127 ?> |
121 echo " </select>\n"; |
128 </select> |
122 echo " </td>\n"; |
129 </td> |
123 echo " </tr>\n"; |
130 </tr> |
124 echo " <tr>\n"; |
131 <tr> |
125 echo " <td class=\"n\">" . _('Create zone without applying records-template') . "</td>\n"; |
132 <td class="n"><?php echo _('Create zone without applying records-template'); ?>:</td> |
126 echo " <td class=\"n\"><input type=\"checkbox\" name=\"empty\" value=\"1\"></td>\n"; |
133 <td class="n"><input type="checkbox" name="empty" value="1"></td> |
127 echo " </tr>\n"; |
134 </tr> |
128 echo " <tr>\n"; |
135 <tr> |
129 echo " <td class=\"n\"> </td>\n"; |
136 <td class="n"> </td> |
130 echo " <td class=\"n\">\n"; |
137 <td class="n"> |
131 echo " <input type=\"submit\" class=\"button\" name=\"submit\" value=\"" . _('Add zone') . "\">\n"; |
138 <input type="submit" class="button" name="submit" value="<?php echo _('Add zone'); ?>"> |
132 echo " </td>\n"; |
139 </td> |
133 echo " </tr>\n"; |
140 </tr> |
134 echo " </table>\n"; |
141 </table> |
135 echo " </form>\n"; |
142 </form> |
136 } |
143 <?php |
|
144 |
137 |
145 include_once("inc/footer.inc.php"); |
138 include_once("inc/footer.inc.php"); |