709c9ea228a4039610d5aaafd0a4464e1f7b443e
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)   $domain = new Domain( (int) $_POST['domain'] );
27)   if ($domain->useraccount != $_SESSION['userinfo']['uid'])
28)     system_failure('Ungültige Domain');
29) 
30) 
31)   if (! is_array($_POST['options']))
32)     $_POST['options'] = array();
33)   $aliaswww = in_array('aliaswww', $_POST['options']);
34) 
35)   $defaultdocroot = $vhost['homedir'].'/websites/'.((strlen($hostname) > 0) ? $hostname.'.' : '').($domain->fqdn).'/htdocs';
36) 
37)   if (! check_path( $_POST['docroot'] ))
38)     system_failure("Eingegebener Pfad enthält ungültige Angaben");
39)   $docroot = $vhost['homedir'].'/'.$_POST['docroot'];
40) 
41)   if (($_POST['use_default_docroot'] == '1') || ($docroot == $defaultdocroot)) {
42)     $docroot = '';
43)   }
44) 
45)   DEBUG("Document-Root: ".$docroot);
46) 
47)   $php = '';
48)   switch ($_POST['php']) {
49)     case 'mod_php':
50)       $php = 'mod_php';
51)       break;
52)     case 'fastcgi':
53)       $php = 'fastcgi';
54)       break;
55)     /* Wenn etwas anderes kommt, ist das "kein PHP". So einfach ist das. */
56)   }
57) 
58)   $logtype = '';
59)   switch ($_POST['logtype']) {
60)     case 'anonymous':
61)       $logtype = 'anonymous';
62)       break;
63)     case 'default':
64)       $logtype = 'default';
65)       break;
66)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
67)   }
68) 
69)   DEBUG("PHP: {$php} / Logging: {$logtype}");
70) 
71)   $old_options = explode(',', $vhost['options']);
72)   $new_options = array();
73)   foreach ($old_options AS $op)
74)   {
75)     if ($op != 'aliaswww')
76)       array_push($new_options, $op);
77)   }
78)   if ($aliaswww)
79)     array_push($new_options, 'aliaswww');
80) 
81)   DEBUG($old_options);
82)   DEBUG($new_options);
83)   $options = implode(',', $new_options);
84)   DEBUG('New options: '.$options);
85) 
86)   $vhost['hostname'] = $hostname;
87)   $vhost['domainid'] = $domain->id;
88)   $vhost['docroot'] = $docroot;
89)   $vhost['php'] = $php;
90)   $vhost['logtype'] = $logtype;
91)     
92)   $vhost['options'] = $options;
93)     
94)   save_vhost($vhost);
95) 
96)   if (! $debugmode)
97)     header('Location: vhosts.php');
98) 
99) }
bernd Aliases editieren

bernd authored 16 years ago

100) elseif ($_GET['action'] == 'addalias')
101) {
102)   check_form_token('vhosts_add_alias');
103)   $id = (int) $_GET['vhost'];
104)   $vhost = get_vhost_details( $id );
105)   DEBUG($vhost);
106) 
107)   $alias = empty_alias();
108)   $alias['vhost'] = $vhost['id'];
109) 
110)   
111)   $hostname = filter_input_hostname($_POST['hostname']);
112)   $domain = new Domain( (int) $_POST['domain'] );
113)   if ($domain->useraccount != $_SESSION['userinfo']['uid'])
114)     system_failure('Ungültige Domain');
115) 
116)   if (! is_array($_POST['options']))
117)     $_POST['options'] = array();
118)   $aliaswww = in_array('aliaswww', $_POST['options']);
119)   $forward = in_array('forward', $_POST['options']);
120) 
121)   $new_options = array();
122)   if ($aliaswww)
123)     array_push($new_options, 'aliaswww');
124)   if ($forward)
125)     array_push($new_options, 'forward');
126)   DEBUG($new_options);
127)   $options = implode(',', $new_options);
128)   DEBUG('New options: '.$options);
129) 
130)   $alias['hostname'] = $hostname;
131)   $alias['domainid'] = $domain->id;
132)     
133)   $alias ['options'] = $options;
134)     
135)   save_alias($alias);
136) 
137)   if (! $debugmode)
138)     header('Location: aliases.php?vhost='.$vhost['id']);
139) 
140) }
141) elseif ($_GET['action'] == 'deletealias')
142) {
143)   $title = "Subdomain löschen";
144)   $section = 'vhosts_vhosts';
145)   
146)   $alias = get_alias_details( (int) $_GET['alias'] );
147)   DEBUG($alias);
148)   $alias_string = ((strlen($alias['hostname']) > 0) ? $alias['hostname'].'.' : '').$alias['domain'];
149)   
150)   $vhost = get_vhost_details( $alias['vhost'] );
151)   DEBUG($vhost);
152)   $vhost_string = ((strlen($vhost['hostname']) > 0) ? $vhost['hostname'].'.' : '').$vhost['domain'];
153)   
154)   $sure = user_is_sure();
155)   if ($sure === NULL)
156)   {
157)     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?");
158)   }
159)   elseif ($sure === true)
160)   {
161)     delete_alias($alias['id']);
162)     if (! $debugmode)
163)       header('Location: aliases.php?vhost='.$vhost['id']);
164)   }
165)   elseif ($sure === false)
166)   {
167)     if (! $debugmode)
168)       header('Location: aliases.php?vhost='.$vhost['id']);
169)   }
170) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

171) elseif ($_GET['action'] == 'delete')
172) {
bernd Aliases editieren

bernd authored 16 years ago

173)   $title = "Subdomain löschen";
174)   $section = 'vhosts_vhosts';
175)