4c630eb1d90ef9c268aeff3700814575bdf24ed6
bernd VHosts können bearbeitet we...

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) 
Bernd Wurst Copyright year update

Bernd Wurst authored 6 years ago

5) Written 2008-2018 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) 
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

12) http://creativecommons.org/publicdomain/zero/1.0/
13) 
14) Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15) */
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

16) 
17) require_once('session/start.php');
18) 
19) require_once('vhosts.php');
20) 
Bernd Wurst Weise Benutzer auf Wartezei...

Bernd Wurst authored 11 years ago

21) require_once('inc/error.php');
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

22) require_once('inc/security.php');
23) require_once('class/domain.php');
24) 
25) require_role(ROLE_SYSTEMUSER);
26) 
27) require_once("inc/debug.php");
28) global $debugmode;
29) 
30) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

31) if ($_GET['action'] == 'edit') {
32)     check_form_token('vhosts_edit_vhost');
33)     $id = (int) $_GET['vhost'];
34)     $vhost = empty_vhost();
35)     if ($id != 0) {
36)         $vhost = get_vhost_details($id);
37)     }
38)     DEBUG($vhost);
39) 
Hanno Böck vhost-hostnamen vernünftig...

Hanno Böck authored 5 years ago

40)     $hostname = strtolower(trim($_POST['hostname']));
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

41) 
42)     $domainname = null;
43)     $domain_id = (int) $_POST['domain'];
44)     if ($domain_id >= 0) {
45)         $domain = new Domain((int) $_POST['domain']);
46)         $domain->ensure_userdomain();
47)         $domain_id = $domain->id;
48)         $domainname = $domain->fqdn;
49)     } elseif ($domain_id == -1) {
50)         # use configured user_vhosts_domain
51)         $userdomain = userdomain();
52)         $domain = new Domain((int) $userdomain['id']);
53)         $domain_id = $domain->id;
54)         $domainname = $domain->fqdn;
55)         $hostname = $hostname.'.'.$_SESSION['userinfo']['username'];
56)         $hostname = trim($hostname, " .-");
57)     } elseif ($domain_id == -2) {
58)         # use system masterdomain
59)         $domainname = $_SESSION['userinfo']['username'].".".config('masterdomain');
60)     }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

Hanno authored 5 years ago

62)     $aliaswww = (isset($_POST['aliaswww']) && $_POST['aliaswww'] == 'aliaswww');
63)     $forwardwww = null;
64)     if ($aliaswww && isset($_POST['forwardwww'])) {
65)         if ($_POST['forwardwww'] == 'forwardwww') {
66)             $forwardwww = 'forwardwww';
67)         } elseif ($_POST['forwardwww'] == 'forwardnowww') {
68)             $forwardwww = 'forwardnowww';
69)         }
Bernd Wurst Funktionsfähiger Prototyp

Bernd Wurst authored 7 years ago

70)     }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

71) 
Hanno Böck vhost-hostnamen vernünftig...

Hanno Böck authored 5 years ago

72)     $fqdn = ($hostname!==""?$hostname.".":"").$domainname;
73)     verify_input_hostname_utf8($fqdn);
74)     if ($aliaswww) {
75)         verify_input_hostname_utf8("www.".$fqdn);
76)     }
77) 
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

78)     $docroot = '';
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

79)     if ($_POST['vhost_type'] == 'regular' || $_POST['vhost_type'] == 'dav') {
80)         $defaultdocroot = $vhost['homedir'].'/websites/'.((strlen($hostname) > 0) ? $hostname.'.' : '').($domainname).'/htdocs';
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

82)         $docroot = '';
83)         if (isset($_POST['docroot'])) {
84)             if (! check_path($_POST['docroot'])) {
85)                 system_failure("Eingegebener Pfad enthält ungültige Angaben");
86)             }
87)             $docroot = $vhost['homedir'].'/websites/'.$_POST['docroot'];
88)         }
89)         if ((isset($_POST['use_default_docroot']) && $_POST['use_default_docroot'] == '1') || ($docroot == $defaultdocroot)) {
90)             $docroot = null;
91)         }
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

93)         DEBUG("Document-Root: ".$docroot);
94)     }
95)     $php = null;
96)     if ($_POST['vhost_type'] == 'regular' && isset($_POST['php'])) {
Bernd Wurst read available php versions...

Bernd Wurst authored 5 years ago

97)         $phpinfo = valid_php_versions();
98)         if (array_key_exists($_POST['php'], $phpinfo)) {
99)             $php = $_POST['php'];
100)         } else {
101)             $php = null;
102)         }
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

103)     }
104)     $cgi = 1;
105)     if (isset($_POST['safemode']) && $_POST['safemode'] == 'yes') {
106)         $cgi = 0;
107)     }
bernd CGI abschaltbar

bernd authored 14 years ago

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

Hanno authored 5 years ago

109)     if (isset($_POST['suexec_user'])) {
110)         $vhost['suexec_user'] = $_POST['suexec_user'];
111)     }
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

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

Hanno authored 5 years ago

113)     if (isset($_POST['server'])) {
114)         $vhost['server'] = $_POST['server'];
115)     }
Bernd Wurst Ermögliche das Auswählen de...

Bernd Wurst authored 11 years ago

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

Hanno authored 5 years ago

117)     if ($_POST['vhost_type'] == 'regular') {
118)         $vhost['is_dav'] = 0;
119)         $vhost['is_svn'] = 0;
120)         $vhost['is_webapp'] = 0;
121)     } elseif ($_POST['vhost_type'] == 'dav') {
122)         $vhost['is_dav'] = 1;
123)         $vhost['is_svn'] = 0;
124)         $vhost['is_webapp'] = 0;
125)     } elseif ($_POST['vhost_type'] == 'svn') {
126)         $vhost['is_dav'] = 0;
127)         $vhost['is_svn'] = 1;
128)         $vhost['is_webapp'] = 0;
129)     } elseif ($_POST['vhost_type'] == 'webapp') {
130)         $vhost['is_dav'] = 0;
131)         $vhost['is_svn'] = 0;
132)         $vhost['is_webapp'] = 1;
133)         $vhost['webapp_id'] = (int) $_POST['webapp'];
134)     }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

135) 
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

137)     $ssl = null;
138)     switch ($_POST['ssl']) {
bernd SSL auch über webinterface...

bernd authored 16 years ago

139)     case 'http':
140)       $ssl = 'http';
141)       break;
142)     case 'https':
143)       $ssl = 'https';
144)       break;
145)     case 'forward':
146)       $ssl = 'forward';
147)       break;
148)     /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
149)   }
150) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

151)     $hsts = null;
152)     $hsts_subdomains = false;
153)     $hsts_preload = false;
154)     if (isset($_POST['hsts'])) {
155)         if (is_numeric($_POST['hsts']) && (int) $_POST['hsts'] > -2) {
156)             $hsts = (int) $_POST['hsts'];
157)         } else {
158)             system_failure('Es wurde ein ungültiger HSTS-Wert eingegeben. Dort sind nur Sekunden erlaubt.');
159)         }
160)         if (isset($_POST['hsts_subdomains']) and $_POST['hsts_subdomains'] == 1) {
161)             $hsts_subdomains = true;
162)             if (isset($_POST['hsts_preload']) and $_POST['hsts_preload'] == 1) {
163)                 $hsts_preload = true;
164)             }
165)         }
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

166)     }
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

168)     $cert = (isset($_POST['cert']) ? (int) $_POST['cert'] : null);
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

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

Hanno authored 5 years ago

170)     $ipv4 = (isset($_POST['ipv4']) ? $_POST['ipv4'] : null);
bernd IP-Adressen aktivieren

bernd authored 14 years ago

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

Hanno authored 5 years ago

172)     if (isset($_POST['ipv6']) && $_POST['ipv6'] == 'yes') {
173)         $vhost['autoipv6'] = 1;
174)         if (isset($_POST['ipv6_separate']) && $_POST['ipv6_separate'] = 'yes') {
175)             $vhost['autoipv6'] = 2;
176)         }
177)     } else {
178)         $vhost['autoipv6'] = 0;
bernd Zusätzlicher Haken für eige...

bernd authored 13 years ago

179)     }
Hanno remove whitespace in empty...

Hanno authored 5 years ago

180) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

Hanno authored 5 years ago

182)     $logtype = '';
183)     switch ($_POST['logtype']) {
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

184)     case 'anonymous':
185)       $logtype = 'anonymous';
186)       break;
187)     case 'default':
188)       $logtype = 'default';
189)       break;
190)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
191)   }
192) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

193)     $errorlog = 0;
194)     if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1)) {
195)         $errorlog = 1;
196)     }
bernd error_log konfigurierbar

bernd authored 16 years ago

197) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

Hanno authored 5 years ago

199)     if (isset($_POST['stats']) && $_POST['stats'] == 1) {
200)         if ($vhost['stats'] == null) {
201)             $vhost['stats'] = 'private';
202)         }
203)     } else {
204)         $vhost['stats'] = null;
205)     }
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

Hanno authored 5 years ago

207)     if ($logtype == '') {
208)         $vhost['stats'] = null;
209)     }
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

211)     DEBUG("PHP: {$php} / Logging: {$logtype}");
212) 
213)     $old_options = explode(',', $vhost['options']);
Bernd Wurst Behandle Sonderfall des lee...

Bernd Wurst authored 5 years ago

214)     if ($vhost['options'] == '') {
215)         $old_options = array();
216)     }
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

217)     $new_options = array();
218)     foreach ($old_options as $op) {
219)         if (! in_array($op, array('aliaswww', 'forwardwww', 'forwardnowww', 'hsts_subdomains', 'hsts_preload'))) {
220)             array_push($new_options, $op);
221)         }
Bernd Wurst * Ermögliche SAN bei CSRs *...

Bernd Wurst authored 8 years ago

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

Hanno authored 5 years ago

223)     if ($aliaswww) {
224)         array_push($new_options, 'aliaswww');
225)         if ($forwardwww) {
226)             array_push($new_options, $forwardwww);
227)         }
Bernd Wurst Funktionsfähiger Prototyp

Bernd Wurst authored 7 years ago

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

Hanno authored 5 years ago

229)     if ($hsts_subdomains) {
230)         array_push($new_options, 'hsts_subdomains');
231)     }
232)     if ($hsts_preload) {
233)         array_push($new_options, 'hsts_preload');
234)     }
235)     $letsencrypt = ($cert == 0 ? false : ($cert == -1 || cert_is_letsencrypt($cert)));
236) 
237)     if ($letsencrypt) {
238)         array_push($new_options, 'letsencrypt');
239)         if ($vhost['cert'] != 0) {
240)             # Wenn der User manuell von einem gültigen Cert auf "letsencrypt" umgestellt hat,
241)             # dann sollte das alte Cert noch so lange eingetragen bleiben bis das neue da ist.
242)             $cert = $vhost['cert'];
243)         } elseif ($cert > 0) {
244)             # Das Cert was der user gewählt hat, ist von Lets encrypt
Bernd Wurst Status der letsencrypt-Opti...

Bernd Wurst authored 8 years ago

245)       # tu nix, $cert ist schon korrekt
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

246)         } else {
247)             # Wenn vorher kein Zertifikat aktiv war, dann setze jetzt auch keines.
248)             # Der letsencrypt-Automatismus macht das dann schon.
249)             $cert = 0;
250)         }
Bernd Wurst Status der letsencrypt-Opti...

Bernd Wurst authored 8 years ago

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

Hanno authored 5 years ago

252)         # Wenn kein Letsencrypt gewünscht ist, entferne die Letsencrypt-Option
253)         $key = array_search('letsencrypt', $new_options);
254)         if ($key !== false) {
255)             unset($new_options[$key]);
256)         }
Bernd Wurst Status der letsencrypt-Opti...

Bernd Wurst authored 8 years ago

257)     }
Hanno codingstyle fixes

Hanno authored 5 years ago

258) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

Hanno authored 5 years ago

260)     DEBUG($old_options);
261)     DEBUG($new_options);
262)     $options = implode(',', $new_options);
263)     DEBUG('New options: '.$options);
264) 
265)     $vhost['hostname'] = $hostname;
266)     $vhost['domain_id'] = $domain_id;
267)     $vhost['docroot'] = $docroot;
268)     $vhost['php'] = $php;
269)     $vhost['cgi'] = $cgi;
270)     $vhost['ssl'] = $ssl;
271)     $vhost['hsts'] = $hsts;
272)     $vhost['cert'] = $cert;
273)     $vhost['ipv4'] = $ipv4;
274)     $vhost['logtype'] = $logtype;
275)     $vhost['errorlog'] = $errorlog;
276)     $vhost['options'] = $options;
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

278)     DEBUG($vhost);
279)     save_vhost($vhost);
280)     success_msg("Ihre Einstellungen wurden gespeichert. Es dauert jedoch einige Minuten bis die Änderungen wirksam werden.");
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

Hanno authored 5 years ago

282)     if (! $debugmode) {
283)         header('Location: vhosts');
284)     }
285) } elseif ($_GET['action'] == 'addalias') {
286)     check_form_token('vhosts_add_alias');
287)     $id = (int) $_GET['vhost'];
288)     $vhost = get_vhost_details($id);
289)     DEBUG($vhost);
bernd Aliases editieren

bernd authored 16 years ago

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

Hanno authored 5 years ago

291)     $alias = empty_alias();
292)     $alias['vhost'] = $vhost['id'];
bernd Aliases editieren

bernd authored 16 years ago

293) 
Hanno remove whitespace in empty...

Hanno authored 5 years ago

294) 
Hanno Böck vhost-hostnamen vernünftig...

Hanno Böck authored 5 years ago

295)     $hostname = strtolower(trim($_POST['hostname']));
296) 
297)     $domain_id = (int) $_POST['domain'];
298)     if ($domain_id >= 0) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

299)         $domain = new Domain((int) $_POST['domain']);
300)         $domain->ensure_userdomain();
Hanno Böck vhost-hostnamen vernünftig...

Hanno Böck authored 5 years ago

301)         $domain_id = $domain->id;
302)         $domainname = $domain->fqdn;
303)     } elseif ($domain_id == -1) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

304)         # use configured user_vhosts_domain
305)         $userdomain = userdomain();
306)         $domain = new Domain((int) $userdomain['id']);
Hanno Böck vhost-hostnamen vernünftig...

Hanno Böck authored 5 years ago

307)         $domain_id = $domain->id;
308)         $domainname = $domain->fqdn;
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

309)         $hostname = $hostname.'.'.$_SESSION['userinfo']['username'];
310)         $hostname = trim($hostname, " .-");
Hanno fix usersubdomain / -2

Hanno authored 5 years ago

311)     } elseif ($domain_id == -2) {
312)         # use system masterdomain
313)         $domainname = $_SESSION['userinfo']['username'].".".config('masterdomain');
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

314)     }
315) 
316)     if (! is_array($_POST['options'])) {
317)         $_POST['options'] = array();
318)     }
319)     $aliaswww = in_array('aliaswww', $_POST['options']);
320)     $forward = in_array('forward', $_POST['options']);
bernd Aliases editieren

bernd authored 16 years ago

321) 
Hanno Böck vhost-hostnamen vernünftig...

Hanno Böck authored 5 years ago

322)     $fqdn = ($hostname!==""?$hostname.".":"").$domainname;
323)     verify_input_hostname_utf8($fqdn);
324)     if ($aliaswww) {
325)         verify_input_hostname_utf8("www.".$fqdn);
326)     }
327) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

328)     $new_options = array();
329)     if ($aliaswww) {
330)         array_push($new_options, 'aliaswww');
331)     }
332)     if ($forward) {
333)         array_push($new_options, 'forward');
334)     }
335)     DEBUG($new_options);
336)     $options = implode(',', $new_options);
337)     DEBUG('New options: '.$options);
338) 
339)     $alias['hostname'] = $hostname;
Hanno Böck vhost-hostnamen vernünftig...

Hanno Böck authored 5 years ago

340)     $alias['domain_id'] = $domain_id;
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

342)     $alias ['options'] = $options;
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

344)     save_alias($alias);
bernd Aliases editieren

bernd authored 16 years ago

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

Hanno authored 5 years ago

346)     if (! $debugmode) {
347)         header('Location: aliases?vhost='.$vhost['id']);
348)     }
349) } elseif ($_GET['action'] == 'deletealias') {
Bernd Wurst Beschriftung im VHosts-Modu...

Bernd Wurst authored 5 years ago

350)     $title = "Website-Alias löschen";
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

351)     $section = 'vhosts_vhosts';
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

353)     $alias = get_alias_details((int) $_GET['alias']);
354)     DEBUG($alias);
355)     $alias_string = $alias['fqdn'];
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

357)     $vhost = get_vhost_details($alias['vhost']);
358)     DEBUG($vhost);
359)     $vhost_string = $vhost['fqdn'];
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

361)     $sure = user_is_sure();
362)     if ($sure === null) {
Bernd Wurst Beschriftung im VHosts-Modu...

Bernd Wurst authored 5 years ago

363)         are_you_sure("action=deletealias&alias={$_GET['alias']}", "Möchten Sie das Alias »{$alias_string}« für die Website »{$vhost_string}« wirklich löschen?");
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

364)     } elseif ($sure === true) {
365)         delete_alias($alias['id']);
366)         if (! $debugmode) {
367)             header('Location: aliases?vhost='.$vhost['id']);
368)         }
369)     } elseif ($sure === false) {
370)         if (! $debugmode) {
371)             header('Location: aliases?vhost='.$vhost['id']);
372)         }
373)     }
374) } elseif ($_GET['action'] == 'delete') {
Bernd Wurst Beschriftung im VHosts-Modu...

Bernd Wurst authored 5 years ago

375)     $title = "Website löschen";
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

376)     $section = 'vhosts_vhosts';
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

378)     $vhost = get_vhost_details((int) $_GET['vhost']);
379)     $vhost_string = $vhost['fqdn'];
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

381)     $sure = user_is_sure();
382)     if ($sure === null) {
Bernd Wurst Beschriftung im VHosts-Modu...

Bernd Wurst authored 5 years ago

383)         are_you_sure("action=delete&vhost={$_GET['vhost']}", "Möchten Sie die Website »{$vhost_string}« wirklich löschen?");
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

384)     } elseif ($sure === true) {
385)         delete_vhost($vhost['id']);
386)         if (! $debugmode) {
387)             header("Location: vhosts");
388)         }
389)     } elseif ($sure === false) {
390)         if (! $debugmode) {
391)             header("Location: vhosts");
392)         }
393)     }
394) } else {
395)     system_failure("Unimplemented action");