96649f21ba18d07757afa9d98998f7a22c0d86a3
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) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
Bernd Wurst Aktualisiere Domain- und In...

Bernd Wurst authored 6 years ago

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) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

25) function api_download_domain($id)
26) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

27)     $result = db_query("SELECT id, CONCAT_WS('.', domainname, tld) AS fqdn, owner, admin_c, registrierungsdatum, kuendigungsdatum FROM kundendaten.domains WHERE id=?", [$id]);
Bernd Wurst Aktualisiere Domain- und In...

Bernd Wurst authored 6 years ago

28)     if ($result->rowCount() < 1) {
29)         system_failure('Domain nicht gefunden');
30)     }
31)     $dom = $result->fetch();
Hanno remove whitespace in empty...

Hanno authored 6 years ago

32) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

33)     $data = ["domainName" => $dom['fqdn']];
Bernd Wurst Aktualisiere Domain- und In...

Bernd Wurst authored 6 years ago

34)     $result = api_request('domainInfo', $data);
35)     if ($result['status'] != 'success') {
36)         system_failure("Abfrage nicht erfolgreich!");
37)     }
38)     $apidomain = $result['response'];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

39)     $apiowner = null;
40)     $apiadmin_c = null;
Bernd Wurst Aktualisiere Domain- und In...

Bernd Wurst authored 6 years ago

41)     foreach ($apidomain['contacts'] as $ac) {
42)         if ($ac['type'] == 'owner') {
43)             $apiowner = $ac['contact'];
44)         }
45)         if ($ac['type'] == 'admin') {
46)             $apiadmin_c = $ac['contact'];
47)         }
48)     }
49) 
50)     if (! $apiowner || !$apiadmin_c) {
51)         system_failure("Ungültige Daten erhalten!");
52)     }
53)     $owner = download_contact($apiowner);
54)     $admin_c = $owner;
55)     if ($apiadmin_c != $apiowner) {
56)         $admin_c = download_contact($apiadmin_c);
57)     }
58)     if ($owner != $dom['owner'] || $admin_c != $dom['admin_c']) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

59)         db_query("UPDATE kundendaten.domains SET owner=?, admin_c=? WHERE id=?", [$owner, $admin_c, $id]);
Bernd Wurst Aktualisiere Domain- und In...

Bernd Wurst authored 6 years ago

60)     }
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

65) function api_upload_domain($fqdn)
66) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

67)     $result = db_query("SELECT id,CONCAT_WS('.', domainname, tld) AS fqdn, owner, admin_c FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld)=?", [$fqdn]);
Bernd Wurst Domain-Update (Ownerchange)...

Bernd Wurst authored 6 years ago

68)     if ($result->rowCount() < 1) {
69)         system_failure("Unbekannte Domain");
70)     }
71)     $dom = $result->fetch();
72)     $owner = get_contact($dom['owner']);
73)     if (! $owner['nic_id']) {
74)         upload_contact($owner);
75)         $owner = get_contact($dom['owner']);
76)     }
77)     $admin_c = get_contact($dom['admin_c']);
78)     if (! $admin_c['nic_id']) {
79)         upload_contact($admin_c);
80)         $admin_c = get_contact($dom['admin_c']);
81)     }
82)     $owner = $owner['nic_id'];
83)     $admin_c = $admin_c['nic_id'];
84) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

85)     $data = ["domainName" => $dom['fqdn']];
Bernd Wurst Domain-Update (Ownerchange)...

Bernd Wurst authored 6 years ago

86)     $result = api_request('domainInfo', $data);
87)     if ($result['status'] != 'success') {
88)         system_failure("Abfrage nicht erfolgreich!");
89)     }
90)     $apidomain = $result['response'];
91)     foreach ($apidomain['contacts'] as $key => $ac) {
92)         if ($ac['type'] == 'owner') {
93)             $apidomain['contacts'][$key]['contact'] = $owner;
94)         }
95)         if ($ac['type'] == 'admin') {
96)             $apidomain['contacts'][$key]['contact'] = $admin_c;
97)         }
98)     }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

99)     $args = ["domain" => $apidomain];
Bernd Wurst Logging eingebaut

Bernd Wurst authored 6 years ago

100)     logger(LOG_INFO, "modules/domains/include/domainapi", "domains", "uploading domain »{$fqdn}«");
Bernd Wurst Zuverlässigeres Logging bei...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

109) 
110) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

111) function api_register_domain($domainname, $authinfo=null)
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

112) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

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

Bernd Wurst authored 6 years ago

114)     if ($result->rowCount() < 1) {
115)         system_failure("Unbekannte Domain");
116)     }
117)     $dom = $result->fetch();
118)     $owner = get_contact($dom['owner']);
119)     if (! $owner['nic_id']) {
120)         upload_contact($owner);
121)         $owner = get_contact($dom['owner']);
122)     }
123)     $admin_c = get_contact($dom['admin_c']);
124)     if (! $admin_c['nic_id']) {
125)         upload_contact($admin_c);
126)         $admin_c = get_contact($dom['admin_c']);
127)     }
128)     $owner = $owner['nic_id'];
129)     $admin_c = $admin_c['nic_id'];
130) 
131)     // Frage die Masterdomain ab, von dort übernehmen wir Nameserver und zone/tech handles
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

132)     $data = ["domainName" => config('masterdomain')];
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

133)     $result = api_request('domainInfo', $data);
134)     if ($result['status'] != 'success') {
135)         system_failure("Abfrage nicht erfolgreich!");
136)     }
137)     $masterdomain = $result['response'];
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

138)     $newdomain = [];
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

139)     $newdomain['name'] = $domainname;
140)     $newdomain['transferLockEnabled'] = true;
141)     $newdomain['nameservers'] = $masterdomain['nameservers'];
142)     $newdomain['contacts'] = $masterdomain['contacts'];
143) 
144)     foreach ($masterdomain['contacts'] as $key => $ac) {
145)         if ($ac['type'] == 'owner') {
146)             $newdomain['contacts'][$key]['contact'] = $owner;
147)         }
148)         if ($ac['type'] == 'admin') {
149)             $newdomain['contacts'][$key]['contact'] = $admin_c;
150)         }
151)     }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

152)     $result = null;
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

153)     if ($dom['status'] == 'prereg') {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

154)         $args = ["domain" => $newdomain];
Bernd Wurst Logging eingebaut

Bernd Wurst authored 6 years ago

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

156)         $result = api_request('domainCreate', $args);
157)     } else {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

158)         $args = ["domain" => $newdomain, "transferData" => ["authInfo" => $authinfo]];
Bernd Wurst Logging eingebaut

Bernd Wurst authored 6 years ago

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

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

165)         system_failure("Es trat ein interner Fehler auf. Bitte dem Support Bescheid geben!");
166)     }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

167)     return $result;
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

168) }
169) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

170) function api_domain_available($domainname)
Bernd Wurst Ermögliche das Hinzufügen e...

Bernd Wurst authored 6 years ago

171) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

172)     $args = ["domainNames" => [$domainname]];
Bernd Wurst Ermögliche das Hinzufügen e...

Bernd Wurst authored 6 years ago

173)     $result = api_request('domainStatus', $args);
174)     $resp = $result["responses"][0];
Bernd Wurst Domain-Transfer und -Regist...

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

179) function api_cancel_domain($domainname)
180) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

181)     $data = ["domainName" => $domainname];
Bernd Wurst Transfer-Freigabe und Kündi...

Bernd Wurst authored 6 years ago

182)     $result = api_request('domainInfo', $data);
183)     if ($result['status'] != 'success') {
184)         system_failure("Abfrage nicht erfolgreich!");
185)     }
186)     $apidomain = $result['response'];
187)     if (! $apidomain['latestDeletionDateWithoutRenew']) {
188)         system_failure("Konnte Vertragsende nicht herausfinden.");
189)     }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

190)     $args = ["domainName" => $domainname, "execDate" => $apidomain['latestDeletionDateWithoutRenew']];
Bernd Wurst fixed logfile string

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Bernd Wurst authored 6 years ago

194)         $errstr = $result['errors'][0]['text'];
195)         logger(LOG_ERR, "modules/domains/include/domainapi", "domains", "error canceling domain $domainname: {$errstr}");
196)         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

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

Bernd Wurst authored 6 years ago

198)     return $result;
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

199) }
Bernd Wurst Transfer-Freigabe und Kündi...

Bernd Wurst authored 6 years ago

200) 
201) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

202) function api_unlock_domain($domainname)
Bernd Wurst Transfer-Freigabe und Kündi...

Bernd Wurst authored 6 years ago

203) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

204)     $data = ["domainName" => $domainname];
Bernd Wurst Transfer-Freigabe und Kündi...

Bernd Wurst authored 6 years ago

205)     $result = api_request('domainInfo', $data);
206)     if ($result['status'] != 'success') {
207)         system_failure("Abfrage nicht erfolgreich!");
208)     }
209)     $apidomain = $result['response'];
210)     $apidomain['transferLockEnabled'] = false;
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

211)     $args = ["domain" => $apidomain];
Bernd Wurst Logging eingebaut

Bernd Wurst authored 6 years ago

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

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