Ermögliche das Bestätigen der E-Mail-Adresse auch wenn der User nicht eingeloggt ist
Bernd Wurst

Bernd Wurst commited on 2018-02-27 09:45:30
Zeige 2 geänderte Dateien mit 39 Einfügungen und 3 Löschungen.

... ...
@@ -14,6 +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/api.php");
17 18
 
18 19
 function verify_mail_token($token)
19 20
 {
... ...
@@ -47,3 +48,40 @@ function update_mailaddress($daten)
47 48
 }
48 49
 
49 50
 
51
+function upload_changed_contact($id)
52
+{
53
+    $args = array(
54
+        "id" => (int) $id);
55
+    $result = db_query("SELECT id, state, lastchange, nic_id, nic_handle, company, name, address, zip, city, country, phone, mobile, fax, email, pgp_id, pgp_key FROM kundendaten.contacts WHERE id=:id", $args);
56
+    if ($result->rowCount() == 0) {
57
+        return ;
58
+    }
59
+    $c = $result->fetch();
60
+    if (! ($c['nic_id'] || $c['nic_handle'])) {
61
+        return ;
62
+    }
63
+    $ac = array();
64
+    $ac['id'] = $c['nic_id'];
65
+    $ac['handle'] = $c['nic_handle'];
66
+    $ac['type'] = 'person';
67
+    $ac['name'] = $c['name'];
68
+    $ac['organization'] = $c['company'];
69
+    $ac['street'] = explode("\n", $c['address'], 3);
70
+    $ac['postalCode'] = $c['zip'];
71
+    $ac['city'] = $c['city'];
72
+    $ac['country'] = strtolower($c['country']);
73
+    $ac['emailAddress'] = $c['email'];
74
+    $ac['phoneNumber'] = $c['phone'];
75
+    $ac['faxNumber'] = $c['fax'];
76
+    if ($c['state'] == 'deleted') {
77
+        $ac['hidden'] = true;
78
+    }
79
+    $data = array("contact" => $ac,
80
+            "actingAs" => "designatedAgent");
81
+    $result = api_request('contactUpdate', $data);
82
+    if ($result['status'] != 'success') {
83
+            warning("Es gab ein Problem beim Hochladen der geänderten Adresse zum Domainregistrar. Das sollte nicht sein!");
84
+    }
85
+}
86
+
87
+
... ...
@@ -14,7 +14,6 @@ https://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('contacts.php');
18 17
 require_once('verify.php');
19 18
 require_once('inc/security.php');
20 19
 
... ...
@@ -29,8 +28,7 @@ if (isset($_REQUEST['token']))
29 28
     system_failure('Die E-Mail-Adresse konnte nicht verifiziert werden. Vielleicht ist der Link bereits abgelaufen.');
30 29
   } else  {
31 30
     update_mailaddress($daten);
32
-    $c = get_contact($daten['contact']);
33
-    upload_contact($c);
31
+    upload_changed_contact($daten['contact']);
34 32
     success_msg('Die E-Mail-Adresse wurde erfolgreich geändert');
35 33
     header('Location: /');
36 34
   }
37 35