96649f21ba18d07757afa9d98998f7a22c0d86a3
bernd Webapp-Installer, erste Ver...

bernd authored 15 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 Copyright year update

Bernd Wurst authored 6 years ago

5) Written 2008-2018 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) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

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 Webapp-Installer, erste Ver...

bernd authored 15 years ago

16) 
17) require_once('inc/security.php');
18) 
19) require_once('modules/vhosts/include/vhosts.php');
20) require_once('class/domain.php');
21) 
22) $url = '';
23) $docroot = '';
24) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

25) if ($_POST['target'] == 'new') {
26)     check_form_token('webapp_install');
27)     $vhost = empty_vhost();
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

28) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

29)     $hostname = filter_input_hostname($_POST['hostname']);
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

30) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

31)     $domainid = (int) $_POST['domain'];
32)     $domainname = null;
33)     if ($domainid != -1) {
34)         $domain = new Domain((int) $_POST['domain']);
35)         $domain->ensure_userdomain();
36)         $domainid = $domain->id;
37)         $domainname = $domain->fqdn;
38)     }
39)     DEBUG('Domain: '.$domainid.' / '.$domainname);
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

40) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

41)     if (! isset($_POST['options']) || ! is_array($_POST['options'])) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

42)         $_POST['options'] = [];
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

43)     }
44)     $aliaswww = in_array('aliaswww', $_POST['options']);
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

45) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

46)     $vhost['is_dav'] = 0;
47)     $vhost['is_svn'] = 0;
48)     $vhost['is_webapp'] = 0;
Hanno remove whitespace in empty...

Hanno authored 5 years ago

49) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

50)     $ssl = '';
51)     switch ($_POST['ssl']) {
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

52)     case 'http':
53)       $ssl = 'http';
54)       break;
55)     case 'https':
56)       $ssl = 'https';
57)       break;
58)     case 'forward':
59)       $ssl = 'forward';
60)       break;
61)     /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
62)   }
63) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

64)     $logtype = '';
65)     switch ($_POST['logtype']) {
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

66)     case 'anonymous':
67)       $logtype = 'anonymous';
68)       break;
69)     case 'default':
70)       $logtype = 'default';
71)       break;
72)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
73)   }
74) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

75)     $errorlog = 0;
76)     if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1)) {
77)         $errorlog = 1;
78)     }
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

79) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

80)     DEBUG("Logging: {$logtype}");
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

81) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

82)     $old_options = explode(',', $vhost['options']);
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 2 years ago

83)     $new_options = [];
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

84)     foreach ($old_options as $op) {
85)         if ($op != 'aliaswww') {
86)             array_push($new_options, $op);
87)         }
88)     }
89)     if ($aliaswww) {
90)         array_push($new_options, 'aliaswww');
91)     }
92) 
93)     DEBUG($old_options);
94)     DEBUG($new_options);
95)     $options = implode(',', $new_options);
96)     DEBUG('New options: '.$options);
97) 
98)     $vhost['hostname'] = $hostname;
99)     $vhost['domain_id'] = $domainid;
100)     $vhost['domain'] = $domainname;
101)     $vhost['docroot'] = '';
102)     $vhost['php'] = 'php56';
103)     $vhost['ssl'] = $ssl;
104)     $vhost['logtype'] = $logtype;
105)     $vhost['errorlog'] = $errorlog;
106)     $vhost['options'] = $options;
Hanno remove whitespace in empty...

Hanno authored 5 years ago

107) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

108)     $domain = $domainname;
109)     if ($domainid == -1) {
110)         $domain = $_SESSION['userinfo']['username'].'.'.config('masterdomain');
111)     }
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

112) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

113)     $url = ($ssl == 'forward' || $ssl == 'https' ? 'https://' : 'http://').($aliaswww ? 'www.' : '').((strlen($hostname) > 0) ? $hostname.'.' : '').$domain;
114)     $docroot = $vhost['homedir'].'/websites/'.((strlen($hostname) > 0) ? $hostname.'.' : '').($domain).'/htdocs';
115)     DEBUG($vhost);
116)     DEBUG("New Vhost: {$url} / {$docroot}");
117)     save_vhost($vhost);
118) } elseif ($_POST['target'] == 'vhost') {
119)     $docroot = $_POST['vhost'];
120) 
121)     $vhosts = list_vhosts();
122)     foreach ($vhosts as $vhost) {
123)         if ($docroot == $vhost['docroot']) {
124)             $url = $vhost['fqdn'];
125)             if (strstr($vhost['options'], 'aliaswww')) {
126)                 $url = 'www.'.$url;
127)             }
128) 
129)             if ($vhost['ssl'] == 'forward' || $vhost['ssl'] == 'https') {
130)                 $url = 'https://'.$url;
131)             } else {
132)                 $url = 'http://'.$url;
133)             }
134)         }
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

135)     }
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

136)     if (! $url) {
137)         system_failure('Datenchaos, so geht das nicht.');
138)     }
139)     DEBUG("Existing Vhost: {$url} / {$docroot}");
140) } else {
141)     input_error('Fehler im System');
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

142) }
143) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

144) if ($docroot && $url) {
145)     $application = $_POST['application'];
146)     if (! $application) {
147)         system_failure('Keine Web-Anwendung ausgewählt');
148)     }
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

149) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

150)     if (! check_path($application)) {
151)         system_failure('HTML-Krams im Namen der Anwendung');
152)     }
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

153) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

154)     if (! file_exists(dirname(__FILE__).'/install/'.$application.'.php')) {
155)         system_failure('Unbekannte Web-Anwendung.');
156)     }
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

157) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

158)     $_SESSION['webapp_docroot'] = $docroot;
159)     $_SESSION['webapp_url'] = $url;
Hanno remove whitespace in empty...

Hanno authored 5 years ago

160) 
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

161)     if (!$debugmode) {
162)         header('Location: install/'.$application);
163)     }