b7b9e16561a247922945c9e5880251da3c936267
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;
bernd Vorbereitung für PHP 5.3

bernd authored 14 years ago

67)       case 'php53':
68)         $php = 'php53';
69)         break;
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

70)       /* Wenn etwas anderes kommt, ist das "kein PHP". So einfach ist das. */
71)     }
72)   }
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

93)   }
94) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

95)   
bernd SSL auch über webinterface...

bernd authored 16 years ago

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

bernd authored 14 years ago

110)   $cert = (int) $_POST['cert'];
111) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

158)   save_vhost($vhost);
159) 
160)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

162) 
163) }
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

180)     $domainid = $domain->id;
181)   }
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

199)     
200)   $alias ['options'] = $options;
201)     
202)   save_alias($alias);
203) 
204)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

216)   
217)   $vhost = get_vhost_details( $alias['vhost'] );
218)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

220)   
221)   $sure = user_is_sure();
222)   if ($sure === NULL)
223)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

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

bernd authored 15 years ago

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

bernd authored 16 years ago

231)   }
232)   elseif ($sure === false)
233)   {
234)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

236)   }
237) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

238) elseif ($_GET['action'] == 'delete')
239) {
bernd Aliases editieren

bernd authored 16 years ago

240)   $title = "Subdomain löschen";
241)   $section = 'vhosts_vhosts';
242)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

245)   
246)   $sure = user_is_sure();
247)   if ($sure === NULL)
248)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

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

bernd authored 15 years ago

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

bernd authored 16 years ago

256)   }
257)   elseif ($sure === false)
258)   {
259)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

260)       header("Location: vhosts");