c208bd906b3991555db11b9229846c4601ca408c
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) 
5) Written 2008-2012 by schokokeks.org Hosting, namely
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) 
21) require_once('inc/security.php');
22) require_once('class/domain.php');
23) 
24) require_role(ROLE_SYSTEMUSER);
25) 
26) require_once("inc/debug.php");
27) global $debugmode;
28) 
29) 
30) if ($_GET['action'] == 'edit')
31) {
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)   DEBUG($vhost);
38) 
bernd Erlaube wildcards bei vhosts

bernd authored 13 years ago

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

bernd authored 16 years ago

40) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 15 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

57)     $docroot = '';
58)     if (isset($_POST['docroot']))
59)     {
60)       if (! check_path( $_POST['docroot'] ))
61)         system_failure("Eingegebener Pfad enthält ungültige Angaben");
62)       $docroot = $vhost['homedir'].'/websites/'.$_POST['docroot'];
63)     }
64)     if ((isset($_POST['use_default_docroot']) && $_POST['use_default_docroot'] == '1') || ($docroot == $defaultdocroot)) {
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

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

bernd authored 16 years ago

69)   }
70)   $php = '';
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

73)     switch ($_POST['php']) {
74)       case 'mod_php':
75)         $php = 'mod_php';
76)         break;
77)       case 'fastcgi':
78)         $php = 'fastcgi';
79)         break;
bernd Vorbereitung für PHP 5.3

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 13 years ago

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

bernd authored 14 years ago

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

bernd authored 13 years ago

89)     $cgi = 0;
bernd CGI abschaltbar

bernd authored 14 years ago

90)   }
91) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

92)   if (isset($_POST['suexec_user']))
93)     $vhost['suexec_user'] = $_POST['suexec_user'];
94) 
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

95)   if ($_POST['vhost_type'] == 'regular') {
96)     $vhost['is_dav'] = 0;
97)     $vhost['is_svn'] = 0;
98)     $vhost['is_webapp'] = 0;
99)   }
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

115)   }
116) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

117)   
bernd SSL auch über webinterface...

bernd authored 16 years ago

118)   $ssl = '';
119)   switch ($_POST['ssl']) {
120)     case 'http':
121)       $ssl = 'http';
122)       break;
123)     case 'https':
124)       $ssl = 'https';
125)       break;
126)     case 'forward':
127)       $ssl = 'forward';
128)       break;
129)     /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
130)   }
131) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

133) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

135) 
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

139)     if (isset($_POST['ipv6_separate']) && $_POST['ipv6_separate'] = 'yes')
140)     {
141)       $vhost['autoipv6'] = 2;
142)     }
bernd IPv6

bernd authored 14 years ago

143)   } else {
144)     $vhost['autoipv6'] = 0;
145)   }
146)   
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

148)   $logtype = '';
149)   switch ($_POST['logtype']) {
150)     case 'anonymous':
151)       $logtype = 'anonymous';
152)       break;
153)     case 'default':
154)       $logtype = 'default';
155)       break;
156)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
157)   }
158) 
bernd error_log konfigurierbar

bernd authored 16 years ago

159)   $errorlog = 0;
160)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
161)     $errorlog = 1;
162) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

163) 
164)   if (isset($_POST['stats']) && $_POST['stats'] == 1)
165)   {
166)     if ($vhost['stats'] == NULL)
167)       $vhost['stats'] = 'private';
168)   }
169)   else
170)     $vhost['stats'] = NULL;
171) 
172)   if ($logtype == '')
173)     $vhost['stats'] = NULL;
174)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

175)   DEBUG("PHP: {$php} / Logging: {$logtype}");
176) 
177)   $old_options = explode(',', $vhost['options']);
178)   $new_options = array();
179)   foreach ($old_options AS $op)
180)   {
181)     if ($op != 'aliaswww')
182)       array_push($new_options, $op);
183)   }
184)   if ($aliaswww)
185)     array_push($new_options, 'aliaswww');
186) 
187)   DEBUG($old_options);
188)   DEBUG($new_options);
189)   $options = implode(',', $new_options);
190)   DEBUG('New options: '.$options);
191) 
192)   $vhost['hostname'] = $hostname;
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

194)   $vhost['docroot'] = $docroot;
195)   $vhost['php'] = $php;
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

197)   $vhost['ssl'] = $ssl;
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

205)   save_vhost($vhost);
206) 
207)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

209) 
210) }
bernd Aliases editieren

bernd authored 16 years ago

211) elseif ($_GET['action'] == 'addalias')
212) {
213)   check_form_token('vhosts_add_alias');
214)   $id = (int) $_GET['vhost'];
215)   $vhost = get_vhost_details( $id );
216)   DEBUG($vhost);
217) 
218)   $alias = empty_alias();
219)   $alias['vhost'] = $vhost['id'];
220) 
221)   
bernd Erlaube wildcards bei vhosts

bernd authored 13 years ago

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

bernd authored 16 years ago

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

bernd authored 15 years ago

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

bernd authored 16 years ago

227)     $domainid = $domain->id;
228)   }
bernd Aliases editieren

bernd authored 16 years ago

229) 
230)   if (! is_array($_POST['options']))
231)     $_POST['options'] = array();
232)   $aliaswww = in_array('aliaswww', $_POST['options']);
233)   $forward = in_array('forward', $_POST['options']);
234) 
235)   $new_options = array();
236)   if ($aliaswww)
237)     array_push($new_options, 'aliaswww');
238)   if ($forward)
239)     array_push($new_options, 'forward');
240)   DEBUG($new_options);
241)   $options = implode(',', $new_options);
242)   DEBUG('New options: '.$options);
243) 
244)   $alias['hostname'] = $hostname;
bernd domainid -> domain_id, fies...

bernd authored 14 years ago

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

bernd authored 16 years ago

246)     
247)   $alias ['options'] = $options;
248)     
249)   save_alias($alias);
250) 
251)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

253) 
254) }
255) elseif ($_GET['action'] == 'deletealias')
256) {
257)   $title = "Subdomain löschen";
258)   $section = 'vhosts_vhosts';
259)   
260)   $alias = get_alias_details( (int) $_GET['alias'] );
261)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

263)   
264)   $vhost = get_vhost_details( $alias['vhost'] );
265)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

267)   
268)   $sure = user_is_sure();
269)   if ($sure === NULL)
270)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

272)   }
273)   elseif ($sure === true)
274)   {
275)     delete_alias($alias['id']);
276)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

278)   }
279)   elseif ($sure === false)
280)   {
281)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

283)   }
284) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

285) elseif ($_GET['action'] == 'delete')
286) {
bernd Aliases editieren

bernd authored 16 years ago

287)   $title = "Subdomain löschen";
288)   $section = 'vhosts_vhosts';
289)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

292)   
293)   $sure = user_is_sure();
294)   if ($sure === NULL)
295)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

297)   }
298)   elseif ($sure === true)
299)   {
300)     delete_vhost($vhost['id']);
301)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

303)   }
304)   elseif ($sure === false)
305)   {
306)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

307)       header("Location: vhosts");