bf8afc6f46656ed67ffb1b736144c6379a770981
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);
Bernd Wurst Logging eingebaut

Bernd Wurst authored 6 years ago

99)     logger(LOG_INFO, "modules/domains/include/domainapi", "domains", "uploading domain »{$fqdn}«");
Bernd Wurst Domain-Update (Ownerchange)...

Bernd Wurst authored 6 years ago

100)     api_request('domainUpdate', $args);
101) 
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

105) function api_register_domain($domainname, $authinfo=NULL) 
106) {
Bernd Wurst Session aufräumen, Weiterle...

Bernd Wurst authored 6 years ago

107)     $result = db_query("SELECT id,status,CONCAT_WS('.', domainname, tld) AS fqdn, owner, admin_c FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld)=?", array($domainname));
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

108)     if ($result->rowCount() < 1) {
109)         system_failure("Unbekannte Domain");
110)     }
111)     $dom = $result->fetch();
112)     $owner = get_contact($dom['owner']);
113)     if (! $owner['nic_id']) {
114)         upload_contact($owner);
115)         $owner = get_contact($dom['owner']);
116)     }
117)     $admin_c = get_contact($dom['admin_c']);
118)     if (! $admin_c['nic_id']) {
119)         upload_contact($admin_c);
120)         $admin_c = get_contact($dom['admin_c']);
121)     }
122)     $owner = $owner['nic_id'];
123)     $admin_c = $admin_c['nic_id'];
124) 
125)     // Frage die Masterdomain ab, von dort übernehmen wir Nameserver und zone/tech handles
126)     $data = array("domainName" => config('masterdomain'));
127)     $result = api_request('domainInfo', $data);
128)     if ($result['status'] != 'success') {
129)         system_failure("Abfrage nicht erfolgreich!");
130)     }
131)     $masterdomain = $result['response'];
132)     $newdomain = array();
133)     $newdomain['name'] = $domainname;
134)     $newdomain['transferLockEnabled'] = true;
135)     $newdomain['nameservers'] = $masterdomain['nameservers'];
136)     $newdomain['contacts'] = $masterdomain['contacts'];
137) 
138)     foreach ($masterdomain['contacts'] as $key => $ac) {
139)         if ($ac['type'] == 'owner') {
140)             $newdomain['contacts'][$key]['contact'] = $owner;
141)         }
142)         if ($ac['type'] == 'admin') {
143)             $newdomain['contacts'][$key]['contact'] = $admin_c;
144)         }
145)     }
146)     $result = NULL;
147)     if ($dom['status'] == 'prereg') {
148)         $args = array("domain" => $newdomain);
Bernd Wurst Logging eingebaut

Bernd Wurst authored 6 years ago

149)         logger(LOG_WARNING, "modules/domains/include/domainapi", "domains", "register new domain »{$newdomain['name']}«");
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

150)         $result = api_request('domainCreate', $args);
151)     } else {
152)         $args = array("domain" => $newdomain, "transferData" => array("authInfo" => $authinfo));
Bernd Wurst Logging eingebaut

Bernd Wurst authored 6 years ago

153)         logger(LOG_WARNING, "modules/domains/include/domainapi", "domains", "transfer-in domain »{$newdomain['name']}« with authinfo »{$authinfo}«");
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

154)         $result = api_request('domainTransfer', $args);
155)     }
Bernd Wurst Gebe eine generische Fehler...

Bernd Wurst authored 6 years ago

156)     if ($result['status'] == 'error') {
Bernd Wurst Logging eingebaut

Bernd Wurst authored 6 years ago

157)         $errstr = $result['errors'][0]['text'];
158)         logger(LOG_ERR, "modules/domains/include/domainapi", "domains", "error registering domain: {$errstr}");
Bernd Wurst Gebe eine generische Fehler...

Bernd Wurst authored 6 years ago

159)         system_failure("Es trat ein interner Fehler auf. Bitte dem Support Bescheid geben!");
160)     }
161)     return $result;    
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

162) }
163) 
Bernd Wurst Ermögliche das Hinzufügen e...

Bernd Wurst authored 6 years ago

164) function api_domain_available($domainname) 
165) {
166)     $args = array("domainNames" => array($domainname));
167)     $result = api_request('domainStatus', $args);
168)     $resp = $result["responses"][0];
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

170) }
171) 
172) 
Bernd Wurst Transfer-Freigabe und Kündi...

Bernd Wurst authored 6 years ago

173) function api_cancel_domain($domainname)
174) {
175)     $data = array("domainName" => $domainname);
176)     $result = api_request('domainInfo', $data);
177)     if ($result['status'] != 'success') {
178)         system_failure("Abfrage nicht erfolgreich!");
179)     }
180)     $apidomain = $result['response'];
181)     if (! $apidomain['latestDeletionDateWithoutRenew']) {
182)         system_failure("Konnte Vertragsende nicht herausfinden.");
183)     }
184)     $args = array("domainName" => $domainname, "execDate" => $apidomain['latestDeletionDateWithoutRenew']);
Bernd Wurst Logging eingebaut

Bernd Wurst authored 6 years ago

185)     logger(LOG_WARNING, "modules/domains/include/domainapi", "domains", "cancel domain »{$newdomainname}« at time {$apidomain['latestDeletionDateWithoutRenew']}");
Bernd Wurst Transfer-Freigabe und Kündi...

Bernd Wurst authored 6 years ago

186)     $result = api_request('domainDelete', $args);
187)     if ($result['status'] == 'error') {
188)         //system_failure(print_r($result['errors'], true));
189)     }
190)  }
191) 
192) 
193) function api_unlock_domain($domainname) 
194) {
195)     $data = array("domainName" => $domainname);
196)     $result = api_request('domainInfo', $data);
197)     if ($result['status'] != 'success') {
198)         system_failure("Abfrage nicht erfolgreich!");
199)     }
200)     $apidomain = $result['response'];
201)     $apidomain['transferLockEnabled'] = false;
202)     $args = array("domain" => $apidomain);
Bernd Wurst Logging eingebaut

Bernd Wurst authored 6 years ago

203)     logger(LOG_WARNING, "modules/domains/include/domainapi", "domains", "allow transfer for domain »{$domainname}«");