1ab9db55d272aaa37a76d7a5c179e55c2ca52267
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 VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

149)   save_vhost($vhost);
150) 
151)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

153) 
154) }
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

171)     $domainid = $domain->id;
172)   }
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

190)     
191)   $alias ['options'] = $options;
192)     
193)   save_alias($alias);
194) 
195)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

207)   
208)   $vhost = get_vhost_details( $alias['vhost'] );
209)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

211)   
212)   $sure = user_is_sure();
213)   if ($sure === NULL)
214)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

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

bernd authored 15 years ago

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

bernd authored 16 years ago

222)   }
223)   elseif ($sure === false)
224)   {
225)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

227)   }
228) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

229) elseif ($_GET['action'] == 'delete')
230) {
bernd Aliases editieren

bernd authored 16 years ago

231)   $title = "Subdomain löschen";
232)   $section = 'vhosts_vhosts';
233)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

236)   
237)   $sure = user_is_sure();
238)   if ($sure === NULL)
239)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

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

bernd authored 15 years ago

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

bernd authored 16 years ago

247)   }
248)   elseif ($sure === false)
249)   {
250)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

251)       header("Location: vhosts");