7569c300cd09a33bf44aa8714faeda46179ebd12
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-Transfer und -Regist...

Bernd Wurst authored 6 years ago

23) 
24) 
Bernd Wurst Domain-Update (Ownerchange)...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

26)     $result = db_query("SELECT id, CONCAT_WS('.', domainname, tld) AS fqdn, owner, admin_c, registrierungsdatum, kuendigungsdatum FROM kundendaten.domains WHERE id=?", array($id));
27)     if ($result->rowCount() < 1) {
28)         system_failure('Domain nicht gefunden');
29)     }
30)     $dom = $result->fetch();
31)     
32)     $data = array("domainName" => $dom['fqdn']);
33)     $result = api_request('domainInfo', $data);
34)     if ($result['status'] != 'success') {
35)         system_failure("Abfrage nicht erfolgreich!");
36)     }
37)     $apidomain = $result['response'];
38)     $apiowner = NULL;
39)     $apiadmin_c = NULL;
40)     foreach ($apidomain['contacts'] as $ac) {
41)         if ($ac['type'] == 'owner') {
42)             $apiowner = $ac['contact'];
43)         }
44)         if ($ac['type'] == 'admin') {
45)             $apiadmin_c = $ac['contact'];
46)         }
47)     }
48) 
49)     if (! $apiowner || !$apiadmin_c) {
50)         system_failure("Ungültige Daten erhalten!");
51)     }
52)     $owner = download_contact($apiowner);
53)     $admin_c = $owner;
54)     if ($apiadmin_c != $apiowner) {
55)         $admin_c = download_contact($apiadmin_c);
56)     }
57)     if ($owner != $dom['owner'] || $admin_c != $dom['admin_c']) {
58)         db_query("UPDATE kundendaten.domains SET owner=?, admin_c=? WHERE id=?", array($owner, $admin_c, $id));
59)     }
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

60)     return $apidomain;
Bernd Wurst Aktualisiere Domain- und In...

Bernd Wurst authored 6 years ago

61) }
62) 
63) 
Bernd Wurst Domain-Update (Ownerchange)...

Bernd Wurst authored 6 years ago

64) function api_upload_domain($fqdn)
65) {
66)     $result = db_query("SELECT id,CONCAT_WS('.', domainname, tld) AS fqdn, owner, admin_c FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld)=?", array($fqdn));
67)     if ($result->rowCount() < 1) {
68)         system_failure("Unbekannte Domain");
69)     }
70)     $dom = $result->fetch();
71)     $owner = get_contact($dom['owner']);
72)     if (! $owner['nic_id']) {
73)         upload_contact($owner);
74)         $owner = get_contact($dom['owner']);
75)     }
76)     $admin_c = get_contact($dom['admin_c']);
77)     if (! $admin_c['nic_id']) {
78)         upload_contact($admin_c);
79)         $admin_c = get_contact($dom['admin_c']);
80)     }
81)     $owner = $owner['nic_id'];
82)     $admin_c = $admin_c['nic_id'];
83) 
84)     $data = array("domainName" => $dom['fqdn']);
85)     $result = api_request('domainInfo', $data);
86)     if ($result['status'] != 'success') {
87)         system_failure("Abfrage nicht erfolgreich!");
88)     }
89)     $apidomain = $result['response'];
90)     foreach ($apidomain['contacts'] as $key => $ac) {
91)         if ($ac['type'] == 'owner') {
92)             $apidomain['contacts'][$key]['contact'] = $owner;
93)         }
94)         if ($ac['type'] == 'admin') {
95)             $apidomain['contacts'][$key]['contact'] = $admin_c;
96)         }
97)     }
98)     $args = array("domain" => $apidomain);
99)     api_request('domainUpdate', $args);
100) 
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

101) }
Bernd Wurst Domain-Update (Ownerchange)...

Bernd Wurst authored 6 years ago

102) 
103) 
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

104) function api_register_domain($domainname, $authinfo=NULL) 
105) {
106)     $result = db_query("SELECT id,CONCAT_WS('.', domainname, tld) AS fqdn, owner, admin_c FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld)=?", array($domainname));
107)     if ($result->rowCount() < 1) {
108)         system_failure("Unbekannte Domain");
109)     }
110)     $dom = $result->fetch();
111)     $owner = get_contact($dom['owner']);
112)     if (! $owner['nic_id']) {
113)         upload_contact($owner);
114)         $owner = get_contact($dom['owner']);
115)     }
116)     $admin_c = get_contact($dom['admin_c']);
117)     if (! $admin_c['nic_id']) {
118)         upload_contact($admin_c);
119)         $admin_c = get_contact($dom['admin_c']);
120)     }
121)     $owner = $owner['nic_id'];
122)     $admin_c = $admin_c['nic_id'];
123) 
124)     // Frage die Masterdomain ab, von dort übernehmen wir Nameserver und zone/tech handles
125)     $data = array("domainName" => config('masterdomain'));
126)     $result = api_request('domainInfo', $data);
127)     if ($result['status'] != 'success') {
128)         system_failure("Abfrage nicht erfolgreich!");
129)     }
130)     $masterdomain = $result['response'];
131)     $newdomain = array();
132)     $newdomain['name'] = $domainname;
133)     $newdomain['transferLockEnabled'] = true;
134)     $newdomain['nameservers'] = $masterdomain['nameservers'];
135)     $newdomain['contacts'] = $masterdomain['contacts'];
136) 
137)     foreach ($masterdomain['contacts'] as $key => $ac) {
138)         if ($ac['type'] == 'owner') {
139)             $newdomain['contacts'][$key]['contact'] = $owner;
140)         }
141)         if ($ac['type'] == 'admin') {
142)             $newdomain['contacts'][$key]['contact'] = $admin_c;
143)         }
144)     }
145)     $result = NULL;
146)     if ($dom['status'] == 'prereg') {
147)         $args = array("domain" => $newdomain);
148)         $result = api_request('domainCreate', $args);
149)     } else {
150)         $args = array("domain" => $newdomain, "transferData" => array("authInfo" => $authinfo));
151)         $result = api_request('domainTransfer', $args);
152)     }
153)     
154) }
155) 
Bernd Wurst Ermögliche das Hinzufügen e...

Bernd Wurst authored 6 years ago

156) function api_domain_available($domainname) 
157) {
158)     $args = array("domainNames" => array($domainname));
159)     $result = api_request('domainStatus', $args);
160)     $resp = $result["responses"][0];
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

161)     return $resp;
Bernd Wurst Ermögliche das Hinzufügen e...

Bernd Wurst authored 6 years ago

162) }
163) 
164)