3acbdf2a7fc2b9b9e5af211ec0c3c98596906ce7
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,
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 Spaces between string conca...

Hanno Böck authored 1 year ago

72)         $pwhash = "{SHA}" . base64_encode(sha1($password_http, true));
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 16 years ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 1 year ago

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

Bernd Wurst authored 10 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 5 years ago

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

Hanno authored 6 years ago

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

bernd authored 16 years ago

87) }
88) 
89) 
90) function edit_dyndns_account($id, $handle, $password_http, $sshkey)
91) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

92)     $id = (int) $id;
93)     $oldaccount = get_dyndns_account($id);
Bernd Wurst Umstellung von filter_input...

Bernd Wurst authored 5 years ago

94)     $handle = verify_input_identifier($handle);
95)     $sshkey = verify_input_ascii($sshkey);
96)     if (trim($sshkey) == '') {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 16 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

101)     $pwhash = null;
102)     if ($password_http && $password_http != '************') {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

103)         $args[":pwhash"] = "{SHA}" . base64_encode(sha1($password_http, true));
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 16 years ago

109) }
110) 
111) 
112) function delete_dyndns_account($id)
113) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 16 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

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

bernd authored 16 years ago

118) }
119) 
120) 
121) function get_dyndns_records($id)
122) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

126)     while ($entry = $result->fetch()) {
127)         $dom = new Domain((int) $entry['domain']);
128)         if ($dom->fqdn != config('masterdomain') && $dom->fqdn != config('user_vhosts_domain')) {
129)             $dom->ensure_userdomain();
130)         }
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

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

bernd authored 16 years ago

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

Hanno Böck authored 3 years ago

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

bernd authored 16 years ago

142) 
143) 
144) function blank_dns_record($type)
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

145) {
146)     global $valid_record_types;
147)     if (!in_array(strtolower($type), $valid_record_types)) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

150)     $rec = ['hostname' => null,
bernd some updates

bernd authored 16 years ago

151)                'domain' => 0,
152)                'type' => strtolower($type),
153)                'ttl' => 3600,
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

154)                'ip' => null,
155)                'dyndns' => null,
156)                'data' => null,
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

157)                'spec' => null, ];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

158)     if (strtolower($type) == 'mx') {
159)         $rec['data'] = config('default_mx');
160)         $rec['spec'] = '5';
161)     }
162)     return $rec;
bernd some updates

bernd authored 16 years ago

163) }
164) 
165) function get_dns_record($id)
166) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

169)     if ($result->rowCount() != 1) {
170)         system_failure('illegal ID');
171)     }
172)     $data = $result->fetch();
173)     $dom = new Domain((int) $data['domain']);
174)     $dom->ensure_userdomain();
175)     DEBUG($data);
176)     return $data;
bernd some updates

bernd authored 16 years ago

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

bernd authored 16 years ago

178) 
179) 
180) function get_domain_records($dom)
181) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

190)             $entry['fqdn'] = $dom->fqdn;
191)         }
192)         array_push($data, $entry);
193)     }
194)     DEBUG($data);
195)     return $data;
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

196) }
197) 
bernd some updates

bernd authored 16 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

202)     while ($entry = $result->fetch()) {
203)         array_push($data, $entry);
204)     }
205)     DEBUG($data);
206)     return $data;
bernd some updates

bernd authored 16 years ago

207) }
208) 
bernd Stub für dns-Admin-Interface

bernd authored 16 years ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 4 years ago

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

Bernd Wurst authored 4 years ago

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

Hanno Böck authored 1 year ago

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

Bernd Wurst authored 4 years ago

218)         if ($ar['hostname'] == $hostname && $ar['type'] == $type) {
219)             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.');
220)             break;
221)         }
222)     }
223) }
224) 
225) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

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

bernd authored 16 years ago

227) 
228) function save_dns_record($id, $record)
229) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

230)     global $valid_record_types;
231)     global $implemented_record_types;
232)     $record['type'] = strtolower($record['type']);
233)     if (!in_array($record['type'], $valid_record_types)) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

242)         system_failure('invalid domain');
243)     }
244)     if ($record['hostname'] == '') {
245)         $record['hostname'] = null;
246)     }
247)     verify_input_hostname($record['hostname'], true);
248)     verify_input_recorddata($record['data']);
Hanno Böck Remove some unneeded whites...

Hanno Böck authored 11 months ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 2 years ago

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

Bernd Wurst authored 1 year ago

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

Hanno Böck authored 2 years ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 2 years ago

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

Bernd Wurst authored 1 year ago

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

Hanno Böck authored 2 years ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 2 years ago

305)                 system_failure('destination host missing');
306)             }
307)             break;
308) 
309)         case 'spf':
310)         case 'txt':
311)             $record['dyndns'] = null;
312)             $record['spec'] = null;
313)             $record['ip'] = null;
Bernd Wurst check length of DNS records...

Bernd Wurst authored 1 year ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 2 years ago

318)                 system_failure('text entry missing');
319)             }
320)             break;
321) 
322)         case 'sshfp':
323)             $record['dyndns'] = null;
324)             $record['spec'] = max((int) $record['spec'], 1);
325)             $record['ip'] = null;
Bernd Wurst check length of DNS records...

Bernd Wurst authored 1 year ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 2 years ago

330)                 system_failure('text entry missing');
331)             }
332)             break;
333) 
334)         case 'caa':
335)             $record['dyndns'] = null;
336)             $record['ip'] = null;
Bernd Wurst check length of DNS records...

Bernd Wurst authored 1 year ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 2 years ago

341)                 system_failure('text entry missing');
342)             }
343)             break;
344) 
345)         case 'srv':
346)             $record['dyndns'] = null;
347)             $record['spec'] = (int) $record['spec'];
348)             if ($record['spec'] < 0) {
349)                 system_failure("invalid priority");
350)             }
Bernd Wurst check length of DNS records...

Bernd Wurst authored 1 year ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 2 years ago

355)                 system_failure('SRV target missing');
356)             }
357)             $data = explode(':', $record['data']);
358)             if (count($data) != 2) {
359)                 system_failure('Das eingegebene Ziel war nicht im Format hostname:port');
360)             }
361)             [$hostname, $port] = $data;
362)             verify_input_hostname($hostname);
363)             if ($port !== (string)(int) $port || (int)$port < 1 || (int)$port > 65535) {
364)                 system_failure('Ungültige Portnummer');
365)             }
366)             $record['ip'] = null;
367)             break;
368)         default:
369)             system_failure('Not implemented');
370)     }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

372)     $args = [":domain" => $dom->id,
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

373)                 ":hostname" => $record['hostname'],
374)                 ":type" => $record['type'],
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

375)                 ":ttl" => ($record['ttl'] == 0 ? null : (int) $record['ttl']),
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

376)                 ":ip" => $record['ip'],
377)                 ":dyndns" => $record['dyndns'],
378)                 ":data" => $record['data'],
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

379)                 ":spec" => $record['spec'], ];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

380)     if ($id) {
381)         $args[":id"] = $id;
382)         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);
383)     } else {
384)         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);
385)     }
bernd add save function

bernd authored 16 years ago

386) }
387) 
388) 
389) function delete_dns_record($id)
390) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

396) 
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

397) 
398) function convert_from_autorecords($domainid)
399) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

400)     $dom = new Domain((int) $domainid);
401)     $dom->ensure_userdomain();
402)     $dom = $dom->id;
403) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

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

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

408) }
409) 
410) 
411) function enable_autorecords($domainid)
412) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

413)     $dom = new Domain((int) $domainid);
414)     $dom->ensure_userdomain();
415)     $dom = $dom->id;
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

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

Hanno Böck authored 3 years ago

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

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

420) }
421) 
422) function disable_autorecords($domainid)
423) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

424)     $dom = new Domain((int) $domainid);
425)     $dom->ensure_userdomain();
426)     $dom = $dom->id;
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

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

Hanno Böck authored 3 years ago

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

bernd authored 15 years ago

429) }
430) 
431) 
Bernd Wurst Warnung, wenn man bei einer...

Bernd Wurst authored 12 years ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

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

Bernd Wurst authored 12 years ago

438) }
439) 
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

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

Hanno Böck authored 3 years ago

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

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

443) function own_ns()
444) {
445)     global $own_ns;
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

447)     if (count($own_ns) < 1) {
448)         $auth = dns_get_record(config('masterdomain'), DNS_NS);
449)         foreach ($auth as $ns) {
450)             $own_ns[] = $ns['target'];
451)         }
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

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

Bernd Wurst authored 10 years ago

455) }
456) 
457) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

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

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

460) function check_dns($domainname, $tld)
461) {
462)     global $tld_ns;
Hanno Böck Spaces between string conca...

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 1 year ago

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

Hanno Böck authored 1 year ago

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

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

Hanno authored 6 years ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Hanno authored 6 years ago

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

Hanno authored 6 years ago

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

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

481)     if (in_array($NS, $own_ns)) {
482)         return true;
483)     }
484)     return $NS;
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

487) function remove_from_dns($dom)
488) {
489)     $domains = get_domain_list($_SESSION['customerinfo']['customerno'], $_SESSION['userinfo']['uid']);
490)     $current = null;
491)     foreach ($domains as $d) {
492)         if ($d->id == $dom && $d->dns == 1) {
493)             $current = $d;
494)             break;
495)         }
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

501) }
502) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

503) function add_to_dns($dom)
504) {
505)     $domains = get_domain_list($_SESSION['customerinfo']['customerno'], $_SESSION['userinfo']['uid']);
506)     $current = null;
507)     foreach ($domains as $d) {
508)         if ($d->id == $dom && $d->dns == 0) {
509)             $current = $d;
510)             break;
511)         }
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

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

Hanno Böck authored 1 year ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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