7ae33deebfbf80fde9235c3cea37c80930fe1f77
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)     }
36)     DEBUG('Domain: '.$domainid.' / '.$domainname);
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

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

Hanno authored 5 years 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);
93)     DEBUG('New options: '.$options);
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) {
107)         $domain = $_SESSION['userinfo']['username'].'.'.config('masterdomain');
108)     }
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

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

Hanno authored 5 years 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';
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')) {
123)                 $url = 'www.'.$url;
124)             }
125) 
126)             if ($vhost['ssl'] == 'forward' || $vhost['ssl'] == 'https') {
127)                 $url = 'https://'.$url;
128)             } else {
129)                 $url = 'http://'.$url;
130)             }
131)         }
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

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

Hanno authored 5 years ago

133)     if (! $url) {
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'];
143)     if (! $application) {
144)         system_failure('Keine Web-Anwendung ausgewählt');
145)     }
bernd Webapp-Installer, erste Ver...

bernd authored 15 years ago

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

Hanno authored 5 years ago

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

bernd authored 15 years ago

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

Hanno authored 5 years ago

151)     if (! file_exists(dirname(__FILE__).'/install/'.$application.'.php')) {
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) {
159)         header('Location: install/'.$application);
160)     }