2b282fad245459a43425248e679b8525434c3391
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) 
39)   $defaultdocroot = $vhost['homedir'].'/websites/'.((strlen($hostname) > 0) ? $hostname.'.' : '').($domain->fqdn).'/htdocs';
40) 
41)   if (! check_path( $_POST['docroot'] ))
42)     system_failure("Eingegebener Pfad enthält ungültige Angaben");
43)   $docroot = $vhost['homedir'].'/'.$_POST['docroot'];
44) 
45)   if (($_POST['use_default_docroot'] == '1') || ($docroot == $defaultdocroot)) {
46)     $docroot = '';
47)   }
48) 
49)   DEBUG("Document-Root: ".$docroot);
50) 
51)   $php = '';
52)   switch ($_POST['php']) {
53)     case 'mod_php':
54)       $php = 'mod_php';
55)       break;
56)     case 'fastcgi':
57)       $php = 'fastcgi';
58)       break;
59)     /* Wenn etwas anderes kommt, ist das "kein PHP". So einfach ist das. */
60)   }
61) 
bernd SSL auch über webinterface...

bernd authored 16 years ago

62)   $ssl = '';
63)   switch ($_POST['ssl']) {
64)     case 'http':
65)       $ssl = 'http';
66)       break;
67)     case 'https':
68)       $ssl = 'https';
69)       break;
70)     case 'forward':
71)       $ssl = 'forward';
72)       break;
73)     /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
74)   }
75) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

76)   $logtype = '';
77)   switch ($_POST['logtype']) {
78)     case 'anonymous':
79)       $logtype = 'anonymous';
80)       break;
81)     case 'default':
82)       $logtype = 'default';
83)       break;
84)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
85)   }
86) 
bernd error_log konfigurierbar

bernd authored 16 years ago

87)   $errorlog = 0;
88)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
89)     $errorlog = 1;
90) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

91)   DEBUG("PHP: {$php} / Logging: {$logtype}");
92) 
93)   $old_options = explode(',', $vhost['options']);
94)   $new_options = array();
95)   foreach ($old_options AS $op)
96)   {
97)     if ($op != 'aliaswww')
98)       array_push($new_options, $op);
99)   }
100)   if ($aliaswww)
101)     array_push($new_options, 'aliaswww');
102) 
103)   DEBUG($old_options);
104)   DEBUG($new_options);
105)   $options = implode(',', $new_options);
106)   DEBUG('New options: '.$options);
107) 
108)   $vhost['hostname'] = $hostname;
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

115)   $vhost['options'] = $options;
116)     
117)   save_vhost($vhost);
118) 
119)   if (! $debugmode)
120)     header('Location: vhosts.php');
121) 
122) }
bernd Aliases editieren

bernd authored 16 years ago

123) elseif ($_GET['action'] == 'addalias')
124) {
125)   check_form_token('vhosts_add_alias');
126)   $id = (int) $_GET['vhost'];
127)   $vhost = get_vhost_details( $id );
128)   DEBUG($vhost);
129) 
130)   $alias = empty_alias();
131)   $alias['vhost'] = $vhost['id'];
132) 
133)   
134)   $hostname = filter_input_hostname($_POST['hostname']);
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

135)   $domainid = (int) $_POST['domain'];
136)   if ($domainid != -1) {
137)     $domain = new Domain( (int) $_POST['domain'] );
138)     if ($domain->useraccount != $_SESSION['userinfo']['uid'])
139)       system_failure('Ungültige Domain');
140)     $domainid = $domain->id;
141)   }
bernd Aliases editieren

bernd authored 16 years ago

142) 
143)   if (! is_array($_POST['options']))
144)     $_POST['options'] = array();
145)   $aliaswww = in_array('aliaswww', $_POST['options']);
146)   $forward = in_array('forward', $_POST['options']);
147) 
148)   $new_options = array();
149)   if ($aliaswww)
150)     array_push($new_options, 'aliaswww');
151)   if ($forward)
152)     array_push($new_options, 'forward');
153)   DEBUG($new_options);
154)   $options = implode(',', $new_options);
155)   DEBUG('New options: '.$options);
156) 
157)   $alias['hostname'] = $hostname;
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

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

bernd authored 16 years ago

159)     
160)   $alias ['options'] = $options;
161)     
162)   save_alias($alias);
163) 
164)   if (! $debugmode)
165)     header('Location: aliases.php?vhost='.$vhost['id']);
166) 
167) }
168) elseif ($_GET['action'] == 'deletealias')
169) {
170)   $title = "Subdomain löschen";
171)   $section = 'vhosts_vhosts';
172)   
173)   $alias = get_alias_details( (int) $_GET['alias'] );
174)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

176)   
177)   $vhost = get_vhost_details( $alias['vhost'] );
178)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

180)   
181)   $sure = user_is_sure();
182)   if ($sure === NULL)
183)   {
184)     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?");
185)   }
186)   elseif ($sure === true)
187)   {
188)     delete_alias($alias['id']);
189)     if (! $debugmode)
190)       header('Location: aliases.php?vhost='.$vhost['id']);
191)   }
192)   elseif ($sure === false)
193)   {
194)     if (! $debugmode)
195)       header('Location: aliases.php?vhost='.$vhost['id']);
196)   }
197) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

198) elseif ($_GET['action'] == 'delete')
199) {
bernd Aliases editieren

bernd authored 16 years ago

200)   $title = "Subdomain löschen";
201)   $section = 'vhosts_vhosts';
202)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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