3c2fddcaeffccc83c138202d47d97e789a9826f1
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'] );
30)     if ($domain->useraccount != $_SESSION['userinfo']['uid'])
31)       system_failure('Ungültige Domain');
32)     $domainid = $domain->id;
33)   }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

40)   $php = '';
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

41)   if ($_POST['vhost_type'] == 'regular')
42)   {
43)     $vhost['is_dav'] = 0;
44)     $vhost['is_svn'] = 0;
45)     $vhost['is_webapp'] = 0;
46)     $defaultdocroot = $vhost['homedir'].'/websites/'.((strlen($hostname) > 0) ? $hostname.'.' : '').($domain->fqdn).'/htdocs';
47)   
48)     if (! check_path( $_POST['docroot'] ))
49)       system_failure("Eingegebener Pfad enthält ungültige Angaben");
50)     $docroot = $vhost['homedir'].'/'.$_POST['docroot'];
51)   
52)     if (($_POST['use_default_docroot'] == '1') || ($docroot == $defaultdocroot)) {
53)       $docroot = '';
54)     }
55)   
56)     DEBUG("Document-Root: ".$docroot);
57)   
58)     switch ($_POST['php']) {
59)       case 'mod_php':
60)         $php = 'mod_php';
61)         break;
62)       case 'fastcgi':
63)         $php = 'fastcgi';
64)         break;
65)       /* Wenn etwas anderes kommt, ist das "kein PHP". So einfach ist das. */
66)     }
67)   }
68)   elseif ($_POST['vhost_type'] == 'dav') {
69)     $vhost['is_dav'] = 1;
70)     $vhost['is_svn'] = 0;
71)     $vhost['is_webapp'] = 0;
72)   }
73)   elseif ($_POST['vhost_type'] == 'svn') {
74)     $vhost['is_dav'] = 0;
75)     $vhost['is_svn'] = 1;
76)     $vhost['is_webapp'] = 0;
77)   }
78)   elseif ($_POST['vhost_type'] == 'webapp') {
79)     $vhost['is_dav'] = 0;
80)     $vhost['is_svn'] = 0;
81)     $vhost['is_webapp'] = 1;
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

83)   }
84) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

85)   
bernd SSL auch über webinterface...

bernd authored 16 years ago

86)   $ssl = '';
87)   switch ($_POST['ssl']) {
88)     case 'http':
89)       $ssl = 'http';
90)       break;
91)     case 'https':
92)       $ssl = 'https';
93)       break;
94)     case 'forward':
95)       $ssl = 'forward';
96)       break;
97)     /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
98)   }
99) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

100)   $logtype = '';
101)   switch ($_POST['logtype']) {
102)     case 'anonymous':
103)       $logtype = 'anonymous';
104)       break;
105)     case 'default':
106)       $logtype = 'default';
107)       break;
108)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
109)   }
110) 
bernd error_log konfigurierbar

bernd authored 16 years ago

111)   $errorlog = 0;
112)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
113)     $errorlog = 1;
114) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

142)   save_vhost($vhost);
143) 
144)   if (! $debugmode)
145)     header('Location: vhosts.php');
146) 
147) }
bernd Aliases editieren

bernd authored 16 years ago

148) elseif ($_GET['action'] == 'addalias')
149) {
150)   check_form_token('vhosts_add_alias');
151)   $id = (int) $_GET['vhost'];
152)   $vhost = get_vhost_details( $id );
153)   DEBUG($vhost);
154) 
155)   $alias = empty_alias();
156)   $alias['vhost'] = $vhost['id'];
157) 
158)   
159)   $hostname = filter_input_hostname($_POST['hostname']);
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

160)   $domainid = (int) $_POST['domain'];
161)   if ($domainid != -1) {
162)     $domain = new Domain( (int) $_POST['domain'] );
163)     if ($domain->useraccount != $_SESSION['userinfo']['uid'])
164)       system_failure('Ungültige Domain');
165)     $domainid = $domain->id;
166)   }
bernd Aliases editieren

bernd authored 16 years ago

167) 
168)   if (! is_array($_POST['options']))
169)     $_POST['options'] = array();
170)   $aliaswww = in_array('aliaswww', $_POST['options']);
171)   $forward = in_array('forward', $_POST['options']);
172) 
173)   $new_options = array();
174)   if ($aliaswww)
175)     array_push($new_options, 'aliaswww');
176)   if ($forward)
177)     array_push($new_options, 'forward');
178)   DEBUG($new_options);
179)   $options = implode(',', $new_options);
180)   DEBUG('New options: '.$options);
181) 
182)   $alias['hostname'] = $hostname;
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

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

bernd authored 16 years ago

184)     
185)   $alias ['options'] = $options;
186)     
187)   save_alias($alias);
188) 
189)   if (! $debugmode)
190)     header('Location: aliases.php?vhost='.$vhost['id']);
191) 
192) }
193) elseif ($_GET['action'] == 'deletealias')
194) {
195)   $title = "Subdomain löschen";
196)   $section = 'vhosts_vhosts';
197)   
198)   $alias = get_alias_details( (int) $_GET['alias'] );
199)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

201)   
202)   $vhost = get_vhost_details( $alias['vhost'] );
203)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

205)   
206)   $sure = user_is_sure();
207)   if ($sure === NULL)
208)   {
209)     are_you_sure("action=deletealias&amp;alias={$_GET['alias']}", "Möchten Sie das Alias »{$alias_string}« für die Subdomain »{$vhost_string}« wirklich löschen?");
210)   }
211)   elseif ($sure === true)
212)   {
213)     delete_alias($alias['id']);
214)     if (! $debugmode)
215)       header('Location: aliases.php?vhost='.$vhost['id']);
216)   }
217)   elseif ($sure === false)
218)   {
219)     if (! $debugmode)
220)       header('Location: aliases.php?vhost='.$vhost['id']);
221)   }
222) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

223) elseif ($_GET['action'] == 'delete')
224) {
bernd Aliases editieren

bernd authored 16 years ago

225)   $title = "Subdomain löschen";
226)   $section = 'vhosts_vhosts';
227)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

229)   $vhost_string = $vhost['fqdn'];