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 $xsid = (isset($_GET['id'])) ? $_GET['id'] : $_POST['zoneid']; |
25 if (verify_permission(zone_content_view_others)) { $perm_view = "all" ; } |
25 if ((!level(5)) && ((!xs($xsid) || ($_SESSION[$xsid.'_ispartial'])))) { |
26 elseif (verify_permission(zone_content_view_own)) { $perm_view = "own" ; } |
26 error(ERR_RECORD_ACCESS_DENIED); |
27 else { $perm_view = "none" ; } |
|
28 |
|
29 if (verify_permission(zone_content_edit_others)) { $perm_content_edit = "all" ; } |
|
30 elseif (verify_permission(zone_content_edit_own)) { $perm_content_edit = "own" ; } |
|
31 else { $perm_content_edit = "none" ; } |
|
32 |
|
33 if (verify_permission(zone_meta_edit_others)) { $perm_meta_edit = "all" ; } |
|
34 elseif (verify_permission(zone_meta_edit_own)) { $perm_meta_edit = "own" ; } |
|
35 else { $perm_meta_edit = "none" ; } |
|
36 |
|
37 $zone_id = "-1"; |
|
38 if ((isset($_GET['id'])) && (v_num($_GET['id']))) { |
|
39 $zone_id = $_GET['id']; |
27 } |
40 } |
28 |
41 |
29 if (isset($_POST["commit"]) && isset($_POST['zoneid']) && isset($_POST['name']) && isset($_POST['type']) && isset($_POST['content']) && isset($_POST['ttl']) && isset($_POST['prio']) ) { |
42 $ttl = $DEFAULT_TTL; |
30 $ret = add_record($_POST["zoneid"], $_POST["name"], $_POST["type"], $_POST["content"], $_POST["ttl"], $_POST["prio"]); |
43 if ((isset($_POST['ttl'])) && (v_num($_POST['ttl']))) { |
31 if ($ret != '1') { |
44 $ttl = $_POST['ttl']; |
32 die("$ret"); |
|
33 } |
|
34 clean_page("edit.php?id=".$_POST["zoneid"]); |
|
35 } |
45 } |
36 |
46 |
37 include_once("inc/header.inc.php"); |
47 $prio = "10"; |
|
48 if ((isset($_GET['prio'])) && (v_num($_GET['prio']))) { |
|
49 $prio = $_GET['prio']; |
|
50 } |
|
51 |
|
52 $name = $_POST['name']; |
|
53 $type = $_POST['type']; |
|
54 $content = $_POST['content']; |
|
55 |
|
56 if ($zone_id == "-1") { |
|
57 error(ERR_INV_INPUT); |
|
58 include_once("inc/footer.inc.php"); |
|
59 exit; |
|
60 } |
|
61 |
|
62 $user_is_zone_owner = verify_user_is_owner_zoneid($zone_id); |
|
63 $zone_type = get_domain_type($zone_id); |
|
64 $zone_name = get_domain_name_from_id($zone_id); |
|
65 |
|
66 if ($_POST["commit"]) { |
|
67 if ( $zone_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) { |
|
68 error(ERR_PERM_ADD_RECORD); |
|
69 } else { |
|
70 if ( add_record($zone_id, $name, $type, $content, $ttl, $prio)) { |
|
71 success(_('The record was succesfully added.')); |
|
72 unset($zone_id, $name, $type, $content, $ttl, $prio); |
|
73 } |
|
74 } |
|
75 } |
|
76 |
|
77 echo " <h2>" . _('Add record in zone') . " " . $zone_name . "</h2>\n"; |
|
78 |
|
79 if ( $zone_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) { |
|
80 error(ERR_PERM_ADD_RECORD); |
|
81 } else { |
|
82 echo " <form method=\"post\">\n"; |
|
83 echo " <input type=\"hidden\" name=\"domain\" value=\"" . $zone_id . "\">\n"; |
|
84 echo " <table border=\"0\" cellspacing=\"4\">\n"; |
|
85 echo " <tr>\n"; |
|
86 echo " <td class=\"n\">" . _('Name') . "</td>\n"; |
|
87 echo " <td class=\"n\"> </td>\n"; |
|
88 echo " <td class=\"n\">" . _('Type') . "</td>\n"; |
|
89 echo " <td class=\"n\">" . _('Priority') . "</td>\n"; |
|
90 echo " <td class=\"n\">" . _('Content') . "</td>\n"; |
|
91 echo " <td class=\"n\">" . _('TTL') . "</td>\n"; |
|
92 echo " </tr>\n"; |
|
93 echo " <tr>\n"; |
|
94 echo " <td class=\"n\"><input type=\"text\" name=\"name\" class=\"input\" value=\"" . $name . "\">." . $zone_name . "</td>\n"; |
|
95 echo " <td class=\"n\">IN</td>\n"; |
|
96 echo " <td class=\"n\">\n"; |
|
97 echo " <select name=\"type\">\n"; |
|
98 foreach (get_record_types() as $record_type) { |
|
99 if ($type) { |
|
100 if ($type == $record_type) { |
|
101 $add = " SELECTED"; |
|
102 } else { |
|
103 unset ($add); |
|
104 } |
|
105 } else { |
|
106 if (eregi('in-addr.arpa', $zone_name) && strtoupper($record_type) == 'PTR') { |
|
107 $add = " SELECTED"; |
|
108 } elseif (strtoupper($record_type) == 'A') { |
|
109 $add = " SELECTED"; |
|
110 } else { |
|
111 unset($add); |
|
112 } |
|
113 } |
|
114 echo " <option" . $add . " value=\"" . $record_type . "\">" . $record_type . "</option>\n"; |
|
115 } |
|
116 echo " </select>\n"; |
|
117 echo " </td>\n"; |
|
118 echo " <td class=\"n\"><input type=\"text\" name=\"prio\" class=\"sinput\" value=\"" . $prio . "\"></td>\n"; |
|
119 echo " <td class=\"n\"><input type=\"text\" name=\"content\" class=\"input\" value=\"" . $content . "\"></td>\n"; |
|
120 echo " <td class=\"n\"><input type=\"text\" name=\"ttl\" class=\"sinput\" value=\"" . $ttl . "\"</td>\n"; |
|
121 echo " </tr>\n"; |
|
122 echo " </table>\n"; |
|
123 echo " <br>\n"; |
|
124 echo " <input type=\"submit\" name=\"commit\" value=\"" . _('Add record') . "\" class=\"button\">\n"; |
|
125 echo " </form>\n"; |
|
126 } |
|
127 |
|
128 include_once("inc/footer.inc.php"); |
|
129 |
38 ?> |
130 ?> |
39 |
|
40 <h2><?php echo _('Add record to zone'); ?> "<?php echo get_domain_name_from_id($_GET["id"]) ?>"</H2> |
|
41 |
|
42 <form method="post"> |
|
43 <input type="hidden" name="zoneid" value="<?php echo $_GET["id"] ?>"> |
|
44 <table border="0" cellspacing="4"> |
|
45 <tr> |
|
46 <td class="n"><?php echo _('Name'); ?></td> |
|
47 <td class="n"> </td> |
|
48 <td class="n"><?php echo _('Type'); ?></td> |
|
49 <td class="n"><?php echo _('Priority'); ?></td> |
|
50 <td class="n"><?php echo _('Content'); ?></td> |
|
51 <td class="n"><?php echo _('TTL'); ?></td> |
|
52 </tr> |
|
53 <tr> |
|
54 <td class="n"><input type="text" name="name" class="input">.<?php echo get_domain_name_from_id($_GET["id"]) ?></td> |
|
55 <td class="n">IN</td> |
|
56 <td class="n"> |
|
57 <select name="type"> |
|
58 <?php |
|
59 $dname = get_domain_name_from_id($_GET["id"]); |
|
60 foreach (get_record_types() as $c) { |
|
61 if (eregi('in-addr.arpa', $dname) && strtoupper($c) == 'PTR') { |
|
62 $add = " SELECTED"; |
|
63 } elseif (strtoupper($c) == 'A') { |
|
64 $add = " SELECTED"; |
|
65 } else { |
|
66 $add = ''; |
|
67 } |
|
68 ?><option<?php echo $add ?> value="<?php echo $c ?>"><?php echo $c ?></option><?php |
|
69 } |
|
70 ?> |
|
71 </select> |
|
72 </td> |
|
73 <td class="n"><input type="text" name="prio" class="sinput"></td> |
|
74 <td class="n"><input type="text" name="content" class="input"></td> |
|
75 <td class="n"><input type="text" name="ttl" class="sinput" value="<?php echo $DEFAULT_TTL?>"></td> |
|
76 </tr> |
|
77 </table> |
|
78 <br> |
|
79 <input type="submit" name="commit" value="<?php echo _('Add record'); ?>" class="button"> |
|
80 </form> |
|
81 |
|
82 <?php include_once("inc/footer.inc.php"); ?> |
|