c61521fa744024963e46a2d89065740866edfa98
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 Docroot auch bei WebDAV anz...

bernd authored 16 years ago

41)   if ($_POST['vhost_type'] == 'regular' || $_POST['vhost_type'] == 'dav')
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

42)   {
43)     $defaultdocroot = $vhost['homedir'].'/websites/'.((strlen($hostname) > 0) ? $hostname.'.' : '').($domain->fqdn).'/htdocs';
44)   
45)     if (! check_path( $_POST['docroot'] ))
46)       system_failure("Eingegebener Pfad enthält ungültige Angaben");
bernd mod_php deprecated, zwang z...

bernd authored 15 years ago

47)     $docroot = $vhost['homedir'].'/websites/'.$_POST['docroot'];
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

48)   
49)     if (($_POST['use_default_docroot'] == '1') || ($docroot == $defaultdocroot)) {
50)       $docroot = '';
51)     }
52)   
53)     DEBUG("Document-Root: ".$docroot);
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

54)   }
55)   $php = '';
56)   if ($_POST['vhost_type'] == 'regular')
57)   {
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

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)   }
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

88)   }
89) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

90)   
bernd SSL auch über webinterface...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 15 years ago

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

bernd authored 16 years ago

151) 
152) }
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 16 years ago

165)   $domainid = (int) $_POST['domain'];
166)   if ($domainid != -1) {
167)     $domain = new Domain( (int) $_POST['domain'] );
168)     if ($domain->useraccount != $_SESSION['userinfo']['uid'])
169)       system_failure('Ungültige Domain');
170)     $domainid = $domain->id;
171)   }
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

210)   
211)   $sure = user_is_sure();
212)   if ($sure === NULL)
213)   {
214)     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?");
215)   }
216)   elseif ($sure === true)
217)   {
218)     delete_alias($alias['id']);
219)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

235)   
236)   $sure = user_is_sure();
237)   if ($sure === NULL)
238)   {
239)     are_you_sure("action=delete&amp;vhost={$_GET['vhost']}", "Möchten Sie die Subdomain »{$vhost_string}« wirklich löschen?");
240)   }
241)   elseif ($sure === true)
242)   {
243)     delete_vhost($vhost['id']);
244)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 15 years ago

250)       header("Location: vhosts");