740b2bce32a775a38d703fae0d6fbefe456acd0c
Bernd Wurst Aktualisiere Domain- und In...

Bernd Wurst authored 6 years ago

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) 
Bernd Wurst Domain-Update (Ownerchange)...

Bernd Wurst authored 6 years ago

23) function api_download_domain($id) {
Bernd Wurst Aktualisiere Domain- und In...

Bernd Wurst authored 6 years ago

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)