f97ab0cdcd11d669e4d9d9ee73fa99872381b4d6
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 Einige Statements auf Prepa...

Bernd Wurst authored 10 years ago

29)   $result = db_query("SELECT sum(mb_in+mb_out) as mb FROM vhosts.traffic where date > CURDATE() - INTERVAL 1 MONTH AND vhost_id = ?", array($vhost_id));
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

30)   $data = $result->fetch();
Bernd Wurst Traffic-Statistik im Webint...

Bernd Wurst authored 11 years ago

31)   return $data['mb'];
32) }
33) 
bernd Zusätzlicher Haken für eige...

bernd authored 13 years ago

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

bernd authored 13 years ago

35) {
Bernd Wurst Einige Statements auf Prepa...

Bernd Wurst authored 10 years ago

36)   $result = db_query("SELECT uid, v6_prefix FROM vhosts.v_vhost LEFT JOIN system.servers ON (servers.hostname = server) WHERE v_vhost.id=?", array($vhost_id));
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

37)   $data = $result->fetch();
bernd IPv6-Regelbetrieb vorbereit...

bernd authored 13 years ago

38)   if (!$data['v6_prefix'])
39)   {
40)     warning("IPv6-Adresse nicht verfügbar, Server unterstützt kein IPv6");
41)     return "";
42)   }
bernd Prefix-Länge herauslöschen

bernd authored 13 years ago

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

bernd authored 13 years ago

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

bernd authored 13 years ago

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

bernd authored 13 years ago

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

bernd authored 16 years ago

53) function list_vhosts()
54) {
55)   $uid = (int) $_SESSION['userinfo']['uid'];
Bernd Wurst Einige Statements auf Prepa...

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

58)   while ($item = $result->fetch())
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 Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

66)   $servername = db_escape_string($server);
bernd IPv6-fähigkeit auch richtig...

bernd authored 13 years ago

67)   $result = db_query("SELECT v6_prefix FROM system.servers WHERE id={$serverid} OR hostname='{$servername}'");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

68)   $line = $result->fetch();
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;
Hanno Böck php 5.5 default

Hanno Böck authored 10 years ago

83)   $vhost['php'] = 'php55';
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 Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

Bernd Wurst authored 11 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

91)   $vhost['is_dav'] = 0;
92)   $vhost['is_svn'] = 0;
93)   $vhost['is_webapp'] = 0;
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

94)   $vhost['webapp_id'] = NULL;
95)   
96)   $vhost['cert'] = NULL;
bernd Einige notices (undefined i...

bernd authored 14 years ago

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

bernd authored 14 years ago

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

bernd authored 13 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

103)   return $vhost;
104) }
105) 
106) 
bernd Aliases editieren

bernd authored 16 years ago

107) function empty_alias()
108) {
109)   $alias['hostname'] = '';
110)   
bernd domain = NULL ==> user-subd...

bernd authored 16 years ago

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

bernd authored 15 years ago

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

bernd authored 16 years ago

113)   
114)   $alias['options'] = '';
115)   return $alias;
116) }
117) 
118) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 15 years ago

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

bernd authored 16 years ago

122)   if ($domainlist == NULL)
123)     $domainlist = get_domain_list($_SESSION['customerinfo']['customerno'],
124)                                   $_SESSION['userinfo']['uid']);
125)   $selected = (int) $selected;
126) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 15 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

133)     $s = '';
134)     if ($selected == $dom->id) {
135)       $s = ' selected="selected" ';
136)       $found = true;
137)     }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

144)   return $ret;
145) }
146) 
147) 
148) 
149) function get_vhost_details($id)
150) {
151)   $id = (int) $id;
152)   $uid = (int) $_SESSION['userinfo']['uid'];
bernd VHosts-Modul mit neuem Layo...

bernd authored 16 years ago

153)   $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 Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 10 years ago

159)   if ($ret['hsts'] === NULL) {
160)     DEBUG('HSTS: '.$ret['hsts']);
161)     $ret['hsts'] = -1;
162)   }
Bernd Wurst bugfix: server vorausgewählt

Bernd Wurst authored 11 years ago

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

bernd authored 14 years ago

164)   DEBUG($ret);
165)   return $ret;
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

166) }
167) 
168) 
169) function get_aliases($vhost)
170) {
Bernd Wurst Einige Statements auf Prepa...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

175)   }
176)   return $ret;
177) }
178) 
179) 
180) 
181) function get_all_aliases($vhost)
182) {
bernd Weniger Datenbankzugriffe b...

bernd authored 14 years ago

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

bernd authored 16 years ago

184)   $aliases = get_aliases($vhost['id']);
185)   $ret = array();
186)   if (strstr($vhost['options'], 'aliaswww')) {
187)     array_push($ret, array('id' => 'www', 'fqdn' => 'www.'.$vhost['fqdn'], 'options' => (strstr($vhost['options'], 'forwardwww') ? 'forward' : '')));
188)   }
189)   foreach ($aliases as $item) {
190)     array_push($ret, $item);
191)     if (strstr($item['options'], 'aliaswww')) {
192)       array_push($ret, array('id' => 'www_'.$item['id'], 'fqdn' => 'www.'.$item['fqdn'], 'options' => (strstr($item['options'], 'forward') ? 'forward' : '')));
193)     }
194)   }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

195)   return $ret;
196) }
197) 
bernd Aliases editieren

bernd authored 16 years ago

198) 
bernd Webapps implementiert

bernd authored 16 years ago

199) function list_available_webapps()
200) {
201)   $result = db_query("SELECT id,displayname FROM vhosts.global_webapps");
202)   $ret = array();
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

204)     array_push($ret, $item);
205)   return $ret;
206) }
207) 
208) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

209) function delete_vhost($id)
210) {
211)   $id = (int) $id;
212)   if ($id == 0)
213)     system_failure("id == 0");
214)   $vhost = get_vhost_details($id);
bernd Logger mit Logleveln

bernd authored 14 years ago

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

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

bernd authored 16 years ago

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

bernd authored 16 years ago

220) 
221) function make_svn_vhost($id) 
222) {
223)   $id = (int) $id;
224)   if ($id == 0)
225)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

229) }
230) 
231) function make_dav_vhost($id) 
232) {
233)   $id = (int) $id;
234)   if ($id == 0)
235)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

239) }
240) 
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

242) {
243)   $id = (int) $id;
244)   if ($id == 0)
245)     system_failure("id == 0");
bernd Logger mit Logleveln

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

249) }
250) 
251) 
252) function make_webapp_vhost($id, $webapp) 
253) {
254)   $id = (int) $id;
255)   $webapp = (int) $webapp;
256)   if ($id == 0)
257)     system_failure("id == 0");
bernd Webapps implementiert

bernd authored 16 years ago

258)   $result = db_query("SELECT displayname FROM vhosts.global_webapps WHERE id={$webapp};");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

265) }
266) 
267) 
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

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

schokokeks.org GbR authored 10 years ago

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

Bernd Wurst authored 11 years ago

271)   # Neuer vhost => Prüfe Duplikat
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 11 years ago

273)   if (! $hostname) {
274)     $hostnamecheck = "hostname IS NULL";
275)   }
276)   $domaincheck = "domain=". (int) $domain ;
277)   if ($domain == -1) {
schokokeks.org GbR Kollisions-Check für VHosts...

schokokeks.org GbR authored 10 years ago

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

Bernd Wurst authored 11 years ago

279)   }
280)   $result = db_query("SELECT id FROM vhosts.vhost WHERE {$hostnamecheck} AND {$domaincheck}");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 11 years ago

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

schokokeks.org GbR authored 10 years ago

284)   if ($domain == -1) {
285)     return ;
286)   }
Bernd Wurst Kollissionsprüfung auf Alia...

Bernd Wurst authored 11 years ago

287)   $result = db_query("SELECT id, vhost FROM vhosts.alias WHERE {$hostnamecheck} AND {$domaincheck}");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

Bernd Wurst authored 11 years ago

290)     $vh = get_vhost_details($data['vhost']);
291)     system_failure('Dieser Hostname ist bereits als Alias für »'.$vh['fqdn'].'« eingerichtet');
292)   }
293) }
294) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

295) function save_vhost($vhost)
296) {
297)   if (! is_array($vhost))
298)     system_failure('$vhost kein array!');
299)   $id = (int) $vhost['id'];
300)   $hostname = maybe_null($vhost['hostname']);
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

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

Bernd Wurst authored 11 years ago

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

bernd authored 16 years ago

309)   $docroot = maybe_null($vhost['docroot']);
310)   $php = maybe_null($vhost['php']);
bernd CGI abschaltbar

bernd authored 14 years ago

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

bernd authored 16 years ago

312)   $ssl = maybe_null($vhost['ssl']);
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

313)   $hsts = (int) $vhost['hsts'];
314)   if ($hsts < 0) {
315)     $hsts = "NULL";
316)   }
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

317)   $suexec_user = 'NULL';
318) 
319)   $available_suexec = available_suexec_users();
320)   foreach ($available_suexec AS $u)
321)     if ($u['uid'] == $vhost['suexec_user'])
322)       $suexec_user = $u['uid'];
323) 
Bernd Wurst Ermögliche das Auswählen de...

Bernd Wurst authored 11 years ago

324)   $server = 'NULL';
325)   $available_servers = additional_servers();
326)   if (in_array($vhost['server'], $available_servers)) {
327)     $server = (int) $vhost['server'];
328)   }
329)   if ($server == my_server_id()) {
330)     $server = 'NULL';
331)   }
332) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

336)     if (! $vhost['options']) $vhost['options']='nodocroot';
337)     else $vhost['options']+=",nodocroot";
338)   }
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

340) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

341)   $cert = 0;
342)   $certs = user_certs();
343)   foreach ($certs as $c)
344)     if ($c['id'] == $vhost['cert'])
345)       $cert = $c['id'];
346)   if ($cert == 0)
347)     $cert = 'NULL';
348) 
bernd IP-Adressen aktivieren

bernd authored 14 years ago

349)   $ipv4 = 'NULL';
350)   $ipv4_avail = user_ipaddrs();
351)   if (in_array($vhost['ipv4'], $ipv4_avail))
352)   {
353)     $ipv4 = maybe_null($vhost['ipv4']);
354)   }
bernd IPv6

bernd authored 14 years ago

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

bernd authored 13 years ago

356)   $autoipv6 = 1;
357)   if ($vhost['autoipv6'] == 0 ||  $vhost['autoipv6'] == 2) {
358)     $autoipv6 = $vhost['autoipv6'];
359)   }
bernd IPv6

bernd authored 14 years ago

360) 
bernd Webalizer/Statistik-Funktio...

bernd authored 14 years ago

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

bernd authored 14 years ago

362) 
bernd Logging

bernd authored 16 years ago

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

bernd authored 14 years ago

364)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

365)     db_query("UPDATE vhosts.vhost SET hostname={$hostname}, domain={$domain}, docroot={$docroot}, php={$php}, cgi={$cgi}, `ssl`={$ssl}, hsts={$hsts}, `suexec_user`={$suexec_user}, `server`={$server}, logtype={$logtype}, errorlog={$errorlog}, certid={$cert}, ipv4={$ipv4}, autoipv6={$autoipv6}, options='{$options}', stats={$stats} WHERE id={$id} LIMIT 1");
bernd Logging

bernd authored 16 years ago

366)   }
367)   else {
bernd Logger mit Logleveln

bernd authored 14 years ago

368)     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].'');
Bernd Wurst JQuery als Include HSTS-Int...

Bernd Wurst authored 10 years ago

369)     $result = db_query("INSERT INTO vhosts.vhost (user, hostname, domain, docroot, php, cgi, `ssl`, hsts, `suexec_user`, `server`, logtype, errorlog, certid, ipv4, autoipv6, options, stats) VALUES ({$_SESSION['userinfo']['uid']}, {$hostname}, {$domain}, {$docroot}, {$php}, {$cgi}, {$ssl}, {$hsts}, {$suexec_user}, {$server}, {$logtype}, {$errorlog}, {$cert}, {$ipv4}, {$autoipv6}, '{$options}', {$stats})");
Bernd Wurst Warnung im dev-branch bzgl....

Bernd Wurst authored 10 years ago

370)     $id = db_insert_id();
bernd Logging

bernd authored 16 years ago

371)   }
bernd Webapps implementiert

bernd authored 16 years ago

372)   $oldvhost = get_vhost_details($id);
373)   /*
374)     these vars may be 0 or 1.
375)     So newval > oldval means that it has been switched on yet.
376)   */
377)   if ($vhost['is_dav'] > $oldvhost['is_dav'])
bernd vhost-Modul kann jetzt SVN-...

bernd authored 16 years ago

378)       make_dav_vhost($id);
bernd Webapps implementiert

bernd authored 16 years ago

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

bernd authored 16 years ago

380)       make_svn_vhost($id);
bernd Webapps implementiert

bernd authored 16 years ago

381)   elseif ($vhost['is_webapp'] > $oldvhost['is_webapp'])
382)       make_webapp_vhost($id, $vhost['webapp_id']);
383)   elseif ($vhost['is_dav'] == 0 && $vhost['is_svn'] == 0 && $vhost['is_webapp'] == 0)
384)       make_regular_vhost($id);
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

385) }
386) 
387) 
bernd Aliases editieren

bernd authored 16 years ago

388) function get_alias_details($id)
389) {
390)   $id = (int) $id;
391)   $uid = (int) $_SESSION['userinfo']['uid'];
392)   $result = db_query("SELECT * FROM vhosts.v_alias WHERE id={$id}");
393)   
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

401)   }
bernd Aliases editieren

bernd authored 16 years ago

402) 
403)   /* Das bewirkt, dass nur die eigenen Aliase gesehen werden können */
404)   get_vhost_details( (int) $alias['vhost'] );
405) 
406)   return $alias;
407) }
408) 
409) 
410) function delete_alias($id)
411) {
412)   $id = (int) $id;
413)   $alias = get_alias_details($id);
414) 
bernd Logger mit Logleveln

bernd authored 14 years ago

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

bernd authored 16 years ago

416)   db_query("DELETE FROM vhosts.alias WHERE id={$id}");
417) }
418) 
419) function save_alias($alias)
420) {
421)   if (! is_array($alias))
422)     system_failure('$alias kein array!');
bernd Neue aliase haben keine ID

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

430)   $vhost = get_vhost_details( (int) $alias['vhost']);
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

431)   $options = db_escape_string( $alias['options'] );
bernd Aliases editieren

bernd authored 16 years ago

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

bernd authored 14 years ago

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

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

bernd authored 14 years ago

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

bernd authored 16 years ago

438)     db_query("UPDATE vhosts.alias SET hostname={$hostname}, domain={$domain}, options='{$options}' WHERE id={$id} LIMIT 1");
439)   }
440) }
441) 
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

442) 
bernd SuExec-Useraccount einstellbar

bernd authored 14 years ago

443) function available_suexec_users()
444) {
445)   $uid = (int) $_SESSION['userinfo']['uid'];
446)   $result = db_query("SELECT uid, username FROM vhosts.available_users LEFT JOIN vhosts.v_useraccounts ON (uid = suexec_user) WHERE mainuser={$uid}");
447)   $ret = array();
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

449)     $ret[] = $i;
450)   DEBUG('available suexec-users:');
451)   DEBUG($ret);
452)   return $ret;
453) 
454) }
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

455) 
bernd Neue Zertifikatsverwaltung

bernd authored 14 years ago

456) 
457) function user_ipaddrs()
458) {
459)   $uid = (int) $_SESSION['userinfo']['uid'];
460)   $result = db_query("SELECT ipaddr FROM vhosts.ipaddr_available WHERE uid={$uid}");
461)   $ret = array();
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 14 years ago

463)   {
464)     $ret[] = $i['ipaddr'];
465)   }
466)   DEBUG($ret);
467)   return $ret;
468) }
469) 
470)