1aaaa700cdfda9c1e0bd92741205d07d8e0132de
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

1) <?php
2) 
3) require_once('session/start.php');
4) 
5) require_once('vhosts.php');
6) 
7) require_once('inc/security.php');
8) require_once('class/domain.php');
9) 
10) require_role(ROLE_SYSTEMUSER);
11) 
12) require_once("inc/debug.php");
13) global $debugmode;
14) 
15) 
16) if ($_GET['action'] == 'edit')
17) {
18)   check_form_token('vhosts_edit_vhost');
19)   $id = (int) $_GET['vhost'];
20)   $vhost = empty_vhost();
21)   if ($id != 0)
22)     $vhost = get_vhost_details( $id );
23)   DEBUG($vhost);
24) 
bernd Erlaube wildcards bei vhosts

bernd authored 13 years ago

25)   $hostname = filter_input_hostname($_POST['hostname'], true);
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

26) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

27)   $domain_id = (int) $_POST['domain'];
28)   if ($domain_id != -1) {
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

29)     $domain = new Domain( (int) $_POST['domain'] );
bernd Mehr config-optionen und co...

bernd authored 14 years ago

30)     $domain->ensure_userdomain();
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

31)     $domain_id = $domain->id;
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

32)   }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

33) 
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

34)   if (! (isset($_POST['options']) && is_array($_POST['options'])))
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

35)     $_POST['options'] = array();
36)   $aliaswww = in_array('aliaswww', $_POST['options']);
37) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

38)   $docroot = '';
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

39)   if ($_POST['vhost_type'] == 'regular' || $_POST['vhost_type'] == 'dav')
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

40)   {
41)     $defaultdocroot = $vhost['homedir'].'/websites/'.((strlen($hostname) > 0) ? $hostname.'.' : '').($domain->fqdn).'/htdocs';
42)   
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

43)     $docroot = '';
44)     if (isset($_POST['docroot']))
45)     {
46)       if (! check_path( $_POST['docroot'] ))
47)         system_failure("Eingegebener Pfad enthält ungültige Angaben");
48)       $docroot = $vhost['homedir'].'/websites/'.$_POST['docroot'];
49)     }
50)     if ((isset($_POST['use_default_docroot']) && $_POST['use_default_docroot'] == '1') || ($docroot == $defaultdocroot)) {
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

51)       $docroot = '';
52)     }
53)   
54)     DEBUG("Document-Root: ".$docroot);
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

55)   }
56)   $php = '';
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

57)   if ($_POST['vhost_type'] == 'regular' && isset($_POST['php']))
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

58)   {
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

59)     switch ($_POST['php']) {
60)       case 'mod_php':
61)         $php = 'mod_php';
62)         break;
63)       case 'fastcgi':
64)         $php = 'fastcgi';
65)         break;
bernd Vorbereitung für PHP 5.3

bernd authored 14 years ago

66)       case 'php53':
67)         $php = 'php53';
68)         break;
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

69)       /* Wenn etwas anderes kommt, ist das "kein PHP". So einfach ist das. */
70)     }
71)   }
bernd "CGI-Aktivieren" ist jetzt...

bernd authored 13 years ago

72)   $cgi = 1;
73)   if (isset($_POST['safemode']) && $_POST['safemode'] == 'yes')
bernd CGI abschaltbar

bernd authored 14 years ago

74)   {
bernd "CGI-Aktivieren" ist jetzt...

bernd authored 13 years ago

75)     $cgi = 0;
bernd CGI abschaltbar

bernd authored 14 years ago

76)   }
77) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

78)   if (isset($_POST['suexec_user']))
79)     $vhost['suexec_user'] = $_POST['suexec_user'];
80) 
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

81)   if ($_POST['vhost_type'] == 'regular') {
82)     $vhost['is_dav'] = 0;
83)     $vhost['is_svn'] = 0;
84)     $vhost['is_webapp'] = 0;
85)   }
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

86)   elseif ($_POST['vhost_type'] == 'dav') {
87)     $vhost['is_dav'] = 1;
88)     $vhost['is_svn'] = 0;
89)     $vhost['is_webapp'] = 0;
90)   }
91)   elseif ($_POST['vhost_type'] == 'svn') {
92)     $vhost['is_dav'] = 0;
93)     $vhost['is_svn'] = 1;
94)     $vhost['is_webapp'] = 0;
95)   }
96)   elseif ($_POST['vhost_type'] == 'webapp') {
97)     $vhost['is_dav'] = 0;
98)     $vhost['is_svn'] = 0;
99)     $vhost['is_webapp'] = 1;
bernd Webapps implementiert

bernd authored 16 years ago

100)     $vhost['webapp_id'] = (int) $_POST['webapp'];
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

101)   }
102) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

103)   
bernd SSL auch über webinterface...

bernd authored 16 years ago

104)   $ssl = '';
105)   switch ($_POST['ssl']) {
106)     case 'http':
107)       $ssl = 'http';
108)       break;
109)     case 'https':
110)       $ssl = 'https';
111)       break;
112)     case 'forward':
113)       $ssl = 'forward';
114)       break;
115)     /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
116)   }
117) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

119) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

121) 
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

125)     if (isset($_POST['ipv6_separate']) && $_POST['ipv6_separate'] = 'yes')
126)     {
127)       $vhost['autoipv6'] = 2;
128)     }
bernd IPv6

bernd authored 14 years ago

129)   } else {
130)     $vhost['autoipv6'] = 0;
131)   }
132)   
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

134)   $logtype = '';
135)   switch ($_POST['logtype']) {
136)     case 'anonymous':
137)       $logtype = 'anonymous';
138)       break;
139)     case 'default':
140)       $logtype = 'default';
141)       break;
142)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
143)   }
144) 
bernd error_log konfigurierbar

bernd authored 16 years ago

145)   $errorlog = 0;
146)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
147)     $errorlog = 1;
148) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

149) 
150)   if (isset($_POST['stats']) && $_POST['stats'] == 1)
151)   {
152)     if ($vhost['stats'] == NULL)
153)       $vhost['stats'] = 'private';
154)   }
155)   else
156)     $vhost['stats'] = NULL;
157) 
158)   if ($logtype == '')
159)     $vhost['stats'] = NULL;
160)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

161)   DEBUG("PHP: {$php} / Logging: {$logtype}");
162) 
163)   $old_options = explode(',', $vhost['options']);
164)   $new_options = array();
165)   foreach ($old_options AS $op)
166)   {
167)     if ($op != 'aliaswww')
168)       array_push($new_options, $op);
169)   }
170)   if ($aliaswww)
171)     array_push($new_options, 'aliaswww');
172) 
173)   DEBUG($old_options);
174)   DEBUG($new_options);
175)   $options = implode(',', $new_options);
176)   DEBUG('New options: '.$options);
177) 
178)   $vhost['hostname'] = $hostname;
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

180)   $vhost['docroot'] = $docroot;
181)   $vhost['php'] = $php;
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

191)   save_vhost($vhost);
192) 
193)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

195) 
196) }
bernd Aliases editieren

bernd authored 16 years ago

197) elseif ($_GET['action'] == 'addalias')
198) {
199)   check_form_token('vhosts_add_alias');
200)   $id = (int) $_GET['vhost'];
201)   $vhost = get_vhost_details( $id );
202)   DEBUG($vhost);
203) 
204)   $alias = empty_alias();
205)   $alias['vhost'] = $vhost['id'];
206) 
207)   
bernd Erlaube wildcards bei vhosts

bernd authored 13 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

213)     $domainid = $domain->id;
214)   }
bernd Aliases editieren

bernd authored 16 years ago

215) 
216)   if (! is_array($_POST['options']))
217)     $_POST['options'] = array();
218)   $aliaswww = in_array('aliaswww', $_POST['options']);
219)   $forward = in_array('forward', $_POST['options']);
220) 
221)   $new_options = array();
222)   if ($aliaswww)
223)     array_push($new_options, 'aliaswww');
224)   if ($forward)
225)     array_push($new_options, 'forward');
226)   DEBUG($new_options);
227)   $options = implode(',', $new_options);
228)   DEBUG('New options: '.$options);
229) 
230)   $alias['hostname'] = $hostname;
bernd domainid -> domain_id, fies...

bernd authored 14 years ago

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

bernd authored 16 years ago

232)     
233)   $alias ['options'] = $options;
234)     
235)   save_alias($alias);
236) 
237)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

239) 
240) }
241) elseif ($_GET['action'] == 'deletealias')
242) {
243)   $title = "Subdomain löschen";
244)   $section = 'vhosts_vhosts';
245)   
246)   $alias = get_alias_details( (int) $_GET['alias'] );
247)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

249)   
250)   $vhost = get_vhost_details( $alias['vhost'] );
251)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

253)   
254)   $sure = user_is_sure();
255)   if ($sure === NULL)
256)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

258)   }
259)   elseif ($sure === true)
260)   {
261)     delete_alias($alias['id']);
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)   elseif ($sure === false)
266)   {
267)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

269)   }
270) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

271) elseif ($_GET['action'] == 'delete')
272) {
bernd Aliases editieren

bernd authored 16 years ago

273)   $title = "Subdomain löschen";
274)   $section = 'vhosts_vhosts';
275)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

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=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

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

bernd authored 15 years ago

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

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: vhosts");