Browse code

Codingstyle PSR12 + array syntax

Hanno Böck authored on 30/10/2021 21:18:17
Showing 1 changed files
... ...
@@ -32,10 +32,10 @@ function valid_php_versions()
32 32
             +: Beta-Version
33 33
     */
34 34
     $tags = explode(',', config('php_versions'));
35
-    $ret = array();
35
+    $ret = [];
36 36
     foreach ($tags as $t) {
37 37
         $key = $t;
38
-        $ver = array('major' => null, 'minor' => null, 'status' => 'regular', 'default' => false);
38
+        $ver = ['major' => null, 'minor' => null, 'status' => 'regular', 'default' => false];
39 39
         if (substr($t, -1, 1) == '+') {
40 40
             $ver['status'] = 'beta';
41 41
             $key = substr($t, 0, -1);
... ...
@@ -61,7 +61,7 @@ function valid_php_versions()
61 61
     foreach ($list as $vhost) {
62 62
         if ($vhost['php'] && $vhost['php'] != 'default' && !array_key_exists($vhost['php'], $ret)) {
63 63
             $key = $vhost['php'];
64
-            $ret = array($key => array('major' => null, 'minor' => null, 'status' => 'used', 'default' => false)) + $ret;
64
+            $ret = [$key => ['major' => null, 'minor' => null, 'status' => 'used', 'default' => false]] + $ret;
65 65
             /* Wir nehmen an, dass unsere Tags immer an zweitletzter Stelle die Major-Version und
66 66
             an letzter Stelle die Minor-Version enthalten */
67 67
             $ret[$key]['major'] = substr($key, -2, 1);
... ...
@@ -75,20 +75,20 @@ function valid_php_versions()
75 75
 function traffic_month($vhost_id)
76 76
 {
77 77
     $vhost_id = (int) $vhost_id;
78
-    $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));
78
+    $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]);
79 79
     $data = $result->fetch();
80 80
     return $data['mb'];
81 81
 }
82 82
 
83 83
 function autoipv6_address($vhost_id, $mode = 1)
84 84
 {
85
-    $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));
85
+    $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]);
86 86
     $data = $result->fetch();
87 87
     if (!$data['v6_prefix']) {
88 88
         warning("IPv6-Adresse nicht verfügbar, Server unterstützt kein IPv6");
89 89
         return "";
90 90
     }
91
-    list($prefix, $null) = explode('/', $data['v6_prefix']);
91
+    [$prefix, $null] = explode('/', $data['v6_prefix']);
92 92
     $vh = ':1';
93 93
     if ($mode == 2) {
94 94
         $vh = implode(':', str_split(sprintf("%08x", $vhost_id), 4));
... ...
@@ -102,13 +102,13 @@ function list_vhosts($filter=null)
102 102
 {
103 103
     $uid = (int) $_SESSION['userinfo']['uid'];
104 104
     $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 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";
105
-    $params = array(":uid" => $uid);
105
+    $params = [":uid" => $uid];
106 106
     if ($filter) {
107 107
         $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 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 (vh.fqdn LIKE :filter OR vh.id IN (SELECT vhost FROM vhosts.v_alias WHERE fqdn LIKE :filter)) AND uid=:uid ORDER BY hostname";
108 108
         $params[":filter"] = "%$filter%";
109 109
     }
110 110
     $result = db_query($query, $params);
111
-    $ret = array();
111
+    $ret = [];
112 112
     while ($item = $result->fetch()) {
113 113
         array_push($ret, $item);
114 114
     }
... ...
@@ -117,7 +117,7 @@ function list_vhosts($filter=null)
117 117
 
118 118
 function ipv6_possible($server)
119 119
 {
120
-    $args = array(":server" => $server);
120
+    $args = [":server" => $server];
121 121
     $result = db_query("SELECT v6_prefix FROM system.servers WHERE id=:server OR hostname=:server", $args);
122 122
     $line = $result->fetch();
123 123
     DEBUG("Server {$server} is v6-capable: ". ($line['v6_prefix'] != null));
... ...
@@ -175,7 +175,7 @@ function userdomain()
175 175
     if (config('user_vhosts_domain') === null) {
176 176
         return null;
177 177
     }
178
-    $result = db_query("SELECT id,name FROM vhosts.v_domains WHERE name=:dom", array(":dom" => config('user_vhosts_domain')));
178
+    $result = db_query("SELECT id,name FROM vhosts.v_domains WHERE name=:dom", [":dom" => config('user_vhosts_domain')]);
179 179
     $res = $result->fetch();
180 180
     return $res;
181 181
 }
... ...
@@ -226,7 +226,7 @@ function get_vhost_details($id)
226 226
     DEBUG("Lese #{$id}...");
227 227
     $id = (int) $id;
228 228
     $uid = (int) $_SESSION['userinfo']['uid'];
229
-    $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", array(":uid" => $uid, ":id" => $id));
229
+    $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", [":uid" => $uid, ":id" => $id]);
230 230
     if ($result->rowCount() != 1) {
231 231
         system_failure('Interner Fehler beim Auslesen der Daten');
232 232
     }
... ...
@@ -261,8 +261,8 @@ function get_vhost_details($id)
261 261
 
262 262
 function get_aliases($vhost)
263 263
 {
264
-    $result = db_query("SELECT id,fqdn,options FROM vhosts.v_alias WHERE vhost=?", array($vhost));
265
-    $ret = array();
264
+    $result = db_query("SELECT id,fqdn,options FROM vhosts.v_alias WHERE vhost=?", [$vhost]);
265
+    $ret = [];
266 266
     while ($item = $result->fetch()) {
267 267
         array_push($ret, $item);
268 268
     }
... ...
@@ -275,14 +275,14 @@ function get_all_aliases($vhost)
275 275
 {
276 276
     //$vhost = get_vhost_details( (int) $vhost );
277 277
     $aliases = get_aliases($vhost['id']);
278
-    $ret = array();
278
+    $ret = [];
279 279
     if (strstr($vhost['options'], 'aliaswww')) {
280
-        array_push($ret, array('id' => 'www', 'fqdn' => 'www.'.$vhost['fqdn'], 'options' => (strstr($vhost['options'], 'forwardwww') ? 'forward' : null)));
280
+        array_push($ret, ['id' => 'www', 'fqdn' => 'www.'.$vhost['fqdn'], 'options' => (strstr($vhost['options'], 'forwardwww') ? 'forward' : null)]);
281 281
     }
282 282
     foreach ($aliases as $item) {
283 283
         array_push($ret, $item);
284 284
         if (strstr($item['options'], 'aliaswww')) {
285
-            array_push($ret, array('id' => 'www_'.$item['id'], 'fqdn' => 'www.'.$item['fqdn'], 'options' => (strstr($item['options'], 'forward') ? 'forward' : null)));
285
+            array_push($ret, ['id' => 'www_'.$item['id'], 'fqdn' => 'www.'.$item['fqdn'], 'options' => (strstr($item['options'], 'forward') ? 'forward' : null)]);
286 286
         }
287 287
     }
288 288
     return $ret;
... ...
@@ -292,7 +292,7 @@ function get_all_aliases($vhost)
292 292
 function list_available_webapps()
293 293
 {
294 294
     $result = db_query("SELECT id,displayname FROM vhosts.global_webapps");
295
-    $ret = array();
295
+    $ret = [];
296 296
     while ($item = $result->fetch()) {
297 297
         array_push($ret, $item);
298 298
     }
... ...
@@ -308,7 +308,7 @@ function delete_vhost($id)
308 308
     }
309 309
     $vhost = get_vhost_details($id);
310 310
     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Removing vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
311
-    db_query("DELETE FROM vhosts.vhost WHERE id=?", array($vhost['id']));
311
+    db_query("DELETE FROM vhosts.vhost WHERE id=?", [$vhost['id']]);
312 312
 }
313 313
 
314 314
 
... ...
@@ -320,8 +320,8 @@ function make_svn_vhost($id)
320 320
         system_failure("id == 0");
321 321
     }
322 322
     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to SVN');
323
-    db_query("REPLACE INTO vhosts.dav (vhost, type) VALUES (?, 'svn')", array($id));
324
-    db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
323
+    db_query("REPLACE INTO vhosts.dav (vhost, type) VALUES (?, 'svn')", [$id]);
324
+    db_query("DELETE FROM vhosts.webapps WHERE vhost=?", [$id]);
325 325
 }
326 326
 
327 327
 function make_dav_vhost($id)
... ...
@@ -331,8 +331,8 @@ function make_dav_vhost($id)
331 331
         system_failure("id == 0");
332 332
     }
333 333
     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to WebDAV');
334
-    db_query("REPLACE INTO vhosts.dav (vhost, type, options) VALUES (?, 'dav', 'nouserfile')", array($id));
335
-    db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
334
+    db_query("REPLACE INTO vhosts.dav (vhost, type, options) VALUES (?, 'dav', 'nouserfile')", [$id]);
335
+    db_query("DELETE FROM vhosts.webapps WHERE vhost=?", [$id]);
336 336
 }
337 337
 
338 338
 function make_regular_vhost($id)
... ...
@@ -342,8 +342,8 @@ function make_regular_vhost($id)
342 342
         system_failure("id == 0");
343 343
     }
344 344
     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to regular');
345
-    db_query("DELETE FROM vhosts.dav WHERE vhost=?", array($id));
346
-    db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
345
+    db_query("DELETE FROM vhosts.dav WHERE vhost=?", [$id]);
346
+    db_query("DELETE FROM vhosts.webapps WHERE vhost=?", [$id]);
347 347
 }
348 348
 
349 349
 
... ...
@@ -354,13 +354,13 @@ function make_webapp_vhost($id, $webapp)
354 354
     if ($id == 0) {
355 355
         system_failure("id == 0");
356 356
     }
357
-    $result = db_query("SELECT displayname FROM vhosts.global_webapps WHERE id=?", array($webapp));
357
+    $result = db_query("SELECT displayname FROM vhosts.global_webapps WHERE id=?", [$webapp]);
358 358
     if ($result->rowCount() == 0) {
359 359
         system_failure("webapp-id invalid");
360 360
     }
361 361
     $webapp_name = $result->fetch(PDO::FETCH_OBJ)->displayname;
362 362
     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Setting up webapp '.$webapp_name.' on vhost #'.$id);
363
-    db_query("REPLACE INTO vhosts.webapps (vhost, webapp) VALUES (?, ?)", array($id, $webapp));
363
+    db_query("REPLACE INTO vhosts.webapps (vhost, webapp) VALUES (?, ?)", [$id, $webapp]);
364 364
     mail('webapps-setup@schokokeks.org', 'setup', 'setup');
365 365
 }
366 366
 
... ...
@@ -369,7 +369,7 @@ function check_hostname_collision($hostname, $domain)
369 369
 {
370 370
     $uid = (int) $_SESSION['userinfo']['uid'];
371 371
     # Neuer vhost => Prüfe Duplikat
372
-    $args = array(":hostname" => $hostname, ":domain" => $domain, ":uid" => $uid);
372
+    $args = [":hostname" => $hostname, ":domain" => $domain, ":uid" => $uid];
373 373
     $domaincheck = "domain=:domain";
374 374
     if ($domain == -1) {
375 375
         $userdomain = userdomain();
... ...
@@ -474,7 +474,7 @@ function save_vhost($vhost)
474 474
         $vhost['ssl'] = null;
475 475
     }
476 476
 
477
-    $args = array(":hostname" => ($hostname ? $hostname : null),
477
+    $args = [":hostname" => ($hostname ? $hostname : null),
478 478
                 ":domain" => $domain,
479 479
                 ":docroot" => ($vhost['docroot'] ? $vhost['docroot'] : null),
480 480
                 ":php" => $vhost['php'],
... ...
@@ -489,7 +489,7 @@ function save_vhost($vhost)
489 489
                 ":ipv4" => $ipv4,
490 490
                 ":autoipv6" => $autoipv6,
491 491
                 ":options" => $vhost['options'],
492
-                ":id" => $id);
492
+                ":id" => $id, ];
493 493
     if ($id != 0) {
494 494
         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
495 495
         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 WHERE id=:id", $args);
... ...
@@ -522,7 +522,7 @@ function get_alias_details($id)
522 522
 {
523 523
     $id = (int) $id;
524 524
     $uid = (int) $_SESSION['userinfo']['uid'];
525
-    $result = db_query("SELECT * FROM vhosts.v_alias WHERE id=?", array($id));
525
+    $result = db_query("SELECT * FROM vhosts.v_alias WHERE id=?", [$id]);
526 526
 
527 527
     if ($result->rowCount() != 1) {
528 528
         system_failure('Interner Fehler beim Auslesen der Alias-Daten');
... ...
@@ -547,7 +547,7 @@ function delete_alias($id)
547 547
     $alias = get_alias_details($id);
548 548
 
549 549
     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Removing alias #'.$id.' ('.$alias['hostname'].'.'.$alias['domain'].')');
550
-    db_query("DELETE FROM vhosts.alias WHERE id=?", array($id));
550
+    db_query("DELETE FROM vhosts.alias WHERE id=?", [$id]);
551 551
 }
552 552
 
553 553
 function save_alias($alias)
... ...
@@ -567,11 +567,11 @@ function save_alias($alias)
567 567
     if (! $alias['hostname']) {
568 568
         $alias['hostname'] = null;
569 569
     }
570
-    $args = array(":hostname" => $alias['hostname'],
570
+    $args = [":hostname" => $alias['hostname'],
571 571
                 ":domain" => $domain,
572 572
                 ":vhost" => $vhost['id'],
573 573
                 ":options" => $alias['options'],
574
-                ":id" => $id);
574
+                ":id" => $id, ];
575 575
     if ($id == 0) {
576 576
         unset($args[":id"]);
577 577
         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Creating alias '.$alias['hostname'].'.'.$alias['domain'].' for VHost '.$vhost['id']);
... ...
@@ -587,8 +587,8 @@ function save_alias($alias)
587 587
 function available_suexec_users()
588 588
 {
589 589
     $uid = (int) $_SESSION['userinfo']['uid'];
590
-    $result = db_query("SELECT uid, username FROM vhosts.available_users LEFT JOIN vhosts.v_useraccounts ON (uid = suexec_user) WHERE mainuser=?", array($uid));
591
-    $ret = array();
590
+    $result = db_query("SELECT uid, username FROM vhosts.available_users LEFT JOIN vhosts.v_useraccounts ON (uid = suexec_user) WHERE mainuser=?", [$uid]);
591
+    $ret = [];
592 592
     while ($i = $result->fetch()) {
593 593
         $ret[] = $i;
594 594
     }
... ...
@@ -601,8 +601,8 @@ function available_suexec_users()
601 601
 function user_ipaddrs()
602 602
 {
603 603
     $uid = (int) $_SESSION['userinfo']['uid'];
604
-    $result = db_query("SELECT ipaddr FROM vhosts.ipaddr_available WHERE uid=?", array($uid));
605
-    $ret = array();
604
+    $result = db_query("SELECT ipaddr FROM vhosts.ipaddr_available WHERE uid=?", [$uid]);
605
+    $ret = [];
606 606
     while ($i = $result->fetch()) {
607 607
         $ret[] = $i['ipaddr'];
608 608
     }
Browse code

added php version tag "default"

Bernd Wurst authored on 13/07/2020 14:01:49
Showing 1 changed files
... ...
@@ -54,11 +54,12 @@ function valid_php_versions()
54 54
         $ret[$key] = $ver;
55 55
     }
56 56
     /* Bis hier: aus der Datenbank ausgelesen */
57
+    krsort($ret);
57 58
     DEBUG($ret);
58 59
     /* Sonderfall: Wenn ein User noch Vhosts einer anderen Version hat, dann bleibt diese erlaubt */
59 60
     $list = list_vhosts();
60 61
     foreach ($list as $vhost) {
61
-        if ($vhost['php'] && !array_key_exists($vhost['php'], $ret)) {
62
+        if ($vhost['php'] && $vhost['php'] != 'default' && !array_key_exists($vhost['php'], $ret)) {
62 63
             $key = $vhost['php'];
63 64
             $ret = array($key => array('major' => null, 'minor' => null, 'status' => 'used', 'default' => false)) + $ret;
64 65
             /* Wir nehmen an, dass unsere Tags immer an zweitletzter Stelle die Major-Version und
... ...
@@ -134,13 +135,7 @@ function empty_vhost()
134 135
     $vhost['homedir'] = $_SESSION['userinfo']['homedir'];
135 136
     $vhost['docroot'] = null;
136 137
 
137
-    $vhost['php'] = null;
138
-    $phpversions = valid_php_versions();
139
-    foreach ($phpversions as $tag => $info) {
140
-        if ($info['default']) {
141
-            $vhost['php'] = $tag;
142
-        }
143
-    }
138
+    $vhost['php'] = 'default';
144 139
     $vhost['cgi'] = 1;
145 140
     $vhost['ssl'] = null;
146 141
     $vhost['hsts'] = -1;
Browse code

Übergebe keine Kundennummer beim Auflisten der Userdomains im vhost-Modul

Bernd Wurst authored on 07/08/2019 06:59:51
Showing 1 changed files
... ...
@@ -189,10 +189,11 @@ function domainselect($selected = null, $selectattribute = '')
189 189
 {
190 190
     global $domainlist, $config;
191 191
     if ($domainlist == null) {
192
-        $domainlist = get_domain_list(
193
-            $_SESSION['customerinfo']['customerno'],
194
-            $_SESSION['userinfo']['uid']
195
-    );
192
+        $uid = null;
193
+        if (isset($_SESSION['userinfo']['uid'])) {
194
+            $uid = $_SESSION['userinfo']['uid'];
195
+        }
196
+        $domainlist = get_domain_list(null, $uid);
196 197
     }
197 198
     $selected = (int) $selected;
198 199
 
Browse code

Statistik-Funktion entfernt

Bernd Wurst authored on 29/07/2019 07:26:02
Showing 1 changed files
... ...
@@ -100,10 +100,10 @@ function autoipv6_address($vhost_id, $mode = 1)
100 100
 function list_vhosts($filter=null)
101 101
 {
102 102
     $uid = (int) $_SESSION['userinfo']['uid'];
103
-    $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";
103
+    $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 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";
104 104
     $params = array(":uid" => $uid);
105 105
     if ($filter) {
106
-        $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 (vh.fqdn LIKE :filter OR vh.id IN (SELECT vhost FROM vhosts.v_alias WHERE fqdn LIKE :filter)) AND uid=:uid ORDER BY hostname";
106
+        $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 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 (vh.fqdn LIKE :filter OR vh.id IN (SELECT vhost FROM vhosts.v_alias WHERE fqdn LIKE :filter)) AND uid=:uid ORDER BY hostname";
107 107
         $params[":filter"] = "%$filter%";
108 108
     }
109 109
     $result = db_query($query, $params);
... ...
@@ -159,7 +159,6 @@ function empty_vhost()
159 159
     $vhost['autoipv6'] = 2; // 1 => Eine IP pro User, 2 => Eine IP pro VHost
160 160
 
161 161
     $vhost['options'] = 'forwardwww';
162
-    $vhost['stats'] = null;
163 162
     return $vhost;
164 163
 }
165 164
 
... ...
@@ -494,17 +493,16 @@ function save_vhost($vhost)
494 493
                 ":ipv4" => $ipv4,
495 494
                 ":autoipv6" => $autoipv6,
496 495
                 ":options" => $vhost['options'],
497
-                ":stats" => ($vhost['stats'] ? $vhost['stats'] : null),
498 496
                 ":id" => $id);
499 497
     if ($id != 0) {
500 498
         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
501
-        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", $args);
499
+        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 WHERE id=:id", $args);
502 500
     } else {
503 501
         $args[":user"] = $_SESSION['userinfo']['uid'];
504 502
         unset($args[":id"]);
505 503
         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].'');
506
-        $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 ".
507
-                       "(:user, :hostname, :domain, :docroot, :php, :cgi, :ssl, :hsts, :suexec_user, :server, :logtype, :errorlog, :cert, :ipv4, :autoipv6, :options, :stats)", $args, true);
504
+        $result = db_query("INSERT INTO vhosts.vhost (user, hostname, domain, docroot, php, cgi, `ssl`, hsts, `suexec_user`, `server`, logtype, errorlog, certid, ipv4, autoipv6, options) VALUES ".
505
+                       "(:user, :hostname, :domain, :docroot, :php, :cgi, :ssl, :hsts, :suexec_user, :server, :logtype, :errorlog, :cert, :ipv4, :autoipv6, :options)", $args, true);
508 506
         $id = db_insert_id();
509 507
     }
510 508
     $oldvhost = get_vhost_details($id);
Browse code

Update codingstyle according to latest PHP CS Fixer 2.14.2

Hanno authored on 28/03/2019 18:56:56
Showing 1 changed files
... ...
@@ -191,8 +191,8 @@ function domainselect($selected = null, $selectattribute = '')
191 191
     global $domainlist, $config;
192 192
     if ($domainlist == null) {
193 193
         $domainlist = get_domain_list(
194
-        $_SESSION['customerinfo']['customerno'],
195
-                                  $_SESSION['userinfo']['uid']
194
+            $_SESSION['customerinfo']['customerno'],
195
+            $_SESSION['userinfo']['uid']
196 196
     );
197 197
     }
198 198
     $selected = (int) $selected;
Browse code

usersubdomain immer verfügbar machen

Hanno authored on 14/03/2019 11:17:25
Showing 1 changed files
... ...
@@ -186,20 +186,6 @@ function userdomain()
186 186
     return $res;
187 187
 }
188 188
 
189
-function user_uses_userdomain()
190
-{
191
-    global $config;
192
-    $uid = (int) $_SESSION['userinfo']['uid'];
193
-    $userdomain = userdomain();
194
-    $result = db_query("SELECT id FROM vhosts.vhost WHERE domain=:domid AND user=:uid", array(":uid" => $uid, ":domid" => $userdomain['id']));
195
-    if ($result->rowCount() > 0) {
196
-        DEBUG("User hat ".$result->rowCount()." Domains *.schokokeks.net");
197
-        return true;
198
-    }
199
-    DEBUG("User hat keine Domains *.schokokeks.net");
200
-    return false;
201
-}
202
-
203 189
 function domainselect($selected = null, $selectattribute = '')
204 190
 {
205 191
     global $domainlist, $config;
... ...
@@ -222,12 +208,8 @@ function domainselect($selected = null, $selectattribute = '')
222 208
         $ret .= "<option value=\"{$dom->id}\"{$s}>{$dom->fqdn}</option>\n";
223 209
     }
224 210
     $userdomain = userdomain();
225
-    $user_needs_userdomain = $userdomain && (count($domainlist) == 0 || user_uses_userdomain());
226
-    $user_needs_userdomain = $user_needs_userdomain || ($selected == -2);
227
-    if (count($domainlist) > 0 && $user_needs_userdomain) {
228
-        $ret .= ' <option value="" disabled="disabled">--------------------------------</option>';
229
-    }
230
-    if ($userdomain && (count($domainlist) == 0 || user_uses_userdomain())) {
211
+    $ret .= ' <option value="" disabled="disabled">--------------------------------</option>';
212
+    if ($userdomain) {
231 213
         $s = ($selected == -1 ? ' selected="selected"' : '');
232 214
         $ret .= ' <option value="-1"'.$s.'>'.$_SESSION['userinfo']['username'].'.'.$userdomain['name'].'</option>';
233 215
     }
Browse code

Warnung bei vhost anlegen vermeiden.

Hanno authored on 07/11/2018 17:50:22
Showing 1 changed files
... ...
@@ -522,7 +522,7 @@ function save_vhost($vhost)
522 522
         unset($args[":id"]);
523 523
         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].'');
524 524
         $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 ".
525
-                       "(:user, :hostname, :domain, :docroot, :php, :cgi, :ssl, :hsts, :suexec_user, :server, :logtype, :errorlog, :cert, :ipv4, :autoipv6, :options, :stats)", $args);
525
+                       "(:user, :hostname, :domain, :docroot, :php, :cgi, :ssl, :hsts, :suexec_user, :server, :logtype, :errorlog, :cert, :ipv4, :autoipv6, :options, :stats)", $args, true);
526 526
         $id = db_insert_id();
527 527
     }
528 528
     $oldvhost = get_vhost_details($id);
Browse code

codingstyle

Hanno authored on 29/07/2018 09:00:23
Showing 1 changed files
... ...
@@ -23,7 +23,8 @@ require_once('class/domain.php');
23 23
 require_once("certs.php");
24 24
 
25 25
 
26
-function valid_php_versions() {
26
+function valid_php_versions()
27
+{
27 28
     /* In der konfiguration ist die Variable "php_versions" eine kommaseparierte Liste der unterstützten Versionen.
28 29
         Dabei gelten folgende Suffixe (nicht kombinierbar!):
29 30
             *: Standardversion für neue Konfigurationen
... ...
@@ -46,7 +47,7 @@ function valid_php_versions() {
46 47
             $key = substr($t, 0, -1);
47 48
         }
48 49
 
49
-        /* Wir nehmen an, dass unsere Tags immer an zweitletzter Stelle die Major-Version und 
50
+        /* Wir nehmen an, dass unsere Tags immer an zweitletzter Stelle die Major-Version und
50 51
         an letzter Stelle die Minor-Version enthalten */
51 52
         $ver['major'] = substr($key, -2, 1);
52 53
         $ver['minor'] = substr($key, -1, 1);
... ...
@@ -60,7 +61,7 @@ function valid_php_versions() {
60 61
         if ($vhost['php'] && !array_key_exists($vhost['php'], $ret)) {
61 62
             $key = $vhost['php'];
62 63
             $ret = array($key => array('major' => null, 'minor' => null, 'status' => 'used', 'default' => false)) + $ret;
63
-            /* Wir nehmen an, dass unsere Tags immer an zweitletzter Stelle die Major-Version und 
64
+            /* Wir nehmen an, dass unsere Tags immer an zweitletzter Stelle die Major-Version und
64 65
             an letzter Stelle die Minor-Version enthalten */
65 66
             $ret[$key]['major'] = substr($key, -2, 1);
66 67
             $ret[$key]['minor'] = substr($key, -1, 1);
Browse code

optional parameter to not warn about empty params to database queries

Hanno authored on 23/07/2018 15:39:24
Showing 1 changed files
... ...
@@ -598,11 +598,11 @@ function save_alias($alias)
598 598
     if ($id == 0) {
599 599
         unset($args[":id"]);
600 600
         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Creating alias '.$alias['hostname'].'.'.$alias['domain'].' for VHost '.$vhost['id']);
601
-        db_query("INSERT INTO vhosts.alias (hostname, domain, vhost, options) VALUES (:hostname, :domain, :vhost, :options)", $args);
601
+        db_query("INSERT INTO vhosts.alias (hostname, domain, vhost, options) VALUES (:hostname, :domain, :vhost, :options)", $args, true);
602 602
     } else {
603 603
         unset($args[":vhost"]);
604 604
         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Updating alias #'.$id.' ('.$alias['hostname'].'.'.$alias['domain'].')');
605
-        db_query("UPDATE vhosts.alias SET hostname=:hostname, domain=:domain, options=:options WHERE id=:id", $args);
605
+        db_query("UPDATE vhosts.alias SET hostname=:hostname, domain=:domain, options=:options WHERE id=:id", $args, true);
606 606
     }
607 607
 }
608 608
 
Browse code

Definiere Markierungen für veraltete, Beta und Standardversion von PHP

Bernd Wurst authored on 18/07/2018 20:56:31
Showing 1 changed files
... ...
@@ -24,18 +24,33 @@ require_once("certs.php");
24 24
 
25 25
 
26 26
 function valid_php_versions() {
27
+    /* In der konfiguration ist die Variable "php_versions" eine kommaseparierte Liste der unterstützten Versionen.
28
+        Dabei gelten folgende Suffixe (nicht kombinierbar!):
29
+            *: Standardversion für neue Konfigurationen
30
+            /: Deprecated
31
+            +: Beta-Version
32
+    */
27 33
     $tags = explode(',', config('php_versions'));
28 34
     $ret = array();
29 35
     foreach ($tags as $t) {
30
-        $key = str_replace('*', '', $t);
31
-        $ret[$key] = array('major' => null, 'minor' => null, 'status' => 'regular');
36
+        $key = $t;
37
+        $ver = array('major' => null, 'minor' => null, 'status' => 'regular', 'default' => false);
38
+        if (substr($t, -1, 1) == '+') {
39
+            $ver['status'] = 'beta';
40
+            $key = substr($t, 0, -1);
41
+        } elseif (substr($t, -1, 1) == '/') {
42
+            $ver['status'] = 'deprecated';
43
+            $key = substr($t, 0, -1);
44
+        } elseif (substr($t, -1, 1) == '*') {
45
+            $ver['default'] = true;
46
+            $key = substr($t, 0, -1);
47
+        }
48
+
32 49
         /* Wir nehmen an, dass unsere Tags immer an zweitletzter Stelle die Major-Version und 
33 50
         an letzter Stelle die Minor-Version enthalten */
34
-        $ret[$key]['major'] = substr(str_replace('*', '', $t), -2, 1);
35
-        $ret[$key]['minor'] = substr(str_replace('*', '', $t), -1, 1);
36
-        if (substr($t, -1) === '*') {
37
-            $ret[$key]['status'] = 'deprecated';
38
-        }
51
+        $ver['major'] = substr($key, -2, 1);
52
+        $ver['minor'] = substr($key, -1, 1);
53
+        $ret[$key] = $ver;
39 54
     }
40 55
     /* Bis hier: aus der Datenbank ausgelesen */
41 56
     DEBUG($ret);
... ...
@@ -44,12 +59,11 @@ function valid_php_versions() {
44 59
     foreach ($list as $vhost) {
45 60
         if ($vhost['php'] && !array_key_exists($vhost['php'], $ret)) {
46 61
             $key = $vhost['php'];
47
-            $ret = array($key => array('major' => null, 'minor' => null, 'status' => 'regular')) + $ret;
62
+            $ret = array($key => array('major' => null, 'minor' => null, 'status' => 'used', 'default' => false)) + $ret;
48 63
             /* Wir nehmen an, dass unsere Tags immer an zweitletzter Stelle die Major-Version und 
49 64
             an letzter Stelle die Minor-Version enthalten */
50 65
             $ret[$key]['major'] = substr($key, -2, 1);
51 66
             $ret[$key]['minor'] = substr($key, -1, 1);
52
-            $ret[$key]['status'] = 'used';
53 67
         }
54 68
     }
55 69
     return $ret;
... ...
@@ -118,8 +132,14 @@ function empty_vhost()
118 132
 
119 133
     $vhost['homedir'] = $_SESSION['userinfo']['homedir'];
120 134
     $vhost['docroot'] = null;
121
-    $phpversions = explode(',', config('php_versions'));
122
-    $vhost['php'] = end($phpversions);
135
+
136
+    $vhost['php'] = null;
137
+    $phpversions = valid_php_versions();
138
+    foreach ($phpversions as $tag => $info) {
139
+        if ($info['default']) {
140
+            $vhost['php'] = $tag;
141
+        }
142
+    }
123 143
     $vhost['cgi'] = 1;
124 144
     $vhost['ssl'] = null;
125 145
     $vhost['hsts'] = -1;
Browse code

Bestandsschutz für eigentlich nicht mehr angebotene PHP-Versionen

Bernd Wurst authored on 18/07/2018 15:03:13
Showing 1 changed files
... ...
@@ -37,7 +37,21 @@ function valid_php_versions() {
37 37
             $ret[$key]['status'] = 'deprecated';
38 38
         }
39 39
     }
40
+    /* Bis hier: aus der Datenbank ausgelesen */
40 41
     DEBUG($ret);
42
+    /* Sonderfall: Wenn ein User noch Vhosts einer anderen Version hat, dann bleibt diese erlaubt */
43
+    $list = list_vhosts();
44
+    foreach ($list as $vhost) {
45
+        if ($vhost['php'] && !array_key_exists($vhost['php'], $ret)) {
46
+            $key = $vhost['php'];
47
+            $ret = array($key => array('major' => null, 'minor' => null, 'status' => 'regular')) + $ret;
48
+            /* Wir nehmen an, dass unsere Tags immer an zweitletzter Stelle die Major-Version und 
49
+            an letzter Stelle die Minor-Version enthalten */
50
+            $ret[$key]['major'] = substr($key, -2, 1);
51
+            $ret[$key]['minor'] = substr($key, -1, 1);
52
+            $ret[$key]['status'] = 'used';
53
+        }
54
+    }
41 55
     return $ret;
42 56
 }
43 57
 
Browse code

read available php versions from config

Bernd Wurst authored on 18/07/2018 13:32:37
Showing 1 changed files
... ...
@@ -23,6 +23,25 @@ require_once('class/domain.php');
23 23
 require_once("certs.php");
24 24
 
25 25
 
26
+function valid_php_versions() {
27
+    $tags = explode(',', config('php_versions'));
28
+    $ret = array();
29
+    foreach ($tags as $t) {
30
+        $key = str_replace('*', '', $t);
31
+        $ret[$key] = array('major' => null, 'minor' => null, 'status' => 'regular');
32
+        /* Wir nehmen an, dass unsere Tags immer an zweitletzter Stelle die Major-Version und 
33
+        an letzter Stelle die Minor-Version enthalten */
34
+        $ret[$key]['major'] = substr(str_replace('*', '', $t), -2, 1);
35
+        $ret[$key]['minor'] = substr(str_replace('*', '', $t), -1, 1);
36
+        if (substr($t, -1) === '*') {
37
+            $ret[$key]['status'] = 'deprecated';
38
+        }
39
+    }
40
+    DEBUG($ret);
41
+    return $ret;
42
+}
43
+
44
+
26 45
 function traffic_month($vhost_id)
27 46
 {
28 47
     $vhost_id = (int) $vhost_id;
... ...
@@ -85,7 +104,8 @@ function empty_vhost()
85 104
 
86 105
     $vhost['homedir'] = $_SESSION['userinfo']['homedir'];
87 106
     $vhost['docroot'] = null;
88
-    $vhost['php'] = 'fpm72';
107
+    $phpversions = explode(',', config('php_versions'));
108
+    $vhost['php'] = end($phpversions);
89 109
     $vhost['cgi'] = 1;
90 110
     $vhost['ssl'] = null;
91 111
     $vhost['hsts'] = -1;
Browse code

remove whitespace in empty lines

Hanno authored on 26/06/2018 23:36:40
Showing 1 changed files
... ...
@@ -79,10 +79,10 @@ function empty_vhost()
79 79
 {
80 80
     $vhost['id'] = null;
81 81
     $vhost['hostname'] = null;
82
-  
82
+
83 83
     $vhost['domain_id'] = null;
84 84
     $vhost['domain'] = null;
85
-  
85
+
86 86
     $vhost['homedir'] = $_SESSION['userinfo']['homedir'];
87 87
     $vhost['docroot'] = null;
88 88
     $vhost['php'] = 'fpm72';
... ...
@@ -97,7 +97,7 @@ function empty_vhost()
97 97
     $vhost['is_svn'] = 0;
98 98
     $vhost['is_webapp'] = 0;
99 99
     $vhost['webapp_id'] = null;
100
-  
100
+
101 101
     $vhost['cert'] = null;
102 102
     $vhost['certid'] = null;
103 103
     $vhost['ipv4'] = null;
... ...
@@ -112,10 +112,10 @@ function empty_vhost()
112 112
 function empty_alias()
113 113
 {
114 114
     $alias['hostname'] = null;
115
-  
115
+
116 116
     $alias['domain_id'] = -1;
117 117
     $alias['domain'] = $_SESSION['userinfo']['username'].'.'.config('masterdomain');
118
-  
118
+
119 119
     $alias['options'] = null;
120 120
     return $alias;
121 121
 }
... ...
@@ -492,13 +492,13 @@ function get_alias_details($id)
492 492
     $id = (int) $id;
493 493
     $uid = (int) $_SESSION['userinfo']['uid'];
494 494
     $result = db_query("SELECT * FROM vhosts.v_alias WHERE id=?", array($id));
495
-  
495
+
496 496
     if ($result->rowCount() != 1) {
497 497
         system_failure('Interner Fehler beim Auslesen der Alias-Daten');
498 498
     }
499
-  
499
+
500 500
     $alias = $result->fetch();
501
-  
501
+
502 502
     if ($alias['domain_id'] == null) {
503 503
         $alias['domain_id'] = -1;
504 504
     }
Browse code

Fix coding style with php-cs-checker, see https://cs.sensiolabs.org/

Hanno authored on 26/06/2018 13:58:19
Showing 1 changed files
... ...
@@ -8,7 +8,7 @@ Written 2008-2018 by schokokeks.org Hosting, namely
8 8
 
9 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 10
 
11
-You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
11
+You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
12 12
 http://creativecommons.org/publicdomain/zero/1.0/
13 13
 
14 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.
... ...
@@ -25,540 +25,556 @@ require_once("certs.php");
25 25
 
26 26
 function traffic_month($vhost_id)
27 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 = ?", array($vhost_id));
30
-  $data = $result->fetch();
31
-  return $data['mb'];
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 = ?", array($vhost_id));
30
+    $data = $result->fetch();
31
+    return $data['mb'];
32 32
 }
33 33
 
34 34
 function autoipv6_address($vhost_id, $mode = 1)
35 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=?", array($vhost_id));
37
-  $data = $result->fetch();
38
-  if (!$data['v6_prefix'])
39
-  {
40
-    warning("IPv6-Adresse nicht verfügbar, Server unterstützt kein IPv6");
41
-    return "";
42
-  }
43
-  list($prefix, $null) = explode('/', $data['v6_prefix']);
44
-  $vh = ':1';
45
-  if ($mode == 2) {
46
-    $vh = implode(':', str_split(sprintf("%08x", $vhost_id), 4));
47
-  }
48
-  $ipv6 = $prefix . sprintf("%04s", $data['uid']) . ':' . $vh;
49
-  return $ipv6;
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));
37
+    $data = $result->fetch();
38
+    if (!$data['v6_prefix']) {
39
+        warning("IPv6-Adresse nicht verfügbar, Server unterstützt kein IPv6");
40
+        return "";
41
+    }
42
+    list($prefix, $null) = explode('/', $data['v6_prefix']);
43
+    $vh = ':1';
44
+    if ($mode == 2) {
45
+        $vh = implode(':', str_split(sprintf("%08x", $vhost_id), 4));
46
+    }
47
+    $ipv6 = $prefix . sprintf("%04s", $data['uid']) . ':' . $vh;
48
+    return $ipv6;
50 49
 }
51 50
 
52 51
 
53
-function list_vhosts($filter=NULL)
52
+function list_vhosts($filter=null)
54 53
 {
55
-  $uid = (int) $_SESSION['userinfo']['uid'];
56
-  $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";
57
-  $params = array(":uid" => $uid);
58
-  if ($filter) {
59
-    $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 (vh.fqdn LIKE :filter OR vh.id IN (SELECT vhost FROM vhosts.v_alias WHERE fqdn LIKE :filter)) AND uid=:uid ORDER BY hostname";
60
-    $params[":filter"] = "%$filter%";
61
-  }
62
-  $result = db_query($query, $params);
63
-  $ret = array();
64
-  while ($item = $result->fetch())
65
-    array_push($ret, $item);
66
-  return $ret;
54
+    $uid = (int) $_SESSION['userinfo']['uid'];
55
+    $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";
56
+    $params = array(":uid" => $uid);
57
+    if ($filter) {
58
+        $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 (vh.fqdn LIKE :filter OR vh.id IN (SELECT vhost FROM vhosts.v_alias WHERE fqdn LIKE :filter)) AND uid=:uid ORDER BY hostname";
59
+        $params[":filter"] = "%$filter%";
60
+    }
61
+    $result = db_query($query, $params);
62
+    $ret = array();
63
+    while ($item = $result->fetch()) {
64
+        array_push($ret, $item);
65
+    }
66
+    return $ret;
67 67
 }
68 68
 
69 69
 function ipv6_possible($server)
70 70
 {
71
-  $args = array(":server" => $server);
72
-  $result = db_query("SELECT v6_prefix FROM system.servers WHERE id=:server OR hostname=:server", $args);
73
-  $line = $result->fetch();
74
-  DEBUG("Server {$server} is v6-capable: ". ($line['v6_prefix'] != NULL));
75
-  return ($line['v6_prefix'] != NULL);
71
+    $args = array(":server" => $server);
72
+    $result = db_query("SELECT v6_prefix FROM system.servers WHERE id=:server OR hostname=:server", $args);
73
+    $line = $result->fetch();
74
+    DEBUG("Server {$server} is v6-capable: ". ($line['v6_prefix'] != null));
75
+    return ($line['v6_prefix'] != null);
76 76
 }
77 77
 
78 78
 function empty_vhost()
79 79
 {
80
-  $vhost['id'] = NULL;
81
-  $vhost['hostname'] = NULL;
80
+    $vhost['id'] = null;
81
+    $vhost['hostname'] = null;
82 82
   
83
-  $vhost['domain_id'] = NULL;
84
-  $vhost['domain'] = NULL;
83
+    $vhost['domain_id'] = null;
84
+    $vhost['domain'] = null;
85 85
   
86
-  $vhost['homedir'] = $_SESSION['userinfo']['homedir'];
87
-  $vhost['docroot'] = NULL;
88
-  $vhost['php'] = 'fpm72';
89
-  $vhost['cgi'] = 1;
90
-  $vhost['ssl'] = NULL;
91
-  $vhost['hsts'] = -1;
92
-  $vhost['suexec_user'] = NULL;
93
-  $vhost['server'] = NULL;
94
-  $vhost['logtype'] = NULL;
95
-  $vhost['errorlog'] = 0;
96
-  $vhost['is_dav'] = 0;
97
-  $vhost['is_svn'] = 0;
98
-  $vhost['is_webapp'] = 0;
99
-  $vhost['webapp_id'] = NULL;
86
+    $vhost['homedir'] = $_SESSION['userinfo']['homedir'];
87
+    $vhost['docroot'] = null;
88
+    $vhost['php'] = 'fpm72';
89
+    $vhost['cgi'] = 1;
90
+    $vhost['ssl'] = null;
91
+    $vhost['hsts'] = -1;
92
+    $vhost['suexec_user'] = null;
93
+    $vhost['server'] = null;
94
+    $vhost['logtype'] = null;
95
+    $vhost['errorlog'] = 0;
96
+    $vhost['is_dav'] = 0;
97
+    $vhost['is_svn'] = 0;
98
+    $vhost['is_webapp'] = 0;
99
+    $vhost['webapp_id'] = null;
100 100
   
101
-  $vhost['cert'] = NULL;
102
-  $vhost['certid'] = NULL;
103
-  $vhost['ipv4'] = NULL;
104
-  $vhost['autoipv6'] = 2; // 1 => Eine IP pro User, 2 => Eine IP pro VHost
105
-
106
-  $vhost['options'] = 'forwardwww';
107
-  $vhost['stats'] = NULL;
108
-  return $vhost;
101
+    $vhost['cert'] = null;
102
+    $vhost['certid'] = null;
103
+    $vhost['ipv4'] = null;
104
+    $vhost['autoipv6'] = 2; // 1 => Eine IP pro User, 2 => Eine IP pro VHost
105
+
106
+    $vhost['options'] = 'forwardwww';
107
+    $vhost['stats'] = null;
108
+    return $vhost;
109 109
 }
110 110
 
111 111
 
112 112
 function empty_alias()
113 113
 {
114
-  $alias['hostname'] = NULL;
114
+    $alias['hostname'] = null;
115 115
   
116
-  $alias['domain_id'] = -1;
117
-  $alias['domain'] = $_SESSION['userinfo']['username'].'.'.config('masterdomain');
116
+    $alias['domain_id'] = -1;
117
+    $alias['domain'] = $_SESSION['userinfo']['username'].'.'.config('masterdomain');
118 118
   
119
-  $alias['options'] = NULL;
120
-  return $alias;
119
+    $alias['options'] = null;
120
+    return $alias;
121 121
 }
122 122
 
123 123
 
124
-function userdomain() {
125
-  if (config('user_vhosts_domain') === NULL) {
126
-    return NULL;
127
-  }
128
-  $result = db_query("SELECT id,name FROM vhosts.v_domains WHERE name=:dom", array(":dom" => config('user_vhosts_domain')));
129
-  $res = $result->fetch();
130
-  return $res;
124
+function userdomain()
125
+{
126
+    if (config('user_vhosts_domain') === null) {
127
+        return null;
128
+    }
129
+    $result = db_query("SELECT id,name FROM vhosts.v_domains WHERE name=:dom", array(":dom" => config('user_vhosts_domain')));
130
+    $res = $result->fetch();
131
+    return $res;
131 132
 }
132 133
 
133 134
 function user_uses_userdomain()
134 135
 {
135
-  global $config;
136
-  $uid = (int) $_SESSION['userinfo']['uid'];
137
-  $userdomain = userdomain();
138
-  $result = db_query("SELECT id FROM vhosts.vhost WHERE domain=:domid AND user=:uid", array(":uid" => $uid, ":domid" => $userdomain['id']));
139
-  if ($result->rowCount() > 0) {
140
-    DEBUG("User hat ".$result->rowCount()." Domains *.schokokeks.net");
141
-    return True;
142
-  }
143
-  DEBUG("User hat keine Domains *.schokokeks.net");
144
-  return false;
136
+    global $config;
137
+    $uid = (int) $_SESSION['userinfo']['uid'];
138
+    $userdomain = userdomain();
139
+    $result = db_query("SELECT id FROM vhosts.vhost WHERE domain=:domid AND user=:uid", array(":uid" => $uid, ":domid" => $userdomain['id']));
140
+    if ($result->rowCount() > 0) {
141
+        DEBUG("User hat ".$result->rowCount()." Domains *.schokokeks.net");
142
+        return true;
143
+    }
144
+    DEBUG("User hat keine Domains *.schokokeks.net");
145
+    return false;
145 146
 }
146 147
 
147
-function domainselect($selected = NULL, $selectattribute = '')
148
+function domainselect($selected = null, $selectattribute = '')
148 149
 {
149
-  global $domainlist, $config;
150
-  if ($domainlist == NULL)
151
-    $domainlist = get_domain_list($_SESSION['customerinfo']['customerno'],
152
-                                  $_SESSION['userinfo']['uid']);
153
-  $selected = (int) $selected;
154
-
155
-  $ret = '<select id="domain" name="domain" size="1" '.$selectattribute.' >';
156
-  $found = false;
157
-  foreach ($domainlist as $dom)
158
-  {
159
-    $s = '';
160
-    if ($selected == $dom->id) {
161
-      $s = ' selected="selected" ';
162
-      $found = true;
163
-    }
164
-    $ret .= "<option value=\"{$dom->id}\"{$s}>{$dom->fqdn}</option>\n";
165
-  }
166
-  $userdomain = userdomain();
167
-  $user_needs_userdomain = $userdomain && (count($domainlist) == 0 || user_uses_userdomain());
168
-  $user_needs_userdomain = $user_needs_userdomain || ($selected == -2);
169
-  if (count($domainlist) > 0 && $user_needs_userdomain) {
170
-    $ret .= ' <option value="" disabled="disabled">--------------------------------</option>';
171
-  }
172
-  if ($userdomain && (count($domainlist) == 0 || user_uses_userdomain())) {
173
-    $s = ($selected == -1 ? ' selected="selected"' : '');
174
-    $ret .= ' <option value="-1"'.$s.'>'.$_SESSION['userinfo']['username'].'.'.$userdomain['name'].'</option>';
175
-  }
176
-  if ($selected == -2) {
177
-    $s = ($selected == -2 ? ' selected="selected"' : '');
178
-    $ret .= ' <option value="-2"'.$s.'>'.$_SESSION['userinfo']['username'].'.'.config('masterdomain').' (Bitte nicht mehr benutzen!)</option>';
179
-    if ($selected > 0 and ! $found) {
180
-      system_failure("Hier wird eine Domain benutzt, die nicht zu diesem Benutzeraccount gehört. Bearbeiten würde Daten zerstören!");
181
-    }
182
-  }