bc1036251a91a87c2ba8a3a46956fa569224cc9c
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 Lizenzinfos in eigenes Modu...

Bernd Wurst authored 10 years ago

5) Written 2008-2014 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) 
11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
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) 
31) if ($_GET['action'] == 'edit')
32) {
33)   check_form_token('vhosts_edit_vhost');
34)   $id = (int) $_GET['vhost'];
35)   $vhost = empty_vhost();
36)   if ($id != 0)
37)     $vhost = get_vhost_details( $id );
38)   DEBUG($vhost);
39) 
bernd Erlaube wildcards bei vhosts

bernd authored 13 years ago

40)   $hostname = filter_input_hostname($_POST['hostname'], true);
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

41) 
Bernd Wurst Zeige Userdomains nur noch...

Bernd Wurst authored 9 years ago

42)   $domainname = NULL;
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

43)   $domain_id = (int) $_POST['domain'];
Bernd Wurst Ermögliche dem user Hosts m...

Bernd Wurst authored 9 years ago

44)   if ($domain_id >= 0) {
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

45)     $domain = new Domain( (int) $_POST['domain'] );
bernd Mehr config-optionen und co...

bernd authored 14 years ago

46)     $domain->ensure_userdomain();
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

47)     $domain_id = $domain->id;
Bernd Wurst Zeige Userdomains nur noch...

Bernd Wurst authored 9 years ago

48)     $domainname = $domain->fqdn;
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

49)   }
Bernd Wurst Zeige Userdomains nur noch...

Bernd Wurst authored 9 years ago

50)   elseif ($domain_id == -1) {
Bernd Wurst Ermögliche dem user Hosts m...

Bernd Wurst authored 9 years ago

51)     # use configured user_vhosts_domain
52)     $userdomain = userdomain();
53)     $domain = new Domain( (int) $userdomain['id'] );
54)     $domain_id = $domain->id;
Bernd Wurst Zeige Userdomains nur noch...

Bernd Wurst authored 9 years ago

55)     $domainname = $domain->fqdn;
Bernd Wurst Ermögliche dem user Hosts m...

Bernd Wurst authored 9 years ago

56)     $hostname = $hostname.'.'.$_SESSION['userinfo']['username'];
57)     $hostname = trim($hostname, " .-");
58)   }
Bernd Wurst Zeige Userdomains nur noch...

Bernd Wurst authored 9 years ago

59)   elseif ($domain_id == -2) {
60)     # use system masterdomain
61)     $domainname = $_SESSION['userinfo']['username'].".".config('masterdomain');
62)   }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

63) 
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

64)   if (! (isset($_POST['options']) && is_array($_POST['options'])))
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

65)     $_POST['options'] = array();
66)   $aliaswww = in_array('aliaswww', $_POST['options']);
67) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

68)   $docroot = '';
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

69)   if ($_POST['vhost_type'] == 'regular' || $_POST['vhost_type'] == 'dav')
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

70)   {
Bernd Wurst Zeige Userdomains nur noch...

Bernd Wurst authored 9 years ago

71)     $defaultdocroot = $vhost['homedir'].'/websites/'.((strlen($hostname) > 0) ? $hostname.'.' : '').($domainname).'/htdocs';
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

72)   
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

73)     $docroot = '';
74)     if (isset($_POST['docroot']))
75)     {
76)       if (! check_path( $_POST['docroot'] ))
77)         system_failure("Eingegebener Pfad enthält ungültige Angaben");
78)       $docroot = $vhost['homedir'].'/websites/'.$_POST['docroot'];
79)     }
80)     if ((isset($_POST['use_default_docroot']) && $_POST['use_default_docroot'] == '1') || ($docroot == $defaultdocroot)) {
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

81)       $docroot = NULL;
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

82)     }
83)   
84)     DEBUG("Document-Root: ".$docroot);
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

85)   }
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

86)   $php = NULL;
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

87)   if ($_POST['vhost_type'] == 'regular' && isset($_POST['php']))
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

88)   {
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

89)     switch ($_POST['php']) {
Bernd Wurst prepare for experimental PH...

Bernd Wurst authored 12 years ago

90)       case 'php54':
91)         $php = 'php54';
92)         break;
Hanno Böck übrige Änderungen für php55

Hanno Böck authored 10 years ago

93)       case 'php55':
94)         $php = 'php55';
95)         break;
Bernd Wurst PHP 5.6 experimentell

Bernd Wurst authored 9 years ago

96)       case 'php56':
97)         $php = 'php56';
98)         break;
Hanno Böck PHP 7.0 support

Hanno Böck authored 8 years ago

99)       case 'php70':
100)         $php = 'php70';
101)         break;
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

102)       /* Wenn etwas anderes kommt, ist das "kein PHP". So einfach ist das. */
103)     }
104)   }
bernd "CGI-Aktivieren" ist jetzt...

bernd authored 13 years ago

105)   $cgi = 1;
106)   if (isset($_POST['safemode']) && $_POST['safemode'] == 'yes')
bernd CGI abschaltbar

bernd authored 14 years ago

107)   {
bernd "CGI-Aktivieren" ist jetzt...

bernd authored 13 years ago

108)     $cgi = 0;
bernd CGI abschaltbar

bernd authored 14 years ago

109)   }
110) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

111)   if (isset($_POST['suexec_user']))
112)     $vhost['suexec_user'] = $_POST['suexec_user'];
113) 
Bernd Wurst Ermögliche das Auswählen de...

Bernd Wurst authored 11 years ago

114)   if (isset($_POST['server']))
115)     $vhost['server'] = $_POST['server'];
116) 
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

117)   if ($_POST['vhost_type'] == 'regular') {
118)     $vhost['is_dav'] = 0;
119)     $vhost['is_svn'] = 0;
120)     $vhost['is_webapp'] = 0;
121)   }
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

122)   elseif ($_POST['vhost_type'] == 'dav') {
123)     $vhost['is_dav'] = 1;
124)     $vhost['is_svn'] = 0;
125)     $vhost['is_webapp'] = 0;
126)   }
127)   elseif ($_POST['vhost_type'] == 'svn') {
128)     $vhost['is_dav'] = 0;
129)     $vhost['is_svn'] = 1;
130)     $vhost['is_webapp'] = 0;
131)   }
132)   elseif ($_POST['vhost_type'] == 'webapp') {
133)     $vhost['is_dav'] = 0;
134)     $vhost['is_svn'] = 0;
135)     $vhost['is_webapp'] = 1;
bernd Webapps implementiert

bernd authored 16 years ago

136)     $vhost['webapp_id'] = (int) $_POST['webapp'];
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

137)   }
138) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

139)   
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

140)   $ssl = NULL;
bernd SSL auch über webinterface...

bernd authored 16 years ago

141)   switch ($_POST['ssl']) {
142)     case 'http':
143)       $ssl = 'http';
144)       break;
145)     case 'https':
146)       $ssl = 'https';
147)       break;
148)     case 'forward':
149)       $ssl = 'forward';
150)       break;
151)     /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
152)   }
153) 
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

154)   $hsts = NULL;
155)   if (isset($_POST['hsts'])) {
156)     if (is_numeric($_POST['hsts']) && (int) $_POST['hsts'] > -2) {
157)       $hsts = (int) $_POST['hsts'];
158)     } else {
159)       system_failure('Es wurde ein ungültiger HSTS-Wert eingegeben. Dort sind nur Sekunden erlaubt.');
160)     }
161)   }
162)  
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

164) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

166) 
bernd IPv6

bernd authored 14 years ago

167)   if (isset($_POST['ipv6']) && $_POST['ipv6'] == 'yes')
168)   {
169)     $vhost['autoipv6'] = 1;
bernd Zusätzlicher Haken für eige...

bernd authored 13 years ago

170)     if (isset($_POST['ipv6_separate']) && $_POST['ipv6_separate'] = 'yes')
171)     {
172)       $vhost['autoipv6'] = 2;
173)     }
bernd IPv6

bernd authored 14 years ago

174)   } else {
175)     $vhost['autoipv6'] = 0;
176)   }
177)   
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

179)   $logtype = '';
180)   switch ($_POST['logtype']) {
181)     case 'anonymous':
182)       $logtype = 'anonymous';
183)       break;
184)     case 'default':
185)       $logtype = 'default';
186)       break;
187)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
188)   }
189) 
bernd error_log konfigurierbar

bernd authored 16 years ago

190)   $errorlog = 0;
191)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
192)     $errorlog = 1;
193) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

194) 
195)   if (isset($_POST['stats']) && $_POST['stats'] == 1)
196)   {
197)     if ($vhost['stats'] == NULL)
198)       $vhost['stats'] = 'private';
199)   }
200)   else
201)     $vhost['stats'] = NULL;
202) 
203)   if ($logtype == '')
204)     $vhost['stats'] = NULL;
205)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

206)   DEBUG("PHP: {$php} / Logging: {$logtype}");
207) 
208)   $old_options = explode(',', $vhost['options']);
209)   $new_options = array();
210)   foreach ($old_options AS $op)
211)   {
Bernd Wurst * Ermögliche SAN bei CSRs *...

Bernd Wurst authored 8 years ago

212)     if ($op != 'aliaswww') {
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

213)       array_push($new_options, $op);
Bernd Wurst * Ermögliche SAN bei CSRs *...

Bernd Wurst authored 8 years ago

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

bernd authored 16 years ago

215)   }
Bernd Wurst Status der letsencrypt-Opti...

Bernd Wurst authored 8 years ago

216)   if ($aliaswww) {
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

217)     array_push($new_options, 'aliaswww');
Bernd Wurst * Ermögliche SAN bei CSRs *...

Bernd Wurst authored 8 years ago

218)   }
Bernd Wurst Status der letsencrypt-Opti...

Bernd Wurst authored 8 years ago

219)   $letsencrypt = ($cert == 0 ? false : ($cert == -1 || cert_is_letsencrypt($cert)));
220) 
221)   if ($letsencrypt) {
Bernd Wurst * Ermögliche SAN bei CSRs *...

Bernd Wurst authored 8 years ago

222)     array_push($new_options, 'letsencrypt');
Bernd Wurst Letsencrypt vorbereitet und...

Bernd Wurst authored 8 years ago

223)     if ($vhost['cert'] != 0) {
Bernd Wurst Status der letsencrypt-Opti...

Bernd Wurst authored 8 years ago

224)       # Wenn der User manuell von einem gültigen Cert auf "letsencrypt" umgestellt hat, 
Bernd Wurst Letsencrypt vorbereitet und...

Bernd Wurst authored 8 years ago

225)       # dann sollte das alte Cert noch so lange eingetragen bleiben bis das neue da ist.
Bernd Wurst Status der letsencrypt-Opti...

Bernd Wurst authored 8 years ago

226)       $cert = $vhost['cert'];
227)     } elseif ($cert > 0) {
228)       # Das Cert was der user gewählt hat, ist von Lets encrypt
229)       # tu nix, $cert ist schon korrekt
230)     } else {
231)       # Wenn vorher kein Zertifikat aktiv war, dann setze jetzt auch keines. 
232)       # Der letsencrypt-Automatismus macht das dann schon.
233)       $cert = 0;
234)     }
235)   } else {
236)     # Wenn kein Letsencrypt gewünscht ist, entferne die Letsencrypt-Option
237)     $key = array_search('letsencrypt',$new_options);
238)     if ($key !== false) {
239)       unset($new_options[$key]);
Bernd Wurst Letsencrypt vorbereitet und...

Bernd Wurst authored 8 years ago

240)     }
Bernd Wurst * Ermögliche SAN bei CSRs *...

Bernd Wurst authored 8 years ago

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

bernd authored 16 years ago

242) 
243)   DEBUG($old_options);
244)   DEBUG($new_options);
245)   $options = implode(',', $new_options);
246)   DEBUG('New options: '.$options);
247) 
248)   $vhost['hostname'] = $hostname;
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

249)   $vhost['domain_id'] = $domain_id;
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

250)   $vhost['docroot'] = $docroot;
251)   $vhost['php'] = $php;
bernd CGI abschaltbar

bernd authored 14 years ago

252)   $vhost['cgi'] = $cgi;
bernd SSL auch über webinterface...

bernd authored 16 years ago

253)   $vhost['ssl'] = $ssl;
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

254)   $vhost['hsts'] = $hsts;
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

255)   $vhost['cert'] = $cert;
bernd IP-Adressen aktivieren

bernd authored 14 years ago

256)   $vhost['ipv4'] = $ipv4;
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

257)   $vhost['logtype'] = $logtype;
bernd error_log konfigurierbar

bernd authored 16 years ago

258)   $vhost['errorlog'] = $errorlog; 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

259)   $vhost['options'] = $options;
260)     
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

261)   DEBUG($vhost);
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

262)   save_vhost($vhost);
Bernd Wurst Weise Benutzer auf Wartezei...

Bernd Wurst authored 11 years ago

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

264) 
265)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

266)     header('Location: vhosts');
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

267) 
268) }
bernd Aliases editieren

bernd authored 16 years ago

269) elseif ($_GET['action'] == 'addalias')
270) {
271)   check_form_token('vhosts_add_alias');
272)   $id = (int) $_GET['vhost'];
273)   $vhost = get_vhost_details( $id );
274)   DEBUG($vhost);
275) 
276)   $alias = empty_alias();
277)   $alias['vhost'] = $vhost['id'];
278) 
279)   
bernd Erlaube wildcards bei vhosts

bernd authored 13 years ago

280)   $hostname = filter_input_hostname($_POST['hostname'], true);
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

281)   $domainid = (int) $_POST['domain'];
Bernd Wurst Ermögliche dem user Hosts m...

Bernd Wurst authored 9 years ago

282)   if ($domainid >= 0) {
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

283)     $domain = new Domain( (int) $_POST['domain'] );
bernd Mehr config-optionen und co...

bernd authored 14 years ago

284)     $domain->ensure_userdomain();
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

285)     $domainid = $domain->id;
286)   }
Bernd Wurst Ermögliche dem user Hosts m...

Bernd Wurst authored 9 years ago

287)   if ($domainid == -1) {
288)     # use configured user_vhosts_domain
289)     $userdomain = userdomain();
290)     $domain = new Domain( (int) $userdomain['id'] );
291)     $domainid = $domain->id;
292)     $hostname = $hostname.'.'.$_SESSION['userinfo']['username'];
293)     $hostname = trim($hostname, " .-");
294)   }
bernd Aliases editieren

bernd authored 16 years ago

295) 
296)   if (! is_array($_POST['options']))
297)     $_POST['options'] = array();
298)   $aliaswww = in_array('aliaswww', $_POST['options']);
299)   $forward = in_array('forward', $_POST['options']);
300) 
301)   $new_options = array();
302)   if ($aliaswww)
303)     array_push($new_options, 'aliaswww');
304)   if ($forward)
305)     array_push($new_options, 'forward');
306)   DEBUG($new_options);
307)   $options = implode(',', $new_options);
308)   DEBUG('New options: '.$options);
309) 
310)   $alias['hostname'] = $hostname;
bernd domainid -> domain_id, fies...

bernd authored 14 years ago

311)   $alias['domain_id'] = $domainid;
bernd Aliases editieren

bernd authored 16 years ago

312)     
313)   $alias ['options'] = $options;
314)     
315)   save_alias($alias);
316) 
317)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

318)     header('Location: aliases?vhost='.$vhost['id']);
bernd Aliases editieren

bernd authored 16 years ago

319) 
320) }
321) elseif ($_GET['action'] == 'deletealias')
322) {
323)   $title = "Subdomain löschen";
324)   $section = 'vhosts_vhosts';
325)   
326)   $alias = get_alias_details( (int) $_GET['alias'] );
327)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

328)   $alias_string = $alias['fqdn'];
bernd Aliases editieren

bernd authored 16 years ago

329)   
330)   $vhost = get_vhost_details( $alias['vhost'] );
331)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

332)   $vhost_string = $vhost['fqdn'];
bernd Aliases editieren

bernd authored 16 years ago

333)   
334)   $sure = user_is_sure();
335)   if ($sure === NULL)
336)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

337)     are_you_sure("action=deletealias&alias={$_GET['alias']}", "Möchten Sie das Alias »{$alias_string}« für die Subdomain »{$vhost_string}« wirklich löschen?");
bernd Aliases editieren

bernd authored 16 years ago

338)   }
339)   elseif ($sure === true)
340)   {
341)     delete_alias($alias['id']);
342)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

343)       header('Location: aliases?vhost='.$vhost['id']);
bernd Aliases editieren

bernd authored 16 years ago

344)   }
345)   elseif ($sure === false)
346)   {
347)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

348)       header('Location: aliases?vhost='.$vhost['id']);
bernd Aliases editieren

bernd authored 16 years ago

349)   }
350) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

351) elseif ($_GET['action'] == 'delete')
352) {
bernd Aliases editieren

bernd authored 16 years ago

353)   $title = "Subdomain löschen";
354)   $section = 'vhosts_vhosts';
355)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

356)   $vhost = get_vhost_details( (int) $_GET['vhost'] );
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

357)   $vhost_string = $vhost['fqdn'];
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

358)   
359)   $sure = user_is_sure();
360)   if ($sure === NULL)
361)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

362)     are_you_sure("action=delete&vhost={$_GET['vhost']}", "Möchten Sie die Subdomain »{$vhost_string}« wirklich löschen?");
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

363)   }
364)   elseif ($sure === true)
365)   {
366)     delete_vhost($vhost['id']);
367)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

368)       header("Location: vhosts");
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

369)   }
370)   elseif ($sure === false)
371)   {
372)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

373)       header("Location: vhosts");