0c8b89b37a5e6f130274744d594a081052113b33
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;
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

99)       /* Wenn etwas anderes kommt, ist das "kein PHP". So einfach ist das. */
100)     }
101)   }
bernd "CGI-Aktivieren" ist jetzt...

bernd authored 13 years ago

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

bernd authored 14 years ago

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

bernd authored 13 years ago

105)     $cgi = 0;
bernd CGI abschaltbar

bernd authored 14 years ago

106)   }
107) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

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

Bernd Wurst authored 11 years ago

111)   if (isset($_POST['server']))
112)     $vhost['server'] = $_POST['server'];
113) 
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

134)   }
135) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

161) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

163) 
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

167)     if (isset($_POST['ipv6_separate']) && $_POST['ipv6_separate'] = 'yes')
168)     {
169)       $vhost['autoipv6'] = 2;
170)     }
bernd IPv6

bernd authored 14 years ago

171)   } else {
172)     $vhost['autoipv6'] = 0;
173)   }
174)   
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

187)   $errorlog = 0;
188)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
189)     $errorlog = 1;
190) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

203)   DEBUG("PHP: {$php} / Logging: {$logtype}");
204) 
205)   $old_options = explode(',', $vhost['options']);
206)   $new_options = array();
207)   foreach ($old_options AS $op)
208)   {
209)     if ($op != 'aliaswww')
210)       array_push($new_options, $op);
211)   }
212)   if ($aliaswww)
213)     array_push($new_options, 'aliaswww');
214) 
215)   DEBUG($old_options);
216)   DEBUG($new_options);
217)   $options = implode(',', $new_options);
218)   DEBUG('New options: '.$options);
219) 
220)   $vhost['hostname'] = $hostname;
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

222)   $vhost['docroot'] = $docroot;
223)   $vhost['php'] = $php;
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 11 years ago

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

236) 
237)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

239) 
240) }
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 13 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 9 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 9 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

284)     
285)   $alias ['options'] = $options;
286)     
287)   save_alias($alias);
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) }
293) elseif ($_GET['action'] == 'deletealias')
294) {
295)   $title = "Subdomain löschen";
296)   $section = 'vhosts_vhosts';
297)   
298)   $alias = get_alias_details( (int) $_GET['alias'] );
299)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

301)   
302)   $vhost = get_vhost_details( $alias['vhost'] );
303)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

305)   
306)   $sure = user_is_sure();
307)   if ($sure === NULL)
308)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

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

bernd authored 15 years ago

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

bernd authored 16 years ago

316)   }
317)   elseif ($sure === false)
318)   {
319)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

321)   }
322) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

323) elseif ($_GET['action'] == 'delete')
324) {
bernd Aliases editieren

bernd authored 16 years ago

325)   $title = "Subdomain löschen";
326)   $section = 'vhosts_vhosts';
327)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

330)   
331)   $sure = user_is_sure();
332)   if ($sure === NULL)
333)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

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

bernd authored 15 years ago

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

bernd authored 16 years ago

341)   }
342)   elseif ($sure === false)
343)   {
344)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

345)       header("Location: vhosts");