5231fb2f16a0c488f95833b13a61dd7a52c58c02
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 14 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 Wurst prepare for experimental PH...

Bernd Wurst authored 12 years ago

83)       case 'php54':
84)         $php = 'php54';
85)         break;
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

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

bernd authored 13 years ago

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

bernd authored 14 years ago

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

bernd authored 13 years ago

92)     $cgi = 0;
bernd CGI abschaltbar

bernd authored 14 years ago

93)   }
94) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

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

Bernd Wurst authored 11 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

121)   }
122) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

123)   
bernd SSL auch über webinterface...

bernd authored 16 years ago

124)   $ssl = '';
125)   switch ($_POST['ssl']) {
126)     case 'http':
127)       $ssl = 'http';
128)       break;
129)     case 'https':
130)       $ssl = 'https';
131)       break;
132)     case 'forward':
133)       $ssl = 'forward';
134)       break;
135)     /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
136)   }
137) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

139) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

141) 
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

145)     if (isset($_POST['ipv6_separate']) && $_POST['ipv6_separate'] = 'yes')
146)     {
147)       $vhost['autoipv6'] = 2;
148)     }
bernd IPv6

bernd authored 14 years ago

149)   } else {
150)     $vhost['autoipv6'] = 0;
151)   }
152)   
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

154)   $logtype = '';
155)   switch ($_POST['logtype']) {
156)     case 'anonymous':
157)       $logtype = 'anonymous';
158)       break;
159)     case 'default':
160)       $logtype = 'default';
161)       break;
162)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
163)   }
164) 
bernd error_log konfigurierbar

bernd authored 16 years ago

165)   $errorlog = 0;
166)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
167)     $errorlog = 1;
168) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

169) 
170)   if (isset($_POST['stats']) && $_POST['stats'] == 1)
171)   {
172)     if ($vhost['stats'] == NULL)
173)       $vhost['stats'] = 'private';
174)   }
175)   else
176)     $vhost['stats'] = NULL;
177) 
178)   if ($logtype == '')
179)     $vhost['stats'] = NULL;
180)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

200)   $vhost['docroot'] = $docroot;
201)   $vhost['php'] = $php;
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

211)   save_vhost($vhost);
212) 
213)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

215) 
216) }
bernd Aliases editieren

bernd authored 16 years ago

217) elseif ($_GET['action'] == 'addalias')
218) {
219)   check_form_token('vhosts_add_alias');
220)   $id = (int) $_GET['vhost'];
221)   $vhost = get_vhost_details( $id );
222)   DEBUG($vhost);
223) 
224)   $alias = empty_alias();
225)   $alias['vhost'] = $vhost['id'];
226) 
227)   
bernd Erlaube wildcards bei vhosts

bernd authored 13 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

233)     $domainid = $domain->id;
234)   }
bernd Aliases editieren

bernd authored 16 years ago

235) 
236)   if (! is_array($_POST['options']))
237)     $_POST['options'] = array();
238)   $aliaswww = in_array('aliaswww', $_POST['options']);
239)   $forward = in_array('forward', $_POST['options']);
240) 
241)   $new_options = array();
242)   if ($aliaswww)
243)     array_push($new_options, 'aliaswww');
244)   if ($forward)
245)     array_push($new_options, 'forward');
246)   DEBUG($new_options);
247)   $options = implode(',', $new_options);
248)   DEBUG('New options: '.$options);
249) 
250)   $alias['hostname'] = $hostname;
bernd domainid -> domain_id, fies...

bernd authored 14 years ago

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

bernd authored 16 years ago

252)     
253)   $alias ['options'] = $options;
254)     
255)   save_alias($alias);
256) 
257)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

259) 
260) }
261) elseif ($_GET['action'] == 'deletealias')
262) {
263)   $title = "Subdomain löschen";
264)   $section = 'vhosts_vhosts';
265)   
266)   $alias = get_alias_details( (int) $_GET['alias'] );
267)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

269)   
270)   $vhost = get_vhost_details( $alias['vhost'] );
271)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

273)   
274)   $sure = user_is_sure();
275)   if ($sure === NULL)
276)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

278)   }
279)   elseif ($sure === true)
280)   {
281)     delete_alias($alias['id']);
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)   elseif ($sure === false)
286)   {
287)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

289)   }
290) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

291) elseif ($_GET['action'] == 'delete')
292) {
bernd Aliases editieren

bernd authored 16 years ago

293)   $title = "Subdomain löschen";
294)   $section = 'vhosts_vhosts';
295)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

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=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

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

bernd authored 15 years ago

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

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: vhosts");