d88d35dc8f30c3e093240e665e874cc6f1d38c31
bernd neues VHosts-Modul (unbenut...

bernd authored 16 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) 
Bernd Wurst Updated copyright notice (2...

Bernd Wurst authored 11 years ago

5) Written 2008-2013 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) 
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10) 
11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
12) http://creativecommons.org/publicdomain/zero/1.0/
13) 
14) 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.
15) */
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

16) 
17) require_once("inc/base.php");
18) require_once("inc/error.php");
19) require_once("inc/security.php");
20) 
21) require_once('class/domain.php');
22) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

23) require_once("certs.php");
24) 
bernd Aliases editieren

bernd authored 16 years ago

25) 
Bernd Wurst Traffic-Statistik im Webint...

Bernd Wurst authored 11 years ago

26) function traffic_month($vhost_id)
27) {
28)   $vhost_id = (int) $vhost_id;
29)   $result = db_query("SELECT sum(mb_in+mb_out) as mb FROM vhosts.traffic where date > CURDATE() - INTERVAL 1 MONTH AND vhost_id = {$vhost_id}");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

30)   $data = $result->fetch();
Bernd Wurst Traffic-Statistik im Webint...

Bernd Wurst authored 11 years ago

31)   return $data['mb'];
32) }
33) 
bernd Zusätzlicher Haken für eige...

bernd authored 13 years ago

34) function autoipv6_address($vhost_id, $mode = 1)
bernd IPv6-Regelbetrieb vorbereit...

bernd authored 13 years ago

35) {
36)   $result = db_query("SELECT uid, v6_prefix FROM vhosts.v_vhost LEFT JOIN system.servers ON (servers.hostname = server) WHERE v_vhost.id={$vhost_id}");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

37)   $data = $result->fetch();
bernd IPv6-Regelbetrieb vorbereit...

bernd authored 13 years ago

38)   if (!$data['v6_prefix'])
39)   {
40)     warning("IPv6-Adresse nicht verfügbar, Server unterstützt kein IPv6");
41)     return "";
42)   }
bernd Prefix-Länge herauslöschen

bernd authored 13 years ago

43)   list($prefix, $null) = explode('/', $data['v6_prefix']);
bernd Zusätzlicher Haken für eige...

bernd authored 13 years ago

44)   $vh = ':1';
45)   if ($mode == 2) {
46)     $vh = implode(':', str_split(sprintf("%08x", $vhost_id), 4));
47)   }
bernd Prefix-Länge herauslöschen

bernd authored 13 years ago

48)   $ipv6 = $prefix . sprintf("%04s", $data['uid']) . ':' . $vh;
bernd IPv6-Regelbetrieb vorbereit...

bernd authored 13 years ago

49)   return $ipv6;
50) }
51) 
52) 
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

53) function list_vhosts()
54) {
55)   $uid = (int) $_SESSION['userinfo']['uid'];
bernd CGI abschaltbar

bernd authored 14 years ago

56)   $result = db_query("SELECT vh.id,fqdn,domain,docroot,docroot_is_default,php,cgi,vh.certid AS cert, vh.ssl, vh.options,logtype,errorlog,IF(dav.id IS NULL OR dav.type='svn', 0, 1) AS is_dav,IF(dav.id IS NULL OR dav.type='dav', 0, 1) AS is_svn, IF(webapps.id IS NULL, 0, 1) AS is_webapp, stats FROM vhosts.v_vhost AS vh LEFT JOIN vhosts.dav ON (dav.vhost=vh.id) LEFT JOIN vhosts.webapps ON (webapps.vhost = vh.id) WHERE uid={$uid} ORDER BY domain,hostname");
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

57)   $ret = array();
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

58)   while ($item = $result->fetch())
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

59)     array_push($ret, $item);
60)   return $ret;
61) }
62) 
bernd IPv6-fähigkeit auch richtig...

bernd authored 13 years ago

63) function ipv6_possible($server)
bernd IPv6-Option nur anzeigen we...

bernd authored 13 years ago

64) {
bernd IPv6-fähigkeit auch richtig...

bernd authored 13 years ago

65)   $serverid = (int) $server;
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

66)   $servername = db_escape_string($server);
bernd IPv6-fähigkeit auch richtig...

bernd authored 13 years ago

67)   $result = db_query("SELECT v6_prefix FROM system.servers WHERE id={$serverid} OR hostname='{$servername}'");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

68)   $line = $result->fetch();
bernd IPv6-fähigkeit auch richtig...

bernd authored 13 years ago

69)   DEBUG("Server {$server} is v6-capable: ". ($line['v6_prefix'] != NULL));
70)   return ($line['v6_prefix'] != NULL);
bernd IPv6-Option nur anzeigen we...

bernd authored 13 years ago

71) }
72) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

73) function empty_vhost()
74) {
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

75)   $vhost['id'] = NULL;
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

76)   $vhost['hostname'] = '';
77)   
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

78)   $vhost['domain_id'] = -1;
bernd Mehr config-optionen und co...

bernd authored 14 years ago

79)   $vhost['domain'] = $_SESSION['userinfo']['username'].'.'.config('masterdomain');
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

80)   
81)   $vhost['homedir'] = $_SESSION['userinfo']['homedir'];
82)   $vhost['docroot'] = NULL;
Hanno Böck php 5.5 default

Hanno Böck authored 10 years ago

83)   $vhost['php'] = 'php55';
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

85)   $vhost['ssl'] = NULL;
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

86)   $vhost['hsts'] = -1;
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

87)   $vhost['suexec_user'] = NULL;
Bernd Wurst Ermögliche das Auswählen de...

Bernd Wurst authored 11 years ago

88)   $vhost['server'] = NULL;
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

89)   $vhost['logtype'] = NULL;
bernd Einige notices (undefined i...

bernd authored 14 years ago

90)   $vhost['errorlog'] = 0;
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

91)   $vhost['is_dav'] = 0;
92)   $vhost['is_svn'] = 0;
93)   $vhost['is_webapp'] = 0;
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

94)   $vhost['webapp_id'] = NULL;
95)   
96)   $vhost['cert'] = NULL;
bernd Einige notices (undefined i...

bernd authored 14 years ago

97)   $vhost['certid'] = NULL;
bernd IP-Adressen aktivieren

bernd authored 14 years ago

98)   $vhost['ipv4'] = NULL;
bernd r1864 war Blöd, reverted

bernd authored 13 years ago

99)   $vhost['autoipv6'] = 2; // 1 => Eine IP pro User, 2 => Eine IP pro VHost
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

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

bernd authored 16 years ago

101)   $vhost['options'] = '';
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

102)   $vhost['stats'] = NULL;
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

103)   return $vhost;
104) }
105) 
106) 
bernd Aliases editieren

bernd authored 16 years ago

107) function empty_alias()
108) {
109)   $alias['hostname'] = '';
110)   
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

111)   $alias['domain_id'] = -1;
bernd Mehr config-optionen und co...

bernd authored 14 years ago

112)   $alias['domain'] = $_SESSION['userinfo']['username'].'.'.config('masterdomain');
bernd Aliases editieren

bernd authored 16 years ago

113)   
114)   $alias['options'] = '';
115)   return $alias;
116) }
117) 
118) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

119) function domainselect($selected = NULL, $selectattribute = '')
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

120) {
bernd Mehr config-optionen und co...

bernd authored 14 years ago

121)   global $domainlist, $config;
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

122)   if ($domainlist == NULL)
123)     $domainlist = get_domain_list($_SESSION['customerinfo']['customerno'],
124)                                   $_SESSION['userinfo']['uid']);
125)   $selected = (int) $selected;
126) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

127)   $ret = '<select id="domain" name="domain" size="1" '.$selectattribute.' >';
bernd Mehr config-optionen und co...

bernd authored 14 years ago

128)   $ret .= ' <option value="-1">'.$_SESSION['userinfo']['username'].'.'.config('masterdomain').'</option>';
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

129)   $ret .= ' <option value="" disabled="disabled">--------------------------------</option>';
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

130)   foreach ($domainlist as $dom)
131)   {
bernd Aliases editieren

bernd authored 16 years ago

132)     $s = ($selected == $dom->id) ? ' selected="selected" ': '';
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

133)     $ret .= "<option value=\"{$dom->id}\"{$s}>{$dom->fqdn}</option>\n";
134)   }
135)   $ret .= '</select>';
136)   return $ret;
137) }
138) 
139) 
140) 
141) function get_vhost_details($id)
142) {
143)   $id = (int) $id;
144)   $uid = (int) $_SESSION['userinfo']['uid'];
bernd VHosts-Modul mit neuem Layo...

bernd authored 16 years ago

145)   $result = db_query("SELECT vh.*,IF(dav.id IS NULL OR dav.type='svn', 0, 1) AS is_dav,IF(dav.id IS NULL OR dav.type='dav', 0, 1) AS is_svn, IF(webapps.id IS NULL, 0, 1) AS is_webapp FROM vhosts.v_vhost AS vh LEFT JOIN vhosts.dav ON (dav.vhost=vh.id) LEFT JOIN vhosts.webapps ON (webapps.vhost = vh.id) WHERE uid={$uid} AND vh.id={$id}");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

146)   if ($result->rowCount() != 1)
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

147)     system_failure('Interner Fehler beim Auslesen der Daten');
148) 
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

149)   $ret = $result->fetch();
Bernd Wurst bugfix: server vorausgewählt

Bernd Wurst authored 11 years ago

150) 
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

151)   if ($ret['hsts'] === NULL) {
152)     DEBUG('HSTS: '.$ret['hsts']);
153)     $ret['hsts'] = -1;
154)   }
Bernd Wurst bugfix: server vorausgewählt

Bernd Wurst authored 11 years ago

155)   $ret['server'] = $ret['server_id'];
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

156)   DEBUG($ret);
157)   return $ret;
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

158) }
159) 
160) 
161) function get_aliases($vhost)
162) {
163)   $result = db_query("SELECT id,fqdn,options FROM vhosts.v_alias WHERE vhost={$vhost}");
164)   $ret = array();
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

165)   while ($item = $result->fetch()) {
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

166)     array_push($ret, $item);
bernd Aliases editieren

bernd authored 16 years ago

167)   }
168)   return $ret;
169) }
170) 
171) 
172) 
173) function get_all_aliases($vhost)
174) {
bernd Weniger Datenbankzugriffe b...

bernd authored 14 years ago

175)   //$vhost = get_vhost_details( (int) $vhost );
bernd Aliases editieren

bernd authored 16 years ago

176)   $aliases = get_aliases($vhost['id']);
177)   $ret = array();
178)   if (strstr($vhost['options'], 'aliaswww')) {
179)     array_push($ret, array('id' => 'www', 'fqdn' => 'www.'.$vhost['fqdn'], 'options' => (strstr($vhost['options'], 'forwardwww') ? 'forward' : '')));
180)   }
181)   foreach ($aliases as $item) {
182)     array_push($ret, $item);
183)     if (strstr($item['options'], 'aliaswww')) {
184)       array_push($ret, array('id' => 'www_'.$item['id'], 'fqdn' => 'www.'.$item['fqdn'], 'options' => (strstr($item['options'], 'forward') ? 'forward' : '')));
185)     }
186)   }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

187)   return $ret;
188) }
189) 
bernd Aliases editieren

bernd authored 16 years ago

190) 
bernd Webapps implementiert

bernd authored 16 years ago

191) function list_available_webapps()
192) {
193)   $result = db_query("SELECT id,displayname FROM vhosts.global_webapps");
194)   $ret = array();
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

195)   while ($item = $result->fetch())
bernd Webapps implementiert

bernd authored 16 years ago

196)     array_push($ret, $item);
197)   return $ret;
198) }
199) 
200) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

201) function delete_vhost($id)
202) {
203)   $id = (int) $id;
204)   if ($id == 0)
205)     system_failure("id == 0");
206)   $vhost = get_vhost_details($id);
bernd Logger mit Logleveln

bernd authored 14 years ago

207)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Removing vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

208)   db_query("DELETE FROM vhosts.vhost WHERE id={$vhost['id']} LIMIT 1");
209) }
210) 
bernd Aliases editieren

bernd authored 16 years ago

211) 
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

212) 
213) function make_svn_vhost($id) 
214) {
215)   $id = (int) $id;
216)   if ($id == 0)
217)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

218)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to SVN');
bernd letzter commit rückgängig

bernd authored 16 years ago

219)   db_query("REPLACE INTO vhosts.dav (vhost, type) VALUES ({$id}, 'svn')");
bernd Webapps implementiert

bernd authored 16 years ago

220)   db_query("DELETE FROM vhosts.webapps WHERE vhost={$id}");
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

221) }
222) 
223) function make_dav_vhost($id) 
224) {
225)   $id = (int) $id;
226)   if ($id == 0)
227)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

228)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to WebDAV');
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

229)   db_query("REPLACE INTO vhosts.dav (vhost, type, options) VALUES ({$id}, 'dav', 'nouserfile')");
bernd Webapps implementiert

bernd authored 16 years ago

230)   db_query("DELETE FROM vhosts.webapps WHERE vhost={$id}");
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

231) }
232) 
bernd Webapps implementiert

bernd authored 16 years ago

233) function make_regular_vhost($id)
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

234) {
235)   $id = (int) $id;
236)   if ($id == 0)
237)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

238)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to regular');
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

239)   db_query("DELETE FROM vhosts.dav WHERE vhost={$id}");
bernd Webapps implementiert

bernd authored 16 years ago

240)   db_query("DELETE FROM vhosts.webapps WHERE vhost={$id}");
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

241) }
242) 
243) 
244) function make_webapp_vhost($id, $webapp) 
245) {
246)   $id = (int) $id;
247)   $webapp = (int) $webapp;
248)   if ($id == 0)
249)     system_failure("id == 0");
bernd Webapps implementiert

bernd authored 16 years ago

250)   $result = db_query("SELECT displayname FROM vhosts.global_webapps WHERE id={$webapp};");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

251)   if ($result->rowCount() == 0)
bernd Webapps implementiert

bernd authored 16 years ago

252)     system_failure("webapp-id invalid");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

253)   $webapp_name = $result->fetch(PDO::FETCH_OBJ)->displayname;
bernd Logger mit Logleveln

bernd authored 14 years ago

254)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Setting up webapp '.$webapp_name.' on vhost #'.$id);
bernd Webapps implementiert

bernd authored 16 years ago

255)   db_query("REPLACE INTO vhosts.webapps (vhost, webapp) VALUES ({$id}, {$webapp})");
256)   mail('webapps-setup@schokokeks.org', 'setup', 'setup');
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

257) }
258) 
259) 
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

260) function check_hostname_collision($hostname, $domain) 
261) {
schokokeks.org GbR Kollisions-Check für VHosts...

schokokeks.org GbR authored 10 years ago

262)   $uid = (int) $_SESSION['userinfo']['uid'];
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

263)   # Neuer vhost => Prüfe Duplikat
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

264)   $hostnamecheck = "hostname='".db_escape_string($hostname)."'";
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

265)   if (! $hostname) {
266)     $hostnamecheck = "hostname IS NULL";
267)   }
268)   $domaincheck = "domain=". (int) $domain ;
269)   if ($domain == -1) {
schokokeks.org GbR Kollisions-Check für VHosts...

schokokeks.org GbR authored 10 years ago

270)     $domaincheck = "domain IS NULL AND user={$uid}";
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

271)   }
272)   $result = db_query("SELECT id FROM vhosts.vhost WHERE {$hostnamecheck} AND {$domaincheck}");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

273)   if ($result->rowCount() > 0) {
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

274)     system_failure('Eine Konfiguration mit diesem Namen gibt es bereits.');
275)   }
schokokeks.org GbR Kollisions-Check für VHosts...

schokokeks.org GbR authored 10 years ago

276)   if ($domain == -1) {
277)     return ;
278)   }
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

279)   $result = db_query("SELECT id, vhost FROM vhosts.alias WHERE {$hostnamecheck} AND {$domaincheck}");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

280)   if ($result->rowCount() > 0) {
281)     $data = $result->fetch();
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

282)     $vh = get_vhost_details($data['vhost']);
283)     system_failure('Dieser Hostname ist bereits als Alias für »'.$vh['fqdn'].'« eingerichtet');
284)   }
285) }
286) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

287) function save_vhost($vhost)
288) {
289)   if (! is_array($vhost))
290)     system_failure('$vhost kein array!');
291)   $id = (int) $vhost['id'];
292)   $hostname = maybe_null($vhost['hostname']);
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

293)   $domain = (int) $vhost['domain_id'];
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

294)   if ($domain == 0)
bernd Aliases editieren

bernd authored 16 years ago

295)     system_failure('$domain == 0');
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

296)   if ($vhost['domain_id'] == -1)
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

297)     $domain = 'NULL';
Bernd Wurst Sperre das Eintragen doppel...

Bernd Wurst authored 11 years ago

298)   if ($id == 0) {
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

299)     check_hostname_collision($vhost['hostname'], $vhost['domain_id']);
Bernd Wurst Sperre das Eintragen doppel...

Bernd Wurst authored 11 years ago

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

bernd authored 16 years ago

301)   $docroot = maybe_null($vhost['docroot']);
302)   $php = maybe_null($vhost['php']);
bernd CGI abschaltbar

bernd authored 14 years ago

303)   $cgi = ($vhost['cgi'] == 1 ? 1 : 0);
bernd SSL auch über webinterface...

bernd authored 16 years ago

304)   $ssl = maybe_null($vhost['ssl']);
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

305)   $hsts = (int) $vhost['hsts'];
306)   if ($hsts < 0) {
307)     $hsts = "NULL";
308)   }
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

309)   $suexec_user = 'NULL';
310) 
311)   $available_suexec = available_suexec_users();
312)   foreach ($available_suexec AS $u)
313)     if ($u['uid'] == $vhost['suexec_user'])
314)       $suexec_user = $u['uid'];
315) 
Bernd Wurst Ermögliche das Auswählen de...

Bernd Wurst authored 11 years ago

316)   $server = 'NULL';
317)   $available_servers = additional_servers();
318)   if (in_array($vhost['server'], $available_servers)) {
319)     $server = (int) $vhost['server'];
320)   }
321)   if ($server == my_server_id()) {
322)     $server = 'NULL';
323)   }
324) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

325)   $logtype = maybe_null($vhost['logtype']);
bernd error_log konfigurierbar

bernd authored 16 years ago

326)   $errorlog = (int) $vhost['errorlog'];
bernd fix für svn/nodocroot

bernd authored 16 years ago

327)   if ($vhost['is_svn']) {
bernd nodocroot für svn-hosts

bernd authored 16 years ago

328)     if (! $vhost['options']) $vhost['options']='nodocroot';
329)     else $vhost['options']+=",nodocroot";
330)   }
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

331)   $options = db_escape_string( $vhost['options'] );
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

332) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

333)   $cert = 0;
334)   $certs = user_certs();
335)   foreach ($certs as $c)
336)     if ($c['id'] == $vhost['cert'])
337)       $cert = $c['id'];
338)   if ($cert == 0)
339)     $cert = 'NULL';
340) 
bernd IP-Adressen aktivieren

bernd authored 14 years ago

341)   $ipv4 = 'NULL';
342)   $ipv4_avail = user_ipaddrs();
343)   if (in_array($vhost['ipv4'], $ipv4_avail))
344)   {
345)     $ipv4 = maybe_null($vhost['ipv4']);
346)   }
bernd IPv6

bernd authored 14 years ago

347) 
bernd Zusätzlicher Haken für eige...

bernd authored 13 years ago

348)   $autoipv6 = 1;
349)   if ($vhost['autoipv6'] == 0 ||  $vhost['autoipv6'] == 2) {
350)     $autoipv6 = $vhost['autoipv6'];
351)   }
bernd IPv6

bernd authored 14 years ago

352) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

353)   $stats = maybe_null($vhost['stats']);
bernd IP-Adressen aktivieren

bernd authored 14 years ago

354) 
bernd Logging

bernd authored 16 years ago

355)   if ($id != 0) {
bernd Logger mit Logleveln

bernd authored 14 years ago

356)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

357)     db_query("UPDATE vhosts.vhost SET hostname={$hostname}, domain={$domain}, docroot={$docroot}, php={$php}, cgi={$cgi}, `ssl`={$ssl}, hsts={$hsts}, `suexec_user`={$suexec_user}, `server`={$server}, logtype={$logtype}, errorlog={$errorlog}, certid={$cert}, ipv4={$ipv4}, autoipv6={$autoipv6}, options='{$options}', stats={$stats} WHERE id={$id} LIMIT 1");
bernd Logging

bernd authored 16 years ago

358)   }
359)   else {
bernd Logger mit Logleveln

bernd authored 14 years ago

360)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].'');
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

361)     $result = db_query("INSERT INTO vhosts.vhost (user, hostname, domain, docroot, php, cgi, `ssl`, hsts, `suexec_user`, `server`, logtype, errorlog, certid, ipv4, autoipv6, options, stats) VALUES ({$_SESSION['userinfo']['uid']}, {$hostname}, {$domain}, {$docroot}, {$php}, {$cgi}, {$ssl}, {$hsts}, {$suexec_user}, {$server}, {$logtype}, {$errorlog}, {$cert}, {$ipv4}, {$autoipv6}, '{$options}', {$stats})");
Bernd Wurst Warnung im dev-branch bzgl....

Bernd Wurst authored 10 years ago

362)     $id = db_insert_id();
bernd Logging

bernd authored 16 years ago

363)   }
bernd Webapps implementiert

bernd authored 16 years ago

364)   $oldvhost = get_vhost_details($id);
365)   /*
366)     these vars may be 0 or 1.
367)     So newval > oldval means that it has been switched on yet.
368)   */
369)   if ($vhost['is_dav'] > $oldvhost['is_dav'])
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

370)       make_dav_vhost($id);
bernd Webapps implementiert

bernd authored 16 years ago

371)   elseif ($vhost['is_svn'] > $oldvhost['is_svn'])
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

372)       make_svn_vhost($id);
bernd Webapps implementiert

bernd authored 16 years ago

373)   elseif ($vhost['is_webapp'] > $oldvhost['is_webapp'])
374)       make_webapp_vhost($id, $vhost['webapp_id']);
375)   elseif ($vhost['is_dav'] == 0 && $vhost['is_svn'] == 0 && $vhost['is_webapp'] == 0)
376)       make_regular_vhost($id);
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

377) }
378) 
379) 
bernd Aliases editieren

bernd authored 16 years ago

380) function get_alias_details($id)
381) {
382)   $id = (int) $id;
383)   $uid = (int) $_SESSION['userinfo']['uid'];
384)   $result = db_query("SELECT * FROM vhosts.v_alias WHERE id={$id}");
385)   
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

386)   if ($result->rowCount() != 1)
bernd Aliases editieren

bernd authored 16 years ago

387)     system_failure('Interner Fehler beim Auslesen der Alias-Daten');
388)   
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

389)   $alias = $result->fetch();
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

390)   
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

391)   if ($alias['domain_id'] == NULL) {
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

392)     $alias['domain_id'] = -1;
bernd auch aliases dürfen usernam...

bernd authored 16 years ago

393)   }
bernd Aliases editieren

bernd authored 16 years ago

394) 
395)   /* Das bewirkt, dass nur die eigenen Aliase gesehen werden können */
396)   get_vhost_details( (int) $alias['vhost'] );
397) 
398)   return $alias;
399) }
400) 
401) 
402) function delete_alias($id)
403) {
404)   $id = (int) $id;
405)   $alias = get_alias_details($id);
406) 
bernd Logger mit Logleveln

bernd authored 14 years ago

407)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Removing alias #'.$id.' ('.$alias['hostname'].'.'.$alias['domain'].')');
bernd Aliases editieren

bernd authored 16 years ago

408)   db_query("DELETE FROM vhosts.alias WHERE id={$id}");
409) }
410) 
411) function save_alias($alias)
412) {
413)   if (! is_array($alias))
414)     system_failure('$alias kein array!');
bernd Neue aliase haben keine ID

bernd authored 14 years ago

415)   $id = (isset($alias['id']) ? (int) $alias['id'] : 0);
bernd Aliases editieren

bernd authored 16 years ago

416)   $hostname = maybe_null($alias['hostname']);
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

417)   $domain = (int) $alias['domain_id'];
bernd Aliases editieren

bernd authored 16 years ago

418)   if ($domain == 0)
419)     system_failure('$domain == 0');
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

420)   if ($alias['domain_id'] == -1)
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

421)     $domain = 'NULL';
bernd Aliases editieren

bernd authored 16 years ago

422)   $vhost = get_vhost_details( (int) $alias['vhost']);
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

423)   $options = db_escape_string( $alias['options'] );
bernd Aliases editieren

bernd authored 16 years ago

424)   if ($id == 0) {
bernd Logger mit Logleveln

bernd authored 14 years ago

425)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Creating alias '.$alias['hostname'].'.'.$alias['domain'].' for VHost '.$vhost['id']);
bernd Aliases editieren

bernd authored 16 years ago

426)     db_query("INSERT INTO vhosts.alias (hostname, domain, vhost, options) VALUES ({$hostname}, {$domain}, {$vhost['id']}, '{$options}')");
427)   }
428)   else {
bernd Logger mit Logleveln

bernd authored 14 years ago

429)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Updating alias #'.$id.' ('.$alias['hostname'].'.'.$alias['domain'].')');
bernd Aliases editieren

bernd authored 16 years ago

430)     db_query("UPDATE vhosts.alias SET hostname={$hostname}, domain={$domain}, options='{$options}' WHERE id={$id} LIMIT 1");
431)   }
432) }
433) 
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

434) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

435) function available_suexec_users()
436) {
437)   $uid = (int) $_SESSION['userinfo']['uid'];
438)   $result = db_query("SELECT uid, username FROM vhosts.available_users LEFT JOIN vhosts.v_useraccounts ON (uid = suexec_user) WHERE mainuser={$uid}");
439)   $ret = array();
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

440)   while ($i = $result->fetch())
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

441)     $ret[] = $i;
442)   DEBUG('available suexec-users:');
443)   DEBUG($ret);
444)   return $ret;
445) 
446) }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

447) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

448) 
449) function user_ipaddrs()
450) {
451)   $uid = (int) $_SESSION['userinfo']['uid'];
452)   $result = db_query("SELECT ipaddr FROM vhosts.ipaddr_available WHERE uid={$uid}");
453)   $ret = array();
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

454)   while ($i = $result->fetch())
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

455)   {
456)     $ret[] = $i['ipaddr'];
457)   }
458)   DEBUG($ret);
459)   return $ret;
460) }
461) 
462)