da1ba0c3ad07288657d857ec093f6f2f362be1b6
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)   {
212)     if ($op != 'aliaswww')
213)       array_push($new_options, $op);
214)   }
215)   if ($aliaswww)
216)     array_push($new_options, 'aliaswww');
217) 
218)   DEBUG($old_options);
219)   DEBUG($new_options);
220)   $options = implode(',', $new_options);
221)   DEBUG('New options: '.$options);
222) 
223)   $vhost['hostname'] = $hostname;
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

225)   $vhost['docroot'] = $docroot;
226)   $vhost['php'] = $php;
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 11 years ago

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

239) 
240)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

242) 
243) }
bernd Aliases editieren

bernd authored 16 years ago

244) elseif ($_GET['action'] == 'addalias')
245) {
246)   check_form_token('vhosts_add_alias');
247)   $id = (int) $_GET['vhost'];
248)   $vhost = get_vhost_details( $id );
249)   DEBUG($vhost);
250) 
251)   $alias = empty_alias();
252)   $alias['vhost'] = $vhost['id'];
253) 
254)   
bernd Erlaube wildcards bei vhosts

bernd authored 13 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 9 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 9 years ago

262)   if ($domainid == -1) {
263)     # use configured user_vhosts_domain
264)     $userdomain = userdomain();
265)     $domain = new Domain( (int) $userdomain['id'] );
266)     $domainid = $domain->id;
267)     $hostname = $hostname.'.'.$_SESSION['userinfo']['username'];
268)     $hostname = trim($hostname, " .-");
269)   }
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

287)     
288)   $alias ['options'] = $options;
289)     
290)   save_alias($alias);
291) 
292)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

294) 
295) }
296) elseif ($_GET['action'] == 'deletealias')
297) {
298)   $title = "Subdomain löschen";
299)   $section = 'vhosts_vhosts';
300)   
301)   $alias = get_alias_details( (int) $_GET['alias'] );
302)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

304)   
305)   $vhost = get_vhost_details( $alias['vhost'] );
306)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

308)   
309)   $sure = user_is_sure();
310)   if ($sure === NULL)
311)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

313)   }
314)   elseif ($sure === true)
315)   {
316)     delete_alias($alias['id']);
317)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

319)   }
320)   elseif ($sure === false)
321)   {
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) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

326) elseif ($_GET['action'] == 'delete')
327) {
bernd Aliases editieren

bernd authored 16 years ago

328)   $title = "Subdomain löschen";
329)   $section = 'vhosts_vhosts';
330)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

333)   
334)   $sure = user_is_sure();
335)   if ($sure === NULL)
336)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

338)   }
339)   elseif ($sure === true)
340)   {
341)     delete_vhost($vhost['id']);
342)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

344)   }
345)   elseif ($sure === false)
346)   {
347)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

348)       header("Location: vhosts");