20664c3d61ba75cad92cf2d92e7e4d36311e73eb
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 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 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;
125)   } else {
126)     $vhost['autoipv6'] = 0;
127)   }
128)   
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

141)   $errorlog = 0;
142)   if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
143)     $errorlog = 1;
144) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

176)   $vhost['docroot'] = $docroot;
177)   $vhost['php'] = $php;
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

187)   save_vhost($vhost);
188) 
189)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

191) 
192) }
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 13 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

209)     $domainid = $domain->id;
210)   }
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

228)     
229)   $alias ['options'] = $options;
230)     
231)   save_alias($alias);
232) 
233)   if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

245)   
246)   $vhost = get_vhost_details( $alias['vhost'] );
247)   DEBUG($vhost);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

249)   
250)   $sure = user_is_sure();
251)   if ($sure === NULL)
252)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

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

bernd authored 15 years ago

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

bernd authored 16 years ago

260)   }
261)   elseif ($sure === false)
262)   {
263)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

265)   }
266) }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

267) elseif ($_GET['action'] == 'delete')
268) {
bernd Aliases editieren

bernd authored 16 years ago

269)   $title = "Subdomain löschen";
270)   $section = 'vhosts_vhosts';
271)   
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

274)   
275)   $sure = user_is_sure();
276)   if ($sure === NULL)
277)   {
bernd * alle internen Links sinnv...

bernd authored 15 years ago

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

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

bernd authored 15 years ago

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

bernd authored 16 years ago

285)   }
286)   elseif ($sure === false)
287)   {
288)     if (! $debugmode)
bernd eliminate .php extensions f...

bernd authored 15 years ago

289)       header("Location: vhosts");