Browse code

Passwort bei DynDNS-Änderung richtig speichern

Bernd Wurst authored on 07/03/2014 11:30:28
Showing 1 changed files
... ...
@@ -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
+  if (chop($sshkey) == '') {
80
+    $sshkey = NULL;
81
+  }
79 82
 
83
+  $args = array(":handle" => $handle, ":sshkey" => $sshkey, ":id" => $id);
80 84
   $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))."'";
85
+  if ($password_http && $password_http != '************') {
86
+      $args[":pwhash"] = "{SHA}".base64_encode(sha1($password_http, true));
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);
87 90
   }
88
-  
89
-  $args = array(":handle" => $handle, ":pwhash" => $pwhash, ":sshkey" => $sshkey, ":id" => $id);
90
-  db_query("UPDATE dns.dyndns SET handle=:handle, password=:pwhash, sshkey=:sshkey WHERE id=:id", $args);
91 91
   logger(LOG_INFO, "modules/dns/include/dnsinclude", "dyndns", "edited account »{$id}«");
92 92
 }
93 93