359af7b0e9693caa4ed8488f78d262f1e41e15ca
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 fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

143) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

145) 
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

149)     if (isset($_POST['ipv6_separate']) && $_POST['ipv6_separate'] = 'yes')
150)     {
151)       $vhost['autoipv6'] = 2;
152)     }
bernd IPv6

bernd authored 14 years ago

153)   } else {
154)     $vhost['autoipv6'] = 0;
155)   }
156)   
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

169)   $errorlog = 0;
170)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
171)     $errorlog = 1;
172) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

204)   $vhost['docroot'] = $docroot;
205)   $vhost['php'] = $php;
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 11 years ago

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

217) 
218)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

220) 
221) }
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 13 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

238)     $domainid = $domain->id;
239)   }
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

257)     
258)   $alias ['options'] = $options;
259)     
260)   save_alias($alias);
261) 
262)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

274)   
275)   $vhost = get_vhost_details( $alias['vhost'] );
276)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

278)   
279)   $sure = user_is_sure();
280)   if ($sure === NULL)
281)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

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

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

296) elseif ($_GET['action'] == 'delete')
297) {
bernd Aliases editieren

bernd authored 16 years ago

298)   $title = "Subdomain löschen";
299)   $section = 'vhosts_vhosts';
300)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 15 years ago

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

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

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 15 years ago

318)       header("Location: vhosts");