18ff9a57dd4964bc1964912c62eb9965c3dda93c
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 8 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 11 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)     if (trim($sshkey) == '') {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

99)         $sshkey = null;
Bernd Wurst nutze filter_ssh_key nur we...

Bernd Wurst authored 3 months ago

100)     } else {
101)         $sshkey = filter_ssh_key($sshkey);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 16 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 11 months ago

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

Hanno authored 6 years ago

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

bernd authored 16 years ago

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

Hanno authored 6 years ago

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

bernd authored 16 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

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

bernd authored 16 years ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

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

bernd authored 16 years ago

146) }
147) 
Hanno Böck add HTTPS DNS record type s...

Hanno Böck authored 5 months ago

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

bernd authored 16 years ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

Hanno Böck authored 8 months ago

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

Hanno authored 6 years ago

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

bernd authored 16 years ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

bernd authored 16 years ago

203) }
204) 
bernd some updates

bernd authored 16 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 4 years ago

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

Bernd Wurst authored 4 years ago

219)     $autorecords = get_domain_auto_records($domain);
220)     foreach ($autorecords as $ar) {
Bernd Wurst warnings vermeiden

Bernd Wurst authored 7 months ago

221)         if (is_string($data) && !str_starts_with($data, "v=spf1") && $hostname == null) {
Hanno Böck Spezialfall TXT/SPF-Record...

Hanno Böck authored 1 year ago

222)             // Spezialfall SPF-Record
223)             continue;
224)         }
Bernd Wurst added support for SRV recor...

Bernd Wurst authored 4 years ago

225)         if ($ar['hostname'] == $hostname && $ar['type'] == $type) {
226)             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.');
227)             break;
228)         }
229)     }
230) }
231) 
232) 
Hanno Böck add HTTPS DNS record type s...

Hanno Böck authored 5 months ago

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

bernd authored 16 years ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

249)         system_failure('invalid domain');
250)     }
251)     if ($record['hostname'] == '') {
252)         $record['hostname'] = null;
253)     }
254)     verify_input_hostname($record['hostname'], true);
Hanno Böck add HTTPS DNS record type s...

Hanno Böck authored 5 months ago

255)     /* HTTPS record type allows quotes, we check format below */
256)     if ($record['type'] != 'https') {
257)         verify_input_recorddata($record['data']);
258)     }
Hanno Böck Remove some unneeded whites...

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 2 years ago

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

Bernd Wurst authored 1 year ago

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

Hanno Böck authored 2 years ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 2 years ago

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

Bernd Wurst authored 1 year ago

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

Hanno Böck authored 2 years ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 2 years ago

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

Bernd Wurst authored 1 year ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 2 years ago

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

Bernd Wurst authored 1 year ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 2 years ago

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

Bernd Wurst authored 1 year ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 2 years ago

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

Bernd Wurst authored 1 year ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 2 years ago

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

Hanno Böck authored 11 months ago

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

374)                 system_failure('Ungültige Portnummer');
375)             }
376)             $record['ip'] = null;
377)             break;
Hanno Böck add HTTPS DNS record type s...

Hanno Böck authored 5 months ago

378) 
379)         case 'https':
380)             $record['dyndns'] = null;
381)             $record['ip'] = null;
382)             $record['spec'] = (int) $record['spec'];
383)             if ($record['spec'] < 0) {
384)                 system_failure("invalid priority");
385)             }
386)             if ((!$record['data']) || (strlen($record['data']) == 0)) {
387)                 system_failure('data is missing');
388)             }
389)             if (strlen($record['data']) > 255) {
390)                 system_failure('data field is too long');
391)             }
392)             $data = explode(' ', $record['data']);
393)             $host = array_shift($data);
394)             if ($host != "." && !filter_var($host, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
395)                 system_failure("Ungültiger Hostname!");
396)             }
397)             foreach($data as $d) {
398)                 if (!(preg_match('/[a-z0-9]+=([a-z0-9,:.]+|"[a-z0-9,:.]+")/', $d))) {
399)                     system_failure("Ungültiger HTTPS record!");
400)                 }
401)             }
402)             break;
403) 
Hanno Böck more strict codingstyle wit...

Hanno Böck authored 2 years ago

404)         default:
405)             system_failure('Not implemented');
406)     }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

Hanno Böck authored 8 months ago

409)         ":hostname" => $record['hostname'],
410)         ":type" => $record['type'],
411)         ":ttl" => ($record['ttl'] == 0 ? null : (int) $record['ttl']),
412)         ":ip" => $record['ip'],
413)         ":dyndns" => $record['dyndns'],
414)         ":data" => $record['data'],
415)         ":spec" => $record['spec'], ];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

416)     if ($id) {
417)         $args[":id"] = $id;
418)         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);
419)     } else {
420)         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);
421)     }
bernd add save function

bernd authored 16 years ago

422) }
423) 
424) 
425) function delete_dns_record($id)
426) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

432) 
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

433) 
434) function convert_from_autorecords($domainid)
435) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

436)     $dom = new Domain((int) $domainid);
437)     $dom->ensure_userdomain();
438)     $dom = $dom->id;
439) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

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

441)     disable_autorecords($dom);
442)     db_query("UPDATE dns.dnsstatus SET status='outdated'");
443)     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

444) }
445) 
446) 
447) function enable_autorecords($domainid)
448) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

449)     $dom = new Domain((int) $domainid);
450)     $dom->ensure_userdomain();
451)     $dom = $dom->id;
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

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

Hanno Böck authored 3 years ago

453)     db_query("UPDATE kundendaten.domains SET autodns=1 WHERE id=?", [$dom]);
454)     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

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

456) }
457) 
458) function disable_autorecords($domainid)
459) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

460)     $dom = new Domain((int) $domainid);
461)     $dom->ensure_userdomain();
462)     $dom = $dom->id;
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

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

Hanno Böck authored 3 years ago

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

bernd authored 15 years ago

465) }
466) 
467) 
Bernd Wurst Warnung, wenn man bei einer...

Bernd Wurst authored 12 years ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

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

Bernd Wurst authored 12 years ago

474) }
475) 
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

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

Hanno Böck authored 3 years ago

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

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

479) function own_ns()
480) {
481)     global $own_ns;
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

483)     if (count($own_ns) < 1) {
484)         $auth = dns_get_record(config('masterdomain'), DNS_NS);
485)         foreach ($auth as $ns) {
486)             $own_ns[] = $ns['target'];
487)         }
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

488)     }
489) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

Bernd Wurst authored 10 years ago

491) }
492) 
493) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

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

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

496) function check_dns($domainname, $tld)
497) {
498)     global $tld_ns;
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 1 year ago

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

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

Hanno authored 6 years ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

509)     $line = explode("\n", $resp, 2)[0];
510)     if (preg_match('/^.*\\sIN\\s+NS\\s+/', $line) === 0) {
511)         return "NXDOMAIN";
512)     }
513)     $NS = preg_replace("/^.*\\sIN\\s+NS\\s+(\\S+).$/", '\1', $line);
Hanno remove whitespace in empty...

Hanno authored 6 years ago

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

Hanno authored 6 years ago

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

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

517)     if (in_array($NS, $own_ns)) {
518)         return true;
519)     }
520)     return $NS;
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

521) }
522) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

523) function remove_from_dns($dom)
524) {
525)     $domains = get_domain_list($_SESSION['customerinfo']['customerno'], $_SESSION['userinfo']['uid']);
526)     $current = null;
527)     foreach ($domains as $d) {
528)         if ($d->id == $dom && $d->dns == 1) {
529)             $current = $d;
530)             break;
531)         }
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

537) }
538) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

539) function add_to_dns($dom)
540) {
541)     $domains = get_domain_list($_SESSION['customerinfo']['customerno'], $_SESSION['userinfo']['uid']);
542)     $current = null;
543)     foreach ($domains as $d) {
544)         if ($d->id == $dom && $d->dns == 0) {
545)             $current = $d;
546)             break;
547)         }
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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