0434646d0d11a573aea06fef2dffe5734fde116e
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

1) <?php
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
Bernd Wurst Updated copyright notice (2...

Bernd Wurst authored 11 years ago

5) Written 2008-2013 by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10) 
11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
12) http://creativecommons.org/publicdomain/zero/1.0/
13) 
14) Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15) */
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

16) 
17) require_once('session/start.php');
18) 
19) require_once('vhosts.php');
20) 
Bernd Wurst Weise Benutzer auf Wartezei...

Bernd Wurst authored 11 years ago

21) require_once('inc/error.php');
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

22) require_once('inc/security.php');
23) require_once('class/domain.php');
24) 
25) require_role(ROLE_SYSTEMUSER);
26) 
27) require_once("inc/debug.php");
28) global $debugmode;
29) 
30) 
31) if ($_GET['action'] == 'edit')
32) {
33)   check_form_token('vhosts_edit_vhost');
34)   $id = (int) $_GET['vhost'];
35)   $vhost = empty_vhost();
36)   if ($id != 0)
37)     $vhost = get_vhost_details( $id );
38)   DEBUG($vhost);
39) 
bernd Erlaube wildcards bei vhosts

bernd authored 13 years ago

40)   $hostname = filter_input_hostname($_POST['hostname'], true);
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

41) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 15 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

50)     $_POST['options'] = array();
51)   $aliaswww = in_array('aliaswww', $_POST['options']);
52) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

53)   $docroot = '';
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

58)     $docroot = '';
59)     if (isset($_POST['docroot']))
60)     {
61)       if (! check_path( $_POST['docroot'] ))
62)         system_failure("Eingegebener Pfad enthält ungültige Angaben");
63)       $docroot = $vhost['homedir'].'/websites/'.$_POST['docroot'];
64)     }
65)     if ((isset($_POST['use_default_docroot']) && $_POST['use_default_docroot'] == '1') || ($docroot == $defaultdocroot)) {
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

66)       $docroot = '';
67)     }
68)   
69)     DEBUG("Document-Root: ".$docroot);
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

74)     switch ($_POST['php']) {
75)       case 'mod_php':
76)         $php = 'mod_php';
77)         break;
78)       case 'fastcgi':
79)         $php = 'fastcgi';
80)         break;
bernd Vorbereitung für PHP 5.3

bernd authored 14 years ago

81)       case 'php53':
82)         $php = 'php53';
83)         break;
Bernd Wurst prepare for experimental PH...

Bernd Wurst authored 12 years ago

84)       case 'php54':
85)         $php = 'php54';
86)         break;
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

87)       /* Wenn etwas anderes kommt, ist das "kein PHP". So einfach ist das. */
88)     }
89)   }
bernd "CGI-Aktivieren" ist jetzt...

bernd authored 13 years ago

90)   $cgi = 1;
91)   if (isset($_POST['safemode']) && $_POST['safemode'] == 'yes')
bernd CGI abschaltbar

bernd authored 14 years ago

92)   {
bernd "CGI-Aktivieren" ist jetzt...

bernd authored 13 years ago

93)     $cgi = 0;
bernd CGI abschaltbar

bernd authored 14 years ago

94)   }
95) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

96)   if (isset($_POST['suexec_user']))
97)     $vhost['suexec_user'] = $_POST['suexec_user'];
98) 
Bernd Wurst Ermögliche das Auswählen de...

Bernd Wurst authored 11 years ago

99)   if (isset($_POST['server']))
100)     $vhost['server'] = $_POST['server'];
101) 
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

102)   if ($_POST['vhost_type'] == 'regular') {
103)     $vhost['is_dav'] = 0;
104)     $vhost['is_svn'] = 0;
105)     $vhost['is_webapp'] = 0;
106)   }
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

107)   elseif ($_POST['vhost_type'] == 'dav') {
108)     $vhost['is_dav'] = 1;
109)     $vhost['is_svn'] = 0;
110)     $vhost['is_webapp'] = 0;
111)   }
112)   elseif ($_POST['vhost_type'] == 'svn') {
113)     $vhost['is_dav'] = 0;
114)     $vhost['is_svn'] = 1;
115)     $vhost['is_webapp'] = 0;
116)   }
117)   elseif ($_POST['vhost_type'] == 'webapp') {
118)     $vhost['is_dav'] = 0;
119)     $vhost['is_svn'] = 0;
120)     $vhost['is_webapp'] = 1;
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

122)   }
123) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

124)   
bernd SSL auch über webinterface...

bernd authored 16 years ago

125)   $ssl = '';
126)   switch ($_POST['ssl']) {
127)     case 'http':
128)       $ssl = 'http';
129)       break;
130)     case 'https':
131)       $ssl = 'https';
132)       break;
133)     case 'forward':
134)       $ssl = 'forward';
135)       break;
136)     /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
137)   }
138) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

140) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

142) 
bernd IPv6

bernd authored 14 years ago

143)   if (isset($_POST['ipv6']) && $_POST['ipv6'] == 'yes')
144)   {
145)     $vhost['autoipv6'] = 1;
bernd Zusätzlicher Haken für eige...

bernd authored 13 years ago

146)     if (isset($_POST['ipv6_separate']) && $_POST['ipv6_separate'] = 'yes')
147)     {
148)       $vhost['autoipv6'] = 2;
149)     }
bernd IPv6

bernd authored 14 years ago

150)   } else {
151)     $vhost['autoipv6'] = 0;
152)   }
153)   
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

155)   $logtype = '';
156)   switch ($_POST['logtype']) {
157)     case 'anonymous':
158)       $logtype = 'anonymous';
159)       break;
160)     case 'default':
161)       $logtype = 'default';
162)       break;
163)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
164)   }
165) 
bernd error_log konfigurierbar

bernd authored 16 years ago

166)   $errorlog = 0;
167)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
168)     $errorlog = 1;
169) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

170) 
171)   if (isset($_POST['stats']) && $_POST['stats'] == 1)
172)   {
173)     if ($vhost['stats'] == NULL)
174)       $vhost['stats'] = 'private';
175)   }
176)   else
177)     $vhost['stats'] = NULL;
178) 
179)   if ($logtype == '')
180)     $vhost['stats'] = NULL;
181)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

182)   DEBUG("PHP: {$php} / Logging: {$logtype}");
183) 
184)   $old_options = explode(',', $vhost['options']);
185)   $new_options = array();
186)   foreach ($old_options AS $op)
187)   {
188)     if ($op != 'aliaswww')
189)       array_push($new_options, $op);
190)   }
191)   if ($aliaswww)
192)     array_push($new_options, 'aliaswww');
193) 
194)   DEBUG($old_options);
195)   DEBUG($new_options);
196)   $options = implode(',', $new_options);
197)   DEBUG('New options: '.$options);
198) 
199)   $vhost['hostname'] = $hostname;
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

201)   $vhost['docroot'] = $docroot;
202)   $vhost['php'] = $php;
bernd CGI abschaltbar

bernd authored 14 years ago

203)   $vhost['cgi'] = $cgi;
bernd SSL auch über webinterface...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

212)   save_vhost($vhost);
Bernd Wurst Weise Benutzer auf Wartezei...

Bernd Wurst authored 11 years ago

213)   success_msg("Ihre Einstellungen wurden gespeichert. Es dauert jedoch einige Minuten bis die Änderungen wirksam werden.");
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

214) 
215)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

217) 
218) }
bernd Aliases editieren

bernd authored 16 years ago

219) elseif ($_GET['action'] == 'addalias')
220) {
221)   check_form_token('vhosts_add_alias');
222)   $id = (int) $_GET['vhost'];
223)   $vhost = get_vhost_details( $id );
224)   DEBUG($vhost);
225) 
226)   $alias = empty_alias();
227)   $alias['vhost'] = $vhost['id'];
228) 
229)   
bernd Erlaube wildcards bei vhosts

bernd authored 13 years ago

230)   $hostname = filter_input_hostname($_POST['hostname'], true);
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

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

bernd authored 15 years ago

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

bernd authored 16 years ago

235)     $domainid = $domain->id;
236)   }
bernd Aliases editieren

bernd authored 16 years ago

237) 
238)   if (! is_array($_POST['options']))
239)     $_POST['options'] = array();
240)   $aliaswww = in_array('aliaswww', $_POST['options']);
241)   $forward = in_array('forward', $_POST['options']);
242) 
243)   $new_options = array();
244)   if ($aliaswww)
245)     array_push($new_options, 'aliaswww');
246)   if ($forward)
247)     array_push($new_options, 'forward');
248)   DEBUG($new_options);
249)   $options = implode(',', $new_options);
250)   DEBUG('New options: '.$options);
251) 
252)   $alias['hostname'] = $hostname;
bernd domainid -> domain_id, fies...

bernd authored 14 years ago

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

bernd authored 16 years ago

254)     
255)   $alias ['options'] = $options;
256)     
257)   save_alias($alias);
258) 
259)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

261) 
262) }
263) elseif ($_GET['action'] == 'deletealias')
264) {
265)   $title = "Subdomain löschen";
266)   $section = 'vhosts_vhosts';
267)   
268)   $alias = get_alias_details( (int) $_GET['alias'] );
269)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

271)   
272)   $vhost = get_vhost_details( $alias['vhost'] );
273)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

275)   
276)   $sure = user_is_sure();
277)   if ($sure === NULL)
278)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

280)   }
281)   elseif ($sure === true)
282)   {
283)     delete_alias($alias['id']);
284)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

286)   }
287)   elseif ($sure === false)
288)   {
289)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

291)   }
292) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

293) elseif ($_GET['action'] == 'delete')
294) {
bernd Aliases editieren

bernd authored 16 years ago

295)   $title = "Subdomain löschen";
296)   $section = 'vhosts_vhosts';
297)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

300)   
301)   $sure = user_is_sure();
302)   if ($sure === NULL)
303)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

305)   }
306)   elseif ($sure === true)
307)   {
308)     delete_vhost($vhost['id']);
309)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

311)   }
312)   elseif ($sure === false)
313)   {
314)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

315)       header("Location: vhosts");