193e38bdfbdefc7b71e1ba0b7523dc668d456f63
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 Webalizer/Statistik-Funktio...

bernd authored 14 years ago

42)   $domain_id = (int) $_POST['domain'];
43)   if ($domain_id != -1) {
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

46)     $domain_id = $domain->id;
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

50)     $_POST['options'] = array();
51)   $aliaswww = in_array('aliaswww', $_POST['options']);
52) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

55)   {
56)     $defaultdocroot = $vhost['homedir'].'/websites/'.((strlen($hostname) > 0) ? $hostname.'.' : '').($domain->fqdn).'/htdocs';
57)   
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

58)     $docroot = '';
59)     if (isset($_POST['docroot']))
60)     {
61)       if (! check_path( $_POST['docroot'] ))
62)         system_failure("Eingegebener Pfad enthält ungültige Angaben");
63)       $docroot = $vhost['homedir'].'/websites/'.$_POST['docroot'];
64)     }
65)     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

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

bernd authored 16 years ago

67)     }
68)   
69)     DEBUG("Document-Root: ".$docroot);
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 12 years ago

75)       case 'php54':
76)         $php = 'php54';
77)         break;
Hanno Böck übrige Änderungen für php55

Hanno Böck authored 10 years ago

78)       case 'php55':
79)         $php = 'php55';
80)         break;
Bernd Wurst PHP 5.6 experimentell

Bernd Wurst authored 9 years ago

81)       case 'php56':
82)         $php = 'php56';
83)         break;
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

84)       /* Wenn etwas anderes kommt, ist das "kein PHP". So einfach ist das. */
85)     }
86)   }
bernd "CGI-Aktivieren" ist jetzt...

bernd authored 13 years ago

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

bernd authored 14 years ago

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

bernd authored 13 years ago

90)     $cgi = 0;
bernd CGI abschaltbar

bernd authored 14 years ago

91)   }
92) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

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

Bernd Wurst authored 11 years ago

96)   if (isset($_POST['server']))
97)     $vhost['server'] = $_POST['server'];
98) 
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

99)   if ($_POST['vhost_type'] == 'regular') {
100)     $vhost['is_dav'] = 0;
101)     $vhost['is_svn'] = 0;
102)     $vhost['is_webapp'] = 0;
103)   }
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

104)   elseif ($_POST['vhost_type'] == 'dav') {
105)     $vhost['is_dav'] = 1;
106)     $vhost['is_svn'] = 0;
107)     $vhost['is_webapp'] = 0;
108)   }
109)   elseif ($_POST['vhost_type'] == 'svn') {
110)     $vhost['is_dav'] = 0;
111)     $vhost['is_svn'] = 1;
112)     $vhost['is_webapp'] = 0;
113)   }
114)   elseif ($_POST['vhost_type'] == 'webapp') {
115)     $vhost['is_dav'] = 0;
116)     $vhost['is_svn'] = 0;
117)     $vhost['is_webapp'] = 1;
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

119)   }
120) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

123)   switch ($_POST['ssl']) {
124)     case 'http':
125)       $ssl = 'http';
126)       break;
127)     case 'https':
128)       $ssl = 'https';
129)       break;
130)     case 'forward':
131)       $ssl = 'forward';
132)       break;
133)     /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
134)   }
135) 
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

136)   $hsts = NULL;
137)   if (isset($_POST['hsts'])) {
138)     if (is_numeric($_POST['hsts']) && (int) $_POST['hsts'] > -2) {
139)       $hsts = (int) $_POST['hsts'];
140)     } else {
141)       system_failure('Es wurde ein ungültiger HSTS-Wert eingegeben. Dort sind nur Sekunden erlaubt.');
142)     }
143)   }
144)  
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

146) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

148) 
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

152)     if (isset($_POST['ipv6_separate']) && $_POST['ipv6_separate'] = 'yes')
153)     {
154)       $vhost['autoipv6'] = 2;
155)     }
bernd IPv6

bernd authored 14 years ago

156)   } else {
157)     $vhost['autoipv6'] = 0;
158)   }
159)   
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

161)   $logtype = '';
162)   switch ($_POST['logtype']) {
163)     case 'anonymous':
164)       $logtype = 'anonymous';
165)       break;
166)     case 'default':
167)       $logtype = 'default';
168)       break;
169)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
170)   }
171) 
bernd error_log konfigurierbar

bernd authored 16 years ago

172)   $errorlog = 0;
173)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
174)     $errorlog = 1;
175) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

176) 
177)   if (isset($_POST['stats']) && $_POST['stats'] == 1)
178)   {
179)     if ($vhost['stats'] == NULL)
180)       $vhost['stats'] = 'private';
181)   }
182)   else
183)     $vhost['stats'] = NULL;
184) 
185)   if ($logtype == '')
186)     $vhost['stats'] = NULL;
187)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

188)   DEBUG("PHP: {$php} / Logging: {$logtype}");
189) 
190)   $old_options = explode(',', $vhost['options']);
191)   $new_options = array();
192)   foreach ($old_options AS $op)
193)   {
194)     if ($op != 'aliaswww')
195)       array_push($new_options, $op);
196)   }
197)   if ($aliaswww)
198)     array_push($new_options, 'aliaswww');
199) 
200)   DEBUG($old_options);
201)   DEBUG($new_options);
202)   $options = implode(',', $new_options);
203)   DEBUG('New options: '.$options);
204) 
205)   $vhost['hostname'] = $hostname;
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

207)   $vhost['docroot'] = $docroot;
208)   $vhost['php'] = $php;
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 11 years ago

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

221) 
222)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

224) 
225) }
bernd Aliases editieren

bernd authored 16 years ago

226) elseif ($_GET['action'] == 'addalias')
227) {
228)   check_form_token('vhosts_add_alias');
229)   $id = (int) $_GET['vhost'];
230)   $vhost = get_vhost_details( $id );
231)   DEBUG($vhost);
232) 
233)   $alias = empty_alias();
234)   $alias['vhost'] = $vhost['id'];
235) 
236)   
bernd Erlaube wildcards bei vhosts

bernd authored 13 years ago

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

bernd authored 16 years ago

238)   $domainid = (int) $_POST['domain'];
239)   if ($domainid != -1) {
240)     $domain = new Domain( (int) $_POST['domain'] );
bernd Mehr config-optionen und co...

bernd authored 14 years ago

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

bernd authored 16 years ago

242)     $domainid = $domain->id;
243)   }
bernd Aliases editieren

bernd authored 16 years ago

244) 
245)   if (! is_array($_POST['options']))
246)     $_POST['options'] = array();
247)   $aliaswww = in_array('aliaswww', $_POST['options']);
248)   $forward = in_array('forward', $_POST['options']);
249) 
250)   $new_options = array();
251)   if ($aliaswww)
252)     array_push($new_options, 'aliaswww');
253)   if ($forward)
254)     array_push($new_options, 'forward');
255)   DEBUG($new_options);
256)   $options = implode(',', $new_options);
257)   DEBUG('New options: '.$options);
258) 
259)   $alias['hostname'] = $hostname;
bernd domainid -> domain_id, fies...

bernd authored 14 years ago

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

bernd authored 16 years ago

261)     
262)   $alias ['options'] = $options;
263)     
264)   save_alias($alias);
265) 
266)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

268) 
269) }
270) elseif ($_GET['action'] == 'deletealias')
271) {
272)   $title = "Subdomain löschen";
273)   $section = 'vhosts_vhosts';
274)   
275)   $alias = get_alias_details( (int) $_GET['alias'] );
276)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

278)   
279)   $vhost = get_vhost_details( $alias['vhost'] );
280)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

282)   
283)   $sure = user_is_sure();
284)   if ($sure === NULL)
285)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

287)   }
288)   elseif ($sure === true)
289)   {
290)     delete_alias($alias['id']);
291)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

293)   }
294)   elseif ($sure === false)
295)   {
296)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

298)   }
299) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

300) elseif ($_GET['action'] == 'delete')
301) {
bernd Aliases editieren

bernd authored 16 years ago

302)   $title = "Subdomain löschen";
303)   $section = 'vhosts_vhosts';
304)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

307)   
308)   $sure = user_is_sure();
309)   if ($sure === NULL)
310)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

312)   }
313)   elseif ($sure === true)
314)   {
315)     delete_vhost($vhost['id']);
316)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

318)   }
319)   elseif ($sure === false)
320)   {
321)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

322)       header("Location: vhosts");