354c05a4ddd678c49bcbba458bffa7d13482139a
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) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 1 year ago

5) Written 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) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 1 year ago

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

Bernd Wurst authored 12 years ago

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

bernd authored 15 years ago

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

Hanno authored 5 years ago

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

bernd authored 15 years ago

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

Hanno authored 5 years ago

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

bernd authored 15 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 6 months ago

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

bernd authored 15 years ago

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

Hanno Böck authored 6 months ago

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

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

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

bernd authored 15 years ago

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

Hanno authored 5 years ago

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

Hanno authored 5 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 1 year ago

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

bernd authored 15 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 1 year ago

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

bernd authored 15 years ago

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

Hanno authored 5 years ago

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

bernd authored 15 years ago

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

Hanno authored 5 years ago

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

bernd authored 15 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 2 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 6 months ago

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

Hanno authored 5 years ago

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

Hanno authored 5 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 6 months ago

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

Hanno authored 5 years ago

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

bernd authored 15 years ago

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

Hanno Böck authored 6 months ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 6 months ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 6 months ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 6 months ago

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

Hanno authored 5 years ago

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

bernd authored 15 years ago

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

Hanno Böck authored 6 months ago

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

Hanno authored 5 years ago

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

bernd authored 15 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 6 months ago

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

Hanno authored 5 years ago

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

bernd authored 15 years ago

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

Hanno Böck authored 6 months ago

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

Hanno authored 5 years ago

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

bernd authored 15 years ago

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

Hanno Böck authored 6 months ago

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

Hanno authored 5 years ago

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

bernd authored 15 years ago

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

Hanno authored 5 years ago

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

Hanno authored 5 years ago

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

Hanno authored 5 years ago

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

Hanno Böck authored 6 months ago

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

Hanno authored 5 years ago

160)     }