Browse code

Ändere automatisch erzeugten DNS-Record wenn das Handle geändert wird

Bernd Wurst authored on04/07/2014 11:49:55
Showing1 changed files
... ...
@@ -79,12 +79,22 @@ function create_dyndns_account($handle, $password_http, $sshkey)
79 79
 function edit_dyndns_account($id, $handle, $password_http, $sshkey)
80 80
 {
81 81
   $id = (int) $id;
82
+  $oldaccount = get_dyndns_account($id);
82 83
   $handle = filter_input_username($handle);
83 84
   $sshkey = filter_input_general($sshkey);
84 85
   if (chop($sshkey) == '') {
85 86
     $sshkey = NULL;
86 87
   }
87 88
 
89
+  if ($oldaccount['handle'] != $handle) {
90
+    $masterdomain = new Domain(config('masterdomain'));
91
+    db_query("UPDATE dns.custom_records SET hostname=:newhostname WHERE ".
92
+             "hostname=:oldhostname AND domain=:dom AND dyndns=:dyndns AND ip IS NULL",
93
+             array(":dom" => $masterdomain->id, ":newhostname" => filter_input_hostname($handle).'.'.$_SESSION['userinfo']['username'],
94
+                   ":oldhostname" => $oldaccount['handle'].'.'.$_SESSION['userinfo']['username'],  ":dyndns" => $id));
95
+
96
+  }
97
+
88 98
   $args = array(":handle" => $handle, ":sshkey" => $sshkey, ":id" => $id);
89 99
   $pwhash = NULL;
90 100
   if ($password_http && $password_http != '************') {