918446fe175c3c16b82509e0ff181b47ba43136c
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

1) <?php
2) 
3) require_once('session/start.php');
4) 
5) require_once('vhosts.php');
6) 
7) require_once('inc/security.php');
8) require_once('class/domain.php');
9) 
10) require_role(ROLE_SYSTEMUSER);
11) 
12) require_once("inc/debug.php");
13) global $debugmode;
14) 
15) 
16) if ($_GET['action'] == 'edit')
17) {
18)   check_form_token('vhosts_edit_vhost');
19)   $id = (int) $_GET['vhost'];
20)   $vhost = empty_vhost();
21)   if ($id != 0)
22)     $vhost = get_vhost_details( $id );
23)   DEBUG($vhost);
24) 
25)   $hostname = filter_input_hostname($_POST['hostname']);
26) 
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 14 years ago

30)     $domain->ensure_userdomain();
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

31)     $domainid = $domain->id;
32)   }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

33) 
34)   if (! is_array($_POST['options']))
35)     $_POST['options'] = array();
36)   $aliaswww = in_array('aliaswww', $_POST['options']);
37) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

38)   $docroot = '';
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

39)   $php = '';
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

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

bernd authored 16 years ago

41)   {
42)     $defaultdocroot = $vhost['homedir'].'/websites/'.((strlen($hostname) > 0) ? $hostname.'.' : '').($domain->fqdn).'/htdocs';
43)   
44)     if (! check_path( $_POST['docroot'] ))
45)       system_failure("Eingegebener Pfad enthält ungültige Angaben");
bernd mod_php deprecated, zwang z...

bernd authored 15 years ago

46)     $docroot = $vhost['homedir'].'/websites/'.$_POST['docroot'];
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

47)   
48)     if (($_POST['use_default_docroot'] == '1') || ($docroot == $defaultdocroot)) {
49)       $docroot = '';
50)     }
51)   
52)     DEBUG("Document-Root: ".$docroot);
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

53)   }
54)   $php = '';
55)   if ($_POST['vhost_type'] == 'regular')
56)   {
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

57)     switch ($_POST['php']) {
58)       case 'mod_php':
59)         $php = 'mod_php';
60)         break;
61)       case 'fastcgi':
62)         $php = 'fastcgi';
63)         break;
64)       /* Wenn etwas anderes kommt, ist das "kein PHP". So einfach ist das. */
65)     }
66)   }
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

67)   if ($_POST['vhost_type'] == 'regular') {
68)     $vhost['is_dav'] = 0;
69)     $vhost['is_svn'] = 0;
70)     $vhost['is_webapp'] = 0;
71)   }
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

72)   elseif ($_POST['vhost_type'] == 'dav') {
73)     $vhost['is_dav'] = 1;
74)     $vhost['is_svn'] = 0;
75)     $vhost['is_webapp'] = 0;
76)   }
77)   elseif ($_POST['vhost_type'] == 'svn') {
78)     $vhost['is_dav'] = 0;
79)     $vhost['is_svn'] = 1;
80)     $vhost['is_webapp'] = 0;
81)   }
82)   elseif ($_POST['vhost_type'] == 'webapp') {
83)     $vhost['is_dav'] = 0;
84)     $vhost['is_svn'] = 0;
85)     $vhost['is_webapp'] = 1;
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

87)   }
88) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

89)   
bernd SSL auch über webinterface...

bernd authored 16 years ago

90)   $ssl = '';
91)   switch ($_POST['ssl']) {
92)     case 'http':
93)       $ssl = 'http';
94)       break;
95)     case 'https':
96)       $ssl = 'https';
97)       break;
98)     case 'forward':
99)       $ssl = 'forward';
100)       break;
101)     /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
102)   }
103) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

104)   $cert = (int) $_POST['cert'];
105) 
bernd IP-Adressen aktivieren

bernd authored 14 years ago

106)   $ipv4 = $_POST['ipv4'];
107) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

108)   $logtype = '';
109)   switch ($_POST['logtype']) {
110)     case 'anonymous':
111)       $logtype = 'anonymous';
112)       break;
113)     case 'default':
114)       $logtype = 'default';
115)       break;
116)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
117)   }
118) 
bernd error_log konfigurierbar

bernd authored 16 years ago

119)   $errorlog = 0;
120)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
121)     $errorlog = 1;
122) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

123)   DEBUG("PHP: {$php} / Logging: {$logtype}");
124) 
125)   $old_options = explode(',', $vhost['options']);
126)   $new_options = array();
127)   foreach ($old_options AS $op)
128)   {
129)     if ($op != 'aliaswww')
130)       array_push($new_options, $op);
131)   }
132)   if ($aliaswww)
133)     array_push($new_options, 'aliaswww');
134) 
135)   DEBUG($old_options);
136)   DEBUG($new_options);
137)   $options = implode(',', $new_options);
138)   DEBUG('New options: '.$options);
139) 
140)   $vhost['hostname'] = $hostname;
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

142)   $vhost['docroot'] = $docroot;
143)   $vhost['php'] = $php;
bernd SSL auch über webinterface...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

152)   save_vhost($vhost);
153) 
154)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

156) 
157) }
bernd Aliases editieren

bernd authored 16 years ago

158) elseif ($_GET['action'] == 'addalias')
159) {
160)   check_form_token('vhosts_add_alias');
161)   $id = (int) $_GET['vhost'];
162)   $vhost = get_vhost_details( $id );
163)   DEBUG($vhost);
164) 
165)   $alias = empty_alias();
166)   $alias['vhost'] = $vhost['id'];
167) 
168)   
169)   $hostname = filter_input_hostname($_POST['hostname']);
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

174)     $domainid = $domain->id;
175)   }
bernd Aliases editieren

bernd authored 16 years ago

176) 
177)   if (! is_array($_POST['options']))
178)     $_POST['options'] = array();
179)   $aliaswww = in_array('aliaswww', $_POST['options']);
180)   $forward = in_array('forward', $_POST['options']);
181) 
182)   $new_options = array();
183)   if ($aliaswww)
184)     array_push($new_options, 'aliaswww');
185)   if ($forward)
186)     array_push($new_options, 'forward');
187)   DEBUG($new_options);
188)   $options = implode(',', $new_options);
189)   DEBUG('New options: '.$options);
190) 
191)   $alias['hostname'] = $hostname;
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

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

bernd authored 16 years ago

193)     
194)   $alias ['options'] = $options;
195)     
196)   save_alias($alias);
197) 
198)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

200) 
201) }
202) elseif ($_GET['action'] == 'deletealias')
203) {
204)   $title = "Subdomain löschen";
205)   $section = 'vhosts_vhosts';
206)   
207)   $alias = get_alias_details( (int) $_GET['alias'] );
208)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

210)   
211)   $vhost = get_vhost_details( $alias['vhost'] );
212)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

214)   
215)   $sure = user_is_sure();
216)   if ($sure === NULL)
217)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

219)   }
220)   elseif ($sure === true)
221)   {
222)     delete_alias($alias['id']);
223)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

225)   }
226)   elseif ($sure === false)
227)   {
228)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

230)   }
231) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

232) elseif ($_GET['action'] == 'delete')
233) {
bernd Aliases editieren

bernd authored 16 years ago

234)   $title = "Subdomain löschen";
235)   $section = 'vhosts_vhosts';
236)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

239)   
240)   $sure = user_is_sure();
241)   if ($sure === NULL)
242)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

244)   }
245)   elseif ($sure === true)
246)   {
247)     delete_vhost($vhost['id']);
248)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

250)   }
251)   elseif ($sure === false)
252)   {
253)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

254)       header("Location: vhosts");