da0e59cc4f30cec244a9f9ee757cf77d0a80f422
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) 
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

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

bernd authored 16 years ago

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)   
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

44)     $docroot = '';
45)     if (isset($_POST['docroot']))
46)     {
47)       if (! check_path( $_POST['docroot'] ))
48)         system_failure("Eingegebener Pfad enthält ungültige Angaben");
49)       $docroot = $vhost['homedir'].'/websites/'.$_POST['docroot'];
50)     }
51)     if ((isset($_POST['use_default_docroot']) && $_POST['use_default_docroot'] == '1') || ($docroot == $defaultdocroot)) {
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

52)       $docroot = '';
53)     }
54)   
55)     DEBUG("Document-Root: ".$docroot);
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

90)   }
91) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

92)   
bernd SSL auch über webinterface...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

155)   save_vhost($vhost);
156) 
157)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

159) 
160) }
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

177)     $domainid = $domain->id;
178)   }
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

196)     
197)   $alias ['options'] = $options;
198)     
199)   save_alias($alias);
200) 
201)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

213)   
214)   $vhost = get_vhost_details( $alias['vhost'] );
215)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

217)   
218)   $sure = user_is_sure();
219)   if ($sure === NULL)
220)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

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

bernd authored 15 years ago

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

bernd authored 16 years ago

228)   }
229)   elseif ($sure === false)
230)   {
231)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

233)   }
234) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

235) elseif ($_GET['action'] == 'delete')
236) {
bernd Aliases editieren

bernd authored 16 years ago

237)   $title = "Subdomain löschen";
238)   $section = 'vhosts_vhosts';
239)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

242)   
243)   $sure = user_is_sure();
244)   if ($sure === NULL)
245)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

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

bernd authored 15 years ago

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

bernd authored 16 years ago

253)   }
254)   elseif ($sure === false)
255)   {
256)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

257)       header("Location: vhosts");