4b6dffbda358db64a31022c813cec50434eb9fcf
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

1) <?php
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
Bernd Wurst Updated copyright notice (2...

Bernd Wurst authored 11 years ago

5) Written 2008-2013 by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10) 
11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
12) http://creativecommons.org/publicdomain/zero/1.0/
13) 
14) Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15) */
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 11 years ago

26) function traffic_month($vhost_id)
27) {
28)   $vhost_id = (int) $vhost_id;
29)   $result = db_query("SELECT sum(mb_in+mb_out) as mb FROM vhosts.traffic where date > CURDATE() - INTERVAL 1 MONTH AND vhost_id = {$vhost_id}");
30)   $data = mysql_fetch_assoc($result);
31)   return $data['mb'];
32) }
33) 
bernd Zusätzlicher Haken für eige...

bernd authored 13 years ago

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

bernd authored 13 years ago

35) {
36)   $result = db_query("SELECT uid, v6_prefix FROM vhosts.v_vhost LEFT JOIN system.servers ON (servers.hostname = server) WHERE v_vhost.id={$vhost_id}");
37)   $data = mysql_fetch_assoc($result);
38)   if (!$data['v6_prefix'])
39)   {
40)     warning("IPv6-Adresse nicht verfügbar, Server unterstützt kein IPv6");
41)     return "";
42)   }
bernd Prefix-Länge herauslöschen

bernd authored 13 years ago

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

bernd authored 13 years ago

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

bernd authored 13 years ago

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

bernd authored 13 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

57)   $ret = array();
58)   while ($item = mysql_fetch_assoc($result))
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;
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);
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 VHosts-Modul mit neuem Layo...

bernd authored 16 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}");
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

145)   if (mysql_num_rows($result) != 1)
146)     system_failure('Interner Fehler beim Auslesen der Daten');
147) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 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) {
158)   $result = db_query("SELECT id,fqdn,options FROM vhosts.v_alias WHERE vhost={$vhost}");
159)   $ret = array();
bernd Aliases editieren

bernd authored 16 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) {
188)   $result = db_query("SELECT id,displayname FROM vhosts.global_webapps");
189)   $ret = array();
190)   while ($item = mysql_fetch_assoc($result))
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 VHosts können bearbeitet we...

bernd authored 16 years ago

203)   db_query("DELETE FROM vhosts.vhost WHERE id={$vhost['id']} LIMIT 1");
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 letzter commit rückgängig

bernd authored 16 years ago

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

bernd authored 16 years ago

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 Docroot auch bei WebDAV anz...

bernd authored 16 years ago

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

bernd authored 16 years ago

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 vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

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

bernd authored 16 years ago

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 Webapps implementiert

bernd authored 16 years ago

245)   $result = db_query("SELECT displayname FROM vhosts.global_webapps WHERE id={$webapp};");
246)   if (mysql_num_rows($result) == 0)
247)     system_failure("webapp-id invalid");
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 Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

252) }
253) 
254) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

255) function save_vhost($vhost)
256) {
257)   if (! is_array($vhost))
258)     system_failure('$vhost kein array!');
259)   $id = (int) $vhost['id'];
260)   $hostname = maybe_null($vhost['hostname']);
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

265)     $domain = 'NULL';
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

266)   $docroot = maybe_null($vhost['docroot']);
267)   $php = maybe_null($vhost['php']);
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

270)   $suexec_user = 'NULL';
271) 
272)   $available_suexec = available_suexec_users();
273)   foreach ($available_suexec AS $u)
274)     if ($u['uid'] == $vhost['suexec_user'])
275)       $suexec_user = $u['uid'];
276) 
Bernd Wurst Ermögliche das Auswählen de...

Bernd Wurst authored 11 years ago

277)   $server = 'NULL';
278)   $available_servers = additional_servers();
279)   if (in_array($vhost['server'], $available_servers)) {
280)     $server = (int) $vhost['server'];
281)   }
282)   if ($server == my_server_id()) {
283)     $server = 'NULL';
284)   }
285) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

289)     if (! $vhost['options']) $vhost['options']='nodocroot';
290)     else $vhost['options']+=",nodocroot";
291)   }
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

292)   $options = mysql_real_escape_string( $vhost['options'] );
293) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

294)   $cert = 0;
295)   $certs = user_certs();
296)   foreach ($certs as $c)
297)     if ($c['id'] == $vhost['cert'])
298)       $cert = $c['id'];
299)   if ($cert == 0)
300)     $cert = 'NULL';
301) 
bernd IP-Adressen aktivieren

bernd authored 14 years ago

302)   $ipv4 = 'NULL';
303)   $ipv4_avail = user_ipaddrs();
304)   if (in_array($vhost['ipv4'], $ipv4_avail))
305)   {
306)     $ipv4 = maybe_null($vhost['ipv4']);
307)   }
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

309)   $autoipv6 = 1;
310)   if ($vhost['autoipv6'] == 0 ||  $vhost['autoipv6'] == 2) {
311)     $autoipv6 = $vhost['autoipv6'];
312)   }
bernd IPv6

bernd authored 14 years ago

313) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 14 years ago

315) 
bernd Logging

bernd authored 16 years ago

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

bernd authored 14 years ago

317)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
Bernd Wurst Ermögliche das Auswählen de...

Bernd Wurst authored 11 years ago

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

319)   }
320)   else {
bernd Logger mit Logleveln

bernd authored 14 years ago

321)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].'');
Bernd Wurst Ermögliche das Auswählen de...

Bernd Wurst authored 11 years ago

322)     $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})");
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

323)     $id = mysql_insert_id();
bernd Logging

bernd authored 16 years ago

324)   }
bernd Webapps implementiert

bernd authored 16 years ago

325)   $oldvhost = get_vhost_details($id);
326)   /*
327)     these vars may be 0 or 1.
328)     So newval > oldval means that it has been switched on yet.
329)   */
330)   if ($vhost['is_dav'] > $oldvhost['is_dav'])
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

331)       make_dav_vhost($id);
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

333)       make_svn_vhost($id);
bernd Webapps implementiert

bernd authored 16 years ago

334)   elseif ($vhost['is_webapp'] > $oldvhost['is_webapp'])
335)       make_webapp_vhost($id, $vhost['webapp_id']);
336)   elseif ($vhost['is_dav'] == 0 && $vhost['is_svn'] == 0 && $vhost['is_webapp'] == 0)
337)       make_regular_vhost($id);
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

338) }
339) 
340) 
bernd Aliases editieren

bernd authored 16 years ago

341) function get_alias_details($id)
342) {
343)   $id = (int) $id;
344)   $uid = (int) $_SESSION['userinfo']['uid'];
345)   $result = db_query("SELECT * FROM vhosts.v_alias WHERE id={$id}");
346)   
347)   if (mysql_num_rows($result) != 1)
348)     system_failure('Interner Fehler beim Auslesen der Alias-Daten');
349)   
350)   $alias = mysql_fetch_assoc($result);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

354)   }
bernd Aliases editieren

bernd authored 16 years ago

355) 
356)   /* Das bewirkt, dass nur die eigenen Aliase gesehen werden können */
357)   get_vhost_details( (int) $alias['vhost'] );
358) 
359)   return $alias;
360) }
361) 
362) 
363) function delete_alias($id)
364) {
365)   $id = (int) $id;
366)   $alias = get_alias_details($id);
367) 
bernd Logger mit Logleveln

bernd authored 14 years ago

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

bernd authored 16 years ago

369)   db_query("DELETE FROM vhosts.alias WHERE id={$id}");
370) }
371) 
372) function save_alias($alias)
373) {
374)   if (! is_array($alias))
375)     system_failure('$alias kein array!');
bernd Neue aliase haben keine ID

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

383)   $vhost = get_vhost_details( (int) $alias['vhost']);
384)   $options = mysql_real_escape_string( $alias['options'] );
385)   if ($id == 0) {
bernd Logger mit Logleveln

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

391)     db_query("UPDATE vhosts.alias SET hostname={$hostname}, domain={$domain}, options='{$options}' WHERE id={$id} LIMIT 1");
392)   }
393) }
394) 
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

395) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

396) function available_suexec_users()
397) {
398)   $uid = (int) $_SESSION['userinfo']['uid'];
399)   $result = db_query("SELECT uid, username FROM vhosts.available_users LEFT JOIN vhosts.v_useraccounts ON (uid = suexec_user) WHERE mainuser={$uid}");
400)   $ret = array();
401)   while ($i = mysql_fetch_assoc($result))
402)     $ret[] = $i;
403)   DEBUG('available suexec-users:');
404)   DEBUG($ret);
405)   return $ret;
406) 
407) }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

408) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

409) 
410) function user_ipaddrs()
411) {
412)   $uid = (int) $_SESSION['userinfo']['uid'];
413)   $result = db_query("SELECT ipaddr FROM vhosts.ipaddr_available WHERE uid={$uid}");
414)   $ret = array();
415)   while ($i = mysql_fetch_assoc($result))
416)   {
417)     $ret[] = $i['ipaddr'];
418)   }
419)   DEBUG($ret);
420)   return $ret;
421) }
422) 
423)