bd22f03937341179a1beaf87aafcde8e61882589
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 Revert "Umstellung auf mysqli"

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 = {$vhost_id}");
30)   $data = mysql_fetch_assoc($result);
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 Revert "Umstellung auf mysqli"

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={$vhost_id}");
37)   $data = mysql_fetch_assoc($result);
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 Revert "Umstellung auf mysqli"

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={$uid} ORDER BY domain,hostname");
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

57)   $ret = array();
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

58)   while ($item = mysql_fetch_assoc($result))
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 Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

66)   $servername = mysql_real_escape_string($server);
67)   $result = db_query("SELECT v6_prefix FROM system.servers WHERE id={$serverid} OR hostname='{$servername}'");
68)   $line = mysql_fetch_assoc($result);
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 15 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;
Bernd Wurst Default ist PHP 5.4

Bernd Wurst authored 11 years ago

83)   $vhost['php'] = 'php54';
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 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) {
108)   $alias['hostname'] = '';
109)   
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 15 years ago

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

bernd authored 16 years ago

112)   
113)   $alias['options'] = '';
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 15 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 15 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 neues VHosts-Modul (unbenut...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

132)     $ret .= "<option value=\"{$dom->id}\"{$s}>{$dom->fqdn}</option>\n";
133)   }
134)   $ret .= '</select>';
135)   return $ret;
136) }
137) 
138) 
139) 
140) function get_vhost_details($id)
141) {
142)   $id = (int) $id;
143)   $uid = (int) $_SESSION['userinfo']['uid'];
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

144)   $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}");
145)   if (mysql_num_rows($result) != 1)
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

146)     system_failure('Interner Fehler beim Auslesen der Daten');
147) 
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

148)   $ret = mysql_fetch_assoc($result);
Bernd Wurst bugfix: server vorausgewählt

Bernd Wurst authored 11 years ago

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

bernd authored 14 years ago

151)   DEBUG($ret);
152)   return $ret;
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

153) }
154) 
155) 
156) function get_aliases($vhost)
157) {
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

159)   $ret = array();
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

160)   while ($item = mysql_fetch_assoc($result)) {
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

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

bernd authored 16 years ago

162)   }
163)   return $ret;
164) }
165) 
166) 
167) 
168) function get_all_aliases($vhost)
169) {
bernd Weniger Datenbankzugriffe b...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

182)   return $ret;
183) }
184) 
bernd Aliases editieren

bernd authored 16 years ago

185) 
bernd Webapps implementiert

bernd authored 16 years ago

186) function list_available_webapps()
187) {
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

188)   $result = db_query("SELECT id,displayname FROM vhosts.global_webapps");
bernd Webapps implementiert

bernd authored 16 years ago

189)   $ret = array();
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

190)   while ($item = mysql_fetch_assoc($result))
bernd Webapps implementiert

bernd authored 16 years ago

191)     array_push($ret, $item);
192)   return $ret;
193) }
194) 
195) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

196) function delete_vhost($id)
197) {
198)   $id = (int) $id;
199)   if ($id == 0)
200)     system_failure("id == 0");
201)   $vhost = get_vhost_details($id);
bernd Logger mit Logleveln

bernd authored 14 years ago

202)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Removing vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

203)   db_query("DELETE FROM vhosts.vhost WHERE id={$vhost['id']} LIMIT 1");
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

204) }
205) 
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 16 years ago

207) 
208) function make_svn_vhost($id) 
209) {
210)   $id = (int) $id;
211)   if ($id == 0)
212)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

213)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to SVN');
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

214)   db_query("REPLACE INTO vhosts.dav (vhost, type) VALUES ({$id}, 'svn')");
215)   db_query("DELETE FROM vhosts.webapps WHERE vhost={$id}");
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

216) }
217) 
218) function make_dav_vhost($id) 
219) {
220)   $id = (int) $id;
221)   if ($id == 0)
222)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

223)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to WebDAV');
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

224)   db_query("REPLACE INTO vhosts.dav (vhost, type, options) VALUES ({$id}, 'dav', 'nouserfile')");
225)   db_query("DELETE FROM vhosts.webapps WHERE vhost={$id}");
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

226) }
227) 
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

229) {
230)   $id = (int) $id;
231)   if ($id == 0)
232)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

233)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to regular');
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

236) }
237) 
238) 
239) function make_webapp_vhost($id, $webapp) 
240) {
241)   $id = (int) $id;
242)   $webapp = (int) $webapp;
243)   if ($id == 0)
244)     system_failure("id == 0");
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

245)   $result = db_query("SELECT displayname FROM vhosts.global_webapps WHERE id={$webapp};");
246)   if (mysql_num_rows($result) == 0)
bernd Webapps implementiert

bernd authored 16 years ago

247)     system_failure("webapp-id invalid");
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

248)   $webapp_name = mysql_fetch_object($result)->displayname;
bernd Logger mit Logleveln

bernd authored 14 years ago

249)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Setting up webapp '.$webapp_name.' on vhost #'.$id);
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

250)   db_query("REPLACE INTO vhosts.webapps (vhost, webapp) VALUES ({$id}, {$webapp})");
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

252) }
253) 
254) 
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

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

schokokeks.org GbR authored 10 years ago

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

Bernd Wurst authored 11 years ago

258)   # Neuer vhost => Prüfe Duplikat
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 11 years ago

260)   if (! $hostname) {
261)     $hostnamecheck = "hostname IS NULL";
262)   }
263)   $domaincheck = "domain=". (int) $domain ;
264)   if ($domain == -1) {
schokokeks.org GbR Kollisions-Check für VHosts...

schokokeks.org GbR authored 10 years ago

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

Bernd Wurst authored 11 years ago

266)   }
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

267)   $result = db_query("SELECT id FROM vhosts.vhost WHERE {$hostnamecheck} AND {$domaincheck}");
268)   if (mysql_num_rows($result) > 0) {
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

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

schokokeks.org GbR authored 10 years ago

271)   if ($domain == -1) {
272)     return ;
273)   }
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

274)   $result = db_query("SELECT id, vhost FROM vhosts.alias WHERE {$hostnamecheck} AND {$domaincheck}");
275)   if (mysql_num_rows($result) > 0) {
276)     $data = mysql_fetch_assoc($result);
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

277)     $vh = get_vhost_details($data['vhost']);
278)     system_failure('Dieser Hostname ist bereits als Alias für »'.$vh['fqdn'].'« eingerichtet');
279)   }
280) }
281) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

282) function save_vhost($vhost)
283) {
284)   if (! is_array($vhost))
285)     system_failure('$vhost kein array!');
286)   $id = (int) $vhost['id'];
287)   $hostname = maybe_null($vhost['hostname']);
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

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

bernd authored 16 years ago

296)   $docroot = maybe_null($vhost['docroot']);
297)   $php = maybe_null($vhost['php']);
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

299)   $ssl = maybe_null($vhost['ssl']);
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

300)   $suexec_user = 'NULL';
301) 
302)   $available_suexec = available_suexec_users();
303)   foreach ($available_suexec AS $u)
304)     if ($u['uid'] == $vhost['suexec_user'])
305)       $suexec_user = $u['uid'];
306) 
Bernd Wurst Ermögliche das Auswählen de...

Bernd Wurst authored 11 years ago

307)   $server = 'NULL';
308)   $available_servers = additional_servers();
309)   if (in_array($vhost['server'], $available_servers)) {
310)     $server = (int) $vhost['server'];
311)   }
312)   if ($server == my_server_id()) {
313)     $server = 'NULL';
314)   }
315) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

319)     if (! $vhost['options']) $vhost['options']='nodocroot';
320)     else $vhost['options']+=",nodocroot";
321)   }
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

323) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

324)   $cert = 0;
325)   $certs = user_certs();
326)   foreach ($certs as $c)
327)     if ($c['id'] == $vhost['cert'])
328)       $cert = $c['id'];
329)   if ($cert == 0)
330)     $cert = 'NULL';
331) 
bernd IP-Adressen aktivieren

bernd authored 14 years ago

332)   $ipv4 = 'NULL';
333)   $ipv4_avail = user_ipaddrs();
334)   if (in_array($vhost['ipv4'], $ipv4_avail))
335)   {
336)     $ipv4 = maybe_null($vhost['ipv4']);
337)   }
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

339)   $autoipv6 = 1;
340)   if ($vhost['autoipv6'] == 0 ||  $vhost['autoipv6'] == 2) {
341)     $autoipv6 = $vhost['autoipv6'];
342)   }
bernd IPv6

bernd authored 14 years ago

343) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 14 years ago

345) 
bernd Logging

bernd authored 16 years ago

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

bernd authored 14 years ago

347)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

348)     db_query("UPDATE vhosts.vhost SET hostname={$hostname}, domain={$domain}, docroot={$docroot}, php={$php}, cgi={$cgi}, `ssl`={$ssl}, `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

349)   }
350)   else {
bernd Logger mit Logleveln

bernd authored 14 years ago

351)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].'');
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

352)     $result = db_query("INSERT INTO vhosts.vhost (user, hostname, domain, docroot, php, cgi, `ssl`, `suexec_user`, `server`, logtype, errorlog, certid, ipv4, autoipv6, options, stats) VALUES ({$_SESSION['userinfo']['uid']}, {$hostname}, {$domain}, {$docroot}, {$php}, {$cgi}, {$ssl}, {$suexec_user}, {$server}, {$logtype}, {$errorlog}, {$cert}, {$ipv4}, {$autoipv6}, '{$options}', {$stats})");
353)     $id = mysql_insert_id();
bernd Logging

bernd authored 16 years ago

354)   }
bernd Webapps implementiert

bernd authored 16 years ago

355)   $oldvhost = get_vhost_details($id);
356)   /*
357)     these vars may be 0 or 1.
358)     So newval > oldval means that it has been switched on yet.
359)   */
360)   if ($vhost['is_dav'] > $oldvhost['is_dav'])
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

361)       make_dav_vhost($id);
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

363)       make_svn_vhost($id);
bernd Webapps implementiert

bernd authored 16 years ago

364)   elseif ($vhost['is_webapp'] > $oldvhost['is_webapp'])
365)       make_webapp_vhost($id, $vhost['webapp_id']);
366)   elseif ($vhost['is_dav'] == 0 && $vhost['is_svn'] == 0 && $vhost['is_webapp'] == 0)
367)       make_regular_vhost($id);
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

368) }
369) 
370) 
bernd Aliases editieren

bernd authored 16 years ago

371) function get_alias_details($id)
372) {
373)   $id = (int) $id;
374)   $uid = (int) $_SESSION['userinfo']['uid'];
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

375)   $result = db_query("SELECT * FROM vhosts.v_alias WHERE id={$id}");
bernd Aliases editieren

bernd authored 16 years ago

376)   
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

377)   if (mysql_num_rows($result) != 1)
bernd Aliases editieren

bernd authored 16 years ago

378)     system_failure('Interner Fehler beim Auslesen der Alias-Daten');
379)   
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

380)   $alias = mysql_fetch_assoc($result);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

384)   }
bernd Aliases editieren

bernd authored 16 years ago

385) 
386)   /* Das bewirkt, dass nur die eigenen Aliase gesehen werden können */
387)   get_vhost_details( (int) $alias['vhost'] );
388) 
389)   return $alias;
390) }
391) 
392) 
393) function delete_alias($id)
394) {
395)   $id = (int) $id;
396)   $alias = get_alias_details($id);
397) 
bernd Logger mit Logleveln

bernd authored 14 years ago

398)   logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Removing alias #'.$id.' ('.$alias['hostname'].'.'.$alias['domain'].')');
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

399)   db_query("DELETE FROM vhosts.alias WHERE id={$id}");
bernd Aliases editieren

bernd authored 16 years ago

400) }
401) 
402) function save_alias($alias)
403) {
404)   if (! is_array($alias))
405)     system_failure('$alias kein array!');
bernd Neue aliase haben keine ID

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

413)   $vhost = get_vhost_details( (int) $alias['vhost']);
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

414)   $options = mysql_real_escape_string( $alias['options'] );
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 14 years ago

416)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Creating alias '.$alias['hostname'].'.'.$alias['domain'].' for VHost '.$vhost['id']);
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

417)     db_query("INSERT INTO vhosts.alias (hostname, domain, vhost, options) VALUES ({$hostname}, {$domain}, {$vhost['id']}, '{$options}')");
bernd Aliases editieren

bernd authored 16 years ago

418)   }
419)   else {
bernd Logger mit Logleveln

bernd authored 14 years ago

420)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Updating alias #'.$id.' ('.$alias['hostname'].'.'.$alias['domain'].')');
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

421)     db_query("UPDATE vhosts.alias SET hostname={$hostname}, domain={$domain}, options='{$options}' WHERE id={$id} LIMIT 1");
bernd Aliases editieren

bernd authored 16 years ago

422)   }
423) }
424) 
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

425) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

426) function available_suexec_users()
427) {
428)   $uid = (int) $_SESSION['userinfo']['uid'];
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

430)   $ret = array();
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

431)   while ($i = mysql_fetch_assoc($result))
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

432)     $ret[] = $i;
433)   DEBUG('available suexec-users:');
434)   DEBUG($ret);
435)   return $ret;
436) 
437) }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

438) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

439) 
440) function user_ipaddrs()
441) {
442)   $uid = (int) $_SESSION['userinfo']['uid'];
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

443)   $result = db_query("SELECT ipaddr FROM vhosts.ipaddr_available WHERE uid={$uid}");
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

444)   $ret = array();
Bernd Wurst Revert "Umstellung auf mysqli"

Bernd Wurst authored 10 years ago

445)   while ($i = mysql_fetch_assoc($result))
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

446)   {
447)     $ret[] = $i['ipaddr'];
448)   }
449)   DEBUG($ret);
450)   return $ret;
451) }
452) 
453)