dcc202fb249a446ac15c7cf413b9f1b4a3f31b58
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 PSR12 + array s...

Hanno Böck authored 3 years 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 Fix coding style with php-c...

Hanno authored 6 years 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) {
72)         $pwhash = "{SHA}".base64_encode(sha1($password_http, true));
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 Update codingstyle accordin...

Hanno authored 5 years 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 != '************') {
103)         $args[":pwhash"] = "{SHA}".base64_encode(sha1($password_http, true));
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)         }
131)         $entry['fqdn'] = $entry['hostname'].'.'.$dom->fqdn;
132)         if (! $entry['hostname']) {
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)) {
148)         system_failure('invalid type: '.$type);
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();
188)         $entry['fqdn'] = $entry['hostname'].'.'.$dom->fqdn;
189)         if (! $entry['hostname']) {
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 fix codingstyle

Hanno Böck authored 4 years ago

210) function warn_autorecord_collission($hostname, $domain, $type)
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) {
214)         if ($ar['hostname'] == $hostname && $ar['type'] == $type) {
215)             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.');
216)             break;
217)         }
218)     }
219) }
220) 
221) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

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

bernd authored 16 years ago

223) 
224) function save_dns_record($id, $record)
225) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

226)     global $valid_record_types;
227)     global $implemented_record_types;
228)     $record['type'] = strtolower($record['type']);
229)     if (!in_array($record['type'], $valid_record_types)) {
230)         system_failure('invalid type: '.$record['type']);
231)     }
232)     if (!in_array($record['type'], $implemented_record_types)) {
233)         system_failure('record type '.$record['type'].' not implemented at the moment.');
234)     }
235)     $dom = new Domain((int) $record['domain']);
236)     $dom->ensure_userdomain();
237)     if (! $dom->id) {
238)         system_failure('invalid domain');
239)     }
240)     if ($record['hostname'] == '') {
241)         $record['hostname'] = null;
242)     }
243)     verify_input_hostname($record['hostname'], true);
244)     verify_input_recorddata($record['data']);
245)     if ($record['ttl'] &&  (int) $record['ttl'] < 1) {
246)         system_failure('Fehler bei TTL');
247)     }
Bernd Wurst added support for SRV recor...

Bernd Wurst authored 4 years ago

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

Hanno authored 6 years ago

249)     switch ($record['type']) {
bernd add save function

bernd authored 16 years ago

250)     case 'a':
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

251)       if ($record['dyndns']) {
252)           get_dyndns_account($record['dyndns']);
253)           $record['ip'] = null;
254)       } else {
255)           verify_input_ipv4($record['ip']);
256)           $record['data'] = null;
257)           $record['spec'] = null;
bernd add save function

bernd authored 16 years ago

258)       }
259)       break;
260)     case 'aaaa':
Bernd Wurst IPv6-support für DynDNS

Bernd Wurst authored 6 years ago

261)       if ($record['dyndns']) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

262)           get_dyndns_account($record['dyndns']);
263)           $record['ip'] = null;
Bernd Wurst IPv6-support für DynDNS

Bernd Wurst authored 6 years ago

264)       } else {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

265)           $record['dyndns'] = null;
Bernd Wurst IPv6-support für DynDNS

Bernd Wurst authored 6 years ago

266)           verify_input_ipv6($record['ip']);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

267)           $record['data'] = null;
268)           $record['spec'] = null;
Bernd Wurst IPv6-support für DynDNS

Bernd Wurst authored 6 years ago

269)       }
bernd add save function

bernd authored 16 years ago

270)       break;
271)     case 'mx':
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

272)       $record['dyndns'] = null;
bernd add save function

bernd authored 16 years ago

273)       $record['spec'] = (int) $record['spec'];
Bernd Wurst Fixed mx-priority can be 0...

Bernd Wurst authored 5 years ago

274)       if ($record['spec'] < 0) {
275)           system_failure("invalid priority");
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

276)       }
bernd add save function

bernd authored 16 years ago

277)       verify_input_hostname($record['data']);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

278)       if (! $record['data']) {
279)           system_failure('MX hostname missing');
280)       }
281)       $record['ip'] = null;
bernd add save function

bernd authored 16 years ago

282)       break;
bernd DNs-record-Interface ist je...

bernd authored 15 years ago

283)     case 'ptr':
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

284)     case 'ns':
Bernd Wurst Text für Autorecords geände...

Bernd Wurst authored 6 years ago

285)       if (!$record['hostname']) {
286)           system_failure("Die angestrebte Konfiguration wird nicht funktionieren, Speichern wurde daher verweigert.");
287)       }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

288)       // no break
Bernd Wurst Text für Autorecords geände...

Bernd Wurst authored 6 years ago

289)     case 'cname':
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

290)       $record['dyndns'] = null;
291)       $record['spec'] = null;
292)       $record['ip'] = null;
bernd add save function

bernd authored 16 years ago

293)       verify_input_hostname($record['data']);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

294)       if (! $record['data']) {
295)           system_failure('destination host missing');
296)       }
bernd add save function

bernd authored 16 years ago

297)       break;
298) 
bernd DNs-record-Interface ist je...

bernd authored 15 years ago

299)     case 'spf':
300)     case 'txt':
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

301)       $record['dyndns'] = null;
302)       $record['spec'] = null;
303)       $record['ip'] = null;
304)       if (! $record['data']) {
305)           system_failure('text entry missing');
306)       }
bernd SPF und TXT records

bernd authored 15 years ago

307)       break;
308) 
bernd SSHFP-Records (Thanks to Ma...

bernd authored 13 years ago

309)     case 'sshfp':
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

310)       $record['dyndns'] = null;
311)       $record['spec'] = max((int) $record['spec'], 1);
312)       $record['ip'] = null;
313)       if (! $record['data']) {
314)           system_failure('text entry missing');
315)       }
bernd SSHFP-Records (Thanks to Ma...

bernd authored 13 years ago

316)       break;
317) 
Hanno Böck add caa support

Hanno Böck authored 7 years ago

318)     case 'caa':
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

319)       $record['dyndns'] = null;
320)       $record['ip'] = null;
321)       if (! $record['data']) {
322)           system_failure('text entry missing');
323)       }
Hanno Böck add caa support

Hanno Böck authored 7 years ago

324)       break;
bernd SSHFP-Records (Thanks to Ma...

bernd authored 13 years ago

325) 
bernd add save function

bernd authored 16 years ago

326)     case 'srv':
Bernd Wurst added support for SRV recor...

Bernd Wurst authored 4 years ago

327)       $record['dyndns'] = null;
328)       $record['spec'] = (int) $record['spec'];
329)       if ($record['spec'] < 0) {
330)           system_failure("invalid priority");
331)       }
332)       if (! $record['data']) {
333)           system_failure('SRV target missing');
334)       }
Hanno Böck more robust SRV record filt...

Hanno Böck authored 4 years ago

335)       $data = explode(':', $record['data']);
Bernd Wurst validate SRV record data field

Bernd Wurst authored 4 years ago

336)       if (count($data) != 2) {
337)           system_failure('Das eingegebene Ziel war nicht im Format hostname:port');
338)       }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

339)       [$hostname, $port] = $data;
Bernd Wurst added support for SRV recor...

Bernd Wurst authored 4 years ago

340)       verify_input_hostname($hostname);
Hanno Böck more robust SRV record filt...

Hanno Böck authored 4 years ago

341)       if ($port !== (string)(int) $port || (int)$port < 1 || (int)$port > 65535) {
Bernd Wurst validate SRV record data field

Bernd Wurst authored 4 years ago

342)           system_failure('Ungültige Portnummer');
343)       }
Bernd Wurst added support for SRV recor...

Bernd Wurst authored 4 years ago

344)       $record['ip'] = null;
345)       break;
bernd add save function

bernd authored 16 years ago

346)     default:
347)       system_failure('Not implemented');
348)   }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

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

Bernd Wurst authored 10 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

358)     if ($id) {
359)         $args[":id"] = $id;
360)         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);
361)     } else {
362)         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);
363)     }
bernd add save function

bernd authored 16 years ago

364) }
365) 
366) 
367) function delete_dns_record($id)
368) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

374) 
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

375) 
376) function convert_from_autorecords($domainid)
377) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

378)     $dom = new Domain((int) $domainid);
379)     $dom->ensure_userdomain();
380)     $dom = $dom->id;
381) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

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

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

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

Hanno authored 6 years ago

391)     $dom = new Domain((int) $domainid);
392)     $dom->ensure_userdomain();
393)     $dom = $dom->id;
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

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

Hanno Böck authored 3 years ago

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

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

398) }
399) 
400) function disable_autorecords($domainid)
401) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

402)     $dom = new Domain((int) $domainid);
403)     $dom->ensure_userdomain();
404)     $dom = $dom->id;
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

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

Hanno Böck authored 3 years ago

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

bernd authored 15 years ago

407) }
408) 
409) 
Bernd Wurst Warnung, wenn man bei einer...

Bernd Wurst authored 12 years ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

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

Bernd Wurst authored 12 years ago

416) }
417) 
bernd Autodns ein- und ausschaltb...

bernd authored 15 years ago

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

Hanno Böck authored 3 years ago

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

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

421) function own_ns()
422) {
423)     global $own_ns;
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

425)     if (count($own_ns) < 1) {
426)         $auth = dns_get_record(config('masterdomain'), DNS_NS);
427)         foreach ($auth as $ns) {
428)             $own_ns[] = $ns['target'];
429)         }
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

430)     }
431) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

Bernd Wurst authored 10 years ago

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

Hanno Böck authored 3 years ago

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

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

438) function check_dns($domainname, $tld)
439) {
440)     global $tld_ns;
441)     $domain=idn_to_ascii($domainname.".".$tld, 0, INTL_IDNA_VARIANT_UTS46);
442) 
443)     if (! isset($tld_ns[$tld])) {
444)         $resp = shell_exec('dig @a.root-servers.net. +noall +authority -t ns '.$tld.'.');
445)         $line = explode("\n", $resp, 2)[0];
446)         $NS = preg_replace("/^.*\\sIN\\s+NS\\s+(\\S+)$/", '\1', $line);
447)         $tld_ns[$tld] = $NS;
448)     }
Hanno remove whitespace in empty...

Hanno authored 6 years ago

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

Hanno authored 6 years ago

450)     $resp = shell_exec('dig @'.$tld_ns[$tld].' +noall +authority -t ns '.$domain.'.');
451)     $line = explode("\n", $resp, 2)[0];
452)     if (preg_match('/^.*\\sIN\\s+NS\\s+/', $line) === 0) {
453)         return "NXDOMAIN";
454)     }
455)     $NS = preg_replace("/^.*\\sIN\\s+NS\\s+(\\S+).$/", '\1', $line);
Hanno remove whitespace in empty...

Hanno authored 6 years ago

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

Hanno authored 6 years ago

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

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

459)     if (in_array($NS, $own_ns)) {
460)         return true;
461)     }
462)     return $NS;
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

463) }
464) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

465) function remove_from_dns($dom)
466) {
467)     $domains = get_domain_list($_SESSION['customerinfo']['customerno'], $_SESSION['userinfo']['uid']);
468)     $current = null;
469)     foreach ($domains as $d) {
470)         if ($d->id == $dom && $d->dns == 1) {
471)             $current = $d;
472)             break;
473)         }
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

475)     if (! $current) {
476)         system_failure("Domain nicht gefunden!");
477)     }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

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

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

Hanno authored 6 years ago

481) function add_to_dns($dom)
482) {
483)     $domains = get_domain_list($_SESSION['customerinfo']['customerno'], $_SESSION['userinfo']['uid']);
484)     $current = null;
485)     foreach ($domains as $d) {
486)         if ($d->id == $dom && $d->dns == 0) {
487)             $current = $d;
488)             break;
489)         }
Bernd Wurst Warne, wenn bei den DNS-Ser...

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

491)     if (! $current) {
492)         system_failure("Domain nicht gefunden!");
493)     }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

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