5231fb2f16a0c488f95833b13a61dd7a52c58c02
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 Wurst Default ist PHP 5.4

Bernd Wurst authored 11 years ago

75)   $vhost['php'] = 'php54';
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 Wurst Ermögliche das Auswählen de...

Bernd Wurst authored 11 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 13 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

175) 
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

206) }
207) 
208) function make_dav_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 WebDAV');
bernd Docroot auch bei WebDAV anz...

bernd authored 16 years ago

214)   db_query("REPLACE INTO vhosts.dav (vhost, type, options) VALUES ({$id}, 'dav', 'nouserfile')");
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) 
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

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 regular');
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

224)   db_query("DELETE FROM vhosts.dav WHERE vhost={$id}");
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) 
228) 
229) function make_webapp_vhost($id, $webapp) 
230) {
231)   $id = (int) $id;
232)   $webapp = (int) $webapp;
233)   if ($id == 0)
234)     system_failure("id == 0");
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

260)   $suexec_user = 'NULL';
261) 
262)   $available_suexec = available_suexec_users();
263)   foreach ($available_suexec AS $u)
264)     if ($u['uid'] == $vhost['suexec_user'])
265)       $suexec_user = $u['uid'];
266) 
Bernd Wurst Ermögliche das Auswählen de...

Bernd Wurst authored 11 years ago

267)   $server = 'NULL';
268)   $available_servers = additional_servers();
269)   if (in_array($vhost['server'], $available_servers)) {
270)     $server = (int) $vhost['server'];
271)   }
272)   if ($server == my_server_id()) {
273)     $server = 'NULL';
274)   }
275) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

282)   $options = mysql_real_escape_string( $vhost['options'] );
283) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

284)   $cert = 0;
285)   $certs = user_certs();
286)   foreach ($certs as $c)
287)     if ($c['id'] == $vhost['cert'])
288)       $cert = $c['id'];
289)   if ($cert == 0)
290)     $cert = 'NULL';
291) 
bernd IP-Adressen aktivieren

bernd authored 14 years ago

292)   $ipv4 = 'NULL';
293)   $ipv4_avail = user_ipaddrs();
294)   if (in_array($vhost['ipv4'], $ipv4_avail))
295)   {
296)     $ipv4 = maybe_null($vhost['ipv4']);
297)   }
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

299)   $autoipv6 = 1;
300)   if ($vhost['autoipv6'] == 0 ||  $vhost['autoipv6'] == 2) {
301)     $autoipv6 = $vhost['autoipv6'];
302)   }
bernd IPv6

bernd authored 14 years ago

303) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 14 years ago

305) 
bernd Logging

bernd authored 16 years ago

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

bernd authored 14 years ago

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

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

309)   }
310)   else {
bernd Logger mit Logleveln

bernd authored 14 years ago

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

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

313)     $id = mysql_insert_id();
bernd Logging

bernd authored 16 years ago

314)   }
bernd Webapps implementiert

bernd authored 16 years ago

315)   $oldvhost = get_vhost_details($id);
316)   /*
317)     these vars may be 0 or 1.
318)     So newval > oldval means that it has been switched on yet.
319)   */
320)   if ($vhost['is_dav'] > $oldvhost['is_dav'])
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

321)       make_dav_vhost($id);
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

323)       make_svn_vhost($id);
bernd Webapps implementiert

bernd authored 16 years ago

324)   elseif ($vhost['is_webapp'] > $oldvhost['is_webapp'])
325)       make_webapp_vhost($id, $vhost['webapp_id']);
326)   elseif ($vhost['is_dav'] == 0 && $vhost['is_svn'] == 0 && $vhost['is_webapp'] == 0)
327)       make_regular_vhost($id);
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

328) }
329) 
330) 
bernd Aliases editieren

bernd authored 16 years ago

331) function get_alias_details($id)
332) {
333)   $id = (int) $id;
334)   $uid = (int) $_SESSION['userinfo']['uid'];
335)   $result = db_query("SELECT * FROM vhosts.v_alias WHERE id={$id}");
336)   
337)   if (mysql_num_rows($result) != 1)
338)     system_failure('Interner Fehler beim Auslesen der Alias-Daten');
339)   
340)   $alias = mysql_fetch_assoc($result);
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

344)   }
bernd Aliases editieren

bernd authored 16 years ago

345) 
346)   /* Das bewirkt, dass nur die eigenen Aliase gesehen werden können */
347)   get_vhost_details( (int) $alias['vhost'] );
348) 
349)   return $alias;
350) }
351) 
352) 
353) function delete_alias($id)
354) {
355)   $id = (int) $id;
356)   $alias = get_alias_details($id);
357) 
bernd Logger mit Logleveln

bernd authored 14 years ago

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

bernd authored 16 years ago

359)   db_query("DELETE FROM vhosts.alias WHERE id={$id}");
360) }
361) 
362) function save_alias($alias)
363) {
364)   if (! is_array($alias))
365)     system_failure('$alias kein array!');
bernd Neue aliase haben keine ID

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

373)   $vhost = get_vhost_details( (int) $alias['vhost']);
374)   $options = mysql_real_escape_string( $alias['options'] );
375)   if ($id == 0) {
bernd Logger mit Logleveln

bernd authored 14 years ago

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

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

bernd authored 14 years ago

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

bernd authored 16 years ago

381)     db_query("UPDATE vhosts.alias SET hostname={$hostname}, domain={$domain}, options='{$options}' WHERE id={$id} LIMIT 1");
382)   }
383) }
384) 
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

385) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

386) function available_suexec_users()
387) {
388)   $uid = (int) $_SESSION['userinfo']['uid'];
389)   $result = db_query("SELECT uid, username FROM vhosts.available_users LEFT JOIN vhosts.v_useraccounts ON (uid = suexec_user) WHERE mainuser={$uid}");
390)   $ret = array();
391)   while ($i = mysql_fetch_assoc($result))
392)     $ret[] = $i;
393)   DEBUG('available suexec-users:');
394)   DEBUG($ret);
395)   return $ret;
396) 
397) }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

398) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

399) 
400) function user_ipaddrs()
401) {
402)   $uid = (int) $_SESSION['userinfo']['uid'];
403)   $result = db_query("SELECT ipaddr FROM vhosts.ipaddr_available WHERE uid={$uid}");
404)   $ret = array();
405)   while ($i = mysql_fetch_assoc($result))
406)   {
407)     $ret[] = $i['ipaddr'];
408)   }
409)   DEBUG($ret);
410)   return $ret;
411) }
412) 
413)