33819571e30027cae0ae8df3248a40ef77dd9c4d
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 Lizenzinfos in eigenes Modu...

Bernd Wurst authored 10 years ago

5) Written 2008-2014 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 Wurst Link auf Website / Ermöglic...

Bernd Wurst authored 9 years ago

53) function list_vhosts($domainname=NULL)
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

54) {
55)   $uid = (int) $_SESSION['userinfo']['uid'];
Bernd Wurst Link auf Website / Ermöglic...

Bernd Wurst authored 9 years ago

56)   $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";
57)   $params = array(":uid" => $uid);
58)   if ($domainname) {
59)     $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 domain=:domain AND uid=:uid ORDER BY hostname";
60)     $params[":domain"] = $domainname;
61)   }
62)   $result = db_query($query, $params);
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

65)     array_push($ret, $item);
66)   return $ret;
67) }
68) 
bernd IPv6-fähigkeit auch richtig...

bernd authored 13 years ago

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

bernd authored 13 years ago

70) {
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

71)   $args = array(":server" => $server);
72)   $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

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

bernd authored 13 years ago

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

bernd authored 13 years ago

76) }
77) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

78) function empty_vhost()
79) {
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

85)   
86)   $vhost['homedir'] = $_SESSION['userinfo']['homedir'];
87)   $vhost['docroot'] = NULL;
Hanno Böck php 5.5 default

Hanno Böck authored 10 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

Bernd Wurst authored 11 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

96)   $vhost['is_dav'] = 0;
97)   $vhost['is_svn'] = 0;
98)   $vhost['is_webapp'] = 0;
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

99)   $vhost['webapp_id'] = NULL;
100)   
101)   $vhost['cert'] = NULL;
bernd Einige notices (undefined i...

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 13 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

108)   return $vhost;
109) }
110) 
111) 
bernd Aliases editieren

bernd authored 16 years ago

112) function empty_alias()
113) {
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

120)   return $alias;
121) }
122) 
123) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

127)   if ($domainlist == NULL)
128)     $domainlist = get_domain_list($_SESSION['customerinfo']['customerno'],
129)                                   $_SESSION['userinfo']['uid']);
130)   $selected = (int) $selected;
131) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

138)     $s = '';
139)     if ($selected == $dom->id) {
140)       $s = ' selected="selected" ';
141)       $found = true;
142)     }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

149)   return $ret;
150) }
151) 
152) 
153) 
154) function get_vhost_details($id)
155) {
156)   $id = (int) $id;
157)   $uid = (int) $_SESSION['userinfo']['uid'];
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

158)   $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

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 10 years ago

164)   if ($ret['hsts'] === NULL) {
165)     DEBUG('HSTS: '.$ret['hsts']);
166)     $ret['hsts'] = -1;
167)   }
Bernd Wurst bugfix: server vorausgewählt

Bernd Wurst authored 11 years ago

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

bernd authored 14 years ago

169)   DEBUG($ret);
170)   return $ret;
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

171) }
172) 
173) 
174) function get_aliases($vhost)
175) {
Bernd Wurst Einige Statements auf Prepa...

Bernd Wurst authored 10 years ago

176)   $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

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

180)   }
181)   return $ret;
182) }
183) 
184) 
185) 
186) function get_all_aliases($vhost)
187) {
bernd Weniger Datenbankzugriffe b...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

193)   }
194)   foreach ($aliases as $item) {
195)     array_push($ret, $item);
196)     if (strstr($item['options'], 'aliaswww')) {
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

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

198)     }
199)   }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

200)   return $ret;
201) }
202) 
bernd Aliases editieren

bernd authored 16 years ago

203) 
bernd Webapps implementiert

bernd authored 16 years ago

204) function list_available_webapps()
205) {
206)   $result = db_query("SELECT id,displayname FROM vhosts.global_webapps");
207)   $ret = array();
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

209)     array_push($ret, $item);
210)   return $ret;
211) }
212) 
213) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

214) function delete_vhost($id)
215) {
216)   $id = (int) $id;
217)   if ($id == 0)
218)     system_failure("id == 0");
219)   $vhost = get_vhost_details($id);
bernd Logger mit Logleveln

bernd authored 14 years ago

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

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

bernd authored 16 years ago

222) }
223) 
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 16 years ago

225) 
226) function make_svn_vhost($id) 
227) {
228)   $id = (int) $id;
229)   if ($id == 0)
230)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

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

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

bernd authored 16 years ago

234) }
235) 
236) function make_dav_vhost($id) 
237) {
238)   $id = (int) $id;
239)   if ($id == 0)
240)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

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

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

bernd authored 16 years ago

244) }
245) 
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

247) {
248)   $id = (int) $id;
249)   if ($id == 0)
250)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

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

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

bernd authored 16 years ago

254) }
255) 
256) 
257) function make_webapp_vhost($id, $webapp) 
258) {
259)   $id = (int) $id;
260)   $webapp = (int) $webapp;
261)   if ($id == 0)
262)     system_failure("id == 0");
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

263)   $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

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

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

bernd authored 16 years ago

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

bernd authored 16 years ago

270) }
271) 
272) 
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

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

schokokeks.org GbR authored 10 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 10 years ago

281)     unset($args[":hostname"]);
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)   $domaincheck = "domain=:domain";
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 10 years ago

289)   $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

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

Bernd Wurst authored 11 years ago

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

schokokeks.org GbR authored 10 years ago

293)   if ($domain == -1) {
294)     return ;
295)   }
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

296)   $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

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

Bernd Wurst authored 11 years ago

299)     $vh = get_vhost_details($data['vhost']);
300)     system_failure('Dieser Hostname ist bereits als Alias für »'.$vh['fqdn'].'« eingerichtet');
301)   }
302) }
303) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

304) function save_vhost($vhost)
305) {
306)   if (! is_array($vhost))
307)     system_failure('$vhost kein array!');
308)   $id = (int) $vhost['id'];
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

323) 
324)   $available_suexec = available_suexec_users();
325)   foreach ($available_suexec AS $u)
326)     if ($u['uid'] == $vhost['suexec_user'])
327)       $suexec_user = $u['uid'];
328) 
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)   $available_servers = additional_servers();
331)   if (in_array($vhost['server'], $available_servers)) {
332)     $server = (int) $vhost['server'];
333)   }
334)   if ($server == my_server_id()) {
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 11 years ago

336)   }
337) 
bernd fix für svn/nodocroot

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

339)     if (! $vhost['options']) {
340)       $vhost['options']='nodocroot';
341)     } else {
342)       $vhost['options']+=",nodocroot";
343)     }
bernd nodocroot für svn-hosts

bernd authored 16 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

346)   $cert = NULL;
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

347)   $certs = user_certs();
348)   foreach ($certs as $c)
349)     if ($c['id'] == $vhost['cert'])
350)       $cert = $c['id'];
351) 
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

357)   }
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

359)   $autoipv6 = 1;
360)   if ($vhost['autoipv6'] == 0 ||  $vhost['autoipv6'] == 2) {
361)     $autoipv6 = $vhost['autoipv6'];
362)   }
bernd IPv6

bernd authored 14 years ago

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

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 10 years ago

365)                 ":domain" => $domain,
366)                 ":docroot" => $vhost['docroot'],
367)                 ":php" => $vhost['php'],
368)                 ":cgi" => ($vhost['cgi'] == 1 ? 1 : 0),
369)                 ":ssl" => $vhost['ssl'],
370)                 ":hsts" => $hsts,
371)                 ":suexec_user" => $suexec_user,
372)                 ":server" => $server,
Bernd Wurst Bugfix: Werte dürfen nicht...

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 10 years ago

374)                 ":errorlog" => (int) $vhost['errorlog'],
375)                 ":cert" => $cert,
376)                 ":ipv4" => $ipv4,
377)                 ":autoipv6" => $autoipv6,
Bernd Wurst $vhost["options"] darf in d...

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

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

384)   }
385)   else {
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

389)     $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 ".
390)                        "(: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

391)     $id = db_insert_id();
bernd Logging

bernd authored 16 years ago

392)   }
bernd Webapps implementiert

bernd authored 16 years ago

393)   $oldvhost = get_vhost_details($id);
394)   /*
395)     these vars may be 0 or 1.
396)     So newval > oldval means that it has been switched on yet.
397)   */
398)   if ($vhost['is_dav'] > $oldvhost['is_dav'])
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

399)       make_dav_vhost($id);
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

401)       make_svn_vhost($id);
bernd Webapps implementiert

bernd authored 16 years ago

402)   elseif ($vhost['is_webapp'] > $oldvhost['is_webapp'])
403)       make_webapp_vhost($id, $vhost['webapp_id']);
404)   elseif ($vhost['is_dav'] == 0 && $vhost['is_svn'] == 0 && $vhost['is_webapp'] == 0)
405)       make_regular_vhost($id);
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

406) }
407) 
408) 
bernd Aliases editieren

bernd authored 16 years ago

409) function get_alias_details($id)
410) {
411)   $id = (int) $id;
412)   $uid = (int) $_SESSION['userinfo']['uid'];
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

422)   }
bernd Aliases editieren

bernd authored 16 years ago

423) 
424)   /* Das bewirkt, dass nur die eigenen Aliase gesehen werden können */
425)   get_vhost_details( (int) $alias['vhost'] );
426) 
427)   return $alias;
428) }
429) 
430) 
431) function delete_alias($id)
432) {
433)   $id = (int) $id;
434)   $alias = get_alias_details($id);
435) 
bernd Logger mit Logleveln

bernd authored 14 years ago

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

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

bernd authored 16 years ago

438) }
439) 
440) function save_alias($alias)
441) {
442)   if (! is_array($alias))
443)     system_failure('$alias kein array!');
bernd Neue aliase haben keine ID

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

Bernd Wurst authored 10 years ago

449)     $domain = NULL;
bernd Aliases editieren

bernd authored 16 years ago

450)   $vhost = get_vhost_details( (int) $alias['vhost']);
Bernd Wurst Bei Aliasnamen darf kein le...

Bernd Wurst authored 10 years ago

451)   if (! $alias['hostname']) {
452)     $alias['hostname'] = NULL;
453)   }
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

454)   $args = array(":hostname" => $alias['hostname'],
455)                 ":domain" => $domain,
456)                 ":vhost" => $vhost['id'],
457)                 ":options" => $alias['options'],
458)                 ":id" => $id);
bernd Aliases editieren

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

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

bernd authored 16 years ago

463)   }
464)   else {
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

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

bernd authored 16 years ago

468)   }
469) }
470) 
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

471) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

472) function available_suexec_users()
473) {
474)   $uid = (int) $_SESSION['userinfo']['uid'];
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

475)   $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

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

478)     $ret[] = $i;
479)   DEBUG('available suexec-users:');
480)   DEBUG($ret);
481)   return $ret;
482) 
483) }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

484) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

485) 
486) function user_ipaddrs()
487) {
488)   $uid = (int) $_SESSION['userinfo']['uid'];
Bernd Wurst * Weitere Module auf prepar...

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

492)   {
493)     $ret[] = $i['ipaddr'];
494)   }
495)   DEBUG($ret);
496)   return $ret;
497) }
498) 
499)