3ef995c2108fe77d22c0b556fb9717cb848bc48f
bernd Webapp-Installer, erste Ver...

bernd authored 17 years ago

1) <?php
Hanno Böck Add newlines before comment...

Hanno Böck authored 1 year ago

2) 
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 14 years ago

3) /*
4) This file belongs to the Webinterface of schokokeks.org Hosting
5) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 3 years ago

6) Written by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 14 years ago

7)   Bernd Wurst <bernd@schokokeks.org>
8)   Hanno Böck <hanno@schokokeks.org>
9) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 3 years ago

10) This code is published under a 0BSD license.
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 14 years ago

11) 
12) 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.
13) */
bernd Webapp-Installer, erste Ver...

bernd authored 17 years ago

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

Hanno authored 7 years ago

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

bernd authored 17 years ago

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

Hanno authored 7 years ago

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

bernd authored 17 years ago

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

Hanno authored 7 years ago

29)     $domainid = (int) $_POST['domain'];
30)     $domainname = null;
31)     if ($domainid != -1) {
32)         $domain = new Domain((int) $_POST['domain']);
33)         $domain->ensure_userdomain();
34)         $domainid = $domain->id;
35)         $domainname = $domain->fqdn;
36)     }
Hanno Böck Spaces between string conca...

Hanno Böck authored 2 years ago

37)     DEBUG('Domain: ' . $domainid . ' / ' . $domainname);
bernd Webapp-Installer, erste Ver...

bernd authored 17 years ago

38) 
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 2 years ago

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

Hanno Böck authored 4 years ago

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

Hanno authored 7 years ago

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

bernd authored 17 years ago

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

Hanno authored 7 years ago

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

Hanno authored 7 years ago

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

Hanno authored 7 years ago

48)     $ssl = '';
49)     switch ($_POST['ssl']) {
Hanno Böck more strict codingstyle wit...

Hanno Böck authored 3 years ago

50)         case 'http':
51)             $ssl = 'http';
52)             break;
53)         case 'https':
54)             $ssl = 'https';
55)             break;
56)         case 'forward':
57)             $ssl = 'forward';
58)             break;
59)             /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
60)     }
bernd Webapp-Installer, erste Ver...

bernd authored 17 years ago

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

Hanno authored 7 years ago

62)     $logtype = '';
63)     switch ($_POST['logtype']) {
Hanno Böck more strict codingstyle wit...

Hanno Böck authored 3 years ago

64)         case 'anonymous':
65)             $logtype = 'anonymous';
66)             break;
67)         case 'default':
68)             $logtype = 'default';
69)             break;
70)             /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
71)     }
bernd Webapp-Installer, erste Ver...

bernd authored 17 years ago

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

Hanno authored 7 years ago

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

bernd authored 17 years ago

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

Hanno authored 7 years ago

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

bernd authored 17 years ago

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

Hanno authored 7 years ago

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

Hanno Böck authored 4 years ago

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

Hanno authored 7 years ago

82)     foreach ($old_options as $op) {
83)         if ($op != 'aliaswww') {
84)             array_push($new_options, $op);
85)         }
86)     }
87)     if ($aliaswww) {
88)         array_push($new_options, 'aliaswww');
89)     }
90) 
91)     DEBUG($old_options);
92)     DEBUG($new_options);
93)     $options = implode(',', $new_options);
Hanno Böck Spaces between string conca...

Hanno Böck authored 2 years ago

94)     DEBUG('New options: ' . $options);
Hanno Fix coding style with php-c...

Hanno authored 7 years ago

95) 
96)     $vhost['hostname'] = $hostname;
97)     $vhost['domain_id'] = $domainid;
98)     $vhost['domain'] = $domainname;
99)     $vhost['docroot'] = '';
100)     $vhost['php'] = 'php56';
101)     $vhost['ssl'] = $ssl;
102)     $vhost['logtype'] = $logtype;
103)     $vhost['errorlog'] = $errorlog;
104)     $vhost['options'] = $options;
Hanno remove whitespace in empty...

Hanno authored 7 years ago

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

Hanno authored 7 years ago

106)     $domain = $domainname;
107)     if ($domainid == -1) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 2 years ago

108)         $domain = $_SESSION['userinfo']['username'] . '.' . config('masterdomain');
Hanno Fix coding style with php-c...

Hanno authored 7 years ago

109)     }
bernd Webapp-Installer, erste Ver...

bernd authored 17 years ago

110) 
Hanno Böck Spaces between string conca...

Hanno Böck authored 2 years ago

111)     $url = ($ssl == 'forward' || $ssl == 'https' ? 'https://' : 'http://') . ($aliaswww ? 'www.' : '') . ((strlen($hostname) > 0) ? $hostname . '.' : '') . $domain;
112)     $docroot = $vhost['homedir'] . '/websites/' . ((strlen($hostname) > 0) ? $hostname . '.' : '') . ($domain) . '/htdocs';
Hanno Fix coding style with php-c...

Hanno authored 7 years ago

113)     DEBUG($vhost);
114)     DEBUG("New Vhost: {$url} / {$docroot}");
115)     save_vhost($vhost);
116) } elseif ($_POST['target'] == 'vhost') {
117)     $docroot = $_POST['vhost'];
118) 
119)     $vhosts = list_vhosts();
120)     foreach ($vhosts as $vhost) {
121)         if ($docroot == $vhost['docroot']) {
122)             $url = $vhost['fqdn'];
123)             if (strstr($vhost['options'], 'aliaswww')) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 2 years ago

124)                 $url = 'www.' . $url;
Hanno Fix coding style with php-c...

Hanno authored 7 years ago

125)             }
126) 
127)             if ($vhost['ssl'] == 'forward' || $vhost['ssl'] == 'https') {
Hanno Böck Spaces between string conca...

Hanno Böck authored 2 years ago

128)                 $url = 'https://' . $url;
Hanno Fix coding style with php-c...

Hanno authored 7 years ago

129)             } else {
Hanno Böck Spaces between string conca...

Hanno Böck authored 2 years ago

130)                 $url = 'http://' . $url;
Hanno Fix coding style with php-c...

Hanno authored 7 years ago

131)             }
132)         }
bernd Webapp-Installer, erste Ver...

bernd authored 17 years ago

133)     }
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 2 years ago

134)     if (!$url) {
Hanno Fix coding style with php-c...

Hanno authored 7 years ago

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

bernd authored 17 years ago

140) }
141) 
Hanno Fix coding style with php-c...

Hanno authored 7 years ago

142) if ($docroot && $url) {
143)     $application = $_POST['application'];
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 2 years ago

144)     if (!$application) {
Hanno Fix coding style with php-c...

Hanno authored 7 years ago

145)         system_failure('Keine Web-Anwendung ausgewählt');
146)     }
bernd Webapp-Installer, erste Ver...

bernd authored 17 years ago

147) 
Hanno Böck Fix not operator (!) spaces

Hanno Böck authored 2 years ago

148)     if (!check_path($application)) {
Hanno Fix coding style with php-c...

Hanno authored 7 years ago

149)         system_failure('HTML-Krams im Namen der Anwendung');
150)     }
bernd Webapp-Installer, erste Ver...

bernd authored 17 years ago

151) 
Hanno Böck Spaces between string conca...

Hanno Böck authored 2 years ago

152)     if (!file_exists(dirname(__FILE__) . '/install/' . $application . '.php')) {
Hanno Fix coding style with php-c...

Hanno authored 7 years ago

153)         system_failure('Unbekannte Web-Anwendung.');
154)     }
bernd Webapp-Installer, erste Ver...

bernd authored 17 years ago

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

Hanno authored 7 years ago

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

Hanno authored 7 years ago

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

Hanno authored 7 years ago

159)     if (!$debugmode) {
Hanno Böck Spaces between string conca...

Hanno Böck authored 2 years ago

160)         header('Location: install/' . $application);
Hanno Fix coding style with php-c...

Hanno authored 7 years ago

161)     }