fe8d7c2025e33349ab1e51c0e906ec3ee69dcff2
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

1) <?php
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 2 years ago

5) Written by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 2 years ago

9) This code is published under a 0BSD license.
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

10) 
11) 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.
12) */
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

13) 
14) require_once('inc/debug.php');
15) require_once('inc/base.php');
16) require_once('inc/security.php');
bernd Neue Autorecords-Tabelle

bernd authored 14 years ago

17) require_once('inc/error.php');
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

18) 
19) require_once('class/domain.php');
20) 
Hanno Böck codingstyle, spaces between...

Hanno Böck authored 1 year ago

21) $caa_properties = [ 0 => "issue", 1 => "issuewild", 2 => "iodef" ];
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

22) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

23) function get_dyndns_accounts()
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

24) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

25)     $uid = (int) $_SESSION['userinfo']['uid'];
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

26)     $result = db_query("SELECT * FROM dns.dyndns WHERE uid=?", [$uid]);
27)     $list = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

28)     while ($item = $result->fetch()) {
29)         array_push($list, $item);
30)     }
31)     DEBUG($list);
32)     return $list;
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

33) }
34) 
35) 
Hanno Böck codingstyle, spaces between...

Hanno Böck authored 1 year ago

36) function get_dyndns_account($id, $ignore = true)
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

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

Hanno Böck authored 3 years ago

38)     $args = [":id" => (int) $id,
Hanno Böck Neue codingstyle-rule array...

Hanno Böck authored 7 months ago

39)         ":uid" => (int) $_SESSION['userinfo']['uid'], ];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

40)     $result = db_query("SELECT * FROM dns.dyndns WHERE id=:id AND uid=:uid", $args);
41)     if ($result->rowCount() != 1) {
42)         if ($ignore) {
43)             return null;
44)         }
45)         logger(LOG_WARNING, "modules/dns/include/dnsinclude", "dyndns", "account »{$id}« invalid for uid »{$_SESSION['userinfo']['uid']}«.");
46)         system_failure("Account ungültig");
47)     }
48)     $item = $result->fetch();
49)     DEBUG($item);
50)     return $item;
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

51) }
52) 
53) 
54) function create_dyndns_account($handle, $password_http, $sshkey)
55) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

56)     $uid = (int) $_SESSION['userinfo']['uid'];
bernd Warnings eliminiert und Plu...

bernd authored 15 years ago

57) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

58)     if ($password_http == '' && $sshkey == '') {
59)         system_failure('Sie müssen entweder einen SSH-Key oder ein Passwort zum Web-Update eingeben.');
60)     }
bernd Warnings eliminiert und Plu...

bernd authored 15 years ago

61) 
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 5 years ago

62)     $handle = verify_input_identifier($handle);
Hanno Böck validiere SSH-Keys korrekt

Hanno Böck authored 7 years ago

63) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

64)     if (strlen(trim($sshkey)) == 0) {
65)         $sshkey = null;
66)     } else {
67)         $sshkey = filter_ssh_key($sshkey);
68)     }
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

69) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

70)     $pwhash = null;
71)     if ($password_http) {
Hanno Böck dyndns: use gen_pw_hash for...

Hanno Böck authored 10 months ago

72)         if (($check = strong_password($password_http)) !== true) {
73)             system_failure($check);
74)         }
75)         $pwhash = gen_pw_hash($password_http);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

76)     }
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

77) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

78)     db_query(
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

79)         "INSERT INTO dns.dyndns (uid, handle, password, sshkey) VALUES " .
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

80)            "(:uid, :handle, :pwhash, :sshkey)",
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

81)         [":uid" => $uid, ":handle" => $handle, ":pwhash" => $pwhash, ":sshkey" => $sshkey]
Hanno Fix codingstyle

Hanno authored 5 years ago

82)     );
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

83)     $dyndns_id = db_insert_id();
84)     //$masterdomain = new Domain(config('masterdomain'));
85)     //db_query("INSERT INTO dns.custom_records (type, domain, hostname, dyndns, ttl) VALUES ".
86)     //         "('a', :dom, :hostname, :dyndns, 120)",
87)     //         array(":dom" => $masterdomain->id, ":hostname" => filter_input_hostname($handle).'.'.$_SESSION['userinfo']['username'], ":dyndns" => $dyndns_id));
88)     logger(LOG_INFO, "modules/dns/include/dnsinclude", "dyndns", "inserted account {$dyndns_id}");
89)     return $dyndns_id;
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

90) }
91) 
92) 
93) function edit_dyndns_account($id, $handle, $password_http, $sshkey)
94) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

95)     $id = (int) $id;
96)     $oldaccount = get_dyndns_account($id);
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 5 years ago

97)     $handle = verify_input_identifier($handle);
98)     $sshkey = verify_input_ascii($sshkey);
99)     if (trim($sshkey) == '') {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

100)         $sshkey = null;
101)     }
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

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

Hanno Böck authored 3 years ago

103)     $args = [":handle" => $handle, ":sshkey" => $sshkey, ":id" => $id];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

104)     $pwhash = null;
105)     if ($password_http && $password_http != '************') {
Hanno Böck dyndns: use gen_pw_hash for...

Hanno Böck authored 10 months ago

106)         if (($check = strong_password($password_http)) !== true) {
107)             system_failure($check);
108)         }
109)         $args[":pwhash"] = gen_pw_hash($password_http);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

110)         db_query("UPDATE dns.dyndns SET handle=:handle, password=:pwhash, sshkey=:sshkey WHERE id=:id", $args);
111)     } else {
112)         db_query("UPDATE dns.dyndns SET handle=:handle, sshkey=:sshkey WHERE id=:id", $args);
113)     }
114)     logger(LOG_INFO, "modules/dns/include/dnsinclude", "dyndns", "edited account »{$id}«");
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

115) }
116) 
117) 
118) function delete_dyndns_account($id)
119) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

120)     $id = (int) $id;
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

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

Hanno Böck authored 3 years ago

122)     db_query("DELETE FROM dns.dyndns WHERE id=?", [$id]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

123)     logger(LOG_INFO, "modules/dns/include/dnsinclude", "dyndns", "deleted account »{$id}«");
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

124) }
125) 
126) 
127) function get_dyndns_records($id)
128) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

129)     $id = (int) $id;
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

130)     $result = db_query("SELECT hostname, domain, type, ttl, lastchange, id FROM dns.custom_records WHERE dyndns=?", [$id]);
131)     $data = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

132)     while ($entry = $result->fetch()) {
133)         $dom = new Domain((int) $entry['domain']);
134)         if ($dom->fqdn != config('masterdomain') && $dom->fqdn != config('user_vhosts_domain')) {
135)             $dom->ensure_userdomain();
136)         }
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

137)         $entry['fqdn'] = $entry['hostname'] . '.' . $dom->fqdn;
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

138)         if (!$entry['hostname']) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

139)             $entry['fqdn'] = $dom->fqdn;
140)         }
141)         array_push($data, $entry);
Bernd Wurst Erzeuge DNS-Records der For...

Bernd Wurst authored 10 years ago

142)     }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

143)     DEBUG($data);
144)     return $data;
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

145) }
146) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

147) $valid_record_types = ['a', 'aaaa', 'mx', 'ns', 'spf', 'txt', 'cname', 'ptr', 'srv', 'raw', 'sshfp', 'caa', 'srv'];
bernd some updates

bernd authored 16 years ago

148) 
149) 
150) function blank_dns_record($type)
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

151) {
152)     global $valid_record_types;
153)     if (!in_array(strtolower($type), $valid_record_types)) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

154)         system_failure('invalid type: ' . $type);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

155)     }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

156)     $rec = ['hostname' => null,
Hanno Böck Neue codingstyle-rule array...

Hanno Böck authored 7 months ago

157)         'domain' => 0,
158)         'type' => strtolower($type),
159)         'ttl' => 3600,
160)         'ip' => null,
161)         'dyndns' => null,
162)         'data' => null,
163)         'spec' => null, ];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

164)     if (strtolower($type) == 'mx') {
165)         $rec['data'] = config('default_mx');
166)         $rec['spec'] = '5';
167)     }
168)     return $rec;
bernd some updates

bernd authored 16 years ago

169) }
170) 
171) function get_dns_record($id)
172) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

173)     $id = (int) $id;
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

174)     $result = db_query("SELECT hostname, domain, type, ip, dyndns, spec, data, ttl FROM dns.custom_records WHERE id=?", [$id]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

175)     if ($result->rowCount() != 1) {
176)         system_failure('illegal ID');
177)     }
178)     $data = $result->fetch();
179)     $dom = new Domain((int) $data['domain']);
180)     $dom->ensure_userdomain();
181)     DEBUG($data);
182)     return $data;
bernd some updates

bernd authored 16 years ago

183) }
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

184) 
185) 
186) function get_domain_records($dom)
187) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

188)     $dom = (int) $dom;
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

189)     $result = db_query("SELECT hostname, domain, type, ip, dyndns, spec, data, ttl, id FROM dns.custom_records WHERE domain=?", [$dom]);
190)     $data = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

191)     while ($entry = $result->fetch()) {
192)         $dom = new Domain((int) $entry['domain']);
193)         $dom->ensure_userdomain();
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

194)         $entry['fqdn'] = $entry['hostname'] . '.' . $dom->fqdn;
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

195)         if (!$entry['hostname']) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

196)             $entry['fqdn'] = $dom->fqdn;
197)         }
198)         array_push($data, $entry);
199)     }
200)     DEBUG($data);
201)     return $data;
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

202) }
203) 
bernd some updates

bernd authored 16 years ago

204) function get_domain_auto_records($domainname)
205) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

206)     $result = db_query("SELECT hostname, domain, CONCAT_WS('.', hostname, domain) AS fqdn, type, ip, spec, data, ttl FROM dns.tmp_autorecords WHERE domain=?", [$domainname]);
207)     $data = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

208)     while ($entry = $result->fetch()) {
209)         array_push($data, $entry);
210)     }
211)     DEBUG($data);
212)     return $data;
bernd some updates

bernd authored 16 years ago

213) }
214) 
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

215) 
Hanno Böck Spezialfall TXT/SPF-Record...

Hanno Böck authored 1 year ago

216) function warn_autorecord_collission($hostname, $domain, $type, $data)
Hanno Böck fix codingstyle

Hanno Böck authored 4 years ago

217) {
Bernd Wurst added support for SRV recor...

Bernd Wurst authored 4 years ago

218)     $autorecords = get_domain_auto_records($domain);
219)     foreach ($autorecords as $ar) {
Hanno Böck Spezialfall TXT/SPF-Record...

Hanno Böck authored 1 year ago

220)         if (!str_starts_with($data, "v=spf1") && $hostname == null) {
221)             // Spezialfall SPF-Record
222)             continue;
223)         }
Bernd Wurst added support for SRV recor...

Bernd Wurst authored 4 years ago

224)         if ($ar['hostname'] == $hostname && $ar['type'] == $type) {
225)             warning('Sie haben einen DNS-Record angelegt, für den bisher ein automatisch erzeuger Record vorhanden war. Ihr neuer Eintrag wird den bisherigen ersetzen. Bitte haben Sie einen Moment Geduld und laden Sie diese Seite in wenigen Minuten neu. Der automatisch erzeute Record sollte dann verschwunden sein.');
226)             break;
227)         }
228)     }
229) }
230) 
231) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

232) $implemented_record_types = ['a', 'aaaa', 'mx', 'spf', 'txt', 'cname', 'ptr', 'srv', 'ns', 'sshfp', 'caa'];
bernd add save function

bernd authored 16 years ago

233) 
234) function save_dns_record($id, $record)
235) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

236)     global $valid_record_types;
237)     global $implemented_record_types;
238)     $record['type'] = strtolower($record['type']);
239)     if (!in_array($record['type'], $valid_record_types)) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

240)         system_failure('invalid type: ' . $record['type']);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

241)     }
242)     if (!in_array($record['type'], $implemented_record_types)) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

243)         system_failure('record type ' . $record['type'] . ' not implemented at the moment.');
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

244)     }
245)     $dom = new Domain((int) $record['domain']);
246)     $dom->ensure_userdomain();
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

247)     if (!$dom->id) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

248)         system_failure('invalid domain');
249)     }
250)     if ($record['hostname'] == '') {
251)         $record['hostname'] = null;
252)     }
253)     verify_input_hostname($record['hostname'], true);
254)     verify_input_recorddata($record['data']);
Hanno Böck Remove some unneeded whites...

Hanno Böck authored 11 months ago

255)     if ($record['ttl'] && (int) $record['ttl'] < 1) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

256)         system_failure('Fehler bei TTL');
257)     }
Hanno Böck Spezialfall TXT/SPF-Record...

Hanno Böck authored 1 year ago

258)     warn_autorecord_collission($record['hostname'], $dom->fqdn, $record['type'], $record['data']);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

259)     switch ($record['type']) {
Hanno Böck more strict codingstyle wit...

Hanno Böck authored 2 years ago

260)         case 'a':
261)             if ($record['dyndns']) {
262)                 get_dyndns_account($record['dyndns']);
263)                 $record['ip'] = null;
264)             } else {
265)                 verify_input_ipv4($record['ip']);
266)                 $record['data'] = null;
267)                 $record['spec'] = null;
268)             }
269)             break;
270)         case 'aaaa':
271)             if ($record['dyndns']) {
272)                 get_dyndns_account($record['dyndns']);
273)                 $record['ip'] = null;
274)             } else {
275)                 $record['dyndns'] = null;
276)                 verify_input_ipv6($record['ip']);
277)                 $record['data'] = null;
278)                 $record['spec'] = null;
279)             }
280)             break;
281)         case 'mx':
282)             $record['dyndns'] = null;
283)             $record['spec'] = (int) $record['spec'];
284)             if ($record['spec'] < 0) {
285)                 system_failure("invalid priority");
286)             }
Bernd Wurst check length of DNS records...

Bernd Wurst authored 1 year ago

287)             if (strlen($record['data']) > 255) {
288)                 system_failure('data field is too long');
289)             }
Hanno Böck more strict codingstyle wit...

Hanno Böck authored 2 years ago

290)             verify_input_hostname($record['data']);
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

291)             if (!$record['data']) {
Hanno Böck more strict codingstyle wit...

Hanno Böck authored 2 years ago

292)                 system_failure('MX hostname missing');
293)             }
294)             $record['ip'] = null;
295)             break;
296)         case 'ptr':
297)         case 'ns':
298)             if (!$record['hostname']) {
299)                 system_failure("Die angestrebte Konfiguration wird nicht funktionieren, Speichern wurde daher verweigert.");
300)             }
301)             // no break
302)         case 'cname':
303)             $record['dyndns'] = null;
304)             $record['spec'] = null;
305)             $record['ip'] = null;
Bernd Wurst check length of DNS records...

Bernd Wurst authored 1 year ago

306)             if (strlen($record['data']) > 255) {
307)                 system_failure('data field is too long');
308)             }
Hanno Böck more strict codingstyle wit...

Hanno Böck authored 2 years ago

309)             verify_input_hostname($record['data']);
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

310)             if (!$record['data']) {
Hanno Böck more strict codingstyle wit...

Hanno Böck authored 2 years ago

311)                 system_failure('destination host missing');
312)             }
313)             break;
314) 
315)         case 'spf':
316)         case 'txt':
317)             $record['dyndns'] = null;
318)             $record['spec'] = null;
319)             $record['ip'] = null;
Bernd Wurst check length of DNS records...

Bernd Wurst authored 1 year ago

320)             if (strlen($record['data']) > 1024) {
321)                 system_failure('data field is too long');
322)             }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

323)             if (!$record['data']) {
Hanno Böck more strict codingstyle wit...

Hanno Böck authored 2 years ago

324)                 system_failure('text entry missing');
325)             }
326)             break;
327) 
328)         case 'sshfp':
329)             $record['dyndns'] = null;
330)             $record['spec'] = max((int) $record['spec'], 1);
331)             $record['ip'] = null;
Bernd Wurst check length of DNS records...

Bernd Wurst authored 1 year ago

332)             if (strlen($record['data']) > 255) {
333)                 system_failure('data field is too long');
334)             }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

335)             if (!$record['data']) {
Hanno Böck more strict codingstyle wit...

Hanno Böck authored 2 years ago

336)                 system_failure('text entry missing');
337)             }
338)             break;
339) 
340)         case 'caa':
341)             $record['dyndns'] = null;
342)             $record['ip'] = null;
Bernd Wurst check length of DNS records...

Bernd Wurst authored 1 year ago

343)             if (strlen($record['data']) > 255) {
344)                 system_failure('data field is too long');
345)             }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

346)             if (!$record['data']) {
Hanno Böck more strict codingstyle wit...

Hanno Böck authored 2 years ago

347)                 system_failure('text entry missing');
348)             }
349)             break;
350) 
351)         case 'srv':
352)             $record['dyndns'] = null;
353)             $record['spec'] = (int) $record['spec'];
354)             if ($record['spec'] < 0) {
355)                 system_failure("invalid priority");
356)             }
Bernd Wurst check length of DNS records...

Bernd Wurst authored 1 year ago

357)             if (strlen($record['data']) > 255) {
358)                 system_failure('data field is too long');
359)             }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

360)             if (!$record['data']) {
Hanno Böck more strict codingstyle wit...

Hanno Böck authored 2 years ago

361)                 system_failure('SRV target missing');
362)             }
363)             $data = explode(':', $record['data']);
364)             if (count($data) != 2) {
365)                 system_failure('Das eingegebene Ziel war nicht im Format hostname:port');
366)             }
367)             [$hostname, $port] = $data;
368)             verify_input_hostname($hostname);
Hanno Böck codingstyle - spaces with c...

Hanno Böck authored 10 months ago

369)             if ($port !== (string) (int) $port || (int) $port < 1 || (int) $port > 65535) {
Hanno Böck more strict codingstyle wit...

Hanno Böck authored 2 years ago

370)                 system_failure('Ungültige Portnummer');
371)             }
372)             $record['ip'] = null;
373)             break;
374)         default:
375)             system_failure('Not implemented');
376)     }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

377)     $id = (int) $id;
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

378)     $args = [":domain" => $dom->id,
Hanno Böck Neue codingstyle-rule array...

Hanno Böck authored 7 months ago

379)         ":hostname" => $record['hostname'],
380)         ":type" => $record['type'],
381)         ":ttl" => ($record['ttl'] == 0 ? null : (int) $record['ttl']),
382)         ":ip" => $record['ip'],
383)         ":dyndns" => $record['dyndns'],
384)         ":data" => $record['data'],
385)         ":spec" => $record['spec'], ];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

386)     if ($id) {
387)         $args[":id"] = $id;
388)         db_query("UPDATE dns.custom_records SET hostname=:hostname, domain=:domain, type=:type, ttl=:ttl, ip=:ip, dyndns=:dyndns, data=:data, spec=:spec WHERE id=:id", $args);
389)     } else {
390)         db_query("INSERT INTO dns.custom_records (hostname, domain, type, ttl, ip, dyndns, data, spec) VALUES (:hostname, :domain, :type, :ttl, :ip, :dyndns, :data, :spec)", $args);
391)     }
bernd add save function

bernd authored 16 years ago

392) }
393) 
394) 
395) function delete_dns_record($id)
396) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

397)     $id = (int) $id;
398)     // Diese Funktion prüft, ob der Eintrag einer eigenen Domain gehört
399)     $record = get_dns_record($id);
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

400)     db_query("DELETE FROM dns.custom_records WHERE id=?", [$id]);
bernd add save function

bernd authored 16 years ago

401) }
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

402) 
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

403) 
404) function convert_from_autorecords($domainid)
405) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

406)     $dom = new Domain((int) $domainid);
407)     $dom->ensure_userdomain();
408)     $dom = $dom->id;
409) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

410)     db_query("INSERT IGNORE INTO dns.custom_records SELECT r.id, r.lastchange, type, d.id, hostname, ip, NULL AS dyndns, data, spec, ttl FROM dns.v_tmptable_allrecords AS r INNER JOIN dns.v_domains AS d ON (d.name=r.domain) WHERE d.id=?", [$dom]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

411)     disable_autorecords($dom);
412)     db_query("UPDATE dns.dnsstatus SET status='outdated'");
413)     warning("Die automatischen Einträge werden in Kürze abgeschaltet, bitte haben Sie einen Moment Geduld.");
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

414) }
415) 
416) 
417) function enable_autorecords($domainid)
418) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

419)     $dom = new Domain((int) $domainid);
420)     $dom->ensure_userdomain();
421)     $dom = $dom->id;
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

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

Hanno Böck authored 3 years ago

423)     db_query("UPDATE kundendaten.domains SET autodns=1 WHERE id=?", [$dom]);
424)     db_query("DELETE FROM dns.custom_records WHERE type='ns' AND domain=? AND hostname IS NULL", [$dom]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

425)     warning("Die automatischen Einträge werden in Kürze aktiviert, bitte haben Sie einen Moment Geduld.");
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

426) }
427) 
428) function disable_autorecords($domainid)
429) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

430)     $dom = new Domain((int) $domainid);
431)     $dom->ensure_userdomain();
432)     $dom = $dom->id;
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

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

Hanno Böck authored 3 years ago

434)     db_query("UPDATE kundendaten.domains SET autodns=0 WHERE id=?", [$dom]);
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

435) }
436) 
437) 
Bernd Wurst Warnung, wenn man bei einer...

Bernd Wurst authored 12 years ago

438) function domain_is_maildomain($domain)
439) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

440)     $domain = (int) $domain;
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

441)     $result = db_query("SELECT mail FROM kundendaten.domains WHERE id=?", [$domain]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

442)     $dom = $result->fetch();
443)     return ($dom['mail'] != 'none');
Bernd Wurst Warnung, wenn man bei einer...

Bernd Wurst authored 12 years ago

444) }
445) 
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

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

Hanno Böck authored 3 years ago

447) $own_ns = [];
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

448) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

449) function own_ns()
450) {
451)     global $own_ns;
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

452) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

453)     if (count($own_ns) < 1) {
454)         $auth = dns_get_record(config('masterdomain'), DNS_NS);
455)         foreach ($auth as $ns) {
456)             $own_ns[] = $ns['target'];
457)         }
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

458)     }
459) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

460)     return $own_ns;
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

461) }
462) 
463) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

464) $tld_ns = [];
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

465) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

466) function check_dns($domainname, $tld)
467) {
468)     global $tld_ns;
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

469)     $domain = idn_to_ascii($domainname . "." . $tld, 0, INTL_IDNA_VARIANT_UTS46);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

470) 
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

471)     if (!isset($tld_ns[$tld])) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

472)         $resp = shell_exec('dig @a.root-servers.net. +noall +authority -t ns ' . $tld . '.');
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

473)         $line = explode("\n", $resp, 2)[0];
474)         $NS = preg_replace("/^.*\\sIN\\s+NS\\s+(\\S+)$/", '\1', $line);
475)         $tld_ns[$tld] = $NS;
476)     }
Hanno remove whitespace in empty...

Hanno authored 6 years ago

477) 
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

478)     $resp = shell_exec('dig @' . $tld_ns[$tld] . ' +noall +authority -t ns ' . $domain . '.');
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

479)     $line = explode("\n", $resp, 2)[0];
480)     if (preg_match('/^.*\\sIN\\s+NS\\s+/', $line) === 0) {
481)         return "NXDOMAIN";
482)     }
483)     $NS = preg_replace("/^.*\\sIN\\s+NS\\s+(\\S+).$/", '\1', $line);
Hanno remove whitespace in empty...

Hanno authored 6 years ago

484) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

485)     $own_ns = own_ns();
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

486) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

487)     if (in_array($NS, $own_ns)) {
488)         return true;
489)     }
490)     return $NS;
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

491) }
492) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

493) function remove_from_dns($dom)
494) {
495)     $domains = get_domain_list($_SESSION['customerinfo']['customerno'], $_SESSION['userinfo']['uid']);
496)     $current = null;
497)     foreach ($domains as $d) {
498)         if ($d->id == $dom && $d->dns == 1) {
499)             $current = $d;
500)             break;
501)         }
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

502)     }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

503)     if (!$current) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

504)         system_failure("Domain nicht gefunden!");
505)     }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

506)     db_query("UPDATE kundendaten.domains SET dns=0 WHERE id=?", [$current->id]);
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

507) }
508) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

509) function add_to_dns($dom)
510) {
511)     $domains = get_domain_list($_SESSION['customerinfo']['customerno'], $_SESSION['userinfo']['uid']);
512)     $current = null;
513)     foreach ($domains as $d) {
514)         if ($d->id == $dom && $d->dns == 0) {
515)             $current = $d;
516)             break;
517)         }
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

518)     }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 1 year ago

519)     if (!$current) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

520)         system_failure("Domain nicht gefunden!");
521)     }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

522)     db_query("UPDATE kundendaten.domains SET dns=1, autodns=1 WHERE id=?", [$current->id]);