Browse code

Mache manuelle NS-Records nicht mehr editier- und löschbar, Lösche sie aber automatisch wenn Autorecords eingeschaltet werden

Bernd Wurst authored on02/02/2018 06:29:18
Showing2 changed files
... ...
@@ -14,7 +14,7 @@ http://creativecommons.org/publicdomain/zero/1.0/
14 14
 Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15 15
 */
16 16
 
17
-require_once('inc/base.php');
17
+require_once('inc/icons.php');
18 18
 require_once('inc/security.php');
19 19
 
20 20
 require_once('class/domain.php');
... ...
@@ -35,6 +35,7 @@ headline('DNS-Records für <em>'.filter_input_general($domain->fqdn).'</em>');
35 35
 
36 36
 $records = get_domain_records($domain->id);
37 37
 $auto_records = get_domain_auto_records($domain->fqdn);
38
+$cname_on_domain = false;
38 39
 
39 40
 output('<table><tr><th>Hostname</th><th>Typ</th><th>IP-Adresse/Inhalt</th><th>TTL</th><th>&#160;</th></tr>
40 41
 ');
... ...
@@ -74,10 +75,15 @@ foreach ($records AS $rec)
74 75
   if (!in_array($rec['type'], array('a', 'aaaa', 'mx', 'cname', 'ns', 'txt', 'spf', 'ptr', 'sshfp', 'caa'))) {
75 76
       $editable = false;
76 77
   }
78
+  $delete = internal_link('dns_record_save', icon_delete('Record löschen'), "id={$rec['id']}&action=delete");
79
+  if ($rec['type'] == 'ns' && ! $rec['hostname']) {
80
+      $editable = false;
81
+      $delete = '';
82
+  }
77 83
   if ($editable) {
78 84
       $link = internal_link('dns_record_edit', $rec['fqdn'], "id={$rec['id']}");
79 85
   }
80
-  output("<tr><td>{$link}</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");
86
+  output("<tr><td>{$link}</td><td>".strtoupper($rec['type'])."</td><td>".$data."</td><td>{$ttl} Sek.</td><td>".$delete."</td></tr>\n");
81 87
 }  
82 88
 foreach ($auto_records AS $rec)
83 89
 {
... ...
@@ -356,6 +356,7 @@ function enable_autorecords($domainid)
356 356
   $dom = $dom->id;
357 357
 
358 358
   db_query("UPDATE kundendaten.domains SET autodns=1 WHERE id=?", array($dom));
359
+  db_query("DELETE FROM dns.custom_records WHERE type='ns' AND domain=? AND hostname IS NULL", array($dom));
359 360
   warning("Die automatischen Einträge werden in Kürze aktiviert, bitte haben Sie einen Moment Geduld.");
360 361
 }
361 362