Aktualisiere Domain- und Inhaberdaten beim Aufrufen der update-Seite
Bernd Wurst

Bernd Wurst commited on 2018-01-24 10:34:58
Zeige 7 geänderte Dateien mit 139 Einfügungen und 9 Löschungen.

... ...
@@ -282,7 +282,14 @@ function have_module($modname)
282 282
 
283 283
 function use_module($modname) 
284 284
 {
285
-    global $prefix;
285
+    global $prefix, $needed_modules;
286
+    if (! isset($needed_modules)) {
287
+        $needed_modules = array();
288
+    }
289
+    if (in_array($modname, $needed_modules)) {
290
+        return;
291
+    }
292
+    $needed_modules[] = $modname;
286 293
     if (! have_module($modname)) {
287 294
         system_failure("Soll nicht verfügbares Modul laden!");
288 295
     }
... ...
@@ -41,6 +41,45 @@ function contact_to_apicontact($c)
41 41
     return $ac;
42 42
 }
43 43
 
44
+function apicontact_to_contact($ac) 
45
+{
46
+    $c = new_contact();
47
+    $c['nic_id'] = $ac['id'];
48
+    $c['nic_handle'] = $ac['handle'];
49
+    $c['name'] = maybe_null($ac['name']);
50
+    $c['company'] = maybe_null($ac['organization']);
51
+    $c['address'] = implode("\n", $ac['street']);
52
+    $c['zip'] = $ac['postalCode'];
53
+    $c['city'] = $ac['city'];
54
+    $c['country'] = strtoupper($ac['country']);
55
+    $c['email'] = $ac['emailAddress'];
56
+    $c['phone'] = $ac['phoneNumber'];
57
+    $c['fax'] = maybe_null($ac['faxNumber']);
58
+    if ($ac['hidden'] === true) {
59
+        $c['state'] = 'deleted';
60
+    }
61
+    return $c;
62
+}
63
+
64
+
65
+
66
+function download_contact($nic_id) {
67
+    $data = array("contactId" => $nic_id);
68
+    $result = api_request('contactInfo', $data);
69
+    if ($result['status'] != 'success') {
70
+        system_failure("Abfrage nicht erfolgreich!");
71
+    }
72
+    $c = apicontact_to_contact($result['response']);
73
+    $result = db_query("SELECT id FROM kundendaten.contacts WHERE nic_id=?", array($nic_id));
74
+    if ($result->rowCount() > 0) {
75
+        $data = $result->fetch();
76
+        $c['id'] = $data['id'];
77
+    }
78
+    $id = save_contact($c);
79
+    save_emailaddress($id, $c['email']);
80
+    return $id;
81
+}
82
+
44 83
 
45 84
 function upload_contact($c)
46 85
 {
... ...
@@ -156,7 +156,7 @@ function get_kundenkontakte() {
156 156
 
157 157
 function save_emailaddress($id, $email) 
158 158
 {
159
-    // Speichert eine E-Mail-Adresse direkt, z.B. wenn diese schonmal geprüt wurde
159
+    // Speichert eine E-Mail-Adresse direkt, z.B. wenn diese schonmal geprüft wurde
160 160
     $args = array("cid" => (int) $_SESSION['customerinfo']['customerno'],
161 161
         "id" => (int) $id,
162 162
         "email" => $email);
... ...
@@ -75,8 +75,8 @@ foreach ($user_domains as $domain)
75 75
     $punycode = '';
76 76
   }
77 77
   $domainname = "{$domain->fqdn}{$punycode}";
78
-  if ($_SESSION['role'] & ROLE_CUSTOMER && $domain->provider=='terions') {
79
-      $domainname = internal_link('detail', $domainname, 'id='.$domain->id);
78
+  if ($_SESSION['role'] & ROLE_CUSTOMER && update_possible($domain->id)) {
79
+      $domainname = internal_link('update', $domainname, 'id='.$domain->id);
80 80
   }
81 81
   output("  <tr><td>{$domainname}</td><td>{$regdate}</td><td>{$features}</td></tr>\n");
82 82
 }
... ...
@@ -0,0 +1,60 @@
1
+<?php
2
+/*
3
+This file belongs to the Webinterface of schokokeks.org Hosting
4
+
5
+Written 2008-2018 by schokokeks.org Hosting, namely
6
+  Bernd Wurst <bernd@schokokeks.org>
7
+  Hanno Böck <hanno@schokokeks.org>
8
+
9
+To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10
+
11
+You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
12
+http://creativecommons.org/publicdomain/zero/1.0/
13
+
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
+*/
16
+
17
+require_once('inc/debug.php');
18
+require_once('inc/api.php');
19
+use_module('contacts');
20
+require_once('contacts.php');
21
+require_once('contactapi.php');
22
+
23
+function api_update_domain($id) {
24
+    $result = db_query("SELECT id, CONCAT_WS('.', domainname, tld) AS fqdn, owner, admin_c, registrierungsdatum, kuendigungsdatum FROM kundendaten.domains WHERE id=?", array($id));
25
+    if ($result->rowCount() < 1) {
26
+        system_failure('Domain nicht gefunden');
27
+    }
28
+    $dom = $result->fetch();
29
+    
30
+    $data = array("domainName" => $dom['fqdn']);
31
+    $result = api_request('domainInfo', $data);
32
+    if ($result['status'] != 'success') {
33
+        system_failure("Abfrage nicht erfolgreich!");
34
+    }
35
+    $apidomain = $result['response'];
36
+    $apiowner = NULL;
37
+    $apiadmin_c = NULL;
38
+    foreach ($apidomain['contacts'] as $ac) {
39
+        if ($ac['type'] == 'owner') {
40
+            $apiowner = $ac['contact'];
41
+        }
42
+        if ($ac['type'] == 'admin') {
43
+            $apiadmin_c = $ac['contact'];
44
+        }
45
+    }
46
+
47
+    if (! $apiowner || !$apiadmin_c) {
48
+        system_failure("Ungültige Daten erhalten!");
49
+    }
50
+    $owner = download_contact($apiowner);
51
+    $admin_c = $owner;
52
+    if ($apiadmin_c != $apiowner) {
53
+        $admin_c = download_contact($apiadmin_c);
54
+    }
55
+    if ($owner != $dom['owner'] || $admin_c != $dom['admin_c']) {
56
+        db_query("UPDATE kundendaten.domains SET owner=?, admin_c=? WHERE id=?", array($owner, $admin_c, $id));
57
+    }
58
+}
59
+
60
+
... ...
@@ -81,3 +81,23 @@ function web_in_use($domain)
81 81
 }
82 82
 
83 83
 
84
+function update_possible($domain) {
85
+    $dom = new Domain((int) $domain);
86
+    if ($dom->provider != 'terions' || $dom->billing=='external') {
87
+        // Domain nicht über uns verwaltet
88
+        return false;
89
+    }
90
+    $result = db_query("SELECT aenderung_eigentuemer, ruecksprache FROM misc.domainpreise WHERE tld=?", array($dom->tld));
91
+    if ($result->rowCount() < 1) {
92
+        // Endung nicht bei uns in der Liste erfasst
93
+        return false;
94
+    }
95
+    $data = $result->fetch();
96
+    if ($data['aenderung_eigentuemer'] != NULL || $data['ruecksprache'] == 'Y') {
97
+        // Endung mit speziellen Eigenheiten
98
+        return false;
99
+    }
100
+    return true;
101
+}
102
+
103
+
... ...
@@ -19,6 +19,7 @@ require_once('inc/icons.php');
19 19
 
20 20
 require_once('class/domain.php');
21 21
 require_once('domains.php');
22
+require_once('domainapi.php');
22 23
 
23 24
 require_role(ROLE_CUSTOMER);
24 25
 use_module('contacts');
... ...
@@ -26,6 +27,7 @@ require_once('contacts.php');
26 27
 
27 28
 $dom = NULL;
28 29
 if (isset($_REQUEST['id'])) {
30
+    api_update_domain($_REQUEST['id']);
29 31
     $dom = new Domain( (int) $_REQUEST['id']);
30 32
     if ($dom->provider == 'external' || $dom->provider != 'terions') {
31 33
         system_failure("<p>Diese Domain ist extern registriert!</p>");
... ...
@@ -39,6 +41,9 @@ if (isset($_REQUEST['id'])) {
39 41
 if (!$dom) {
40 42
     system_failure("Keine Domain gewählt!");
41 43
 }
44
+if (!update_possible($dom->id)) {
45
+    system_failure("Diese Domain verwendet eine unübliche Endung. Daher kann der Inhaber nicht auf diesem Weg verändert werden. Bitte kontaktieren Sie den Support.");
46
+}
42 47
 
43 48
 if ($_SESSION['domains_update_admin_c'] == $dom->admin_c && 
44 49
     $_SESSION['domains_update_owner'] != $dom->owner && 
... ...
@@ -59,7 +64,6 @@ title("Änderung der Domain {$dom->fqdn}");
59 64
 $section = 'domains_domains';
60 65
 output('<p>Legen Sie hier einen neuen Inhaber für diese Domain fest.</p>');
61 66
 
62
-$changed = false;
63 67
 
64 68
 $owner = get_contact($_SESSION['domains_update_owner']);
65 69
 $admin_c = get_contact($_SESSION['domains_update_admin_c']);
... ...
@@ -70,7 +74,6 @@ if ($owner['id'] == $admin_c['id']) {
70 74
 $cssclass = '';
71 75
 if ($owner['id'] != $dom->owner) {
72 76
     $cssclass = 'modified';
73
-    $changed = true;
74 77
 }
75 78
 output('<p><strong>'.$function.':</strong></p>'.display_contact($owner, '', $cssclass));
76 79
 addnew('choose', 'Neuen Inhaber wählen', "type=owner");
... ...
@@ -78,7 +81,6 @@ if ($owner['id'] != $admin_c['id']) {
78 81
     $cssclass = '';
79 82
     if ($admin_c['id'] != $dom->admin_c) {
80 83
         $cssclass = 'modified';
81
-        $changed = true;
82 84
     }
83 85
     output('<p><strong>Verwalter:</strong></p>'.display_contact($admin_c, '', $cssclass));
84 86
     addnew('choose', 'Neuen Inhaber wählen', "type=admin_c");
... ...
@@ -88,12 +90,14 @@ if ($owner['id'] != $admin_c['id']) {
88 90
 }
89 91
 
90 92
 
91
-if ($changed) {
93
+if ($owner['id'] != $dom->owner || $admin_c['id'] != $dom->admin_c) {
92 94
     if (isset($_GET['error']) && $_GET['error'] == '1') {
93 95
         input_error('Sie müssen der Übertragung explizit zustimmen!');
94 96
     }
95 97
     $form = '<p>Es sind Änderungen vorgenommen worden, die noch nicht gespeichert wurden</p>';
96
-    $form .= '<p><input type="checkbox" name="accept" value="1" id="accept"><label for="accept"> Ich bestätige, dass ich einen Inhaberwechsel bei der Domain '.$dom->fqdn.' vornehmen möchte. Ich bin darüber informiert, dass die Adresse des Domaininhabers öffentlich abrufbar ist. Der bisherige Domaininhaber hat der Übertragung explizit zugestimmt.</p>';
98
+    $form .= '<p><input type="checkbox" name="accept" value="1" id="accept"><label for="accept"> Ich bestätige, dass ich die nachfolgenden Hinweise zur Kenntnis genommen habe.</p>
99
+    <p>Mit Speichern dieser Änderungen führen Sie möglicherweise einen Inhaberwechsel bei der Domain '.$dom->fqdn.' aus. Inhaberwechsel sind bei einigen Domainendungen (z.B. com/net/org) zustimmungspflichtig vom alten und vom neuen Inhaber. Die Registrierungsstelle kann nach eigenem Ermessen diese Zustimmung per separater E-Mail einfordern. Wird diese Zustimmung nicht oder verspätet erteilt, kann eine Domain gesperrt werden. Dieser Vorgang wird nicht von '.config('company_name').' kontrolliert.</p>
100
+    <p>Sie sind ferner darüber informiert, dass die Adresse des Domaininhabers öffentlich abrufbar ist.</p>';
97 101
     $form .= '<p><input type="submit" name="sumbit" value="Änderungen speichern und Domaininhaber ändern"></p>';
98 102
     output(html_form('domains_update', 'update_save', "id=".$dom->id, $form));
99 103
 } 
100 104