Passwort bei DynDNS-Änderung richtig speichern
Bernd Wurst

Bernd Wurst commited on 2014-03-07 11:30:28
Zeige 1 geänderte Dateien mit 9 Einfügungen und 9 Löschungen.

... ...
@@ -76,18 +76,18 @@ function edit_dyndns_account($id, $handle, $password_http, $sshkey)
76 76
   $id = (int) $id;
77 77
   $handle = filter_input_username($handle);
78 78
   $sshkey = filter_input_general($sshkey);
79
-
80
-  $pwhash = NULL;
81
-  if ($password_http)
82
-  {
83
-    if ($password_http == '************')
84
-      $pwhash = 'password';
85
-    else
86
-      $pwhash = "'{SHA}".base64_encode(sha1($password_http, true))."'";
79
+  if (chop($sshkey) == '') {
80
+    $sshkey = NULL;
87 81
   }
88 82
 
89
-  $args = array(":handle" => $handle, ":pwhash" => $pwhash, ":sshkey" => $sshkey, ":id" => $id);
83
+  $args = array(":handle" => $handle, ":sshkey" => $sshkey, ":id" => $id);
84
+  $pwhash = NULL;
85
+  if ($password_http && $password_http != '************') {
86
+      $args[":pwhash"] = "{SHA}".base64_encode(sha1($password_http, true));
90 87
       db_query("UPDATE dns.dyndns SET handle=:handle, password=:pwhash, sshkey=:sshkey WHERE id=:id", $args);
88
+  } else {
89
+      db_query("UPDATE dns.dyndns SET handle=:handle, sshkey=:sshkey WHERE id=:id", $args);
90
+  }
91 91
   logger(LOG_INFO, "modules/dns/include/dnsinclude", "dyndns", "edited account »{$id}«");
92 92
 }
93 93
 
94 94