3e7cffe2a79b64c9f6fa5617a19a7c9c43d4ed26
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 IPv6

bernd authored 14 years ago

114)   if (isset($_POST['ipv6']) && $_POST['ipv6'] == 'yes')
115)   {
116)     $vhost['autoipv6'] = 1;
117)   } else {
118)     $vhost['autoipv6'] = 0;
119)   }
120)   
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

122)   $logtype = '';
123)   switch ($_POST['logtype']) {
124)     case 'anonymous':
125)       $logtype = 'anonymous';
126)       break;
127)     case 'default':
128)       $logtype = 'default';
129)       break;
130)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
131)   }
132) 
bernd error_log konfigurierbar

bernd authored 16 years ago

133)   $errorlog = 0;
134)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
135)     $errorlog = 1;
136) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

137) 
138)   if (isset($_POST['stats']) && $_POST['stats'] == 1)
139)   {
140)     if ($vhost['stats'] == NULL)
141)       $vhost['stats'] = 'private';
142)   }
143)   else
144)     $vhost['stats'] = NULL;
145) 
146)   if ($logtype == '')
147)     $vhost['stats'] = NULL;
148)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

149)   DEBUG("PHP: {$php} / Logging: {$logtype}");
150) 
151)   $old_options = explode(',', $vhost['options']);
152)   $new_options = array();
153)   foreach ($old_options AS $op)
154)   {
155)     if ($op != 'aliaswww')
156)       array_push($new_options, $op);
157)   }
158)   if ($aliaswww)
159)     array_push($new_options, 'aliaswww');
160) 
161)   DEBUG($old_options);
162)   DEBUG($new_options);
163)   $options = implode(',', $new_options);
164)   DEBUG('New options: '.$options);
165) 
166)   $vhost['hostname'] = $hostname;
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

178)   save_vhost($vhost);
179) 
180)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

182) 
183) }
bernd Aliases editieren

bernd authored 16 years ago

184) elseif ($_GET['action'] == 'addalias')
185) {
186)   check_form_token('vhosts_add_alias');
187)   $id = (int) $_GET['vhost'];
188)   $vhost = get_vhost_details( $id );
189)   DEBUG($vhost);
190) 
191)   $alias = empty_alias();
192)   $alias['vhost'] = $vhost['id'];
193) 
194)   
195)   $hostname = filter_input_hostname($_POST['hostname']);
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

200)     $domainid = $domain->id;
201)   }
bernd Aliases editieren

bernd authored 16 years ago

202) 
203)   if (! is_array($_POST['options']))
204)     $_POST['options'] = array();
205)   $aliaswww = in_array('aliaswww', $_POST['options']);
206)   $forward = in_array('forward', $_POST['options']);
207) 
208)   $new_options = array();
209)   if ($aliaswww)
210)     array_push($new_options, 'aliaswww');
211)   if ($forward)
212)     array_push($new_options, 'forward');
213)   DEBUG($new_options);
214)   $options = implode(',', $new_options);
215)   DEBUG('New options: '.$options);
216) 
217)   $alias['hostname'] = $hostname;
bernd domainid -> domain_id, fies...

bernd authored 14 years ago

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

bernd authored 16 years ago

219)     
220)   $alias ['options'] = $options;
221)     
222)   save_alias($alias);
223) 
224)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

226) 
227) }
228) elseif ($_GET['action'] == 'deletealias')
229) {
230)   $title = "Subdomain löschen";
231)   $section = 'vhosts_vhosts';
232)   
233)   $alias = get_alias_details( (int) $_GET['alias'] );
234)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

236)   
237)   $vhost = get_vhost_details( $alias['vhost'] );
238)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

240)   
241)   $sure = user_is_sure();
242)   if ($sure === NULL)
243)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

244)     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

245)   }
246)   elseif ($sure === true)
247)   {
248)     delete_alias($alias['id']);
249)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

251)   }
252)   elseif ($sure === false)
253)   {
254)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

256)   }
257) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

258) elseif ($_GET['action'] == 'delete')
259) {
bernd Aliases editieren

bernd authored 16 years ago

260)   $title = "Subdomain löschen";
261)   $section = 'vhosts_vhosts';
262)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

265)   
266)   $sure = user_is_sure();
267)   if ($sure === NULL)
268)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

269)     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

270)   }
271)   elseif ($sure === true)
272)   {
273)     delete_vhost($vhost['id']);
274)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

276)   }
277)   elseif ($sure === false)
278)   {
279)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

280)       header("Location: vhosts");