bernd commited on 2009-04-30 14:19:40
Zeige 4 geänderte Dateien mit 172 Einfügungen und 42 Löschungen.
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1353 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -15,43 +15,57 @@ $domain = new Domain((int) $_REQUEST['dom']); |
15 | 15 |
|
16 | 16 |
DEBUG($domain); |
17 | 17 |
|
18 |
-$output .= '<h3>DNS-Records für <em>'.filter_input_general($domain->fqdn).'</em></h3>'; |
|
18 |
+output('<h3>DNS-Records für <em>'.filter_input_general($domain->fqdn).'</em></h3>'); |
|
19 | 19 |
|
20 | 20 |
$records = get_domain_records($domain->id); |
21 | 21 |
$auto_records = get_domain_auto_records($domain->fqdn); |
22 | 22 |
|
23 |
-$output .= '<table><tr><th>Hostname</th><th>Typ</th><th>IP-Adresse/Inhalt</th><th>TTL</th><th> </th></tr> |
|
24 |
-'; |
|
23 |
+output('<table><tr><th>Hostname</th><th>Typ</th><th>IP-Adresse/Inhalt</th><th>TTL</th><th> </th></tr> |
|
24 |
+'); |
|
25 | 25 |
foreach ($records AS $rec) |
26 | 26 |
{ |
27 | 27 |
$data = ( $rec['ip'] ? $rec['ip'] : $rec['data'] ); |
28 | 28 |
if ($rec['dyndns']) |
29 |
- $data = internal_link('dyndns_edit', '<em>DynDNS #'.$rec['dyndns'].'</em>', 'id='.$rec['dyndns']); |
|
29 |
+ { |
|
30 |
+ $dyndns = get_dyndns_account($rec['dyndns']); |
|
31 |
+ $data = internal_link('dyndns_edit', '<em>DynDNS #'.$rec['dyndns'].' ('.$dyndns['handle'].')</em>', 'id='.$rec['dyndns']); |
|
32 |
+ } |
|
33 |
+ if ($rec['type'] == 'mx') |
|
34 |
+ { |
|
35 |
+ $data .= ' ('.$rec['spec'].')'; |
|
36 |
+ } |
|
30 | 37 |
$ttl = ($rec['ttl'] ? $rec['ttl'] : 3600); |
31 |
- $output .= "<tr><td>".internal_link('dns_record_edit', $rec['fqdn'], "id={$rec['id']}")."</td><td>".strtoupper($rec['type'])."</td><td>$data</td><td>{$ttl} Sek.</td><td>".internal_link('save', '<img src="'.$prefix.'images/delete.png" width="16" height="16" alt="löschen" title="Record löschen" />', "id={$rec['id']}&type=dns&action=delete")."</td></tr>\n"; |
|
38 |
+ output("<tr><td>".internal_link('dns_record_edit', $rec['fqdn'], "id={$rec['id']}")."</td><td>".strtoupper($rec['type'])."</td><td>$data</td><td>{$ttl} Sek.</td><td>".internal_link('dns_record_save', '<img src="'.$prefix.'images/delete.png" width="16" height="16" alt="löschen" title="Record löschen" />', "id={$rec['id']}&action=delete")."</td></tr>\n"); |
|
32 | 39 |
} |
33 | 40 |
foreach ($auto_records AS $rec) |
34 | 41 |
{ |
35 | 42 |
$data = ( $rec['ip'] ? $rec['ip'] : $rec['data'] ); |
36 | 43 |
$ttl = ($rec['ttl'] ? $rec['ttl'] : 3600); |
37 |
- $output .= "<tr><td><em>{$rec['fqdn']}</td><td>".strtoupper($rec['type'])."</td><td>$data</td><td>{$ttl} Sek.</td><td> </td></tr>\n"; |
|
44 |
+ output("<tr><td><em>{$rec['fqdn']}</td><td>".strtoupper($rec['type'])."</td><td>$data</td><td>{$ttl} Sek.</td><td> </td></tr>\n"); |
|
38 | 45 |
|
39 | 46 |
} |
40 | 47 |
|
41 | 48 |
|
42 |
-$output .= '</table>'; |
|
49 |
+output('</table>'); |
|
43 | 50 |
|
44 | 51 |
if ($domain->autodns) |
45 |
- $output .= '<p style="font-size: 80%;"><em>Kursive Hostnames bezeichnen automatisch erzeugte Records. Diese können nicht geändert werden.</em></p>'; |
|
52 |
+ output('<p style="font-size: 80%;"><em>Kursive Hostnames bezeichnen automatisch erzeugte Records. Diese können nicht geändert werden.</em></p>'); |
|
46 | 53 |
else |
47 |
- $output .= '<p style="font-size: 80%;"><em>Für diese Domain wurde die Erzeugung automatischer Records deaktiviert.</em></p>'; |
|
48 |
- |
|
49 |
- |
|
50 |
-$output .= html_form('dns_record_new', 'dns_record_edit', 'id=new&dom='.$domain->id, |
|
51 |
-'<h4>Neuen DNS-Record anlegen</h4> |
|
52 |
-<p> |
|
53 |
-<label for="type">Typ:</label> '.html_select('type', array('a' => 'A', 'aaaa' => 'AAAA', 'mx' => 'MX', 'ns' => 'NS', 'spf' => 'SPF', 'txt' => 'TXT', 'cname' => 'CNAME', 'ptr' => 'PTR', 'srv' => 'SRV', 'raw' => 'RAW'), 'a').' |
|
54 |
-   <input type="submit" value="Anlegen" /> |
|
55 |
-</p>'); |
|
54 |
+ output('<p style="font-size: 80%;"><em>Für diese Domain wurde die Erzeugung automatischer Records deaktiviert.</em></p>'); |
|
55 |
+ |
|
56 |
+ |
|
57 |
+output('<h4>Neuen DNS-Record anlegen</h4> |
|
58 |
+<p>Je nach dem, welchen Eintrags-Typ Sie anlegen möchten, werden im nächsten Schritt unterschiedliche Daten abgefragt. Bitte klicken Sie auf den Eintrags-Typ, den Sie anlegen möchten. Momentan werden noch nicht alle Eintrags-Typen über dieses System bereitgestellt. Hier nicht aufgeführte Eintragsarten können Sie beim Support beantragen.</p> |
|
59 |
+ |
|
60 |
+<ul> |
|
61 |
+<li>'.internal_link('dns_record_edit', 'DynDNS (Hostname für einen DynDNS-Account setzen))', 'id=new&type=dyndns&domain='.$domain->id).'</li> |
|
62 |
+<li>'.internal_link('dns_record_edit', 'A (normaler Hostname/normale Subdomain)', 'id=new&type=a&domain='.$domain->id).'</li> |
|
63 |
+<li>'.internal_link('dns_record_edit', 'MX (Posteingangsserver)', 'id=new&type=mx&domain='.$domain->id).'</li> |
|
64 |
+</ul> |
|
65 |
+<ul> |
|
66 |
+<li>'.internal_link('dns_record_edit', 'AAAA (IPv6-Adresse)', 'id=new&type=aaaa&domain='.$domain->id).'</li> |
|
67 |
+<li>'.internal_link('dns_record_edit', 'CNAME (Aliasnamen)', 'id=new&type=cname&domain='.$domain->id).'</li> |
|
68 |
+</ul> |
|
69 |
+'); |
|
56 | 70 |
|
57 | 71 |
?> |
... | ... |
@@ -14,51 +14,93 @@ $section = 'dns_dns'; |
14 | 14 |
$data = array(); |
15 | 15 |
$type = NULL; |
16 | 16 |
|
17 |
+$dyndns = false; |
|
18 |
+$dyndns_accounts = array(); |
|
19 |
+foreach (get_dyndns_accounts() AS $t) |
|
20 |
+{ |
|
21 |
+ $dyndns_accounts[$t['id']] = $t['handle']; |
|
22 |
+} |
|
23 |
+ |
|
24 |
+if ($_REQUEST['type'] == "dyndns") |
|
25 |
+{ |
|
26 |
+ $_REQUEST['type'] = 'a'; |
|
27 |
+ $dyndns = true; |
|
28 |
+} |
|
29 |
+ |
|
17 | 30 |
$new = false; |
18 | 31 |
if ($_REQUEST['id'] == 'new') |
19 | 32 |
{ |
20 | 33 |
$new = true; |
21 | 34 |
$data = blank_dns_record($_REQUEST['type']); |
22 |
- $domain = new Domain((int) $_REQUEST['dom']); |
|
23 |
- $type = $_POST['type']; |
|
35 |
+ $domain = new Domain((int) $_REQUEST['domain']); |
|
36 |
+ $type = $_REQUEST['type']; |
|
24 | 37 |
if (! in_array($type, $valid_record_types)) |
25 | 38 |
system_failure('Ungültiger Record-Typ!'); |
26 | 39 |
$data['domain'] = $domain->id; |
40 |
+ if ($dyndns) |
|
41 |
+ $data['ttl'] = 120; |
|
27 | 42 |
} |
28 | 43 |
|
29 | 44 |
if (! $new) |
30 | 45 |
{ |
31 | 46 |
$data = get_dns_record($_REQUEST['id']); |
32 | 47 |
$type = $data['type']; |
48 |
+ $dyndns = isset($data['dyndns']); |
|
49 |
+ $domain = new Domain((int) $data['domain']); |
|
33 | 50 |
if (! in_array($type, $valid_record_types)) |
34 | 51 |
system_failure('Ungültiger Record-Typ!'); |
35 | 52 |
} |
36 | 53 |
|
37 | 54 |
|
38 |
- |
|
39 |
- |
|
40 | 55 |
if ($new) |
41 |
- $output .= '<h3>DNS-Record erstellen</h3>'; |
|
56 |
+ output('<h3>DNS-Record erstellen</h3>'); |
|
42 | 57 |
else |
43 |
- $output .= '<h3>DNS-Record bearbeiten</h3>'; |
|
58 |
+ output('<h3>DNS-Record bearbeiten</h3>'); |
|
44 | 59 |
|
45 |
- |
|
46 |
-$action = 'create'; |
|
47 |
-if (! $new) |
|
48 |
- $action = 'edit&id='.(int)$_REQUEST['id']; |
|
60 |
+output('<p>Record-Typ: '.strtoupper($type).'</p>'); |
|
49 | 61 |
|
50 | 62 |
$submit = 'Speichern'; |
51 | 63 |
if ($new) |
52 | 64 |
$submit = 'Anlegen'; |
53 | 65 |
|
54 |
-$domain = new Domain( (int) $data['domain'] ); |
|
66 |
+$form = ''; |
|
67 |
+ |
|
68 |
+if (! $dyndns && ($type == 'a' || $type == 'aaaa')) |
|
69 |
+{ |
|
70 |
+ $form .= ' |
|
71 |
+<tr><td><label for="ip">IP-Adresse:</label></td><td><input type="text" name="ip" id="ip" value="'.$data['ip'].'" /></td></tr> |
|
72 |
+'; |
|
73 |
+} |
|
74 |
+ |
|
75 |
+if ($type == 'ptr' || $type == 'cname') |
|
76 |
+{ |
|
77 |
+ $form .= ' |
|
78 |
+<tr><td><label for="data">Ziel:</label></td><td><input type="text" name="data" id="data" value="'.$data['data'].'" /></td></tr> |
|
79 |
+'; |
|
80 |
+} |
|
81 |
+ |
|
82 |
+if ($dyndns) |
|
83 |
+{ |
|
84 |
+ $form .= ' |
|
85 |
+<tr><td><label for="dyndns">DynDNS-Zugang:</label></td><td>'.html_select('dyndns', $dyndns_accounts, $data['dyndns']).'</td></tr> |
|
86 |
+'; |
|
87 |
+} |
|
88 |
+ |
|
89 |
+if ($type == 'mx') |
|
90 |
+{ |
|
91 |
+ $form .= ' |
|
92 |
+<tr><td><label for="spec">Priorität:</label></td><td><input type="text" name="spec" id="spec" value="'.$data['spec'].'" /></td></tr> |
|
93 |
+<tr><td><label for="data">Posteingangsserver:</label></td><td><input type="text" name="data" id="data" value="'.$data['data'].'" /></td></tr> |
|
94 |
+'; |
|
95 |
+} |
|
55 | 96 |
|
56 | 97 |
|
57 |
-$output .= html_form('dns_record_edit', 'save', 'type=dns&action='.$action, |
|
58 |
-'<p> |
|
59 |
-<label for="hostname">Hostname:</label> <input type="text" name="hostname" id="hostname" value="'.$data['hostname'].'" /> <strong>.'.$domain->fqdn.'</strong><p> |
|
60 |
-<p>Typ: |
|
98 |
+output(html_form('dns_record_edit', 'dns_record_save', "type={$type}&domain={$domain->id}&id={$_REQUEST['id']}", '<table> |
|
99 |
+<tr><td><label for="hostname">Hostname:</label></td><td><input type="text" name="hostname" id="hostname" value="'.$data['hostname'].'" /> <strong>.'.$domain->fqdn.'</strong></td></tr> |
|
100 |
+'.$form.' |
|
101 |
+<tr><td><label for="ttl">TTL:</label></td><td><input type="text" name="ttl" id="ttl" value="'.$data['ttl'].'" /></td></tr> |
|
102 |
+</table> |
|
61 | 103 |
<p><input type="submit" value="'.$submit.'" /></p> |
62 |
-</p>'); |
|
104 |
+</p>')); |
|
63 | 105 |
|
64 | 106 |
?> |
... | ... |
@@ -0,0 +1,72 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+require_once('inc/base.php'); |
|
4 |
+require_once('inc/debug.php'); |
|
5 |
+global $debugmode; |
|
6 |
+require_once('inc/security.php'); |
|
7 |
+ |
|
8 |
+require_role(ROLE_CUSTOMER); |
|
9 |
+ |
|
10 |
+require_once('dnsinclude.php'); |
|
11 |
+ |
|
12 |
+$section = 'dns_dns'; |
|
13 |
+ |
|
14 |
+ |
|
15 |
+$record = NULL; |
|
16 |
+ |
|
17 |
+$id = NULL; |
|
18 |
+if ($_REQUEST['id'] == 'new') |
|
19 |
+{ |
|
20 |
+ $record = blank_dns_record($_REQUEST['type']); |
|
21 |
+} |
|
22 |
+else |
|
23 |
+{ |
|
24 |
+ $id = (int) $_REQUEST['id']; |
|
25 |
+ $record = get_dns_record($id); |
|
26 |
+} |
|
27 |
+ |
|
28 |
+ |
|
29 |
+if ($_GET['action'] == 'delete') { |
|
30 |
+ $sure = user_is_sure(); |
|
31 |
+ if ($sure === NULL) |
|
32 |
+ { |
|
33 |
+ $domain = new Domain((int) $record['domain']); |
|
34 |
+ $fqdn = $domain->fqdn; |
|
35 |
+ if ($record['hostname']) |
|
36 |
+ { |
|
37 |
+ $fqdn = $record['hostname'].'.'.$fqdn; |
|
38 |
+ } |
|
39 |
+ are_you_sure("action=delete&id={$id}", "Möchten Sie den ".strtoupper($record['type'])."-Record für ".$fqdn." wirklich löschen?"); |
|
40 |
+ } |
|
41 |
+ elseif ($sure === true) |
|
42 |
+ { |
|
43 |
+ delete_dns_record($id); |
|
44 |
+ if (! $debugmode) |
|
45 |
+ header("Location: dns_domain?dom=".$record['domain']); |
|
46 |
+ } |
|
47 |
+ elseif ($sure === false) |
|
48 |
+ { |
|
49 |
+ if (! $debugmode) |
|
50 |
+ header("Location: dns_domain?dom=".$record['domain']); |
|
51 |
+ } |
|
52 |
+} |
|
53 |
+else |
|
54 |
+{ |
|
55 |
+ // Sicherheitsprüfungen passieren im Backend |
|
56 |
+ |
|
57 |
+ $record['hostname'] = $_REQUEST['hostname']; |
|
58 |
+ $record['domain'] = (int) $_REQUEST['domain']; |
|
59 |
+ $record['ip'] = $_REQUEST['ip']; |
|
60 |
+ $record['data'] = $_REQUEST['data']; |
|
61 |
+ $record['dyndns'] = (int) $_REQUEST['dyndns']; |
|
62 |
+ $record['spec'] = (int) $_REQUEST['spec']; |
|
63 |
+ $record['ttl'] = (int) $_REQUEST['ttl']; |
|
64 |
+ |
|
65 |
+ save_dns_record($id, $record); |
|
66 |
+ |
|
67 |
+ if (!$debugmode) |
|
68 |
+ header('Location: dns_domain?dom='.$record['domain']); |
|
69 |
+} |
|
70 |
+ |
|
71 |
+ |
|
72 |
+ |
... | ... |
@@ -191,7 +191,7 @@ function save_dns_record($id, $record) |
191 | 191 |
break; |
192 | 192 |
case 'aaaa': |
193 | 193 |
$record['dyndns'] = ''; |
194 |
- verify_input_ipv4($record['ip']); |
|
194 |
+ verify_input_ipv6($record['ip']); |
|
195 | 195 |
$record['data'] = ''; |
196 | 196 |
$record['spec'] = ''; |
197 | 197 |
break; |
... | ... |
@@ -205,10 +205,8 @@ function save_dns_record($id, $record) |
205 | 205 |
system_failure('MX hostname missing'); |
206 | 206 |
$record['ip'] = ''; |
207 | 207 |
break; |
208 |
- case 'spf': |
|
209 |
- case 'txt': |
|
210 |
- system_failure('not implemented yet'); |
|
211 | 208 |
case 'cname': |
209 |
+ case 'ptr': |
|
212 | 210 |
$record['dyndns'] = ''; |
213 | 211 |
$record['spec'] = ''; |
214 | 212 |
$record['ip'] = ''; |
... | ... |
@@ -217,7 +215,8 @@ function save_dns_record($id, $record) |
217 | 215 |
system_failure('MX hostname missing'); |
218 | 216 |
break; |
219 | 217 |
|
220 |
- case 'ptr': |
|
218 |
+ case 'spf': |
|
219 |
+ case 'txt': |
|
221 | 220 |
case 'srv': |
222 | 221 |
system_failure('not implemented yet'); |
223 | 222 |
default: |
... | ... |
@@ -225,22 +224,25 @@ function save_dns_record($id, $record) |
225 | 224 |
} |
226 | 225 |
$id = (int) $id; |
227 | 226 |
$record['hostname'] = maybe_null($record['hostname']); |
228 |
- $record['ttl'] = ($recory['ttl'] == 0 ? 'NULL' : (int) $record['ttl']); |
|
227 |
+ $record['ttl'] = ($record['ttl'] == 0 ? 'NULL' : (int) $record['ttl']); |
|
229 | 228 |
$record['ip'] = maybe_null($record['ip']); |
230 | 229 |
$record['data'] = maybe_null($record['data']); |
231 | 230 |
$record['spec'] = maybe_null($record['spec']); |
232 | 231 |
$record['dyndns'] = maybe_null($record['dyndns']); |
233 | 232 |
if ($id) |
234 |
- db_query("UPDATE dns.custom_records SET hostname={$record['hostname']}, domain={$dom->id}, type={$record['type']}, ttl={$record['ttl']}, ip={$record['ip']}, dyndns={$record['dyndns']}, data={$record['data']}, spec={$record['spec']} WHERE id={$id} LIMIT 1"); |
|
233 |
+ db_query("UPDATE dns.custom_records SET hostname={$record['hostname']}, domain={$dom->id}, type='{$record['type']}', ttl={$record['ttl']}, ip={$record['ip']}, dyndns={$record['dyndns']}, data={$record['data']}, spec={$record['spec']} WHERE id={$id} LIMIT 1"); |
|
235 | 234 |
else |
236 |
- db_query("INSERT INTO dns.custom_records (hostname, domain, type, ttl, ip, dyndns, data, spec) VALUES ({$record['hostname']}, {$dom->id}, {$record['type']}, {$record['ttl']}, {$record['ip']}, {$record['dyndns']}, {$record['data']}, {$record['spec']})"); |
|
235 |
+ db_query("INSERT INTO dns.custom_records (hostname, domain, type, ttl, ip, dyndns, data, spec) VALUES ({$record['hostname']}, {$dom->id}, '{$record['type']}', {$record['ttl']}, {$record['ip']}, {$record['dyndns']}, {$record['data']}, {$record['spec']})"); |
|
237 | 236 |
|
238 | 237 |
} |
239 | 238 |
|
240 | 239 |
|
241 | 240 |
function delete_dns_record($id) |
242 | 241 |
{ |
243 |
- // ... |
|
242 |
+ $id = (int) $id; |
|
243 |
+ // Diese Funktion prüft, ob der Eintrag einer eigenen Domain gehört |
|
244 |
+ $record = get_dns_record($id); |
|
245 |
+ db_query("DELETE FROM dns.custom_records WHERE id={$id} LIMIT 1"); |
|
244 | 246 |
} |
245 | 247 |
|
246 | 248 |
?> |
247 | 249 |