2532164506c6ea716e821c786e68bd9f2bc77c9d
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;
Bernd Wurst Einige Statements auf Prepa...

Bernd Wurst authored 10 years ago

29)   $result = db_query("SELECT sum(mb_in+mb_out) as mb FROM vhosts.traffic where date > CURDATE() - INTERVAL 1 MONTH AND vhost_id = ?", array($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) {
Bernd Wurst Einige Statements auf Prepa...

Bernd Wurst authored 10 years ago

36)   $result = db_query("SELECT uid, v6_prefix FROM vhosts.v_vhost LEFT JOIN system.servers ON (servers.hostname = server) WHERE v_vhost.id=?", array($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 Wurst Einige Statements auf Prepa...

Bernd Wurst authored 10 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=? ORDER BY domain,hostname", array($uid));
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 Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

65)   $args = array(":server" => $server);
66)   $result = db_query("SELECT v6_prefix FROM system.servers WHERE id=:server OR hostname=:server", $args);
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 13 years ago

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

bernd authored 13 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

74)   $vhost['id'] = NULL;
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

76)   
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Hanno Böck authored 10 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

Bernd Wurst authored 11 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 13 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

106) function empty_alias()
107) {
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

108)   $alias['hostname'] = NULL;
bernd Aliases editieren

bernd authored 16 years ago

109)   
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

112)   
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

113)   $alias['options'] = NULL;
bernd Aliases editieren

bernd authored 16 years ago

114)   return $alias;
115) }
116) 
117) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

128)   $ret .= ' <option value="" disabled="disabled">--------------------------------</option>';
Bernd Wurst Sperre VHosts gegen Änderun...

Bernd Wurst authored 10 years ago

129)   $found = false;
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

130)   foreach ($domainlist as $dom)
131)   {
Bernd Wurst Sperre VHosts gegen Änderun...

Bernd Wurst authored 10 years ago

132)     $s = '';
133)     if ($selected == $dom->id) {
134)       $s = ' selected="selected" ';
135)       $found = true;
136)     }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

137)     $ret .= "<option value=\"{$dom->id}\"{$s}>{$dom->fqdn}</option>\n";
138)   }
139)   $ret .= '</select>';
Bernd Wurst Sperre VHosts gegen Änderun...

Bernd Wurst authored 10 years ago

140)   if ($selected > 0 and ! $found) {
141)     system_failure("Hier wird eine Domain benutzt, die nicht zu diesem Benutzeraccount gehört. Bearbeiten würde Daten zerstören!");
142)   }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

143)   return $ret;
144) }
145) 
146) 
147) 
148) function get_vhost_details($id)
149) {
150)   $id = (int) $id;
151)   $uid = (int) $_SESSION['userinfo']['uid'];
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

152)   $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", array(":uid" => $uid, ":id" => $id));
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 10 years ago

158)   if ($ret['hsts'] === NULL) {
159)     DEBUG('HSTS: '.$ret['hsts']);
160)     $ret['hsts'] = -1;
161)   }
Bernd Wurst bugfix: server vorausgewählt

Bernd Wurst authored 11 years ago

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

bernd authored 14 years ago

163)   DEBUG($ret);
164)   return $ret;
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

165) }
166) 
167) 
168) function get_aliases($vhost)
169) {
Bernd Wurst Einige Statements auf Prepa...

Bernd Wurst authored 10 years ago

170)   $result = db_query("SELECT id,fqdn,options FROM vhosts.v_alias WHERE vhost=?", array($vhost));
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

174)   }
175)   return $ret;
176) }
177) 
178) 
179) 
180) function get_all_aliases($vhost)
181) {
bernd Weniger Datenbankzugriffe b...

bernd authored 14 years ago

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

bernd authored 16 years ago

183)   $aliases = get_aliases($vhost['id']);
184)   $ret = array();
185)   if (strstr($vhost['options'], 'aliaswww')) {
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

186)     array_push($ret, array('id' => 'www', 'fqdn' => 'www.'.$vhost['fqdn'], 'options' => (strstr($vhost['options'], 'forwardwww') ? 'forward' : NULL)));
bernd Aliases editieren

bernd authored 16 years ago

187)   }
188)   foreach ($aliases as $item) {
189)     array_push($ret, $item);
190)     if (strstr($item['options'], 'aliaswww')) {
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

191)       array_push($ret, array('id' => 'www_'.$item['id'], 'fqdn' => 'www.'.$item['fqdn'], 'options' => (strstr($item['options'], 'forward') ? 'forward' : NULL)));
bernd Aliases editieren

bernd authored 16 years ago

192)     }
193)   }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

194)   return $ret;
195) }
196) 
bernd Aliases editieren

bernd authored 16 years ago

197) 
bernd Webapps implementiert

bernd authored 16 years ago

198) function list_available_webapps()
199) {
200)   $result = db_query("SELECT id,displayname FROM vhosts.global_webapps");
201)   $ret = array();
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

203)     array_push($ret, $item);
204)   return $ret;
205) }
206) 
207) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

208) function delete_vhost($id)
209) {
210)   $id = (int) $id;
211)   if ($id == 0)
212)     system_failure("id == 0");
213)   $vhost = get_vhost_details($id);
bernd Logger mit Logleveln

bernd authored 14 years ago

214)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Removing vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

215)   db_query("DELETE FROM vhosts.vhost WHERE id=?", array($vhost['id']));
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

216) }
217) 
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 16 years ago

219) 
220) function make_svn_vhost($id) 
221) {
222)   $id = (int) $id;
223)   if ($id == 0)
224)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

225)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to SVN');
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

226)   db_query("REPLACE INTO vhosts.dav (vhost, type) VALUES (?, 'svn')", array($id));
227)   db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

228) }
229) 
230) function make_dav_vhost($id) 
231) {
232)   $id = (int) $id;
233)   if ($id == 0)
234)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

235)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to WebDAV');
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

236)   db_query("REPLACE INTO vhosts.dav (vhost, type, options) VALUES (?, 'dav', 'nouserfile')", array($id));
237)   db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

238) }
239) 
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

241) {
242)   $id = (int) $id;
243)   if ($id == 0)
244)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

245)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to regular');
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

246)   db_query("DELETE FROM vhosts.dav WHERE vhost=?", array($id));
247)   db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

248) }
249) 
250) 
251) function make_webapp_vhost($id, $webapp) 
252) {
253)   $id = (int) $id;
254)   $webapp = (int) $webapp;
255)   if ($id == 0)
256)     system_failure("id == 0");
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

257)   $result = db_query("SELECT displayname FROM vhosts.global_webapps WHERE id=?", array($webapp));
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

261)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Setting up webapp '.$webapp_name.' on vhost #'.$id);
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

262)   db_query("REPLACE INTO vhosts.webapps (vhost, webapp) VALUES (?, ?)", array($id, $webapp));
bernd Webapps implementiert

bernd authored 16 years ago

263)   mail('webapps-setup@schokokeks.org', 'setup', 'setup');
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

264) }
265) 
266) 
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

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

schokokeks.org GbR authored 10 years ago

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

Bernd Wurst authored 11 years ago

270)   # Neuer vhost => Prüfe Duplikat
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

271)   $args = array(":hostname" => $hostname, ":domain" => $domain);
272)   $hostnamecheck = "hostname=:hostname";
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

273)   if (! $hostname) {
274)     $hostnamecheck = "hostname IS NULL";
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

275)     unset($args[":hostname"]);
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

276)   }
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

277)   $domaincheck = "domain=:domain";
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

278)   if ($domain == -1) {
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

279)     $args[":uid"] = $uid;
280)     unset($args[":domain"]);
281)     $domaincheck = "domain IS NULL AND user=:uid";
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

282)   }
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 11 years ago

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

schokokeks.org GbR authored 10 years ago

287)   if ($domain == -1) {
288)     return ;
289)   }
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 11 years ago

293)     $vh = get_vhost_details($data['vhost']);
294)     system_failure('Dieser Hostname ist bereits als Alias für »'.$vh['fqdn'].'« eingerichtet');
295)   }
296) }
297) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

298) function save_vhost($vhost)
299) {
300)   if (! is_array($vhost))
301)     system_failure('$vhost kein array!');
302)   $id = (int) $vhost['id'];
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

303)   $hostname = $vhost['hostname'];
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

307)   if ($vhost['domain_id'] == -1)
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

311)   }
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

312)   $hsts = (int) $vhost['hsts'];
313)   if ($hsts < 0) {
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

314)     $hsts = NULL;
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

315)   }
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

316)   $suexec_user = NULL;
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

317) 
318)   $available_suexec = available_suexec_users();
319)   foreach ($available_suexec AS $u)
320)     if ($u['uid'] == $vhost['suexec_user'])
321)       $suexec_user = $u['uid'];
322) 
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

323)   $server = NULL;
Bernd Wurst Ermögliche das Auswählen de...

Bernd Wurst authored 11 years ago

324)   $available_servers = additional_servers();
325)   if (in_array($vhost['server'], $available_servers)) {
326)     $server = (int) $vhost['server'];
327)   }
328)   if ($server == my_server_id()) {
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

329)     $server = NULL;
Bernd Wurst Ermögliche das Auswählen de...

Bernd Wurst authored 11 years ago

330)   }
331) 
bernd fix für svn/nodocroot

bernd authored 16 years ago

332)   if ($vhost['is_svn']) {
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

333)     if (! $vhost['options']) {
334)       $vhost['options']='nodocroot';
335)     } else {
336)       $vhost['options']+=",nodocroot";
337)     }
bernd nodocroot für svn-hosts

bernd authored 16 years ago

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

bernd authored 16 years ago

339) 
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

340)   $cert = NULL;
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

341)   $certs = user_certs();
342)   foreach ($certs as $c)
343)     if ($c['id'] == $vhost['cert'])
344)       $cert = $c['id'];
345) 
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

346)   $ipv4 = NULL;
bernd IP-Adressen aktivieren

bernd authored 14 years ago

347)   $ipv4_avail = user_ipaddrs();
348)   if (in_array($vhost['ipv4'], $ipv4_avail))
349)   {
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

350)     $ipv4 = $vhost['ipv4'];
bernd IP-Adressen aktivieren

bernd authored 14 years ago

351)   }
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

353)   $autoipv6 = 1;
354)   if ($vhost['autoipv6'] == 0 ||  $vhost['autoipv6'] == 2) {
355)     $autoipv6 = $vhost['autoipv6'];
356)   }
bernd IPv6

bernd authored 14 years ago

357) 
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

358)   $args = array(":hostname" => ($hostname ? $hostname : NULL),
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

359)                 ":domain" => $domain,
360)                 ":docroot" => $vhost['docroot'],
361)                 ":php" => $vhost['php'],
362)                 ":cgi" => ($vhost['cgi'] == 1 ? 1 : 0),
363)                 ":ssl" => $vhost['ssl'],
364)                 ":hsts" => $hsts,
365)                 ":suexec_user" => $suexec_user,
366)                 ":server" => $server,
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

367)                 ":logtype" => ($vhost['logtype'] ? $vhost['logtype'] : NULL),
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

368)                 ":errorlog" => (int) $vhost['errorlog'],
369)                 ":cert" => $cert,
370)                 ":ipv4" => $ipv4,
371)                 ":autoipv6" => $autoipv6,
Bernd Wurst $vhost["options"] darf in d...

Bernd Wurst authored 10 years ago

372)                 ":options" => $vhost['options'],
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

373)                 ":stats" => ($vhost['stats'] ? $vhost['stats'] : NULL),
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

374)                 ":id" => $id);
bernd Logging

bernd authored 16 years ago

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

bernd authored 14 years ago

376)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

377)     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", $args);
bernd Logging

bernd authored 16 years ago

378)   }
379)   else {
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

380)     $args[":user"] = $_SESSION['userinfo']['uid'];
381)     unset($args[":id"]);
bernd Logger mit Logleveln

bernd authored 14 years ago

382)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].'');
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

383)     $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 ".
384)                        "(:user, :hostname, :domain, :docroot, :php, :cgi, :ssl, :hsts, :suexec_user, :server, :logtype, :errorlog, :cert, :ipv4, :autoipv6, :options, :stats)", $args);
Bernd Wurst Warnung im dev-branch bzgl....

Bernd Wurst authored 10 years ago

385)     $id = db_insert_id();
bernd Logging

bernd authored 16 years ago

386)   }
bernd Webapps implementiert

bernd authored 16 years ago

387)   $oldvhost = get_vhost_details($id);
388)   /*
389)     these vars may be 0 or 1.
390)     So newval > oldval means that it has been switched on yet.
391)   */
392)   if ($vhost['is_dav'] > $oldvhost['is_dav'])
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

393)       make_dav_vhost($id);
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

395)       make_svn_vhost($id);
bernd Webapps implementiert

bernd authored 16 years ago

396)   elseif ($vhost['is_webapp'] > $oldvhost['is_webapp'])
397)       make_webapp_vhost($id, $vhost['webapp_id']);
398)   elseif ($vhost['is_dav'] == 0 && $vhost['is_svn'] == 0 && $vhost['is_webapp'] == 0)
399)       make_regular_vhost($id);
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

400) }
401) 
402) 
bernd Aliases editieren

bernd authored 16 years ago

403) function get_alias_details($id)
404) {
405)   $id = (int) $id;
406)   $uid = (int) $_SESSION['userinfo']['uid'];
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

407)   $result = db_query("SELECT * FROM vhosts.v_alias WHERE id=?", array($id));
bernd Aliases editieren

bernd authored 16 years ago

408)   
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

416)   }
bernd Aliases editieren

bernd authored 16 years ago

417) 
418)   /* Das bewirkt, dass nur die eigenen Aliase gesehen werden können */
419)   get_vhost_details( (int) $alias['vhost'] );
420) 
421)   return $alias;
422) }
423) 
424) 
425) function delete_alias($id)
426) {
427)   $id = (int) $id;
428)   $alias = get_alias_details($id);
429) 
bernd Logger mit Logleveln

bernd authored 14 years ago

430)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Removing alias #'.$id.' ('.$alias['hostname'].'.'.$alias['domain'].')');
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

431)   db_query("DELETE FROM vhosts.alias WHERE id=?", array($id));
bernd Aliases editieren

bernd authored 16 years ago

432) }
433) 
434) function save_alias($alias)
435) {
436)   if (! is_array($alias))
437)     system_failure('$alias kein array!');
bernd Neue aliase haben keine ID

bernd authored 14 years ago

438)   $id = (isset($alias['id']) ? (int) $alias['id'] : 0);
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

442)   if ($alias['domain_id'] == -1)
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

443)     $domain = NULL;
bernd Aliases editieren

bernd authored 16 years ago

444)   $vhost = get_vhost_details( (int) $alias['vhost']);
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

445)   $args = array(":hostname" => $alias['hostname'],
446)                 ":domain" => $domain,
447)                 ":vhost" => $vhost['id'],
448)                 ":options" => $alias['options'],
449)                 ":id" => $id);
bernd Aliases editieren

bernd authored 16 years ago

450)   if ($id == 0) {
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

451)     unset($args[":id"]);
bernd Logger mit Logleveln

bernd authored 14 years ago

452)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Creating alias '.$alias['hostname'].'.'.$alias['domain'].' for VHost '.$vhost['id']);
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

453)     db_query("INSERT INTO vhosts.alias (hostname, domain, vhost, options) VALUES (:hostname, :domain, :vhost, :options)", $args);
bernd Aliases editieren

bernd authored 16 years ago

454)   }
455)   else {
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

456)     unset($args[":vhost"]);
bernd Logger mit Logleveln

bernd authored 14 years ago

457)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Updating alias #'.$id.' ('.$alias['hostname'].'.'.$alias['domain'].')');
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

458)     db_query("UPDATE vhosts.alias SET hostname=:hostname, domain=:domain, options=:options WHERE id=:id", $args);
bernd Aliases editieren

bernd authored 16 years ago

459)   }
460) }
461) 
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

462) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

463) function available_suexec_users()
464) {
465)   $uid = (int) $_SESSION['userinfo']['uid'];
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

466)   $result = db_query("SELECT uid, username FROM vhosts.available_users LEFT JOIN vhosts.v_useraccounts ON (uid = suexec_user) WHERE mainuser=?", array($uid));
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

469)     $ret[] = $i;
470)   DEBUG('available suexec-users:');
471)   DEBUG($ret);
472)   return $ret;
473) 
474) }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

475) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

476) 
477) function user_ipaddrs()
478) {
479)   $uid = (int) $_SESSION['userinfo']['uid'];
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

480)   $result = db_query("SELECT ipaddr FROM vhosts.ipaddr_available WHERE uid=?", array($uid));
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

483)   {
484)     $ret[] = $i['ipaddr'];
485)   }
486)   DEBUG($ret);
487)   return $ret;
488) }
489) 
490)