c208bd906b3991555db11b9229846c4601ca408c
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) 
5) Written 2008-2012 by schokokeks.org Hosting, namely
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 Zusätzlicher Haken für eige...

bernd authored 13 years ago

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

bernd authored 13 years ago

27) {
28)   $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}");
29)   $data = mysql_fetch_assoc($result);
30)   if (!$data['v6_prefix'])
31)   {
32)     warning("IPv6-Adresse nicht verfügbar, Server unterstützt kein IPv6");
33)     return "";
34)   }
bernd Prefix-Länge herauslöschen

bernd authored 13 years ago

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

bernd authored 13 years ago

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

bernd authored 13 years ago

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

bernd authored 13 years ago

41)   return $ipv6;
42) }
43) 
44) 
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

45) function list_vhosts()
46) {
47)   $uid = (int) $_SESSION['userinfo']['uid'];
bernd CGI abschaltbar

bernd authored 14 years ago

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

49)   $ret = array();
50)   while ($item = mysql_fetch_assoc($result))
51)     array_push($ret, $item);
52)   return $ret;
53) }
54) 
bernd IPv6-fähigkeit auch richtig...

bernd authored 13 years ago

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

bernd authored 13 years ago

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

bernd authored 13 years ago

57)   $serverid = (int) $server;
58)   $servername = mysql_real_escape_string($server);
59)   $result = db_query("SELECT v6_prefix FROM system.servers WHERE id={$serverid} OR hostname='{$servername}'");
60)   $line = mysql_fetch_assoc($result);
61)   DEBUG("Server {$server} is v6-capable: ". ($line['v6_prefix'] != NULL));
62)   return ($line['v6_prefix'] != NULL);
bernd IPv6-Option nur anzeigen we...

bernd authored 13 years ago

63) }
64) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

65) function empty_vhost()
66) {
bernd neue Bilder, mehr SSL-Zerti...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

72)   
73)   $vhost['homedir'] = $_SESSION['userinfo']['homedir'];
74)   $vhost['docroot'] = NULL;
bernd PHP 5.3 als Default

bernd authored 14 years ago

75)   $vhost['php'] = 'php53';
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

77)   $vhost['ssl'] = NULL;
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

81)   $vhost['is_dav'] = 0;
82)   $vhost['is_svn'] = 0;
83)   $vhost['is_webapp'] = 0;
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

84)   $vhost['webapp_id'] = NULL;
85)   
86)   $vhost['cert'] = NULL;
bernd Einige notices (undefined i...

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 13 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

93)   return $vhost;
94) }
95) 
96) 
bernd Aliases editieren

bernd authored 16 years ago

97) function empty_alias()
98) {
99)   $alias['hostname'] = '';
100)   
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

103)   
104)   $alias['options'] = '';
105)   return $alias;
106) }
107) 
108) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

112)   if ($domainlist == NULL)
113)     $domainlist = get_domain_list($_SESSION['customerinfo']['customerno'],
114)                                   $_SESSION['userinfo']['uid']);
115)   $selected = (int) $selected;
116) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

120)   foreach ($domainlist as $dom)
121)   {
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 16 years ago

123)     $ret .= "<option value=\"{$dom->id}\"{$s}>{$dom->fqdn}</option>\n";
124)   }
125)   $ret .= '</select>';
126)   return $ret;
127) }
128) 
129) 
130) 
131) function get_vhost_details($id)
132) {
133)   $id = (int) $id;
134)   $uid = (int) $_SESSION['userinfo']['uid'];
bernd VHosts-Modul mit neuem Layo...

bernd authored 16 years ago

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

136)   if (mysql_num_rows($result) != 1)
137)     system_failure('Interner Fehler beim Auslesen der Daten');
138) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

139)   $ret = mysql_fetch_assoc($result);
140)   DEBUG($ret);
141)   return $ret;
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

142) }
143) 
144) 
145) function get_aliases($vhost)
146) {
147)   $result = db_query("SELECT id,fqdn,options FROM vhosts.v_alias WHERE vhost={$vhost}");
148)   $ret = array();
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

151)   }
152)   return $ret;
153) }
154) 
155) 
156) 
157) function get_all_aliases($vhost)
158) {
bernd Weniger Datenbankzugriffe b...

bernd authored 14 years ago

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

bernd authored 16 years ago

160)   $aliases = get_aliases($vhost['id']);
161)   $ret = array();
162)   if (strstr($vhost['options'], 'aliaswww')) {
163)     array_push($ret, array('id' => 'www', 'fqdn' => 'www.'.$vhost['fqdn'], 'options' => (strstr($vhost['options'], 'forwardwww') ? 'forward' : '')));
164)   }
165)   foreach ($aliases as $item) {
166)     array_push($ret, $item);
167)     if (strstr($item['options'], 'aliaswww')) {
168)       array_push($ret, array('id' => 'www_'.$item['id'], 'fqdn' => 'www.'.$item['fqdn'], 'options' => (strstr($item['options'], 'forward') ? 'forward' : '')));
169)     }
170)   }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

171)   return $ret;
172) }
173) 
bernd Aliases editieren

bernd authored 16 years ago

174) 
bernd Webapps implementiert

bernd authored 16 years ago

175) function list_available_webapps()
176) {
177)   $result = db_query("SELECT id,displayname FROM vhosts.global_webapps");
178)   $ret = array();
179)   while ($item = mysql_fetch_assoc($result))
180)     array_push($ret, $item);
181)   return $ret;
182) }
183) 
184) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

185) function delete_vhost($id)
186) {
187)   $id = (int) $id;
188)   if ($id == 0)
189)     system_failure("id == 0");
190)   $vhost = get_vhost_details($id);
bernd Logger mit Logleveln

bernd authored 14 years ago

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

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

205) }
206) 
207) function make_dav_vhost($id) 
208) {
209)   $id = (int) $id;
210)   if ($id == 0)
211)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

215) }
216) 
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

218) {
219)   $id = (int) $id;
220)   if ($id == 0)
221)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

225) }
226) 
227) 
228) function make_webapp_vhost($id, $webapp) 
229) {
230)   $id = (int) $id;
231)   $webapp = (int) $webapp;
232)   if ($id == 0)
233)     system_failure("id == 0");
bernd Webapps implementiert

bernd authored 16 years ago

234)   $result = db_query("SELECT displayname FROM vhosts.global_webapps WHERE id={$webapp};");
235)   if (mysql_num_rows($result) == 0)
236)     system_failure("webapp-id invalid");
237)   $webapp_name = mysql_fetch_object($result)->displayname;
bernd Logger mit Logleveln

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

241) }
242) 
243) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

244) function save_vhost($vhost)
245) {
246)   if (! is_array($vhost))
247)     system_failure('$vhost kein array!');
248)   $id = (int) $vhost['id'];
249)   $hostname = maybe_null($vhost['hostname']);
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

255)   $docroot = maybe_null($vhost['docroot']);
256)   $php = maybe_null($vhost['php']);
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

259)   $suexec_user = 'NULL';
260) 
261)   $available_suexec = available_suexec_users();
262)   foreach ($available_suexec AS $u)
263)     if ($u['uid'] == $vhost['suexec_user'])
264)       $suexec_user = $u['uid'];
265) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

272)   $options = mysql_real_escape_string( $vhost['options'] );
273) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

274)   $cert = 0;
275)   $certs = user_certs();
276)   foreach ($certs as $c)
277)     if ($c['id'] == $vhost['cert'])
278)       $cert = $c['id'];
279)   if ($cert == 0)
280)     $cert = 'NULL';
281) 
bernd IP-Adressen aktivieren

bernd authored 14 years ago

282)   $ipv4 = 'NULL';
283)   $ipv4_avail = user_ipaddrs();
284)   if (in_array($vhost['ipv4'], $ipv4_avail))
285)   {
286)     $ipv4 = maybe_null($vhost['ipv4']);
287)   }
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

289)   $autoipv6 = 1;
290)   if ($vhost['autoipv6'] == 0 ||  $vhost['autoipv6'] == 2) {
291)     $autoipv6 = $vhost['autoipv6'];
292)   }
bernd IPv6

bernd authored 14 years ago

293) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 14 years ago

295) 
bernd Logging

bernd authored 16 years ago

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

bernd authored 14 years ago

297)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

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

299)   }
300)   else {
bernd Logger mit Logleveln

bernd authored 14 years ago

301)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].'');
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

302)     $result = db_query("INSERT INTO vhosts.vhost (user, hostname, domain, docroot, php, cgi, `ssl`, `suexec_user`, logtype, errorlog, certid, ipv4, autoipv6, options, stats) VALUES ({$_SESSION['userinfo']['uid']}, {$hostname}, {$domain}, {$docroot}, {$php}, {$cgi}, {$ssl}, {$suexec_user}, {$logtype}, {$errorlog}, {$cert}, {$ipv4}, {$autoipv6}, '{$options}', {$stats})");
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

303)     $id = mysql_insert_id();
bernd Logging

bernd authored 16 years ago

304)   }
bernd Webapps implementiert

bernd authored 16 years ago

305)   $oldvhost = get_vhost_details($id);
306)   /*
307)     these vars may be 0 or 1.
308)     So newval > oldval means that it has been switched on yet.
309)   */
310)   if ($vhost['is_dav'] > $oldvhost['is_dav'])
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

311)       make_dav_vhost($id);
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

313)       make_svn_vhost($id);
bernd Webapps implementiert

bernd authored 16 years ago

314)   elseif ($vhost['is_webapp'] > $oldvhost['is_webapp'])
315)       make_webapp_vhost($id, $vhost['webapp_id']);
316)   elseif ($vhost['is_dav'] == 0 && $vhost['is_svn'] == 0 && $vhost['is_webapp'] == 0)
317)       make_regular_vhost($id);
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

318) }
319) 
320) 
bernd Aliases editieren

bernd authored 16 years ago

321) function get_alias_details($id)
322) {
323)   $id = (int) $id;
324)   $uid = (int) $_SESSION['userinfo']['uid'];
325)   $result = db_query("SELECT * FROM vhosts.v_alias WHERE id={$id}");
326)   
327)   if (mysql_num_rows($result) != 1)
328)     system_failure('Interner Fehler beim Auslesen der Alias-Daten');
329)   
330)   $alias = mysql_fetch_assoc($result);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

334)   }
bernd Aliases editieren

bernd authored 16 years ago

335) 
336)   /* Das bewirkt, dass nur die eigenen Aliase gesehen werden können */
337)   get_vhost_details( (int) $alias['vhost'] );
338) 
339)   return $alias;
340) }
341) 
342) 
343) function delete_alias($id)
344) {
345)   $id = (int) $id;
346)   $alias = get_alias_details($id);
347) 
bernd Logger mit Logleveln

bernd authored 14 years ago

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

bernd authored 16 years ago

349)   db_query("DELETE FROM vhosts.alias WHERE id={$id}");
350) }
351) 
352) function save_alias($alias)
353) {
354)   if (! is_array($alias))
355)     system_failure('$alias kein array!');
bernd Neue aliase haben keine ID

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

363)   $vhost = get_vhost_details( (int) $alias['vhost']);
364)   $options = mysql_real_escape_string( $alias['options'] );
365)   if ($id == 0) {
bernd Logger mit Logleveln

bernd authored 14 years ago

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

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

bernd authored 14 years ago

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

bernd authored 16 years ago

371)     db_query("UPDATE vhosts.alias SET hostname={$hostname}, domain={$domain}, options='{$options}' WHERE id={$id} LIMIT 1");
372)   }
373) }
374) 
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

375) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

376) function available_suexec_users()
377) {
378)   $uid = (int) $_SESSION['userinfo']['uid'];
379)   $result = db_query("SELECT uid, username FROM vhosts.available_users LEFT JOIN vhosts.v_useraccounts ON (uid = suexec_user) WHERE mainuser={$uid}");
380)   $ret = array();
381)   while ($i = mysql_fetch_assoc($result))
382)     $ret[] = $i;
383)   DEBUG('available suexec-users:');
384)   DEBUG($ret);
385)   return $ret;
386) 
387) }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

388) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

389) 
390) function user_ipaddrs()
391) {
392)   $uid = (int) $_SESSION['userinfo']['uid'];
393)   $result = db_query("SELECT ipaddr FROM vhosts.ipaddr_available WHERE uid={$uid}");
394)   $ret = array();
395)   while ($i = mysql_fetch_assoc($result))
396)   {
397)     $ret[] = $i['ipaddr'];
398)   }
399)   DEBUG($ret);
400)   return $ret;
401) }
402) 
403)