Browse code

added php version tag "default"

Bernd Wurst authored on13/07/2020 14:01:49
Showing1 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 on07/08/2019 06:59:51
Showing1 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 on29/07/2019 07:26:02
Showing1 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 on28/03/2019 18:56:56
Showing1 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 on14/03/2019 11:17:25
Showing1 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 on07/11/2018 17:50:22
Showing1 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 on29/07/2018 09:00:23
Showing1 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 on23/07/2018 15:39:24
Showing1 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 on18/07/2018 20:56:31
Showing1 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 on18/07/2018 15:03:13
Showing1 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 on18/07/2018 13:32:37
Showing1 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 on26/06/2018 23:36:40
Showing1 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 on26/06/2018 13:58:19
Showing1 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
-  }
183
-  $ret .= '</select>';
184
-  return $ret;
150
+    global $domainlist, $config;
151
+    if ($domainlist == null) {
152
+        $domainlist = get_domain_list(
153
+        $_SESSION['customerinfo']['customerno'],
154
+                                  $_SESSION['userinfo']['uid']
155
+    );
156
+    }
157
+    $selected = (int) $selected;
158
+
159
+    $ret = '<select id="domain" name="domain" size="1" '.$selectattribute.' >';
160
+    $found = false;
161
+    foreach ($domainlist as $dom) {
162
+        $s = '';
163
+        if ($selected == $dom->id) {
164
+            $s = ' selected="selected" ';
165
+            $found = true;
166
+        }
167
+        $ret .= "<option value=\"{$dom->id}\"{$s}>{$dom->fqdn}</option>\n";
168
+    }
169
+    $userdomain = userdomain();
170
+    $user_needs_userdomain = $userdomain && (count($domainlist) == 0 || user_uses_userdomain());
171
+    $user_needs_userdomain = $user_needs_userdomain || ($selected == -2);
172
+    if (count($domainlist) > 0 && $user_needs_userdomain) {
173
+        $ret .= ' <option value="" disabled="disabled">--------------------------------</option>';
174
+    }
175
+    if ($userdomain && (count($domainlist) == 0 || user_uses_userdomain())) {
176
+        $s = ($selected == -1 ? ' selected="selected"' : '');
177
+        $ret .= ' <option value="-1"'.$s.'>'.$_SESSION['userinfo']['username'].'.'.$userdomain['name'].'</option>';
178
+    }
179
+    if ($selected == -2) {
180
+        $s = ($selected == -2 ? ' selected="selected"' : '');
181
+        $ret .= ' <option value="-2"'.$s.'>'.$_SESSION['userinfo']['username'].'.'.config('masterdomain').' (Bitte nicht mehr benutzen!)</option>';
182
+        if ($selected > 0 and ! $found) {
183
+            system_failure("Hier wird eine Domain benutzt, die nicht zu diesem Benutzeraccount gehört. Bearbeiten würde Daten zerstören!");
184
+        }
185
+    }
186
+    $ret .= '</select>';
187
+    return $ret;
185 188
 }
186 189
 
187 190
 
188 191
 
189 192
 function get_vhost_details($id)
190 193
 {
191
-  DEBUG("Lese #{$id}...");
192
-  $id = (int) $id;
193
-  $uid = (int) $_SESSION['userinfo']['uid'];
194
-  $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));
195
-  if ($result->rowCount() != 1)
196
-    system_failure('Interner Fehler beim Auslesen der Daten');
197
-
198
-  $ret = $result->fetch();
199
-
200
-  if ($ret['domain_id'] === NULL) {
201
-    $ret['domain_id'] = -2;
202
-  }
203
-  $ret['cert'] = $ret['certid'];
204
-  $userdomain = userdomain();
205
-  if ($ret['domain_id'] == $userdomain['id']) {
206
-    $user = $_SESSION['userinfo']['username'];
207
-    $ret['domain_id'] = -1;
208
-    if ($ret['hostname'] == $user) {
209
-      $ret['hostname'] = NULL;
210
-    } elseif (substr($ret['hostname'], -strlen($user), strlen($user)) == $user) {
211
-      $ret['hostname'] = substr($ret['hostname'], 0, -strlen($user)-1); // Punkt mit entfernen!
212
-    } else {
213
-      system_failure('Userdomain ohne Username!');
214
-    }
215
-  }
216
-  if ($ret['hsts'] === NULL) {
217
-    DEBUG('HSTS: '.$ret['hsts']);
218
-    $ret['hsts'] = -1;
219
-  }
220
-  $ret['server'] = $ret['server_id'];
221
-  DEBUG($ret);
222
-  return $ret;
194
+    DEBUG("Lese #{$id}...");
195
+    $id = (int) $id;
196
+    $uid = (int) $_SESSION['userinfo']['uid'];
197
+    $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));
198
+    if ($result->rowCount() != 1) {
199
+        system_failure('Interner Fehler beim Auslesen der Daten');
200
+    }
201
+
202
+    $ret = $result->fetch();
203
+
204
+    if ($ret['domain_id'] === null) {
205
+        $ret['domain_id'] = -2;
206
+    }
207
+    $ret['cert'] = $ret['certid'];
208
+    $userdomain = userdomain();
209
+    if ($ret['domain_id'] == $userdomain['id']) {
210
+        $user = $_SESSION['userinfo']['username'];
211
+        $ret['domain_id'] = -1;
212
+        if ($ret['hostname'] == $user) {
213
+            $ret['hostname'] = null;
214
+        } elseif (substr($ret['hostname'], -strlen($user), strlen($user)) == $user) {
215
+            $ret['hostname'] = substr($ret['hostname'], 0, -strlen($user)-1); // Punkt mit entfernen!
216
+        } else {
217
+            system_failure('Userdomain ohne Username!');
218
+        }
219
+    }
220
+    if ($ret['hsts'] === null) {
221
+        DEBUG('HSTS: '.$ret['hsts']);
222
+        $ret['hsts'] = -1;
223
+    }
224
+    $ret['server'] = $ret['server_id'];
225
+    DEBUG($ret);
226
+    return $ret;
223 227
 }
224 228
 
225 229
 
226 230
 function get_aliases($vhost)
227 231
 {
228
-  $result = db_query("SELECT id,fqdn,options FROM vhosts.v_alias WHERE vhost=?", array($vhost));
229
-  $ret = array();
230
-  while ($item = $result->fetch()) {
231
-    array_push($ret, $item);
232
-  }
233
-  return $ret;
232
+    $result = db_query("SELECT id,fqdn,options FROM vhosts.v_alias WHERE vhost=?", array($vhost));
233
+    $ret = array();
234
+    while ($item = $result->fetch()) {
235
+        array_push($ret, $item);
236
+    }
237
+    return $ret;
234 238
 }
235 239
 
236 240
 
237 241
 
238 242
 function get_all_aliases($vhost)
239 243
 {
240
-  //$vhost = get_vhost_details( (int) $vhost );
241
-  $aliases = get_aliases($vhost['id']);
242
-  $ret = array();
243
-  if (strstr($vhost['options'], 'aliaswww')) {
244
-    array_push($ret, array('id' => 'www', 'fqdn' => 'www.'.$vhost['fqdn'], 'options' => (strstr($vhost['options'], 'forwardwww') ? 'forward' : NULL)));
245
-  }
246
-  foreach ($aliases as $item) {
247
-    array_push($ret, $item);
248
-    if (strstr($item['options'], 'aliaswww')) {
249
-      array_push($ret, array('id' => 'www_'.$item['id'], 'fqdn' => 'www.'.$item['fqdn'], 'options' => (strstr($item['options'], 'forward') ? 'forward' : NULL)));
250
-    }
251
-  }
252
-  return $ret;
244
+    //$vhost = get_vhost_details( (int) $vhost );
245
+    $aliases = get_aliases($vhost['id']);
246
+    $ret = array();
247
+    if (strstr($vhost['options'], 'aliaswww')) {
248
+        array_push($ret, array('id' => 'www', 'fqdn' => 'www.'.$vhost['fqdn'], 'options' => (strstr($vhost['options'], 'forwardwww') ? 'forward' : null)));
249
+    }
250
+    foreach ($aliases as $item) {
251
+        array_push($ret, $item);
252
+        if (strstr($item['options'], 'aliaswww')) {
253
+            array_push($ret, array('id' => 'www_'.$item['id'], 'fqdn' => 'www.'.$item['fqdn'], 'options' => (strstr($item['options'], 'forward') ? 'forward' : null)));
254
+        }
255
+    }
256
+    return $ret;
253 257
 }
254 258
 
255 259
 
256 260
 function list_available_webapps()
257 261
 {
258
-  $result = db_query("SELECT id,displayname FROM vhosts.global_webapps");
259
-  $ret = array();
260
-  while ($item = $result->fetch())
261
-    array_push($ret, $item);
262
-  return $ret;
262
+    $result = db_query("SELECT id,displayname FROM vhosts.global_webapps");
263
+    $ret = array();
264
+    while ($item = $result->fetch()) {
265
+        array_push($ret, $item);
266
+    }
267
+    return $ret;
263 268
 }
264 269
 
265 270
 
266 271
 function delete_vhost($id)
267 272
 {
268
-  $id = (int) $id;
269
-  if ($id == 0)
270
-    system_failure("id == 0");
271
-  $vhost = get_vhost_details($id);
272
-  logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Removing vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
273
-  db_query("DELETE FROM vhosts.vhost WHERE id=?", array($vhost['id']));
273
+    $id = (int) $id;
274
+    if ($id == 0) {
275
+        system_failure("id == 0");
276
+    }
277
+    $vhost = get_vhost_details($id);
278
+    logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Removing vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
279
+    db_query("DELETE FROM vhosts.vhost WHERE id=?", array($vhost['id']));
274 280
 }
275 281
 
276 282
 
277 283
 
278
-function make_svn_vhost($id) 
284
+function make_svn_vhost($id)
279 285
 {
280
-  $id = (int) $id;
281
-  if ($id == 0)
282
-    system_failure("id == 0");
283
-  logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to SVN');
284
-  db_query("REPLACE INTO vhosts.dav (vhost, type) VALUES (?, 'svn')", array($id));
285
-  db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
286
+    $id = (int) $id;
287
+    if ($id == 0) {
288
+        system_failure("id == 0");
289
+    }
290
+    logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to SVN');
291
+    db_query("REPLACE INTO vhosts.dav (vhost, type) VALUES (?, 'svn')", array($id));
292
+    db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
286 293
 }
287 294
 
288
-function make_dav_vhost($id) 
295
+function make_dav_vhost($id)
289 296
 {
290
-  $id = (int) $id;
291
-  if ($id == 0)
292
-    system_failure("id == 0");
293
-  logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to WebDAV');
294
-  db_query("REPLACE INTO vhosts.dav (vhost, type, options) VALUES (?, 'dav', 'nouserfile')", array($id));
295
-  db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
297
+    $id = (int) $id;
298
+    if ($id == 0) {
299
+        system_failure("id == 0");
300
+    }
301
+    logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to WebDAV');
302
+    db_query("REPLACE INTO vhosts.dav (vhost, type, options) VALUES (?, 'dav', 'nouserfile')", array($id));
303
+    db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
296 304
 }
297 305
 
298 306
 function make_regular_vhost($id)
299 307
 {
300
-  $id = (int) $id;
301
-  if ($id == 0)
302
-    system_failure("id == 0");
303
-  logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to regular');
304
-  db_query("DELETE FROM vhosts.dav WHERE vhost=?", array($id));
305
-  db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
308
+    $id = (int) $id;
309
+    if ($id == 0) {
310
+        system_failure("id == 0");
311
+    }
312
+    logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to regular');
313
+    db_query("DELETE FROM vhosts.dav WHERE vhost=?", array($id));
314
+    db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
306 315
 }
307 316
 
308 317
 
309
-function make_webapp_vhost($id, $webapp) 
318
+function make_webapp_vhost($id, $webapp)
310 319
 {
311
-  $id = (int) $id;
312
-  $webapp = (int) $webapp;
313
-  if ($id == 0)
314
-    system_failure("id == 0");
315
-  $result = db_query("SELECT displayname FROM vhosts.global_webapps WHERE id=?", array($webapp));
316
-  if ($result->rowCount() == 0)
317
-    system_failure("webapp-id invalid");
318
-  $webapp_name = $result->fetch(PDO::FETCH_OBJ)->displayname;
319
-  logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Setting up webapp '.$webapp_name.' on vhost #'.$id);
320
-  db_query("REPLACE INTO vhosts.webapps (vhost, webapp) VALUES (?, ?)", array($id, $webapp));
321
-  mail('webapps-setup@schokokeks.org', 'setup', 'setup');
320
+    $id = (int) $id;
321
+    $webapp = (int) $webapp;
322
+    if ($id == 0) {
323
+        system_failure("id == 0");
324
+    }
325
+    $result = db_query("SELECT displayname FROM vhosts.global_webapps WHERE id=?", array($webapp));
326
+    if ($result->rowCount() == 0) {
327
+        system_failure("webapp-id invalid");
328
+    }
329
+    $webapp_name = $result->fetch(PDO::FETCH_OBJ)->displayname;
330
+    logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Setting up webapp '.$webapp_name.' on vhost #'.$id);
331
+    db_query("REPLACE INTO vhosts.webapps (vhost, webapp) VALUES (?, ?)", array($id, $webapp));
332
+    mail('webapps-setup@schokokeks.org', 'setup', 'setup');
322 333
 }
323 334
 
324 335
 
325
-function check_hostname_collision($hostname, $domain) 
336
+function check_hostname_collision($hostname, $domain)
326 337
 {
327
-  $uid = (int) $_SESSION['userinfo']['uid'];
328
-  # Neuer vhost => Prüfe Duplikat
329
-  $args = array(":hostname" => $hostname, ":domain" => $domain, ":uid" => $uid);
330
-  $domaincheck = "domain=:domain";
331
-  if ($domain == -1) {
332
-    $userdomain = userdomain();
333
-    if ($hostname) {
334
-      $hostname .= ".".$_SESSION['userinfo']['username'];
335
-    }
336
-    $args[":domain"] = $userdomain['id'];
337
-  }
338
-  if ($domain == -2) {
339
-    unset($args[":domain"]);
340
-    $domaincheck = "domain IS NULL";
341
-  }
342
-  $hostnamecheck = "hostname=:hostname";
343
-  if (! $hostname) {
344
-    $hostnamecheck = "hostname IS NULL";
345
-    unset($args[":hostname"]);
346
-  }
347
-  $result = db_query("SELECT id FROM vhosts.vhost WHERE {$hostnamecheck} AND {$domaincheck} AND user=:uid", $args);
348
-  if ($result->rowCount() > 0) {
349
-    system_failure('Eine Konfiguration mit diesem Namen gibt es bereits.');
350
-  }
351
-  if ($domain <= -1) {
352
-    return ;
353
-  }
354
-  unset($args[":uid"]);
355
-  $result = db_query("SELECT id, vhost FROM vhosts.v_alias WHERE {$hostnamecheck} AND {$domaincheck}", $args);
356
-  if ($result->rowCount() > 0) {
357
-    $data = $result->fetch();
358
-    $vh = get_vhost_details($data['vhost']);
359
-    system_failure('Dieser Hostname ist bereits als Alias für »'.$vh['fqdn'].'« eingerichtet');
360
-  }
338
+    $uid = (int) $_SESSION['userinfo']['uid'];
339
+    # Neuer vhost => Prüfe Duplikat
340
+    $args = array(":hostname" => $hostname, ":domain" => $domain, ":uid" => $uid);
341
+    $domaincheck = "domain=:domain";
342
+    if ($domain == -1) {
343
+        $userdomain = userdomain();
344
+        if ($hostname) {
345
+            $hostname .= ".".$_SESSION['userinfo']['username'];
346
+        }
347
+        $args[":domain"] = $userdomain['id'];
348
+    }
349
+    if ($domain == -2) {
350
+        unset($args[":domain"]);
351
+        $domaincheck = "domain IS NULL";
352
+    }
353
+    $hostnamecheck = "hostname=:hostname";
354
+    if (! $hostname) {
355
+        $hostnamecheck = "hostname IS NULL";
356
+        unset($args[":hostname"]);
357
+    }
358
+    $result = db_query("SELECT id FROM vhosts.vhost WHERE {$hostnamecheck} AND {$domaincheck} AND user=:uid", $args);
359
+    if ($result->rowCount() > 0) {
360
+        system_failure('Eine Konfiguration mit diesem Namen gibt es bereits.');
361
+    }
362
+    if ($domain <= -1) {
363
+        return ;
364
+    }
365
+    unset($args[":uid"]);
366
+    $result = db_query("SELECT id, vhost FROM vhosts.v_alias WHERE {$hostnamecheck} AND {$domaincheck}", $args);
367
+    if ($result->rowCount() > 0) {
368
+        $data = $result->fetch();
369
+        $vh = get_vhost_details($data['vhost']);
370
+        system_failure('Dieser Hostname ist bereits als Alias für »'.$vh['fqdn'].'« eingerichtet');
371
+    }
361 372
 }
362 373
 
363 374
 function save_vhost($vhost)
364 375
 {
365
-  if (! is_array($vhost))
366
-    system_failure('$vhost kein array!');
367
-  $id = (int) $vhost['id'];
368
-  $hostname = $vhost['hostname'];
369
-  $domain = (int) $vhost['domain_id'];
370
-  if ($domain == 0)
371
-    system_failure('$domain == 0');
372
-  if ($vhost['domain_id'] == -2)
373
-    $domain = NULL;
374
-  if ($id == 0) {
375
-    check_hostname_collision($vhost['hostname'], $vhost['domain_id']);
376
-  }
377
-  $hsts = (int) $vhost['hsts'];
378
-  if ($hsts < 0) {
379
-    $hsts = NULL;
380
-  }
381
-  $suexec_user = NULL;
382
-
383
-  $available_suexec = available_suexec_users();
384
-  foreach ($available_suexec AS $u)
385
-    if ($u['uid'] == $vhost['suexec_user'])
386
-      $suexec_user = $u['uid'];
387
-
388
-  $server = NULL;
389
-  $available_servers = additional_servers();
390
-  if (in_array($vhost['server'], $available_servers)) {
391
-    $server = (int) $vhost['server'];
392
-  }
393
-  if ($server == my_server_id()) {
394
-    $server = NULL;
395
-  }
396
-
397
-  if ($vhost['is_svn']) {
398
-    if (! $vhost['options']) {
399
-      $vhost['options']='nodocroot';
400
-    } else {
401
-      $vhost['options'].=",nodocroot";
376
+    if (! is_array($vhost)) {
377
+        system_failure('$vhost kein array!');
378
+    }
379
+    $id = (int) $vhost['id'];
380
+    $hostname = $vhost['hostname'];
381
+    $domain = (int) $vhost['domain_id'];
382
+    if ($domain == 0) {
383
+        system_failure('$domain == 0');
384
+    }
385
+    if ($vhost['domain_id'] == -2) {
386
+        $domain = null;
387
+    }
388
+    if ($id == 0) {
389
+        check_hostname_collision($vhost['hostname'], $vhost['domain_id']);
390
+    }
391
+    $hsts = (int) $vhost['hsts'];
392
+    if ($hsts < 0) {
393
+        $hsts = null;
402 394
     }
403
-  }
395
+    $suexec_user = null;
404 396
 
405
-  $cert = NULL;
406
-  $certs = user_certs();
407
-  foreach ($certs as $c)
408
-    if ($c['id'] == $vhost['cert'])
409
-      $cert = $c['id'];
397
+    $available_suexec = available_suexec_users();
398
+    foreach ($available_suexec as $u) {
399
+        if ($u['uid'] == $vhost['suexec_user']) {
400
+            $suexec_user = $u['uid'];
401
+        }
402
+    }
410 403
 
411
-  $ipv4 = NULL;
412
-  $ipv4_avail = user_ipaddrs();
413
-  if (in_array($vhost['ipv4'], $ipv4_avail))
414
-  {
415
-    $ipv4 = $vhost['ipv4'];
416
-  }
404
+    $server = null;
405
+    $available_servers = additional_servers();
406
+    if (in_array($vhost['server'], $available_servers)) {
407
+        $server = (int) $vhost['server'];
408
+    }
409
+    if ($server == my_server_id()) {
410
+        $server = null;
411
+    }
412
+
413
+    if ($vhost['is_svn']) {
414
+        if (! $vhost['options']) {
415
+            $vhost['options']='nodocroot';
416
+        } else {
417
+            $vhost['options'].=",nodocroot";
418
+        }
419
+    }
420
+
421
+    $cert = null;
422
+    $certs = user_certs();
423
+    foreach ($certs as $c) {
424
+        if ($c['id'] == $vhost['cert']) {
425
+            $cert = $c['id'];
426
+        }
427
+    }
428
+
429
+    $ipv4 = null;
430
+    $ipv4_avail = user_ipaddrs();
431
+    if (in_array($vhost['ipv4'], $ipv4_avail)) {
432
+        $ipv4 = $vhost['ipv4'];
433
+    }
417 434
 
418
-  $autoipv6 = 1;
419
-  if ($vhost['autoipv6'] == 0 ||  $vhost['autoipv6'] == 2) {
420
-    $autoipv6 = $vhost['autoipv6'];
421
-  }
435
+    $autoipv6 = 1;
436
+    if ($vhost['autoipv6'] == 0 ||  $vhost['autoipv6'] == 2) {
437
+        $autoipv6 = $vhost['autoipv6'];
438
+    }
422 439
 
423
-  if (!($vhost['ssl'] == 'forward' || $vhost['ssl'] == 'http' ||
440
+    if (!($vhost['ssl'] == 'forward' || $vhost['ssl'] == 'http' ||
424 441
         $vhost['ssl'] == 'https')) {
425
-    $vhost['ssl'] = NULL;
426
-  }
442
+        $vhost['ssl'] = null;
443
+    }
427 444
 
428
-  $args = array(":hostname" => ($hostname ? $hostname : NULL),
445
+    $args = array(":hostname" => ($hostname ? $hostname : null),
429 446
                 ":domain" => $domain,
430
-                ":docroot" => ($vhost['docroot'] ? $vhost['docroot'] : NULL),
447
+                ":docroot" => ($vhost['docroot'] ? $vhost['docroot'] : null),
431 448
                 ":php" => $vhost['php'],
432 449
                 ":cgi" => ($vhost['cgi'] == 1 ? 1 : 0),
433 450
                 ":ssl" => $vhost['ssl'],
434 451
                 ":hsts" => $hsts,
435 452
                 ":suexec_user" => $suexec_user,
436 453
                 ":server" => $server,
437
-                ":logtype" => ($vhost['logtype'] ? $vhost['logtype'] : NULL),
454
+                ":logtype" => ($vhost['logtype'] ? $vhost['logtype'] : null),
438 455
                 ":errorlog" => (int) $vhost['errorlog'],
439 456
                 ":cert" => $cert,
440 457
                 ":ipv4" => $ipv4,
441 458
                 ":autoipv6" => $autoipv6,
442 459
                 ":options" => $vhost['options'],
443
-                ":stats" => ($vhost['stats'] ? $vhost['stats'] : NULL),
460
+                ":stats" => ($vhost['stats'] ? $vhost['stats'] : null),
444 461
                 ":id" => $id);
445
-  if ($id != 0) {
446
-    logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
447
-    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);
448
-  }
449
-  else {
450
-    $args[":user"] = $_SESSION['userinfo']['uid'];
451
-    unset($args[":id"]);
452
-    logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].'');
453
-    $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 ".
462
+    if ($id != 0) {
463
+        logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
464
+        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);
465
+    } else {
466
+        $args[":user"] = $_SESSION['userinfo']['uid'];
467
+        unset($args[":id"]);
468
+        logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].'');
469
+        $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 ".
454 470
                        "(:user, :hostname, :domain, :docroot, :php, :cgi, :ssl, :hsts, :suexec_user, :server, :logtype, :errorlog, :cert, :ipv4, :autoipv6, :options, :stats)", $args);
455
-    $id = db_insert_id();
456
-  }
457
-  $oldvhost = get_vhost_details($id);
458
-  /*
459
-    these vars may be 0 or 1.
460
-    So newval > oldval means that it has been switched on yet.
461
-  */
462
-  if ($vhost['is_dav'] > $oldvhost['is_dav'])
463
-      make_dav_vhost($id);
464
-  elseif ($vhost['is_svn'] > $oldvhost['is_svn'])
465
-      make_svn_vhost($id);
466
-  elseif ($vhost['is_webapp'] > $oldvhost['is_webapp'])
467
-      make_webapp_vhost($id, $vhost['webapp_id']);
468
-  elseif ($vhost['is_dav'] == 0 && $vhost['is_svn'] == 0 && $vhost['is_webapp'] == 0)
469
-      make_regular_vhost($id);
471
+        $id = db_insert_id();
472
+    }
473
+    $oldvhost = get_vhost_details($id);
474
+    /*
475
+      these vars may be 0 or 1.
476
+      So newval > oldval means that it has been switched on yet.
477
+    */
478
+    if ($vhost['is_dav'] > $oldvhost['is_dav']) {
479
+        make_dav_vhost($id);
480
+    } elseif ($vhost['is_svn'] > $oldvhost['is_svn']) {
481
+        make_svn_vhost($id);
482
+    } elseif ($vhost['is_webapp'] > $oldvhost['is_webapp']) {
483
+        make_webapp_vhost($id, $vhost['webapp_id']);
484
+    } elseif ($vhost['is_dav'] == 0 && $vhost['is_svn'] == 0 && $vhost['is_webapp'] == 0) {
485
+        make_regular_vhost($id);
486
+    }
470 487
 }
471 488
 
472 489
 
473 490
 function get_alias_details($id)
474 491
 {
475
-  $id = (int) $id;
476
-  $uid = (int) $_SESSION['userinfo']['uid'];
477
-  $result = db_query("SELECT * FROM vhosts.v_alias WHERE id=?", array($id));
492
+    $id = (int) $id;
493
+    $uid = (int) $_SESSION['userinfo']['uid'];
494
+    $result = db_query("SELECT * FROM vhosts.v_alias WHERE id=?", array($id));
478 495
   
479
-  if ($result->rowCount() != 1)
480
-    system_failure('Interner Fehler beim Auslesen der Alias-Daten');
496
+    if ($result->rowCount() != 1) {
497
+        system_failure('Interner Fehler beim Auslesen der Alias-Daten');
498
+    }
481 499
   
482
-  $alias = $result->fetch();
500
+    $alias = $result->fetch();
483 501
   
484
-  if ($alias['domain_id'] == NULL) {
485
-    $alias['domain_id'] = -1;
486
-  }
502
+    if ($alias['domain_id'] == null) {
503
+        $alias['domain_id'] = -1;
504
+    }
487 505
 
488
-  /* Das bewirkt, dass nur die eigenen Aliase gesehen werden können */
489
-  get_vhost_details( (int) $alias['vhost'] );
506
+    /* Das bewirkt, dass nur die eigenen Aliase gesehen werden können */
507
+    get_vhost_details((int) $alias['vhost']);
490 508
 
491
-  return $alias;
509
+    return $alias;
492 510
 }
493 511
 
494 512
 
495 513
 function delete_alias($id)
496 514
 {
497
-  $id = (int) $id;
498
-  $alias = get_alias_details($id);
515
+    $id = (int) $id;
516
+    $alias = get_alias_details($id);
499 517
 
500
-  logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Removing alias #'.$id.' ('.$alias['hostname'].'.'.$alias['domain'].')');
501
-  db_query("DELETE FROM vhosts.alias WHERE id=?", array($id));
518
+    logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Removing alias #'.$id.' ('.$alias['hostname'].'.'.$alias['domain'].')');
519
+    db_query("DELETE FROM vhosts.alias WHERE id=?", array($id));
502 520
 }
503 521
 
504 522
 function save_alias($alias)
505 523
 {
506
-  if (! is_array($alias))
507
-    system_failure('$alias kein array!');
508
-  $id = (isset($alias['id']) ? (int) $alias['id'] : 0);
509
-  $domain = (int) $alias['domain_id'];
510
-  if ($domain == 0)
511
-    system_failure('$domain == 0');
512
-  if ($alias['domain_id'] == -2)
513
-    $domain = NULL;
514
-  $vhost = get_vhost_details( (int) $alias['vhost']);
515
-  if (! $alias['hostname']) {
516
-    $alias['hostname'] = NULL;
517
-  }
518
-  $args = array(":hostname" => $alias['hostname'],
524
+    if (! is_array($alias)) {
525
+        system_failure('$alias kein array!');
526
+    }
527
+    $id = (isset($alias['id']) ? (int) $alias['id'] : 0);
528
+    $domain = (int) $alias['domain_id'];
529
+    if ($domain == 0) {
530
+        system_failure('$domain == 0');
531
+    }
532
+    if ($alias['domain_id'] == -2) {
533
+        $domain = null;
534
+    }
535
+    $vhost = get_vhost_details((int) $alias['vhost']);
536
+    if (! $alias['hostname']) {
537
+        $alias['hostname'] = null;
538
+    }
539
+    $args = array(":hostname" => $alias['hostname'],
519 540
                 ":domain" => $domain,
520 541
                 ":vhost" => $vhost['id'],
521 542
                 ":options" => $alias['options'],
522 543
                 ":id" => $id);
523
-  if ($id == 0) {
524
-    unset($args[":id"]);
525
-    logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Creating alias '.$alias['hostname'].'.'.$alias['domain'].' for VHost '.$vhost['id']);
526
-    db_query("INSERT INTO vhosts.alias (hostname, domain, vhost, options) VALUES (:hostname, :domain, :vhost, :options)", $args);
527
-  }
528
-  else {
529
-    unset($args[":vhost"]);
530
-    logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Updating alias #'.$id.' ('.$alias['hostname'].'.'.$alias['domain'].')');
531
-    db_query("UPDATE vhosts.alias SET hostname=:hostname, domain=:domain, options=:options WHERE id=:id", $args);
532
-  }
544
+    if ($id == 0) {
545
+        unset($args[":id"]);
546
+        logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Creating alias '.$alias['hostname'].'.'.$alias['domain'].' for VHost '.$vhost['id']);
547
+        db_query("INSERT INTO vhosts.alias (hostname, domain, vhost, options) VALUES (:hostname, :domain, :vhost, :options)", $args);
548
+    } else {
549
+        unset($args[":vhost"]);
550
+        logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Updating alias #'.$id.' ('.$alias['hostname'].'.'.$alias['domain'].')');
551
+        db_query("UPDATE vhosts.alias SET hostname=:hostname, domain=:domain, options=:options WHERE id=:id", $args);
552
+    }
533 553
 }
534 554
 
535 555
 
536 556
 function available_suexec_users()
537 557
 {
538
-  $uid = (int) $_SESSION['userinfo']['uid'];
539
-  $result = db_query("SELECT uid, username FROM vhosts.available_users LEFT JOIN vhosts.v_useraccounts ON (uid = suexec_user) WHERE mainuser=?", array($uid));
540
-  $ret = array();
541
-  while ($i = $result->fetch())
542
-    $ret[] = $i;
543
-  DEBUG('available suexec-users:');
544
-  DEBUG($ret);
545
-  return $ret;
546
-
558
+    $uid = (int) $_SESSION['userinfo']['uid'];
559
+    $result = db_query("SELECT uid, username FROM vhosts.available_users LEFT JOIN vhosts.v_useraccounts ON (uid = suexec_user) WHERE mainuser=?", array($uid));
560
+    $ret = array();
561
+    while ($i = $result->fetch()) {
562
+        $ret[] = $i;
563
+    }
564
+    DEBUG('available suexec-users:');
565
+    DEBUG($ret);
566
+    return $ret;
547 567
 }
548 568
 
549 569
 
550 570
 function user_ipaddrs()
551 571
 {
552
-  $uid = (int) $_SESSION['userinfo']['uid'];
553
-  $result = db_query("SELECT ipaddr FROM vhosts.ipaddr_available WHERE uid=?", array($uid));
554
-  $ret = array();
555
-  while ($i = $result->fetch())
556
-  {
557
-    $ret[] = $i['ipaddr'];
558
-  }
559
-  DEBUG($ret);
560
-  return $ret;
572
+    $uid = (int) $_SESSION['userinfo']['uid'];
573
+    $result = db_query("SELECT ipaddr FROM vhosts.ipaddr_available WHERE uid=?", array($uid));
574
+    $ret = array();
575
+    while ($i = $result->fetch()) {
576
+        $ret[] = $i['ipaddr'];
577
+    }
578
+    DEBUG($ret);
579
+    return $ret;
561 580
 }
562
-
563
-
564
-?>
Browse code

Domain-Nutzung mit Deeplinks zu den Einstellungen

Bernd Wurst authored on14/02/2018 18:27:02
Showing1 changed files
... ...
@@ -50,14 +50,14 @@ function autoipv6_address($vhost_id, $mode = 1)
50 50
 }
51 51
 
52 52
 
53
-function list_vhosts($domainname=NULL)
53
+function list_vhosts($filter=NULL)
54 54
 {
55 55
   $uid = (int) $_SESSION['userinfo']['uid'];
56 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 57
   $params = array(":uid" => $uid);
58
-  if ($domainname) {
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 domain=:domain AND uid=:uid ORDER BY hostname";
60
-    $params[":domain"] = $domainname;
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 61
   }
62 62
   $result = db_query($query, $params);
63 63
   $ret = array();
Browse code

Copyright year update

Bernd Wurst authored on13/01/2018 06:07:05
Showing1 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 /*
3 3
 This file belongs to the Webinterface of schokokeks.org Hosting
4 4
 
5
-Written 2008-2014 by schokokeks.org Hosting, namely
5
+Written 2008-2018 by schokokeks.org Hosting, namely
6 6
   Bernd Wurst <bernd@schokokeks.org>
7 7
   Hanno Böck <hanno@schokokeks.org>
8 8
 
Browse code

PHP 7.2 stable und 7.0 auslaufend

Bernd Wurst authored on01/12/2017 11:32:59
Showing1 changed files
... ...
@@ -85,7 +85,7 @@ function empty_vhost()
85 85
   
86 86
   $vhost['homedir'] = $_SESSION['userinfo']['homedir'];
87 87
   $vhost['docroot'] = NULL;
88
-  $vhost['php'] = 'fpm71';
88
+  $vhost['php'] = 'fpm72';
89 89