56c4c2ac039e0ccd1f92cc10bc9e4bebe63210bd
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 Webalizer/Statistik-Funktio...

bernd authored 14 years ago

27)   $domain_id = (int) $_POST['domain'];
28)   if ($domain_id != -1) {
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

29)     $domain = new Domain( (int) $_POST['domain'] );
bernd Mehr config-optionen und co...

bernd authored 14 years ago

30)     $domain->ensure_userdomain();
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

31)     $domain_id = $domain->id;
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

32)   }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

33) 
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

34)   if (! (isset($_POST['options']) && is_array($_POST['options'])))
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

35)     $_POST['options'] = array();
36)   $aliaswww = in_array('aliaswww', $_POST['options']);
37) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

38)   $docroot = '';
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

39)   $php = '';
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

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

bernd authored 16 years ago

41)   {
42)     $defaultdocroot = $vhost['homedir'].'/websites/'.((strlen($hostname) > 0) ? $hostname.'.' : '').($domain->fqdn).'/htdocs';
43)   
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

44)     $docroot = '';
45)     if (isset($_POST['docroot']))
46)     {
47)       if (! check_path( $_POST['docroot'] ))
48)         system_failure("Eingegebener Pfad enthält ungültige Angaben");
49)       $docroot = $vhost['homedir'].'/websites/'.$_POST['docroot'];
50)     }
51)     if ((isset($_POST['use_default_docroot']) && $_POST['use_default_docroot'] == '1') || ($docroot == $defaultdocroot)) {
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

52)       $docroot = '';
53)     }
54)   
55)     DEBUG("Document-Root: ".$docroot);
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

56)   }
57)   $php = '';
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

58)   if ($_POST['vhost_type'] == 'regular' && isset($_POST['php']))
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

59)   {
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

60)     switch ($_POST['php']) {
61)       case 'mod_php':
62)         $php = 'mod_php';
63)         break;
64)       case 'fastcgi':
65)         $php = 'fastcgi';
66)         break;
bernd Vorbereitung für PHP 5.3

bernd authored 14 years ago

67)       case 'php53':
68)         $php = 'php53';
69)         break;
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

70)       /* Wenn etwas anderes kommt, ist das "kein PHP". So einfach ist das. */
71)     }
72)   }
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

73)   if ($_POST['vhost_type'] == 'regular') {
74)     $vhost['is_dav'] = 0;
75)     $vhost['is_svn'] = 0;
76)     $vhost['is_webapp'] = 0;
77)   }
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

78)   elseif ($_POST['vhost_type'] == 'dav') {
79)     $vhost['is_dav'] = 1;
80)     $vhost['is_svn'] = 0;
81)     $vhost['is_webapp'] = 0;
82)   }
83)   elseif ($_POST['vhost_type'] == 'svn') {
84)     $vhost['is_dav'] = 0;
85)     $vhost['is_svn'] = 1;
86)     $vhost['is_webapp'] = 0;
87)   }
88)   elseif ($_POST['vhost_type'] == 'webapp') {
89)     $vhost['is_dav'] = 0;
90)     $vhost['is_svn'] = 0;
91)     $vhost['is_webapp'] = 1;
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

93)   }
94) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

95)   
bernd SSL auch über webinterface...

bernd authored 16 years ago

96)   $ssl = '';
97)   switch ($_POST['ssl']) {
98)     case 'http':
99)       $ssl = 'http';
100)       break;
101)     case 'https':
102)       $ssl = 'https';
103)       break;
104)     case 'forward':
105)       $ssl = 'forward';
106)       break;
107)     /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
108)   }
109) 
bernd fix a warning

bernd authored 14 years ago

110)   $cert = (isset($_POST['cert']) ? (int) $_POST['cert'] : NULL);
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

111) 
bernd fix a warning

bernd authored 14 years ago

112)   $ipv4 = (isset($_POST['ipv4']) ? $_POST['ipv4'] : NULL);
bernd IP-Adressen aktivieren

bernd authored 14 years ago

113) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

114) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

115)   $logtype = '';
116)   switch ($_POST['logtype']) {
117)     case 'anonymous':
118)       $logtype = 'anonymous';
119)       break;
120)     case 'default':
121)       $logtype = 'default';
122)       break;
123)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
124)   }
125) 
bernd error_log konfigurierbar

bernd authored 16 years ago

126)   $errorlog = 0;
127)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
128)     $errorlog = 1;
129) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

130) 
131)   if (isset($_POST['stats']) && $_POST['stats'] == 1)
132)   {
133)     if ($vhost['stats'] == NULL)
134)       $vhost['stats'] = 'private';
135)   }
136)   else
137)     $vhost['stats'] = NULL;
138) 
139)   if ($logtype == '')
140)     $vhost['stats'] = NULL;
141)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

142)   DEBUG("PHP: {$php} / Logging: {$logtype}");
143) 
144)   $old_options = explode(',', $vhost['options']);
145)   $new_options = array();
146)   foreach ($old_options AS $op)
147)   {
148)     if ($op != 'aliaswww')
149)       array_push($new_options, $op);
150)   }
151)   if ($aliaswww)
152)     array_push($new_options, 'aliaswww');
153) 
154)   DEBUG($old_options);
155)   DEBUG($new_options);
156)   $options = implode(',', $new_options);
157)   DEBUG('New options: '.$options);
158) 
159)   $vhost['hostname'] = $hostname;
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

163)   $vhost['ssl'] = $ssl;
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

164)   $vhost['cert'] = $cert;
bernd IP-Adressen aktivieren

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

171)   save_vhost($vhost);
172) 
173)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

175) 
176) }
bernd Aliases editieren

bernd authored 16 years ago

177) elseif ($_GET['action'] == 'addalias')
178) {
179)   check_form_token('vhosts_add_alias');
180)   $id = (int) $_GET['vhost'];
181)   $vhost = get_vhost_details( $id );
182)   DEBUG($vhost);
183) 
184)   $alias = empty_alias();
185)   $alias['vhost'] = $vhost['id'];
186) 
187)   
188)   $hostname = filter_input_hostname($_POST['hostname']);
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

189)   $domainid = (int) $_POST['domain'];
190)   if ($domainid != -1) {
191)     $domain = new Domain( (int) $_POST['domain'] );
bernd Mehr config-optionen und co...

bernd authored 14 years ago

192)     $domain->ensure_userdomain();
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

193)     $domainid = $domain->id;
194)   }
bernd Aliases editieren

bernd authored 16 years ago

195) 
196)   if (! is_array($_POST['options']))
197)     $_POST['options'] = array();
198)   $aliaswww = in_array('aliaswww', $_POST['options']);
199)   $forward = in_array('forward', $_POST['options']);
200) 
201)   $new_options = array();
202)   if ($aliaswww)
203)     array_push($new_options, 'aliaswww');
204)   if ($forward)
205)     array_push($new_options, 'forward');
206)   DEBUG($new_options);
207)   $options = implode(',', $new_options);
208)   DEBUG('New options: '.$options);
209) 
210)   $alias['hostname'] = $hostname;
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

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

bernd authored 16 years ago

212)     
213)   $alias ['options'] = $options;
214)     
215)   save_alias($alias);
216) 
217)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

219) 
220) }
221) elseif ($_GET['action'] == 'deletealias')
222) {
223)   $title = "Subdomain löschen";
224)   $section = 'vhosts_vhosts';
225)   
226)   $alias = get_alias_details( (int) $_GET['alias'] );
227)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

229)   
230)   $vhost = get_vhost_details( $alias['vhost'] );
231)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

233)   
234)   $sure = user_is_sure();
235)   if ($sure === NULL)
236)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

237)     are_you_sure("action=deletealias&alias={$_GET['alias']}", "Möchten Sie das Alias »{$alias_string}« für die Subdomain »{$vhost_string}« wirklich löschen?");
bernd Aliases editieren

bernd authored 16 years ago

238)   }
239)   elseif ($sure === true)
240)   {
241)     delete_alias($alias['id']);
242)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 15 years ago

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

bernd authored 16 years ago

249)   }
250) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

251) elseif ($_GET['action'] == 'delete')
252) {
bernd Aliases editieren

bernd authored 16 years ago

253)   $title = "Subdomain löschen";
254)   $section = 'vhosts_vhosts';
255)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

258)   
259)   $sure = user_is_sure();
260)   if ($sure === NULL)
261)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

262)     are_you_sure("action=delete&vhost={$_GET['vhost']}", "Möchten Sie die Subdomain »{$vhost_string}« wirklich löschen?");
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

263)   }
264)   elseif ($sure === true)
265)   {
266)     delete_vhost($vhost['id']);
267)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

269)   }
270)   elseif ($sure === false)
271)   {
272)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

273)       header("Location: vhosts");