c5d2cce4e811f132e62a23edeb8426918ae1ce62
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 14 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;
Hanno Böck übrige Änderungen für php55

Hanno Böck authored 10 years ago

87)       case 'php55':
88)         $php = 'php55';
89)         break;
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

90)       /* Wenn etwas anderes kommt, ist das "kein PHP". So einfach ist das. */
91)     }
92)   }
bernd "CGI-Aktivieren" ist jetzt...

bernd authored 13 years ago

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

bernd authored 14 years ago

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

bernd authored 13 years ago

96)     $cgi = 0;
bernd CGI abschaltbar

bernd authored 14 years ago

97)   }
98) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

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

Bernd Wurst authored 11 years ago

102)   if (isset($_POST['server']))
103)     $vhost['server'] = $_POST['server'];
104) 
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

125)   }
126) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

127)   
bernd SSL auch über webinterface...

bernd authored 16 years ago

128)   $ssl = '';
129)   switch ($_POST['ssl']) {
130)     case 'http':
131)       $ssl = 'http';
132)       break;
133)     case 'https':
134)       $ssl = 'https';
135)       break;
136)     case 'forward':
137)       $ssl = 'forward';
138)       break;
139)     /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
140)   }
141) 
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

142)   $hsts = NULL;
143)   if (isset($_POST['hsts'])) {
144)     if (is_numeric($_POST['hsts']) && (int) $_POST['hsts'] > -2) {
145)       $hsts = (int) $_POST['hsts'];
146)     } else {
147)       system_failure('Es wurde ein ungültiger HSTS-Wert eingegeben. Dort sind nur Sekunden erlaubt.');
148)     }
149)   }
150)  
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

152) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

154) 
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

158)     if (isset($_POST['ipv6_separate']) && $_POST['ipv6_separate'] = 'yes')
159)     {
160)       $vhost['autoipv6'] = 2;
161)     }
bernd IPv6

bernd authored 14 years ago

162)   } else {
163)     $vhost['autoipv6'] = 0;
164)   }
165)   
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

167)   $logtype = '';
168)   switch ($_POST['logtype']) {
169)     case 'anonymous':
170)       $logtype = 'anonymous';
171)       break;
172)     case 'default':
173)       $logtype = 'default';
174)       break;
175)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
176)   }
177) 
bernd error_log konfigurierbar

bernd authored 16 years ago

178)   $errorlog = 0;
179)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
180)     $errorlog = 1;
181) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

182) 
183)   if (isset($_POST['stats']) && $_POST['stats'] == 1)
184)   {
185)     if ($vhost['stats'] == NULL)
186)       $vhost['stats'] = 'private';
187)   }
188)   else
189)     $vhost['stats'] = NULL;
190) 
191)   if ($logtype == '')
192)     $vhost['stats'] = NULL;
193)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

194)   DEBUG("PHP: {$php} / Logging: {$logtype}");
195) 
196)   $old_options = explode(',', $vhost['options']);
197)   $new_options = array();
198)   foreach ($old_options AS $op)
199)   {
200)     if ($op != 'aliaswww')
201)       array_push($new_options, $op);
202)   }
203)   if ($aliaswww)
204)     array_push($new_options, 'aliaswww');
205) 
206)   DEBUG($old_options);
207)   DEBUG($new_options);
208)   $options = implode(',', $new_options);
209)   DEBUG('New options: '.$options);
210) 
211)   $vhost['hostname'] = $hostname;
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

213)   $vhost['docroot'] = $docroot;
214)   $vhost['php'] = $php;
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 11 years ago

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

227) 
228)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

230) 
231) }
bernd Aliases editieren

bernd authored 16 years ago

232) elseif ($_GET['action'] == 'addalias')
233) {
234)   check_form_token('vhosts_add_alias');
235)   $id = (int) $_GET['vhost'];
236)   $vhost = get_vhost_details( $id );
237)   DEBUG($vhost);
238) 
239)   $alias = empty_alias();
240)   $alias['vhost'] = $vhost['id'];
241) 
242)   
bernd Erlaube wildcards bei vhosts

bernd authored 13 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

248)     $domainid = $domain->id;
249)   }
bernd Aliases editieren

bernd authored 16 years ago

250) 
251)   if (! is_array($_POST['options']))
252)     $_POST['options'] = array();
253)   $aliaswww = in_array('aliaswww', $_POST['options']);
254)   $forward = in_array('forward', $_POST['options']);
255) 
256)   $new_options = array();
257)   if ($aliaswww)
258)     array_push($new_options, 'aliaswww');
259)   if ($forward)
260)     array_push($new_options, 'forward');
261)   DEBUG($new_options);
262)   $options = implode(',', $new_options);
263)   DEBUG('New options: '.$options);
264) 
265)   $alias['hostname'] = $hostname;
bernd domainid -> domain_id, fies...

bernd authored 14 years ago

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

bernd authored 16 years ago

267)     
268)   $alias ['options'] = $options;
269)     
270)   save_alias($alias);
271) 
272)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

274) 
275) }
276) elseif ($_GET['action'] == 'deletealias')
277) {
278)   $title = "Subdomain löschen";
279)   $section = 'vhosts_vhosts';
280)   
281)   $alias = get_alias_details( (int) $_GET['alias'] );
282)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

284)   
285)   $vhost = get_vhost_details( $alias['vhost'] );
286)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

288)   
289)   $sure = user_is_sure();
290)   if ($sure === NULL)
291)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

293)   }
294)   elseif ($sure === true)
295)   {
296)     delete_alias($alias['id']);
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)   elseif ($sure === false)
301)   {
302)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

304)   }
305) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

306) elseif ($_GET['action'] == 'delete')
307) {
bernd Aliases editieren

bernd authored 16 years ago

308)   $title = "Subdomain löschen";
309)   $section = 'vhosts_vhosts';
310)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

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=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

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

bernd authored 15 years ago

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

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: vhosts");