1
|
1 |
<?php |
|
2 |
|
119
|
3 |
/* Poweradmin, a friendly web-based admin tool for PowerDNS. |
47
|
4 |
* See <https://rejo.zenger.nl/poweradmin> for more details. |
|
5 |
* |
|
6 |
* Copyright 2007, 2008 Rejo Zenger <rejo@zenger.nl> |
|
7 |
* |
|
8 |
* This program is free software: you can redistribute it and/or modify |
|
9 |
* it under the terms of the GNU General Public License as published by |
|
10 |
* the Free Software Foundation, either version 3 of the License, or |
|
11 |
* (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
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/>. |
|
20 |
*/ |
|
21 |
|
13
|
22 |
require_once("inc/toolkit.inc.php"); |
82
|
23 |
include_once("inc/header.inc.php"); |
1
|
24 |
|
126
|
25 |
if (verify_permission('zone_content_view_others')) { $perm_view = "all" ; } |
|
26 |
elseif (verify_permission('zone_content_view_own')) { $perm_view = "own" ; } |
82
|
27 |
else { $perm_view = "none" ; } |
|
28 |
|
126
|
29 |
if (verify_permission('zone_content_edit_others')) { $perm_content_edit = "all" ; } |
|
30 |
elseif (verify_permission('zone_content_edit_own')) { $perm_content_edit = "own" ; } |
82
|
31 |
else { $perm_content_edit = "none" ; } |
|
32 |
|
126
|
33 |
if (verify_permission('zone_meta_edit_others')) { $perm_meta_edit = "all" ; } |
|
34 |
elseif (verify_permission('zone_meta_edit_own')) { $perm_meta_edit = "own" ; } |
82
|
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']; |
|
40 |
} |
|
41 |
|
136
|
42 |
$ttl = $dns_ttl; |
82
|
43 |
if ((isset($_POST['ttl'])) && (v_num($_POST['ttl']))) { |
|
44 |
$ttl = $_POST['ttl']; |
37
|
45 |
} |
|
46 |
|
82
|
47 |
$prio = "10"; |
|
48 |
if ((isset($_GET['prio'])) && (v_num($_GET['prio']))) { |
|
49 |
$prio = $_GET['prio']; |
|
50 |
} |
|
51 |
|
182
|
52 |
if (isset($_POST['name'])) { |
|
53 |
$name = $_POST['name']; |
|
54 |
} else { |
|
55 |
$name = ""; |
|
56 |
} |
|
57 |
|
|
58 |
if (isset($_POST['type'])) { |
|
59 |
$type = $_POST['type']; |
|
60 |
} else { |
|
61 |
$type = ""; |
|
62 |
} |
|
63 |
|
|
64 |
if (isset($_POST['content'])) { |
|
65 |
$content = $_POST['content']; |
|
66 |
} else { |
|
67 |
$content = ""; |
|
68 |
} |
82
|
69 |
|
|
70 |
if ($zone_id == "-1") { |
|
71 |
error(ERR_INV_INPUT); |
|
72 |
include_once("inc/footer.inc.php"); |
|
73 |
exit; |
|
74 |
} |
|
75 |
|
|
76 |
$user_is_zone_owner = verify_user_is_owner_zoneid($zone_id); |
|
77 |
$zone_type = get_domain_type($zone_id); |
140
|
78 |
$zone_name = get_zone_name_from_id($zone_id); |
82
|
79 |
|
182
|
80 |
if (isset($_POST["commit"])) { |
82
|
81 |
if ( $zone_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) { |
|
82 |
error(ERR_PERM_ADD_RECORD); |
|
83 |
} else { |
|
84 |
if ( add_record($zone_id, $name, $type, $content, $ttl, $prio)) { |
132
|
85 |
success(_('The record was successfully added.')); |
182
|
86 |
$name = $type = $content = $ttl = $prio = ""; |
82
|
87 |
} |
|
88 |
} |
1
|
89 |
} |
13
|
90 |
|
110
|
91 |
echo " <h2>" . _('Add record to zone') . " " . $zone_name . "</h2>\n"; |
1
|
92 |
|
82
|
93 |
if ( $zone_type == "SLAVE" || $perm_content_edit == "none" || $perm_content_edit == "own" && $user_is_zone_owner == "0" ) { |
|
94 |
error(ERR_PERM_ADD_RECORD); |
|
95 |
} else { |
|
96 |
echo " <form method=\"post\">\n"; |
|
97 |
echo " <input type=\"hidden\" name=\"domain\" value=\"" . $zone_id . "\">\n"; |
|
98 |
echo " <table border=\"0\" cellspacing=\"4\">\n"; |
|
99 |
echo " <tr>\n"; |
|
100 |
echo " <td class=\"n\">" . _('Name') . "</td>\n"; |
|
101 |
echo " <td class=\"n\"> </td>\n"; |
|
102 |
echo " <td class=\"n\">" . _('Type') . "</td>\n"; |
|
103 |
echo " <td class=\"n\">" . _('Priority') . "</td>\n"; |
|
104 |
echo " <td class=\"n\">" . _('Content') . "</td>\n"; |
|
105 |
echo " <td class=\"n\">" . _('TTL') . "</td>\n"; |
|
106 |
echo " </tr>\n"; |
|
107 |
echo " <tr>\n"; |
|
108 |
echo " <td class=\"n\"><input type=\"text\" name=\"name\" class=\"input\" value=\"" . $name . "\">." . $zone_name . "</td>\n"; |
|
109 |
echo " <td class=\"n\">IN</td>\n"; |
|
110 |
echo " <td class=\"n\">\n"; |
|
111 |
echo " <select name=\"type\">\n"; |
|
112 |
foreach (get_record_types() as $record_type) { |
|
113 |
if ($type) { |
|
114 |
if ($type == $record_type) { |
|
115 |
$add = " SELECTED"; |
|
116 |
} else { |
182
|
117 |
$add = ""; |
82
|
118 |
} |
|
119 |
} else { |
|
120 |
if (eregi('in-addr.arpa', $zone_name) && strtoupper($record_type) == 'PTR') { |
|
121 |
$add = " SELECTED"; |
|
122 |
} elseif (strtoupper($record_type) == 'A') { |
|
123 |
$add = " SELECTED"; |
|
124 |
} else { |
182
|
125 |
$add = ""; |
82
|
126 |
} |
|
127 |
} |
|
128 |
echo " <option" . $add . " value=\"" . $record_type . "\">" . $record_type . "</option>\n"; |
|
129 |
} |
|
130 |
echo " </select>\n"; |
|
131 |
echo " </td>\n"; |
|
132 |
echo " <td class=\"n\"><input type=\"text\" name=\"prio\" class=\"sinput\" value=\"" . $prio . "\"></td>\n"; |
|
133 |
echo " <td class=\"n\"><input type=\"text\" name=\"content\" class=\"input\" value=\"" . $content . "\"></td>\n"; |
|
134 |
echo " <td class=\"n\"><input type=\"text\" name=\"ttl\" class=\"sinput\" value=\"" . $ttl . "\"</td>\n"; |
|
135 |
echo " </tr>\n"; |
|
136 |
echo " </table>\n"; |
|
137 |
echo " <br>\n"; |
|
138 |
echo " <input type=\"submit\" name=\"commit\" value=\"" . _('Add record') . "\" class=\"button\">\n"; |
|
139 |
echo " </form>\n"; |
1
|
140 |
} |
82
|
141 |
|
|
142 |
include_once("inc/footer.inc.php"); |
|
143 |
|
13
|
144 |
?> |