f1d119a959c433c20269927761fd1ccef08de0a3
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) 
62)   $logtype = '';
63)   switch ($_POST['logtype']) {
64)     case 'anonymous':
65)       $logtype = 'anonymous';
66)       break;
67)     case 'default':
68)       $logtype = 'default';
69)       break;
70)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
71)   }
72) 
73)   DEBUG("PHP: {$php} / Logging: {$logtype}");
74) 
75)   $old_options = explode(',', $vhost['options']);
76)   $new_options = array();
77)   foreach ($old_options AS $op)
78)   {
79)     if ($op != 'aliaswww')
80)       array_push($new_options, $op);
81)   }
82)   if ($aliaswww)
83)     array_push($new_options, 'aliaswww');
84) 
85)   DEBUG($old_options);
86)   DEBUG($new_options);
87)   $options = implode(',', $new_options);
88)   DEBUG('New options: '.$options);
89) 
90)   $vhost['hostname'] = $hostname;
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

92)   $vhost['docroot'] = $docroot;
93)   $vhost['php'] = $php;
94)   $vhost['logtype'] = $logtype;
95)     
96)   $vhost['options'] = $options;
97)     
98)   save_vhost($vhost);
99) 
100)   if (! $debugmode)
101)     header('Location: vhosts.php');
102) 
103) }
bernd Aliases editieren

bernd authored 16 years ago

104) elseif ($_GET['action'] == 'addalias')
105) {
106)   check_form_token('vhosts_add_alias');
107)   $id = (int) $_GET['vhost'];
108)   $vhost = get_vhost_details( $id );
109)   DEBUG($vhost);
110) 
111)   $alias = empty_alias();
112)   $alias['vhost'] = $vhost['id'];
113) 
114)   
115)   $hostname = filter_input_hostname($_POST['hostname']);
116)   $domain = new Domain( (int) $_POST['domain'] );
117)   if ($domain->useraccount != $_SESSION['userinfo']['uid'])
118)     system_failure('Ungültige Domain');
119) 
120)   if (! is_array($_POST['options']))
121)     $_POST['options'] = array();
122)   $aliaswww = in_array('aliaswww', $_POST['options']);
123)   $forward = in_array('forward', $_POST['options']);
124) 
125)   $new_options = array();
126)   if ($aliaswww)
127)     array_push($new_options, 'aliaswww');
128)   if ($forward)
129)     array_push($new_options, 'forward');
130)   DEBUG($new_options);
131)   $options = implode(',', $new_options);
132)   DEBUG('New options: '.$options);
133) 
134)   $alias['hostname'] = $hostname;
135)   $alias['domainid'] = $domain->id;
136)     
137)   $alias ['options'] = $options;
138)     
139)   save_alias($alias);
140) 
141)   if (! $debugmode)
142)     header('Location: aliases.php?vhost='.$vhost['id']);
143) 
144) }
145) elseif ($_GET['action'] == 'deletealias')
146) {
147)   $title = "Subdomain löschen";
148)   $section = 'vhosts_vhosts';
149)   
150)   $alias = get_alias_details( (int) $_GET['alias'] );
151)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

153)   
154)   $vhost = get_vhost_details( $alias['vhost'] );
155)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

157)   
158)   $sure = user_is_sure();
159)   if ($sure === NULL)
160)   {
161)     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?");
162)   }
163)   elseif ($sure === true)
164)   {
165)     delete_alias($alias['id']);
166)     if (! $debugmode)
167)       header('Location: aliases.php?vhost='.$vhost['id']);
168)   }
169)   elseif ($sure === false)
170)   {
171)     if (! $debugmode)
172)       header('Location: aliases.php?vhost='.$vhost['id']);
173)   }
174) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

175) elseif ($_GET['action'] == 'delete')
176) {
bernd Aliases editieren

bernd authored 16 years ago

177)   $title = "Subdomain löschen";
178)   $section = 'vhosts_vhosts';
179)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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