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

bernd authored 16 years ago

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

bernd authored 16 years ago

84)   
bernd SSL auch über webinterface...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

204)   
205)   $sure = user_is_sure();
206)   if ($sure === NULL)
207)   {
208)     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?");
209)   }
210)   elseif ($sure === true)
211)   {
212)     delete_alias($alias['id']);
213)     if (! $debugmode)
214)       header('Location: aliases.php?vhost='.$vhost['id']);
215)   }
216)   elseif ($sure === false)
217)   {
218)     if (! $debugmode)
219)       header('Location: aliases.php?vhost='.$vhost['id']);
220)   }
221) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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