eaac3bfa85ad1b842a71a0e9b4b520791fdcea27
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 Lizenzinfos in eigenes Modu...

Bernd Wurst authored 10 years ago

5) Written 2008-2014 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 Wurst Zeige Userdomains nur noch...

Bernd Wurst authored 9 years ago

42)   $domainname = NULL;
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

43)   $domain_id = (int) $_POST['domain'];
Bernd Wurst Ermögliche dem user Hosts m...

Bernd Wurst authored 9 years ago

44)   if ($domain_id >= 0) {
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

47)     $domain_id = $domain->id;
Bernd Wurst Zeige Userdomains nur noch...

Bernd Wurst authored 9 years ago

48)     $domainname = $domain->fqdn;
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

49)   }
Bernd Wurst Zeige Userdomains nur noch...

Bernd Wurst authored 9 years ago

50)   elseif ($domain_id == -1) {
Bernd Wurst Ermögliche dem user Hosts m...

Bernd Wurst authored 9 years ago

51)     # use configured user_vhosts_domain
52)     $userdomain = userdomain();
53)     $domain = new Domain( (int) $userdomain['id'] );
54)     $domain_id = $domain->id;
Bernd Wurst Zeige Userdomains nur noch...

Bernd Wurst authored 9 years ago

55)     $domainname = $domain->fqdn;
Bernd Wurst Ermögliche dem user Hosts m...

Bernd Wurst authored 9 years ago

56)     $hostname = $hostname.'.'.$_SESSION['userinfo']['username'];
57)     $hostname = trim($hostname, " .-");
58)   }
Bernd Wurst Zeige Userdomains nur noch...

Bernd Wurst authored 9 years ago

59)   elseif ($domain_id == -2) {
60)     # use system masterdomain
61)     $domainname = $_SESSION['userinfo']['username'].".".config('masterdomain');
62)   }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

65)     $_POST['options'] = array();
66)   $aliaswww = in_array('aliaswww', $_POST['options']);
67) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

70)   {
Bernd Wurst Zeige Userdomains nur noch...

Bernd Wurst authored 9 years ago

71)     $defaultdocroot = $vhost['homedir'].'/websites/'.((strlen($hostname) > 0) ? $hostname.'.' : '').($domainname).'/htdocs';
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

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

bernd authored 14 years ago

73)     $docroot = '';
74)     if (isset($_POST['docroot']))
75)     {
76)       if (! check_path( $_POST['docroot'] ))
77)         system_failure("Eingegebener Pfad enthält ungültige Angaben");
78)       $docroot = $vhost['homedir'].'/websites/'.$_POST['docroot'];
79)     }
80)     if ((isset($_POST['use_default_docroot']) && $_POST['use_default_docroot'] == '1') || ($docroot == $defaultdocroot)) {
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

81)       $docroot = NULL;
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

82)     }
83)   
84)     DEBUG("Document-Root: ".$docroot);
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

85)   }
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

86)   $php = NULL;
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

89)     switch ($_POST['php']) {
Bernd Wurst prepare for experimental PH...

Bernd Wurst authored 12 years ago

90)       case 'php54':
91)         $php = 'php54';
92)         break;
Hanno Böck übrige Änderungen für php55

Hanno Böck authored 10 years ago

93)       case 'php55':
94)         $php = 'php55';
95)         break;
Bernd Wurst PHP 5.6 experimentell

Bernd Wurst authored 9 years ago

96)       case 'php56':
97)         $php = 'php56';
98)         break;
Hanno Böck PHP 7.0 support

Hanno Böck authored 8 years ago

99)       case 'php70':
100)         $php = 'php70';
101)         break;
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

102)       /* Wenn etwas anderes kommt, ist das "kein PHP". So einfach ist das. */
103)     }
104)   }
bernd "CGI-Aktivieren" ist jetzt...

bernd authored 13 years ago

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

bernd authored 14 years ago

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

bernd authored 13 years ago

108)     $cgi = 0;
bernd CGI abschaltbar

bernd authored 14 years ago

109)   }
110) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

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

Bernd Wurst authored 11 years ago

114)   if (isset($_POST['server']))
115)     $vhost['server'] = $_POST['server'];
116) 
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

117)   if ($_POST['vhost_type'] == 'regular') {
118)     $vhost['is_dav'] = 0;
119)     $vhost['is_svn'] = 0;
120)     $vhost['is_webapp'] = 0;
121)   }
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

122)   elseif ($_POST['vhost_type'] == 'dav') {
123)     $vhost['is_dav'] = 1;
124)     $vhost['is_svn'] = 0;
125)     $vhost['is_webapp'] = 0;
126)   }
127)   elseif ($_POST['vhost_type'] == 'svn') {
128)     $vhost['is_dav'] = 0;
129)     $vhost['is_svn'] = 1;
130)     $vhost['is_webapp'] = 0;
131)   }
132)   elseif ($_POST['vhost_type'] == 'webapp') {
133)     $vhost['is_dav'] = 0;
134)     $vhost['is_svn'] = 0;
135)     $vhost['is_webapp'] = 1;
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

137)   }
138) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

139)   
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

140)   $ssl = NULL;
bernd SSL auch über webinterface...

bernd authored 16 years ago

141)   switch ($_POST['ssl']) {
142)     case 'http':
143)       $ssl = 'http';
144)       break;
145)     case 'https':
146)       $ssl = 'https';
147)       break;
148)     case 'forward':
149)       $ssl = 'forward';
150)       break;
151)     /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
152)   }
153) 
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

154)   $hsts = NULL;
155)   if (isset($_POST['hsts'])) {
156)     if (is_numeric($_POST['hsts']) && (int) $_POST['hsts'] > -2) {
157)       $hsts = (int) $_POST['hsts'];
158)     } else {
159)       system_failure('Es wurde ein ungültiger HSTS-Wert eingegeben. Dort sind nur Sekunden erlaubt.');
160)     }
161)   }
162)  
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

164) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

166) 
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

170)     if (isset($_POST['ipv6_separate']) && $_POST['ipv6_separate'] = 'yes')
171)     {
172)       $vhost['autoipv6'] = 2;
173)     }
bernd IPv6

bernd authored 14 years ago

174)   } else {
175)     $vhost['autoipv6'] = 0;
176)   }
177)   
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

179)   $logtype = '';
180)   switch ($_POST['logtype']) {
181)     case 'anonymous':
182)       $logtype = 'anonymous';
183)       break;
184)     case 'default':
185)       $logtype = 'default';
186)       break;
187)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
188)   }
189) 
bernd error_log konfigurierbar

bernd authored 16 years ago

190)   $errorlog = 0;
191)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
192)     $errorlog = 1;
193) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

194) 
195)   if (isset($_POST['stats']) && $_POST['stats'] == 1)
196)   {
197)     if ($vhost['stats'] == NULL)
198)       $vhost['stats'] = 'private';
199)   }
200)   else
201)     $vhost['stats'] = NULL;
202) 
203)   if ($logtype == '')
204)     $vhost['stats'] = NULL;
205)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

206)   DEBUG("PHP: {$php} / Logging: {$logtype}");
207) 
208)   $old_options = explode(',', $vhost['options']);
209)   $new_options = array();
210)   foreach ($old_options AS $op)
211)   {
Bernd Wurst * Ermögliche SAN bei CSRs *...

Bernd Wurst authored 8 years ago

212)     if ($op != 'aliaswww') {
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

213)       array_push($new_options, $op);
Bernd Wurst * Ermögliche SAN bei CSRs *...

Bernd Wurst authored 8 years ago

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

bernd authored 16 years ago

215)   }
Bernd Wurst * Ermögliche SAN bei CSRs *...

Bernd Wurst authored 8 years ago

216)   if ($aliaswww){
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

217)     array_push($new_options, 'aliaswww');
Bernd Wurst * Ermögliche SAN bei CSRs *...

Bernd Wurst authored 8 years ago

218)   }
219)   if ($cert == -1) {
220)     array_push($new_options, 'letsencrypt');
221)   }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

222) 
223)   DEBUG($old_options);
224)   DEBUG($new_options);
225)   $options = implode(',', $new_options);
226)   DEBUG('New options: '.$options);
227) 
228)   $vhost['hostname'] = $hostname;
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

230)   $vhost['docroot'] = $docroot;
231)   $vhost['php'] = $php;
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

233)   $vhost['ssl'] = $ssl;
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

234)   $vhost['hsts'] = $hsts;
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 11 years ago

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

244) 
245)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

247) 
248) }
bernd Aliases editieren

bernd authored 16 years ago

249) elseif ($_GET['action'] == 'addalias')
250) {
251)   check_form_token('vhosts_add_alias');
252)   $id = (int) $_GET['vhost'];
253)   $vhost = get_vhost_details( $id );
254)   DEBUG($vhost);
255) 
256)   $alias = empty_alias();
257)   $alias['vhost'] = $vhost['id'];
258) 
259)   
bernd Erlaube wildcards bei vhosts

bernd authored 13 years ago

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

bernd authored 16 years ago

261)   $domainid = (int) $_POST['domain'];
Bernd Wurst Ermögliche dem user Hosts m...

Bernd Wurst authored 9 years ago

262)   if ($domainid >= 0) {
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

265)     $domainid = $domain->id;
266)   }
Bernd Wurst Ermögliche dem user Hosts m...

Bernd Wurst authored 9 years ago

267)   if ($domainid == -1) {
268)     # use configured user_vhosts_domain
269)     $userdomain = userdomain();
270)     $domain = new Domain( (int) $userdomain['id'] );
271)     $domainid = $domain->id;
272)     $hostname = $hostname.'.'.$_SESSION['userinfo']['username'];
273)     $hostname = trim($hostname, " .-");
274)   }
bernd Aliases editieren

bernd authored 16 years ago

275) 
276)   if (! is_array($_POST['options']))
277)     $_POST['options'] = array();
278)   $aliaswww = in_array('aliaswww', $_POST['options']);
279)   $forward = in_array('forward', $_POST['options']);
280) 
281)   $new_options = array();
282)   if ($aliaswww)
283)     array_push($new_options, 'aliaswww');
284)   if ($forward)
285)     array_push($new_options, 'forward');
286)   DEBUG($new_options);
287)   $options = implode(',', $new_options);
288)   DEBUG('New options: '.$options);
289) 
290)   $alias['hostname'] = $hostname;
bernd domainid -> domain_id, fies...

bernd authored 14 years ago

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

bernd authored 16 years ago

292)     
293)   $alias ['options'] = $options;
294)     
295)   save_alias($alias);
296) 
297)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

299) 
300) }
301) elseif ($_GET['action'] == 'deletealias')
302) {
303)   $title = "Subdomain löschen";
304)   $section = 'vhosts_vhosts';
305)   
306)   $alias = get_alias_details( (int) $_GET['alias'] );
307)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

309)   
310)   $vhost = get_vhost_details( $alias['vhost'] );
311)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

313)   
314)   $sure = user_is_sure();
315)   if ($sure === NULL)
316)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

318)   }
319)   elseif ($sure === true)
320)   {
321)     delete_alias($alias['id']);
322)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

324)   }
325)   elseif ($sure === false)
326)   {
327)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

329)   }
330) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

331) elseif ($_GET['action'] == 'delete')
332) {
bernd Aliases editieren

bernd authored 16 years ago

333)   $title = "Subdomain löschen";
334)   $section = 'vhosts_vhosts';
335)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

338)   
339)   $sure = user_is_sure();
340)   if ($sure === NULL)
341)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

343)   }
344)   elseif ($sure === true)
345)   {
346)     delete_vhost($vhost['id']);
347)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

349)   }
350)   elseif ($sure === false)
351)   {
352)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

353)       header("Location: vhosts");