60ba2d3f94e0764d99904f896e1f01cecedc22bb
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 Zuverlässigeres Logging bei...

Bernd Wurst authored 6 years ago

100)     $result = api_request('domainUpdate', $args);
101)     if ($result['status'] == 'error') {
102)         $msg = $result['errors'][0]['text'];
103)         logger(LOG_ERR, "modules/domains/include/domainapi", "domains", "ERROR uploading domain »{$fqdn}«: {$msg}");
104)         system_failure("Es trat ein interner Fehler auf. Bitte dem Support Bescheid geben!");
105)     }
106)     return $result;
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

108) 
109) 
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

112)     $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

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

Bernd Wurst authored 6 years ago

154)         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

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

Bernd Wurst authored 6 years ago

158)         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

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

162)         $errstr = $result['errors'][0]['text'];
Bernd Wurst Zuverlässigeres Logging bei...

Bernd Wurst authored 6 years ago

163)         logger(LOG_ERR, "modules/domains/include/domainapi", "domains", "error registering domain $domainname: {$errstr}");
Bernd Wurst Gebe eine generische Fehler...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

167) }
168) 
Bernd Wurst Ermögliche das Hinzufügen e...

Bernd Wurst authored 6 years ago

169) function api_domain_available($domainname) 
170) {
171)     $args = array("domainNames" => array($domainname));
172)     $result = api_request('domainStatus', $args);
173)     $resp = $result["responses"][0];
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

175) }
176) 
177) 
Bernd Wurst Transfer-Freigabe und Kündi...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

190)     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

191)     $result = api_request('domainDelete', $args);
192)     if ($result['status'] == 'error') {
Bernd Wurst Zuverlässigeres Logging bei...

Bernd Wurst authored 6 years ago

193)         $errstr = $result['errors'][0]['text'];
194)         logger(LOG_ERR, "modules/domains/include/domainapi", "domains", "error canceling domain $domainname: {$errstr}");
195)         system_failure("Es trat ein interner Fehler auf. Bitte dem Support Bescheid geben!");
Bernd Wurst Transfer-Freigabe und Kündi...

Bernd Wurst authored 6 years ago

196)     }
Bernd Wurst Zuverlässigeres Logging bei...

Bernd Wurst authored 6 years ago

197)     return $result;
Bernd Wurst Transfer-Freigabe und Kündi...

Bernd Wurst authored 6 years ago

198)  }
199) 
200) 
201) function api_unlock_domain($domainname) 
202) {
203)     $data = array("domainName" => $domainname);
204)     $result = api_request('domainInfo', $data);
205)     if ($result['status'] != 'success') {
206)         system_failure("Abfrage nicht erfolgreich!");
207)     }
208)     $apidomain = $result['response'];
209)     $apidomain['transferLockEnabled'] = false;
210)     $args = array("domain" => $apidomain);
Bernd Wurst Logging eingebaut

Bernd Wurst authored 6 years ago

211)     logger(LOG_WARNING, "modules/domains/include/domainapi", "domains", "allow transfer for domain »{$domainname}«");
Bernd Wurst Zuverlässigeres Logging bei...

Bernd Wurst authored 6 years ago

212)     $result = api_request('domainUpdate', $args);
213)     if ($result['status'] == 'error') {
214)         $errstr = $result['errors'][0]['text'];
215)         logger(LOG_ERR, "modules/domains/include/domainapi", "domains", "error unlocking domain $domainname: {$errstr}");
216)         system_failure("Es trat ein interner Fehler auf. Bitte dem Support Bescheid geben!");
217)     }
218)     return $result;