c8b7c64ca5de1a47823c20b6533015ab24f1fa3d
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'];
Bernd Wurst Ermögliche dem user Hosts m...

Bernd Wurst authored 9 years ago

43)   if ($domain_id >= 0) {
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 Wurst Ermögliche dem user Hosts m...

Bernd Wurst authored 9 years ago

48)   if ($domain_id == -1) {
49)     # use configured user_vhosts_domain
50)     $userdomain = userdomain();
51)     $domain = new Domain( (int) $userdomain['id'] );
52)     $domain_id = $domain->id;
53)     $hostname = $hostname.'.'.$_SESSION['userinfo']['username'];
54)     $hostname = trim($hostname, " .-");
55)   }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

58)     $_POST['options'] = array();
59)   $aliaswww = in_array('aliaswww', $_POST['options']);
60) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

66)     $docroot = '';
67)     if (isset($_POST['docroot']))
68)     {
69)       if (! check_path( $_POST['docroot'] ))
70)         system_failure("Eingegebener Pfad enthält ungültige Angaben");
71)       $docroot = $vhost['homedir'].'/websites/'.$_POST['docroot'];
72)     }
73)     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

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

bernd authored 16 years ago

75)     }
76)   
77)     DEBUG("Document-Root: ".$docroot);
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 12 years ago

83)       case 'php54':
84)         $php = 'php54';
85)         break;
Hanno Böck übrige Änderungen für php55

Hanno Böck authored 10 years ago

86)       case 'php55':
87)         $php = 'php55';
88)         break;
Bernd Wurst PHP 5.6 experimentell

Bernd Wurst authored 9 years ago

89)       case 'php56':
90)         $php = 'php56';
91)         break;
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

92)       /* Wenn etwas anderes kommt, ist das "kein PHP". So einfach ist das. */
93)     }
94)   }
bernd "CGI-Aktivieren" ist jetzt...

bernd authored 13 years ago

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

bernd authored 14 years ago

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

bernd authored 13 years ago

98)     $cgi = 0;
bernd CGI abschaltbar

bernd authored 14 years ago

99)   }
100) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

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

Bernd Wurst authored 11 years ago

104)   if (isset($_POST['server']))
105)     $vhost['server'] = $_POST['server'];
106) 
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

107)   if ($_POST['vhost_type'] == 'regular') {
108)     $vhost['is_dav'] = 0;
109)     $vhost['is_svn'] = 0;
110)     $vhost['is_webapp'] = 0;
111)   }
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

112)   elseif ($_POST['vhost_type'] == 'dav') {
113)     $vhost['is_dav'] = 1;
114)     $vhost['is_svn'] = 0;
115)     $vhost['is_webapp'] = 0;
116)   }
117)   elseif ($_POST['vhost_type'] == 'svn') {
118)     $vhost['is_dav'] = 0;
119)     $vhost['is_svn'] = 1;
120)     $vhost['is_webapp'] = 0;
121)   }
122)   elseif ($_POST['vhost_type'] == 'webapp') {
123)     $vhost['is_dav'] = 0;
124)     $vhost['is_svn'] = 0;
125)     $vhost['is_webapp'] = 1;
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

127)   }
128) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

131)   switch ($_POST['ssl']) {
132)     case 'http':
133)       $ssl = 'http';
134)       break;
135)     case 'https':
136)       $ssl = 'https';
137)       break;
138)     case 'forward':
139)       $ssl = 'forward';
140)       break;
141)     /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
142)   }
143) 
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

144)   $hsts = NULL;
145)   if (isset($_POST['hsts'])) {
146)     if (is_numeric($_POST['hsts']) && (int) $_POST['hsts'] > -2) {
147)       $hsts = (int) $_POST['hsts'];
148)     } else {
149)       system_failure('Es wurde ein ungültiger HSTS-Wert eingegeben. Dort sind nur Sekunden erlaubt.');
150)     }
151)   }
152)  
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

154) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

156) 
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

160)     if (isset($_POST['ipv6_separate']) && $_POST['ipv6_separate'] = 'yes')
161)     {
162)       $vhost['autoipv6'] = 2;
163)     }
bernd IPv6

bernd authored 14 years ago

164)   } else {
165)     $vhost['autoipv6'] = 0;
166)   }
167)   
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

169)   $logtype = '';
170)   switch ($_POST['logtype']) {
171)     case 'anonymous':
172)       $logtype = 'anonymous';
173)       break;
174)     case 'default':
175)       $logtype = 'default';
176)       break;
177)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
178)   }
179) 
bernd error_log konfigurierbar

bernd authored 16 years ago

180)   $errorlog = 0;
181)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
182)     $errorlog = 1;
183) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

184) 
185)   if (isset($_POST['stats']) && $_POST['stats'] == 1)
186)   {
187)     if ($vhost['stats'] == NULL)
188)       $vhost['stats'] = 'private';
189)   }
190)   else
191)     $vhost['stats'] = NULL;
192) 
193)   if ($logtype == '')
194)     $vhost['stats'] = NULL;
195)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

196)   DEBUG("PHP: {$php} / Logging: {$logtype}");
197) 
198)   $old_options = explode(',', $vhost['options']);
199)   $new_options = array();
200)   foreach ($old_options AS $op)
201)   {
202)     if ($op != 'aliaswww')
203)       array_push($new_options, $op);
204)   }
205)   if ($aliaswww)
206)     array_push($new_options, 'aliaswww');
207) 
208)   DEBUG($old_options);
209)   DEBUG($new_options);
210)   $options = implode(',', $new_options);
211)   DEBUG('New options: '.$options);
212) 
213)   $vhost['hostname'] = $hostname;
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

215)   $vhost['docroot'] = $docroot;
216)   $vhost['php'] = $php;
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 11 years ago

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

229) 
230)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

232) 
233) }
bernd Aliases editieren

bernd authored 16 years ago

234) elseif ($_GET['action'] == 'addalias')
235) {
236)   check_form_token('vhosts_add_alias');
237)   $id = (int) $_GET['vhost'];
238)   $vhost = get_vhost_details( $id );
239)   DEBUG($vhost);
240) 
241)   $alias = empty_alias();
242)   $alias['vhost'] = $vhost['id'];
243) 
244)   
bernd Erlaube wildcards bei vhosts

bernd authored 13 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 9 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 9 years ago

252)   if ($domainid == -1) {
253)     # use configured user_vhosts_domain
254)     $userdomain = userdomain();
255)     $domain = new Domain( (int) $userdomain['id'] );
256)     $domainid = $domain->id;
257)     $hostname = $hostname.'.'.$_SESSION['userinfo']['username'];
258)     $hostname = trim($hostname, " .-");
259)   }
bernd Aliases editieren

bernd authored 16 years ago

260) 
261)   if (! is_array($_POST['options']))
262)     $_POST['options'] = array();
263)   $aliaswww = in_array('aliaswww', $_POST['options']);
264)   $forward = in_array('forward', $_POST['options']);
265) 
266)   $new_options = array();
267)   if ($aliaswww)
268)     array_push($new_options, 'aliaswww');
269)   if ($forward)
270)     array_push($new_options, 'forward');
271)   DEBUG($new_options);
272)   $options = implode(',', $new_options);
273)   DEBUG('New options: '.$options);
274) 
275)   $alias['hostname'] = $hostname;
bernd domainid -> domain_id, fies...

bernd authored 14 years ago

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

bernd authored 16 years ago

277)     
278)   $alias ['options'] = $options;
279)     
280)   save_alias($alias);
281) 
282)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

284) 
285) }
286) elseif ($_GET['action'] == 'deletealias')
287) {
288)   $title = "Subdomain löschen";
289)   $section = 'vhosts_vhosts';
290)   
291)   $alias = get_alias_details( (int) $_GET['alias'] );
292)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

294)   
295)   $vhost = get_vhost_details( $alias['vhost'] );
296)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

298)   
299)   $sure = user_is_sure();
300)   if ($sure === NULL)
301)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

303)   }
304)   elseif ($sure === true)
305)   {
306)     delete_alias($alias['id']);
307)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

309)   }
310)   elseif ($sure === false)
311)   {
312)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

314)   }
315) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

316) elseif ($_GET['action'] == 'delete')
317) {
bernd Aliases editieren

bernd authored 16 years ago

318)   $title = "Subdomain löschen";
319)   $section = 'vhosts_vhosts';
320)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

323)   
324)   $sure = user_is_sure();
325)   if ($sure === NULL)
326)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

328)   }
329)   elseif ($sure === true)
330)   {
331)     delete_vhost($vhost['id']);
332)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

334)   }
335)   elseif ($sure === false)
336)   {
337)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

338)       header("Location: vhosts");