516f0c6828d542696d6079eba3216639a6d1fe60
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 Docroot auch bei WebDAV anz...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

120)   
bernd SSL auch über webinterface...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

136) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

138) 
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

142)     if (isset($_POST['ipv6_separate']) && $_POST['ipv6_separate'] = 'yes')
143)     {
144)       $vhost['autoipv6'] = 2;
145)     }
bernd IPv6

bernd authored 14 years ago

146)   } else {
147)     $vhost['autoipv6'] = 0;
148)   }
149)   
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

162)   $errorlog = 0;
163)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
164)     $errorlog = 1;
165) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

197)   $vhost['docroot'] = $docroot;
198)   $vhost['php'] = $php;
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

208)   save_vhost($vhost);
209) 
210)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

212) 
213) }
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 13 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

230)     $domainid = $domain->id;
231)   }
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

249)     
250)   $alias ['options'] = $options;
251)     
252)   save_alias($alias);
253) 
254)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

266)   
267)   $vhost = get_vhost_details( $alias['vhost'] );
268)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

270)   
271)   $sure = user_is_sure();
272)   if ($sure === NULL)
273)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

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

bernd authored 15 years ago

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

bernd authored 16 years ago

281)   }
282)   elseif ($sure === false)
283)   {
284)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

286)   }
287) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

288) elseif ($_GET['action'] == 'delete')
289) {
bernd Aliases editieren

bernd authored 16 years ago

290)   $title = "Subdomain löschen";
291)   $section = 'vhosts_vhosts';
292)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

295)   
296)   $sure = user_is_sure();
297)   if ($sure === NULL)
298)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

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

bernd authored 15 years ago

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

bernd authored 16 years ago

306)   }
307)   elseif ($sure === false)
308)   {
309)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

310)       header("Location: vhosts");