fc35e6982695ba56c5da53c14ecfeb9e7b43d198
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) 
87)   DEBUG("PHP: {$php} / Logging: {$logtype}");
88) 
89)   $old_options = explode(',', $vhost['options']);
90)   $new_options = array();
91)   foreach ($old_options AS $op)
92)   {
93)     if ($op != 'aliaswww')
94)       array_push($new_options, $op);
95)   }
96)   if ($aliaswww)
97)     array_push($new_options, 'aliaswww');
98) 
99)   DEBUG($old_options);
100)   DEBUG($new_options);
101)   $options = implode(',', $new_options);
102)   DEBUG('New options: '.$options);
103) 
104)   $vhost['hostname'] = $hostname;
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

109)   $vhost['logtype'] = $logtype;
110)     
111)   $vhost['options'] = $options;
112)     
113)   save_vhost($vhost);
114) 
115)   if (! $debugmode)
116)     header('Location: vhosts.php');
117) 
118) }
bernd Aliases editieren

bernd authored 16 years ago

119) elseif ($_GET['action'] == 'addalias')
120) {
121)   check_form_token('vhosts_add_alias');
122)   $id = (int) $_GET['vhost'];
123)   $vhost = get_vhost_details( $id );
124)   DEBUG($vhost);
125) 
126)   $alias = empty_alias();
127)   $alias['vhost'] = $vhost['id'];
128) 
129)   
130)   $hostname = filter_input_hostname($_POST['hostname']);
131)   $domain = new Domain( (int) $_POST['domain'] );
132)   if ($domain->useraccount != $_SESSION['userinfo']['uid'])
133)     system_failure('Ungültige Domain');
134) 
135)   if (! is_array($_POST['options']))
136)     $_POST['options'] = array();
137)   $aliaswww = in_array('aliaswww', $_POST['options']);
138)   $forward = in_array('forward', $_POST['options']);
139) 
140)   $new_options = array();
141)   if ($aliaswww)
142)     array_push($new_options, 'aliaswww');
143)   if ($forward)
144)     array_push($new_options, 'forward');
145)   DEBUG($new_options);
146)   $options = implode(',', $new_options);
147)   DEBUG('New options: '.$options);
148) 
149)   $alias['hostname'] = $hostname;
150)   $alias['domainid'] = $domain->id;
151)     
152)   $alias ['options'] = $options;
153)     
154)   save_alias($alias);
155) 
156)   if (! $debugmode)
157)     header('Location: aliases.php?vhost='.$vhost['id']);
158) 
159) }
160) elseif ($_GET['action'] == 'deletealias')
161) {
162)   $title = "Subdomain löschen";
163)   $section = 'vhosts_vhosts';
164)   
165)   $alias = get_alias_details( (int) $_GET['alias'] );
166)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

168)   
169)   $vhost = get_vhost_details( $alias['vhost'] );
170)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

172)   
173)   $sure = user_is_sure();
174)   if ($sure === NULL)
175)   {
176)     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?");
177)   }
178)   elseif ($sure === true)
179)   {
180)     delete_alias($alias['id']);
181)     if (! $debugmode)
182)       header('Location: aliases.php?vhost='.$vhost['id']);
183)   }
184)   elseif ($sure === false)
185)   {
186)     if (! $debugmode)
187)       header('Location: aliases.php?vhost='.$vhost['id']);
188)   }
189) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

190) elseif ($_GET['action'] == 'delete')
191) {
bernd Aliases editieren

bernd authored 16 years ago

192)   $title = "Subdomain löschen";
193)   $section = 'vhosts_vhosts';
194)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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