926f25dbc24be93a66113cbe3fcfdc316dc22981
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) 
25)   $hostname = filter_input_hostname($_POST['hostname']);
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 abschaltbar

bernd authored 14 years ago

72)   $cgi = 0;
73)   if (isset($_POST['cgi']) && isset($_POST['cgi']) && $_POST['cgi'] == 'yes')
74)   {
75)     $cgi = 1;
76)   }
77) 
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

98)   }
99) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

100)   
bernd SSL auch über webinterface...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

116) 
bernd fix a warning

bernd authored 14 years ago

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

bernd authored 14 years ago

118) 
bernd IPv6

bernd authored 14 years ago

119)   if (isset($_POST['ipv6']) && $_POST['ipv6'] == 'yes')
120)   {
121)     $vhost['autoipv6'] = 1;
122)   } else {
123)     $vhost['autoipv6'] = 0;
124)   }
125)   
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

127)   $logtype = '';
128)   switch ($_POST['logtype']) {
129)     case 'anonymous':
130)       $logtype = 'anonymous';
131)       break;
132)     case 'default':
133)       $logtype = 'default';
134)       break;
135)     /* Wenn etwas anderes kommt, ist das "kein Logging". So einfach ist das. */
136)   }
137) 
bernd error_log konfigurierbar

bernd authored 16 years ago

138)   $errorlog = 0;
139)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
140)     $errorlog = 1;
141) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

142) 
143)   if (isset($_POST['stats']) && $_POST['stats'] == 1)
144)   {
145)     if ($vhost['stats'] == NULL)
146)       $vhost['stats'] = 'private';
147)   }
148)   else
149)     $vhost['stats'] = NULL;
150) 
151)   if ($logtype == '')
152)     $vhost['stats'] = NULL;
153)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

154)   DEBUG("PHP: {$php} / Logging: {$logtype}");
155) 
156)   $old_options = explode(',', $vhost['options']);
157)   $new_options = array();
158)   foreach ($old_options AS $op)
159)   {
160)     if ($op != 'aliaswww')
161)       array_push($new_options, $op);
162)   }
163)   if ($aliaswww)
164)     array_push($new_options, 'aliaswww');
165) 
166)   DEBUG($old_options);
167)   DEBUG($new_options);
168)   $options = implode(',', $new_options);
169)   DEBUG('New options: '.$options);
170) 
171)   $vhost['hostname'] = $hostname;
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

173)   $vhost['docroot'] = $docroot;
174)   $vhost['php'] = $php;
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

184)   save_vhost($vhost);
185) 
186)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

188) 
189) }
bernd Aliases editieren

bernd authored 16 years ago

190) elseif ($_GET['action'] == 'addalias')
191) {
192)   check_form_token('vhosts_add_alias');
193)   $id = (int) $_GET['vhost'];
194)   $vhost = get_vhost_details( $id );
195)   DEBUG($vhost);
196) 
197)   $alias = empty_alias();
198)   $alias['vhost'] = $vhost['id'];
199) 
200)   
201)   $hostname = filter_input_hostname($_POST['hostname']);
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

206)     $domainid = $domain->id;
207)   }
bernd Aliases editieren

bernd authored 16 years ago

208) 
209)   if (! is_array($_POST['options']))
210)     $_POST['options'] = array();
211)   $aliaswww = in_array('aliaswww', $_POST['options']);
212)   $forward = in_array('forward', $_POST['options']);
213) 
214)   $new_options = array();
215)   if ($aliaswww)
216)     array_push($new_options, 'aliaswww');
217)   if ($forward)
218)     array_push($new_options, 'forward');
219)   DEBUG($new_options);
220)   $options = implode(',', $new_options);
221)   DEBUG('New options: '.$options);
222) 
223)   $alias['hostname'] = $hostname;
bernd domainid -> domain_id, fies...

bernd authored 14 years ago

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

bernd authored 16 years ago

225)     
226)   $alias ['options'] = $options;
227)     
228)   save_alias($alias);
229) 
230)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

232) 
233) }
234) elseif ($_GET['action'] == 'deletealias')
235) {
236)   $title = "Subdomain löschen";
237)   $section = 'vhosts_vhosts';
238)   
239)   $alias = get_alias_details( (int) $_GET['alias'] );
240)   DEBUG($alias);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

242)   
243)   $vhost = get_vhost_details( $alias['vhost'] );
244)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

246)   
247)   $sure = user_is_sure();
248)   if ($sure === NULL)
249)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

251)   }
252)   elseif ($sure === true)
253)   {
254)     delete_alias($alias['id']);
255)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

257)   }
258)   elseif ($sure === false)
259)   {
260)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

262)   }
263) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

264) elseif ($_GET['action'] == 'delete')
265) {
bernd Aliases editieren

bernd authored 16 years ago

266)   $title = "Subdomain löschen";
267)   $section = 'vhosts_vhosts';
268)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

271)   
272)   $sure = user_is_sure();
273)   if ($sure === NULL)
274)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

276)   }
277)   elseif ($sure === true)
278)   {
279)     delete_vhost($vhost['id']);
280)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

282)   }
283)   elseif ($sure === false)
284)   {
285)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

286)       header("Location: vhosts");