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

Hanno commited on 2018-06-26 13:58:19
Zeige 198 geänderte Dateien mit 2158 Einfügungen und 2716 Löschungen.

... ...
@@ -40,14 +40,12 @@ if (! isset($_SERVER['SSL_CLIENT_CERT']) && isset($_SERVER['REDIRECT_SSL_CLIENT_
40 40
     $redirect = "REDIRECT_";
41 41
 }
42 42
 
43
-if ($_SESSION['role'] != ROLE_ANONYMOUS && isset($_REQUEST['record']) && isset($_REQUEST['backto']) && check_path($_REQUEST['backto']))
44
-{
43
+if ($_SESSION['role'] != ROLE_ANONYMOUS && isset($_REQUEST['record']) && isset($_REQUEST['backto']) && check_path($_REQUEST['backto'])) {
45 44
     DEBUG('recording client-cert');
46 45
     if (isset($_SERVER[$redirect.'SSL_CLIENT_CERT']) && isset($_SERVER[$redirect.'SSL_CLIENT_S_DN']) &&
47 46
       isset($_SERVER[$redirect.'SSL_CLIENT_I_DN']) && isset($_SERVER[$redirect.'SSL_CLIENT_M_SERIAL']) &&
48 47
       isset($_SERVER[$redirect.'SSL_CLIENT_V_START']) && isset($_SERVER[$redirect.'SSL_CLIENT_V_END'])
49
-      )
50
-  {
48
+      ) {
51 49
         $_SESSION['clientcert_cert'] = $_SERVER[$redirect.'SSL_CLIENT_CERT'];
52 50
         $_SESSION['clientcert_dn'] = $_SERVER[$redirect.'SSL_CLIENT_S_DN'];
53 51
         $_SESSION['clientcert_issuer'] = $_SERVER[$redirect.'SSL_CLIENT_I_DN'];
... ...
@@ -58,17 +56,15 @@ if ($_SESSION['role'] != ROLE_ANONYMOUS && isset($_REQUEST['record']) && isset($
58 56
         $_SESSION['clientcert_valid_until'] = date_format($vend, 'Y-m-d');
59 57
         header('Location: '.$prefix.$_REQUEST['backto'].encode_querystring(''));
60 58
         die();
61
-  }
62
-  else
63
-  {
59
+    } else {
64 60
         warning('Ihr Browser hat kein Client-Zertifikat gesendet');
65 61
         header('Location: '.$prefix.$_REQUEST['backto'].encode_querystring(''));
66 62
         die();
67 63
     }
68
-}
69
-elseif (isset($_REQUEST['type']) && isset($_REQUEST['username'])) {
70
-  if (!isset($_SERVER[$redirect.'SSL_CLIENT_CERT'])) 
64
+} elseif (isset($_REQUEST['type']) && isset($_REQUEST['username'])) {
65
+    if (!isset($_SERVER[$redirect.'SSL_CLIENT_CERT'])) {
71 66
         system_failure('Ihr Browser hat kein Client-Zertifikat gesendet');
67
+    }
72 68
 
73 69
     $ret = get_logins_by_cert($_SERVER[$redirect.'SSL_CLIENT_CERT']);
74 70
     DEBUG($ret);
... ...
@@ -76,44 +72,45 @@ elseif (isset($_REQUEST['type']) && isset($_REQUEST['username'])) {
76 72
         DEBUG('/'.$account['type'].'/'.$_REQUEST['type'].'/    /'.$account['username'].'/'.$_REQUEST['username'].'/    =>');
77 73
         if (($account['type'] == urldecode($_REQUEST['type'])) && ($account['username'] == urldecode($_REQUEST['username']))) {
78 74
             $uid = $account['username'];
79
-      $role = find_role($uid, '', True);
75
+            $role = find_role($uid, '', true);
80 76
             setup_session($role, $uid);
81 77
             $destination = 'go/index/index';
82
-      if (check_path($account['startpage']))
78
+            if (check_path($account['startpage'])) {
83 79
                 $destination = $account['startpage'];
84
-      if (isset($_REQUEST['destination']) && check_path($_REQUEST['destination']))
80
+            }
81
+            if (isset($_REQUEST['destination']) && check_path($_REQUEST['destination'])) {
85 82
                 $destination = $_REQUEST['destination'];
83
+            }
86 84
             header('Location: ../'.$destination);
87 85
             die();
88 86
         }
89 87
     }
90 88
     system_failure('Der angegebene Account kann mit diesem Client-Zertifikat nicht eingeloggt werden.');
91
-}
92
-elseif ($_SESSION['role'] != ROLE_ANONYMOUS && $_REQUEST['destination'] != '') {
89
+} elseif ($_SESSION['role'] != ROLE_ANONYMOUS && $_REQUEST['destination'] != '') {
93 90
     # User hat sich grade eingeloggt
94 91
     header('Location: ../'.$destination);
95
-}
96
-else
97
-{
92
+} else {
98 93
     if (isset($_SERVER[$redirect.'SSL_CLIENT_CERT']) &&
99 94
       isset($_SERVER[$redirect.'SSL_CLIENT_S_DN']) && $_SERVER[$redirect.'SSL_CLIENT_S_DN'] != '' &&
100 95
       isset($_SERVER[$redirect.'SSL_CLIENT_I_DN']) && $_SERVER[$redirect.'SSL_CLIENT_I_DN'] != '' &&
101 96
       isset($_SERVER[$redirect.'SSL_CLIENT_M_SERIAL']) && $_SERVER[$redirect.'SSL_CLIENT_M_SERIAL'] != '') {
102 97
         $ret = get_logins_by_cert($_SERVER[$redirect.'SSL_CLIENT_CERT']);
103
-    if ($ret === NULL) {
98
+        if ($ret === null) {
104 99
             login_screen('Ihr Browser hat ein Client-Zertifikat gesendet, dieses ist aber noch nicht für den Zugang hinterlegt. Melden Sie sich bitte per Benutzername und Passwort an.');
105 100
         }
106 101
         if (count($ret) == 1) {
107 102
             $uid = $ret[0]['username'];
108
-      $role = find_role($uid, '', True);
103
+            $role = find_role($uid, '', true);
109 104
             setup_session($role, $uid);
110 105
             DEBUG("Set Cookie!");
111 106
             setcookie('CLIENTCERT_AUTOLOGIN', '1', strtotime("+ 1 year"), '/', '', true, true);
112 107
             $destination = 'go/index/index';
113
-      if (check_path($ret[0]['startpage']))
108
+            if (check_path($ret[0]['startpage'])) {
114 109
                 $destination = $ret[0]['startpage'];
115
-      if (isset($_REQUEST['destination']) && check_path($_REQUEST['destination']))
110
+            }
111
+            if (isset($_REQUEST['destination']) && check_path($_REQUEST['destination'])) {
116 112
                 $destination = $_REQUEST['destination'];
113
+            }
117 114
             header('Location: ../'.$destination);
118 115
             die();
119 116
         }
... ...
@@ -123,16 +120,15 @@ else
123 120
             $type = 'System-Account';
124 121
             if ($account['type'] == 'email') {
125 122
                 $type = 'E-Mail-Konto';
126
-      }
127
-      elseif ($account['type'] == 'subuser') {
123
+            } elseif ($account['type'] == 'subuser') {
128 124
                 $type = 'Unter-Nutzer';
129
-      }
130
-      elseif ($account['type'] == 'customer') {
125
+            } elseif ($account['type'] == 'customer') {
131 126
                 $type = 'Kundenaccount';
132 127
             }
133 128
             $destination = 'go/index/index';
134
-      if ($account['startpage'] && check_path($account['startpage']))
129
+            if ($account['startpage'] && check_path($account['startpage'])) {
135 130
                 $destination = $account['startpage'];
131
+            }
136 132
             output('<li>'.internal_link('', $type.': <strong>'.$account['username'].'</strong>', 'type='.$account['type'].'&username='.urlencode($account['username']).'&destination='.urlencode($destination)).'</li>');
137 133
         }
138 134
         output('</ul>');
... ...
@@ -144,4 +140,3 @@ else
144 140
 }
145 141
 
146 142
 show_page('certlogin');
147
-?>
... ...
@@ -19,8 +19,10 @@ require_once('inc/error.php');
19 19
 require_once('inc/debug.php');
20 20
 
21 21
 
22
-class DB extends PDO {
23
-  function __construct() {
22
+class DB extends PDO
23
+{
24
+    public function __construct()
25
+    {
24 26
         $dsn = "mysql:host=".config('db_host', true);
25 27
         if (config('db_port', true)) {
26 28
             $dsn .= ';port='.config('db_port', true);
... ...
@@ -37,7 +39,8 @@ class DB extends PDO {
37 39
     /*
38 40
       Wenn Parameter übergeben werden, werden Queries immer als Prepared statements übertragen
39 41
     */
40
-  function query($stmt, $params = NULL) {
42
+    public function query($stmt, $params = null)
43
+    {
41 44
         if (is_array($params)) {
42 45
             if (config("enable_debug")) {
43 46
                 foreach (array_values($params) as $p) {
... ...
@@ -118,7 +121,7 @@ function __ensure_connected()
118 121
 }
119 122
 
120 123
 
121
-function db_query($stmt, $params = NULL)
124
+function db_query($stmt, $params = null)
122 125
 {
123 126
     global $_db;
124 127
     __ensure_connected();
... ...
@@ -21,11 +21,10 @@ require_once('inc/debug.php');
21 21
 class Domain
22 22
 {
23 23
     protected $data = array();
24
-  function __construct($init = NULL)
24
+    public function __construct($init = null)
25 25
     {
26 26
         $this->setup();
27
-    switch (gettype($init))
28
-    {
27
+        switch (gettype($init)) {
29 28
       case 'string':
30 29
         $this->loadByName($init);
31 30
         break;
... ...
@@ -37,7 +36,7 @@ class Domain
37 36
     }
38 37
     }
39 38
 
40
-  function __set($key, $value)
39
+    public function __set($key, $value)
41 40
     {
42 41
         if (array_key_exists($key, $this->data)) {
43 42
             $this->data[$key] = $value;
... ...
@@ -49,84 +48,92 @@ class Domain
49 48
     }
50 49
 
51 50
 
52
-  function __get($key)
51
+    public function __get($key)
53 52
     {
54
-    if (array_key_exists($key, $this->data))
53
+        if (array_key_exists($key, $this->data)) {
55 54
             return $this->data[$key];
56
-    elseif (isset($this->$key))
55
+        } elseif (isset($this->$key)) {
57 56
             return $this->$key;
57
+        }
58 58
         // else werfe fehler
59 59
     }
60 60
 
61 61
 
62
-  function loadByID($id)
62
+    public function loadByID($id)
63 63
     {
64 64
         $res = db_query("SELECT * FROM kundendaten.domains WHERE id=?", array($id));
65
-      if ($res->rowCount() < 1)
65
+        if ($res->rowCount() < 1) {
66 66
             return false;
67
+        }
67 68
         $data = $res->fetch();
68 69
         $this->parse($data);
69 70
     }
70 71
 
71
-   function loadByName($name)
72
+    public function loadByName($name)
72 73
     {
73 74
         $raw = $name;
74 75
         $utf8 = idn_to_utf8($raw, 0, INTL_IDNA_VARIANT_UTS46);
75 76
         $res = db_query("SELECT * FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld)=? OR CONCAT_WS('.', domainname, tld)=?", array($raw, $utf8));
76
-      if ($res->rowCount() < 1)
77
+        if ($res->rowCount() < 1) {
77 78
             return false;
79
+        }
78 80
         $data = $res->fetch();
79 81
         $this->parse($data);
80 82
     }
81 83
 
82
-  function ensure_customerdomain()
84
+    public function ensure_customerdomain()
83 85
     {
84
-    if (! $this->is_customerdomain() )
86
+        if (! $this->is_customerdomain()) {
85 87
             system_failure('Diese Domain gehört nicht Ihrem Kundenaccount.');
86 88
         }
89
+    }
87 90
 
88
-  function ensure_userdomain()
91
+    public function ensure_userdomain()
89 92
     {
90
-    if (! $this->is_userdomain() )
93
+        if (! $this->is_userdomain()) {
91 94
             system_failure('Diese Domain gehört nicht Ihrem Benutzeraccount.');
92 95
         }
96
+    }
93 97
 
94
-  function is_customerdomain()
98
+    public function is_customerdomain()
95 99
     {
96
-    if (! isset($_SESSION['customerinfo']) )
100
+        if (! isset($_SESSION['customerinfo'])) {
97 101
             return false;
102
+        }
98 103
         $customerno = (int) $_SESSION['customerinfo']['customerno'];
99 104
         return ($this->kunde == $customerno);
100 105
     }
101 106
 
102
-  function is_userdomain()
107
+    public function is_userdomain()
103 108
     {
104
-    if (! isset($_SESSION['userinfo']) )
109
+        if (! isset($_SESSION['userinfo'])) {
105 110
             return false;
111
+        }
106 112
         $uid = (int) $_SESSION['userinfo']['uid'];
107 113
         return ($this->useraccount == $uid);
108 114
     }
109 115
 
110
-  function setup()
116
+    public function setup()
111 117
     {
112 118
         $fields = array();
113 119
         $res = db_query("DESCRIBE kundendaten.domains");
114
-    while ($f = $res->fetch(PDO::FETCH_OBJ))
115
-    {
120
+        while ($f = $res->fetch(PDO::FETCH_OBJ)) {
116 121
             $fields[$f->Field] = $f->Default;
117 122
         }
118 123
         $this->data = $fields;
119
-    $this->data['id'] = NULL;
124
+        $this->data['id'] = null;
120 125
     }
121 126
 
122 127
 
123 128
 
124
-  function parse($data)
129
+    public function parse($data)
125 130
     {
126 131
         DEBUG($data);
127
-    foreach (array_keys($this->data) as $key)
128
-      if (array_key_exists($key, $data))
132
+        foreach (array_keys($this->data) as $key) {
133
+            if (array_key_exists($key, $data)) {
129 134
                 $this->data[$key] = $data[$key];
135
+            }
136
+        }
130 137
         $this->data['fqdn'] = $data['domainname'].'.'.$data['tld'];
131 138
         $this->data['punycode'] = idn_to_ascii($this->data['fqdn'], 0, INTL_IDNA_VARIANT_UTS46);
132 139
         $this->data['is_idn'] = ($this->data['fqdn'] != $this->data['punycode']);
... ...
@@ -142,26 +148,25 @@ class Domain
142 148
 
143 149
 
144 150
 
145
-function get_domain_list($customerno, $uid = NULL)
151
+function get_domain_list($customerno, $uid = null)
146 152
 {
147 153
     $customerno = (int) $customerno;
148 154
     $query = "SELECT id FROM kundendaten.domains WHERE";
149
-  if ($uid !== NULL)
150
-  {
155
+    if ($uid !== null) {
151 156
         $uid = (int) $uid;
152 157
         $query .= " useraccount={$uid}";
153
-  }
154
-  else
155
-  {
158
+    } else {
156 159
         $query .= " kunde={$customerno}";
157 160
     }
158 161
     $query .= " ORDER BY domainname,tld";
159 162
     $result = db_query($query, array()); // FIXME Übergebe leeren array um die Warnung zu unterdrücken
160 163
     $domains = array();
161 164
     DEBUG('Result set is '.$result->rowCount()." rows.<br />\n");
162
-  if ($result->rowCount() > 0)
163
-    while ($domain = $result->fetch(PDO::FETCH_OBJ))
165
+    if ($result->rowCount() > 0) {
166
+        while ($domain = $result->fetch(PDO::FETCH_OBJ)) {
164 167
             array_push($domains, new Domain((int) $domain->id));
168
+        }
169
+    }
165 170
     DEBUG($domains);
166 171
     return $domains;
167 172
 }
... ...
@@ -178,12 +183,10 @@ function get_jabberable_domains()
178 183
     $result = array( new Domain() );
179 184
     $result[0]->id = 0;
180 185
     $result[0]->fqdn = config('masterdomain');
181
-  foreach ($domains as $dom)
182
-  {
183
-    if ($dom->jabber)
186
+    foreach ($domains as $dom) {
187
+        if ($dom->jabber) {
184 188
             $result[] = $dom;
185 189
         }
190
+    }
186 191
     return $result;
187
-
188 192
 }
189
-
... ...
@@ -41,5 +41,3 @@ $config['theme'] = 'default';
41 41
 $config['jquery_ui_path'] = '/external/jquery';
42 42
 
43 43
 ini_set('display_errors', 'On');
44
-
45
-?>
... ...
@@ -34,14 +34,12 @@ if ( substr( $go, strlen( $go ) - 4 ) == '.php' ) {
34 34
 
35 35
 DEBUG($go);
36 36
 
37
-if (strstr($go, "..") or strstr($go, "./") or strstr($go, ":") or (! file_exists("modules/$go.php")) or (! is_file("modules/$go.php")))
38
-{
37
+if (strstr($go, "..") or strstr($go, "./") or strstr($go, ":") or (! file_exists("modules/$go.php")) or (! is_file("modules/$go.php"))) {
39 38
     die("illegal command");
40 39
 }
41 40
 list($module, $page) = explode('/', $go, 2);
42 41
 $page = str_replace('/', '-', $page);
43
-if (! in_array($module, config('modules')))
44
-{
42
+if (! in_array($module, config('modules'))) {
45 43
     die("inactive module");
46 44
 }
47 45
 
... ...
@@ -72,12 +70,9 @@ $section = str_replace("/", "_", $go);
72 70
 /* Let the module work */
73 71
 include("modules/".$go.".php");
74 72
 
75
-if ($output)
76
-{
73
+if ($output) {
77 74
     if (!isset($title)) {
78 75
         $title = '';
79 76
     }
80 77
     show_page($module, $page);
81 78
 }
82
-
83
-?>
... ...
@@ -30,7 +30,7 @@ function api_request($method, $input_data)
30 30
     curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
31 31
     curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
32 32
     $result = curl_exec($curl);
33
-    if ($result === FALSE) {
33
+    if ($result === false) {
34 34
         system_failure("API-Anfrage kaputt");
35 35
     }
36 36
     DEBUG('==============================');
... ...
@@ -32,22 +32,22 @@ function config($key, $localonly = false)
32 32
         }
33 33
     }
34 34
 
35
-  if ($key == 'modules' && isset($_SESSION['restrict_modules']))
36
-  {
35
+    if ($key == 'modules' && isset($_SESSION['restrict_modules'])) {
37 36
         $modules = array();
38
-    foreach ($config['modules'] as $mod)
39
-    {
40
-      if (in_array($mod, $_SESSION['restrict_modules']))
37
+        foreach ($config['modules'] as $mod) {
38
+            if (in_array($mod, $_SESSION['restrict_modules'])) {
41 39
                 $modules[] = $mod;
42 40
             }
41
+        }
43 42
         return $modules;
44 43
     }
45 44
 
46
-  if (array_key_exists($key, $config))
45
+    if (array_key_exists($key, $config)) {
47 46
         return $config[$key];
47
+    }
48 48
   
49 49
     if ($localonly) {
50
-    return NULL;
50
+        return null;
51 51
     }
52 52
 
53 53
     /* read configuration from database */
... ...
@@ -62,14 +62,16 @@ function config($key, $localonly = false)
62 62
     $debug_config = $config;
63 63
     unset($debug_config['db_pass']);
64 64
     DEBUG($debug_config);
65
-  if (array_key_exists($key, $config))
65
+    if (array_key_exists($key, $config)) {
66 66
         return $config[$key];
67
-  else
67
+    } else {
68 68
         logger(LOG_ERR, "inc/base", "config", "Request to read nonexistant config option »{$key}«.");
69
-    return NULL;
69
+    }
70
+    return null;
70 71
 }
71 72
 
72
-function have_role($role) {
73
+function have_role($role)
74
+{
73 75
     $have = $_SESSION['role'] & $role;
74 76
     if ($have) {
75 77
         DEBUG("Current user has role ".$role);
... ...
@@ -79,7 +81,8 @@ function have_role($role) {
79 81
     return $have;
80 82
 }
81 83
 
82
-function get_server_by_id($id) {
84
+function get_server_by_id($id)
85
+{
83 86
     $id = (int) $id;
84 87
     $result = db_query("SELECT hostname FROM system.servers WHERE id=?", array($id));
85 88
     $ret = $result->fetch();
... ...
@@ -122,8 +125,9 @@ function additional_servers()
122 125
     $uid = (int) $_SESSION['userinfo']['uid'];
123 126
     $result = db_query("SELECT server FROM system.user_server WHERE uid=?", array($uid));
124 127
     $servers = array();
125
-  while ($s = $result->fetch())
128
+    while ($s = $result->fetch()) {
126 129
         $servers[] = $s['server'];
130
+    }
127 131
     DEBUG($servers);
128 132
     return $servers;
129 133
 }
... ...
@@ -133,8 +137,9 @@ function server_names()
133 137
 {
134 138
     $result = db_query("SELECT id, hostname FROM system.servers");
135 139
     $servers = array();
136
-  while ($s = $result->fetch())
140
+    while ($s = $result->fetch()) {
137 141
         $servers[$s['id']] = $s['hostname'];
142
+    }
138 143
     DEBUG($servers);
139 144
     return $servers;
140 145
 }
... ...
@@ -142,13 +147,15 @@ function server_names()
142 147
 
143 148
 function maybe_null($value)
144 149
 {
145
-  if (! $value)
146
-    return NULL;
150
+    if (! $value) {
151
+        return null;
152
+    }
147 153
 
148
-  if (strlen( (string) $value ) > 0)
154
+    if (strlen((string) $value) > 0) {
149 155
         return (string) $value;
150
-  else
151
-    return NULL;
156
+    } else {
157
+        return null;
158
+    }
152 159
 }
153 160
 
154 161
 
... ...
@@ -164,13 +171,14 @@ function logger($severity, $scriptname, $scope, $message)
164 171
     }
165 172
 
166 173
     DEBUG("LOGGING $scriptname:$scope:$message");
167
-  $user = NULL;
174
+    $user = null;
168 175
     if (array_key_exists("role", $_SESSION)) {
169
-    if ($_SESSION['role'] & ROLE_SYSTEMUSER)
176
+        if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
170 177
             $user = $_SESSION['userinfo']['username'];
171
-    elseif ($_SESSION['role'] & ROLE_CUSTOMER)
178
+        } elseif ($_SESSION['role'] & ROLE_CUSTOMER) {
172 179
             $user = $_SESSION['customerinfo']['customerno'];
173 180
         }
181
+    }
174 182
 
175 183
     $args = array(":user" => $user,
176 184
                 ":remote" => $_SERVER['REMOTE_ADDR'],
... ...
@@ -213,7 +221,7 @@ function footnote($explaination)
213 221
     }
214 222
     $fnid = array_search($explaination, $footnotes);
215 223
     DEBUG($footnotes);
216
-    if ($fnid === FALSE) {
224
+    if ($fnid === false) {
217 225
         DEBUG("Footnote »{$explaination}« is not in footnotes!");
218 226
         $footnotes[] = $explaination;
219 227
     }
... ...
@@ -251,17 +259,17 @@ function are_you_sure($query_string, $question)
251 259
 
252 260
 function user_is_sure()
253 261
 {
254
-  if (isset($_POST['really']))
255
-  {
256
-    if ($_POST['random_token'] == $_SESSION['are_you_sure_token'])
262
+    if (isset($_POST['really'])) {
263
+        if ($_POST['random_token'] == $_SESSION['are_you_sure_token']) {
257 264
             return true;
258
-    else
265
+        } else {
259 266
             system_failure("Possible Cross-site-request-forgery detected!");
260 267
         }
261
-  elseif (isset($_POST['not_really']))
268
+    } elseif (isset($_POST['not_really'])) {
262 269
         return false;
263
-  else
264
-    return NULL;
270
+    } else {
271
+        return null;
272
+    }
265 273
 }
266 274
 
267 275
 
... ...
@@ -270,8 +278,7 @@ function generate_form_token($form_id)
270 278
 {
271 279
     require_once("inc/debug.php");
272 280
     $sessid = session_id();
273
-  if ($sessid == "") 
274
-  {
281
+    if ($sessid == "") {
275 282
         DEBUG("Uh? Session not running? Wtf?");
276 283
         system_failure("Internal error!");
277 284
     }
... ...
@@ -282,22 +289,23 @@ function generate_form_token($form_id)
282 289
 }
283 290
 
284 291
 
285
-function check_form_token($form_id, $formtoken = NULL)
292
+function check_form_token($form_id, $formtoken = null)
286 293
 {
287
-  if ($formtoken == NULL)
294
+    if ($formtoken == null) {
288 295
         $formtoken = $_REQUEST['formtoken'];
296
+    }
289 297
     $sessid = session_id();
290
-  if ($sessid == "") 
291
-  {
298
+    if ($sessid == "") {
292 299
         DEBUG("Uh? Session not running? Wtf?");
293 300
         system_failure("Internal error! (Session not running)");
294 301
     }
295 302
 
296 303
     $correct_formtoken = hash('sha256', $sessid.$form_id.$_SESSION['session_token']);
297 304
 
298
-  if (! ($formtoken == $correct_formtoken))
305
+    if (! ($formtoken == $correct_formtoken)) {
299 306
         system_failure("Possible cross-site-request-forgery!");
300 307
     }
308
+}
301 309
 
302 310
 
303 311
 function have_module($modname)
... ...
@@ -332,22 +339,25 @@ function use_module($modname)
332 339
 function encode_querystring($querystring)
333 340
 {
334 341
     global $debugmode;
335
-  if ($debugmode)
342
+    if ($debugmode) {
336 343
         $querystring = 'debug&'.$querystring;
344
+    }
337 345
     $query = explode('&', $querystring);
338 346
     $new_query = array();
339
-  foreach ($query AS $item)
340
-    if ($item != '')
341
-    {
347
+    foreach ($query as $item) {
348
+        if ($item != '') {
342 349
             $split = explode('=', $item, 2);
343
-      if (count($split) == 1)
350
+            if (count($split) == 1) {
344 351
                 $new_query[] = $split[0];
345
-      else
352
+            } else {
346 353
                 $new_query[] = $split[0].'='.urlencode($split[1]);
347 354
             }
355
+        }
356
+    }
348 357
     $querystring = implode('&amp;', $new_query);
349
-  if ($querystring)
358
+    if ($querystring) {
350 359
         $querystring = '?'.$querystring;
360
+    }
351 361
     return $querystring;
352 362
 }
353 363
 
... ...
@@ -367,8 +377,7 @@ function addnew($file, $label, $querystring = '', $attribs = '')
367 377
 function internal_link($file, $label, $querystring = '', $attribs = '')
368 378
 {
369 379
     global $prefix;
370
-  if (strpos($file, '/') === 0)
371
-  {
380
+    if (strpos($file, '/') === 0) {
372 381
         $file = $prefix.substr($file, 1);
373 382
     }
374 383
     $querystring = encode_querystring($querystring);
... ...
@@ -392,11 +401,11 @@ function html_select($name, $options, $default='', $free='')
392 401
 {
393 402
     require_once('inc/security.php');
394 403
     $ret = "<select name=\"{$name}\" id=\"{$name}\" size=\"1\" {$free} >\n";
395
-  foreach ($options as $key => $value)
396
-  {
404
+    foreach ($options as $key => $value) {
397 405
         $selected = '';
398
-    if ($default == $key)
406
+        if ($default == $key) {
399 407
             $selected = ' selected="selected" ';
408
+        }
400 409
         $key = filter_input_general($key);
401 410
         $value = filter_input_general($value);
402 411
         $ret .= "  <option value=\"{$key}\"{$selected}>{$value}</option>\n";
... ...
@@ -439,15 +448,11 @@ function get_modules_info()
439 448
 {
440 449
     $modules = config('modules');
441 450
     $modconfig = array();
442
-  foreach ($modules AS $name) {
443
-    $modconfig[$name] = NULL;
451
+    foreach ($modules as $name) {
452
+        $modconfig[$name] = null;
444 453
         if (file_exists('modules/'.$name.'/module.info')) {
445 454
             $modconfig[$name] = parse_ini_file('modules/'.$name.'/module.info');
446 455
         }
447 456
     }
448 457
     return $modconfig;
449 458
 }
450
-
451
-
452
-
453
-?>
... ...
@@ -21,9 +21,11 @@ $debugmode = (isset($_GET['debug']) && config('enable_debug'));
21 21
 function DEBUG($str)
22 22
 {
23 23
     global $debugmode;
24
-  if ($debugmode)
24
+    if ($debugmode) {
25 25
         if (is_array($str)) {
26
-      array_walk_recursive($str, function(&$v) { $v = htmlspecialchars($v); });
26
+            array_walk_recursive($str, function (&$v) {
27
+                $v = htmlspecialchars($v);
28
+            });
27 29
             echo "<pre>".print_r($str, true)."</pre>\n";
28 30
         } elseif (is_object($str)) {
29 31
             echo "<pre>".print_r($str, true)."</pre>\n";
... ...
@@ -31,8 +33,7 @@ function DEBUG($str)
31 33
             echo htmlspecialchars($str) . "<br />\n";
32 34
         }
33 35
     }
36
+}
34 37
 
35 38
 
36 39
 DEBUG("GET: ".htmlentities(print_r($_GET, true))." / POST: ".htmlentities(print_r($_POST, true)));
37
-
38
-?>
... ...
@@ -27,15 +27,17 @@ function system_failure($reason)
27 27
 function input_error($reason)
28 28
 {
29 29
     global $input_error;
30
-  if (!isset($input_error))
30
+    if (!isset($input_error)) {
31 31
         $input_error = array();
32
+    }
32 33
     array_push($input_error, $reason);
33 34
 }
34 35
 
35 36
 function warning($msg)
36 37
 {
37
-  if (!isset($_SESSION['warning']))
38
+    if (!isset($_SESSION['warning'])) {
38 39
         $_SESSION['warning'] = array();
40
+    }
39 41
     array_push($_SESSION['warning'], $msg);
40 42
     $backtrace = debug_backtrace();
41 43
     DEBUG('WARNING:<br>'.$backtrace[0]['file'].':'.$backtrace[0]['line'].': '.$msg);
... ...
@@ -43,8 +45,9 @@ function warning($msg)
43 45
 
44 46
 function success_msg($msg)
45 47
 {
46
-  if (!isset($_SESSION['success_msg']))
48
+    if (!isset($_SESSION['success_msg'])) {
47 49
         $_SESSION['success_msg'] = array();
50
+    }
48 51
     array_push($_SESSION['success_msg'], $msg);
49 52
 }
50 53
 
... ...
@@ -53,51 +56,46 @@ function we_have_an_error()
53 56
 {
54 57
     global $input_error;
55 58
 
56
-  if (isset($input_error))
59
+    if (isset($input_error)) {
57 60
         return (count($input_error) > 0);
58
-  else
61
+    } else {
59 62
         return 0;
60 63
     }
64
+}
61 65
 
62 66
 
63 67
 function get_messages()
64 68
 {
65 69
     $messages = '';
66 70
     global $input_error;
67
-  if (isset($input_error))
68
-  {
71
+    if (isset($input_error)) {
69 72
         $messages .= '<div class="error">
70 73
     <h3>Fehler</h3>
71 74
     <p>Folgende Fehler wurden festgestellt: </p>
72 75
     <ul>
73 76
     ';
74
-    foreach ($input_error as $error)
75
-    {
77
+        foreach ($input_error as $error) {
76 78
             $messages .= '<li>'.nl2br(filter_input_general($error))."</li>\n";
77 79
         }
78 80
         $messages .= '</ul>
79 81
     </div>';
80 82
     }
81
-  if (isset($_SESSION['warning']))
82
-  {
83
+    if (isset($_SESSION['warning'])) {
83 84
         $messages .= '<div class="error">
84 85
     <ul>
85 86
     ';
86
-    foreach ($_SESSION['warning'] as $msg)
87
-    {
87
+        foreach ($_SESSION['warning'] as $msg) {
88 88
             $messages .= '<li>'.nl2br(filter_input_general($msg))."</li>\n";
89 89
         }
90 90
         $messages .= '</ul>
91 91
     </div>';
92 92
         unset($_SESSION['warning']);
93 93
     }
94
-  if (isset($_SESSION['success_msg']))
95
-  {
94
+    if (isset($_SESSION['success_msg'])) {
96 95
         $messages .= '<div class="success">
97 96
     <ul>
98 97
     ';
99
-    foreach ($_SESSION['success_msg'] as $msg)
100
-    {
98
+        foreach ($_SESSION['success_msg'] as $msg) {
101 99
             $messages .= '<li>'.nl2br(filter_input_general($msg))."</li>\n";
102 100
         }
103 101
         $messages .= '</ul>
... ...
@@ -135,7 +133,7 @@ function require_role($roles)
135 133
 }
136 134
 
137 135
 
138
-function login_screen($why = NULL)
136
+function login_screen($why = null)
139 137
 {
140 138
     if (! $why) {
141 139
         if (isset($_COOKIE['CLIENTCERT_AUTOLOGIN']) && $_COOKIE['CLIENTCERT_AUTOLOGIN'] == '1') {
... ...
@@ -149,6 +147,3 @@ function login_screen($why = NULL)
149 147
     show_page('login');
150 148
     die();
151 149
 }
152
-
153
-
154
-?>
... ...
@@ -26,7 +26,8 @@ if (! defined('__JQUERY_INCLUDED')) {
26 26
 ');
27 27
 }
28 28
 
29
-function javascript($file = NULL, $module = NULL) {
29
+function javascript($file = null, $module = null)
30
+{
30 31
     global $go, $prefix;
31 32
     list($mod, $page) = explode('/', $go, 2);
32 33
     if (! $file) {
... ...
@@ -33,8 +33,8 @@ function strong_password($password, $user = array())
33 33
 
34 34
 function filter_input_general($input)
35 35
 {
36
-  if ($input === NULL) {
37
-    return NULL;
36
+    if ($input === null) {
37
+        return null;
38 38
     }
39 39
     return htmlspecialchars(iconv('UTF-8', 'UTF-8', $input), ENT_QUOTES, 'UTF-8');
40 40
 }
... ...
@@ -81,14 +81,18 @@ function filter_input_hostname( $input, $wildcard=false )
81 81
     if (preg_replace("/[^.]_/", "", $input) != $input) {
82 82
         system_failure("Der Unterstrich ist nur als erstes Zeichen eines Hostnames erlaubt.");
83 83
     }
84
-  if (preg_replace("/[^[:alnum:]äöü_*\.\-]/", "", $input ) != $input)
84
+    if (preg_replace("/[^[:alnum:]äöü_*\.\-]/", "", $input) != $input) {
85 85
         system_failure("Ihre Daten enthielten ungültige Zeichen!");
86
-  if (preg_match("/^.+\*/", $input ))
86
+    }
87
+    if (preg_match("/^.+\*/", $input)) {
87 88
         system_failure("Ihre Daten enthielten ungültige Zeichen (Wildcard-Stern muss ganz vorne stehen)!");
88
-  if (! $wildcard && preg_replace("/^\*/", "", $input ) != $input)
89
+    }
90
+    if (! $wildcard && preg_replace("/^\*/", "", $input) != $input) {
89 91
         system_failure("Ihre Daten enthielten ungültige Zeichen (Keine Wildcards erlaubt)!");
90
-  if (strstr($input, '..'))
92
+    }
93
+    if (strstr($input, '..')) {
91 94
         system_failure("Ungültiger Hostname");
95
+    }
92 96
     return $input;
93 97
 }
94 98
 
... ...
@@ -103,23 +107,26 @@ function verify_input_hostname( $input, $wildcard=false )
103 107
 
104 108
 function verify_input_ipv4($input)
105 109
 {
106
-  if (! preg_match("/^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/", $input))
110
+    if (! preg_match("/^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/", $input)) {
107 111
         system_failure('Keine IP-Adresse');
108 112
     }
113
+}
109 114
 
110 115
 
111 116
 function verify_input_ipv6($input)
112 117
 {
113 118
     // ripped from Perl module Net-IPv6Addr v0.2
114
-  if (! preg_match("/^(([0-9a-f]{1,4}:){7}[0-9a-f]{1,4}|[0-9a-f]{0,4}::|:(?::[a-f0-9]{1,4}){1,6}|(?:[a-f0-9]{1,4}:){1,6}:|(?:[a-f0-9]{1,4}:)(?::[a-f0-9]{1,4}){1,6}|(?:[a-f0-9]{1,4}:){2}(?::[a-f0-9]{1,4}){1,5}|(?:[a-f0-9]{1,4}:){3}(?::[a-f0-9]{1,4}){1,4}|(?:[a-f0-9]{1,4}:){4}(?::[a-f0-9]{1,4}){1,3}|(?:[a-f0-9]{1,4}:){5}(?::[a-f0-9]{1,4}){1,2}|(?:[a-f0-9]{1,4}:){6}(?::[a-f0-9]{1,4}))$/i", $input))
119
+    if (! preg_match("/^(([0-9a-f]{1,4}:){7}[0-9a-f]{1,4}|[0-9a-f]{0,4}::|:(?::[a-f0-9]{1,4}){1,6}|(?:[a-f0-9]{1,4}:){1,6}:|(?:[a-f0-9]{1,4}:)(?::[a-f0-9]{1,4}){1,6}|(?:[a-f0-9]{1,4}:){2}(?::[a-f0-9]{1,4}){1,5}|(?:[a-f0-9]{1,4}:){3}(?::[a-f0-9]{1,4}){1,4}|(?:[a-f0-9]{1,4}:){4}(?::[a-f0-9]{1,4}){1,3}|(?:[a-f0-9]{1,4}:){5}(?::[a-f0-9]{1,4}){1,2}|(?:[a-f0-9]{1,4}:){6}(?::[a-f0-9]{1,4}))$/i", $input)) {
115 120
         system_failure("Ungültige IPv6-Adresse");
116 121
     }
122
+}
117 123
 
118 124
 function verify_input_recorddata($input)
119 125
 {
120
-  if (strstr($input, "\\") || strstr($input, '"'))
126
+    if (strstr($input, "\\") || strstr($input, '"')) {
121 127
         system_failure("Ungültige Zeichen");
122 128
     }
129
+}
123 130
 
124 131
 function filter_quotes($input)
125 132
 {
... ...
@@ -135,9 +142,10 @@ function filter_shell( $input )
135 142
 
136 143
 function verify_shell($input)
137 144
 {
138
-  if (filter_shell($input) != $input)
145
+    if (filter_shell($input) != $input) {
139 146
         system_failure("Ihre Daten enthielten ungültige Zeichen!");
140 147
     }
148
+}
141 149
 
142 150
 
143 151
 function filter_ssh_key($key)
... ...
@@ -171,20 +179,17 @@ function filter_ssh_key($key)
171 179
 function check_path($input)
172 180
 {
173 181
     DEBUG("checking {$input} for valid path name");
174
-  if ($input != filter_input_general($input))
175
-  {
182
+    if ($input != filter_input_general($input)) {
176 183
         logger(LOG_WARNING, 'inc/security', 'check_path', 'HTML-Krams im Pfad: '.$input);
177 184
         DEBUG("HTML-Krams im Pfad");
178
-    return False;
185
+        return false;
179 186
     }
180 187
     $components = explode("/", $input);
181
-  foreach ($components AS $item)
182
-  {
183
-    if ($item == '..')
184
-    {
188
+    foreach ($components as $item) {
189
+        if ($item == '..') {
185 190
             logger(LOG_WARNING, 'inc/security', 'check_path', '»..« im Pfad: '.$input);
186 191
             DEBUG("»..« im Pfad");
187
-      return False;
192
+            return false;
188 193
         }
189 194
     }
190 195
     return (preg_match('/^[ A-Za-z0-9.@\/_-]*$/', $input) == 1);
... ...
@@ -194,15 +199,13 @@ function check_path( $input )
194 199
 function in_homedir($path)
195 200
 {
196 201
     DEBUG("Prüfe »{$path}«");
197
-  if (! check_path($path))
198
-  {
202
+    if (! check_path($path)) {
199 203
         DEBUG('Kein Pfad');
200
-    return False;
204
+        return false;
201 205
     }
202
-  if (! isset($_SESSION['userinfo']['homedir']))
203
-  {
206
+    if (! isset($_SESSION['userinfo']['homedir'])) {
204 207
         DEBUG("Kann homedir nicht ermitteln");
205
-    return False;
208
+        return false;
206 209
     }
207 210
     return strncmp($_SESSION['userinfo']['homedir'], $path, count($_SESSION['userinfo']['homedir'])) == 0;
208 211
 }
... ...
@@ -14,7 +14,7 @@ http://creativecommons.org/publicdomain/zero/1.0/
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.
15 15
 */
16 16
 
17
-function show_page($path = NULL) 
17
+function show_page($path = null)
18 18
 {
19 19
     global $prefix, $go, $title, $headline, $output, $module, $page, $html_header, $footnotes;
20 20
 
... ...
@@ -29,8 +29,9 @@ function show_page($path = NULL)
29 29
         $module = $path;
30 30
     }
31 31
     $theme = config('theme');
32
-  if (! $theme)
32
+    if (! $theme) {
33 33
         $theme = 'default';
34
+    }
34 35
     $theme_path = "themes/$theme/";
35 36
     $candidates = array();
36 37
     if ($page) {
... ...
@@ -48,21 +49,24 @@ function show_page($path = NULL)
48 49
     $candidates[] = "themes/default/page-$module.tpl.php";
49 50
     $candidates[] = "themes/default/page.tpl.php";
50 51
 
51
-  $theme_file = NULL;
52
-  foreach ($candidates AS $c) {
52
+    $theme_file = null;
53
+    foreach ($candidates as $c) {
53 54
         if (file_exists($c)) {
54 55
             $theme_file = $c;
55 56
             break;
56 57
         }
57 58
     }
58
-  if (! file_exists($theme_file))
59
+    if (! file_exists($theme_file)) {
59 60
         die("cannot get any theme file");
61
+    }
60 62
 
61 63
     include('inc/top.php');
62
-  if (!isset($title))
64
+    if (!isset($title)) {
63 65
         $title = '';
64
-  if (!isset($headline))
66
+    }
67
+    if (!isset($headline)) {
65 68
         $headline = $title;
69
+    }
66 70
     $content = $output;
67 71
 
68 72
     include($theme_file);
... ...
@@ -14,9 +14,7 @@ http://creativecommons.org/publicdomain/zero/1.0/
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.
15 15
 */
16 16
 
17
-if (! defined("TOP_INCLUDED"))
18
-{
19
-
17
+if (! defined("TOP_INCLUDED")) {
20 18
     define("TOP_INCLUDED", true);
21 19
 
22 20
     require_once("inc/error.php");
... ...
@@ -28,13 +26,12 @@ $weighted_menuitem = array();
28 26
 
29 27
     $submenu = array();
30 28
 
31
-foreach (config('modules') as $module)
32
-{
29
+    foreach (config('modules') as $module) {
33 30
         $menu = false;
34
-  if (file_exists("modules/{$module}/menu.php"))
31
+        if (file_exists("modules/{$module}/menu.php")) {
35 32
             include("modules/{$module}/menu.php");
36
-  if ($menu === false)
37
-  {
33
+        }
34
+        if ($menu === false) {
38 35
             #DEBUG("Modul {$module} hat keine Menüeinträge");
39 36
             continue;
40 37
         }
... ...
@@ -42,32 +39,30 @@ foreach (config('modules') as $module)
42 39
         //DEBUG("<h4>$module</h4>");
43 40
         //DEBUG($menu);
44 41
         // $menu["foo"]["file"] enthält den Link
45
-  foreach (array_keys($menu) as $key)
46
-  {
42
+        foreach (array_keys($menu) as $key) {
47 43
             $menu[$key]["file"] = $prefix."go/".$module."/".$menu[$key]["file"];
48 44
             $weight = $menu[$key]["weight"];
49
-    if (isset($menu[$key]['submenu']))
50
-    {
51
-      if (isset($submenu[$menu[$key]['submenu']][$weight]))
45
+            if (isset($menu[$key]['submenu'])) {
46
+                if (isset($submenu[$menu[$key]['submenu']][$weight])) {
52 47
                     $submenu[$menu[$key]['submenu']][$weight] = array_merge($submenu[$menu[$key]['submenu']][$weight], array($key => $menu[$key]));
53
-      else
48
+                } else {
54 49
                     $submenu[$menu[$key]['submenu']][$weight] = array($key => $menu[$key]);
55 50
                 }
56
-    else
57
-    {
58
-      if (array_key_exists($weight, $weighted_menuitem))
51
+            } else {
52
+                if (array_key_exists($weight, $weighted_menuitem)) {
59 53
                     $weighted_menuitem[$weight] = array_merge($weighted_menuitem[$weight], array($key => $menu[$key]));
60
-      else
54
+                } else {
61 55
                     $weighted_menuitem[$weight] = array($key => $menu[$key]);
62 56
                 }
63 57
             }
58
+        }
64 59
         $menuitem = array_merge($menuitem, $menu);
65 60
     }
66 61
 
67 62
     ksort($weighted_menuitem);
68 63
     #DEBUG($weighted_menuitem);
69 64
 
70
-foreach ($submenu AS $weight => $data) {
65
+    foreach ($submenu as $weight => $data) {
71 66
         ksort($submenu[$weight]);
72 67
     }
73 68
 
... ...
@@ -77,18 +72,23 @@ foreach ($submenu AS $weight => $data) {
77 72
     header("X-FRAME-OPTIONS: DENY");
78 73
     header("Content-Type: ".config('mime_type'));
79 74
 
80
-if (!isset($html_header))
75
+    if (!isset($html_header)) {
81 76
         $html_header = '';
77
+    }
82 78
 
83 79
     function array_key_exists_r($needle, $haystack)
84 80
     {
85 81
         $result = array_key_exists($needle, $haystack);
86
-    if ($result) return $result;
82
+        if ($result) {
83
+            return $result;
84
+        }
87 85
         foreach ($haystack as $v) {
88 86
             if (is_array($v)) {
89 87
                 $result = array_key_exists_r($needle, $v);
90 88
             }
91
-        if ($result) return $result;
89
+            if ($result) {
90
+                return $result;
91
+            }
92 92
         }
93 93
         return $result;
94 94
     }
... ...
@@ -96,32 +96,29 @@ function array_key_exists_r($needle, $haystack)
96 96
 
97 97
     $menu = '';
98 98
 
99
-foreach ($weighted_menuitem as $key => $menuitem)
100
-        foreach ($menuitem as $key => $item)
101
-        {
102
-                if ($key == $section)
99
+    foreach ($weighted_menuitem as $key => $menuitem) {
100
+        foreach ($menuitem as $key => $item) {
101
+            if ($key == $section) {
103 102
                 $menu .= '<a href="'.$item['file'].'" class="menuitem active">'.$item['label'].'</a>'."\n";
104
-                else
103
+            } else {
105 104
                 $menu .= '<a href="'.$item['file'].'" class="menuitem">'.$item['label'].'</a>'."\n";
106
-                if (isset($submenu[$key]))
107
-                {
108
-                        if ($key == $section || (array_key_exists($key, $submenu) && array_key_exists_r($section, $submenu[$key])))
109
-                        {
105
+            }
106
+            if (isset($submenu[$key])) {
107
+                if ($key == $section || (array_key_exists($key, $submenu) && array_key_exists_r($section, $submenu[$key]))) {
110 108
                     $menu .= "\n";
111
-				foreach ($submenu[$key] as $weight => $mysub) 
112
-				{
113
-                                  foreach ($mysub as $sec => $item)
114
-                                  {
115
-                                          if ($sec == $section)
109
+                    foreach ($submenu[$key] as $weight => $mysub) {
110
+                        foreach ($mysub as $sec => $item) {
111
+                            if ($sec == $section) {
116 112
                                 $menu .= '<a href="'.$item['file'].'" class="submenuitem menuitem active">'.$item['label'].'</a>'."\n";
117
-                                          else
113
+                            } else {
118 114
                                 $menu .= '<a href="'.$item['file'].'" class="submenuitem menuitem">'.$item['label'].'</a>'."\n";
119 115
                             }
120 116
                         }
117
+                    }
121 118
                     $menu .= "\n";
122 119
                 }
123 120
             }
124
-
121
+        }
125 122
     }
126 123
 
127 124
     $userinfo = '';
... ...
@@ -132,17 +129,14 @@ if ($role != ROLE_ANONYMOUS) {
132 129
         if ($role & ROLE_SYSTEMUSER && isset($_SESSION['subuser'])) {
133 130
             $userinfo .= '<strong>'.$_SESSION['subuser'].'</strong>';
134 131
             $userinfo .= '<br />Mitbenutzer von '.$_SESSION['userinfo']['username'];
135
-  }
136
-  elseif ($role & ROLE_SYSTEMUSER) {
132
+        } elseif ($role & ROLE_SYSTEMUSER) {
137 133
             $userinfo .= '<strong>'.$_SESSION['userinfo']['username'].'</strong>';
138 134
             $userinfo .= '<br />'.$_SESSION['userinfo']['name'];
139 135
             $userinfo .= '<br />(UID '.$_SESSION['userinfo']['uid'].(($role & ROLE_CUSTOMER) ? ', Kunde '.$_SESSION['customerinfo']['customerno'] : '').')';
140
-  }
141
-  elseif ($role & ROLE_CUSTOMER) {
136
+        } elseif ($role & ROLE_CUSTOMER) {
142 137
             $userinfo .= '<strong>'.$_SESSION['customerinfo']['name'].'</strong>';
143 138
             $userinfo .= '<br />(Kunde '.$_SESSION['customerinfo']['customerno'].')';
144
-  }
145
-  elseif ($role & (ROLE_MAILACCOUNT | ROLE_VMAIL_ACCOUNT)) {
139
+        } elseif ($role & (ROLE_MAILACCOUNT | ROLE_VMAIL_ACCOUNT)) {
146 140
             $userinfo .= '<strong>'.$_SESSION['mailaccount'].'</strong><br />(Postfach von Benutzer <em>'.$_SESSION['userinfo']['username'].'</em>)';
147 141
         }
148 142
         $userinfo .= '</p>';
... ...
@@ -158,7 +152,4 @@ $messages = get_messages();
158 152
 
159 153
     $BASE_PATH = $prefix;
160 154
     $THEME_PATH = $prefix."themes/".config('theme')."/";
161
-
162
-
163 155
 }
164
-?>
... ...
@@ -54,5 +54,3 @@ $form = '<table>
54 54
 output(html_form('adddomain_add', 'save', 'domain='.$data['domainname'], $form));
55 55
 
56 56
 output("<p><strong>Hinweis:</strong> Die hier angegebenen Beträge wurden automatisch aus unserer Preisliste ermittelt und werden zur Abrechnung verwendet. Sollten diese nicht der Vereinbarung entsprechen, teilen Sie uns dies bitte umgehend mit, damit wir dies korrigieren können.</p>");
57
-
58
-?>
... ...
@@ -77,7 +77,7 @@ function register_domain($domainname, $uid)
77 77
     }
78 78
 
79 79
     $cid = (int) $_SESSION['customerinfo']['customerno'];
80
-  $useraccount = NULL;
80
+    $useraccount = null;
81 81
     $available_users = list_useraccounts();
82 82
     foreach ($available_users as $u) {
83 83
         if ($uid == $u['uid']) {
... ...
@@ -109,8 +109,7 @@ function list_useraccounts()
109 109
     $customerno = (int) $_SESSION['customerinfo']['customerno'];
110 110
     $result = db_query("SELECT uid,username,name FROM system.useraccounts WHERE kunde=?", array($customerno));
111 111
     $ret = array();
112
-  while ($item = $result->fetch())
113
-  {
112
+    while ($item = $result->fetch()) {
114 113
         $ret[] = $item;
115 114
     }
116 115
     DEBUG($ret);
... ...
@@ -17,9 +17,6 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
17 17
 $role = $_SESSION['role'];
18 18
 
19 19
 
20
-if ($role & ROLE_CUSTOMER)
21
-{
20
+if ($role & ROLE_CUSTOMER) {
22 21
     $menu["adddomain_search"] = array("label" => "Domain hinzufügen", "file" => "search", "weight" => 0, "submenu" => "domains_domains");
23 22
 }
24
-
25
-?>
... ...
@@ -34,5 +34,3 @@ register_domain($_REQUEST['domain'], $_REQUEST['uid']);
34 34
 success_msg('Domain »'.filter_input_general($_REQUEST['domain']).'« wurde eingetragen!');
35 35
 
36 36
 redirect('search');
37
-
38
-?>
... ...
@@ -29,6 +29,3 @@ output('<p>Mit dieser Funktion können Sie eine neue Domain in unsere Datenbank
29 29
 $form = '<p>Domainname: <input type="text" name="domain" size="30" /> <input type="submit" value="Verfügbarkeit prüfen" />';
30 30
 
31 31
 output(html_form('adddomain_search', 'add', '', $form));
32
-
33
-
34
-?>
... ...
@@ -19,7 +19,7 @@ require_once('contacts.php');
19 19
 if (isset($_GET['q'])) {
20 20
     $id = search_pgp_key($_GET['q']);
21 21
     $result = array("status" => "notfound",
22
-        "id" => NULL);
22
+        "id" => null);
23 23
     if ($id) {
24 24
         $result['status'] = 'found';
25 25
         $result['id'] = $id;
... ...
@@ -29,7 +29,7 @@ if (isset($_GET['q'])) {
29 29
 }
30 30
 if (isset($_GET['id'])) {
31 31
     $id = fetch_pgp_key($_GET['id']);
32
-    $result = array("status" => "notfound", "id" => NULL);
32
+    $result = array("status" => "notfound", "id" => null);
33 33
     if ($id) {
34 34
         $result['status'] = 'found';
35 35
         $result['id'] = $id;
... ...
@@ -25,10 +25,10 @@ require_once('session/start.php');
25 25
 require_role(array(ROLE_CUSTOMER));
26 26
 $section = 'contacts_list';
27 27
 
28
-$new = False;
28
+$new = false;
29 29
 if ($_REQUEST['id'] == 'new') {
30 30
     title("Adresse anlegen");
31
-    $new = True;
31
+    $new = true;
32 32
 } else {
33 33
     title("Adresse bearbeiten");
34 34
 }
... ...
@@ -38,13 +38,13 @@ if (! $new) {
38 38
     $c = get_contact($_REQUEST['id']);
39 39
 } elseif (isset($_REQUEST['copy'])) {
40 40
     $c = get_contact($_REQUEST['copy']);
41
-    $c['nic_handle'] = NULL;
41
+    $c['nic_handle'] = null;
42 42
 }
43 43
 $domains = domainlist_by_contact($c);
44 44
 
45 45
 $readonly = '';
46 46
 // Wenn das Handle beim NIC angemeldet ist, kann man Name und Land nicht mehr ändern
47
-if ($c['nic_handle'] != NULL) {
47
+if ($c['nic_handle'] != null) {
48 48
     $readonly = ' disabled="disabled" ';
49 49
     output('<p>Da diese Adresse als möglicher Domaininhaber bei der Domain-Regristry angemeldet ist, können Name/Firmenname und Land nicht mehr geändert werden. Legen Sie ggf. eine neue Adresse an und ändern Sie den Domain-Inhaber entsprechend.</p>');
50 50
 }
... ...
@@ -114,6 +114,3 @@ if ($domains) {
114 114
     }
115 115
     output('</ul>');
116 116
 }
117
-
118
-
119
-?>
... ...
@@ -63,7 +63,8 @@ function apicontact_to_contact($ac)
63 63
 
64 64
 
65 65
 
66
-function download_contact($nic_id) {
66
+function download_contact($nic_id)
67
+{
67 68
     $data = array("contactId" => $nic_id);
68 69
     $result = api_request('contactInfo', $data);
69 70
     if ($result['status'] != 'success') {
... ...
@@ -30,24 +30,25 @@ Todo:
30 30
 */
31 31
 
32 32
 
33
-function new_contact() {
34
-    return array("id" => NULL,
35
-        "state" => NULL,
33
+function new_contact()
34
+{
35
+    return array("id" => null,
36
+        "state" => null,
36 37
         "lastchange" => time(),
37
-        "nic_handle" => NULL,
38
-        "nic_id" => NULL,
39
-        "company" => NULL,
40
-        "name" => NULL,
41
-        "address" => NULL,
42
-        "zip" => NULL,
43
-        "city" => NULL,
38
+        "nic_handle" => null,
39
+        "nic_id" => null,
40
+        "company" => null,
41
+        "name" => null,
42
+        "address" => null,
43
+        "zip" => null,
44
+        "city" => null,
44 45
         "country" => "DE",
45
-        "phone" => NULL,
46
-        "mobile" => NULL,
47
-        "fax" => NULL,
48
-        "email" => NULL,
49
-        "pgp_id" => NULL,
50
-        "pgp_key" => NULL,
46
+        "phone" => null,
47
+        "mobile" => null,
48
+        "fax" => null,
49
+        "email" => null,
50
+        "pgp_id" => null,
51
+        "pgp_key" => null,
51 52
         "customer" => $_SESSION['customerinfo']['customerno']);
52 53
 }
53 54
 
... ...
@@ -65,7 +66,8 @@ function get_contact($id)
65 66
     return $contact;
66 67
 }
67 68
 
68
-function get_contacts() {
69
+function get_contacts()
70
+{
69 71
     $cid = (int) $_SESSION['customerinfo']['customerno'];
70 72
     $result = db_query("SELECT id, state, lastchange, nic_id, nic_handle, company, name, address, zip, city, country, phone, mobile, fax, email, pgp_id, pgp_key FROM kundendaten.contacts WHERE (state<>'deleted' OR state IS NULL) AND customer=? ORDER BY COALESCE(company, name)", array($cid));
71 73
     $ret = array();
... ...
@@ -77,7 +79,8 @@ function get_contacts() {
77 79
 }
78 80
 
79 81
 
80
-function is_domainholder($contactid) {
82
+function is_domainholder($contactid)
83
+{
81 84
     $contactid = (int) $contactid;
82 85
     $result = db_query("SELECT id FROM kundendaten.domains WHERE owner=? OR admin_c=?", array($contactid, $contactid));
83 86
     if ($result->rowCount() > 0) {
... ...
@@ -86,7 +89,8 @@ function is_domainholder($contactid) {
86 89
     return false;
87 90
 }
88 91
 
89
-function possible_domainholders() {
92
+function possible_domainholders()
93
+{
90 94
     $allcontacts = get_contacts();
91 95
     $ret = array();
92 96
     foreach ($allcontacts as $id => $c) {
... ...
@@ -116,16 +120,18 @@ function have_mailaddress($email)
116 120
 }
117 121
 
118 122
 
119
-function possible_kundenkontakt($c) {
123
+function possible_kundenkontakt($c)
124
+{
120 125
     if ($c['name'] && $c['email']) {
121 126
         return true;
122 127
     }
123 128
 }
124 129
 
125 130
 
126
-function set_kundenkontakt($typ, $id) {
131
+function set_kundenkontakt($typ, $id)
132
+{
127 133
     if (! $id) {
128
-        $id = NULL;
134
+        $id = null;
129 135
     } else {
130 136
         $id = (int) $id;
131 137
     }
... ...
@@ -133,7 +139,7 @@ function set_kundenkontakt($typ, $id) {
133 139
         "kunde" => (int) $_SESSION['customerinfo']['customerno'],
134 140
         "contact" => $id
135 141
         );
136
-    $field = NULL;
142
+    $field = null;
137 143
     if ($typ == 'kunde') {
138 144
         $field = 'contact_kunde';
139 145
     } elseif ($typ == 'extern') {
... ...
@@ -155,8 +161,8 @@ function sync_legacy_contactdata()
155 161
     $cid = (int) $_SESSION['customerinfo']['customerno'];
156 162
     $kundenkontakte = get_kundenkontakte();
157 163
     $kunde = get_contact($kundenkontakte['kunde']);
158
-    $vorname = NULL;
159
-    $nachname = NULL;
164
+    $vorname = null;
165
+    $nachname = null;
160 166
     if ($kunde['name']) {
161 167
         $vorname = explode(' ', $kunde['name'], 2)[0];
162 168
         $nachname = explode(' ', $kunde['name'], 2)[1];
... ...
@@ -200,7 +205,8 @@ function sync_legacy_contactdata()
200 205
 }
201 206
 
202 207
 
203
-function get_kundenkontakte() {
208
+function get_kundenkontakte()
209
+{
204 210
     $cid = (int) $_SESSION['customerinfo']['customerno'];
205 211
     $result = db_query("SELECT contact_kunde, contact_extern, contact_rechnung, contact_dataprotection FROM kundendaten.kunden WHERE id=?", array($cid));
206 212
     $res = $result->fetch();
... ...
@@ -277,14 +283,14 @@ https://schokokeks.org
277 283
 ';
278 284
     # send welcome message
279 285
     mail($email, '=?UTF-8?Q?Best=C3=A4tigung_Ihrer_E-Mail-Adresse?=', $message, "X-schokokeks-org-message: verify\nFrom: ".config('company_name').' <'.config('adminmail').">\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\n");
280
- 
281 286
 }
282 287
 
283
-function update_pending($contactid) {
288
+function update_pending($contactid)
289
+{
284 290
     $contactid = (int) $contactid;
285 291
     $result = db_query("SELECT email FROM kundendaten.mailaddress_token WHERE contact=?", array($contactid));
286 292
     if ($result->rowCount() == 0) {
287
-        return NULL;
293
+        return null;
288 294
     }
289 295
     $res = $result->fetch();
290 296
     return $res['email'];
... ...
@@ -292,17 +298,18 @@ function update_pending($contactid) {
292 298
 
293 299
 
294 300
 
295
-function delete_contact($id) {
301
+function delete_contact($id)
302
+{
296 303
     $c = get_contact($id);
297 304
     $kundenkontakte = get_kundenkontakte();
298 305
     if ($id == $kundenkontakte['kunde']) {
299 306
         system_failure("Die Stamm-Adresse kann nicht gelöscht werden, bitte erst eine andere Adresse als Stamm-Adresse festlegen!");
300 307
     }
301 308
     if ($id == $kundenkontakte['rechnung']) {
302
-        set_kundenkontakt('rechnung', NULL);
309
+        set_kundenkontakt('rechnung', null);
303 310
     }
304 311
     if ($id == $kundenkontakte['extern']) {
305
-        set_kundenkontakt('extern', NULL);
312
+        set_kundenkontakt('extern', null);
306 313
     }
307 314
     if ($c['nic_id']) {
308 315
         // Lösche bei der Registry
... ...
@@ -313,16 +320,17 @@ function delete_contact($id) {
313 320
 }
314 321
 
315 322
 
316
-function search_pgp_key($search) {
323
+function search_pgp_key($search)
324
+{
317 325
     if (! check_emailaddr($search)) {
318 326
         # Keine Ausgabe weil diese Funktion im AJAX-Call verwendet wird
319
-        return NULL;
327
+        return null;
320 328
     }
321 329
     $output = array();
322 330
     exec('LC_ALL=C /usr/bin/gpg --batch --with-colons --keyserver hkp://pool.sks-keyservers.net --search-key '.escapeshellarg($search), $output);
323 331
     DEBUG($output);
324 332
     $keys = array();
325
-    foreach($output AS $row) {
333
+    foreach ($output as $row) {
326 334
         if (substr($row, 0, 4) === 'pub:') {
327 335
             $parts = explode(':', $row);
328 336
             if ($parts[5] && ($parts[5] < time())) {
... ...
@@ -335,7 +343,7 @@ function search_pgp_key($search) {
335 343
         }
336 344
     }
337 345
     if (count($keys) == 0) {
338
-        return NULL;
346
+        return null;
339 347
     }
340 348
     ksort($keys, SORT_NUMERIC);
341 349
     DEBUG(end($keys));
... ...
@@ -344,9 +352,10 @@ function search_pgp_key($search) {
344 352
 }
345 353
 
346 354
 
347
-function fetch_pgp_key($pgp_id) {
355
+function fetch_pgp_key($pgp_id)
356
+{
348 357
     $output = array();
349
-    $ret = NULL;
358
+    $ret = null;
350 359
     DEBUG('/usr/bin/gpg --batch --keyserver hkp://pool.sks-keyservers.net --recv-key '.escapeshellarg($pgp_id));
351 360
     exec('/usr/bin/gpg --batch --keyserver hkp://pool.sks-keyservers.net --recv-key '.escapeshellarg($pgp_id), $output, $ret);
352 361
     DEBUG($output);
... ...
@@ -354,7 +363,7 @@ function fetch_pgp_key($pgp_id) {
354 363
     if ($ret == 0) {
355 364
         exec('/usr/bin/gpg --batch --with-colons --list-keys '.escapeshellarg($pgp_id), $output);
356 365
         DEBUG($output);
357
-        foreach ($output AS $row) {
366
+        foreach ($output as $row) {
358 367
             if (substr($row, 0, 4) === 'fpr:') {
359 368
                 $parts = explode(':', $row);
360 369
                 // Fingerprint
... ...
@@ -362,11 +371,12 @@ function fetch_pgp_key($pgp_id) {
362 371
             }
363 372
         }
364 373
     }
365
-    return NULL;
374
+    return null;
366 375
 }
367 376
 
368 377
 
369
-function domainlist_by_contact($c) {
378
+function domainlist_by_contact($c)
379
+{
370 380
     $cid = (int) $_SESSION['customerinfo']['customerno'];
371 381
     $result = db_query("SELECT id FROM kundendaten.domains WHERE (owner=? OR admin_c=?) AND kunde=?", array($c['id'], $c['id'], $cid));
372 382
     $ret = array();
... ...
@@ -16,15 +16,16 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
16 16
 
17 17
 require_once('vendor/autoload.php');
18 18
 
19
-function format_number($number, $country) {
19
+function format_number($number, $country)
20
+{
20 21
     $phoneNumberUtil = \libphonenumber\PhoneNumberUtil::getInstance();
21 22
     try {
22 23
         $phoneNumber = $phoneNumberUtil->parse($number, $country);
23 24
     } catch (Exception $e) {
24
-        return NULL;
25
+        return null;
25 26
     }
26 27
     if ($phoneNumberUtil->isValidNumber($phoneNumber)) {
27 28
         return $phoneNumberUtil->format($phoneNumber, 1);
28 29
     }
29
-    return NULL;
30
+    return null;
30 31
 }
... ...
@@ -21,13 +21,12 @@ function verify_mail_token($token)
21 21
     db_query("DELETE FROM kundendaten.mailaddress_token WHERE expire<NOW()");
22 22
     $args = array(":token" => $token);
23 23
     $result = db_query("SELECT contact, email FROM kundendaten.mailaddress_token WHERE token=:token AND expire>NOW()", $args);
24
-  if ($result->rowCount() > 0)
25
-  {
24
+    if ($result->rowCount() > 0) {
26 25
         $line = $result->fetch();
27 26
         db_query("DELETE FROM kundendaten.mailaddress_token WHERE token=:token", $args);
28 27
         return $line;
29 28
     } else {
30
-    return NULL;
29
+        return null;
31 30
     }
32 31
 }
33 32
 
... ...
@@ -49,7 +49,7 @@ foreach ($liste as $id) {
49 49
     if ($id == $kundenkontakte['extern']) {
50 50
         $usage[] = 'Ersatz-Adresse';
51 51
     }
52
-    if ($id == $kundenkontakte['rechnung'] || ($id == $kundenkontakte['kunde'] && $kundenkontakte['rechnung'] == NULL)) {
52
+    if ($id == $kundenkontakte['rechnung'] || ($id == $kundenkontakte['kunde'] && $kundenkontakte['rechnung'] == null)) {
53 53
         $usage[] = 'Rechnungs-Adresse';
54 54
     }
55 55
     if ($id == $kundenkontakte['dataprotection']) {
... ...
@@ -67,6 +67,3 @@ foreach ($liste as $id) {
67 67
 }
68 68
 output("</div><br />");
69 69
 addnew('edit', 'Neue Adresse erstellen', 'id=new');
70
-
71
-
72
-?>
... ...
@@ -17,9 +17,6 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
17 17
 $role = $_SESSION['role'];
18 18
 
19 19
 
20
-if (($role & ROLE_CUSTOMER))
21
-{
20
+if (($role & ROLE_CUSTOMER)) {
22 21
     $menu["contacts_list"] = array("label" => "Adressen verwalten", "file" => "list", "weight" => 1, "submenu" => "index_index");
23 22
 }
24
-
25
-?>
... ...
@@ -28,11 +28,11 @@ if ($number) {
28 28
         $return['number'] = $num;
29 29
         $return['valid'] = 1;
30 30
     } else {
31
-        $return['number'] = NULL;
31
+        $return['number'] = null;
32 32
         $return['valid'] = 0;
33 33
     }
34 34
 } else {
35
-    $return['number'] = NULL;
35
+    $return['number'] = null;
36 36
     $return['valid'] = 0;
37 37
 }
38 38
 
... ...
@@ -35,30 +35,25 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
35 35
     $contact_string = display_contact($contact);
36 36
 
37 37
     $sure = user_is_sure();
38
-    if ($sure === NULL)
39
-    {
38
+    if ($sure === null) {
40 39
         are_you_sure("action=delete&id={$contact['id']}&back=".urlencode($back), "Möchten Sie diese Adresse wirklich löschen? {$contact_string}");
41
-    }
42
-    elseif ($sure === true)
43
-    {
40
+    } elseif ($sure === true) {
44 41
         delete_contact($contact['id']);
45
-       if (! $debugmode)
42
+        if (! $debugmode) {
46 43
             header("Location: ".$back);
47 44
         }
48
-    elseif ($sure === false)
49
-    {
50
-        if (! $debugmode)
45
+    } elseif ($sure === false) {
46
+        if (! $debugmode) {
51 47
             header("Location: ".$back);
52 48
         }
53
-
54
-
49
+    }
55 50
 } else {
56 51
     check_form_token('contacts_edit');
57 52
 
58
-    $new = False;
53
+    $new = false;
59 54
     if ($_REQUEST['id'] == 'new') {
60 55
         title("Adresse anlegen");
61
-        $new = True;
56
+        $new = true;
62 57
     } else {
63 58
         title("Adresse bearbeiten");
64 59
     }
... ...
@@ -78,7 +73,7 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
78 73
         $_REQUEST['land'] = $c['country'];
79 74
     }
80 75
 
81
-    if ($c['nic_handle'] != NULL) {
76
+    if ($c['nic_handle'] != null) {
82 77
         if ($c['name'] != $_REQUEST['name'] || $c['company'] != $_REQUEST['firma'] || $c['country'] != $_REQUEST['land']) {
83 78
             system_failure('Name/Firma/Land kann bei diesem Kontakt nicht geändert werden.');
84 79
         }
... ...
@@ -113,7 +108,7 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
113 108
             system_failure('Die eingegebene Telefonnummer scheint nicht gültig zu sein!');
114 109
         }
115 110
     } else {
116
-        $c['phone'] = NULL;
111
+        $c['phone'] = null;
117 112
     }
118 113
     if (isset($_REQUEST['mobile']) && $_REQUEST['mobile'] != '') {
119 114
         $num = format_number(verify_input_general($_REQUEST['mobile']), $_REQUEST['land']);
... ...
@@ -123,7 +118,7 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
123 118
             system_failure('Die eingegebene Mobiltelefonnummer scheint nicht gültig zu sein!');
124 119
         }
125 120
     } else {
126
-        $c['mobile'] = NULL;
121
+        $c['mobile'] = null;
127 122
     }
128 123
     if (isset($_REQUEST['telefax']) && $_REQUEST['telefax'] != '') {
129 124
         $num = format_number(verify_input_general($_REQUEST['telefax']), $_REQUEST['land']);
... ...
@@ -133,7 +128,7 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
133 128
             system_failure('Die eingegebene Faxnummer scheint nicht gültig zu sein!');
134 129
         }
135 130
     } else {
136
-        $c['fax'] = NULL;
131
+        $c['fax'] = null;
137 132
     }
138 133
 
139 134
     
... ...
@@ -149,8 +144,8 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
149 144
             warning('Ihre PGP-ID wurde nicht übernommen, da sie syntaktisch falsch erscheint');
150 145
         }
151 146
     } else {
152
-        $c['pgp_id'] = NULL;
153
-        $c['pgp_key'] = NULL;
147
+        $c['pgp_id'] = null;
148
+        $c['pgp_key'] = null;
154 149
     }
155 150
 
156 151
 
... ...
@@ -49,7 +49,7 @@ if (isset($_REQUEST['useas'])) {
49 49
     }
50 50
     if ($_REQUEST['useas'] == 'extern') {
51 51
         if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
52
-            set_kundenkontakt('extern', NULL);
52
+            set_kundenkontakt('extern', null);
53 53
             redirect('useas?id='.$id);
54 54
         } else {
55 55
             set_kundenkontakt('extern', $id);
... ...
@@ -58,7 +58,7 @@ if (isset($_REQUEST['useas'])) {
58 58
     }
59 59
     if ($_REQUEST['useas'] == 'rechnung') {
60 60
         if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
61
-            set_kundenkontakt('rechnung', NULL);
61
+            set_kundenkontakt('rechnung', null);
62 62
             redirect('useas?id='.$id);
63 63
         } else {
64 64
             set_kundenkontakt('rechnung', $id);
... ...
@@ -67,7 +67,7 @@ if (isset($_REQUEST['useas'])) {
67 67
     }
68 68
     if ($_REQUEST['useas'] == 'dataprotection') {
69 69
         if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
70
-            set_kundenkontakt('dataprotection', NULL);
70
+            set_kundenkontakt('dataprotection', null);
71 71
             redirect('useas?id='.$id);
72 72
         } else {
73 73
             set_kundenkontakt('dataprotection', $id);
... ...
@@ -20,11 +20,10 @@ require_once('inc/security.php');
20 20
 title("E-Mail-Adresse bestätigen");
21 21
 $section = 'contacts_list';
22 22
 
23
-if (isset($_REQUEST['token']))
24
-{
23
+if (isset($_REQUEST['token'])) {
25 24
     $token = $_REQUEST['token'];
26 25
     $daten = verify_mail_token($token);
27
-  if ($daten == NULL) {
26
+    if ($daten == null) {
28 27
         system_failure('Die E-Mail-Adresse konnte nicht verifiziert werden. Vielleicht ist der Link bereits abgelaufen.');
29 28
     } else {
30 29
         update_mailaddress($daten);
... ...
@@ -33,6 +32,3 @@ if (isset($_REQUEST['token']))
33 32
         header('Location: /');
34 33
     }
35 34
 }
36
-
37
-
38
-?>
... ...
@@ -18,17 +18,12 @@ require_once('contract.php');
18 18
 require_role(ROLE_CUSTOMER);
19 19
 
20 20
 $pdfdata = get_contract_pdf($_REQUEST['id']);
21
-if (! $pdfdata)
22
-{
21
+if (! $pdfdata) {
23 22
     system_failure('Die PDF-Version dieses Vertrags konnte nicht ausgelesen werden. Bitte wenden Sie sich an den Support.');
24
-}
25
-else
26
-{
23
+} else {
27 24
     $filename = 'av_vertrag.pdf';
28 25
     header('Content-type: application/pdf');
29 26
     header('Content-disposition: attachment; filename='.$filename);
30 27
     echo $pdfdata;
31 28
     die();
32 29
 }
33
-
34
-?>
... ...
@@ -20,4 +20,3 @@ require_role(array(ROLE_CUSTOMER));
20 20
 
21 21
 echo contract_html();
22 22
 die();
23
-?>
... ...
@@ -17,19 +17,21 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
17 17
 require_role(ROLE_CUSTOMER);
18 18
 
19 19
 
20
-function get_orderprocessing_contract() {
20
+function get_orderprocessing_contract()
21
+{
21 22
     $args = array(
22 23
         "cid" => (int) $_SESSION['customerinfo']['customerno']);
23 24
     $result = db_query("SELECT id, signed, type, startdate, enddate FROM kundendaten.contract WHERE customer=:cid AND type='orderprocessing' AND (enddate IS NULL OR enddate < CURDATE())", $args);
24 25
     if ($result->rowCount() == 0) {
25
-        return NULL;
26
+        return null;
26 27
     }
27 28
     $line = $result->fetch();
28 29
     return $line;
29 30
 }
30 31
 
31 32
 
32
-function contract_html() {
33
+function contract_html()
34
+{
33 35
     use_module('contacts');
34 36
     require_once('contacts.php');
35 37
     
... ...
@@ -58,21 +60,22 @@ function contract_html() {
58 60
 }
59 61
 
60 62
 
61
-function save_op_contract($pdfdata) {
63
+function save_op_contract($pdfdata)
64
+{
62 65
     $args = array("cid" => $_SESSION['customerinfo']['customerno'],
63 66
             "pdfdata" => $pdfdata);
64
-    db_query("INSERT INTO kundendaten.contract (customer, signed, type, startdate, pdfdata) VALUES (:cid, NOW(), 'orderprocessing', CURDATE(), :pdfdata)",
65
-        $args);
67
+    db_query(
68
+        "INSERT INTO kundendaten.contract (customer, signed, type, startdate, pdfdata) VALUES (:cid, NOW(), 'orderprocessing', CURDATE(), :pdfdata)",
69
+        $args
70
+    );
66 71
 }
67 72
 
68 73
 
69
-function get_contract_pdf($id) {
74
+function get_contract_pdf($id)
75
+{
70 76
     $args = array("id" => $id,
71 77
         "cid" => $_SESSION['customerinfo']['customerno']);
72 78
     $result = db_query("SELECT pdfdata FROM kundendaten.contract WHERE id=:id AND customer=:cid", $args);
73 79
     $line = $result->fetch();
74 80
     return $line['pdfdata'];
75 81
 }
76
-
77
-
78
-?>
... ...
@@ -37,7 +37,3 @@ if ($contract) {
37 37
 } else {
38 38
     addnew('new_op', 'Einen Vertrag zur Auftragsverarbeitung abschließen');
39 39
 }
40
-
41
-
42
-
43
-?>
... ...
@@ -17,9 +17,6 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
17 17
 $role = $_SESSION['role'];
18 18
 
19 19
 
20
-if (($role & ROLE_CUSTOMER))
21
-{
20
+if (($role & ROLE_CUSTOMER)) {
22 21
     $menu["contract_list"] = array("label" => "AV-Vertrag", "file" => "list", "weight" => 10, "submenu" => "index_index");
23 22
 }
24
-
25
-?>
... ...
@@ -30,7 +30,3 @@ $html = '<p><input type="checkbox" name="agree" value="yes" id="agree"> <label f
30 30
 <p><input type="submit" value="Unterzeichnen"></p>';
31 31
 
32 32
 output(html_form('contract_new_op', 'sign', 'type=op', $html));
33
-
34
-
35
-
36
-?>
... ...
@@ -31,5 +31,3 @@ if (isset($_REQUEST['agree']) && $_REQUEST['agree'] == 'yes') {
31 31
 } else {
32 32
     system_failure("Sie müssen dem Vertrag zustimmen!");
33 33
 }
34
-
35
-?>
... ...
@@ -35,12 +35,11 @@ $output .=  '<table><tr><th>Domainname</th><th>Manuelle records</th><th>Automati
35 35
 
36 36
 DEBUG($domains);
37 37
 
38
-$external_domains = False;
39
-$unused_dns = False;
40
-foreach($domains AS $dom)
41
-{
38
+$external_domains = false;
39
+$unused_dns = false;
40
+foreach ($domains as $dom) {
42 41
     if ($dom->provider != 'terions') {
43
-    $external_domains = True;
42
+        $external_domains = true;
44 43
     }
45 44
     $style="";
46 45
     if ($dom->dns == 0) {
... ...
@@ -54,9 +53,9 @@ foreach($domains AS $dom)
54 53
     $records = get_domain_records($dom->id);
55 54
 
56 55
     $autorec = ($dom->autodns == 1 ? 'Ja' : 'Nein');
57
-  if ($dom->provider != 'terions' || $dom->billing != 'regular' || $dom->registrierungsdatum == NULL || $dom->kuendigungsdatum != NULL) {
56
+    if ($dom->provider != 'terions' || $dom->billing != 'regular' || $dom->registrierungsdatum == null || $dom->kuendigungsdatum != null) {
58 57
         $state = check_dns($dom->domainname, $dom->tld);
59
-    if ($state !== True) {
58
+        if ($state !== true) {
60 59
             $current = 'Momentaner DNS-Server (u.A.): '.$state;
61 60
             if ($state == 'NXDOMAIN') {
62 61
                 $current = 'Diese Domain ist aktuell nicht registriert.';
... ...
@@ -66,7 +65,7 @@ foreach($domains AS $dom)
66 65
                 continue;
67 66
             } else {
68 67
                 $output .= '<tr><td>'.internal_link('dns_domain', $dom->fqdn, "dom={$dom->id}").'</td><td>'.count($records).'</td><td>'.$autorec.'</td><td>'.icon_enabled('DNS-Server aktiv').'<br />'.icon_warning().' Lokaler DNS-Server eingeschaltet aber nicht genutzt<br />'.$current.'<br />'.internal_link('save', icon_delete().' Lokalen DNS-Server abschalten', "dom={$dom->id}&dns=0").'</td></tr>';
69
-        $unused_dns = True;
68
+                $unused_dns = true;
70 69
                 continue;
71 70
             }
72 71
         }
... ...
@@ -109,6 +108,3 @@ if ($unused_dns) {
109 108
 <p>Wenn Sie weiterhin einen externen DNS-Server benutzen möchten, dann schalten Sie bitte unseren DNS-Server für diese Domain aus, damit es nicht zu Fehlfunktionen kommt.</p>
110 109
 <p>Im Zweifel sprechen Sie bitte unseren Support an.</p>';
111 110
 }
112
-
113
-
114
-?>
... ...
@@ -33,9 +33,9 @@ DEBUG($domain);
33 33
 title('DNS-Records für '.filter_input_general($domain->fqdn));
34 34
 headline('DNS-Records für <em>'.filter_input_general($domain->fqdn).'</em>');
35 35
 
36
-if ($domain->provider != 'terions' || $domain->billing != 'regular' || $domain->registrierungsdatum == NULL || $domain->kuendigungsdatum != NULL) {
36
+if ($domain->provider != 'terions' || $domain->billing != 'regular' || $domain->registrierungsdatum == null || $domain->kuendigungsdatum != null) {
37 37
     $state = check_dns($domain->domainname, $domain->tld);
38
-    if ($state !== True) {
38
+    if ($state !== true) {
39 39
         $current = 'Momentaner DNS-Server (u.A.): '.$state;
40 40
         if ($state == 'NXDOMAIN') {
41 41
             $current = 'Diese Domain ist aktuell nicht registriert.';
... ...
@@ -56,35 +56,29 @@ $cname_on_domain = false;
56 56
 
57 57
 output('<table><tr><th>Hostname</th><th>Typ</th><th>IP-Adresse/Inhalt</th><th>TTL</th><th>&#160;</th></tr>
58 58
 ');
59
-foreach ($records AS $rec)
60
-{
59
+foreach ($records as $rec) {
61 60
     $editable = true;
62 61
     $data = filter_input_general($rec['ip'] ? $rec['ip'] : $rec['data']);
63
-  if ($rec['dyndns'])
64
-  {
65
-    if ($domain->fqdn == config('masterdomain'))
66
-    { 
62
+    if ($rec['dyndns']) {
63
+        if ($domain->fqdn == config('masterdomain')) {
67 64
             $data = '<em>DynDNS #'.(int) $rec['dyndns'].'</em>';
68 65
             $editable = false;
69 66
         } else {
70 67
             $dyndns = get_dyndns_account($rec['dyndns']);
71
-      if ($dyndns === NULL) {
68
+            if ($dyndns === null) {
72 69
                 $data = '<em>DynDNS #'.(int) $rec['dyndns'].' (nicht Ihr Account)</em>';
73 70
             } else {
74 71
                 $data = internal_link('dyndns_edit', '<em>DynDNS #'.(int) $rec['dyndns'].' ('.filter_input_general($dyndns['handle']).')</em>', 'id='.(int) $rec['dyndns']);
75 72
             }
76 73
         }
77 74
     }
78
-  if ($rec['type'] == 'mx')
79
-  {
75
+    if ($rec['type'] == 'mx') {
80 76
         $data .= ' ('.(int) $rec['spec'].')';
81 77
     }
82
-  if ($rec['type'] == 'sshfp')
83
-  {
78
+    if ($rec['type'] == 'sshfp') {
84 79
         $data = (int) $rec['spec'] . ' 1 ' . $data;
85 80
     }
86
-  if ($rec['type'] == 'caa')
87
-  {
81
+    if ($rec['type'] == 'caa') {
88 82
         $data = $caa_properties[(int) $rec['spec']] . ' 0 "' . $data.'"';
89 83
     }
90 84
     $ttl = ($rec['ttl'] ? $rec['ttl'] : 3600);
... ...
@@ -102,8 +96,7 @@ foreach ($records AS $rec)
102 96
     }
103 97
     output("<tr><td>{$link}</td><td>".strtoupper($rec['type'])."</td><td>".$data."</td><td>{$ttl} Sek.</td><td>".$delete."</td></tr>\n");
104 98
 }
105
-foreach ($auto_records AS $rec)
106
-{
99
+foreach ($auto_records as $rec) {
107 100
     $data = filter_input_general($rec['ip'] ? $rec['ip'] : $rec['data']);
108 101
     $ttl = ($rec['ttl'] ? $rec['ttl'] : 3600);
109 102
     output("<tr><td><em>{$rec['fqdn']}</em></td><td>".strtoupper($rec['type'])."</td><td>$data</td><td>{$ttl} Sek.</td><td>&#160;</td></tr>\n");
... ...
@@ -113,10 +105,11 @@ foreach ($auto_records AS $rec)
113 105
 
114 106
 output('</table>');
115 107
 
116
-if ($domain->autodns)
108
+if ($domain->autodns) {
117 109
     output('<p style="font-size: 80%;"><em>Kursive Hostnames bezeichnen automatisch erzeugte Records. Diese können nicht geändert werden.</em></p>');
118
-else
110
+} else {
119 111
     output('<p style="font-size: 80%;"><em>Für diese Domain wurde die Erzeugung automatischer Records deaktiviert.</em></p>');
112
+}
120 113
 
121 114
 
122 115
 output('<h4>Neuen DNS-Record anlegen</h4>
... ...
@@ -140,18 +133,13 @@ output('<h4>Neuen DNS-Record anlegen</h4>
140 133
 <h4>Automatische DNS-Records</h4>
141 134
 ');
142 135
 
143
-if ($domain->autodns)
144
-{
136
+if ($domain->autodns) {
145 137
     output("<p>Für extrem ungewöhnliche Konfigurationen können Sie die Erzeugung von automatischen DNS-Records unter dieser Domain komplett abschalten. Dies ist i.d.R. falsch und wird zu Fehlfunktion führen. Nutzen Sie diese Einstellung auf eigene Gefahr.</p>
146 138
   <p>Möchten Sie einzelne DNS-Einträge abweichend setzen, so legen Sie einfach oben den jeweils gewünschten Record an. Falls es gleichlautende automatische Einträge gibt, werden diese anschließend unterdrückt.</p>
147 139
   <p>Warten Sie nach Änderung dieser Einstellung eine Minute und laden Sie danach die Seite neu.</p>
148 140
 <p>".internal_link('dns_save', 'Automatisch erzeugte Einträge umwandeln', "type=autodns&action=disable&dom={$domain->id}")."</p>");
149
-}
150
-else
151
-{
141
+} else {
152 142
     output("<p>Sie verwalten Ihre DNS-Einträge selbst. Wenn Sie möchten, können Sie die DNS-Einträge auch automatisch anhand der angelegten Webserver-VHosts und anderer Einstellungen festlegen lassen. Diese Eintäge können Sie dann nicht direkt ändern. Ihre bestehenden Einträge bleiben unberührt und zusätzlich erhalten. Bitte löschen Sie dadurch entstehende Duplikate!</p>
153 143
   <p>Warten Sie nach Änderung dieser Einstellung eine Minute und laden Sie danach die Seite neu.</p>
154 144
 <p>".internal_link('dns_save', 'Automatisch erzeugte Einträge aktivieren', "type=autodns&action=enable&dom={$domain->id}")."</p>");
155 145
 }
156
-
157
-?>
... ...
@@ -26,58 +26,57 @@ require_once('dnsinclude.php');
26 26
 $section = 'dns_dns';
27 27
 
28 28
 $data = array();
29
-$type = NULL;
29
+$type = null;
30 30
 
31 31
 $dyndns = false;
32 32
 $dyndns_accounts = array();
33
-foreach (get_dyndns_accounts() AS $t)
34
-{
33
+foreach (get_dyndns_accounts() as $t) {
35 34
     $dyndns_accounts[$t['id']] = $t['handle'];
36 35
 }
37 36
 
38
-if (isset($_REQUEST['type']) && $_REQUEST['type'] == "dyndns")
39
-{
37
+if (isset($_REQUEST['type']) && $_REQUEST['type'] == "dyndns") {
40 38
     $_REQUEST['type'] = 'a';
41 39
     $dyndns = true;
42 40
 }
43
-if (isset($_REQUEST['type']) && $_REQUEST['type'] == "dyndns_aaaa")
44
-{
41
+if (isset($_REQUEST['type']) && $_REQUEST['type'] == "dyndns_aaaa") {
45 42
     $_REQUEST['type'] = 'aaaa';
46 43
     $dyndns = true;
47 44
 }
48 45
 
49 46
 
50 47
 $new = false;
51
-if ($_REQUEST['id'] == 'new')
52
-{
48
+if ($_REQUEST['id'] == 'new') {
53 49
     $new = true;
54 50
     $data = blank_dns_record($_REQUEST['type']);
55 51
     $domain = new Domain((int) $_REQUEST['domain']);
56 52
     $domain->ensure_userdomain();
57 53
     $type = $_REQUEST['type'];
58
-  if (! in_array($type, $valid_record_types))
54
+    if (! in_array($type, $valid_record_types)) {
59 55
         system_failure('Ungültiger Record-Typ!');
56
+    }
60 57
     $data['domain'] = $domain->id;
61
-  if ($dyndns)
58
+    if ($dyndns) {
62 59
         $data['ttl'] = 120;
63 60
     }
61
+}
64 62
 
65
-if (! $new)
66
-{
63
+if (! $new) {
67 64
     $data = get_dns_record($_REQUEST['id']);
68 65
     $type = $data['type'];
69 66
     $dyndns = isset($data['dyndns']);
70 67
     $domain = new Domain((int) $data['domain']);
71 68
     $domain->ensure_userdomain();
72
-  if (! in_array($type, $valid_record_types))
69
+    if (! in_array($type, $valid_record_types)) {
73 70
         system_failure('Ungültiger Record-Typ!');
74 71
     }
72
+}
75 73
 
76 74
 
77
-if ($new)
75
+if ($new) {
78 76
     title('DNS-Record erstellen');
79
-else
77
+} else {
80 78
     title('DNS-Record bearbeiten');
79
+}
81 80
 
82 81
 if (strtoupper($type) == 'NS') {
83 82
     output('<p style="border: 2px solid red; padding: 1em; padding-left: 4em;"><img src="'.$prefix.'images/warning.png" style="margin-left: -3em; float: left;" /><strong>Bitte beachten Sie:</strong> Das Ändern der DNS-Server für die Stammdomain wird nicht funktionieren. Bitte geben Sie unbedingt einen Hostname ein um eine Subdomain auf einen anderen DNS-Server zu delegieren.</p>');
... ...
@@ -93,41 +92,37 @@ output('<p style="border: 2px solid red; padding: 1em; padding-left: 4em;"><img
93 92
 output('<p>Record-Typ: '.strtoupper($type).'</p>');
94 93
 
95 94
 $submit = 'Speichern';
96
-if ($new) 
95
+if ($new) {
97 96
     $submit = 'Anlegen';
97
+}
98 98
 
99 99
 $form = '';
100 100
 
101
-if (! $dyndns && ($type == 'a' || $type == 'aaaa'))
102
-{
101
+if (! $dyndns && ($type == 'a' || $type == 'aaaa')) {
103 102
     $form .= '
104 103
 <tr><td><label for="ip">IP-Adresse:</label></td><td><input type="text" name="ip" id="ip" value="'.$data['ip'].'" /></td></tr>
105 104
 ';
106 105
 }
107 106
 
108
-if ($type == 'ns')
109
-{
107
+if ($type == 'ns') {
110 108
     $form .= '
111 109
 <tr><td><label for="data">DNS-Server:</label></td><td><input type="text" name="data" id="data" value="'.$data['data'].'" /></td></tr>
112 110
 ';
113 111
 }
114 112
 
115
-if ($type == 'ptr' || $type == 'cname')
116
-{
113
+if ($type == 'ptr' || $type == 'cname') {
117 114
     $form .= '
118 115
 <tr><td><label for="data">Ziel:</label></td><td><input type="text" name="data" id="data" value="'.$data['data'].'" /></td></tr>
119 116
 ';
120 117
 }
121 118
 
122
-if ($type == 'spf' || $type == 'txt')
123
-{
119
+if ($type == 'spf' || $type == 'txt') {
124 120
     $form .= '
125 121
 <tr><td><label for="data">Inhalt:</label></td><td><input type="text" name="data" id="data" value="'.filter_input_general($data['data']).'" /></td></tr>
126 122
 ';
127 123
 }
128 124
 
129
-if ($type == 'sshfp')
130
-{
125
+if ($type == 'sshfp') {
131 126
     $algs = array(
132 127
     1 => "RSA",
133 128
     2 => "DSA",
... ...
@@ -137,7 +132,9 @@ if ($type == 'sshfp')
137 132
     $option="";
138 133
     foreach ($algs as $key => $alg) {
139 134
         $option .= '<option value="'.$key.'" ';
140
-    if ($key == $data['spec']) $option .= 'selected="selected"';
135
+        if ($key == $data['spec']) {
136
+            $option .= 'selected="selected"';
137
+        }
141 138
         $option .= '>'.$alg.' ('.$key.')</option>';
142 139
     }
143 140
 
... ...
@@ -147,12 +144,13 @@ if ($type == 'sshfp')
147 144
 ';
148 145
 }
149 146
 
150
-if ($type == 'caa')
151
-{
147
+if ($type == 'caa') {
152 148
     $option="";
153 149
     foreach ($caa_properties as $key => $property) {
154 150
         $option .= '<option value="'.$key.'" ';
155
-    if ($key == $data['spec']) $option .= 'selected="selected"';
151
+        if ($key == $data['spec']) {
152
+            $option .= 'selected="selected"';
153
+        }
156 154
         $option .= '>'.$property.' ('.$key.')</option>';
157 155
     }
158 156
     $form .= '
... ...
@@ -161,15 +159,13 @@ if ($type == 'caa')
161 159
 ';
162 160
 }
163 161
 
164
-if ($dyndns)
165
-{
162
+if ($dyndns) {
166 163
     $form .= '
167 164
 <tr><td><label for="dyndns">DynDNS-Zugang:</label></td><td>'.html_select('dyndns', $dyndns_accounts, $data['dyndns']).'</td></tr>
168 165
 ';
169 166
 }
170 167
 
171
-if ($type == 'mx')
172
-{
168
+if ($type == 'mx') {
173 169
     $form .= '
174 170
 <tr><td><label for="spec">Priorität:</label></td><td><input type="text" name="spec" id="spec" value="'.$data['spec'].'" /></td></tr>
175 171
 <tr><td><label for="data">Posteingangsserver:</label></td><td><input type="text" name="data" id="data" value="'.$data['data'].'" /></td></tr>
... ...
@@ -184,5 +180,3 @@ output(html_form('dns_record_edit', 'dns_record_save', "type={$type}&domain={$do
184 180
 </table>
185 181
 <p><input type="submit" value="'.$submit.'" /></p>
186 182
 '));
187
-
188
-?>
... ...
@@ -26,15 +26,12 @@ require_once('dnsinclude.php');
26 26
 $section = 'dns_dns';
27 27
 
28 28
 
29
-$record = NULL;
29
+$record = null;
30 30
 
31
-$id = NULL;
32
-if ($_REQUEST['id'] == 'new')
33
-{
31
+$id = null;
32
+if ($_REQUEST['id'] == 'new') {
34 33
     $record = blank_dns_record($_REQUEST['type']);
35
-}
36
-else
37
-{
34
+} else {
38 35
     $id = (int) $_REQUEST['id'];
39 36
     $record = get_dns_record($id);
40 37
 }
... ...
@@ -42,45 +39,37 @@ else
42 39
 
43 40
 if (isset($_GET['action']) && ($_GET['action'] == 'delete')) {
44 41
     $sure = user_is_sure();
45
-  if ($sure === NULL)
46
-  {
42
+    if ($sure === null) {
47 43
         $domain = new Domain((int) $record['domain']);
48 44
         $fqdn = $domain->fqdn;
49
-    if ($record['hostname'])
50
-    {
45
+        if ($record['hostname']) {
51 46
             $fqdn = $record['hostname'].'.'.$fqdn;
52 47
         }
53 48
         are_you_sure("action=delete&id={$id}", "Möchten Sie den ".strtoupper($record['type'])."-Record für ".$fqdn." wirklich löschen?");
54
-  }
55
-  elseif ($sure === true)
56
-  {
49
+    } elseif ($sure === true) {
57 50
         delete_dns_record($id);
58
-    if (! $debugmode)
51
+        if (! $debugmode) {
59 52
             header("Location: dns_domain?dom=".$record['domain']);
60 53
         }
61
-  elseif ($sure === false)
62
-  {
63
-    if (! $debugmode)
54
+    } elseif ($sure === false) {
55
+        if (! $debugmode) {
64 56
             header("Location: dns_domain?dom=".$record['domain']);
65 57
         }
66 58
     }
67
-else
68
-{
59
+} else {
69 60
     // Sicherheitsprüfungen passieren im Backend
70 61
   
71 62
     $record['hostname'] = $_REQUEST['hostname'];
72 63
     $record['domain'] = (int) $_REQUEST['domain'];
73
-  $record['ip'] = (isset($_REQUEST['ip']) ? $_REQUEST['ip'] : NULL);
74
-  $record['data'] = (isset($_REQUEST['data']) ? $_REQUEST['data'] : NULL);
75
-  $record['dyndns'] = (isset($_REQUEST['dyndns']) ? (int) $_REQUEST['dyndns'] : NULL);
76
-  $record['spec'] = (isset($_REQUEST['spec']) ? (int) $_REQUEST['spec'] : NULL);
64
+    $record['ip'] = (isset($_REQUEST['ip']) ? $_REQUEST['ip'] : null);
65
+    $record['data'] = (isset($_REQUEST['data']) ? $_REQUEST['data'] : null);
66
+    $record['dyndns'] = (isset($_REQUEST['dyndns']) ? (int) $_REQUEST['dyndns'] : null);
67
+    $record['spec'] = (isset($_REQUEST['spec']) ? (int) $_REQUEST['spec'] : null);
77 68
     $record['ttl'] = (int) $_REQUEST['ttl'];
78 69
   
79 70
     save_dns_record($id, $record);
80 71
 
81
-  if (!$debugmode)
72
+    if (!$debugmode) {
82 73
         header('Location: dns_domain?dom='.$record['domain']);
83 74
     }
84
-
85
-
86
-
75
+}
... ...
@@ -27,52 +27,40 @@ require_once('dnsinclude.php');
27 27
 
28 28
 $section = 'dns_dns';
29 29
 
30
-if ($_GET['type'] == 'autodns')
31
-{
32
-  if ($_GET['action'] == 'enable')
33
-  {
30
+if ($_GET['type'] == 'autodns') {
31
+    if ($_GET['action'] == 'enable') {
34 32
         $dom = new Domain((int) $_GET['dom']);
35 33
         $dom->ensure_userdomain();
36 34
 
37 35
         $sure = user_is_sure();
38
-    if ($sure === NULL)
39
-    {
36
+        if ($sure === null) {
40 37
             are_you_sure("type=autodns&action=enable&dom={$dom->id}", "Möchten Sie die automatischen DNS-records für {$dom->fqdn} einschalten?");
41
-    }
42
-    elseif ($sure === true)
43
-    {
38
+        } elseif ($sure === true) {
44 39
             enable_autorecords($dom->id);
45
-      if (! $debugmode)
40
+            if (! $debugmode) {
46 41
                 header("Location: dns_domain?dom={$dom->id}");
47 42
             }
48
-    elseif ($sure === false)
49
-    {
50
-      if (! $debugmode)
43
+        } elseif ($sure === false) {
44
+            if (! $debugmode) {
51 45
                 header("Location: dns_domain?dom={$dom->id}");
52 46
             }
53 47
         }
54
-  elseif ($_GET['action'] == 'disable')
55
-  {
48
+    } elseif ($_GET['action'] == 'disable') {
56 49
         $dom = new Domain((int) $_GET['dom']);
57 50
         $dom->ensure_userdomain();
58 51
 
59 52
         $sure = user_is_sure();
60
-    if ($sure === NULL)
61
-    {
53
+        if ($sure === null) {
62 54
             are_you_sure("type=autodns&action=disable&dom={$dom->id}", "Möchten Sie die automatischen DNS-records für {$dom->fqdn} in manuelle Einträge umwandeln?");
63
-    }
64
-    elseif ($sure === true)
65
-    {
55
+        } elseif ($sure === true) {
66 56
             convert_from_autorecords($dom->id);
67
-      if (! $debugmode)
57
+            if (! $debugmode) {
68 58
                 header("Location: dns_domain?dom={$dom->id}");
69 59
             }
70
-    elseif ($sure === false)
71
-    {
72
-      if (! $debugmode)
60
+        } elseif ($sure === false) {
61
+            if (! $debugmode) {
73 62
                 header("Location: dns_domain?dom={$dom->id}");
74 63
             }
75 64
         }
76 65
     }
77
-
78
-
66
+}
... ...
@@ -31,25 +31,25 @@ output("<p>Hier sehen Sie eine Übersicht über die angelegten DynDNS-Accounts.<
31 31
 output('<table><tr><th>Kürzel</th><th>Methode</th><th>aktuelle IP</th><th>letztes Update</th><th>&#160;</th></tr>
32 32
 ');
33 33
 
34
-foreach ($dyndns AS $entry) {
34
+foreach ($dyndns as $entry) {
35 35
     $handle = $entry['handle'];
36
-  if (!$handle)
36
+    if (!$handle) {
37 37
         $handle = '<em>undefiniert</em>';
38
+    }
38 39
     $method = '';
39
-  if ($entry['sshkey'])
40
-    if ($entry['password'])
40
+    if ($entry['sshkey']) {
41
+        if ($entry['password']) {
41 42
             $method = 'SSH, HTTP';
42
-    else
43
+        } else {
43 44
             $method = 'SSH';
44
-  else
45
-    if ($entry['password'])
45
+        }
46
+    } elseif ($entry['password']) {
46 47
         $method = 'HTTP';
47
-    else
48
+    } else {
48 49
         $method = '<em>keine</em>';
50
+    }
49 51
     output("<tr><td>".internal_link('dyndns_edit', $handle, "id={$entry['id']}")."</td><td>{$method}</td><td>{$entry['address']}</td><td>{$entry['lastchange']}</td><td>".internal_link('save', icon_delete("Account löschen"), "id={$entry['id']}&type=dyndns&action=delete").' '.internal_link('dyndns_hostnames', other_icon("world_link.png", "Hostnames verwalten"), "id={$entry['id']}")."</td></tr>\n");
50 52
 }
51 53
 output('</table>');
52 54
 
53 55
 addnew('dyndns_edit', 'Neuen DynDNS-Account anlegen');
54
-
55
-?>
... ...
@@ -26,20 +26,21 @@ $section = 'dns_dyndns';
26 26
 
27 27
 $new = true;
28 28
 $dyndns = array();
29
-if (isset($_REQUEST['id']))
30
-{
29
+if (isset($_REQUEST['id'])) {
31 30
     $dyndns = get_dyndns_account($_REQUEST['id']);
32 31
     $new = false;
33 32
 }
34 33
 
35 34
 
36 35
 $username_http = $_SESSION['userinfo']['username'];
37
-if (isset($dyndns['handle']))
36
+if (isset($dyndns['handle'])) {
38 37
     $username_http .= "_{$dyndns['handle']}";
38
+}
39 39
 
40 40
 $http_update_info = '';
41
-if (isset($dyndns['password']))
41
+if (isset($dyndns['password'])) {
42 42
     $http_update_info = ' Lassen Sie das Passworteingabefeld unberührt um das bestehende Passwort zu erhalten. Entfernen Sie das bestehende Passwort um das HTTP-Update zu deaktivieren.';
43
+}
43 44
 
44 45
 
45 46
 $html_header .= '<script type="text/javascript">
... ...
@@ -63,11 +64,12 @@ document.getElementById("username_http").firstChild.data = http_username;
63 64
 title('DynDNS-Account');
64 65
 
65 66
 
66
-if (! $new ) 
67
+if (! $new) {
67 68
     $output .= '<div style="padding: 0.5em; border: 1px solid black;"><strong>aktuelle Daten:</strong><br />
68 69
   letztes Update: '.$dyndns['lastchange'].'<br />
69 70
   aktuelle Adresse: '.$dyndns['address'].'
70 71
   </div>';
72
+}
71 73
 
72 74
 $form = '<p><label for="handle">Bezeichnung:</label>&#160;<input type="text" name="handle" id="handle" value="'.(isset($dyndns['handle']) ? $dyndns['handle'] : '').'" onkeyup="updateUsernameHTTP()" /></p>
73 75
 
... ...
@@ -87,15 +89,14 @@ $form = '<p><label for="handle">Bezeichnung:</label>&#160;<input type="text" nam
87 89
 $output .= html_form('dyndns_edit', 'save', 'type=dyndns&action=edit&'.(isset($_REQUEST['id']) ? 'id='.$_REQUEST['id'] : ''), $form);
88 90
 
89 91
   
90
-if (! $new )
91
-{
92
+if (! $new) {
92 93
     $records = get_dyndns_records($_REQUEST['id']);
93 94
 
94 95
     $output .= '<h4>Folgende DNS-records sind mit diesem DynDNS-Account verknüpft:</h4>
95 96
   
96 97
   <ul>';
97 98
   
98
-  foreach ($records AS $record) {
99
+    foreach ($records as $record) {
99 100
         $output .= '<li>'.$record['fqdn'].' (Typ: '.strtoupper($record['type']).' / TTL: '.$record['ttl'].' Sek.)</li>';
100 101
     }
101 102
   
... ...
@@ -25,8 +25,9 @@ require_once('dnsinclude.php');
25 25
 
26 26
 $section = 'dns_dyndns';
27 27
 
28
-if (!isset($_REQUEST['id']))
28
+if (!isset($_REQUEST['id'])) {
29 29
     system_failure("Keine ID");
30
+}
30 31
 
31 32
 $id = (int) $_REQUEST['id'];
32 33
 $dyndns = get_dyndns_account($id);
... ...
@@ -43,10 +44,8 @@ $dyndns = get_dyndns_account($id);
43 44
   $record['dyndns'] = $id;
44 45
   $record['ttl'] = 120;
45 46
   
46
-  save_dns_record(NULL, $record);
47
+  save_dns_record(null, $record);
47 48
 
48
-  if (!$debugmode)
49
+  if (!$debugmode) {
49 50
       header('Location: dyndns_hostnames?id='.$dyndns['id']);
50
-
51
-
52
-
51
+  }
... ...
@@ -25,32 +25,29 @@ require_once('dnsinclude.php');
25 25
 
26 26
 $section = 'dns_dyndns';
27 27
 
28
-if (!isset($_REQUEST['id']))
28
+if (!isset($_REQUEST['id'])) {
29 29
     system_failure("Keine ID");
30
+}
30 31
 
31 32
 $id = (int) $_REQUEST['id'];
32 33
 $record = get_dns_record($id);
33 34
 $dyndns = get_dyndns_account($record['dyndns']);
34 35
 
35 36
 $sure = user_is_sure();
36
-if ($sure === NULL)
37
-{
37
+if ($sure === null) {
38 38
     $domain = new Domain((int) $record['domain']);
39 39
     $fqdn = $domain->fqdn;
40
-  if ($record['hostname'])
41
-  {
40
+    if ($record['hostname']) {
42 41
         $fqdn = $record['hostname'].'.'.$fqdn;
43 42
     }
44 43
     are_you_sure("action=delete&id={$id}", "Möchten Sie den Hostname ".$fqdn." für den DynDNS-Account {$dyndns['handle']} wirklich löschen?");
45
-  }
46
-  elseif ($sure === true)
47
-  {
44
+} elseif ($sure === true) {
48 45
       delete_dns_record($id);
49
-    if (! $debugmode)
46
+      if (! $debugmode) {
50 47
           header("Location: dyndns_hostnames?id=".$dyndns['id']);
51 48
       }
52
-  elseif ($sure === false)
53
-  {
54
-    if (! $debugmode)
49
+  } elseif ($sure === false) {
50
+      if (! $debugmode) {
55 51
           header("Location: dyndns_hostnames?id=".$dyndns['id']);
56 52
       }
53
+  }
... ...
@@ -43,7 +43,7 @@ if ($records) {
43 43
     $output .= '<h4>Folgende DNS-records sind mit diesem DynDNS-Account verknüpft:</h4>
44 44
 <ul>
45 45
 ';
46
-  foreach ($records AS $record) {
46
+    foreach ($records as $record) {
47 47
         $type = strtoupper($record['type']).' / '.($record['type'] == 'a' ? 'IPv4' : 'IPv6');
48 48
         $output .= '  <li>'.$record['fqdn'].' ('.$type.') '.internal_link('dyndns_hostname_delete', icon_delete(), 'id='.$record['id']).'</li>';
49 49
     }
... ...
@@ -43,7 +43,7 @@ function get_dyndns_account($id, $ignore=true)
43 43
     $result = db_query("SELECT * FROM dns.dyndns WHERE id=:id AND uid=:uid", $args);
44 44
     if ($result->rowCount() != 1) {
45 45
         if ($ignore) {
46
-      return NULL;
46
+            return null;
47 47
         }
48 48
         logger(LOG_WARNING, "modules/dns/include/dnsinclude", "dyndns", "account »{$id}« invalid for uid »{$_SESSION['userinfo']['uid']}«.");
49 49
         system_failure("Account ungültig");
... ...
@@ -58,24 +58,28 @@ function create_dyndns_account($handle, $password_http, $sshkey)
58 58
 {
59 59
     $uid = (int) $_SESSION['userinfo']['uid'];
60 60
 
61
-  if ($password_http == '' && $sshkey == '')
61
+    if ($password_http == '' && $sshkey == '') {
62 62
         system_failure('Sie müssen entweder einen SSH-Key oder ein Passwort zum Web-Update eingeben.');
63
+    }
63 64
 
64 65
     $handle = filter_input_username($handle);
65 66
 
66 67
     if (strlen(trim($sshkey)) == 0) {
67
-    $sshkey = NULL;
68
+        $sshkey = null;
68 69
     } else {
69 70
         $sshkey = filter_ssh_key($sshkey);
70 71
     }
71 72
 
72
-  $pwhash = NULL;
73
-  if ($password_http)
73
+    $pwhash = null;
74
+    if ($password_http) {
74 75
         $pwhash = "{SHA}".base64_encode(sha1($password_http, true));
76
+    }
75 77
 
76
-  db_query("INSERT INTO dns.dyndns (uid, handle, password, sshkey) VALUES ".
78
+    db_query(
79
+      "INSERT INTO dns.dyndns (uid, handle, password, sshkey) VALUES ".
77 80
            "(:uid, :handle, :pwhash, :sshkey)",
78
-           array(":uid" => $uid, ":handle" => $handle, ":pwhash" => $pwhash, ":sshkey" => $sshkey));
81
+           array(":uid" => $uid, ":handle" => $handle, ":pwhash" => $pwhash, ":sshkey" => $sshkey)
82
+  );
79 83
     $dyndns_id = db_insert_id();
80 84
     //$masterdomain = new Domain(config('masterdomain'));
81 85
     //db_query("INSERT INTO dns.custom_records (type, domain, hostname, dyndns, ttl) VALUES ".
... ...
@@ -93,20 +97,21 @@ function edit_dyndns_account($id, $handle, $password_http, $sshkey)
93 97
     $handle = filter_input_username($handle);
94 98
     $sshkey = filter_input_general($sshkey);
95 99
     if (chop($sshkey) == '') {
96
-    $sshkey = NULL;
100
+        $sshkey = null;
97 101
     }
98 102
 
99 103
     if ($oldaccount['handle'] != $handle) {
100 104
         $masterdomain = new Domain(config('masterdomain'));
101
-    db_query("UPDATE dns.custom_records SET hostname=:newhostname WHERE ".
105
+        db_query(
106
+        "UPDATE dns.custom_records SET hostname=:newhostname WHERE ".
102 107
              "hostname=:oldhostname AND domain=:dom AND dyndns=:dyndns AND ip IS NULL",
103 108
              array(":dom" => $masterdomain->id, ":newhostname" => filter_input_hostname($handle).'.'.$_SESSION['userinfo']['username'],
104
-                   ":oldhostname" => $oldaccount['handle'].'.'.$_SESSION['userinfo']['username'],  ":dyndns" => $id));
105
-
109
+                   ":oldhostname" => $oldaccount['handle'].'.'.$_SESSION['userinfo']['username'],  ":dyndns" => $id)
110
+    );
106 111
     }
107 112
 
108 113
     $args = array(":handle" => $handle, ":sshkey" => $sshkey, ":id" => $id);
109
-  $pwhash = NULL;
114
+    $pwhash = null;
110 115
     if ($password_http && $password_http != '************') {
111 116
         $args[":pwhash"] = "{SHA}".base64_encode(sha1($password_http, true));
112 117
         db_query("UPDATE dns.dyndns SET handle=:handle, password=:pwhash, sshkey=:sshkey WHERE id=:id", $args);
... ...
@@ -137,8 +142,9 @@ function get_dyndns_records($id)
137 142
             $dom->ensure_userdomain();
138 143
         }
139 144
         $entry['fqdn'] = $entry['hostname'].'.'.$dom->fqdn;
140
-    if (! $entry['hostname'])
145
+        if (! $entry['hostname']) {
141 146
             $entry['fqdn'] = $dom->fqdn;
147
+        }
142 148
         array_push($data, $entry);
143 149
     }
144 150
     DEBUG($data);
... ...
@@ -151,18 +157,18 @@ $valid_record_types = array('a', 'aaaa', 'mx', 'ns', 'spf', 'txt', 'cname', 'ptr
151 157
 function blank_dns_record($type)
152 158
 {
153 159
     global $valid_record_types;
154
-  if (!in_array(strtolower($type), $valid_record_types))
160
+    if (!in_array(strtolower($type), $valid_record_types)) {
155 161
         system_failure('invalid type: '.$type);
156
-  $rec = array('hostname' => NULL,
162
+    }
163
+    $rec = array('hostname' => null,
157 164
                'domain' => 0,
158 165
                'type' => strtolower($type),
159 166
                'ttl' => 3600,
160
-               'ip' => NULL,
161
-               'dyndns' => NULL,
162
-               'data' => NULL,
163
-               'spec' => NULL);
164
-  if (strtolower($type) == 'mx')
165
-  {
167
+               'ip' => null,
168
+               'dyndns' => null,
169
+               'data' => null,
170
+               'spec' => null);
171
+    if (strtolower($type) == 'mx') {
166 172
         $rec['data'] = config('default_mx');
167 173
         $rec['spec'] = '5';
168 174
     }
... ...
@@ -173,8 +179,9 @@ function get_dns_record($id)
173 179
 {
174 180
     $id = (int) $id;
175 181
     $result = db_query("SELECT hostname, domain, type, ip, dyndns, spec, data, ttl FROM dns.custom_records WHERE id=?", array($id));
176
-  if ($result->rowCount() != 1)
182
+    if ($result->rowCount() != 1) {
177 183
         system_failure('illegal ID');
184
+    }
178 185
     $data = $result->fetch();
179 186
     $dom = new Domain((int) $data['domain']);
180 187
     $dom->ensure_userdomain();
... ...
@@ -192,8 +199,9 @@ function get_domain_records($dom)
192 199
         $dom = new Domain((int) $entry['domain']);
193 200
         $dom->ensure_userdomain();
194 201
         $entry['fqdn'] = $entry['hostname'].'.'.$dom->fqdn;
195
-    if (! $entry['hostname'])
202
+        if (! $entry['hostname']) {
196 203
             $entry['fqdn'] = $dom->fqdn;
204
+        }
197 205
         array_push($data, $entry);
198 206
     }
199 207
     DEBUG($data);
... ...
@@ -219,97 +227,105 @@ function save_dns_record($id, $record)
219 227
     global $valid_record_types;
220 228
     global $implemented_record_types;
221 229
     $record['type'] = strtolower($record['type']);
222
-  if (!in_array($record['type'], $valid_record_types))
230
+    if (!in_array($record['type'], $valid_record_types)) {
223 231
         system_failure('invalid type: '.$record['type']);
224
-  if (!in_array($record['type'], $implemented_record_types))
232
+    }
233
+    if (!in_array($record['type'], $implemented_record_types)) {
225 234
         system_failure('record type '.$record['type'].' not implemented at the moment.');
235
+    }
226 236
     $dom = new Domain((int) $record['domain']);
227 237
     $dom->ensure_userdomain();
228
-  if (! $dom->id)
238
+    if (! $dom->id) {
229 239
         system_failure('invalid domain');
240
+    }
230 241
     if ($record['hostname'] == '') {
231
-    $record['hostname'] = NULL;
242
+        $record['hostname'] = null;
232 243
     }
233 244
     verify_input_hostname($record['hostname'], true);
234 245
     verify_input_recorddata($record['data']);
235
-  if ($record['ttl'] &&  (int) $record['ttl'] < 1)
246
+    if ($record['ttl'] &&  (int) $record['ttl'] < 1) {
236 247
         system_failure('Fehler bei TTL');
237
-  switch ($record['type']) 
238
-  {
248
+    }
249
+    switch ($record['type']) {
239 250
     case 'a':
240
-      if ($record['dyndns'])
241
-      {
251
+      if ($record['dyndns']) {
242 252
           get_dyndns_account($record['dyndns']);
243
-      	$record['ip'] = NULL;
244
-      }
245
-      else
246
-      {
253
+          $record['ip'] = null;
254
+      } else {
247 255
           verify_input_ipv4($record['ip']);
248
-        $record['data'] = NULL;
249
-        $record['spec'] = NULL;
256
+          $record['data'] = null;
257
+          $record['spec'] = null;
250 258
       }
251 259
       break;
252 260
     case 'aaaa':
253 261
       if ($record['dyndns']) {
254 262
           get_dyndns_account($record['dyndns']);
255
-          $record['ip'] = NULL;
263
+          $record['ip'] = null;
256 264
       } else {
257
-          $record['dyndns'] = NULL;
265
+          $record['dyndns'] = null;
258 266
           verify_input_ipv6($record['ip']);
259
-          $record['data'] = NULL;
260
-          $record['spec'] = NULL;
267
+          $record['data'] = null;
268
+          $record['spec'] = null;
261 269
       }
262 270
       break;
263 271
     case 'mx':
264
-      $record['dyndns'] = NULL;
272
+      $record['dyndns'] = null;
265 273
       $record['spec'] = (int) $record['spec'];
266
-      if ($record['spec'] < 1)
274
+      if ($record['spec'] < 1) {
267 275
           systen_failure("invalid priority");
276
+      }
268 277
       verify_input_hostname($record['data']);
269
-      if (! $record['data'] )
278
+      if (! $record['data']) {
270 279
           system_failure('MX hostname missing');
271
-      $record['ip'] = NULL;
280
+      }
281
+      $record['ip'] = null;
272 282
       break;
273 283
     case 'ptr':
274 284
     case 'ns':
275 285
       if (!$record['hostname']) {
276 286
           system_failure("Die angestrebte Konfiguration wird nicht funktionieren, Speichern wurde daher verweigert.");
277 287
       }
288
+      // no break
278 289
     case 'cname':
279
-      $record['dyndns'] = NULL;
280
-      $record['spec'] = NULL;
281
-      $record['ip'] = NULL;
290
+      $record['dyndns'] = null;
291
+      $record['spec'] = null;
292
+      $record['ip'] = null;
282 293
       verify_input_hostname($record['data']);
283
-      if (! $record['data'] )
294
+      if (! $record['data']) {
284 295
           system_failure('destination host missing');
296
+      }
285 297
       break;
286 298
 
287 299
     case 'spf':
288 300
     case 'txt':
289
-      $record['dyndns'] = NULL;
290
-      $record['spec'] = NULL;
291
-      $record['ip'] = NULL;
292
-      if (! $record['data'] )
301
+      $record['dyndns'] = null;
302
+      $record['spec'] = null;
303
+      $record['ip'] = null;
304
+      if (! $record['data']) {
293 305
           system_failure('text entry missing');
306
+      }
294 307
       break;
295 308
 
296 309
     case 'sshfp':
297
-      $record['dyndns'] = NULL;
310
+      $record['dyndns'] = null;
298 311
       $record['spec'] = max((int) $record['spec'], 1);
299
-      $record['ip'] = NULL;
300
-      if (! $record['data'] )
312
+      $record['ip'] = null;
313
+      if (! $record['data']) {
301 314
           system_failure('text entry missing');
315
+      }
302 316
       break;
303 317
 
304 318
     case 'caa':
305
-      $record['dyndns'] = NULL;
306
-      $record['ip'] = NULL;
307
-      if (! $record['data'] )
319
+      $record['dyndns'] = null;
320
+      $record['ip'] = null;
321
+      if (! $record['data']) {
308 322
           system_failure('text entry missing');
323
+      }
309 324
       break;
310 325
 
311 326
     case 'srv':
312 327
       system_failure('not implemented yet');
328
+      // no break
313 329
     default:
314 330
       system_failure('Not implemented');
315 331
   }
... ...
@@ -317,7 +333,7 @@ function save_dns_record($id, $record)
317 333
     $args = array(":domain" => $dom->id,
318 334
                 ":hostname" => $record['hostname'],
319 335
                 ":type" => $record['type'],
320
-                ":ttl" => ($record['ttl'] == 0 ? NULL : (int) $record['ttl']),
336
+                ":ttl" => ($record['ttl'] == 0 ? null : (int) $record['ttl']),
321 337
                 ":ip" => $record['ip'],
322 338
                 ":dyndns" => $record['dyndns'],
323 339
                 ":data" => $record['data'],
... ...
@@ -386,7 +401,8 @@ function domain_is_maildomain($domain)
386 401
 
387 402
 $own_ns = array();
388 403
 
389
-function own_ns() {
404
+function own_ns()
405
+{
390 406
     global $own_ns;
391 407
 
392 408
     if (count($own_ns) < 1) {
... ...
@@ -402,7 +418,8 @@ function own_ns() {
402 418
 
403 419
 $tld_ns = array();
404 420
 
405
-function check_dns($domainname, $tld) {
421
+function check_dns($domainname, $tld)
422
+{
406 423
     global $tld_ns;
407 424
     $domain=idn_to_ascii($domainname.".".$tld, 0, INTL_IDNA_VARIANT_UTS46);
408 425
 
... ...
@@ -423,14 +440,15 @@ function check_dns($domainname, $tld) {
423 440
     $own_ns = own_ns();
424 441
 
425 442
     if (in_array($NS, $own_ns)) {
426
-    return True;
443
+        return true;
427 444
     }
428 445
     return $NS;
429 446
 }
430 447
 
431
-function remove_from_dns($dom) {
448
+function remove_from_dns($dom)
449
+{
432 450
     $domains = get_domain_list($_SESSION['customerinfo']['customerno'], $_SESSION['userinfo']['uid']);
433
-  $current = NULL;
451
+    $current = null;
434 452
     foreach ($domains as $d) {
435 453
         if ($d->id == $dom && $d->dns == 1) {
436 454
             $current = $d;
... ...
@@ -443,9 +461,10 @@ function remove_from_dns($dom) {
443 461
     db_query("UPDATE kundendaten.domains SET dns=0 WHERE id=?", array($current->id));
444 462
 }
445 463
 
446
-function add_to_dns($dom) {
464
+function add_to_dns($dom)
465
+{
447 466
     $domains = get_domain_list($_SESSION['customerinfo']['customerno'], $_SESSION['userinfo']['uid']);
448
-  $current = NULL;
467
+    $current = null;
449 468
     foreach ($domains as $d) {
450 469
         if ($d->id == $dom && $d->dns == 0) {
451 470
             $current = $d;
... ...
@@ -17,10 +17,7 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
17 17
 $role = $_SESSION['role'];
18 18
 
19 19
 
20
-if ($role & ROLE_SYSTEMUSER)
21
-{
20
+if ($role & ROLE_SYSTEMUSER) {
22 21
     $menu["dns_dns"] = array("label" => "DNS-Einträge", "file" => "dns", "weight" => 10, "submenu" => "domains_domains");
23 22
     $menu["dns_dyndns"] = array("label" => "DynDNS", "file" => "dyndns", "weight" => 11, "submenu" => "domains_domains");
24 23
 }
25
-
26
-?>
... ...
@@ -25,34 +25,32 @@ require_once('dnsinclude.php');
25 25
 
26 26
 $section = 'dns_dyndns';
27 27
 
28
-$id = NULL;
29
-if (isset($_REQUEST['id']))
28
+$id = null;
29
+if (isset($_REQUEST['id'])) {
30 30
     $id = (int) $_REQUEST['id'];
31
+}
31 32
 
32 33
 
33 34
 if (isset($_GET['type']) && $_GET['type'] == 'dyndns') {
34 35
     if ($_GET['action'] == 'delete') {
35 36
         $sure = user_is_sure();
36
-    if ($sure === NULL)
37
-    {
37
+        if ($sure === null) {
38 38
             are_you_sure("type=dyndns&action=delete&id={$id}", "Möchten Sie den DynDNS-Account wirklich löschen?");
39
-    }
40
-    elseif ($sure === true)
41
-    {
39
+        } elseif ($sure === true) {
42 40
             delete_dyndns_account($id);
43
-      if (! $debugmode)
41
+            if (! $debugmode) {
44 42
                 header("Location: dyndns");
45 43
             }
46
-    elseif ($sure === false)
47
-    {
48
-      if (! $debugmode)
44
+        } elseif ($sure === false) {
45
+            if (! $debugmode) {
49 46
                 header("Location: dyndns");
50 47
             }
51 48
         }
49
+    }
52 50
     if ($_GET['action'] == 'edit') {
53 51
         check_form_token('dyndns_edit');
54 52
       
55
-    $newid = NULL;
53
+        $newid = null;
56 54
         if ($id) {
57 55
             edit_dyndns_account($id, $_POST['handle'], $_POST['password_http'], $_POST['sshkey']);
58 56
         } else {
... ...
@@ -75,7 +73,7 @@ if (isset($_GET['type']) && $_GET['type'] == 'dyndns') {
75 73
 if (isset($_GET['dns']) && isset($_GET['dom'])) {
76 74
     $section = 'dns_dns';
77 75
     $domains = get_domain_list($_SESSION['customerinfo']['customerno'], $_SESSION['userinfo']['uid']);
78
-  $dom = NULL;
76
+    $dom = null;
79 77
     foreach ($domains as $d) {
80 78
         if ($d->id == $_GET['dom']) {
81 79
             $dom = $d;
... ...
@@ -88,17 +86,12 @@ if (isset($_GET['dns']) && isset($_GET['dom'])) {
88 86
     if ($_GET['dns'] == 0) {
89 87
         if ($dom->dns == 1) {
90 88
             $sure = user_is_sure();
91
-      if ($sure === NULL)
92
-      {
89
+            if ($sure === null) {
93 90
                 are_you_sure("dom={$dom->id}&dns=0", "Möchten Sie die Domain {$dom->fqdn} aus dem DNS-Server entfernen?");
94
-      }
95
-      elseif ($sure === true)
96
-      {
91
+            } elseif ($sure === true) {
97 92
                 remove_from_dns($dom->id);
98 93
                 redirect('dns');
99
-      }
100
-      elseif ($sure === false)
101
-      {
94
+            } elseif ($sure === false) {
102 95
                 redirect('dns');
103 96
             }
104 97
         } else {
... ...
@@ -22,7 +22,7 @@ require_once('domains.php');
22 22
 
23 23
 require_role(array(ROLE_CUSTOMER, ROLE_SYSTEMUSER));
24 24
 
25
-$dom = NULL;
25
+$dom = null;
26 26
 if (isset($_REQUEST['id'])) {
27 27
     $dom = new Domain((int) $_REQUEST['id']);
28 28
     $_SESSION['domains_detail_domainname'] = $dom->fqdn;
... ...
@@ -121,7 +121,7 @@ if ($is_current_user) {
121 121
 
122 122
 // Block Domain-Inhaber
123 123
 
124
-if (have_role(ROLE_CUSTOMER) && config('http.net-apikey') && $dom->provider == 'terions' && ($dom->cancel_date === NULL || $dom->cancel_date > date('Y-m-d'))) {
124
+if (have_role(ROLE_CUSTOMER) && config('http.net-apikey') && $dom->provider == 'terions' && ($dom->cancel_date === null || $dom->cancel_date > date('Y-m-d'))) {
125 125
     use_module('contacts');
126 126
     require_once('contacts.php');
127 127
     require_once('domainapi.php');
... ...
@@ -28,7 +28,7 @@ if (! config('http.net-apikey')) {
28 28
     system_failure("Dieses System ist nicht eingerichtet zum Hinzufügen von Domains");
29 29
 }
30 30
 
31
-$dom = NULL;
31
+$dom = null;
32 32
 if (isset($_REQUEST['domain'])) {
33 33
     $request = idn_to_utf8($_REQUEST['domain'], 0, INTL_IDNA_VARIANT_UTS46);
34 34
     if (substr($request, 0, 4) == 'www.') {
... ...
@@ -86,7 +85,7 @@ if (!$pricedata) {
86 85
     warning('Die Domain '.$dom->fqdn.' kann nicht über dieses Webinterface umgezogen werden weil bei dieser Endung Besonderheiten zu beachten sind. Bitte kontaktieren Sie den Support.');
87 86
     redirect('domains');
88 87
 }
89
-$mode=NULL;
88
+$mode=null;
90 89
 
91 90
 if ($avail['status'] == 'available') {
92 91
     set_domain_prereg($dom->id);
... ...
@@ -109,7 +108,7 @@ $section='domains_domains';
109 108
 output('<h4>Inhaber der Domain</h4>');
110 109
 output('<p>Legen Sie hier einen neuen Inhaber für diese Domain fest.</p>');
111 110
 
112
-if ($_SESSION['domains_domainreg_owner'] === NULL) {
111
+if ($_SESSION['domains_domainreg_owner'] === null) {
113 112
     $kundenkontakte = get_kundenkontakte();
114 113
     $customer = get_contact($kundenkontakte['kunde']);
115 114
     if (possible_domainholder($customer)) {
... ...
@@ -37,7 +37,7 @@ $dom->ensure_userdomain();
37 37
 // Speichere Kontakte
38 38
 domain_ownerchange($dom->fqdn, $_SESSION['domains_domainreg_owner'], $_SESSION['domains_domainreg_admin_c']);
39 39
 
40
-$authinfo = NULL;
40
+$authinfo = null;
41 41
 if ($dom->status == 'pretransfer') {
42 42
     if (! (isset($_REQUEST['authinfo']) && $_REQUEST['authinfo'])) {
43 43
         system_failure("Kein Auth-Info-Code angegeben!");
... ...
@@ -23,10 +23,11 @@ require_once('domains.php');
23 23
 
24 24
 require_role(array(ROLE_SYSTEMUSER, ROLE_CUSTOMER));
25 25
 
26
-if (have_role(ROLE_CUSTOMER))
26
+if (have_role(ROLE_CUSTOMER)) {
27 27
     $user_domains = get_domain_list($_SESSION['customerinfo']['customerno']);
28
-else
28
+} else {
29 29
     $user_domains = get_domain_list($_SESSION['userinfo']['customerno'], $_SESSION['userinfo']['uid']);
30
+}
30 31
 
31 32
 // Session-Variablen aufräumen
32 33
 unset($_SESSION['domains_detail_domainname']);
... ...
@@ -43,8 +44,7 @@ title("Domains");
43 44
 output('<p>In Ihrem Account werden die folgenden Domains verwaltet:</p>');
44 45
 
45 46
 output('<div class="domain-list">');
46
-foreach ($user_domains as $domain)
47
-{
47
+foreach ($user_domains as $domain) {
48 48
     $status = 'regular';
49 49
     $locked = '';
50 50
     $mailserver_lock = '';
... ...
@@ -65,7 +65,7 @@ foreach ($user_domains as $domain)
65 65
     } elseif ($domain->provider != 'terions') {
66 66
         $status = 'external';
67 67
         $regdate = '<em>Extern registriert</em>';
68
-  } elseif ($domain->reg_date == NULL) {
68
+    } elseif ($domain->reg_date == null) {
69 69
         $status = 'pretransfer';
70 70
         $regdate = '<em>Umzug bevorstehend</em>';
71 71
     } else {
... ...
@@ -82,24 +82,30 @@ foreach ($user_domains as $domain)
82 82
 
83 83
     $features = array();
84 84
     if ($domain->dns == 1) {
85
-    if (dns_in_use($domain->id))
85
+        if (dns_in_use($domain->id)) {
86 86
             $features[] = 'DNS';
87
+        }
87 88
         //if ($domain->autodns == 1)
88 89
     //  $features[] = 'AutoDNS';
89 90
     }
90 91
     $mailman = mailman_subdomains($domain->id);
91
-  if (mail_in_use($domain->id))
92
+    if (mail_in_use($domain->id)) {
92 93
         $features[] = 'Mail';
93
-  if ($mailman)
94
+    }
95
+    if ($mailman) {
94 96
         $features[] = 'Mailinglisten';
95
-  if (web_in_use($domain->id))
97
+    }
98
+    if (web_in_use($domain->id)) {
96 99
         $features[] = 'Web';
97
-  if ($domain->jabber == 1)
100
+    }
101
+    if ($domain->jabber == 1) {
98 102
         $features[] = 'Jabber';
103
+    }
99 104
 
100 105
     $features = implode(', ', $features);
101
-  if (! $features)
106
+    if (! $features) {
102 107
         $features = '<em>unbenutzt</em>';
108
+    }
103 109
     $punycode = $domain->punycode;
104 110
     if ($domain->is_idn) {
105 111
         $punycode = "<br/><span class=\"punycode\">($punycode)</span>";
... ...
@@ -118,6 +124,3 @@ output("<br />");
118 124
 if (have_role(ROLE_CUSTOMER) && config('http.net-apikey')) {
119 125
     addnew('adddomain', 'Neue Domain bestellen oder externe Domain hinzufügen');
120 126
 }
121
-
122
-
123
-?>
... ...
@@ -22,7 +22,8 @@ require_once('contactapi.php');
22 22
 
23 23
 
24 24
 
25
-function api_download_domain($id) {
25
+function api_download_domain($id)
26
+{
26 27
     $result = db_query("SELECT id, CONCAT_WS('.', domainname, tld) AS fqdn, owner, admin_c, registrierungsdatum, kuendigungsdatum FROM kundendaten.domains WHERE id=?", array($id));
27 28
     if ($result->rowCount() < 1) {
28 29
         system_failure('Domain nicht gefunden');
... ...
@@ -35,8 +36,8 @@ function api_download_domain($id) {
35 36
         system_failure("Abfrage nicht erfolgreich!");
36 37
     }
37 38
     $apidomain = $result['response'];
38
-    $apiowner = NULL;
39
-    $apiadmin_c = NULL;
39
+    $apiowner = null;
40
+    $apiadmin_c = null;
40 41
     foreach ($apidomain['contacts'] as $ac) {
41 42
         if ($ac['type'] == 'owner') {
42 43
             $apiowner = $ac['contact'];
... ...
@@ -107,7 +108,7 @@ function api_upload_domain($fqdn)
107 108
 }
108 109
 
109 110
 
110
-function api_register_domain($domainname, $authinfo=NULL) 
111
+function api_register_domain($domainname, $authinfo=null)
111 112
 {
112 113
     $result = db_query("SELECT id,status,CONCAT_WS('.', domainname, tld) AS fqdn, owner, admin_c FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld)=?", array($domainname));
113 114
     if ($result->rowCount() < 1) {
... ...
@@ -148,7 +149,7 @@ function api_register_domain($domainname, $authinfo=NULL)
148 149
             $newdomain['contacts'][$key]['contact'] = $admin_c;
149 150
         }
150 151
     }
151
-    $result = NULL;
152
+    $result = null;
152 153
     if ($dom['status'] == 'prereg') {
153 154
         $args = array("domain" => $newdomain);
154 155
         logger(LOG_WARNING, "modules/domains/include/domainapi", "domains", "register new domain »{$newdomain['name']}«");
... ...
@@ -19,15 +19,13 @@ require_once('inc/debug.php');
19 19
 
20 20
 function mailman_subdomains($domain)
21 21
 {
22
-  if ( ! in_array('mailman', config('modules')))
23
-  {
22
+    if (! in_array('mailman', config('modules'))) {
24 23
         return array();
25 24
     }
26 25
     $domain = (int) $domain;
27 26
     $result = db_query("SELECT id, hostname FROM mail.mailman_domains WHERE domain=?", array($domain));
28 27
     $ret = array();
29
-  while ($line = $result->fetch())
30
-  {
28
+    while ($line = $result->fetch()) {
31 29
         $ret[] = $line;
32 30
     }
33 31
     return $ret;
... ...
@@ -35,8 +33,9 @@ function mailman_subdomains($domain)
35 33
 
36 34
 function dns_in_use($domain)
37 35
 {
38
-  if ( ! in_array('dns', config('modules')))
36
+    if (! in_array('dns', config('modules'))) {
39 37
         return false;
38
+    }
40 39
     $domain = (int) $domain;
41 40
     $result = db_query("SELECT id FROM dns.custom_records WHERE domain=?", array($domain));
42 41
     return ($result->rowCount() > 0);
... ...
@@ -45,25 +44,28 @@ function dns_in_use($domain)
45 44
 
46 45
 function mail_in_use($domain)
47 46
 {
48
-  if ( ! in_array('email', config('modules')))
49
-  {
47
+    if (! in_array('email', config('modules'))) {
50 48
         return false;
51 49
     }
52 50
     $domain = (int) $domain;
53 51
     $result = db_query("SELECT mail FROM kundendaten.domains WHERE id=?", array($domain));
54
-  if ($result->rowCount() < 1)
52
+    if ($result->rowCount() < 1) {
55 53
         system_failure("Domain not found");
54
+    }
56 55
     $d = $result->fetch();
57
-  if ($d['mail'] == 'none')
58
-    return false; // manually disabled
56
+    if ($d['mail'] == 'none') {
57
+        return false;
58
+    } // manually disabled
59 59
     $result = db_query("SELECT id FROM mail.virtual_mail_domains WHERE domain=?", array($domain));
60
-  if ($result->rowCount() < 1)
61
-    return true; // .courier
60
+    if ($result->rowCount() < 1) {
61
+        return true;
62
+    } // .courier
62 63
     $result = db_query("SELECT acc.id FROM mail.vmail_accounts acc LEFT JOIN mail.virtual_mail_domains dom ON (acc.domain=dom.id) WHERE dom.domain=?", array($domain));
63 64
     return ($result->rowCount() > 0);
64 65
 }
65 66
 
66
-function count_vmail($domain) {
67
+function count_vmail($domain)
68
+{
67 69
     $domain = (int) $domain;
68 70
     $result = db_query("SELECT acc.id FROM mail.vmail_accounts acc LEFT JOIN mail.virtual_mail_domains dom ON (acc.domain=dom.id) WHERE dom.domain=?", array($domain));
69 71
     return $result->rowCount();
... ...
@@ -71,14 +73,16 @@ function count_vmail($domain) {
71 73
 
72 74
 function web_in_use($domain)
73 75
 {
74
-  if ( ! in_array('vhosts', config('modules')))
76
+    if (! in_array('vhosts', config('modules'))) {
75 77
         return false;
78
+    }
76 79
 
77 80
     $domain = (int) $domain;
78 81
 
79 82
     $result = db_query("SELECT id FROM kundendaten.domains WHERE id=? AND webserver=1", array($domain));
80
-  if ($result->rowCount() < 1)
83
+    if ($result->rowCount() < 1) {
81 84
         return false;
85
+    }
82 86
 
83 87
     $result = db_query("SELECT id FROM vhosts.vhost WHERE domain=?", array($domain));
84 88
     $result2 = db_query("SELECT id FROM vhosts.alias WHERE domain=?", array($domain));
... ...
@@ -98,7 +102,8 @@ function domain_ownerchange($fqdn, $owner, $admin_c)
98 102
 }
99 103
 
100 104
 
101
-function update_possible($domain) {
105
+function update_possible($domain)
106
+{
102 107
     $dom = new Domain((int) $domain);
103 108
     if ($dom->provider != 'terions' || $dom->billing=='external') {
104 109
         // Domain nicht über uns verwaltet
... ...
@@ -112,7 +117,7 @@ function update_possible($domain) {
112 117
         return false;
113 118
     }
114 119
     $data = $result->fetch();
115
-    if ($data['aenderung_eigentuemer'] != NULL || $data['ruecksprache'] == 'Y') {
120
+    if ($data['aenderung_eigentuemer'] != null || $data['ruecksprache'] == 'Y') {
116 121
         DEBUG("Endung hat Eigenheiten (ruecksprache=Y)");
117 122
         // Endung mit speziellen Eigenheiten
118 123
         return false;
... ...
@@ -121,12 +126,14 @@ function update_possible($domain) {
121 126
     return true;
122 127
 }
123 128
 
124
-function unset_mailserver_lock($dom) {
129
+function unset_mailserver_lock($dom)
130
+{
125 131
     $id = $dom->id;
126 132
     db_query("UPDATE kundendaten.domains SET secret=NULL, mailserver_lock=0 WHERE id=?", array($id));
127 133
 }
128 134
 
129
-function create_domain_secret($dom) {
135
+function create_domain_secret($dom)
136
+{
130 137
     $id = $dom->id;
131 138
     $secret = md5(random_string(20));
132 139
     db_query("UPDATE kundendaten.domains SET secret=? WHERE id=?", array($secret, $id));
... ...
@@ -135,7 +142,8 @@ function create_domain_secret($dom) {
135 142
 }
136 143
 
137 144
 
138
-function get_auth_dns($domainname, $tld) {
145
+function get_auth_dns($domainname, $tld)
146
+{
139 147
     $domain=idn_to_ascii($domainname.".".$tld, 0, INTL_IDNA_VARIANT_UTS46);
140 148
 
141 149
     $resp = shell_exec('dig @a.root-servers.net. +noall +authority -t ns '.$tld.'.');
... ...
@@ -145,9 +153,9 @@ function get_auth_dns($domainname, $tld) {
145 153
     $resp = shell_exec('dig @'.$NS.' -t ns '.$domain.'.');
146 154
     $lines = explode("\n", $resp);
147 155
   
148
-  $NS = NULL;
149
-  $NS_IP = NULL;
150
-  $sec = NULL;
156
+    $NS = null;
157
+    $NS_IP = null;
158
+    $sec = null;
151 159
     foreach ($lines as $l) {
152 160
         if (preg_match("/;; AUTHORITY SECTION:.*/", $l)) {
153 161
             $sec = 'auth';
... ...
@@ -165,7 +173,8 @@ function get_auth_dns($domainname, $tld) {
165 173
 }
166 174
 
167 175
 
168
-function own_ns() {
176
+function own_ns()
177
+{
169 178
     $auth = dns_get_record(config('masterdomain'), DNS_NS);
170 179
     $own_ns = array();
171 180
     foreach ($auth as $ns) {
... ...
@@ -181,7 +190,7 @@ function own_ns() {
181 190
 function has_own_ns($domainname, $tld)
182 191
 {
183 192
     $nsdata = get_auth_dns($domainname, $tld);
184
-  $NS = NULL;
193
+    $NS = null;
185 194
     foreach ($nsdata as $host => $ip) {
186 195
         $NS=$host;
187 196
     }
... ...
@@ -193,10 +202,11 @@ function has_own_ns($domainname, $tld)
193 202
 }
194 203
 
195 204
 
196
-function get_txt_record($hostname, $domainname, $tld) {
205
+function get_txt_record($hostname, $domainname, $tld)
206
+{
197 207
     $domain=idn_to_ascii($domainname.".".$tld, 0, INTL_IDNA_VARIANT_UTS46);
198 208
     $nsdata = get_auth_dns($domainname, $tld);
199
-  $NS = NULL;
209
+    $NS = null;
200 210
     foreach ($nsdata as $host => $ip) {
201 211
         $NS = $host;
202 212
         if ($ip) {
... ...
@@ -216,8 +226,7 @@ function list_useraccounts()
216 226
     $customerno = (int) $_SESSION['customerinfo']['customerno'];
217 227
     $result = db_query("SELECT uid,username,name FROM system.useraccounts WHERE kunde=?", array($customerno));
218 228
     $ret = array();
219
-  while ($item = $result->fetch())
220
-  {
229
+    while ($item = $result->fetch()) {
221 230
         $ret[] = $item;
222 231
     }
223 232
     DEBUG($ret);
... ...
@@ -229,7 +238,7 @@ function change_user($domain, $uid)
229 238
 {
230 239
     $domain = new Domain($domain);
231 240
     $domain->ensure_customerdomain();
232
-    $targetuser = NULL;
241
+    $targetuser = null;
233 242
     $useraccounts = list_useraccounts();
234 243
     foreach ($useraccounts as $u) {
235 244
         if ($u['uid'] == $uid) {
... ...
@@ -271,8 +280,10 @@ function set_domain_pretransfer($domain)
271 280
     $cid = (int) $_SESSION['customerinfo']['customerno'];
272 281
     $uid = (int) $_SESSION['userinfo']['uid'];
273 282
     $domain = (int) $domain;
274
-    db_query("UPDATE kundendaten.domains SET status='pretransfer', dns=1 WHERE id=? AND kunde=?", 
275
-            array($domain, $cid));
283
+    db_query(
284
+        "UPDATE kundendaten.domains SET status='pretransfer', dns=1 WHERE id=? AND kunde=?",
285
+            array($domain, $cid)
286
+    );
276 287
 }
277 288
 
278 289
 
... ...
@@ -282,8 +293,10 @@ function set_domain_prereg($domain)
282 293
     $cid = (int) $_SESSION['customerinfo']['customerno'];
283 294
     $uid = (int) $_SESSION['userinfo']['uid'];
284 295
     $domain = (int) $domain;
285
-    db_query("UPDATE kundendaten.domains SET status='prereg', dns=1 WHERE id=? AND kunde=?", 
286
-            array($domain, $cid));
296
+    db_query(
297
+        "UPDATE kundendaten.domains SET status='prereg', dns=1 WHERE id=? AND kunde=?",
298
+            array($domain, $cid)
299
+    );
287 300
 }
288 301
 
289 302
 
... ...
@@ -17,9 +17,6 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
17 17
 $role = $_SESSION['role'];
18 18
 
19 19
 
20
-if (($role & ROLE_CUSTOMER) || ($role & ROLE_SYSTEMUSER))
21
-{
20
+if (($role & ROLE_CUSTOMER) || ($role & ROLE_SYSTEMUSER)) {
22 21
     $menu["domains_domains"] = array("label" => "Domains", "file" => "domains", "weight" => 1);
23 22
 }
24
-
25
-?>
... ...
@@ -28,7 +28,7 @@ if ($_REQUEST['action'] == 'delete') {
28 28
         system_failure("Diese Domain ist noch in Benutzung. Bitte Postfächer und Websites löschen sowie Eintragungen in Mailinglisten oder Jabber-Server löschen lassen.");
29 29
     }
30 30
     $sure = user_is_sure();
31
-    if ($sure === NULL) {
31
+    if ($sure === null) {
32 32
         are_you_sure("action=delete&domain={$dom->id}", "Möchten Sie die Domain »{$dom->fqdn}« wirklich löschen?");
33 33
     } elseif ($sure === true) {
34 34
         delete_domain($dom->id);
... ...
@@ -39,7 +39,7 @@ if ($_REQUEST['action'] == 'delete') {
39 39
 } elseif ($_REQUEST['action'] == 'cancel') {
40 40
     $info = api_download_domain($dom->id);
41 41
     $sure = user_is_sure();
42
-    if ($sure === NULL) {
42
+    if ($sure === null) {
43 43
         are_you_sure("action=cancel&domain={$dom->id}", "Möchten Sie die Domain »{$dom->fqdn}« wirklich kündigen?<br>Das Kündigungsdatum wäre dann {$info['currentContractPeriodEnd']}");
44 44
     } elseif ($sure === true) {
45 45
         api_cancel_domain($dom->fqdn);
... ...
@@ -26,39 +26,36 @@ title("Passwort ändern");
26 26
 
27 27
 
28 28
 
29
-if (isset($_POST['password1']) && $_POST['password1'] != '')
30
-{
29
+if (isset($_POST['password1']) && $_POST['password1'] != '') {
31 30
     $accname = $_SESSION['mailaccount'];
32 31
     check_form_token('email_chpass');
33 32
     $result = find_role($accname, $_POST['old_password']);
34 33
 
35
-  if ($_POST['old_password'] == '')
34
+    if ($_POST['old_password'] == '') {
36 35
         input_error('Altes Passwort nicht angegeben!');
37
-  elseif (! $result & ROLE_VMAIL_ACCOUNT)
36
+    } elseif (! $result & ROLE_VMAIL_ACCOUNT) {
38 37
         input_error('Das bisherige Passwort ist nicht korrekt!');
39
-  elseif ($_POST['password2'] != $_POST['password1'])
38
+    } elseif ($_POST['password2'] != $_POST['password1']) {
40 39
         input_error('Die Bestätigung ist nicht identisch mit dem neuen Passwort!');
41
-  elseif ($_POST['password2'] == '')
40
+    } elseif ($_POST['password2'] == '') {
42 41
         input_error('Sie müssen das neue Passwort zweimal eingeben!');
43
-  elseif (($check = strong_password($_POST['password1'])) !== true)
42
+    } elseif (($check = strong_password($_POST['password1'])) !== true) {
44 43
         input_error("Das Passwort ist zu einfach ({$check})!");
45
-  else {
46
-    if ($role & ROLE_VMAIL_ACCOUNT)
47
-    {
44
+    } else {
45
+        if ($role & ROLE_VMAIL_ACCOUNT) {
48 46
             DEBUG("Ändere VMail-Passwort");
49 47
             change_vmail_password($accname, $_POST['password1']);
50
-    }
51
-    elseif ($role & ROLE_MAILACCOUNT)
52
-    {
48
+        } elseif ($role & ROLE_MAILACCOUNT) {
53 49
             DEBUG("Ändere IMAP-Passwort");
54 50
             change_mailaccount(get_mailaccount_id($accname), array('password' => $_POST['password1']));
55 51
         }
56
-    if (! $debugmode)
52
+        if (! $debugmode) {
57 53
             header('Location: /');
58
-    else
54
+        } else {
59 55
             output('');
60 56
         }
61 57
     }
58
+}
62 59
 
63 60
 
64 61
 
... ...
@@ -45,7 +45,7 @@ beachtet. Subdomains können grundsätzlich nur durch Administratoren eingericht
45 45
 ');
46 46
 
47 47
 $odd = true;
48
-foreach ($domains AS $id => $dom) {
48
+foreach ($domains as $id => $dom) {
49 49
     $odd = !$odd;
50 50
     $trextra = ($odd ? ' class="odd"' : ' class="even"');
51 51
     $edit_disabled = false;
... ...
@@ -77,7 +77,7 @@ foreach ($domains AS $id => $dom) {
77 77
       </span>';
78 78
     output("<tr{$trextra}><td>{$dom['name']}</td><td>".html_form('vmail_domainchange', 'domainchange', '', $buttons)."</td><td>{$notice}</td></tr>\n");
79 79
     if (array_key_exists($id, $subdomains)) {
80
-    foreach ($subdomains[$id] AS $subdom) {
80
+        foreach ($subdomains[$id] as $subdom) {
81 81
             $odd = !$odd;
82 82
             $trextra = ($odd ? ' class="odd"' : ' class="even"');
83 83
             $edit_disabled = true;
... ...
@@ -101,7 +101,3 @@ output('</table>
101 101
 
102 102
 output('<p><strong>Sicherheitshinweis:</strong> Während der Umstellung der Empfangsart ist Ihre Domain eventuell für einige Minuten in einem undefinierten Zustand. In dieser Zeit kann es passieren, dass E-Mails nicht korrekt zugestellt oder sogar ganz zurückgewiesen werden. Sie sollten diese Einstellungen daher nicht mehr ändern, wenn die Domain aktiv für den E-Mail-Verkehr benutzt wird.</p>
103 103
 ');
104
-
105
-
106
-
107
-?>
... ...
@@ -29,8 +29,9 @@ require_role(array(ROLE_SYSTEMUSER, ROLE_VMAIL_ACCOUNT));
29 29
 $account = empty_account();
30 30
 $id = (isset($_GET['id']) ? (int) $_GET['id'] : 0);
31 31
 
32
-if ($id != 0)
32
+if ($id != 0) {
33 33
     $account = get_account_details($id);
34
+}
34 35
 
35 36
 $accountlogin = false;
36 37
 if ($_SESSION['role'] == ROLE_VMAIL_ACCOUNT) {
... ...
@@ -45,8 +46,7 @@ if ($_SESSION['role'] == ROLE_VMAIL_ACCOUNT) {
45 46
 DEBUG($account);
46 47
 if ($id == 0) {
47 48
     title("E-Mail-Adresse anlegen");
48
-}
49
-else {
49
+} else {
50 50
     if ($accountlogin) {
51 51
         title("Einstellungen für {$accountname}");
52 52
     } else {
... ...
@@ -55,9 +55,9 @@ else {
55 55
 }
56 56
 
57 57
 
58
-$is_autoresponder = is_array($account['autoresponder']) && $account['autoresponder']['valid_from'] != NULL && ($account['autoresponder']['valid_until'] > date('Y-m-d') || $account['autoresponder']['valid_until'] == NULL);
58
+$is_autoresponder = is_array($account['autoresponder']) && $account['autoresponder']['valid_from'] != null && ($account['autoresponder']['valid_until'] > date('Y-m-d') || $account['autoresponder']['valid_until'] == null);
59 59
 $is_forward = (count($account['forwards']) > 0);
60
-$is_mailbox = ($account['password'] != NULL  ||  $id == 0);
60
+$is_mailbox = ($account['password'] != null  ||  $id == 0);
61 61
 $numforwards = max(count($account['forwards']), 1);
62 62
 
63 63
 $form = '';
... ...
@@ -65,7 +65,7 @@ $form = '';
65 65
 if (! $accountlogin) {
66 66
     if ($id != 0) {
67 67
         $domainlist = get_vmail_domains();
68
-    $domain = NULL;
68
+        $domain = null;
69 69
         foreach ($domainlist as $dom) {
70 70
             if ($dom['id'] == $account['domain']) {
71 71
                 $domain = $dom['domainname'];
... ...
@@ -74,7 +74,7 @@ if (! $accountlogin) {
74 74
         $form .= "
75 75
     <p><strong style=\"font-size: 1.5em;\">{$account['local']}@{$domain}</strong></p>";
76 76
     } else {
77
-    $domain = NULL;
77
+        $domain = null;
78 78
         if (isset($_GET['domain'])) {
79 79
             $domain = (int) $_GET['domain'];
80 80
         }
... ...
@@ -83,8 +83,7 @@ if (! $accountlogin) {
83 83
     }
84 84
     $password_message = '';
85 85
     $password_value = '';
86
-  if ($is_mailbox and ($account['password'] != ''))
87
-  {
86
+    if ($is_mailbox and ($account['password'] != '')) {
88 87
         $password_message = '<span style="font-size: 80%"><br /><em>Sie haben bereits ein Passwort gesetzt. Wenn Sie dieses Feld nicht ändern, wird das bisherige Passwort beibehalten.</em></span>';
89 88
         $password_value = '**********';
90 89
     }
... ...
@@ -118,12 +117,12 @@ if (! $ar) {
118 117
     $ar = empty_autoresponder_config();
119 118
 }
120 119
 
121
-if ($ar['valid_until'] != NULL && $ar['valid_until'] < date('Y-m-d')) {
120
+if ($ar['valid_until'] != null && $ar['valid_until'] < date('Y-m-d')) {
122 121
     // Daten sind Restbestand von einem früheren Einsatz des Autoresponders
123
-  $ar['valid_from'] = NULL;
124
-  $ar['valid_until'] = NULL;
122
+    $ar['valid_from'] = null;
123
+    $ar['valid_until'] = null;
125 124
 }
126
-$valid_from_now_checked = ($ar['valid_from'] <= date('Y-m-d H:i:s') || $ar['valid_from'] == NULL) ? ' checked="checked"' : '';
125
+$valid_from_now_checked = ($ar['valid_from'] <= date('Y-m-d H:i:s') || $ar['valid_from'] == null) ? ' checked="checked"' : '';
127 126
 $valid_from_future_checked = ($ar['valid_from'] > date('Y-m-d H:i:s')) ? ' checked="checked"' : '';
128 127
 $startdate = $ar['valid_from'];
129 128
 if (! $startdate || $startdate <= date('Y-m-d')) {
... ...
@@ -133,8 +132,8 @@ $form .= "<p><input type=\"radio\" name=\"ar_valid_from\" value=\"now\" id=\"ar_
133 132
   "<input type=\"radio\" name=\"ar_valid_from\" value=\"date\" id=\"ar_valid_from_date\"{$valid_from_future_checked} /> <label for=\"ar_valid_from_date\">Erst ab dem </label>".
134 133
   "<input type=\"text\" value=\"$startdate\" id=\"ar_startdate\" name=\"ar_startdate\" /></p>";
135 134
 
136
-$valid_until_infinity_checked = ($ar['valid_until'] == NULL) ? ' checked="checked"' : '';
137
-$valid_until_date_checked = ($ar['valid_until'] != NULL) ? ' checked="checked"' : '';
135
+$valid_until_infinity_checked = ($ar['valid_until'] == null) ? ' checked="checked"' : '';
136
+$valid_until_date_checked = ($ar['valid_until'] != null) ? ' checked="checked"' : '';
138 137
 $enddate = $ar['valid_until'];
139 138
 if (! $enddate) {
140 139
     $enddate = date('Y-m-d', time() + 7*24*60*60);
... ...
@@ -152,9 +151,10 @@ $form .= "<p><input type=\"radio\" name=\"ar_valid_until\" value=\"infinity\" id
152 151
 */
153 152
 
154 153
 $subject = filter_input_general($ar['subject']);
155
-if ($subject == NULL)
154
+if ($subject == null) {
156 155
     $subject = '';
157
-$ar_subject_default_checked = ($subject == NULL) ? ' checked="checked"' : '';
156
+}
157
+$ar_subject_default_checked = ($subject == null) ? ' checked="checked"' : '';
158 158
 $ar_subject_custom_checked = ($subject) ? ' checked="checked"' : '';
159 159
 $form .= "<h4>Betreffzeile der automatischen Antwort</h4>".
160 160
   "<p><input type=\"radio\" name=\"ar_subject\" value=\"default\" id=\"ar_subject_default\"{$ar_subject_default_checked} /> ".
... ...
@@ -166,8 +166,9 @@ $message = filter_input_general($ar['message']);
166 166
 $form .= "<h4>Inhalt der automatischen Antwort</h4>".
167 167
   "<p><textarea cols=\"80\" rows=\"10\" name=\"ar_message\" id=\"ar_message\">".$ar['message']."</textarea></p>";
168 168
 $quote = $ar['quote'];
169
-if (! $quote) 
169
+if (! $quote) {
170 170
     $quote = 'none';
171
+}
171 172
 $form .= "<p><label for=\"ar_quote\">Originalnachricht des Absenders </label>".
172 173
   html_select('ar_quote', array("none" => 'nicht in Antwort einschließen',
173 174
                                 "teaser" => 'anreißen (erste 10 Zeilen)',
... ...
@@ -175,8 +176,8 @@ $form .= "<p><label for=\"ar_quote\">Originalnachricht des Absenders </label>".
175 176
                                 //"attach" => 'vollständig als Anhang beifügen'), $quote)."</p>";
176 177
 
177 178
 
178
-$ar_from_default_checked = ($ar['fromname'] == NULL) ? ' checked="checked"' : '';
179
-$ar_from_custom_checked = ($ar['fromname'] != NULL) ? ' checked="checked"' : '';
179
+$ar_from_default_checked = ($ar['fromname'] == null) ? ' checked="checked"' : '';
180
+$ar_from_custom_checked = ($ar['fromname'] != null) ? ' checked="checked"' : '';
180 181
 $fromname = filter_input_general($ar['fromname']);
181 182
 $form .= "<h4>Absender der automatischen Antwort</h4>".
182 183
   "<p><input type=\"radio\" name=\"ar_from\" value=\"default\" id=\"ar_from_default\"{$ar_from_default_checked} /> <label for=\"ar_from_default\">Nur E-Mail-Adresse</label><br />".
... ...
@@ -206,8 +207,7 @@ while (count($account['forwards']) < 10) {
206 207
     // Dummy-Einträge für Leute ohne JavaScript
207 208
     $account['forwards'][] = array('destination' => '');
208 209
 }
209
-for ($i = 0 ; $i < max($numforwards,10) ; $i++)
210
-{
210
+for ($i = 0 ; $i < max($numforwards, 10) ; $i++) {
211 211
     $num = $i+1;
212 212
     $form .= "<div class=\"vmail-forward\" id=\"vmail_forward_{$num}\">
213 213
   <div style=\"float: right;\" class=\"delete_forward\">".icon_delete("Diese Weiterleitung entfernen")."</div>
... ...
@@ -230,6 +230,3 @@ output(html_form('vmail_edit_mailbox', 'save', 'action=edit'.($id != 0 ? '&id='.
230 230
 if (! $accountlogin && ($id != 0)) {
231 231
     output("<p>".internal_link('suspend', 'Diese Adresse stilllegen (mit individuellem Fehlertext)', "account=".$id)."</p>");
232 232
 }
233
-
234
-
235
-?>
... ...
@@ -29,67 +29,63 @@ $user = $_SESSION['userinfo'];
29 29
 title("E-Mail-Accounts");
30 30
 
31 31
 
32
-if (isset($_GET['action']) && $_GET['action'] == 'save')
33
-{
34
-  if (isset($_GET['id']))
35
-  {
32
+if (isset($_GET['action']) && $_GET['action'] == 'save') {
33
+    if (isset($_GET['id'])) {
36 34
         check_form_token('email_imap_edit');
37 35
         $account = $_POST['user'].'@'.$_POST['domain'];
38
-    if (isset($_POST['enabled']) && $_POST['enabled'] == 'true')
36
+        if (isset($_POST['enabled']) && $_POST['enabled'] == 'true') {
39 37
             $enabled = 'Y';
40
-    else
38
+        } else {
41 39
             $enabled = 'N';
40
+        }
42 41
         $acc = array('id' => $_GET['id'], 'account' => $account, 'mailbox' => $_POST['mailbox'], 'enabled' => $enabled);
43
-    if ($_POST['password'] != '')
42
+        if ($_POST['password'] != '') {
44 43
             $acc['password'] = $_POST['password'];
44
+        }
45 45
         $error = check_valid($acc);
46
-    if ($error != "")
47
-    {
46
+        if ($error != "") {
48 47
             input_error($error);
49 48
             $title = "E-Mail-Accounts";
50 49
             output("");
51
-    }
52
-    else
53
-    {
50
+        } else {
54 51
             change_mailaccount($_GET['id'], $acc);
55
-      if (! $debugmode)
52
+            if (! $debugmode) {
56 53
                 header('Location: imap');
57
-      die();
58 54
             }
55
+            die();
59 56
         }
60
-  elseif (isset($_POST['create']))
61
-  {
57
+    } elseif (isset($_POST['create'])) {
62 58
         check_form_token('email_imap_create');
63 59
         $account = $_POST['user'].'@'.$_POST['domain'];
64
-    if (isset($_POST['enabled']) && $_POST['enabled'] == 'true')
60
+        if (isset($_POST['enabled']) && $_POST['enabled'] == 'true') {
65 61
             $enabled = 'Y';
66
-    else
62
+        } else {
67 63
             $enabled = 'N';
64
+        }
68 65
         $acc = array('account' => $account, 'mailbox' => $_POST['mailbox'], 'enabled' => $enabled);
69
-    if ($_POST['password'] != '')
66
+        if ($_POST['password'] != '') {
70 67
             $acc['password'] = $_POST['password'];
68
+        }
71 69
         $error = check_valid($acc);
72
-    if ($error != "")
73
-    {
70
+        if ($error != "") {
74 71
             system_failure($error);
75
-    }
76
-    else
77
-    {
72
+        } else {
78 73
             create_mailaccount($acc);
79
-      if (! $debugmode)
74
+            if (! $debugmode) {
80 75
                 header('Location: imap');
81
-      die(); 
82 76
             }
77
+            die();
83 78
         }
84 79
     }
85
-elseif (isset($_GET['action']) && $_GET['action'] == 'create')
86
-{
80
+} elseif (isset($_GET['action']) && $_GET['action'] == 'create') {
87 81
     $options = '';
88 82
     $domains = get_domain_list($user['customerno'], $user['uid']);
89
-  if (count($domains) > 0)
83
+    if (count($domains) > 0) {
90 84
         $options .= '<option>----------------------------</option>';
91
-  foreach ($domains as $dom)
85
+    }
86
+    foreach ($domains as $dom) {
92 87
         $options .= '<option value="'.$dom->fqdn.'">'.$dom->fqdn.'</option>';
88
+    }
93 89
 
94 90
     title("IMAP-Account anlegen");
95 91
     output('<p>Hier können Sie ein neues POP3/IMAP-Konto anlegen.</p>
... ...
@@ -119,12 +115,9 @@ elseif (isset($_GET['action']) && $_GET['action'] == 'create')
119 115
   </table>
120 116
   <p><input type="submit" name="create" value="Anlegen" /></p>
121 117
   '));
122
-}
123
-elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && $_GET['account'] != '')
124
-{
118
+} elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && $_GET['account'] != '') {
125 119
     $sure = user_is_sure();
126
-  if ($sure === NULL)
127
-  {
120
+    if ($sure === null) {
128 121
         $_GET['account'] = (int) $_GET['account'];
129 122
         $account = get_mailaccount($_GET['account']);
130 123
         $enabled = ($account['enabled'] ? 'Ja' : 'Nein');
... ...
@@ -142,23 +135,19 @@ elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && $_GET['account'
142 135
       </tr>
143 136
     </table>
144 137
 ');
145
-  }
146
-  elseif ($sure === true)
147
-  {
138
+    } elseif ($sure === true) {
148 139
         delete_mailaccount($_GET['account']);
149
-    if (! $debugmode)
140
+        if (! $debugmode) {
150 141
             header('Location: imap');
151
-    die();
152 142
         }
153
-  elseif ($sure === false)
154
-  {
155
-    if (! $debugmode)
156
-      header("Location: imap");
157 143
         die();
144
+    } elseif ($sure === false) {
145
+        if (! $debugmode) {
146
+            header("Location: imap");
158 147
         }
148
+        die();
159 149
     }
160
-elseif (isset($_GET['edit']))
161
-{
150
+} elseif (isset($_GET['edit'])) {
162 151
     title("IMAP-Account bearbeiten");
163 152
     output('<p>Hier können Sie die Einstellungen des IMAP-Kontos bearbeiten.</p>
164 153
 ');
... ...
@@ -174,13 +163,16 @@ elseif (isset($_GET['edit']))
174 163
     <option value="'.config('masterdomain').'">'.config('masterdomain').'</option>
175 164
     ';
176 165
     $domains = get_domain_list($user['customerno'], $user['uid']);
177
-    if (count($domains) > 0)
166
+    if (count($domains) > 0) {
178 167
         $form .= '<option>----------------------------</option>';
179
-    foreach ($domains as $dom)
180
-      if ($domain == $dom->fqdn)
168
+    }
169
+    foreach ($domains as $dom) {
170
+        if ($domain == $dom->fqdn) {
181 171
             $form .= '<option value="'.$dom->fqdn.'" selected="selected">'.$dom->fqdn.'</option>';
182
-      else
172
+        } else {
183 173
             $form .= '<option value="'.$dom->fqdn.'">'.$dom->fqdn.'</option>';
174
+        }
175
+    }
184 176
 
185 177
     $form .= '</select></td>
186 178
           <td><input type="button" onclick="document.getElementById(\'user\').value = \''.$username.'\' ; document.getElementById(\'domain\').value = \''.$domain.'\'" value="Zeile zurücksetzen" /></td></tr>
... ...
@@ -199,12 +191,9 @@ elseif (isset($_GET['edit']))
199 191
   Hinweis: Das Passwort wird nur geändert, wenn Sie auf dieser Seite eines eingeben. Geben Sie keines an, wird das bisherige beibehalten!</p>
200 192
   ';
201 193
     output(html_form('email_imap_edit', 'imap', 'action=save&id='.$_GET['edit'], $form));
202
-}
203
-else
204
-{
194
+} else {
205 195
     title("IMAP-Accounts");
206
-  if (user_has_only_vmail_domains())
207
-  {
196
+    if (user_has_only_vmail_domains()) {
208 197
         output('<div class="error"><strong>Achtung:</strong> Alle Ihre Domains sind auf Webinterface-Verwaltung konfiguriert. Sie können dennoch manuelle IMAP-Konten für Ihre speziellen Konfigurationen anlegen, in der Regel sollten Sie aber hier keine IMAP-Acccounts anlegen. Dies kann zu Fehlfunktionen führen.</div>');
209 198
     }
210 199
     addnew("imap", "Neuen Account anlegen", "action=create");
... ...
@@ -213,11 +202,11 @@ else
213 202
 <tr><th>Kontoname:</th><th>Mailbox-Pfad:</th><th>aktiv</th><th>&#160;</th></tr>
214 203
 ');
215 204
 
216
-        foreach (mailaccounts($user['uid']) as $account)
217
-        {
205
+    foreach (mailaccounts($user['uid']) as $account) {
218 206
         $mailbox = $account['mailbox'];
219
-                if (empty($mailbox))
207
+        if (empty($mailbox)) {
220 208
             $mailbox = '<i>nicht festgelegt</i>';
209
+        }
221 210
         output('<tr>
222 211
             <td>'.internal_link('imap', $account['account'], 'edit='.$account['id']).'</td>
223 212
             <td>'.$mailbox.'</td>
... ...
@@ -225,13 +214,10 @@ else
225 214
             <td>'.internal_link("imap", icon_delete("»{$account['account']}« löschen"), "action=delete&account=".$account['id']).'</td></tr>');
226 215
     }
227 216
     output('</table>');
228
-  if (imap_on_vmail_domain())
229
-  {
217
+    if (imap_on_vmail_domain()) {
230 218
         output('<div class="error"><strong>Achtung:</strong> Es scheint als hätten Sie einen (manuellen) IMAP-Account mittels einer Domain angelegt, die für Webinterface-Verwaltung konfiguriert ist. Sollten Sie nicht genau wissen was Sie tun, ist das vermutlich falsch und wird zu Fehlfunktionen führen.</div>');
231 219
     }
232 220
     addnew("imap", "Neuen Account anlegen", "action=create");
233 221
 
234 222
     output('<p>'.other_icon('information.png', 'Zugangsdaten anzeigen').' <strong>'.internal_link('logindata', 'Zugangsdaten für E-Mail-Abruf anzeigen', 'server='.get_server_by_id($_SESSION['userinfo']['server']).'&type=manual').'</strong></p>');
235 223
 }
236
-
237
-?>
... ...
@@ -18,15 +18,12 @@ function encrypt_mail_password($newpass)
18 18
 {
19 19
     DEBUG("unencrypted PW: »".$newpass."«");
20 20
     require_once('inc/base.php');
21
-  if (defined("CRYPT_SHA512") && CRYPT_SHA512 == 1)
22
-  {
21
+    if (defined("CRYPT_SHA512") && CRYPT_SHA512 == 1) {
23 22
         $rounds = rand(1000, 5000);
24 23
         $salt = "rounds=".$rounds."$".random_string(8);
25 24
         DEBUG("crypt(\"{$newpass}\", \"\$6\${$salt}\$\");");
26 25
         $newpass = crypt($newpass, "\$6\${$salt}\$");
27
-  }
28
-  else
29
-  {
26
+    } else {
30 27
         $salt = random_string(8);
31 28
         DEBUG("crypt(\"{$newpass}\", \"\$1\${$salt}\$\");");
32 29
         $newpass = crypt($newpass, "\$1\${$salt}\$");
... ...
@@ -24,8 +24,7 @@ function user_has_accounts()
24 24
     return ($result->rowCount() > 0);
25 25
 }
26 26
 
27
-if (! function_exists("user_has_vmail_domain"))
28
-{
27
+if (! function_exists("user_has_vmail_domain")) {
29 28
     function user_has_vmail_domain()
30 29
     {
31 30
         $role = $_SESSION['role'];
... ...
@@ -14,8 +14,7 @@ http://creativecommons.org/publicdomain/zero/1.0/
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.
15 15
 */
16 16
 
17
-if (! function_exists("user_has_vmail_domain"))
18
-{
17
+if (! function_exists("user_has_vmail_domain")) {
19 18
     function user_has_vmail_domain()
20 19
     {
21 20
         $role = $_SESSION['role'];
... ...
@@ -31,8 +30,7 @@ if (! function_exists("user_has_vmail_domain"))
31 30
     }
32 31
 }
33 32
 
34
-if (! function_exists("user_has_dotcourier_domain"))
35
-{
33
+if (! function_exists("user_has_dotcourier_domain")) {
36 34
     function user_has_dotcourier_domain()
37 35
     {
38 36
         $role = $_SESSION['role'];
... ...
@@ -43,10 +41,9 @@ if (! function_exists("user_has_dotcourier_domain"))
43 41
         $result = db_query("select 1 from mail.custom_mappings as c left join mail.v_domains as d on (d.id=c.domain) where d.user=:uid or c.uid=:uid UNION ".
44 42
             "SELECT 1 FROM mail.v_domains AS d WHERE d.user=:uid AND d.id != ALL(SELECT domain FROM mail.virtual_mail_domains)", array(":uid" => $uid));
45 43
         $ret = ($result->rowCount() > 0);
46
-  if ($ret)
44
+        if ($ret) {
47 45
             DEBUG("User {$uid} has dotcourier-domains");
46
+        }
48 47
         return $ret;
49 48
     }
50 49
 }
51
-
52
-?>
... ...
@@ -28,9 +28,11 @@ function mailaccounts($uid)
28 28
     $result = db_query("SELECT m.id,concat_ws('@',`m`.`local`,if(isnull(`m`.`domain`),:masterdomain,`d`.`domainname`)) AS `account`, `m`.`password` AS `cryptpass`,`m`.`maildir` AS `maildir`,aktiv from (`mail`.`mailaccounts` `m` left join `mail`.`v_domains` `d` on((`d`.`id` = `m`.`domain`))) WHERE m.uid=:uid ORDER BY if(isnull(`m`.`domain`),:masterdomain,`d`.`domainname`), local", array(":masterdomain" => config("masterdomain"), ":uid" => $uid));
29 29
     DEBUG("Found ".@$result->rowCount()." rows!");
30 30
     $accounts = array();
31
-  if (@$result->rowCount() > 0)
32
-    while ($acc = @$result->fetch(PDO::FETCH_OBJ))
31
+    if (@$result->rowCount() > 0) {
32
+        while ($acc = @$result->fetch(PDO::FETCH_OBJ)) {
33 33
             array_push($accounts, array('id'=> $acc->id, 'account' => $acc->account, 'mailbox' => $acc->maildir, 'cryptpass' => $acc->cryptpass, 'enabled' => ($acc->aktiv == 1)));
34
+        }
35
+    }
34 36
     return $accounts;
35 37
 }
36 38
 
... ...
@@ -40,8 +42,9 @@ function get_mailaccount($id)
40 42
     $uid = (int) $_SESSION['userinfo']['uid'];
41 43
     $result = db_query("SELECT concat_ws('@',`m`.`local`,if(isnull(`m`.`domain`),:masterdomain,`d`.`domainname`)) AS `account`, `m`.`password` AS `cryptpass`,`m`.`maildir` AS `maildir`,aktiv from (`mail`.`mailaccounts` `m` left join `mail`.`v_domains` `d` on((`d`.`id` = `m`.`domain`))) WHERE m.id=:mid AND m.uid=:uid", array(":masterdomain" => config("masterdomain"), ":uid" => $uid, ":mid" => $id));
42 44
     DEBUG("Found ".$result->rowCount()." rows!");
43
-  if ($result->rowCount() != 1)
45
+    if ($result->rowCount() != 1) {
44 46
         system_failure('Dieser Mailaccount existiert nicht oder gehört Ihnen nicht');
47
+    }
45 48
     $acc = $result->fetch(PDO::FETCH_OBJ);
46 49
     $ret = array('account' => $acc->account, 'mailbox' => $acc->maildir,  'enabled' => ($acc->aktiv == 1));
47 50
     DEBUG(print_r($ret, true));
... ...
@@ -55,18 +58,14 @@ function change_mailaccount($id, $arr)
55 58
     $conditions = array();
56 59
     $values = array(":id" => $id, ":uid" => $uid);
57 60
 
58
-  if (isset($arr['account']))
59
-  {
61
+    if (isset($arr['account'])) {
60 62
         list($local, $domain) = explode('@', $arr['account'], 2);
61
-    if ($domain == config('masterdomain'))
62
-    {
63
-      $values[':domain'] = NULL;
64
-    }
65
-    else
66
-    {
63
+        if ($domain == config('masterdomain')) {
64
+            $values[':domain'] = null;
65
+        } else {
67 66
             $domain = new Domain((string) $domain);
68
-      if ($domain->id == NULL) {
69
-        $values[":domain"] = NULL;
67
+            if ($domain->id == null) {
68
+                $values[":domain"] = null;
70 69
             } else {
71 70
                 $domain->ensure_userdomain();
72 71
                 $values[":domain"] = $domain->id;
... ...
@@ -78,14 +77,14 @@ function change_mailaccount($id, $arr)
78 77
     }
79 78
     if (isset($arr['mailbox'])) {
80 79
         array_push($conditions, "`maildir`=:maildir");
81
-    if ($arr['mailbox'] == '')
82
-      $values[":maildir"] = NULL;
83
-    else
80
+        if ($arr['mailbox'] == '') {
81
+            $values[":maildir"] = null;
82
+        } else {
84 83
             $values[":maildir"] = $arr['mailbox'];
85 84
         }
85
+    }
86 86
 
87
-  if (isset($arr['password']))
88
-  {
87
+    if (isset($arr['password'])) {
89 88
         $encpw = encrypt_mail_password($arr['password']);
90 89
         array_push($conditions, "`password`=:password");
91 90
         $values[":password"] = $encpw;
... ...
@@ -106,22 +104,20 @@ function create_mailaccount($arr)
106 104
 {
107 105
     $values = array();
108 106
 
109
-  if (($arr['account']) == '')
107
+    if (($arr['account']) == '') {
110 108
         system_failure('empty account name!');
109
+    }
111 110
 
112 111
     $values[':uid'] = (int) $_SESSION['userinfo']['uid'];
113 112
 
114 113
     list($local, $domain) = explode('@', $arr['account'], 2);
115
-  if ($domain == config('masterdomain'))
116
-  {
117
-    $values[':domain'] = NULL;
118
-  }
119
-  else
120
-  {
114
+    if ($domain == config('masterdomain')) {
115
+        $values[':domain'] = null;
116
+    } else {
121 117
         $domain = new Domain((string) $domain);
122
-    if ($domain->id == NULL)
123
-      $values[':domain'] = NULL;
124
-    else {
118
+        if ($domain->id == null) {
119
+            $values[':domain'] = null;
120
+        } else {
125 121
             $domain->ensure_userdomain();
126 122
             $values[':domain'] = $domain->id;
127 123
         }
... ...
@@ -129,26 +125,29 @@ function create_mailaccount($arr)
129 125
 
130 126
     $values[':local'] = $local;
131 127
 
132
-  if (isset($arr['mailbox']))
133
-    if ($arr['mailbox'] == '')
134
-      $values[':maildir'] = NULL;
135
-    else
128
+    if (isset($arr['mailbox'])) {
129
+        if ($arr['mailbox'] == '') {
130
+            $values[':maildir'] = null;
131
+        } else {
136 132
             $values[':maildir'] = $arr['mailbox'];
133
+        }
134
+    }
137 135
 
138 136
 
139
-  if (isset($arr['password']))
140
-  {
137
+    if (isset($arr['password'])) {
141 138
         $values[':password'] = encrypt_mail_password($arr['password']);
142 139
     }
143 140
 
144
-  if (isset($arr['enabled']))
141
+    if (isset($arr['enabled'])) {
145 142
         $values[':aktiv'] = ($arr['enabled'] == 'Y' ? 1 : 0);
143
+    }
146 144
 
147 145
 
148
-  $fields = array_map( function ($k) { return substr($k, 1);}, array_keys($values));
146
+    $fields = array_map(function ($k) {
147
+        return substr($k, 1);
148
+    }, array_keys($values));
149 149
     db_query("INSERT INTO mail.mailaccounts (".implode(',', $fields).") VALUES (".implode(",", array_keys($values)).")", $values);
150 150
     logger(LOG_INFO, "modules/imap/include/mailaccounts", "imap", "created account »{$arr['account']}«");
151
-
152 151
 }
153 152
 
154 153
     
... ...
@@ -185,38 +184,39 @@ function check_valid($acc)
185 184
     $user = $_SESSION['userinfo'];
186 185
     DEBUG("Account-data: ".print_r($acc, true));
187 186
     DEBUG("User-data: ".print_r($user, true));
188
-  if ($acc['mailbox'] != '')
189
-  {
190
-    if (substr($acc['mailbox'], 0, strlen($user['homedir'])+1) != $user['homedir'].'/')
187
+    if ($acc['mailbox'] != '') {
188
+        if (substr($acc['mailbox'], 0, strlen($user['homedir'])+1) != $user['homedir'].'/') {
191 189
             return "Die Mailbox muss innerhalb des Home-Verzeichnisses liegen. Sie haben »".$acc['mailbox']."« als Mailbox angegeben, Ihr Home-Verzeichnis ist »".$user['homedir']."/«.";
192
-    if (! check_path($acc['mailbox']))
190
+        }
191
+        if (! check_path($acc['mailbox'])) {
193 192
             return "Sie verwenden ungültige Zeichen in Ihrem Mailbox-Pfad.";
194 193
         }
194
+    }
195 195
 
196
-  if ($acc['account'] == '' || strpos($acc['account'], '@') == 0)
196
+    if ($acc['account'] == '' || strpos($acc['account'], '@') == 0) {
197 197
         return "Es wurde kein Benutzername angegeben!";
198
-  if (strpos($acc['account'], '@') === false)
198
+    }
199
+    if (strpos($acc['account'], '@') === false) {
199 200
         return "Es wurde kein Domain-Teil im Account-Name angegeben. Account-Namen müssen einen Domain-Teil enthalten. Im Zweifel versuchen Sie »@".config('masterdomain')."«.";
201
+    }
200 202
 
201 203
     list($local, $domain) = explode('@', $acc['account'], 2);
202 204
     verify_input_username($local);
203 205
     $tmpdomains = get_domain_list($user['customerno'], $user['uid']);
204 206
     $domains = array();
205
-  foreach ($tmpdomains as $dom)
207
+    foreach ($tmpdomains as $dom) {
206 208
         $domains[] = $dom->fqdn;
209
+    }
207 210
 
208
-  if (array_search($domain, $domains) === false)
209
-  {
210
-    if ($domain == config('masterdomain'))
211
-    {
212
-      if (substr($local, 0, strlen($user['username'])) != $user['username'] || ($acc['account'][strlen($user['username'])] != '-' && $acc['account'][strlen($user['username'])] != '@'))
213
-      {
211
+    if (array_search($domain, $domains) === false) {
212
+        if ($domain == config('masterdomain')) {
213
+            if (substr($local, 0, strlen($user['username'])) != $user['username'] || ($acc['account'][strlen($user['username'])] != '-' && $acc['account'][strlen($user['username'])] != '@')) {
214 214
                 return "Sie haben »@".config('masterdomain')."« als Domain-Teil angegeben, aber der Benutzer-Teil beginnt nicht mit Ihrem Benutzername!";
215 215
             }
216
-    }
217
-    else
216
+        } else {
218 217
             return "Der angegebene Domain-Teil (»".htmlentities($domain, ENT_QUOTES, "UTF-8")."«) ist nicht für Ihren Account eingetragen. Sollte dies ein Fehler sein, wenden sie sich bitte an einen Administrator!";
219 218
         }
219
+    }
220 220
 
221 221
     return '';
222 222
 }
... ...
@@ -226,8 +226,9 @@ function imap_on_vmail_domain()
226 226
 {
227 227
     $uid = (int) $_SESSION['userinfo']['uid'];
228 228
     $result = db_query("SELECT m.id FROM mail.mailaccounts AS m INNER JOIN mail.virtual_mail_domains AS vd USING (domain) WHERE vd.hostname IS NULL AND m.uid=?", array($uid));
229
-  if ($result->rowCount() > 0)
229
+    if ($result->rowCount() > 0) {
230 230
         return true;
231
+    }
231 232
     return false;
232 233
 }
233 234
 
... ...
@@ -236,15 +237,13 @@ function user_has_only_vmail_domains()
236 237
     $uid = (int) $_SESSION['userinfo']['uid'];
237 238
     $result = db_query("SELECT id FROM mail.v_vmail_domains WHERE useraccount=?", array($uid));
238 239
     // User hat keine VMail-Domains
239
-  if ($result->rowCount() == 0)
240
+    if ($result->rowCount() == 0) {
240 241
         return false;
242
+    }
241 243
     $result = db_query("SELECT d.id FROM mail.v_domains AS d LEFT JOIN mail.v_vmail_domains AS vd USING (domainname) WHERE vd.id IS NULL AND d.user=?", array($uid));
242 244
     // User hat keine Domains die nicht vmail-Domains sind
243
-  if ($result->rowCount() == 0)
245
+    if ($result->rowCount() == 0) {
244 246
         return true;
247
+    }
245 248
     return false;
246 249
 }
247
-
248
-
249
-
250
-?>
... ...
@@ -22,7 +22,8 @@ require_once('hasdomain.php');
22 22
 require_once('common.php');
23 23
 
24 24
 
25
-function forward_type($target) {
25
+function forward_type($target)
26
+{
26 27
     list($l, $d) = explode('@', strtolower($target), 2);
27 28
     DEBUG('Weiterleitung an '.$l.' @ '.$d);
28 29
     $result = db_query("SELECT id FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld) = ?", array($d));
... ...
@@ -39,32 +40,31 @@ function forward_type($target) {
39 40
 function empty_account()
40 41
 {
41 42
     $account = array(
42
-		'id' => NULL,
43
+        'id' => null,
43 44
         'local' => '',
44
-		'domain' => NULL,
45
-		'password' => NULL,
46
-    'smtpreply' => NULL,
45
+        'domain' => null,
46
+        'password' => null,
47
+    'smtpreply' => null,
47 48
     'quota' => config('vmail_basequota'),
48 49
     'quota_threshold' => 20,
49 50
         'forwards' => array(),
50
-		'autoresponder' => NULL
51
+        'autoresponder' => null
51 52
         );
52 53
     return $account;
53
-
54 54
 }
55 55
 
56 56
 function empty_autoresponder_config()
57 57
 {
58 58
     $ar = array(
59 59
     'valid_from' => date('Y-m-d'),
60
-    'valid_until' => NULL,
61
-    'fromname' => NULL,
62
-    'fromaddr' => NULL,
63
-    'subject' => NULL,
60
+    'valid_until' => null,
61
+    'fromname' => null,
62
+    'fromaddr' => null,
63
+    'subject' => null,
64 64
     'message' => 'Danke für Ihre E-Mail.
65 65
 Ich bin aktuell nicht im Büro und werde Ihre Nachricht erst nach meiner Rückkehr beantworten.
66 66
 Ihre E-Mail wird nicht weitergeleitet.',
67
-    'quote' => NULL
67
+    'quote' => null
68 68
     );
69 69
     return $ar;
70 70
 }
... ...
@@ -89,13 +89,15 @@ function get_account_details($id, $checkuid = true)
89 89
         $args[":uid"] = $uid;
90 90
     }
91 91
     $result = db_query("SELECT id, local, domain, password, smtpreply, forwards, autoresponder, server, quota, COALESCE(quota_used, 0) AS quota_used, quota_threshold from mail.v_vmail_accounts WHERE {$uid_check}id=:id LIMIT 1", $args);
92
-	if ($result->rowCount() == 0)
92
+    if ($result->rowCount() == 0) {
93 93
         system_failure('Ungültige ID oder kein eigener Account');
94
+    }
94 95
     $acc = empty_account();
95 96
     $res = $result->fetch();
96
-	foreach ($res AS $key => $value) {
97
-	  if ($key == 'forwards')
97
+    foreach ($res as $key => $value) {
98
+        if ($key == 'forwards') {
98 99
             continue;
100
+        }
99 101
         $acc[$key] = $value;
100 102
     }
101 103
     if ($acc['forwards'] > 0) {
... ...
@@ -110,9 +112,9 @@ function get_account_details($id, $checkuid = true)
110 112
         DEBUG($item);
111 113
         $acc['autoresponder'] = $item;
112 114
     } else {
113
-    $acc['autoresponder'] = NULL;
115
+        $acc['autoresponder'] = null;
114 116
     }
115
-  if ($acc['quota_threshold'] === NULL) {
117
+    if ($acc['quota_threshold'] === null) {
116 118
         $acc['quota_threshold'] = -1;
117 119
     }
118 120
     return $acc;
... ...
@@ -123,8 +125,7 @@ function get_vmail_accounts()
123 125
     $uid = (int) $_SESSION['userinfo']['uid'];
124 126
     $result = db_query("SELECT * from mail.v_vmail_accounts WHERE useraccount=? ORDER BY domainname,local ASC", array($uid));
125 127
     $ret = array();
126
-	while ($line = $result->fetch())
127
-	{
128
+    while ($line = $result->fetch()) {
128 129
         array_push($ret, $line);
129 130
     }
130 131
     DEBUG($ret);
... ...
@@ -137,11 +138,13 @@ function get_vmail_domains()
137 138
 {
138 139
     $uid = (int) $_SESSION['userinfo']['uid'];
139 140
     $result = db_query("SELECT id, domainname, server FROM mail.v_vmail_domains WHERE useraccount=? ORDER BY domainname", array($uid));
140
-	if ($result->rowCount() == 0)
141
+    if ($result->rowCount() == 0) {
141 142
         system_failure('Sie haben keine Domains für virtuelle Mail-Verarbeitung');
143
+    }
142 144
     $ret = array();
143
-	while ($tmp = $result->fetch())
145
+    while ($tmp = $result->fetch()) {
144 146
         array_push($ret, $tmp);
147
+    }
145 148
     return $ret;
146 149
 }
147 150
 
... ...
@@ -151,13 +154,15 @@ function find_account_id($accname)
151 154
     DEBUG($accname);
152 155
     $tmp = explode('@', $accname, 2);
153 156
     DEBUG($tmp);
154
-  if (count($tmp) != 2)
157
+    if (count($tmp) != 2) {
155 158
         system_failure("Der Account hat nicht die korrekte Syntax");
159
+    }
156 160
     list($local, $domainname) = $tmp;
157 161
 
158 162
     $result = db_query("SELECT id FROM mail.v_vmail_accounts WHERE local=? AND domainname=? LIMIT 1", array($local, $domainname));
159
-  if ($result->rowCount() == 0)
163
+    if ($result->rowCount() == 0) {
160 164
         system_failure("Der Account konnte nicht gefunden werden");
165
+    }
161 166
     $tmp = $result->fetch();
162 167
     return $tmp[0];
163 168
 }
... ...
@@ -171,14 +176,13 @@ function change_vmail_password($accname, $newpass)
171 176
 }
172 177
 
173 178
 
174
-function domainselect($selected = NULL, $selectattribute = '')
179
+function domainselect($selected = null, $selectattribute = '')
175 180
 {
176 181
     $domainlist = get_vmail_domains();
177 182
     $selected = (int) $selected;
178 183
 
179 184
     $ret = '<select id="domain" name="domain" size="1" '.$selectattribute.' >';
180
-  foreach ($domainlist as $dom)
181
-  {
185
+    foreach ($domainlist as $dom) {
182 186
         $s = ($selected == $dom['id']) ? ' selected="selected" ': '';
183 187
         $ret .= "<option value=\"{$dom['id']}\"{$s}>{$dom['domainname']}</option>\n";
184 188
     }
... ...
@@ -187,7 +191,8 @@ function domainselect($selected = NULL, $selectattribute = '')
187 191
 }
188 192
 
189 193
 
190
-function get_max_mailboxquota($server, $oldquota) {
194
+function get_max_mailboxquota($server, $oldquota)
195
+{
191 196
     $uid = (int) $_SESSION['userinfo']['uid'];
192 197
     $server = (int) $server;
193 198
     $result = db_query("SELECT systemquota - (COALESCE(systemquota_used,0) + COALESCE(mailquota,0)) AS free FROM system.v_quota WHERE uid=:uid AND server=:server", array(":uid" => $uid, ":server" => $server));
... ...
@@ -203,8 +208,7 @@ function save_vmail_account($account)
203 208
 {
204 209
     $accountlogin = ($_SESSION['role'] == ROLE_VMAIL_ACCOUNT);
205 210
     $id = $account['id'];
206
-  if ($id != NULL)
207
-  {
211
+    if ($id != null) {
208 212
         $id = (int) $id;
209 213
         $oldaccount = get_account_details($id, !$accountlogin);
210 214
         // Erzeugt einen system_error() wenn ID ungültig
... ...
@@ -212,57 +216,54 @@ function save_vmail_account($account)
212 216
     // Ab hier ist $id sicher, entweder NULL oder eine gültige ID des aktuellen users
213 217
 
214 218
     $newaccount = false;
215
-  if ($id === NULL) {
219
+    if ($id === null) {
216 220
         $newaccount = true;
217 221
     }
218 222
 
219 223
     if ($accountlogin) {
220
-    if ($account['domain'] != $oldaccount['domain'])
224
+        if ($account['domain'] != $oldaccount['domain']) {
221 225
             system_failure('Sie können die E-Mail-Adresse nicht ändern!');
222
-    if ($account['local'] != $oldaccount['local'])
226
+        }
227
+        if ($account['local'] != $oldaccount['local']) {
223 228
             system_failure('Sie können die E-Mail-Adresse nicht ändern!');
224
-    if ($account['quota'] != $oldaccount['quota'])
229
+        }
230
+        if ($account['quota'] != $oldaccount['quota']) {
225 231
             system_failure('Sie können Ihren eigenen Speicherplatz nicht verändern.');
226
-    if ($account['smtpreply'] != NULL) {
232
+        }
233
+        if ($account['smtpreply'] != null) {
227 234
             system_failure("Sie können nicht den Account stilllegen mit dem Sie grade angemeldet sind.");
228 235
         }
229 236
     } else {
230
-  
231 237
         $account['local'] = filter_input_username($account['local']);
232
-    if ($account['local'] == '')
233
-    {
238
+        if ($account['local'] == '') {
234 239
             system_failure('Die E-Mail-Adresse braucht eine Angabe vor dem »@«!');
235 240
             return false;
236 241
         }
237 242
         $account['domain'] = (int) $account['domain'];
238 243
         $domainlist = get_vmail_domains();
239 244
         $valid_domain = false;
240
-    $domainname = NULL;
241
-    $server = NULL;
242
-    foreach ($domainlist as $dom)
243
-    {
244
-      if ($dom['id'] == $account['domain'])
245
-      {
245
+        $domainname = null;
246
+        $server = null;
247
+        foreach ($domainlist as $dom) {
248
+            if ($dom['id'] == $account['domain']) {
246 249
                 $domainname = $dom['domainname'];
247 250
                 $server = $dom['server'];
248 251
                 $valid_domain = true;
249 252
                 break;
250 253
             }
251 254
         }
252
-    if (($account['domain'] == 0) || (! $valid_domain))
253
-    {
255
+        if (($account['domain'] == 0) || (! $valid_domain)) {
254 256
             system_failure('Bitte wählen Sie eine Ihrer Domains aus!');
255 257
             return false;
256 258
         }
257
-    if ($id == NULL && get_vmail_id_by_emailaddr($account['local'].'@'.$domainname)) {
259
+        if ($id == null && get_vmail_id_by_emailaddr($account['local'].'@'.$domainname)) {
258 260
             system_failure('Diese E-Mail-Adresse gibt es bereits.');
259 261
             return false;
260 262
         }
261 263
     }
262 264
   
263 265
     $forwards = array();
264
-  if (count($account['forwards']) > 0) 
265
-  {
266
+    if (count($account['forwards']) > 0) {
266 267
         for ($i = 0 ; $i < count($account['forwards']) ; $i++) {
267 268
             $account['forwards'][$i]['destination'] = filter_input_general($account['forwards'][$i]['destination']);
268 269
             if (! check_emailaddr($account['forwards'][$i]['destination'])) {
... ...
@@ -272,23 +273,21 @@ function save_vmail_account($account)
272 273
     }
273 274
 
274 275
     if ($accountlogin) {
275
-    $password = NULL; 
276
+        $password = null;
276 277
         $set_password = false;
277 278
     } else {
278
-    $password= NULL;
279
-    if ($account['password'] != '')
280
-    {
279
+        $password= null;
280
+        if ($account['password'] != '') {
281 281
             $account['password'] = stripslashes($account['password']);
282 282
             $crack = strong_password($account['password']);
283
-      if ($crack !== true)
284
-      {
283
+            if ($crack !== true) {
285 284
                 system_failure('Ihr Passwort ist zu einfach. bitte wählen Sie ein sicheres Passwort!'."\nDie Fehlermeldung lautet: »{$crack}«");
286 285
                 return false;
287 286
             }
288 287
             $password = encrypt_mail_password($account['password']);
289 288
         }
290
-    $set_password = ($id == NULL || $password != NULL);
291
-    if ($account['password'] === NULL) {
289
+        $set_password = ($id == null || $password != null);
290
+        if ($account['password'] === null) {
292 291
             $set_password=true;
293 292
         }
294 293
     }
... ...
@@ -316,15 +315,14 @@ function save_vmail_account($account)
316 315
     }
317 316
 
318 317
     if ($account['quota_threshold'] == -1) {
319
-    $account['quota_threshold'] = NULL;
320
-  }
321
-  else {
318
+        $account['quota_threshold'] = null;
319
+    } else {
322 320
         $account['quota_threshold'] = min((int) $account['quota_threshold'], (int) $account['quota']);
323 321
     }
324 322
   
325 323
     $account['local'] = strtolower($account['local']);
326 324
     # Leerstring wird zu NULL
327
-  $account['smtpreply'] = ($account['smtpreply'] ? $account['smtpreply'] : NULL);
325
+    $account['smtpreply'] = ($account['smtpreply'] ? $account['smtpreply'] : null);
328 326
 
329 327
     $args = array(":local" => $account['local'],
330 328
                 ":domain" => $account['domain'],
... ...
@@ -335,14 +333,13 @@ function save_vmail_account($account)
335 333
                 ":id" => $id
336 334
                 );
337 335
     $query = '';
338
-  if ($newaccount)
339
-  {
336
+    if ($newaccount) {
340 337
         unset($args[":id"]);
341 338
         $query = "INSERT INTO mail.vmail_accounts (local, domain, password, smtpreply, quota, quota_threshold) VALUES (:local, :domain, :password, :smtpreply, :quota, :quota_threshold)";
342 339
     } else {
343
-    if ($set_password)
340
+        if ($set_password) {
344 341
             $pw=", password=:password";
345
-    else {
342
+        } else {
346 343
             unset($args[":password"]);
347 344
             $pw='';
348 345
         }
... ...
@@ -355,16 +352,17 @@ function save_vmail_account($account)
355 352
 
356 353
     if (is_array($account['autoresponder'])) {
357 354
         $ar = $account['autoresponder'];
358
-    $quote = NULL;
359
-    if ($ar['quote'] == 'attach')
355
+        $quote = null;
356
+        if ($ar['quote'] == 'attach') {
360 357
             $quote = "attach";
361
-    elseif ($ar['quote'] == 'inline')
358
+        } elseif ($ar['quote'] == 'inline') {
362 359
             $quote = 'inline';
363
-    elseif ($ar['quote'] == 'teaser')
360
+        } elseif ($ar['quote'] == 'teaser') {
364 361
             $quote = 'teaser';
362
+        }
365 363
         if (! check_emailaddr($ar['fromaddr'])) {
366 364
             input_error("Die Absenderadresse sieht ungültig aus. Es wird Ihre E-Mail-Adresse benutzt!");
367
-      $ar['fromaddr'] = NULL;
365
+            $ar['fromaddr'] = null;
368 366
         }
369 367
         $query = "REPLACE INTO mail.vmail_autoresponder (account, valid_from, valid_until, fromname, fromaddr, subject, message, quote) ".
370 368
              "VALUES (:id, :valid_from, :valid_until, :fromname, :fromaddr, :subject, :message, :quote)";
... ...
@@ -385,8 +383,7 @@ function save_vmail_account($account)
385 383
         db_query("DELETE FROM mail.vmail_forward WHERE account=?", array($id));
386 384
     }
387 385
 
388
-  if (count($account['forwards']) > 0)
389
-  {
386
+    if (count($account['forwards']) > 0) {
390 387
         $forward_query = "INSERT INTO mail.vmail_forward (account,destination) VALUES (:account, :destination)";
391 388
         for ($i=0;$i < count($account['forwards']); $i++) {
392 389
             if (! isset($account['forwards'][$i]['destination'])) {
... ...
@@ -435,7 +432,7 @@ Wussten Sie schon, dass Sie auf mehrere Arten Ihre E-Mails abrufen können?
435 432
         $uid = (int) $_SESSION['userinfo']['uid'];
436 433
         $result = db_query("SELECT useraccount, server, SUM(quota-(SELECT value FROM misc.config WHERE `key`='vmail_basequota')) AS quota, SUM(GREATEST(quota_used-(SELECT value FROM misc.config WHERE `key`='vmail_basequota'), 0)) AS used FROM mail.v_vmail_accounts WHERE useraccount=? GROUP BY useraccount, server", array($uid));
437 434
         while ($line = $result->fetch()) {
438
-      if ($line['quota'] !== NULL) {
435
+            if ($line['quota'] !== null) {
439 436
                 db_query("REPLACE INTO mail.vmailquota (uid, server, quota, used) VALUES (:uid, :server, :quota, :used)", array(":uid" => $line['useraccount'], ":server" => $line['server'], ":quota" => $line['quota'], ":used" => $line['used']));
440 437
             }
441 438
         }
... ...
@@ -454,10 +451,12 @@ function delete_account($id)
454 451
 
455 452
 
456 453
 
457
-function domainsettings($only_domain=NULL) {
454
+function domainsettings($only_domain=null)
455
+{
458 456
     $uid = (int) $_SESSION['userinfo']['uid'];
459
-  if ($only_domain)
457
+    if ($only_domain) {
460 458
         $only_domain = (int) $only_domain;
459
+    }
461 460
     $domains = array();
462 461
     $subdomains = array();
463 462
 
... ...
@@ -466,27 +465,31 @@ function domainsettings($only_domain=NULL) {
466 465
 
467 466
     while ($mydom = $result->fetch()) {
468 467
         if (! array_key_exists($mydom['id'], $domains)) {
469
-      if ($mydom['v_id'])
468
+            if ($mydom['v_id']) {
470 469
                 $mydom['mail'] = 'virtual';
470
+            }
471 471
             $domains[$mydom['id']] = array(
472 472
         "name" => $mydom['name'],
473 473
         "type" => $mydom['mail'],
474 474
         "mailserver_lock" => $mydom['mailserver_lock']
475 475
         );
476
-      if ($only_domain && $only_domain == $mydom['id'])
476
+            if ($only_domain && $only_domain == $mydom['id']) {
477 477
                 return $domains[$only_domain];
478 478
             }
479 479
         }
480
+    }
480 481
 
481 482
     // Subdomains
482 483
     $result = db_query("SELECT d.id, CONCAT_WS('.',d.domainname,d.tld) AS name, d.mail, m.id AS m_id, v.id AS v_id, IF(ISNULL(v.hostname),m.subdomain,v.hostname) AS hostname FROM kundendaten.domains AS d LEFT JOIN mail.virtual_mail_domains AS v ON (d.id=v.domain AND v.hostname IS NOT NULL) LEFT JOIN mail.custom_mappings AS m ON (d.id=m.domain AND m.subdomain IS NOT NULL) WHERE (m.id IS NOT NULL OR v.id IS NOT NULL) AND d.useraccount=:uid OR m.uid=:uid;", array(":uid" => $uid));
483 484
     while ($mydom = $result->fetch()) {
484
-    if (! array_key_exists($mydom['id'], $subdomains))
485
+        if (! array_key_exists($mydom['id'], $subdomains)) {
485 486
             $subdomains[$mydom['id']] = array();
487
+        }
486 488
         
487 489
         $type = 'auto';
488
-    if ($mydom['v_id'])
490
+        if ($mydom['v_id']) {
489 491
             $type = 'virtual';
492
+        }
490 493
         $subdomains[$mydom['id']][] = array(
491 494
       "name" => $mydom['hostname'],
492 495
       "type" => $type
... ...
@@ -507,28 +510,29 @@ function domain_has_vmail_accounts($domid)
507 510
 function change_domain($id, $type)
508 511
 {
509 512
     $id = (int) $id;
510
-  if (domain_has_vmail_accounts($id))
513
+    if (domain_has_vmail_accounts($id)) {
511 514
         system_failure("Sie müssen zuerst alle E-Mail-Konten mit dieser Domain löschen, bevor Sie die Webinterface-Verwaltung für diese Domain abschalten können.");
515
+    }
512 516
   
513
-  if (! in_array($type, array('none','auto','virtual')))
517
+    if (! in_array($type, array('none','auto','virtual'))) {
514 518
         system_failure("Ungültige Aktion");
519
+    }
515 520
   
516 521
     $old = domainsettings($id);
517
-  if ($old['type'] == $type)
522
+    if ($old['type'] == $type) {
518 523
         system_failure('Domain ist bereits so konfiguriert');
524
+    }
519 525
 
520 526
     if ($type == 'none') {
521 527
         db_query("DELETE FROM mail.virtual_mail_domains WHERE domain=? AND hostname IS NULL", array($id));
522 528
         db_query("DELETE FROM mail.custom_mappings WHERE domain=? AND subdomain IS NULL", array($id));
523 529
         db_query("UPDATE kundendaten.domains SET mail='none', lastchange=NOW() WHERE id=?", array($id));
524
-  }
525
-  elseif ($type == 'virtual') {
530
+    } elseif ($type == 'virtual') {
526 531
         $vmailserver = (int) $_SESSION['userinfo']['server'];
527 532
         db_query("DELETE FROM mail.custom_mappings WHERE domain=? AND subdomain IS NULL", array($id));
528 533
         db_query("UPDATE kundendaten.domains SET mail='auto', lastchange=NOW() WHERE id=?", array($id));
529 534
         db_query("INSERT INTO mail.virtual_mail_domains (domain, server) VALUES (?, ?)", array($id, $vmailserver));
530
-  }
531
-  elseif ($type == 'auto') {
535
+    } elseif ($type == 'auto') {
532 536
         db_query("DELETE FROM mail.virtual_mail_domains WHERE domain=? AND hostname IS NULL LIMIT 1;", array($id));
533 537
         db_query("DELETE FROM mail.custom_mappings WHERE domain=? AND subdomain IS NULL LIMIT 1;", array($id));
534 538
         db_query("UPDATE kundendaten.domains SET mail='auto', lastchange=NOW() WHERE id=? LIMIT 1;", array($id));
... ...
@@ -556,7 +560,8 @@ function maildomain_type($type) {
556 560
 }
557 561
 */
558 562
 
559
-function maildomain_type($type) {
563
+function maildomain_type($type)
564
+{
560 565
     switch ($type) {
561 566
     case 'none':
562 567
       $type = 'Deaktiviert';
... ...
@@ -22,21 +22,15 @@ require_once('include/hasaccount.php');
22 22
 if ($role & ROLE_SYSTEMUSER) {
23 23
     $menu["email_vmail"] = array("label" => "E-Mail", "file" => "vmail", "weight" => 3);
24 24
 }
25
-if ($role & ROLE_VMAIL_ACCOUNT)
26
-{
25
+if ($role & ROLE_VMAIL_ACCOUNT) {
27 26
     $menu['email_edit'] = array("label" => "Einstellungen", "file" => "edit", "weight" => 10);
28 27
 }
29
-if ($role & (ROLE_VMAIL_ACCOUNT | ROLE_MAILACCOUNT))
30
-{
28
+if ($role & (ROLE_VMAIL_ACCOUNT | ROLE_MAILACCOUNT)) {
31 29
     $menu['email_chpass'] = array("label" => "Passwort ändern", "file" => "chpass", "weight" => 15);
32 30
 }
33 31
 if ($role & ROLE_SYSTEMUSER) {
34 32
     $menu["email_domains"] = array("label" => "Mail-Verwaltung", "file" => "domains", "weight" => 1, "submenu" => "domains_domains");
35 33
 }
36
-if ($role & ROLE_SYSTEMUSER && (user_has_accounts() || ! user_has_vmail_domain() || user_has_dotcourier_domain() ) )
37
-{
34
+if ($role & ROLE_SYSTEMUSER && (user_has_accounts() || ! user_has_vmail_domain() || user_has_dotcourier_domain())) {
38 35
     $menu["email_imap"] = array("label" => "IMAP/POP3", "file" => "imap", "weight" => 20, 'submenu' => "email_vmail");
39 36
 }
40
-
41
-
42
-?>
... ...
@@ -26,8 +26,7 @@ global $debugmode;
26 26
 $section = 'email_vmail';
27 27
 
28 28
 
29
-if ($_GET['action'] == 'edit')
30
-{
29
+if ($_GET['action'] == 'edit') {
31 30
     check_form_token('vmail_edit_mailbox');
32 31
     $accountlogin = ($_SESSION['role'] == ROLE_VMAIL_ACCOUNT);
33 32
 
... ...
@@ -38,10 +37,10 @@ if ($_GET['action'] == 'edit')
38 37
         // Leere das, sonst werden die vervielfacht
39 38
         $account['forwards'] = array();
40 39
     } else {
41
-    $id = isset($_GET['id']) ? (int) $_GET['id'] : NULL;
40
+        $id = isset($_GET['id']) ? (int) $_GET['id'] : null;
42 41
 
43 42
         $account = empty_account();
44
-    $account['id'] = NULL;
43
+        $account['id'] = null;
45 44
         if ($id) {
46 45
             $account['id'] = $id;
47 46
   
... ...
@@ -54,13 +53,14 @@ if ($_GET['action'] == 'edit')
54 53
         }
55 54
         $account['password'] = $_POST['password'];
56 55
 
57
-    if (($account['password'] == '') && (isset($_POST['mailbox']) && $_POST['mailbox'] == 'yes'))
56
+        if (($account['password'] == '') && (isset($_POST['mailbox']) && $_POST['mailbox'] == 'yes')) {
58 57
             system_failure("Sie haben ein leeres Passwort eingegeben!");
59
-    if ($_POST['password'] == '**********')
58
+        }
59
+        if ($_POST['password'] == '**********') {
60 60
             $account['password'] = '';
61
-    if (!isset($_POST['mailbox']) || (isset($_POST['mailbox']) && $_POST['mailbox'] != 'yes'))
62
-    {
63
-      $account['password'] = NULL;
61
+        }
62
+        if (!isset($_POST['mailbox']) || (isset($_POST['mailbox']) && $_POST['mailbox'] != 'yes')) {
63
+            $account['password'] = null;
64 64
         }
65 65
         if (isset($_POST['quota'])) {
66 66
             $account['quota'] = $_POST['quota'];
... ...
@@ -75,7 +74,7 @@ if ($_GET['action'] == 'edit')
75 74
 
76 75
     $ar = empty_autoresponder_config();
77 76
     $valid_from_date = time();
78
-  $valid_until_date = NULL;
77
+    $valid_until_date = null;
79 78
     if (isset($_POST['ar_valid_from']) && ($_POST['ar_valid_from'] == 'now')) {
80 79
         $valid_from_date = time();
81 80
     } else {
... ...
@@ -95,7 +94,7 @@ if ($_GET['action'] == 'edit')
95 94
         warning('Das Aktivierungs-Datum liegt mehr als ein Jahr in der Zukunft. Bitte prüfen Sie ob Sie das korrekte Jahr gewählt haben.');
96 95
     }
97 96
     if (isset($_POST['ar_valid_until']) && ($_POST['ar_valid_until'] == 'infinity')) {
98
-    $valid_until_date = NULL;
97
+        $valid_until_date = null;
99 98
     } else {
100 99
         if (isset($_POST['ar_enddate'])) {
101 100
             if (date('Y-m-d', strtotime($_POST['ar_enddate'])) != $_POST['ar_enddate']) {
... ...
@@ -106,7 +105,7 @@ if ($_GET['action'] == 'edit')
106 105
         }
107 106
     }
108 107
     if (!isset($_POST['autoresponder']) || $_POST['autoresponder'] != 'yes') {
109
-    $valid_from_date = NULL;
108
+        $valid_from_date = null;
110 109
     } else {
111 110
         if ($valid_until_date && $valid_until_date < time()) {
112 111
             warning('Das Deaktivierungs-Datum liegt in der Vergangenheit, der Autoresponder wird sofort deaktiviert!');
... ...
@@ -115,12 +114,12 @@ if ($_GET['action'] == 'edit')
115 114
     if ($valid_from_date) {
116 115
         $ar['valid_from'] = date('Y-m-d', $valid_from_date);
117 116
     } else {
118
-    $ar['valid_from'] = NULL;
117
+        $ar['valid_from'] = null;
119 118
     }
120 119
     if ($valid_until_date) {
121 120
         $ar['valid_until'] = date('Y-m-d', $valid_until_date);
122 121
     } else {
123
-    $ar['valid_until'] = NULL;
122
+        $ar['valid_until'] = null;
124 123
     }
125 124
 
126 125
     if (isset($_POST['ar_subject']) && $_POST['ar_subject'] == 'custom' && isset($_POST['ar_subject_value']) && chop($_POST['ar_subject_value']) != '') {
... ...
@@ -151,24 +150,25 @@ if ($_GET['action'] == 'edit')
151 150
 
152 151
 
153 152
 
154
-  if (isset($_POST['forward']) && $_POST['forward'] == 'yes')
155
-  {
153
+    if (isset($_POST['forward']) && $_POST['forward'] == 'yes') {
156 154
         $num = 1;
157
-    while (true)
158
-    {
155
+        while (true) {
159 156
             // Die ersten 50 Einträge in jedem Fall prüfen, danach nur so lange zusätzliche Einträge vorhanden
160
-      if (! isset($_POST['forward_to_'.$num]) && $num > 50)
157
+            if (! isset($_POST['forward_to_'.$num]) && $num > 50) {
161 158
                 break;
159
+            }
162 160
             if (isset($_POST['forward_to_'.$num]) && chop($_POST['forward_to_'.$num]) != '') {
163 161
                 $fwd = array("destination" => chop($_POST['forward_to_'.$num]));
164 162
                 array_push($account['forwards'], $fwd);
165 163
             }
166 164
             $num++;
167 165
         }
168
-    if (count($account['forwards']) == 0) system_failure("Bitte mindestens eine Weiterleitungsadresse angeben.");
166
+        if (count($account['forwards']) == 0) {
167
+            system_failure("Bitte mindestens eine Weiterleitungsadresse angeben.");
168
+        }
169 169
     }
170 170
 
171
-  if ($account['password'] === NULL && count($account['forwards']) == 0) {
171
+    if ($account['password'] === null && count($account['forwards']) == 0) {
172 172
         system_failure("Entweder eine Mailbox oder eine Weiterleitung muss angegeben werden!");
173 173
     }
174 174
 
... ...
@@ -183,56 +183,48 @@ if ($_GET['action'] == 'edit')
183 183
             header('Location: vmail');
184 184
         }
185 185
     }
186
-}
187
-elseif ($_GET['action'] == 'delete')
188
-{
186
+} elseif ($_GET['action'] == 'delete') {
189 187
     $title = "E-mail-Adresse löschen";
190 188
     $section = 'vmail_vmail';
191 189
 
192 190
     $account = get_account_details((int) $_GET['id']);
193 191
 
194
-  $domain = NULL;
192
+    $domain = null;
195 193
     $domains = get_vmail_domains();
196
-  foreach ($domains as $dom)
197
-    if ($dom['id'] == $account['domain'])
198
-    {
194
+    foreach ($domains as $dom) {
195
+        if ($dom['id'] == $account['domain']) {
199 196
             $domain = $dom['domainname'];
200 197
             break;
201 198
         }
199
+    }
202 200
     $account_string = $account['local'] . "@" . $domain;
203 201
     $sure = user_is_sure();
204
-  if ($sure === NULL)
205
-  {
202
+    if ($sure === null) {
206 203
         are_you_sure("action=delete&id={$account['id']}", "Möchten Sie die E-Mail-Adresse »{$account_string}« wirklich löschen?");
207
-  }
208
-  elseif ($sure === true)
209
-  {
204
+    } elseif ($sure === true) {
210 205
         delete_account($account['id']);
211
-    if (! $debugmode)
206
+        if (! $debugmode) {
212 207
             header("Location: vmail");
213 208
         }
214
-  elseif ($sure === false)
215
-  {
216
-    if (! $debugmode)
209
+    } elseif ($sure === false) {
210
+        if (! $debugmode) {
217 211
             header("Location: vmail");
218 212
         }
219
-
220 213
     }
221
-elseif ($_GET['action'] == 'suspend')
222
-{
214
+} elseif ($_GET['action'] == 'suspend') {
223 215
     $title = "E-mail-Adresse stilllegen";
224 216
     $section = 'vmail_vmail';
225 217
 
226 218
     $account = get_account_details((int) $_GET['id']);
227 219
 
228
-  $domain = NULL;
220
+    $domain = null;
229 221
     $domains = get_vmail_domains();
230
-  foreach ($domains as $dom)
231
-    if ($dom['id'] == $account['domain'])
232
-    {
222
+    foreach ($domains as $dom) {
223
+        if ($dom['id'] == $account['domain']) {
233 224
             $domain = $dom['domainname'];
234 225
             break;
235 226
         }
227
+    }
236 228
     $account_string = $account['local'] . "@" . $domain;
237 229
   
238 230
     if (!isset($_POST['smtpreply']) || !$_POST['smtpreply']) {
... ...
@@ -241,36 +233,33 @@ elseif ($_GET['action'] == 'suspend')
241 233
     $account['smtpreply'] = $_POST['smtpreply'];
242 234
 
243 235
     save_vmail_account($account);
244
-  if (! $debugmode)
236
+    if (! $debugmode) {
245 237
         header("Location: vmail");
246 238
     }
247
-elseif ($_GET['action'] == 'unsuspend')
248
-{
239
+} elseif ($_GET['action'] == 'unsuspend') {
249 240
     $title = "E-mail-Adresse wieder aktivieren";
250 241
     $section = 'vmail_vmail';
251 242
 
252 243
     $account = get_account_details((int) $_GET['id']);
253 244
 
254
-  $domain = NULL;
245
+    $domain = null;
255 246
     $domains = get_vmail_domains();
256
-  foreach ($domains as $dom)
257
-    if ($dom['id'] == $account['domain'])
258
-    {
247
+    foreach ($domains as $dom) {
248
+        if ($dom['id'] == $account['domain']) {
259 249
             $domain = $dom['domainname'];
260 250
             break;
261 251
         }
252
+    }
262 253
     $account_string = $account['local'] . "@" . $domain;
263 254
   
264
-  $account['smtpreply'] = NULL;
255
+    $account['smtpreply'] = null;
265 256
 
266 257
     save_vmail_account($account);
267
-  if (! $debugmode)
258
+    if (! $debugmode) {
268 259
         header("Location: vmail");
269 260
     }
270
-else
261
+} else {
271 262
     system_failure("Unimplemented action");
263
+}
272 264
 
273 265
 output('');
274
-
275
-
276
-?>
... ...
@@ -20,7 +20,7 @@ if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
20 20
                         'file'    => 'vmail',
21 21
                         'icon'    => 'email.png',
22 22
                         'title'   => 'E-Mail-Adressen verwalten',
23
-                        'alert'   => NULL );
23
+                        'alert'   => null );
24 24
 }
25 25
 if ($_SESSION['role'] & ROLE_MAILACCOUNT || $_SESSION['role'] & ROLE_VMAIL_ACCOUNT) {
26 26
     $shortcuts[] = array( 'section' => 'E-Mail',
... ...
@@ -28,7 +28,7 @@ if ($_SESSION['role'] & ROLE_MAILACCOUNT || $_SESSION['role'] & ROLE_VMAIL_ACCOU
28 28
                         'file'    => 'chpass',
29 29
                         'icon'    => 'pwchange.png',
30 30
                         'title'   => 'Passwort ändern',
31
-                        'alert'   => NULL );
31
+                        'alert'   => null );
32 32
 }
33 33
 if ($_SESSION['role'] & ROLE_VMAIL_ACCOUNT) {
34 34
     $shortcuts[] = array( 'section' => 'E-Mail',
... ...
@@ -36,5 +36,5 @@ if ($_SESSION['role'] & ROLE_VMAIL_ACCOUNT) {
36 36
                         'file'    => 'edit',
37 37
                         'icon'    => 'cog.png',
38 38
                         'title'   => 'E-Mail-Einstellungen',
39
-                        'alert'   => NULL );
39
+                        'alert'   => null );
40 40
 }
... ...
@@ -29,9 +29,9 @@ if (! isset($_REQUEST['account'])) {
29 29
 $id = $_REQUEST['account'];
30 30
 $account = get_account_details($id);
31 31
 
32
-$suspended = False;
32
+$suspended = false;
33 33
 if ($account['smtpreply']) {
34
-  $suspended = True;
34
+    $suspended = true;
35 35
 } else {
36 36
     $account['smtpreply'] = 'Diese E-Mail-Adresse wird nicht mehr verwendet. 
37 37
 
... ...
@@ -57,6 +57,3 @@ output(html_form('vmail_edit_mailbox', 'save', 'action=suspend&id='.$id, $form))
57 57
 if ($suspended) {
58 58
     output("<p><strong>".internal_link('save', 'Stilllegung aufheben', 'action=unsuspend&id='.$account['id'])."</strong></p>");
59 59
 }
60
-
61
-
62
-?>
... ...
@@ -42,11 +42,8 @@ Subdomains können grundsätzlich nur durch Administratoren eingerichtet und ver
42 42
 <p>Wenn Sie die manuelle Einrichtung möchten oder keine eigene Domain nutzen, können Sie unter '.internal_link('imap', 'POP3/IMAP').' manuelle POP3-/IMAP-Konten erstellen.</p>
43 43
 
44 44
 ');
45
-}
46
-else
47
-{
48
-
49
-$filter = NULL;
45
+} else {
46
+    $filter = null;
50 47
     if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != '') {
51 48
         $filter = $_REQUEST['filter'];
52 49
     }
... ...
@@ -57,13 +54,13 @@ $domains = get_vmail_domains();
57 54
     $all_accounts = get_vmail_accounts();
58 55
 
59 56
     $sorted_by_domains = array();
60
-foreach ($all_accounts AS $account)
61
-{
62
-  if (array_key_exists($account['domain'], $sorted_by_domains))
57
+    foreach ($all_accounts as $account) {
58
+        if (array_key_exists($account['domain'], $sorted_by_domains)) {
63 59
             array_push($sorted_by_domains[$account['domain']], $account);
64
-  else
60
+        } else {
65 61
             $sorted_by_domains[$account['domain']] = array($account);
66 62
         }
63
+    }
67 64
 
68 65
     DEBUG($sorted_by_domains);
69 66
 
... ...
@@ -71,8 +68,7 @@ title('E-Mail-Accounts');
71 68
 
72 69
     addnew("edit", "Neue E-Mail-Adresse anlegen");
73 70
 
74
-if (count($domains) > 0)
75
-{
71
+    if (count($domains) > 0) {
76 72
         // Filter-Funktion
77 73
         if (count($all_accounts) > 10 || $filter) {
78 74
             $form = '<p><label for="filter">Filter für die Anzeige:</label> <input type="text" name="filter" id="filter" value="'.$filter.'"><button type="button" id="clear" title="Filter leeren">&times;</button><input type="submit" value="Filtern!"></p>';
... ...
@@ -82,14 +78,13 @@ if (count($domains) > 0)
82 78
         output('
83 79
             <p>Folgende E-Mail-Konten sind aktuell eingerichtet:</p>
84 80
             ');
85
-    foreach ($domains as $dom) 
86
-    {
81
+        foreach ($domains as $dom) {
87 82
             if ($filter && strpos($dom['domainname'], $filter) === false) {
88 83
                 // Die Domain entspricht nicht dem Filter, schau die Postfächer an
89 84
                 $account_found = false;
90 85
                 if (array_key_exists($dom['id'], $sorted_by_domains)) {
91 86
                     $accounts_on_domain = $sorted_by_domains[$dom['id']];
92
-                foreach ($accounts_on_domain AS $this_account) {
87
+                    foreach ($accounts_on_domain as $this_account) {
93 88
                         if (strpos($this_account['local'], $filter) !== false) {
94 89
                             $account_found = true;
95 90
                         }
... ...
@@ -105,8 +100,7 @@ if (count($domains) > 0)
105 100
             if (array_key_exists($dom['id'], $sorted_by_domains)) {
106 101
                 $accounts_on_domain = $sorted_by_domains[$dom['id']];
107 102
 
108
-            foreach ($accounts_on_domain AS $this_account)
109
-            {
103
+                foreach ($accounts_on_domain as $this_account) {
110 104
                     if ($filter &&
111 105
                     (strpos($dom['domainname'], $filter) === false &&
112 106
                      strpos($this_account['local'], $filter) === false)) {
... ...
@@ -115,8 +109,7 @@ if (count($domains) > 0)
115 109
                     $acc = get_account_details($this_account['id']);
116 110
                     $actions = array();
117 111
                     DEBUG($acc);
118
-                if ($acc['password'] != '')
119
-                {
112
+                    if ($acc['password'] != '') {
120 113
                         $percent = round(($acc["quota_used"] / $acc["quota"]) * 100);
121 114
                         $color = ($percent > 95 ? 'red' : ($percent > 75 ? "yellow" : "green"));
122 115
                         $width = 2 * min($percent, 100);
... ...
@@ -129,12 +122,12 @@ if (count($domains) > 0)
129 122
                         $valid_from_string = date('d.m.Y', strtotime($acc['autoresponder']['valid_from']));
130 123
                         $valid_until = $acc['autoresponder']['valid_until'];
131 124
                         $valid_until_string = date('d.m.Y', strtotime($acc['autoresponder']['valid_until']));
132
-                    if ($valid_from == NULL) {
125
+                        if ($valid_from == null) {
133 126
                             // Autoresponder abgeschaltet
134 127
                         //array_push($actions, "<strike>Automatische Antwort versenden</strike> (Abgeschaltet)");
135 128
                         } elseif ($valid_from > $now) {
136 129
                             array_push($actions, "<strike>Automatische Antwort versenden</strike> (Wird aktiviert am {$valid_from_string})");
137
-                    } elseif ($valid_until == NULL) {
130
+                        } elseif ($valid_until == null) {
138 131
                             array_push($actions, "Automatische Antwort versenden (Unbefristet)");
139 132
                         } elseif ($valid_until > $now) {
140 133
                             array_push($actions, "Automatische Antwort versenden (Wird deaktiviert am {$valid_until_string})");
... ...
@@ -142,17 +135,16 @@ if (count($domains) > 0)
142 135
                             array_push($actions, "<strike>Automatische Antwort versenden</strike> (Automatisch abgeschaltet seit {$valid_until_string})");
143 136
                         }
144 137
                     }
145
-                foreach ($acc['forwards'] AS $fwd)
146
-                {
138
+                    foreach ($acc['forwards'] as $fwd) {
147 139
                         $fwd['destination'] = filter_input_general($fwd['destination']);
148 140
                         array_push($actions, "Weiterleitung an <strong>{$fwd['destination']}</strong>");
149 141
                     }
150 142
                     $dest = '';
151
-                if (count($actions) > 0)
152
-                {
143
+                    if (count($actions) > 0) {
153 144
                         $dest = "<ul>";
154
-                    foreach ($actions as $a)
145
+                        foreach ($actions as $a) {
155 146
                             $dest .= "<li>{$a}</li>";
147
+                        }
156 148
                         $dest .= '</ul>';
157 149
                     }
158 150
                     if ($acc['smtpreply']) {
... ...
@@ -169,16 +161,11 @@ if (count($domains) > 0)
169 161
             addnew("edit", "Neue E-Mail-Adresse anlegen", "domain={$dom['id']}");
170 162
             output('</div>');
171 163
         }
172
-}
173
-else
174
-{
164
+    } else {
175 165
         output('<p><em>Es sind bisher keine Ihrer Domains für Mail-Empfang eingerichtet.</em></p>');
176 166
     }
177 167
 
178 168
 
179 169
     /* FIXME: Das sollte nur kommen, wenn der IMAP/POP3-Menü-Eintrag nicht da ist */
180 170
     output('<p style="font-size: 90%;padding-top: 0.5em; border-top: 1px solid black;">Hinweis: '.config('company_name').' bietet für fortgeschrittene Nutzer die manuelle Einrichtung von POP3/IMAP-Accounts.<br/>'.internal_link("imap", "Neuen POP3/IMAP-Account anlegen", "action=create").'</p>');
181
-
182 171
 }
183
-
184
-?>
... ...
@@ -45,12 +45,12 @@ if ($acc['autoresponder']) {
45 45
     $valid_from_string = date('d.m.Y', strtotime($acc['autoresponder']['valid_from']));
46 46
     $valid_until = $acc['autoresponder']['valid_until'];
47 47
     $valid_until_string = date('d.m.Y', strtotime($acc['autoresponder']['valid_until']));
48
-  if ($valid_from == NULL) {
48
+    if ($valid_from == null) {
49 49
         // Autoresponder abgeschaltet
50 50
     //$content .= '<p>'.other_icon('go.png')." Es wird keine automatische Antwort versendet</p>";
51 51
     } elseif ($valid_from > $now) {
52 52
         $content .= '<p>'.other_icon('go.png')." Es wird ab dem {$valid_from_string} eine automatische Antwort versendet</p>";
53
-  } elseif ($valid_until == NULL) {
53
+    } elseif ($valid_until == null) {
54 54
         $content .= '<p>'.other_icon('go.png')." Es wird eine automatische Antwort versendet</p>";
55 55
     } elseif ($valid_until > $now) {
56 56
         $content .= '<p>'.other_icon('go.png')." Es wird eine automatische Antwort versendet, jedoch nicht mehr ab dem {$valid_until_string}</p>";
... ...
@@ -59,8 +59,7 @@ if ($acc['autoresponder']) {
59 59
     }
60 60
 }
61 61
 
62
-foreach ($acc['forwards'] AS $fwd)
63
-{
62
+foreach ($acc['forwards'] as $fwd) {
64 63
     $fwd['destination'] = filter_input_general($fwd['destination']);
65 64
     $content .= '<p>'.other_icon('go.png')." Weiterleitung an <strong>{$fwd['destination']}</strong></p>";
66 65
 }
... ...
@@ -68,5 +67,3 @@ foreach ($acc['forwards'] AS $fwd)
68 67
 
69 68
 $content .= '<h3>Nachrichten-Abruf</h3>
70 69
 <p>'.internal_link('/go/email/logindata', 'Zugangsdaten für E-Mail-Abruf anzeigen', 'server='.get_server_by_id($acc['server']).'&type=vmail').'</p>';
71
-
72
-?>
... ...
@@ -29,22 +29,18 @@ output('
29 29
 <p>Als Zusatzleistung bieten wir Ihnen die Möglichkeit, weitere FTP-Benutzerzugänge anzulegen. Diese Zugänge sind auf das angegebene Verzeichnis beschränkt und es kann nur mit dem FTP-Protokoll verwendet werden. Ein Login mittels SSH ist für diese Benutzerkonten nicht möglich.</p>');
30 30
 
31 31
 
32
-if (count($ftpusers) > 0)
33
-{
32
+if (count($ftpusers) > 0) {
34 33
     output('
35 34
 <table><tr><th>Benutzername</th><th>Verzeichnis</th><th>aktiv</th><th>&#160;</th></tr>
36 35
 ');
37 36
 
38
-  foreach ($ftpusers AS $f)
39
-  {
37
+    foreach ($ftpusers as $f) {
40 38
         $sslwarning = ($f['forcessl'] == 0 ? icon_warning('Unverschlüsselte Verbindungen werden erlaubt') : '');
41 39
         $active = ($f['active'] == 1 ? icon_enabled('Ja') : '-');
42 40
         output("<tr><td>".internal_link("edit?id={$f['id']}", $f['username'])."</td><td>{$f['homedir']}</td><td style=\"text-align: center;\">{$active} {$sslwarning}</td><td>".internal_link("save?delete={$f['id']}", icon_delete("{$f['username']} löschen"))."</td></tr>");
43 41
     }
44 42
     output('</table>');
45
-}
46
-else
47
-{
43
+} else {
48 44
     output('<p><em>Sie haben bisher keine zusätzlichen FTP-Benutzer angelegt</em></p>');
49 45
 }
50 46
 
... ...
@@ -58,11 +54,8 @@ output('<h3>Haupt-Account mittels FTP nutzen</h3>
58 54
 
59 55
 $token = generate_form_token('regular_ftp');
60 56
 
61
-if ($regular_ftp)
62
-{
57
+if ($regular_ftp) {
63 58
     output('<p>'.icon_enabled().' Momentan ist der Zugriff über FTP <strong>aktiviert</strong>. Wenn Sie diesen nicht benötigen sollten Sie ihn aus Sicherheitsgründen ausschalten.<br />'.internal_link('save', 'FTP-Zugriff für Haupt-Account sperren', 'regular_ftp=no&token='.$token).'</p>');
64
-}
65
-else
66
-{
59
+} else {
67 60
     output('<p>Der Zugriff Ihres Haupt-Accounts über FTP ist momentan abgeschaltet. Aktivieren Sie diesen nur wenn Sie ihn auch nutzen möchten.<br />'.internal_link("save", 'FTP-Zugriff für Haupt-Account freischalten', 'regular_ftp=yes&token='.$token).'</p>');
68 61
 }
... ...
@@ -23,13 +23,13 @@ $section='ftpusers_accounts';
23 23
 
24 24
 $ftpuser = empty_ftpuser();
25 25
 
26
-if (isset($_GET['id']))
26
+if (isset($_GET['id'])) {
27 27
     $ftpuser = load_ftpuser($_GET['id']);
28
+}
28 29
 
29
-if ($ftpuser['username'])
30
+if ($ftpuser['username']) {
30 31
     title('Ändern des FTP-Benutzers');
31
-else
32
-{
32
+} else {
33 33
     title('Neuer FTP-Zugang');
34 34
     output('<p style="border: 2px solid red; padding: 1em; padding-left: 4em;"><img src="'.$prefix.'images/warning.png" style="margin-left: -3em; float: left;" /><strong>Bitte beachten Sie:</strong> Ein FTP-Benutzer kann nur im hier angegebenen Verzeichnis (und dallen darin enthaltenen Verzeichnissen) Dateien erstellen oder ändern. Sofern der Benutzer allerdings die Möglichkeit hat, PHP- oder CGI-Programme zu installieren und über den Webserver aufzurufen, kann er damit auch außerhalb dieses Verzeichnisses agieren. Schalten Sie bitte ggf. die PHP- und CGI-Unterstützung für die betreffende Website aus.</p>');
35 35
 }
... ...
@@ -47,11 +47,11 @@ $servers = server_names();
47 47
 $available_servers = array_merge(array(my_server_id()), additional_servers());
48 48
 
49 49
 $whichserver = '<strong>'.$servers[my_server_id()].'</strong>';
50
-if (count($available_servers) > 1)
51
-{
50
+if (count($available_servers) > 1) {
52 51
     $serverselect = array();
53
-  foreach ($available_servers AS $s)
52
+    foreach ($available_servers as $s) {
54 53
         $serverselect[$s] = $servers[$s];
54
+    }
55 55
     $whichserver = html_select('server', $serverselect, $ftpuser['server']);
56 56
 }
57 57
   
... ...
@@ -35,12 +35,14 @@ function empty_ftpuser()
35 35
 
36 36
 function load_ftpuser($id)
37 37
 {
38
-  if ($id == 0)
38
+    if ($id == 0) {
39 39
         return empty_ftpuser();
40
+    }
40 41
     $args = array(":id" => $id, ":uid" => $_SESSION['userinfo']['uid']);
41 42
     $result = db_query("SELECT id, username, password, homedir, active, forcessl, server FROM system.ftpusers WHERE uid=:uid AND id=:id", $args);
42
-  if ($result->rowCount() != 1)
43
+    if ($result->rowCount() != 1) {
43 44
         system_failure("Fehler beim auslesen des Accounts");
45
+    }
44 46
     $account = $result->fetch();
45 47
     DEBUG($account);
46 48
     return $account;
... ...
@@ -50,45 +52,39 @@ function load_ftpuser($id)
50 52
 function save_ftpuser($data)
51 53
 {
52 54
     verify_input_username($data['username']);
53
-  if ($data['username'] == '')
55
+    if ($data['username'] == '') {
54 56
         system_failure('Bitte geben Sie eine Erweiterung für den Benutzernamen an!');
57
+    }
55 58
     $homedir = filter_input_general($data['homedir']);
56
-  if (substr($homedir, 0, 1) == '/')
59
+    if (substr($homedir, 0, 1) == '/') {
57 60
         $homedir = substr($homedir, 1);
61
+    }
58 62
     $homedir = $_SESSION['userinfo']['homedir'].'/'.$homedir;
59
-  if (! in_homedir($homedir))
63
+    if (! in_homedir($homedir)) {
60 64
         system_failure('Pfad scheint nicht in Ihrem Home zu sein oder enthielt ungültige Zeichen.');
61
-
62
-  $server = NULL;
63
-  if ($data['server'] == my_server_id())
64
-  {
65
-    $server = NULL;
66 65
     }
67
-  elseif (in_array($data['server'], additional_servers()))
68
-  {
66
+
67
+    $server = null;
68
+    if ($data['server'] == my_server_id()) {
69
+        $server = null;
70
+    } elseif (in_array($data['server'], additional_servers())) {
69 71
         $server = (int) $data['server'];
70 72
     }
71 73
 
72 74
     $set_password = false;
73 75
     $password_hash = '';
74
-  if ($data['password'] != '')
75
-  {
76
-    if (defined("CRYPT_SHA512") && CRYPT_SHA512 == 1)
77
-    {
76
+    if ($data['password'] != '') {
77
+        if (defined("CRYPT_SHA512") && CRYPT_SHA512 == 1) {
78 78
             $rounds = rand(1000, 5000);
79 79
             $salt = "rounds=".$rounds."$".random_string(8);
80 80
             $password_hash = crypt($data['password'], "\$6\${$salt}\$");
81
-    }
82
-    else
83
-    {
81
+        } else {
84 82
             $salt = random_string(8);
85 83
             $password_hash = crypt($data['password'], "\$1\${$salt}\$");
86 84
         }
87 85
         $set_password = true;
88 86
         $password_query = "password='{$password_hash}', ";
89
-  }
90
-  elseif (! $data['id'])
91
-  {
87
+    } elseif (! $data['id']) {
92 88
         system_failure('Wenn Sie einen neuen Zugang anlegen, müssen Sie ein Passwort setzen');
93 89
     }
94 90
     
... ...
@@ -124,12 +120,14 @@ function delete_ftpuser($id)
124 120
 function get_gid($groupname)
125 121
 {
126 122
     $result = db_query("SELECT gid FROM system.gruppen WHERE name=?", array($groupname));
127
-  if ($result->rowCount() != 1)
123
+    if ($result->rowCount() != 1) {
128 124
         system_failure('cannot determine gid of ftpusers group');
125
+    }
129 126
     $a = $result->fetch();
130 127
     $gid = (int) $a['gid'];
131
-  if ($gid == 0)
128
+    if ($gid == 0) {
132 129
         system_failure('error on determining gid of ftpusers group');
130
+    }
133 131
     return $gid;
134 132
 }
135 133
 
... ...
@@ -16,13 +16,10 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
16 16
 
17 17
 $role = $_SESSION['role'];
18 18
 
19
-if ($role & ROLE_SYSTEMUSER)
20
-{
19
+if ($role & ROLE_SYSTEMUSER) {
21 20
     if (have_module('systemuser')) {
22 21
         $menu["ftpusers_accounts"] = array("label" => "FTP-Zugriff", "file" => "accounts", "weight" => 35, 'submenu' => 'systemuser_account');
23 22
     } else {
24 23
         $menu["ftpusers_accounts"] = array("label" => "FTP-Zugriff", "file" => "accounts", "weight" => 35);
25 24
     }
26 25
 }
27
-
28
-?>
... ...
@@ -18,39 +18,31 @@ include('ftpusers.php');
18 18
 
19 19
 require_role(ROLE_SYSTEMUSER);
20 20
 
21
-if (isset($_GET['regular_ftp']))
22
-{
21
+if (isset($_GET['regular_ftp'])) {
23 22
     check_form_token('regular_ftp', $_REQUEST['token']);
24 23
     if ($_GET['regular_ftp'] == 'yes') {
25 24
         $sure = user_is_sure();
26
-    if ($sure === NULL)
27
-    {
25
+        if ($sure === null) {
28 26
             are_you_sure("regular_ftp=yes&token=".$_REQUEST['token'], "Benötigen Sie wirklich klassischen FTP-Zugriff für Ihren Benutzeraccount? Lesen Sie die Hinweise in unserem Wiki falls Sie sich nicht sicher sind.");
29 27
             return;
30
-    }
31
-    elseif ($sure === true)
32
-    {
28
+        } elseif ($sure === true) {
33 29
             enable_regular_ftp();
34 30
         }
35
-  }
36
-  else
31
+    } else {
37 32
         disable_regular_ftp();
33
+    }
38 34
     redirect('accounts');
39 35
 }
40 36
 
41 37
 
42
-if (isset($_GET['delete']))
43
-{
38
+if (isset($_GET['delete'])) {
44 39
     $ftpuser = load_ftpuser($_GET['delete']);
45 40
 
46 41
     $sure = user_is_sure();
47
-  if ($sure === NULL)
48
-  {
42
+    if ($sure === null) {
49 43
         are_you_sure("delete={$ftpuser['id']}", "Möchten Sie den FTP-Zugang »{$ftpuser['username']}« wirklich löschen?");
50 44
         return;
51
-  }
52
-  elseif ($sure === true)
53
-  {
45
+    } elseif ($sure === true) {
54 46
         delete_ftpuser($ftpuser['id']);
55 47
     }
56 48
     redirect('accounts');
... ...
@@ -58,8 +50,7 @@ if (isset($_GET['delete']))
58 50
 
59 51
 $ftpuser = empty_ftpuser();
60 52
 
61
-if (isset($_GET['id']))
62
-{
53
+if (isset($_GET['id'])) {
63 54
     check_form_token('ftpusers_edit');
64 55
     $ftpuser = load_ftpuser($_GET['id']);
65 56
 }
... ...
@@ -68,18 +59,21 @@ if (isset($_GET['id']))
68 59
 $ftpuser['username'] = $_REQUEST['ftpusername'];
69 60
 $ftpuser['password'] = $_REQUEST['password'];
70 61
 $ftpuser['homedir'] = $_REQUEST['homedir'];
71
-if (isset($_REQUEST['active']))
62
+if (isset($_REQUEST['active'])) {
72 63
     $ftpuser['active'] = $_REQUEST['active'];
73
-else
64
+} else {
74 65
     $ftpuser['active'] = 0;
66
+}
75 67
 
76
-if (isset($_REQUEST['forcessl']))
68
+if (isset($_REQUEST['forcessl'])) {
77 69
     $ftpuser['forcessl'] = $_REQUEST['forcessl'];
78
-else
70
+} else {
79 71
     $ftpuser['forcessl'] = 0;
72
+}
80 73
 
81
-if (isset($_REQUEST['server']))
74
+if (isset($_REQUEST['server'])) {
82 75
     $ftpuser['server'] = $_REQUEST['server'];
76
+}
83 77
 
84 78
   
85 79
 save_ftpuser($ftpuser);
... ...
@@ -27,22 +27,19 @@ if (isset($_GET['repo'])) {
27 27
     }
28 28
 
29 29
     $sure = user_is_sure();
30
-  if ($sure === NULL)
31
-  {
30
+    if ($sure === null) {
32 31
         are_you_sure("repo={$_GET['repo']}", '<p>Soll das GIT-Repository »'.$_GET['repo'].'« wirklich gelöscht werden?</p>
33 32
     <p>Alle Inhalte die in diesem Repository gespeichert sind, werden gelöscht!</p>');
34
-  }
35
-  elseif ($sure === true)
36
-  {
33
+    } elseif ($sure === true) {
37 34
         delete_repo($_GET['repo']);
38
-    if (! $debugmode)
35
+        if (! $debugmode) {
39 36
             header('Location: git');
40
-    die();
41 37
         }
42
-  elseif ($sure === false)
43
-  {
44
-    if (! $debugmode)
38
+        die();
39
+    } elseif ($sure === false) {
40
+        if (! $debugmode) {
45 41
             header("Location: git");
42
+        }
46 43
         die();
47 44
     }
48 45
 }
... ...
@@ -54,21 +51,18 @@ if (isset($_GET['handle'])) {
54 51
     }
55 52
 
56 53
     $sure = user_is_sure();
57
-  if ($sure === NULL)
58
-  {
54
+    if ($sure === null) {
59 55
         are_you_sure("handle={$_GET['handle']}", '<p>Soll der SSH-Key »'.$_GET['handle'].'« wirklich gelöscht werden?</p>');
60
-  }
61
-  elseif ($sure === true)
62
-  {
56
+    } elseif ($sure === true) {
63 57
         delete_key($_GET['handle']);
64
-    if (! $debugmode)
58
+        if (! $debugmode) {
65 59
             header('Location: git');
66
-    die();
67 60
         }
68
-  elseif ($sure === false)
69
-  {
70
-    if (! $debugmode)
61
+        die();
62
+    } elseif ($sure === false) {
63
+        if (! $debugmode) {
71 64
             header("Location: git");
65
+        }
72 66
         die();
73 67
     }
74 68
 }
... ...
@@ -80,21 +74,18 @@ if (isset($_GET['foreignhandle'])) {
80 74
     }
81 75
 
82 76
     $sure = user_is_sure();
83
-  if ($sure === NULL)
84
-  {
77
+    if ($sure === null) {
85 78
         are_you_sure("foreignhandle={$_GET['foreignhandle']}", '<p>Soll der GIT-Benutzer »'.$_GET['foreignhandle'].'« wirklich aus Ihrer Konfiguration werden?</p>');
86
-  }
87
-  elseif ($sure === true)
88
-  {
79
+    } elseif ($sure === true) {
89 80
         delete_foreign_user($_GET['foreignhandle']);
90
-    if (! $debugmode)
81
+        if (! $debugmode) {
91 82
             header('Location: git');
92
-    die();
93 83
         }
94
-  elseif ($sure === false)
95
-  {
96
-    if (! $debugmode)
84
+        die();
85
+    } elseif ($sure === false) {
86
+        if (! $debugmode) {
97 87
             header("Location: git");
88
+        }
98 89
         die();
99 90
     }
100 91
 }
... ...
@@ -46,11 +46,13 @@ function check_env()
46 46
 }
47 47
 
48 48
 
49
-function validate_name($name) {
49
+function validate_name($name)
50
+{
50 51
     return (preg_match('/^[[:alnum:]][[:alnum:]._-]*$/', $name));
51 52
 }
52 53
 
53
-function get_git_url($repo) {
54
+function get_git_url($repo)
55
+{
54 56
     $remote = git_wrapper('remote --verbose');
55 57
     DEBUG('gitolite-admin repo: '.$remote[0]);
56 58
     $url = preg_replace('#^.*\s+(\S+):gitolite-admin.*#', '$1', $remote[0]);
... ...
@@ -98,20 +100,20 @@ function list_repos()
98 100
 
99 101
     $repos = array();
100 102
     $lines = file($userconfig);
101
-  $current_repo = NULL;
103
+    $current_repo = null;
102 104
     $current_repo_users = array();
103 105
     foreach ($lines as $line) {
104 106
         DEBUG("LINE: ".$line);
105 107
         $m = array();
106 108
         if (preg_match('/^(\S+) "[^"]+" = "([^"]+)"$/', $line, $m) != 0) {
107 109
             if (!array_key_exists($m[1], $repos)) {
108
-        $repos[$m[1]] = array('users' => NULL, 'description' => '');
110
+                $repos[$m[1]] = array('users' => null, 'description' => '');
109 111
             }
110 112
             DEBUG("found description: {$m[1]} = \"{$m[2]}\"");
111 113
             $repos[$m[1]]['description'] = $m[2];
112 114
         } elseif (preg_match('_^\s*repo (\S+)\s*$_', $line, $m) != 0) {
113 115
             if (!array_key_exists($m[1], $repos)) {
114
-        $repos[$m[1]] = array('users' => NULL, 'description' => '');
116
+                $repos[$m[1]] = array('users' => null, 'description' => '');
115 117
             }
116 118
             if ($current_repo) {
117 119
                 $repos[$current_repo]['users'] = $current_repo_users;
... ...
@@ -133,7 +135,8 @@ function list_repos()
133 135
 }
134 136
 
135 137
 
136
-function list_users() {
138
+function list_users()
139
+{
137 140
     global $config_file, $config_dir;
138 141
     $username = $_SESSION['userinfo']['username'];
139 142
     $userconfig = $config_dir . '/' . $username . '.conf';
... ...
@@ -159,7 +162,8 @@ function list_users() {
159 162
     return $users;
160 163
 }
161 164
 
162
-function list_foreign_users() {
165
+function list_foreign_users()
166
+{
163 167
     global $config_file, $config_dir;
164 168
     $username = $_SESSION['userinfo']['username'];
165 169
     $userconfig = $config_dir . '/' . $username . '.conf';
... ...
@@ -185,7 +189,8 @@ function list_foreign_users() {
185 189
     return $users;
186 190
 }
187 191
 
188
-function get_pubkey($handle) {
192
+function get_pubkey($handle)
193
+{
189 194
     global $key_dir;
190 195
     if (! validate_name($handle)) {
191 196
         return '';
... ...
@@ -373,7 +375,8 @@ function delete_key($handle)
373 375
 }
374 376
 
375 377
 
376
-function remove_repo_from_array($data, $repo) {
378
+function remove_repo_from_array($data, $repo)
379
+{
377 380
     DEBUG("Request to remove repo »{$repo}«...");
378 381
     $inside = false;
379 382
     $outdata = array();
... ...
@@ -439,8 +442,7 @@ function set_user_include()
439 442
 {
440 443
     global $config_file, $userconfig;
441 444
     $username = $_SESSION['userinfo']['username'];
442
-  if (!file_exists($userconfig))
443
-  {
445
+    if (!file_exists($userconfig)) {
444 446
         // Erzeuge eine leere Konfiguration damit das Include auf jeden Fall funktionieren kann
445 447
         file_put_contents($userconfig, '');
446 448
         git_wrapper('add '.$userconfig);
... ...
@@ -19,6 +19,3 @@ $role = $_SESSION['role'];
19 19
 if ($role & ROLE_SYSTEMUSER) {
20 20
     $menu["git_git"] = array("label" => "Git-Zugänge", "file" => "git", "weight" => 1, "submenu" => "systemuser_account");
21 21
 }
22
-
23
-
24
-?>
... ...
@@ -32,8 +32,9 @@ if ($_GET['action'] == 'newuser') {
32 32
         system_failure("Ein Benutzer mit diesem Namen existiert bereits.");
33 33
     }
34 34
     newkey($_POST['pubkey'], $handle);
35
-  if (! $debugmode)
35
+    if (! $debugmode) {
36 36
         header('Location: git');
37
+    }
37 38
     die();
38 39
 } elseif ($_GET['action'] == 'newforeignuser') {
39 40
     check_form_token('git_newforeignuser');
... ...
@@ -46,8 +47,9 @@ if ($_GET['action'] == 'newuser') {
46 47
         system_failure("Diesen Benutzer haben Sie bereits hinzugefügt.");
47 48
     }
48 49
     new_foreign_user($handle);
49
-  if (! $debugmode)
50
+    if (! $debugmode) {
50 51
         header('Location: git');
52
+    }
51 53
     die();
52 54
 } elseif ($_GET['action'] == 'newkey') {
53 55
     check_form_token('git_newkey');
... ...
@@ -56,8 +58,9 @@ if ($_GET['action'] == 'newuser') {
56 58
         system_failure("Leere Benutzerbezeichnung!");
57 59
     }
58 60
     newkey($_POST['pubkey'], $handle);
59
-  if (! $debugmode)
61
+    if (! $debugmode) {
60 62
         header('Location: git');
63
+    }
61 64
     die();
62 65
 } elseif ($_GET['action'] == 'newrepo' || $_GET['action'] == 'editrepo') {
63 66
     check_form_token('git_edit');
... ...
@@ -80,14 +83,11 @@ if ($_GET['action'] == 'newuser') {
80 83
         $permissions['daemon'] = 'R';
81 84
         $description = $_POST['description'];
82 85
     } else {
83
-    $description = NULL;
86
+        $description = null;
84 87
     }
85 88
     save_repo($_POST['repo'], $permissions, $description);
86
-  if (! $debugmode)
89
+    if (! $debugmode) {
87 90
         header('Location: git');
91
+    }
88 92
     die();
89
-  
90 93
 }
91
-
92
-
93
-
... ...
@@ -19,8 +19,9 @@ function whitelist_entries()
19 19
     $uid = (int) $_SESSION['userinfo']['uid'];
20 20
     $res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid=?", array($uid));
21 21
     $return = array();
22
-	while ($line = $res->fetch())
22
+    while ($line = $res->fetch()) {
23 23
         array_push($return, $line);
24
+    }
24 25
     return $return;
25 26
 }
26 27
 
... ...
@@ -30,8 +31,9 @@ function get_whitelist_details($id)
30 31
     $args = array(":id" => $id,
31 32
                 ":uid" => $_SESSION['userinfo']['uid']);
32 33
     $res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid=:uid AND id=:id", $args);
33
-	if ($res->rowCount() != 1)
34
+    if ($res->rowCount() != 1) {
34 35
         system_failure('Kann diesen Eintrag nicht finden');
36
+    }
35 37
     return $res->fetch();
36 38
 }
37 39
 
... ...
@@ -48,18 +50,19 @@ function delete_from_whitelist($id)
48 50
 
49 51
 function valid_entry($local, $domain)
50 52
 {
51
-	if ($domain == 'schokokeks.org')
52
-	{
53
+    if ($domain == 'schokokeks.org') {
53 54
         if (($local != $_SESSION['userinfo']['username']) &&
54
-		    (strpos($local, $_SESSION['userinfo']['username'].'-') !== 0))
55
+            (strpos($local, $_SESSION['userinfo']['username'].'-') !== 0)) {
55 56
             system_failure('Diese E-Mail-Adresse gehört Ihnen nicht!');
57
+        }
56 58
         return true;
57 59
     }
58 60
     $args = array(":domain" => $domain,
59 61
                 ":uid" => $_SESSION['userinfo']['uid']);
60 62
     $res = db_query("SELECT id FROM mail.v_domains WHERE domainname=:domain AND user=:uid", $args);
61
-	if ($res->rowCount() != 1)
63
+    if ($res->rowCount() != 1) {
62 64
         system_failure('Diese domain gehört Ihnen nicht!');
65
+    }
63 66
     return true;
64 67
 }
65 68
 
... ...
@@ -81,6 +84,3 @@ function new_whitelist_entry($local, $domain, $minutes)
81 84
     db_query("INSERT INTO mail.greylisting_manual_whitelist (local,domain,date,expire,uid) VALUES ".
82 85
              "(:local, :domain, NOW(), {$expire}, :uid)", $args);
83 86
 }
84
-
85
-
86
-?>
... ...
@@ -16,9 +16,6 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
16 16
 
17 17
 $role = $_SESSION['role'];
18 18
 
19
-if ($role & ROLE_SYSTEMUSER)
20
-{
19
+if ($role & ROLE_SYSTEMUSER) {
21 20
     $menu['greylisting_whitelist'] = array("label" => "Greylisting", "file" => "whitelist", "weight" => 5, 'submenu' => 'email_vmail');
22 21
 }
23
-
24
-?>
... ...
@@ -20,47 +20,39 @@ require_once('inc/security.php');
20 20
 require_once('greylisting.php');
21 21
 
22 22
 
23
-if ($_GET['action'] == 'delete')
24
-{
23
+if ($_GET['action'] == 'delete') {
25 24
     $entry = get_whitelist_details($_GET['id']);
26 25
     $sure = user_is_sure();
27
-  if ($sure === NULL)
28
-  {
26
+    if ($sure === null) {
29 27
         are_you_sure("action=delete&id={$entry['id']}", "Möchten Sie die E-Mail-Adresse »{$entry['local']}@{$entry['domain']}« von der Ausnahmeliste entfernen?");
30
-  }
31
-  elseif ($sure === true)
32
-  {
28
+    } elseif ($sure === true) {
33 29
         delete_from_whitelist($entry['id']);
34
-    if (! $debugmode)
30
+        if (! $debugmode) {
35 31
             header("Location: whitelist");
36 32
         }
37
-  elseif ($sure === false)
38
-  {
39
-    if (! $debugmode)
33
+    } elseif ($sure === false) {
34
+        if (! $debugmode) {
40 35
             header("Location: whitelist");
41 36
         }
42 37
     }
43
-elseif ($_GET['action'] == 'add')
44
-{
38
+} elseif ($_GET['action'] == 'add') {
45 39
     check_form_token('greylisting_add');
46 40
     if (!filter_var($_POST['address'], FILTER_VALIDATE_EMAIL)
47
-		&& !filter_var("x@".$_POST['address'], FILTER_VALIDATE_EMAIL) )
41
+        && !filter_var("x@".$_POST['address'], FILTER_VALIDATE_EMAIL)) {
48 42
         system_failure("Sie haben eine ungültige Mailadresse eingegeben.");
43
+    }
49 44
     $local = false;
50 45
     $domain = '';
51 46
     $at = strrpos($_POST['address'], '@');
52
-	if ($at === false)
47
+    if ($at === false) {
53 48
         $domain = $_POST['address'];
54
-	else
55
-	{
49
+    } else {
56 50
         $local = substr($_POST['address'], 0, $at);
57 51
         $domain = substr($_POST['address'], $at+1);
58 52
     }
59 53
     DEBUG("Whitelisting {$local}@{$domain} for {$_POST['expire']} minutes");
60 54
     new_whitelist_entry($local, $domain, $_POST['expire']);
61
-	if (! $debugmode)	
55
+    if (! $debugmode) {
62 56
         header("Location: whitelist");
63
-
64 57
     }
65
-
66
-?>
58
+}
... ...
@@ -44,11 +44,11 @@ $form = "<table>
44 44
     <tr><th>Empfänger-Adresse</th><th>seit</th><th>bis</th><th> </th></tr>
45 45
     ";
46 46
 
47
-foreach ($whitelist AS $entry)
48
-{
47
+foreach ($whitelist as $entry) {
49 48
     $end = $entry['expire'];
50
-	if (! $end)
49
+    if (! $end) {
51 50
         $end = '<em>unbegrenzt</em>';
51
+    }
52 52
     $local = $entry['local'];
53 53
     if (empty($local)) {
54 54
         $local = '*';
... ...
@@ -65,5 +65,3 @@ $form .= '<p><input type="submit" value="Speichern" /></p>';
65 65
 output(html_form('greylisting_add', 'save', 'action=add', $form));
66 66
 
67 67
 output('<p></p>');
68
-
69
-?>
... ...
@@ -24,29 +24,29 @@ $account = $_SESSION['accountname'];
24 24
 
25 25
 title("Passwort ändern");
26 26
 
27
-if ($_POST['password1'] != '')
28
-{
27
+if ($_POST['password1'] != '') {
29 28
     check_form_token('imap_chpass');
30 29
     $result = find_role($_SESSION['mailaccount'], $_POST['old_password']);
31 30
 
32
-  if ($_POST['old_password'] == '')
31
+    if ($_POST['old_password'] == '') {
33 32
         input_error('Altes Passwort nicht angegeben!');
34
-  elseif (! $result & ROLE_MAILACCOUNT)
33
+    } elseif (! $result & ROLE_MAILACCOUNT) {
35 34
         input_error('Das bisherige Passwort ist nicht korrekt!');
36
-  elseif ($_POST['password2'] != $_POST['password1'])
35
+    } elseif ($_POST['password2'] != $_POST['password1']) {
37 36
         input_error('Die Bestätigung ist nicht identisch mit dem neuen Passwort!');
38
-  elseif ($_POST['password2'] == '')
37
+    } elseif ($_POST['password2'] == '') {
39 38
         input_error('Sie müssen das neue Passwort zweimal eingeben!');
40
-  elseif (($check = strong_password($_POST['password1'])) !== true)
39
+    } elseif (($check = strong_password($_POST['password1'])) !== true) {
41 40
         input_error("Das Passwort ist zu einfach ({$check})!");
42
-  else {
41
+    } else {
43 42
         change_mailaccount(get_mailaccount_id($_SESSION['mailaccount']), array('password' => $_POST['password1']));
44
-    if (! $debugmode)
43
+        if (! $debugmode) {
45 44
             header('Location: chpass');
46
-    else
45
+        } else {
47 46
             output('');
48 47
         }
49 48
     }
49
+}
50 50
 
51 51
 
52 52
 
... ...
@@ -65,8 +65,3 @@ output('<p>Hier können Sie Ihr Passwort ändern.</p>
65 65
 </table>
66 66
 <p><input type="submit" value="Speichern" /></p>
67 67
 '));
68
-
69
-
70
-
71
-
72
-?>
... ...
@@ -19,14 +19,8 @@ require_once('include/hasdomain.php');
19 19
 
20 20
 $role = $_SESSION['role'];
21 21
 
22
-if ($role & ROLE_SYSTEMUSER && (user_has_accounts() || ! user_has_vmail_domain() || user_has_dotcourier_domain() ) )
23
-{
22
+if ($role & ROLE_SYSTEMUSER && (user_has_accounts() || ! user_has_vmail_domain() || user_has_dotcourier_domain())) {
24 23
     $menu["imap_accounts"] = array("label" => "IMAP/POP3", "file" => "accounts", "weight" => 10);
25
-}
26
-elseif ($role & ROLE_MAILACCOUNT)
27
-{
24
+} elseif ($role & ROLE_MAILACCOUNT) {
28 25
     $menu["imap_chpass"] = array("label" => "Passwort ändern", "file" => "chpass", "weight" => 10);
29 26
 }
30
-
31
-
32
-?>
... ...
@@ -26,15 +26,14 @@ output('<p>Sie können Sie an diesem Webinterface wahlweise auch über ein SSL-C
26 26
 
27 27
 
28 28
 
29
-if (isset($_GET['clear']))
30
-{
29
+if (isset($_GET['clear'])) {
31 30
     unset($_SESSION['clientcert_cert']);
32 31
     unset($_SESSION['clientcert_dn']);
33 32
     unset($_SESSION['clientcert_issuer']);
34 33
     unset($_SESSION['clientcert_serial']);
35 34
 }
36 35
 
37
-$username = NULL;
36
+$username = null;
38 37
 if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
39 38
     $username = $_SESSION['userinfo']['username'];
40 39
     if (isset($_SESSION['subuser'])) {
... ...
@@ -44,8 +43,7 @@ if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
44 43
     $username = $_SESSION['mailaccount'];
45 44
 }
46 45
 
47
-if (isset($_SESSION['clientcert_cert']))
48
-{
46
+if (isset($_SESSION['clientcert_cert'])) {
49 47
     // FIXME: Es gibt keine Duplikaterkennung.
50 48
     global $menu;
51 49
     output('<div style="margin: 1em; padding: 1em; border: 2px solid green;">');
... ...
@@ -62,18 +60,16 @@ if (isset($_SESSION['clientcert_cert']))
62 60
 
63 61
 DEBUG($username);
64 62
 $certs = get_certs_by_username($username);
65
-if ($certs != NULL) {
63
+if ($certs != null) {
66 64
     output('<p>Sie haben bereits Zertifikate für den Zugang eingerichtet.</p>
67 65
   <ul>');
68
-  foreach ($certs AS $cert) {
66
+    foreach ($certs as $cert) {
69 67
         output('<li>'.$cert['dn'].' / Seriennummer '.$cert['serial'].' / '.'Gültig von '.$cert['valid_from'].' bis '.$cert['valid_until'].'<br /><em>ausgestellt von </em>'.$cert['issuer']);
70 68
         output('<br />'.internal_link('certsave', 'Dieses Zertifikat löschen', 'action=delete&id='.$cert['id']));
71 69
         output('</li>');
72 70
     }
73 71
     output('</ul>');
74
-}
75
-else
76
-{
72
+} else {
77 73
     output('<p><em>Bisher sind keine Zertifikate für Ihren Zugang eingerichtet</em></p>');
78 74
 }
79 75
 
... ...
@@ -20,14 +20,26 @@ require_once('x509.php');
20 20
 require_role(array(ROLE_SYSTEMUSER, ROLE_SUBUSER, ROLE_VMAIL_ACCOUNT));
21 21
 
22 22
 
23
-if ($_GET['action'] == 'new')
24
-{
23
+if ($_GET['action'] == 'new') {
25 24
     check_form_token('clientcert_add');
26
-  if (! isset($_SESSION['clientcert_cert']))
25
+    if (! isset($_SESSION['clientcert_cert'])) {
27 26
         system_failure('Kein Zertifikat');
27
+    }
28
+  
29
+    add_clientcert(
30
+  
31
+      $_SESSION['clientcert_cert'],
32
+  
33
+      $_SESSION['clientcert_dn'],
34
+  
35
+      $_SESSION['clientcert_issuer'],
36
+                 $_SESSION['clientcert_serial'],
37
+  
38
+      $_SESSION['clientcert_valid_from'],
39
+  
40
+      $_SESSION['clientcert_valid_until']
28 41
   
29
-  add_clientcert($_SESSION['clientcert_cert'], $_SESSION['clientcert_dn'], $_SESSION['clientcert_issuer'], 
30
-                 $_SESSION['clientcert_serial'], $_SESSION['clientcert_valid_from'], $_SESSION['clientcert_valid_until']);
42
+  );
31 43
 
32 44
     // Räume session auf
33 45
     unset($_SESSION['clientcert_cert']);
... ...
@@ -37,13 +49,12 @@ if ($_GET['action'] == 'new')
37 49
     unset($_SESSION['clientcert_valid_from']);
38 50
     unset($_SESSION['clientcert_valid_until']);
39 51
     header('Location: cert');
40
-}
41
-elseif ($_GET['action'] == 'delete')
42
-{
52
+} elseif ($_GET['action'] == 'delete') {
43 53
     $cert = get_cert_by_id($_GET['id']);
44
-  if (! $cert)
54
+    if (! $cert) {
45 55
         system_failure('no ID');
46
-  $username = NULL;
56
+    }
57
+    $username = null;
47 58
     if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
48 59
         $username = $_SESSION['userinfo']['username'];
49 60
         if (isset($_SESSION['subuser'])) {
... ...
@@ -52,26 +63,22 @@ elseif ($_GET['action'] == 'delete')
52 63
     } elseif ($_SESSION['role'] & ROLE_VMAIL_ACCOUNT) {
53 64
         $username = $_SESSION['mailaccount'];
54 65
     }
55
-  if (! ($cert['username'] == $username))
66
+    if (! ($cert['username'] == $username)) {
56 67
         system_failure('Das Zertifikat ist nicht für Ihren Zugang eingerichtet');
68
+    }
57 69
     $sure = user_is_sure();
58
-  if ($sure === NULL)
59
-  {
70
+    if ($sure === null) {
60 71
         are_you_sure("action=delete&id={$cert['id']}", "Möchten Sie das Zertifikat »{$cert['dn']}« (Seriennummer {$cert['serial']}, Gültig von {$cert['valid_from']} bis {$cert['valid_until']}) wirklich löschen?");
61
-  }
62
-  elseif ($sure === true)
63
-  {
72
+    } elseif ($sure === true) {
64 73
         delete_clientcert($cert['id']);
65
-    if (! $debugmode)
74
+        if (! $debugmode) {
66 75
             header("Location: cert");
67 76
         }
68
-  elseif ($sure === false)
69
-  {
70
-    if (! $debugmode)
77
+    } elseif ($sure === false) {
78
+        if (! $debugmode) {
71 79
             header("Location: cert");
72 80
         }
73 81
     }
74
-else
82
+} else {
75 83
     system_failure('Kein Kommando');
76
-
77
-
84
+}
... ...
@@ -23,50 +23,53 @@ $error = '';
23 23
 
24 24
 
25 25
 
26
-if (isset($_POST['password1']))
27
-{
26
+if (isset($_POST['password1'])) {
28 27
     check_form_token('index_chpass');
29
-  $result = NULL;
30
-  if ($_SESSION['role'] & ROLE_SYSTEMUSER)
31
-    if ($_SESSION['role'] & ROLE_SUBUSER)
28
+    $result = null;
29
+    if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
30
+        if ($_SESSION['role'] & ROLE_SUBUSER) {
32 31
             $result = find_role($_SESSION['subuser'], $_POST['old_password']);
33
-    else
32
+        } else {
34 33
             $result = find_role($_SESSION['userinfo']['uid'], $_POST['old_password']);
35
-  else
34
+        }
35
+    } else {
36 36
         $result = find_role($_SESSION['customerinfo']['customerno'], $_POST['old_password']);
37
+    }
37 38
 
38
-  if ($result == NULL)
39
+    if ($result == null) {
39 40
         input_error('Das bisherige Passwort ist nicht korrekt!');
40
-  elseif ($_POST['password2'] != $_POST['password1'])
41
+    } elseif ($_POST['password2'] != $_POST['password1']) {
41 42
         input_error('Die Bestätigung ist nicht identisch mit dem neuen Passwort!');
42
-  elseif ($_POST['password2'] == '')
43
+    } elseif ($_POST['password2'] == '') {
43 44
         input_error('Sie müssen das neue Passwort zweimal eingeben!');
44
-  elseif ($_POST['old_password'] == '')
45
+    } elseif ($_POST['old_password'] == '') {
45 46
         input_error('Altes Passwort nicht angegeben!');
46
-  elseif (($check = strong_password($_POST['password1'])) !== true)
47
+    } elseif (($check = strong_password($_POST['password1'])) !== true) {
47 48
         input_error("Das Passwort ist zu einfach ({$check})!");
48
-  else
49
-  {
50
-    if ($result & ROLE_SYSTEMUSER)
49
+    } else {
50
+        if ($result & ROLE_SYSTEMUSER) {
51 51
             set_systemuser_password($_SESSION['userinfo']['uid'], $_POST['password1']);
52
-    elseif ($result & ROLE_SUBUSER)
52
+        } elseif ($result & ROLE_SUBUSER) {
53 53
             set_subuser_password($_SESSION['subuser'], $_POST['password1']);
54
-    elseif ($result & ROLE_CUSTOMER)
54
+        } elseif ($result & ROLE_CUSTOMER) {
55 55
             set_customer_password($_SESSION['customerinfo']['customerno'], $_POST['password1']);
56
-    else
56
+        } else {
57 57
             system_failure("WTF?! (\$result={$result})");
58
+        }
58 59
     
59
-    if (! $debugmode)
60
+        if (! $debugmode) {
60 61
             header('Location: index');
61
-    else
62
+        } else {
62 63
             output('');
63 64
         }
64 65
     }
66
+}
65 67
 
66 68
 
67 69
 
68
-if ($_SESSION['role'] & ROLE_SYSTEMUSER && ! ($_SESSION['role'] & ROLE_SUBUSER))
70
+if ($_SESSION['role'] & ROLE_SYSTEMUSER && ! ($_SESSION['role'] & ROLE_SUBUSER)) {
69 71
     warning('Beachten Sie: Wenn Sie hier Ihr Passwort ändern, betrifft dies auch Ihr Anmelde-Passwort am Server (SSH).');
72
+}
70 73
 
71 74
 output('<p>Hier können Sie Ihr Passwort ändern.</p>
72 75
 '.html_form('index_chpass', 'chpass', '', '<table>
... ...
@@ -83,8 +86,3 @@ output('<p>Hier können Sie Ihr Passwort ändern.</p>
83 86
 </table>
84 87
 <p><input type="submit" value="Speichern" /></p>
85 88
 '));
86
-
87
-
88
-
89
-
90
-?>
... ...
@@ -41,13 +41,15 @@ function send_customer_token($customerno)
41 41
     $customerno = (int) $customerno;
42 42
     $token = get_customer_token($customerno);
43 43
     $customer = get_customer_info($customerno);
44
-  if ($customer['email'] == '')
44
+    if ($customer['email'] == '') {
45 45
         system_failure('Für Ihr Kundenkonto ist keine E-Mail-Adresse eingetragen. Diese Funktion steht Ihnen daher nicht zur Verfügung.');
46
+    }
46 47
     $anrede = "Sehr geehrte Damen und Herren";
47
-  if ($customer['title'] == 'Herr')
48
+    if ($customer['title'] == 'Herr') {
48 49
         $anrede = "Sehr geehrter Herr {$customer['name']}";
49
-  elseif ($customer['title'] == 'Frau')
50
+    } elseif ($customer['title'] == 'Frau') {
50 51
         $anrede = "Sehr geehrte Frau {$customer['name']}";
52
+    }
51 53
     $msg = "{$anrede},
52 54
 
53 55
 Sie haben auf unserem Web-Administrations-Interface ein neues
... ...
@@ -76,12 +78,9 @@ Gültigkeit.
76 78
 
77 79
 function send_mail($address, $subject, $body)
78 80
 {
79
-  if (strstr($subject, "\n") !== false)
81
+    if (strstr($subject, "\n") !== false) {
80 82
         die("Zeilenumbruch im subject!");
83
+    }
81 84
     $header = "From: ".config('company_name')." Web Administration <noreply@".config('masterdomain').">\r\nReply-To: ".config('adminmail')."\r\nCc: ".config('adminmail')."\r\nContent-Type: text/plain; charset=\"utf-8\"\r\nContent-Transfer-Encoding: 8bit";
82 85
     mail($address, $subject, $body, $header);
83 86
 }
84
-
85
-
86
-
87
-?>
... ...
@@ -21,8 +21,9 @@ function user_customer_match($cust, $user)
21 21
     $args = array(":cid" => $cust,
22 22
                 ":user" => $user);
23 23
     $result = db_query("SELECT uid FROM system.useraccounts WHERE kunde=:cid AND username=:user AND kundenaccount=1", $args);
24
-  if ($result->rowCount() > 0)
24
+    if ($result->rowCount() > 0) {
25 25
         return true;
26
+    }
26 27
     return false;
27 28
 }
28 29
 
... ...
@@ -30,8 +31,7 @@ function find_username($input)
30 31
 {
31 32
     $args = array(":user" => $input);
32 33
     $result = db_query("SELECT username FROM system.useraccounts WHERE username=:user AND kundenaccount=1", $args);
33
-  if ($result->rowCount() > 0)
34
-  {
34
+    if ($result->rowCount() > 0) {
35 35
         $line = $result->fetch();
36 36
         return $line['username'];
37 37
     } else {
... ...
@@ -63,7 +63,7 @@ function get_uid_for_token($token)
63 63
     expire_tokens();
64 64
     $result = db_query("SELECT uid FROM system.usertoken WHERE token=?", array($token));
65 65
     if ($result->rowCount() == 0) {
66
-    return NULL;
66
+        return null;
67 67
     }
68 68
     $data = $result->fetch();
69 69
     return $data['uid'];
... ...
@@ -136,8 +136,9 @@ function get_customer_token($customerno)
136 136
 {
137 137
     expire_tokens();
138 138
     $result = db_query("SELECT token FROM kundendaten.kunden WHERE id=? AND token IS NOT NULL", array($customerno));
139
-  if ($result->rowCount() < 1)
139
+    if ($result->rowCount() < 1) {
140 140
         system_failure("Kann das Token nicht auslesen!");
141
+    }
141 142
     return $result->fetch(PDO::FETCH_OBJ)->token;
142 143
 }
143 144
 
... ...
@@ -148,5 +149,3 @@ function get_user_token($username)
148 149
     $tmp = $result->fetch();
149 150
     return $tmp['token'];
150 151
 }
151
-
152
-?>
... ...
@@ -16,7 +16,8 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
16 16
 
17 17
 require_once('inc/security.php');
18 18
 
19
-function do_ajax_cert_login() {
19
+function do_ajax_cert_login()
20
+{
20 21
     global $prefix;
21 22
     require_once('inc/jquery.php');
22 23
     javascript('certlogin.js', 'index');
... ...
@@ -27,7 +28,7 @@ function get_logins_by_cert($cert)
27 28
     $result = db_query("SELECT type,username,startpage FROM system.clientcert WHERE cert=? ORDER BY type,username", array($cert));
28 29
     if ($result->rowCount() < 1) {
29 30
         DEBUG("No certlogin found for this cert!");
30
-		return NULL;
31
+        return null;
31 32
     } else {
32 33
         $ret = array();
33 34
         while ($row = $result->fetch()) {
... ...
@@ -42,11 +43,13 @@ function get_logins_by_cert($cert)
42 43
 function get_cert_by_id($id)
43 44
 {
44 45
     $id = (int) $id;
45
-	if ($id == 0)
46
+    if ($id == 0) {
46 47
         system_failure('no ID');
48
+    }
47 49
     $result = db_query("SELECT id,dn,issuer,serial,valid_from,valid_until,cert,username,startpage FROM system.clientcert WHERE `id`=?", array($id));
48
-	if ($result->rowCount() < 1)
49
-		return NULL;
50
+    if ($result->rowCount() < 1) {
51
+        return null;
52
+    }
50 53
     $ret = $result->fetch();
51 54
     DEBUG($ret);
52 55
     return $ret;
... ...
@@ -55,11 +58,13 @@ function get_cert_by_id($id)
55 58
 
56 59
 function get_certs_by_username($username)
57 60
 {
58
-	if ($username == '')
61
+    if ($username == '') {
59 62
         system_failure('empty username');
63
+    }
60 64
     $result = db_query("SELECT id,dn,issuer,serial,valid_from,valid_until,cert,startpage FROM system.clientcert WHERE `username`=?", array($username));
61
-	if ($result->rowCount() < 1)
62
-		return NULL;
65
+    if ($result->rowCount() < 1) {
66
+        return null;
67
+    }
63 68
     while ($row = $result->fetch()) {
64 69
         $ret[] = $row;
65 70
     }
... ...
@@ -67,10 +72,10 @@ function get_certs_by_username($username)
67 72
 }
68 73
 
69 74
 
70
-function add_clientcert($certdata, $dn, $issuer, $serial, $vstart, $vend, $startpage=NULL)
75
+function add_clientcert($certdata, $dn, $issuer, $serial, $vstart, $vend, $startpage=null)
71 76
 {
72
-  $type = NULL;
73
-  $username = NULL;
77
+    $type = null;
78
+    $username = null;
74 79
     if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
75 80
         $type = 'user';
76 81
         $username = $_SESSION['userinfo']['username'];
... ...
@@ -85,11 +90,13 @@ function add_clientcert($certdata, $dn, $issuer, $serial, $vstart, $vend, $start
85 90
     if (! $type || ! $username) {
86 91
         system_failure('cannot get type or username of login');
87 92
     }
88
-  if ($startpage &&  ! check_path($startpage))
93
+    if ($startpage &&  ! check_path($startpage)) {
89 94
         system_failure('Startseite kaputt');
95
+    }
90 96
 
91
-  if ($certdata == '')
97
+    if ($certdata == '') {
92 98
         system_failure('Kein Zertifikat');
99
+    }
93 100
 
94 101
     $args = array(":dn" => $dn,
95 102
                 ":issuer" => $issuer,
... ...
@@ -111,8 +117,8 @@ VALUES (:dn, :issuer, :serial, :vstart, :vend, :certdata, :type, :username, :sta
111 117
 function delete_clientcert($id)
112 118
 {
113 119
     $id = (int) $id;
114
-  $type = NULL;
115
-  $username = NULL;
120
+    $type = null;
121
+    $username = null;
116 122
     if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
117 123
         $type = 'user';
118 124
         $username = $_SESSION['userinfo']['username'];
... ...
@@ -127,7 +133,8 @@ function delete_clientcert($id)
127 133
     if (! $type || ! $username) {
128 134
         system_failure('cannot get type or username of login');
129 135
     }
130
-  db_query("DELETE FROM system.clientcert WHERE id=:id AND type=:type AND username=:username", 
131
-           array(":id" => $id, ":type" => $type, ":username" => $username));
136
+    db_query(
137
+      "DELETE FROM system.clientcert WHERE id=:id AND type=:type AND username=:username",
138
+           array(":id" => $id, ":type" => $type, ":username" => $username)
139
+  );
132 140
 }
133
-
... ...
@@ -23,8 +23,7 @@ if ($user['email'] == '')
23 23
   input_error('Im System ist keine alternative eMail-Adresse gespeichert (siehe Stammdaten)!');
24 24
 */
25 25
 
26
-switch ($_SESSION['role'])
27
-{
26
+switch ($_SESSION['role']) {
28 27
 case ROLE_ANONYMOUS:
29 28
   login_screen('');
30 29
   break;
... ...
@@ -107,6 +105,3 @@ if (have_module('email') && $_SESSION['role'] & ROLE_VMAIL_ACCOUNT) {
107 105
     include('modules/email/vmailoverview.php');
108 106
     output("<div class=\"vmailoverview\">".$content."</div>");
109 107
 }
110
-
111
-
112
-?>
... ...
@@ -27,49 +27,43 @@ if (isset($_SESSION['role']) && $_SESSION['role'] != ROLE_ANONYMOUS) {
27 27
     die();
28 28
 }
29 29
 
30
-if (isset($_REQUEST['token']))
31
-{
30
+if (isset($_REQUEST['token'])) {
32 31
     $token = $_REQUEST['token'];
33 32
     $uid = get_uid_for_token($token);
34 33
   
35
-  if ($uid != NULL && validate_uid_token($uid, $token))
36
-  {
34
+    if ($uid != null && validate_uid_token($uid, $token)) {
37 35
         $show = 'agb';
38 36
         if (isset($_REQUEST['agb']) && $_REQUEST['agb'] == '1') {
39 37
             $show = 'password';
40 38
         }
41
-    if (isset($_POST['password']))
42
-    {
43
-      if ($_POST['password'] != $_POST['password2'])
39
+        if (isset($_POST['password'])) {
40
+            if ($_POST['password'] != $_POST['password2']) {
44 41
                 input_error("Die beiden Passwort-Eingaben stimmen nicht überein.");
45
-      elseif ($_POST['password'] == '')
42
+            } elseif ($_POST['password'] == '') {
46 43
                 input_error("Es kann kein leeres Passwort gesetzt werden");
47
-      elseif (preg_match('/["\'\\\\]/', $_POST['password']) === 1)
44
+            } elseif (preg_match('/["\'\\\\]/', $_POST['password']) === 1) {
48 45
                 input_error("Das Passwort enthält problematische Zeichen. Bitte keine Anführungszeichen und kein Backslash benutzen.");
49
-      elseif (($result = strong_password($_POST['password'])) !== true)
46
+            } elseif (($result = strong_password($_POST['password'])) !== true) {
50 47
                 input_error("Das Passwort ist zu einfach ({$result})!");
51
-      else
52
-      {
48
+            } else {
53 49
                 require_once('session/checkuser.php');
54 50
                 require_once('inc/base.php');
55 51
                 logger(LOG_INFO, "modules/index/initialize_useraccount", "initialize", "uid »{$uid}« set a new password");
56 52
                 set_systemuser_password($uid, $_POST['password']);
57 53
                 invalidate_systemuser_token($uid);
58
-        $_SESSION['role'] = find_role($uid, '', True);;
54
+                $_SESSION['role'] = find_role($uid, '', true);
55
+                ;
59 56
                 setup_session($_SESSION['role'], $uid);
60 57
                 success_msg('Das Passwort wurde gesetzt!');
61 58
                 redirect('index');
62 59
             }
63 60
         }
64
-  }
65
-  else
66
-  {
61
+    } else {
67 62
         input_error("Der eingegebene Code war nicht korrekt. Eventuell haben Sie die Adresse nicht vollständig übernommen oder die Gültigkeit des Sicherheitscodes ist abgelaufen.");
68 63
     }
69 64
 }
70 65
 
71
-if ($show == 'password')
72
-{
66
+if ($show == 'password') {
73 67
     $username = get_username_for_uid($uid);
74 68
     title("Neues Passwort setzen");
75 69
     output('<p>Bitte legen Sie jetzt Ihr neues Passwort fest.</p>'.
... ...
@@ -80,9 +74,7 @@ if ($show == 'password')
80 74
   <p><span class="login_label">Bestätigung:</span> <input type="password" name="password2" size="30" /></p>
81 75
   <p><span class="login_label">&#160;</span> <input type="submit" value="Passwort setzen" /></p>
82 76
   '));
83
-}
84
-elseif ($show == 'agb')
85
-{
77
+} elseif ($show == 'agb') {
86 78
     title("Bestätigung unserer AGB");
87 79
     output('<p>Die Nutzung unseres Angebots ist an unsere <a href="https://schokokeks.org/agb">Allgemeinen Geschäftsbedingungen</a> gebunden. Bitte lesen Sie diese Bedingungen und bestätigen Sie Ihr Einverständnis. Sollten Sie diese Bedingungen nicht akzeptieren, setzen Sie sich bitte mit uns in Verbindung.</p>'.
88 80
   html_form('initialize_useraccount_agb', '', '', '<p style="display: none"><input type="hidden" name="uid" value="'.$uid.'" />
... ...
@@ -90,12 +82,7 @@ elseif ($show == 'agb')
90 82
   <p><span class="login_label">&#160;</span><input type="checkbox" name="agb" value="1" /> Ja, ich akzeptiere die AGB.<p>
91 83
   <p><span class="login_label">&#160;</span> <input type="submit" value="Weiter" /></p>
92 84
   '));
93
-}
94
-elseif ($show == 'token')
95
-{
85
+} elseif ($show == 'token') {
96 86
     title("Neues Passwort setzen");
97 87
     output('<p>Bitte rufen Sie die Adresse aus Ihrer Begrüßungs-E-Mail auf um ein neues Passwort zu setzen.');
98 88
 }
99
-
100
-
101
-?>
... ...
@@ -19,10 +19,9 @@ require_once('session/start.php');
19 19
 require_once('inc/error.php');
20 20
 
21 21
 if (isset($_COOKIE['CLIENTCERT_AUTOLOGIN'])) {
22
-  setcookie('CLIENTCERT_AUTOLOGIN', FALSE, 0, '/');
22
+    setcookie('CLIENTCERT_AUTOLOGIN', false, 0, '/');
23 23
 }
24
-if (!session_destroy())
25
-{
24
+if (!session_destroy()) {
26 25
     logger(LOG_INFO, "modules/index/logout", "logout", "session timed out.");
27 26
     system_failure('Die Sitzung konnte nicht geschlossen werden, eventuell ist die Wartezeit abgelaufen und die Sitzung wurde daher schon beendet.');
28 27
 }
... ...
@@ -38,7 +37,3 @@ output('
38 37
 <p>Um sich neu anzumelden, klicken Sie bitte hier: '.internal_link("index", "Anmeldung").'.</p>
39 38
 
40 39
 ');
41
-
42
-
43
-
44
-?>
... ...
@@ -19,14 +19,11 @@ title("Neues Passwort beantragen");
19 19
 //require_once('inc/error.php');
20 20
 //system_failure("Diese Funktion ist noch nicht fertiggestellt.");
21 21
 
22
-if (isset($_POST['username']))
23
-{
22
+if (isset($_POST['username'])) {
24 23
     require_once('newpass.php');
25 24
     $username = find_username($_POST['username']);
26
-  if ($username)
27
-  {
28
-    if (create_token($username))
29
-    {
25
+    if ($username) {
26
+        if (create_token($username)) {
30 27
             require_once('mail.php');
31 28
             require_once('inc/base.php');
32 29
             send_user_token($username);
... ...
@@ -43,7 +40,3 @@ output('<p>Wenn Sie Ihr Benutzer-Passwort nicht mehr kennen, können Sie hier ei
43 40
 <p><span class="login_label">Benutzername:</span> <input type="text" name="username" size="30" /></p>
44 41
 <p><span class="login_label">&#160;</span> <input type="submit" value="Passwort anfordern" /></p>
45 42
 </form>');
46
-
47
-
48
-
49
-?>
... ...
@@ -19,8 +19,9 @@ $role = $_SESSION['role'];
19 19
 if ($role == ROLE_ANONYMOUS) {
20 20
     $menu["index_login"] = array("label" => "Login", "file" => "index", "weight" => 0);
21 21
 } else {
22
-  if ($role & (ROLE_SYSTEMUSER | ROLE_SUBUSER | ROLE_VMAIL_ACCOUNT))
22
+    if ($role & (ROLE_SYSTEMUSER | ROLE_SUBUSER | ROLE_VMAIL_ACCOUNT)) {
23 23
         $menu["index_cert"] = array("label" => "Client-Zertifikat", "file" => "cert", "weight" => 10, "submenu" => "index_index");
24
+    }
24 25
     if ($role & (ROLE_SYSTEMUSER | ROLE_CUSTOMER)) {
25 26
         $menu["index_chpass"] = array("label" => "Passwort ändern", "file" => "chpass", "weight" => 98);
26 27
     }
... ...
@@ -28,6 +29,3 @@ if ($role == ROLE_ANONYMOUS) {
28 29
     $menu["index_logout"] = array("label" => "Logout", "file" => "logout", "weight" => 99);
29 30
     $menu["index_index"] = array("label" => "Übersicht", "file" => "index", "weight" => 0);
30 31
 }
31
-
32
-
33
-?>
... ...
@@ -20,5 +20,5 @@ if ($_SESSION['role'] & ROLE_CUSTOMER || $_SESSION['role'] & ROLE_SYSTEMUSER) {
20 20
                         'file'    => 'chpass',
21 21
                         'icon'    => 'pwchange.png',
22 22
                         'title'   => 'Passwort ändern',
23
-                        'alert'   => NULL );
23
+                        'alert'   => null );
24 24
 }
... ...
@@ -18,26 +18,22 @@ title("Passwort setzen");
18 18
 
19 19
 $show = 'token';
20 20
 
21
-if (isset($_REQUEST['customerno']) and isset($_REQUEST['token']))
22
-{
21
+if (isset($_REQUEST['customerno']) and isset($_REQUEST['token'])) {
23 22
     $customerno = (int) $_REQUEST['customerno'];
24 23
     $token = $_REQUEST['token'];
25 24
   
26 25
     require_once('newpass.php');
27 26
     require_once('inc/security.php');
28
-  if (validate_token($customerno, $token))
29
-  {
27
+    if (validate_token($customerno, $token)) {
30 28
         $show = 'password';
31
-    if (isset($_POST['password']))
32
-    {
33
-      if ($_POST['password'] != $_POST['password2'])
29
+        if (isset($_POST['password'])) {
30
+            if ($_POST['password'] != $_POST['password2']) {
34 31
                 input_error("Die beiden Passwort-Eingaben stimmen nicht überein.");
35
-      elseif ($_POST['password'] == '')
32
+            } elseif ($_POST['password'] == '') {
36 33
                 input_error("Es kann kein leeres Passwort gesetzt werden");
37
-      elseif (($result = strong_password($_POST['password'])) !== true)
34
+            } elseif (($result = strong_password($_POST['password'])) !== true) {
38 35
                 input_error("Das Passwort ist zu einfach ({$result})!");
39
-      else
40
-      {
36
+            } else {
41 37
                 require_once('session/checkuser.php');
42 38
                 require_once('inc/base.php');
43 39
                 logger(LOG_INFO, "modules/index/validate_token", "pwrecovery", "customer »{$customerno}« set a new password");
... ...
@@ -50,18 +46,15 @@ if (isset($_REQUEST['customerno']) and isset($_REQUEST['token']))
50 46
                 $_SESSION['customerinfo'] = get_customer_info($customerno);
51 47
                 title("Passwort gesetzt");
52 48
                 output('<p>Ihr neues Passwort wurde gesetzt, Sie können jetzt '.internal_link("index", "die Web-Oberfläche sofort benutzen").'.</p>');
53
-        $show = NULL;
49
+                $show = null;
54 50
             }
55 51
         }
56
-  }
57
-  else
58
-  {
52
+    } else {
59 53
         input_error("Der eingegebene Code war nicht korrekt. Bitte benutzen Sie die Kopieren &amp; Einfügen-Operation!");
60 54
     }
61 55
 }
62 56
 
63
-if ($show == 'password')
64
-{
57
+if ($show == 'password') {
65 58
     output('<p>Bitte legen Sie jetzt Ihr neues Kunden-Passwort fest.</p>
66 59
   <form action="" method="post">
67 60
   <p style="display: none"><input type="hidden" name="customerno" value="'.$customerno.'" />
... ...
@@ -70,9 +63,7 @@ if ($show == 'password')
70 63
   <p><span class="login_label">Bestätigung:</span> <input type="password" name="password2" size="30" /></p>
71 64
   <p><span class="login_label">&#160;</span> <input type="submit" value="Passwort setzen" /></p>
72 65
   </form>');
73
-}
74
-elseif ($show == 'token')
75
-{
66
+} elseif ($show == 'token') {
76 67
     output('<p>Bitte geben Sie Ihre Kundennummer und den per E-Mail zugeschickten Code ein. Alternativ können sie den Link aus der E-Mail direkt aufrufen.</p>
77 68
   <form action="" method="post">
78 69
   <p><span class="login_label">Kundennummer:</span> <input type="text" name="customerno" size="30" /></p>
... ...
@@ -80,6 +71,3 @@ elseif ($show == 'token')
80 71
   <p><span class="login_label">&#160;</span> <input type="submit" value="Überprüfen" /></p>
81 72
   </form>');
82 73
 }
83
-
84
-
85
-?>
... ...
@@ -54,8 +54,7 @@ if (count($invoices_to_show) == 0) {
54 54
     output('<table class="nogrid"><tr><th>Nr.</th><th>Datum</th><th>Gesamtbetrag</th><th>bezahlt?</th><th>Herunterladen</th></tr>');
55 55
 
56 56
     $odd = true;
57
-  foreach($invoices_to_show AS $invoice)
58
-  {
57
+    foreach ($invoices_to_show as $invoice) {
59 58
         $bezahlt = 'Nein';
60 59
         $class = 'unpaid';
61 60
         if ($invoice['bezahlt'] == 1) {
... ...
@@ -107,7 +106,7 @@ if ($mandate) {
107 106
             $gueltig = $m['gueltig_ab'].' - '.$m['gueltig_bis'];
108 107
         }
109 108
         $aktiv = false;
110
-    if ($m['gueltig_ab'] <= date('Y-m-d') && ($m['gueltig_bis'] == NULL || $m['gueltig_bis'] >= date('Y-m-d'))) {
109
+        if ($m['gueltig_ab'] <= date('Y-m-d') && ($m['gueltig_bis'] == null || $m['gueltig_bis'] >= date('Y-m-d'))) {
111 110
             $aktiv = true;
112 111
         }
113 112
         output('<tr><td'.($aktiv ? ' style="font-weight: bold;"' : '').'>'.internal_link('sepamandat_detail', $m['mandatsreferenz'], 'ref='.$m['mandatsreferenz']).'</td><td>'.$m['iban'].'</td><td>'.$gueltig.'</td></tr>');
... ...
@@ -145,14 +144,12 @@ $counter = 0;
145 144
 $more = false;
146 145
 $odd = false;
147 146
 
148
-foreach($items AS $item)
149
-{
147
+foreach ($items as $item) {
150 148
     if ($item['startdatum'] > $max_date) {
151 149
         $more = true;
152 150
         break;
153 151
     }
154
-	if ($flip && $item['startdatum'] > $today)
155
-	{
152
+    if ($flip && $item['startdatum'] > $today) {
156 153
         if ($counter == 0) {
157 154
             output("<tr class=\"even\"><td colspan=\"5\"><em>Aktuell keine fälligen Posten</em></td></tr>");
158 155
         }
... ...
@@ -164,11 +161,13 @@ foreach($items AS $item)
164 161
     }
165 162
     $counter++;
166 163
     $desc = $item['startdatum'];
167
-	if ($item['enddatum'] != NULL)
164
+    if ($item['enddatum'] != null) {
168 165
         $desc = $item['startdatum'].' - '.$item['enddatum'];
166
+    }
169 167
     $epreis = $item['betrag'];
170
-	if ($item['brutto'] == 0)
168
+    if ($item['brutto'] == 0) {
171 169
         $epreis = $epreis * (1 + ($item['mwst'] / 100));
170
+    }
172 171
     $gesamt = round($epreis * $item['anzahl'], 2);
173 172
     $epreis = round($epreis, 2);
174 173
     $summe += $gesamt;
... ...
@@ -191,4 +190,3 @@ if ($counter) {
191 190
 if ($more) {
192 191
     output('<p>'.internal_link('upcoming', other_icon('control_fastforward.png').' Alle zukünftigen Rechnungsposten anzeigen').'</p>');
193 192
 }
194
-?>
... ...
@@ -45,19 +45,21 @@ Rechnungsdatum: '.$invoice['datum'].'
45 45
 
46 46
 output('<table><tr><th>Anzahl</th><th>Beschreibung</th><th>Einzelpreis</th><th>Gesamtbetrag</th></tr>');
47 47
 
48
-foreach($items AS $item)
49
-{
48
+foreach ($items as $item) {
50 49
     $anzahl = $item['anzahl'];
51
-	if (round($anzahl, 0) == $anzahl)
50
+    if (round($anzahl, 0) == $anzahl) {
52 51
         $anzahl = round($anzahl, 0);
52
+    }
53 53
     $desc = $item['beschreibung'];
54
-	if ($item['enddatum'] == NULL)
54
+    if ($item['enddatum'] == null) {
55 55
         $desc .= '<br />(Leistungsdatum: '.$item['datum'].')';
56
-	else
56
+    } else {
57 57
         $desc .= '<br />(Leistungszeitraum: '.$item['datum'].' - '.$item['enddatum'].')';
58
+    }
58 59
     $epreis = $item['betrag'];
59
-	if ($item['brutto'] == 0)
60
+    if ($item['brutto'] == 0) {
60 61
         $epreis = $epreis * (1 + ($item['mwst'] / 100));
62
+    }
61 63
     $einheit = ($item['einheit'] ? $item['einheit'] : '');
62 64
     $gesamt = round($epreis * $item['anzahl'], 2);
63 65
     $epreis = round($epreis, 2);
... ...
@@ -84,5 +86,3 @@ if ($invoice['bezahlt'] == 1) {
84 86
 
85 87
     output('<h4>GiroCode für Mobile Banking (SEPA Credit Transfer)</h4><p><img src="data:image/png;base64,'.base64_encode($qrcode_image).'" /></p>');
86 88
 }
87
-
88
-?>
... ...
@@ -23,8 +23,9 @@ function my_invoices()
23 23
     $c = (int) $_SESSION['customerinfo']['customerno'];
24 24
     $result = db_query("SELECT id,datum,betrag,bezahlt,abbuchung,sepamandat FROM kundendaten.ausgestellte_rechnungen WHERE kunde=? ORDER BY id DESC", array($c));
25 25
     $ret = array();
26
-  while($line = $result->fetch())
26
+    while ($line = $result->fetch()) {
27 27
         array_push($ret, $line);
28
+    }
28 29
     return $ret;
29 30
 }
30 31
 
... ...
@@ -34,10 +35,10 @@ function get_pdf($id)
34 35
     $c = (int) $_SESSION['customerinfo']['customerno'];
35 36
     $id = (int) $id;
36 37
     $result = db_query("SELECT pdfdata FROM kundendaten.ausgestellte_rechnungen WHERE kunde=:c AND id=:id", array(":c" => $c, ":id" => $id));
37
-  if ($result->rowCount() == 0)
38
+    if ($result->rowCount() == 0) {
38 39
         system_failure('Ungültige Rechnungsnummer oder nicht eingeloggt');
40
+    }
39 41
     return $result->fetch(PDO::FETCH_OBJ)->pdfdata;
40
-
41 42
 }
42 43
 
43 44
 
... ...
@@ -46,8 +47,9 @@ function invoice_details($id)
46 47
     $c = (int) $_SESSION['customerinfo']['customerno'];
47 48
     $id = (int) $id;
48 49
     $result = db_query("SELECT kunde,datum,betrag,bezahlt,abbuchung FROM kundendaten.ausgestellte_rechnungen WHERE kunde=:c AND id=:id", array(":c" => $c, ":id" => $id));
49
-  if ($result->rowCount() == 0)
50
+    if ($result->rowCount() == 0) {
50 51
         system_failure('Ungültige Rechnungsnummer oder nicht eingeloggt');
52
+    }
51 53
     return $result->fetch();
52 54
 }
53 55
 
... ...
@@ -56,11 +58,13 @@ function invoice_items($id)
56 58
     $c = (int) $_SESSION['customerinfo']['customerno'];
57 59
     $id = (int) $id;
58 60
     $result = db_query("SELECT id, beschreibung, datum, enddatum, betrag, einheit, brutto, mwst, anzahl FROM kundendaten.rechnungsposten WHERE rechnungsnummer=:id AND kunde=:c", array(":c" => $c, ":id" => $id));
59
-  if ($result->rowCount() == 0)
61
+    if ($result->rowCount() == 0) {
60 62
         system_failure('Ungültige Rechnungsnummer oder nicht eingeloggt');
63
+    }
61 64
     $ret = array();
62
-  while($line = $result->fetch())
65
+    while ($line = $result->fetch()) {
63 66
         array_push($ret, $line);
67
+    }
64 68
     return $ret;
65 69
 }
66 70
 
... ...
@@ -70,8 +74,9 @@ function upcoming_items()
70 74
     $c = (int) $_SESSION['customerinfo']['customerno'];
71 75
     $result = db_query("SELECT quelle, id, anzahl, beschreibung, startdatum, enddatum, betrag, einheit, brutto, mwst FROM kundendaten.upcoming_items WHERE kunde=? ORDER BY startdatum ASC", array($c));
72 76
     $ret = array();
73
-  while($line = $result->fetch())
77
+    while ($line = $result->fetch()) {
74 78
         array_push($ret, $line);
79
+    }
75 80
     return $ret;
76 81
 }
77 82
 
... ...
@@ -124,11 +129,12 @@ RE '.$id.' KD '.$customerno.' vom '.$datum;
124 129
 }
125 130
 
126 131
 
127
-function get_lastschrift($rechnungsnummer) {
132
+function get_lastschrift($rechnungsnummer)
133
+{
128 134
     $rechnungsnummer = (int) $rechnungsnummer;
129 135
     $result = db_query("SELECT rechnungsnummer, rechnungsdatum, sl.betrag, buchungsdatum, sl.status FROM kundendaten.sepalastschrift sl LEFT JOIN kundendaten.ausgestellte_rechnungen re ON (re.sepamandat=sl.mandatsreferenz) WHERE rechnungsnummer=?", array($rechnungsnummer));
130 136
     if ($result->rowCount() == 0) {
131
-    return NULL;
137
+        return null;
132 138
     }
133 139
     $item = $result->fetch();
134 140
     return $item;
... ...
@@ -189,7 +195,7 @@ function sepamandat($name, $adresse, $iban, $bankname, $bic, $gueltig_ab)
189 195
     $alte_mandate = get_sepamandate();
190 196
     $referenzen = array();
191 197
     foreach ($alte_mandate as $mandat) {
192
-    if ($mandat['gueltig_bis'] == NULL || $mandat['gueltig_bis'] >= $gueltig_ab) {
198
+        if ($mandat['gueltig_bis'] == null || $mandat['gueltig_bis'] >= $gueltig_ab) {
193 199
             DEBUG('Altes Mandat wird für ungültig erklärt.');
194 200
             DEBUG($mandat);
195 201
             invalidate_sepamandat($mandat['id'], yesterday($gueltig_ab));
... ...
@@ -207,10 +213,12 @@ function sepamandat($name, $adresse, $iban, $bankname, $bic, $gueltig_ab)
207 213
     $glaeubiger_id = config('glaeubiger_id');
208 214
 
209 215
     $today = date('Y-m-d');
210
-  db_query("INSERT INTO kundendaten.sepamandat (mandatsreferenz, glaeubiger_id, kunde, erteilt, medium, gueltig_ab, kontoinhaber, adresse, iban, bic, bankname) VALUES (:referenz, :glaeubiger_id, :cid, :today, 'online', :gueltig_ab, :name, :adresse, :iban, :bic, :bankname)",
216
+    db_query(
217
+      "INSERT INTO kundendaten.sepamandat (mandatsreferenz, glaeubiger_id, kunde, erteilt, medium, gueltig_ab, kontoinhaber, adresse, iban, bic, bankname) VALUES (:referenz, :glaeubiger_id, :cid, :today, 'online', :gueltig_ab, :name, :adresse, :iban, :bic, :bankname)",
211 218
           array(":referenz" => $referenz, ":glaeubiger_id" => $glaeubiger_id, ":cid" => $cid,
212 219
                 ":today" => $today, ":gueltig_ab" => $gueltig_ab, ":name" => $name, ":adresse" => $adresse,
213
-                ":iban" => $iban, ":bic" => $bic, ":bankname" => $bankname));
220
+                ":iban" => $iban, ":bic" => $bic, ":bankname" => $bankname)
221
+  );
214 222
 }
215 223
 
216 224
 
... ...
@@ -223,7 +231,7 @@ function get_bank_info($iban)
223 231
         echo '$iban = '.$iban;
224 232
         echo 'strlen($iban): '.strlen($iban);
225 233
         echo 'substr($iban, 0, 2): '.substr($iban, 0, 2);
226
-    return NULL;
234
+        return null;
227 235
     }
228 236
     $blz = substr($iban, 4, 8);
229 237
     // FIXME: Liste der BLZs muss vorhanden sein!
... ...
@@ -259,7 +267,8 @@ function get_customerquota()
259 267
     return $data["quota"];
260 268
 }
261 269
 
262
-function save_more_storage($items, $storage) {
270
+function save_more_storage($items, $storage)
271
+{
263 272
     $cid = (int) $_SESSION['customerinfo']['customerno'];
264 273
   
265 274
     $queries = array();
... ...
@@ -317,5 +326,3 @@ function save_more_storage($items, $storage) {
317 326
     $message = "Hallo,\n\nsoeben wurde im Webinterface von ".config('company_name')." eine Bestellung über zusätzlichen Speicherplatz ausgeführt.\nSollten Sie diese Bestellung nicht getätigt haben, antworten Sie bitte auf diese E-Mail um unseren Support zu erreichen.\n\nBei dieser Bestellung wurden {$storage} MB zusätzlicher Speicherplatz bestellt. Ihnen stehen ab sofort insgesamt {$allstorage} MB zur Verfügung.\n\nIhre Kundennummer: {$_SESSION['customerinfo']['customerno']} ({$_SESSION['customerinfo']['name']})\n";
318 327
     mail($emailaddr, 'Auftragsbestätigung: Mehr Speicherplatz bei schokokeks.org', $message, "X-schokokeks-org-message: notify\nFrom: ".config('company_name').' <'.config('adminmail').">\nBcc: ".config('adminmail')."\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\n");
319 328
 }
320
-
321
-?>
... ...
@@ -16,12 +16,7 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
16 16
 
17 17
 $role = $_SESSION['role'];
18 18
 
19
-if ($role & ROLE_CUSTOMER)
20
-{
19
+if ($role & ROLE_CUSTOMER) {
21 20
     $menu["invoice_current"] = array("label" => "Rechnungen", "file" => "current", "weight" => 2, "submenu" => "index_index");
22 21
     //$menu["invoice_upcoming"] = array("label" => "zukünftige Rechnungen", "file" => "upcoming", "weight" => 2, "submenu" => "invoice_current");
23
-
24
-    
25 22
 }
26
-
27
-?>
... ...
@@ -32,7 +32,7 @@ $section = $_SESSION['more_storage_section'];
32 32
 title('Zusätzlichen Speicherplatz buchen');
33 33
 
34 34
 $upcoming = upcoming_items();
35
-$hosting = NULL;
35
+$hosting = null;
36 36
 foreach ($upcoming as $item) {
37 37
     if ($item['quelle'] == 'hosting') {
38 38
         $hosting = $item;
... ...
@@ -106,24 +106,24 @@ $items[] = $new_item;
106 106
 output('<p>Die Abrechnung erfolgt mit Ihrer nächsten turnusgemäßen Abrechnung und wird mit folgenden Rechnungsposten vorgemerkt.</p>');
107 107
 output('<table><tr><th>Anzahl</th><th>Beschreibung</th><th>Zeitraum</th><th>Einzelpreis</th><th>Gesamtbetrag</th></tr>');
108 108
 $counter = 0;
109
-foreach($items AS $item)
110
-{
109
+foreach ($items as $item) {
111 110
     $counter++;
112 111
     if ($counter == 1 && ($item['anzahl'] > 0)) {
113 112
         output("<tr><td colspan=\"5\" style=\"border: none;\"><em>Einmaliger Posten:</em></td></tr>");
114
-  }
115
-  elseif ($counter == 2) {
113
+    } elseif ($counter == 2) {
116 114
         output("<tr><td colspan=\"5\" style=\"border: none;\"><em>Künftiger regelmäßiger Posten:</em></td></tr>");
117 115
     }
118 116
     if ($item['anzahl'] == 0) {
119 117
         continue;
120 118
     }
121 119
     $desc = $item['startdatum'];
122
-	if ($item['enddatum'] != NULL)
120
+    if ($item['enddatum'] != null) {
123 121
         $desc = $item['startdatum'].' - '.$item['enddatum'];
122
+    }
124 123
     $epreis = $item['betrag'];
125
-	if ($item['brutto'] == 0)
124
+    if ($item['brutto'] == 0) {
126 125
         $epreis = $epreis * (1 + ($item['mwst'] / 100));
126
+    }
127 127
     $gesamt = round($epreis * $item['anzahl'], 2);
128 128
     $epreis = round($epreis, 2);
129 129
     $einheit = ($item['einheit'] ? $item['einheit'] : '');
... ...
@@ -164,5 +164,3 @@ $form .= '<p>
164 164
 
165 165
 
166 166
 output(html_form("more_storage", "more_storage_save", "action=more_storage", $form));
167
-
168
-?>
... ...
@@ -49,7 +49,7 @@ if (count($items) < 2) {
49 49
 
50 50
 $stub = $items[0];
51 51
 if ($stub['anzahl'] == 0) {
52
-  $stub = NULL;
52
+    $stub = null;
53 53
 }
54 54
 $regular = $items[1];
55 55
 
... ...
@@ -70,7 +70,7 @@ if ($stub) {
70 70
 $i = array();
71 71
 $i['beschreibung'] = $regular['beschreibung'];
72 72
 $i['datum'] = $regular['startdatum'];
73
-$i['kuendigungsdatum'] = NULL;
73
+$i['kuendigungsdatum'] = null;
74 74
 $i['betrag'] = $regular['betrag'];
75 75
 $i['brutto'] = $regular['brutto'];
76 76
 $i['monate'] = $regular['anzahl'];
... ...
@@ -105,5 +105,3 @@ if (isset($_SESSION['more_storage_section'])) {
105 105
 } else {
106 106
     redirect($prefix.'go/invoice/current');
107 107
 }
108
-
109
-?>
... ...
@@ -19,17 +19,12 @@ require_once('invoice.php');
19 19
 require_role(ROLE_CUSTOMER);
20 20
 
21 21
 $pdfdata = get_pdf($_GET['id']);
22
-if (! $pdfdata)
23
-{
22
+if (! $pdfdata) {
24 23
     system_failure('Die PDF-Version dieser Rechnung konnte nicht aufgerufen werden. PDF-Versionen für sehr alte Rechnungen sind nicht mehr verfügbar.');
25
-}
26
-else
27
-{
24
+} else {
28 25
     $filename = sprintf('rechnung%05s.pdf', $_GET['id']);
29 26
     header('Content-type: application/pdf');
30 27
     header('Content-disposition: attachment; filename='.$filename);
31 28
     echo $pdfdata;
32 29
     die();
33 30
 }
34
-
35
-?>
... ...
@@ -24,8 +24,7 @@ global $debugmode;
24 24
 $section = 'invoice_current';
25 25
 
26 26
 
27
-if ($_GET['action'] == 'new')
28
-{
27
+if ($_GET['action'] == 'new') {
29 28
     check_form_token('sepamandat_neu');
30 29
   
31 30
     $gueltig_ab = $_REQUEST['gueltig_ab'];
... ...
@@ -64,10 +63,10 @@ if ($_GET['action'] == 'new')
64 63
     }
65 64
     DEBUG('Bank: '.$bankname);
66 65
 
67
-  $bic = NULL;
66
+    $bic = null;
68 67
     if (empty($_REQUEST['bic'])) {
69 68
         if (substr($iban, 0, 2) == 'DE') {
70
-      $bic=NULL;
69
+            $bic=null;
71 70
         } else {
72 71
             system_failure('Sie haben keinen BIC angegeben. Für Konten außerhalb Deutschlands ist ein BIC weiterhin erforderlich.');
73 72
         }
... ...
@@ -47,7 +47,7 @@ output('<p>Dieses Mandat gilt für Forderungen bzgl. der Kundennummer <strong>'.
47 47
 $first_date = date('Y-m-d');
48 48
 $invoices = my_invoices();
49 49
 foreach ($invoices as $i) {
50
-  if ($i['bezahlt'] == 0 && $i['sepamandat'] == NULL && $i['datum'] < $first_date) {
50
+    if ($i['bezahlt'] == 0 && $i['sepamandat'] == null && $i['datum'] < $first_date) {
51 51
         $first_date = $i['datum'];
52 52
     }
53 53
 }
... ...
@@ -55,9 +55,9 @@ foreach ($invoices as $i) {
55 55
 $html = '<h4>Gültigkeit des Mandats</h4>
56 56
 <p>Ein eventuell zuvor erteiltes Mandat wird zu diesem Datum automatisch ungültig.</p>';
57 57
 
58
-$checked = False;
58
+$checked = false;
59 59
 if ($first_date != date('Y-m-d')) {
60
-  $checked = True;
60
+    $checked = true;
61 61
     $html .= '<p><input type="radio" id="gueltig_ab_'.$first_date.'" name="gueltig_ab" value="'.$first_date.'" checked="checked" /><label for="gueltig_ab_'.$first_date.'">Dieses Mandat gilt <strong>ab '.$first_date.'</strong> (Alle bisher offenen Forderungen werden ebenfalls abgebucht)</label></p>';
62 62
 }
63 63
 $html .= '<p><input type="radio" id="gueltig_ab_heute" name="gueltig_ab" value="'.date('Y-m-d').'" '.($checked ? '' : 'checked="checked"').' /><label for="gueltig_ab_heute">Dieses Mandat gilt <strong>ab heute</strong> ('.date('Y-m-d').')</label></p>';
... ...
@@ -20,13 +20,13 @@ require_once('inc/debug.php');
20 20
 require_once('invoice.php');
21 21
 
22 22
 
23
-$iban = NULL;
23
+$iban = null;
24 24
 if (isset($_GET['iban'])) {
25 25
     $iban = $_GET['iban'];
26 26
 } elseif (isset($_GET['kto']) && isset($_GET['blz'])) {
27 27
     $iban = find_iban($_GET['blz'], $_GET['kto']);
28 28
 }
29
-if ($iban == NULL) {
29
+if ($iban == null) {
30 30
     echo "Fehler!";
31 31
     die();
32 32
 }
... ...
@@ -23,7 +23,7 @@ title('Daten Ihres Lastschrift-Mandats');
23 23
 
24 24
 $ref = $_REQUEST['ref'];
25 25
 $mandate = get_sepamandate();
26
-$m = NULL;
26
+$m = null;
27 27
 
28 28
 foreach ($mandate as $man) {
29 29
     if ($man['mandatsreferenz'] == $ref) {
... ...
@@ -66,7 +66,7 @@ if ($m['gueltig_ab'] < date('Y-m-d')) {
66 66
 if ($m['gueltig_bis']) {
67 67
     $gueltigkeit = 'von '.$m['gueltig_ab'].' bis '.$m['gueltig_bis'];
68 68
 }
69
-if ($m['gueltig_ab'] <= date('Y-m-d') && ($m['gueltig_bis'] == NULL || $m['gueltig_bis'] >= date('Y-m-d'))) {
69
+if ($m['gueltig_ab'] <= date('Y-m-d') && ($m['gueltig_bis'] == null || $m['gueltig_bis'] >= date('Y-m-d'))) {
70 70
     output('<p>Das Mandat ist momentan gültig ('.$gueltigkeit.').</p>');
71 71
 } elseif ($m['gueltig_ab'] > date('Y-m-d')) {
72 72
     output('<p>Das Mandat ist noch nicht gültig ('.$gueltigkeit.').</p>');
... ...
@@ -106,5 +106,3 @@ output('<h3>Kontodaten</h3>
106 106
 
107 107
 
108 108
 output('<p>'.internal_link('current', 'Zurück').'</p>');
109
-
110
-?>
... ...
@@ -15,11 +15,11 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
15 15
 */
16 16
 
17 17
 if ($_SESSION['role'] & ROLE_CUSTOMER) {
18
-  $alert = NULL;
18
+    $alert = null;
19 19
     include_once('modules/invoice/include/invoice.php');
20 20
     $unpayed_invoices = 0;
21 21
     $my_invoices = my_invoices();
22
-  foreach($my_invoices AS $inv) {
22
+    foreach ($my_invoices as $inv) {
23 23
         if ($inv['bezahlt'] == 0) {
24 24
             $l = get_lastschrift($inv['id']);
25 25
             if (! $l || $l['status'] == 'rejected') {
... ...
@@ -38,10 +38,8 @@ output('<table><tr><th>Anzahl</th><th>Beschreibung</th><th>Zeitraum</th><th>Einz
38 38
 
39 39
 $counter = 0;
40 40
 
41
-foreach($items AS $item)
42
-{
43
-	if ($flip && $item['startdatum'] > $today)
44
-	{
41
+foreach ($items as $item) {
42
+    if ($flip && $item['startdatum'] > $today) {
45 43
         if ($counter == 0) {
46 44
             output("<tr><td colspan=\"5\"><em>Aktuell keine fälligen Posten</em></td></tr>");
47 45
         }
... ...
@@ -52,11 +50,13 @@ foreach($items AS $item)
52 50
     }
53 51
     $counter++;
54 52
     $desc = $item['startdatum'];
55
-	if ($item['enddatum'] != NULL)
53
+    if ($item['enddatum'] != null) {
56 54
         $desc = $item['startdatum'].' - '.$item['enddatum'];
55
+    }
57 56
     $epreis = $item['betrag'];
58
-	if ($item['brutto'] == 0)
57
+    if ($item['brutto'] == 0) {
59 58
         $epreis = $epreis * (1 + ($item['mwst'] / 100));
59
+    }
60 60
     $gesamt = round($epreis * $item['anzahl'], 2);
61 61
     $epreis = round($epreis, 2);
62 62
     $summe += $gesamt;
... ...
@@ -69,6 +69,3 @@ foreach($items AS $item)
69 69
 output("<tr><td colspan=\"4\" style=\"text-align: right; font-weight: bold; border: none;\">Summe aller Posten:</td>");
70 70
 output("<td style=\"font-weight: bold;\">{$summe} €</td></tr>\n");
71 71
 output('</table><br />');
72
-
73
-
74
-?>
... ...
@@ -30,8 +30,7 @@ title("Jabber-Accounts");
30 30
 
31 31
 output("<table>");
32 32
 
33
-foreach ($jabberaccounts as $acc)
34
-{
33
+foreach ($jabberaccounts as $acc) {
35 34
     $not_ready = '';
36 35
     if ($acc['create'] == 1) {
37 36
         $not_ready = " ".icon_warning('Dieser Account wird in Kürze auf dem Server eingerichtet.');
... ...
@@ -46,8 +45,7 @@ foreach ($jabberaccounts as $acc)
46 45
     }
47 46
     $local = filter_input_general($acc['local']);
48 47
     $domain = new Domain((int) $acc['domain']);
49
-  if ($domain->id == NULL)
50
-  {
48
+    if ($domain->id == null) {
51 49
         $domain = new Domain();
52 50
         $domain->fqdn = config('masterdomain');
53 51
     }
... ...
@@ -58,5 +56,3 @@ output('</table>');
58 56
 
59 57
 addnew("new_account", "Neues Jabber-Konto anlegen");
60 58
 addnew("new_domain", "Eigene Domain für Jabber freischalten");
61
-
62
-?>
... ...
@@ -36,6 +36,3 @@ output(html_form('jabber_chpass', 'save', 'action=chpass', '
36 36
 <input type="hidden" name="accountid" value="'.$account['id'].'" />
37 37
 <input type="submit" name="submit" value="Speichern" />
38 38
 '));
39
-
40
-
41
-?>
... ...
@@ -19,14 +19,17 @@ require_once("inc/security.php");
19 19
 
20 20
 require_once('class/domain.php');
21 21
 
22
-function get_jabber_accounts() {
22
+function get_jabber_accounts()
23
+{
23 24
     require_role(ROLE_CUSTOMER);
24 25
     $customerno = (int) $_SESSION['customerinfo']['customerno'];
25 26
     $result = db_query("SELECT id, `create`, created, lastactivity, local, domain FROM jabber.accounts WHERE customerno=? AND `delete`=0", array($customerno));
26 27
     $accounts = array();
27
-  if (@$result->rowCount() > 0)
28
-    while ($acc = @$result->fetch())
28
+    if (@$result->rowCount() > 0) {
29
+        while ($acc = @$result->fetch()) {
29 30
             array_push($accounts, $acc);
31
+        }
32
+    }
30 33
     return $accounts;
31 34
 }
32 35
 
... ...
@@ -39,13 +42,13 @@ function get_jabberaccount_details($id)
39 42
                 ":id" => $id);
40 43
 
41 44
     $result = db_query("SELECT id, local, domain FROM jabber.accounts WHERE customerno=:customerno AND id=:id", $args);
42
-  if ($result->rowCount() != 1)
45
+    if ($result->rowCount() != 1) {
43 46
         system_failure("Invalid account");
47
+    }
44 48
     $data = $result->fetch();
45
-  if ($data['domain'] == NULL)
49
+    if ($data['domain'] == null) {
46 50
         $data['domain'] = config('masterdomain');
47
-  else
48
-  {
51
+    } else {
49 52
         $dom = new Domain((int) $data['domain']);
50 53
         $dom->ensure_customerdomain();
51 54
         $data['domain'] = $dom->fqdn;
... ...
@@ -71,19 +74,16 @@ function create_jabber_account($local, $domain, $password)
71 74
     $data = array(":customerno" => $_SESSION['customerinfo']['customerno'],
72 75
                 ":local" => filter_input_username($local),
73 76
                 ":domain" => $domain);
74
-  if (! valid_jabber_password($password))
75
-  {
77
+    if (! valid_jabber_password($password)) {
76 78
         input_error('Das Passwort enthält Zeichen, die aufgrund technischer Beschränkungen momentan nicht benutzt werden können.');
77 79
         return;
78 80
     }
79 81
     $data[':password'] = $password;
80 82
   
81
-  if ($domain > 0)
82
-  {
83
+    if ($domain > 0) {
83 84
         $args = array(":domain" => $data[":domain"], ":customerno" => $data[":customerno"]);
84 85
         $result = db_query("SELECT id FROM kundendaten.domains WHERE kunde=:customerno AND jabber=1 AND id=:domain", $args);
85
-    if ($result->rowCount() == 0)
86
-    {
86
+        if ($result->rowCount() == 0) {
87 87
             logger(LOG_WARNING, "modules/jabber/include/jabberaccounts", "jabber", "attempt to create account for invalid domain »{$domain}«");
88 88
             system_failure("Invalid domain!");
89 89
         }
... ...
@@ -91,15 +91,13 @@ function create_jabber_account($local, $domain, $password)
91 91
 
92 92
     $args = array(":domain" => $data[":domain"], ":local" => $data[":local"]);
93 93
     $domainquery = "domain=:domain";
94
-  if ($domain == 0)
95
-  {
94
+    if ($domain == 0) {
96 95
         unset($args[":domain"]);
97
-    $data[":domain"] = NULL;
96
+        $data[":domain"] = null;
98 97
         $domainquery = 'domain IS NULL';
99 98
     }
100 99
     $result = db_query("SELECT id FROM jabber.accounts WHERE local=:local AND {$domainquery}", $args);
101
-  if ($result->rowCount() > 0)
102
-  {
100
+    if ($result->rowCount() > 0) {
103 101
         logger(LOG_WARNING, "modules/jabber/include/jabberaccounts", "jabber", "attempt to create already existing account »{$local}@{$domain}«");
104 102
         system_failure("Diesen Account gibt es bereits!");
105 103
     }
... ...
@@ -113,8 +111,7 @@ function create_jabber_account($local, $domain, $password)
113 111
 function change_jabber_password($id, $password)
114 112
 {
115 113
     require_role(ROLE_CUSTOMER);
116
-  if (! valid_jabber_password($password))
117
-  {
114
+    if (! valid_jabber_password($password)) {
118 115
         input_error('Das Passwort enthält Zeichen, die aufgrund technischer Beschränkungen momentan nicht benutzt werden können.');
119 116
         return;
120 117
     }
... ...
@@ -146,6 +143,3 @@ function new_jabber_domain($id)
146 143
     $d->ensure_customerdomain();
147 144
     db_query("UPDATE kundendaten.domains SET jabber=2 WHERE jabber=0 AND id=?", array($d->id));
148 145
 }
149
-
150
-
151
-?>
... ...
@@ -16,10 +16,6 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
16 16
 
17 17
 $role = $_SESSION['role'];
18 18
 
19
-if ($role & ROLE_CUSTOMER)
20
-{
19
+if ($role & ROLE_CUSTOMER) {
21 20
     $menu["jabber_accounts"] = array("label" => "Jabber", "file" => "accounts", "weight" => 10);
22
-    
23 21
 }
24
-
25
-?>
... ...
@@ -29,8 +29,7 @@ $jabberdomains = get_jabberable_domains();
29 29
 DEBUG($jabberdomains);
30 30
 
31 31
 $options = '';
32
-foreach ($jabberdomains as $dom)
33
-{
32
+foreach ($jabberdomains as $dom) {
34 33
     $options .= '<option value="'.$dom->id.'">'.$dom->fqdn.'</option>'."\n";
35 34
 }
36 35
 
... ...
@@ -47,6 +46,3 @@ output('<p>Erstellen Sie hier ein neues Jabber-Konto. Ihre Änderungen werden na
47 46
 <br />
48 47
 <input type="submit" name="submit" value="Anlegen" />
49 48
 '));
50
-
51
-
52
-?>
... ...
@@ -36,12 +36,14 @@ if (! count($domains)) {
36 36
 $pending_domains = array();
37 37
 $available_domains = array();
38 38
 
39
-foreach ($domains AS $d) {
40
-  if ($d->jabber == 0)
39
+foreach ($domains as $d) {
40
+    if ($d->jabber == 0) {
41 41
         $available_domains[$d->id] = $d->domainname.'.'.$d->tld;
42
-  if ($d->jabber == 2)
42
+    }
43
+    if ($d->jabber == 2) {
43 44
         $pending_domains[] = $d->fqdn;
44 45
     }
46
+}
45 47
 
46 48
 
47 49
 $pending = '';
... ...
@@ -49,8 +51,9 @@ if (count($pending_domains) > 0) {
49 51
     $pending = '<h3>Wartend auf Freischaltung</h3>
50 52
 <p>Folgende Domains sind bereits eingetragen und werden in der kommenden Nacht im Jabber-Server registriert:</p>
51 53
 <ul>';
52
-  foreach($pending_domains AS $d)
54
+    foreach ($pending_domains as $d) {
53 55
         $pending .= '<li>'.$d.'</li>';
56
+    }
54 57
     $pending .= '</ul>';
55 58
 }
56 59
 
... ...
@@ -63,6 +66,3 @@ output('<p>Sie können hier eine Ihrer eigenen Domains für Jabber-Nutzung freis
63 66
 <input type="submit" name="submit" value="Freischalten" />
64 67
 
65 68
 ').$pending);
66
-
67
-
68
-?>
... ...
@@ -26,75 +26,57 @@ require_role(ROLE_CUSTOMER);
26 26
 require_once("inc/debug.php");
27 27
 global $debugmode;
28 28
 
29
-if ($_GET['action'] == 'new')
30
-{
29
+if ($_GET['action'] == 'new') {
31 30
     check_form_token('jabber_new_account');
32 31
     if (filter_input_username($_POST['local']) == '' ||
33 32
       $_POST['domain'] == '' ||
34
-      $_POST['password'] == '')
35
-  {
33
+      $_POST['password'] == '') {
36 34
         input_error('Sie müssen alle Felder ausfüllen!');
37
-  }
38
-  else
39
-  {
35
+    } else {
40 36
         create_jabber_account($_POST['local'], $_POST['domain'], stripslashes($_POST['password']));
41
-    if (! $debugmode)
37
+        if (! $debugmode) {
42 38
             header('Location: accounts');
43 39
         }
44 40
     }
45
-elseif ($_GET['action'] == 'chpass')
46
-{
41
+} elseif ($_GET['action'] == 'chpass') {
47 42
     check_form_token('jabber_chpass');
48 43
     get_jabberaccount_details($_POST['accountid']);
49 44
     if ($_POST['newpass'] == '' ||
50 45
       $_POST['newpass2'] == '' ||
51 46
       $_POST['newpass'] != $_POST['newpass2'] ||
52
-      $_POST['accountid'] == '')
53
-  {
47
+      $_POST['accountid'] == '') {
54 48
         input_error('Bitte zweimal ein neues Passwort eingeben!');
55
-  }
56
-  else
57
-  {
49
+    } else {
58 50
         change_jabber_password($_POST['accountid'], stripslashes($_POST['newpass']));
59
-    if (! $debugmode)
51
+        if (! $debugmode) {
60 52
             header('Location: accounts');
61 53
         }
62 54
     }
63
-elseif ($_GET['action'] == 'delete')
64
-{
55
+} elseif ($_GET['action'] == 'delete') {
65 56
     $title = "Jabber-Account löschen";
66 57
     $section = 'jabber_accounts';
67 58
   
68 59
     $account = get_jabberaccount_details($_GET['account']);
69 60
     $account_string = filter_input_general($account['local'].'@'.$account['domain']);
70 61
     $sure = user_is_sure();
71
-  if ($sure === NULL)
72
-  {
62
+    if ($sure === null) {
73 63
         are_you_sure("action=delete&account={$_GET['account']}", "Möchten Sie den Account »{$account_string}« wirklich löschen?");
74
-  }
75
-  elseif ($sure === true)
76
-  {
64
+    } elseif ($sure === true) {
77 65
         delete_jabber_account($account['id']);
78
-    if (! $debugmode)
66
+        if (! $debugmode) {
79 67
             header("Location: accounts");
80 68
         }
81
-  elseif ($sure === false)
82
-  {
83
-    if (! $debugmode)
69
+    } elseif ($sure === false) {
70
+        if (! $debugmode) {
84 71
             header("Location: accounts");
85 72
         }
86
-
87 73
     }
88
-elseif ($_GET['action'] == 'newdomain')
89
-{
74
+} elseif ($_GET['action'] == 'newdomain') {
90 75
     check_form_token('jabber_new_domain');
91 76
     new_jabber_domain($_REQUEST['domain']);
92 77
     header("Location: accounts");
93
-}
94
-else
78
+} else {
95 79
     system_failure("Unimplemented action");
80
+}
96 81
 
97 82
 output('');
98
-
99
-
100
-?>
... ...
@@ -20,5 +20,5 @@ if ($_SESSION['role'] & ROLE_CUSTOMER) {
20 20
                         'file'    => 'accounts',
21 21
                         'icon'    => 'jabber.png',
22 22
                         'title'   => 'Jabber-Accounts',
23
-                        'alert'   => NULL );
23
+                        'alert'   => null );
24 24
 }
... ...
@@ -22,7 +22,7 @@ require_once('inc/security.php');
22 22
 function get_lists($filter)
23 23
 {
24 24
     $uid = (int) $_SESSION['userinfo']['uid'];
25
-  $result = NULL;
25
+    $result = null;
26 26
     if ($filter) {
27 27
         $filter = '%'.$filter.'%';
28 28
         $result = db_query("SELECT id, created, status, listname, fqdn, admin, archivesize FROM mail.v_mailman_lists WHERE owner=:uid AND (listname LIKE :filter OR fqdn LIKE :filter OR admin LIKE :filter) ORDER BY listname", array('uid' => $uid, 'filter' => $filter));
... ...
@@ -30,8 +30,9 @@ function get_lists($filter)
30 30
         $result = db_query("SELECT id, created, status, listname, fqdn, admin, archivesize FROM mail.v_mailman_lists WHERE owner=:uid ORDER BY listname", array('uid' => $uid));
31 31
     }
32 32
     $ret = array();
33
-  while ($list = $result->fetch())
33
+    while ($list = $result->fetch()) {
34 34
         $ret[] = $list;
35
+    }
35 36
     DEBUG($ret);
36 37
     return $ret;
37 38
 }
... ...
@@ -42,8 +43,9 @@ function get_list($id)
42 43
     $args = array(":id" => $id,
43 44
                 ":uid" => $_SESSION['userinfo']['uid']);
44 45
     $result = db_query("SELECT id, created, status, listname, fqdn, admin, archivesize FROM mail.v_mailman_lists WHERE owner=:uid AND id=:id", $args);
45
-  if ($result->rowCount() < 1)
46
+    if ($result->rowCount() < 1) {
46 47
         system_failure('Die gewünschte Mailingliste konnte nicht gefunden werden');
48
+    }
47 49
     $list = $result->fetch();
48 50
     DEBUG($list);
49 51
 
... ...
@@ -70,13 +72,16 @@ function create_list($listname, $maildomain, $admin)
70 72
     $listname = strtolower($listname);
71 73
     verify_input_username($listname);
72 74
     verify_input_general($admin);
73
-  if (in_array($listname, array("admin", "administrator", "webmaster", "hostmaster", "postmaster")))
75
+    if (in_array($listname, array("admin", "administrator", "webmaster", "hostmaster", "postmaster"))) {
74 76
         system_failure('Der Mailinglistenname '.$listname.' ist unzulässig.');
75
-  if (! check_emailaddr($admin))
77
+    }
78
+    if (! check_emailaddr($admin)) {
76 79
         system_failure('Der Verwalter muss eine gültige E-Mail-Adresse sein ('.$admin.').');
80
+    }
77 81
     $result = db_query("SELECT id FROM mail.mailman_lists WHERE listname LIKE ?", array($listname));
78
-  if ($result->rowCount() > 0)
82
+    if ($result->rowCount() > 0) {
79 83
         system_failure('Eine Liste mit diesem Namen existiert bereits auf unserem Mailinglisten-Server (unter einer Ihrer Domains oder unter einer Domain eines anderen Kunden). Jeder Listenname kann auf dem gesamten Server nur einmal verwendet werden.');
84
+    }
80 85
 
81 86
     $args = array(":listname" => $listname,
82 87
                 ":maildomain" => $maildomain,
... ...
@@ -93,8 +98,9 @@ function get_mailman_domains()
93 98
     $uid = (int) $_SESSION['userinfo']['uid'];
94 99
     $result = db_query("SELECT md.id, md.fqdn FROM mail.v_mailman_domains AS md left join mail.v_domains AS d on (d.id=md.domain) where d.user=?", array($uid));
95 100
     $ret = array();
96
-  while ($dom = $result->fetch())
101
+    while ($dom = $result->fetch()) {
97 102
         $ret[] = $dom;
103
+    }
98 104
     DEBUG($ret);
99 105
     return $ret;
100 106
 }
... ...
@@ -41,41 +41,31 @@ if (count($lists) > 10 || $filter) {
41 41
 }
42 42
 
43 43
 
44
-if (! empty($lists))
45
-{
44
+if (! empty($lists)) {
46 45
     addnew('newlist', 'Neue Mailingliste anlegen');
47 46
     output('<div id="mailman_lists_container">');
48
-  foreach ($lists AS $list)
49
-  {
47
+    foreach ($lists as $list) {
50 48
         $size = $list['archivesize'];
51 49
         $sizestr = $size.' Bytes';
52 50
         if (! $size) {
53 51
             $sizestr = '<em>Kein Archiv</em>';
54
-    }
55
-    else {
52
+        } else {
56 53
             $sizestr = sprintf('%.2f', $size/(1024*1024)).' MB';
57 54
         }
58 55
 
59 56
 
60 57
         $class = 'regular';
61 58
         $status = 'In Betrieb (erstellt am '.strftime('%d.%m.%Y', strtotime($list['created'])).')';
62
-    if ($list['status'] == 'delete')
63
-    {
59
+        if ($list['status'] == 'delete') {
64 60
             $class = 'deleted';
65 61
             $status = 'Wird gelöscht';
66
-    }
67
-    elseif ($list['status'] == 'pending')
68
-    {
62
+        } elseif ($list['status'] == 'pending') {
69 63
             $class = 'new';
70 64
             $status = 'Wird angelegt';
71
-    }
72
-    elseif ($list['status'] == 'newpw')
73
-    {
65
+        } elseif ($list['status'] == 'newpw') {
74 66
             $class = 'edited';
75 67
             $status = 'Neues Passwort angefordert';
76
-    }
77
-    elseif ($list['status'] == 'failure')
78
-    {
68
+        } elseif ($list['status'] == 'failure') {
79 69
             $class = 'error';
80 70
             $status = 'Fehler bei der Erstellung';
81 71
         }
... ...
@@ -85,15 +75,14 @@ if (! empty($lists))
85 75
 
86 76
         output("<div class=\"mailman_list $class\"><p class=\"listname\"><span class=\"listname\">{$list['listname']}</span>@{$list['fqdn']}</p>
87 77
         <p class=\"listadmin\">Verwalter: {$admin}</p><p class=\"status\">Status: {$status}</p><p class=\"archivesize\">Archivgröße: {$sizestr}</p>");
88
-    if ($list['status'] == 'running')
78
+        if ($list['status'] == 'running') {
89 79
             output("<p class=\"operations\">".internal_link('save', other_icon("lock.png", "Neues Passwort anfordern").' Neues Passwort anfordern', "action=newpw&id={$list['id']}")."<br>".internal_link('save', icon_delete("Mailingliste löschen").' Liste löschen', "action=delete&id={$list['id']}")."<br><a href=\"https://".config('mailman_host')."/mailman/admin.cgi/{$list['listname']}\">".other_icon("database_go.png", "Listen-Verwaltung aufrufen")." Verwaltung aufrufen</a></p></div>\n");
90
-    else
80
+        } else {
91 81
             output("</div>\n");
92 82
         }
93
-  output("</div>");
94 83
     }
95
-else
96
-{
84
+    output("</div>");
85
+} else {
97 86
     // keine Listen
98 87
     output('<p><em>Sie betreiben bisher keine Mailinglisten.</em></p>');
99 88
 }
... ...
@@ -16,9 +16,6 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
16 16
 
17 17
 $role = $_SESSION['role'];
18 18
 
19
-if ($role & ROLE_SYSTEMUSER)
20
-{
19
+if ($role & ROLE_SYSTEMUSER) {
21 20
     $menu['mailman_lists'] = array("label" => "Mailinglisten", "file" => "lists", "weight" => 5, 'submenu' => 'email_vmail');
22 21
 }
23
-
24
-?>
... ...
@@ -22,12 +22,12 @@ $section = 'mailman_lists';
22 22
 $domains = get_mailman_domains();
23 23
 
24 24
 $maildomains = array('0' => config('mailman_host'));
25
-foreach ($domains AS $domain)
26
-{
25
+foreach ($domains as $domain) {
27 26
     $maildomains[$domain['id']] = $domain['fqdn'];
28 27
 }
29 28
 
30
-output('<p>Tragen Sie hier die benötigten Daten zur Erstellung einer neuen Mailingliste ein. Die Liste wird <strong>mit etwas Zeitverzögerung</strong> angelegt, Sie erhalten dann eine E-Mail an die unten angegebene Adresse des Listen-Verwalters</p>
29
+output(
30
+    '<p>Tragen Sie hier die benötigten Daten zur Erstellung einer neuen Mailingliste ein. Die Liste wird <strong>mit etwas Zeitverzögerung</strong> angelegt, Sie erhalten dann eine E-Mail an die unten angegebene Adresse des Listen-Verwalters</p>
31 31
 
32 32
 '.html_form('mailman_newlist', 'save', 'action=new', '
33 33
 <table>
... ...
@@ -40,6 +40,3 @@ output('<p>Tragen Sie hier die benötigten Daten zur Erstellung einer neuen Mail
40 40
 
41 41
 <p><strong>Hinweis zu Domains:</strong> Aufgrund der Architektur von Mailman ist es momentan notwendig, bestimmte Domains oder Subdomains vollständig auf Mailman zu konfigurieren. Unter diesen Domains oder Subdomains kann keine anderweitige E-Mail-Adresse benutzt werden. Sofern Sie eine Ihrer eigenen Domains oder eine Subdomain unter einer Ihrer Domains für Mailinglisten benutzen möchten, müssen Sie diese Domain oder Subdomain vorher von einem Administrator anlegen lassen. Sie können danach in dieser Auswahlliste Ihre eigene Domain wählen.</p>'
42 42
 );
43
-
44
-
45
-?>
... ...
@@ -21,67 +21,53 @@ $title = "Neue Mailingliste erstellen";
21 21
 $domains = get_mailman_domains();
22 22
 
23 23
 $maildomains = array('0' => config('mailman_host'));
24
-foreach ($domains AS $domain)
25
-{
24
+foreach ($domains as $domain) {
26 25
     $maildomains[$domain['id']] = $domain['fqdn'];
27 26
 }
28 27
 
29 28
 
30
-if ($_GET['action'] == 'new')
31
-{
29
+if ($_GET['action'] == 'new') {
32 30
     $maildomain = $_POST['maildomain'];
33
-  if ($maildomain == 0)
34
-    $maildomain = NULL;
35
-  else
36
-    if (! isset($maildomains[$maildomain]))
31
+    if ($maildomain == 0) {
32
+        $maildomain = null;
33
+    } elseif (! isset($maildomains[$maildomain])) {
37 34
         system_failure('Ihre Domain-Auswahl scheint ungültig zu sein');
35
+    }
38 36
 
39 37
     create_list($_POST['listname'], $maildomain, $_POST['admin']);
40
-  if (! $debugmode)
38
+    if (! $debugmode) {
41 39
         header('Location: lists');
42 40
     }
43
-
44
-elseif ($_GET['action'] == 'newpw') {
41
+} elseif ($_GET['action'] == 'newpw') {
45 42
     $list = get_list($_GET['id']);
46 43
     $sure = user_is_sure();
47
-  if ($sure === NULL)
48
-  {
44
+    if ($sure === null) {
49 45
         are_you_sure('action=newpw&id='.$list['id'], 'Möchten Sie für die Mailingliste »<strong>'.$list['listname'].'</strong>@'.$list['fqdn'].'« ein neues Passwort anfordern? (Das neue Passwort wird dem Listenverwalter zugeschickt.)');
50
-  }
51
-  elseif ($sure === true)
52
-  {
46
+    } elseif ($sure === true) {
53 47
         request_new_password($list['id']);
54
-    if (! $debugmode)
48
+        if (! $debugmode) {
55 49
             header('Location: lists');
56 50
         }
57
-  elseif ($sure === false)
58
-  {
59
-    if (! $debugmode)
51
+    } elseif ($sure === false) {
52
+        if (! $debugmode) {
60 53
             header('Location: lists');
61 54
         }
62 55
     }
63
-elseif ($_GET['action'] == 'delete') {
56
+} elseif ($_GET['action'] == 'delete') {
64 57
     $list = get_list($_GET['id']);
65 58
     $sure = user_is_sure();
66
-  if ($sure === NULL)
67
-  {
59
+    if ($sure === null) {
68 60
         are_you_sure('action=delete&id='.$list['id'], 'Möchten Sie die Mailingliste »<strong>'.$list['listname'].'</strong>@'.$list['fqdn'].'« wirklich löschen?');
69
-  }
70
-  elseif ($sure === true)
71
-  {
61
+    } elseif ($sure === true) {
72 62
         delete_list($list['id']);
73
-    if (! $debugmode)
63
+        if (! $debugmode) {
74 64
             header('Location: lists');
75 65
         }
76
-  elseif ($sure === false)
77
-  {
78
-    if (! $debugmode)
66
+    } elseif ($sure === false) {
67
+        if (! $debugmode) {
79 68
             header('Location: lists');
80 69
         }
81 70
     }
82
-else
83
-{
71
+} else {
84 72
     system_failure('Function not implemented');
85 73
 }
86
-
87
-
... ...
@@ -30,7 +30,7 @@ $section = 'mysql_overview';
30 30
 title('Beschreibung ändern');
31 31
 
32 32
 if (isset($_GET['db'])) {
33
-  $thisdb = NULL;
33
+    $thisdb = null;
34 34
     foreach ($dbs as $db) {
35 35
         if ($db['name'] == $_GET['db']) {
36 36
             $thisdb = $db;
... ...
@@ -42,7 +42,7 @@ if (isset($_GET['db'])) {
42 42
     output(html_form('mysql_description', 'save', "action=description&db={$thisdb['name']}", $form));
43 43
 }
44 44
 if (isset($_GET['username'])) {
45
-  $thisuser = NULL;
45
+    $thisuser = null;
46 46
     foreach ($users as $user) {
47 47
         if ($user['username'] == $_GET['username']) {
48 48
             $thisuser = $user;
... ...
@@ -17,11 +17,11 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
17 17
 function get_mysql_accounts($UID)
18 18
 {
19 19
     $result = db_query("SELECT id, username, description, created FROM misc.mysql_accounts WHERE useraccount=? ORDER BY username", array($UID));
20
-  if ($result->rowCount() == 0)
20
+    if ($result->rowCount() == 0) {
21 21
         return array();
22
+    }
22 23
     $list = array();
23
-  while ($item = $result->fetch())
24
-  {
24
+    while ($item = $result->fetch()) {
25 25
         $list[] = $item;
26 26
     }
27 27
     return $list;
... ...
@@ -30,11 +30,11 @@ function get_mysql_accounts($UID)
30 30
 function get_mysql_databases($UID)
31 31
 {
32 32
     $result = db_query("SELECT id, name, description, created FROM misc.mysql_database WHERE useraccount=? ORDER BY name", array($UID));
33
-  if ($result->rowCount() == 0)
33
+    if ($result->rowCount() == 0) {
34 34
         return array();
35
+    }
35 36
     $list = array();
36
-  while ($item = $result->fetch())
37
-  {
37
+    while ($item = $result->fetch()) {
38 38
         $list[] = $item;
39 39
     }
40 40
     return $list;
... ...
@@ -43,13 +43,13 @@ function get_mysql_databases($UID)
43 43
 function set_database_description($dbname, $description)
44 44
 {
45 45
     $dbs = get_mysql_databases($_SESSION['userinfo']['uid']);
46
-  $thisdb = NULL;
46
+    $thisdb = null;
47 47
     foreach ($dbs as $db) {
48 48
         if ($db['name'] == $dbname) {
49 49
             $thisdb = $db;
50 50
         }
51 51
     }
52
-  if ($thisdb == NULL) {
52
+    if ($thisdb == null) {
53 53
         system_failure('Ungültige Datenbank');
54 54
     }
55 55
     $args = array(":id" => $thisdb['id'],
... ...
@@ -60,13 +60,13 @@ function set_database_description($dbname, $description)
60 60
 function set_dbuser_description($username, $description)
61 61
 {
62 62
     $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
63
-  $thisuser = NULL;
63
+    $thisuser = null;
64 64
     foreach ($users as $user) {
65 65
         if ($user['username'] == $username) {
66 66
             $thisuser = $user;
67 67
         }
68 68
     }
69
-  if ($thisuser == NULL) {
69
+    if ($thisuser == null) {
70 70
         system_failure('Ungültiger Benutzer');
71 71
     }
72 72
     $args = array(":id" => $thisuser['id'],
... ...
@@ -91,15 +91,16 @@ function get_mysql_access($db, $account)
91 91
 {
92 92
     $uid = $_SESSION['userinfo']['uid'];
93 93
     global $mysql_access;
94
-  if (!is_array($mysql_access))
95
-  {
94
+    if (!is_array($mysql_access)) {
96 95
         $mysql_access = array();
97 96
         $result = db_query("SELECT db.name AS db, acc.username AS user FROM misc.mysql_access AS access LEFT JOIN misc.mysql_database AS db ON (db.id=access.database) LEFT JOIN misc.mysql_accounts AS acc ON (acc.id = access.user) WHERE acc.useraccount=:uid OR db.useraccount=:uid", array(":uid" => $uid));
98
-    if ($result->rowCount() == 0)
97
+        if ($result->rowCount() == 0) {
99 98
             return false;
100
-    while ($line = $result->fetch(PDO::FETCH_OBJ))
99
+        }
100
+        while ($line = $result->fetch(PDO::FETCH_OBJ)) {
101 101
             $mysql_access[$line->db][$line->user] = true;
102 102
         }
103
+    }
103 104
     return (array_key_exists($db, $mysql_access) && array_key_exists($account, $mysql_access[$db]));
104 105
 }
105 106
 
... ...
@@ -109,32 +110,29 @@ function set_mysql_access($db, $account, $status)
109 110
     $uid = $_SESSION['userinfo']['uid'];
110 111
     DEBUG("User »{$account}« soll ".($status ? "" : "NICHT ")."auf die Datenbank »{$db}« zugreifen");
111 112
     $query = '';
112
-  if ($status)
113
-  {
114
-    if (get_mysql_access($db, $account))
115
-      return NULL;
113
+    if ($status) {
114
+        if (get_mysql_access($db, $account)) {
115
+            return null;
116
+        }
116 117
         $args = array(":db" => $db, ":uid" => $uid);
117 118
         $result = db_query("SELECT id FROM misc.mysql_database WHERE name=:db AND useraccount=:uid", $args);
118
-    if ($result->rowCount() != 1)
119
-    {
119
+        if ($result->rowCount() != 1) {
120 120
             logger(LOG_ERR, "modules/mysql/include/mysql", "mysql", "cannot find database {$db}");
121 121
             system_failure("cannot find database »{$db}«");
122 122
         }
123 123
         $args = array(":account" => $account, ":uid" => $uid);
124 124
         $result = db_query("SELECT id FROM misc.mysql_accounts WHERE username=:account AND useraccount=:uid", $args);
125
-    if ($result->rowCount() != 1)
126
-    {
125
+        if ($result->rowCount() != 1) {
127 126
             logger(LOG_ERR, "modules/mysql/include/mysql", "mysql", "cannot find user {$account}");
128 127
             system_failure("cannot find database user »{$account}«");
129 128
         }
130 129
         $args = array(":db" => $db, ":uid" => $uid, ":account" => $account);
131 130
         db_query("INSERT INTO misc.mysql_access (`database`,user) VALUES ((SELECT id FROM misc.mysql_database WHERE name=:db AND useraccount=:uid LIMIT 1), (SELECT id FROM misc.mysql_accounts WHERE username=:account AND useraccount=:uid))", $args);
132 131
         logger(LOG_INFO, "modules/mysql/include/mysql", "mysql", "granting access on »{$db}« to »{$account}«");
132
+    } else {
133
+        if (! get_mysql_access($db, $account)) {
134
+            return null;
133 135
         }
134
-  else
135
-  {
136
-    if (! get_mysql_access($db, $account))
137
-      return NULL;
138 136
         $args = array(":db" => $db, ":account" => $account, ":uid" => $uid);
139 137
         db_query("DELETE FROM misc.mysql_access WHERE `database`=(SELECT id FROM misc.mysql_database WHERE name=:db AND useraccount=:uid LIMIT 1) AND user=(SELECT id FROM misc.mysql_accounts WHERE username=:account AND useraccount=:uid)", $args);
140 138
         logger(LOG_INFO, "modules/mysql/include/mysql", "mysql", "revoking access on »{$db}« from »{$account}«");
... ...
@@ -144,11 +142,10 @@ function set_mysql_access($db, $account, $status)
144 142
 
145 143
 function create_mysql_account($username, $description = '')
146 144
 {
147
-  if (! validate_mysql_username($username))
148
-  {
145
+    if (! validate_mysql_username($username)) {
149 146
         logger(LOG_WARNING, "modules/mysql/include/mysql", "mysql", "illegal username »{$username}«");
150 147
         system_failure("Der eingegebene Benutzername entspricht leider nicht der Konvention. Bitte tragen Sie einen passenden Namen ein.");
151
-    return NULL;
148
+        return null;
152 149
     }
153 150
     $args = array(":uid" => $_SESSION['userinfo']['uid'],
154 151
                 ":username" => $username,
... ...
@@ -167,16 +164,15 @@ function delete_mysql_account($username)
167 164
 }
168 165
 
169 166
 
170
-function create_mysql_database($dbname, $description = NULL, $server = NULL)
171
-{
172
-  if (! validate_mysql_dbname($dbname))
167
+function create_mysql_database($dbname, $description = null, $server = null)
173 168
 {
169
+    if (! validate_mysql_dbname($dbname)) {
174 170
         logger(LOG_WARNING, "modules/mysql/include/mysql", "mysql", "illegal db-name »{$dbname}«");
175 171
         system_failure("Der eingegebene Datenbankname entspricht leider nicht der Konvention. Bitte tragen Sie einen passenden Namen ein.");
176
-    return NULL;
172
+        return null;
177 173
     }
178 174
     if (! in_array($server, additional_servers()) || ($server == my_server_id())) {
179
-    $server = NULL;
175
+        $server = null;
180 176
     }
181 177
     $args = array(":dbname" => $dbname,
182 178
                 ":uid" => $_SESSION['userinfo']['uid'],
... ...
@@ -236,6 +232,3 @@ function has_mysql_user($username)
236 232
     $result = db_query("SELECT NULL FROM misc.mysql_accounts WHERE username=:username AND useraccount=:uid", $args);
237 233
     return ($result->rowCount() == 1);
238 234
 }
239
-
240
-
241
-?>
... ...
@@ -16,9 +16,6 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
16 16
 
17 17
 $role = $_SESSION['role'];
18 18
 
19
-if ($role & ROLE_SYSTEMUSER)
20
-{
19
+if ($role & ROLE_SYSTEMUSER) {
21 20
     $menu["mysql_overview"] = array("label" => "MySQL-Datenbank", "file" => "overview", "weight" => 20);
22
-    
23 21
 }
24
-?>
... ...
@@ -60,8 +59,7 @@ if (count($dbs) > 0 || count($users) > 0) {
60 59
   <tr><th>&#160;</th><th style="background-color: #729bb3; color: #fff;padding: 0.2em;" colspan="'.(count($users)+1).'">Benutzerkonten</th></tr>
61 60
   <tr><th style="background-color: #729bb3; color: #fff;padding: 0.2em; text-align: left;">Datenbanken</th>');
62 61
 
63
-  foreach ($users as $user)
64
-  {
62
+    foreach ($users as $user) {
65 63
         $username = $user["username"];
66 64
         //$username = str_replace('_', '_ ', $user['username']);
67 65
         $desc = '';
... ...
@@ -76,8 +74,7 @@ if (count($dbs) > 0 || count($users) > 0) {
76 74
 
77 75
     $formtoken = generate_form_token('mysql_permchange');
78 76
 
79
-  foreach($dbs as $db)
80
-  {
77
+    foreach ($dbs as $db) {
81 78
         $phpmyadmin = "https://mysql-{$servers[$db['name']]}/";
82 79
         $desc = '';
83 80
         if ($db['description']) {
... ...
@@ -122,21 +116,17 @@ if (count($dbs) > 0) {
122 116
   <p><img src=\"{$prefix}images/phpmyadmin.png\" style=\"width: 120px; height: 70px; float: right;\" />Zur Verwaltung der Datenbank-Inhalte stellen wir Ihnen eine stets aktualisierte Version von phpMyAdmin zur Verfügung.</p>");
123 117
     if (count($myservers) == 1) {
124 118
         output("<p><strong><a href=\"https://mysql-{$myservers[0]}/\">phpMyAdmin aufrufen</a></strong></p>");
125
-  }
126
-  else {
119
+    } else {
127 120
         output("<p><em>Ihre Datenbanken befinden sich auf unterschiedlichen Servern, daher müssen Sie die jeweils passende Adresse für phpMyAdmin benutzen. Klicken Sie auf das Symbol ".other_icon("database_go.png", "Datenbank-Verwaltung über phpMyAdmin")." oben neben der jeweiligen Datenbank.</em></p>");
128 121
     }
129
-
130 122
 }
131 123
 if (count($users) > 0) {
132
-
133 124
     $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
134 125
 
135 126
 
136 127
 
137 128
     $my_users = array();
138
-  foreach ($users as $u)
139
-  {
129
+    foreach ($users as $u) {
140 130
         $my_users[$u['username']] = $u['username'];
141 131
     }
142 132
     $form = '<div>
... ...
@@ -151,7 +141,4 @@ if (count($users) > 0) {
151 141
   <p>Hier können Sie das Passwort eines MySQL-Benutzeraccounts ändern bzw. neu setzen</p>
152 142
 
153 143
   '.html_form('mysql_databases', 'save', 'action=change_pw', $form).'<br />');
154
-
155
-
156 144
 }
157
-?>
... ...
@@ -32,7 +32,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'newdb') {
32 32
     check_form_token('mysql_newdb');
33 33
     $dbname = $_POST['newdb'];
34 34
     $desc = $_POST['description'];
35
-  $server = NULL;
35
+    $server = null;
36 36
     if (isset($_POST['server'])) {
37 37
         $server = $_POST['server'];
38 38
     }
... ...
@@ -77,41 +77,32 @@ if (isset($_GET['action']) && $_GET['action'] == 'description') {
77 77
 
78 78
 
79 79
 if (isset($_GET['action'])) {
80
-  switch ($_GET['action'])
81
-  {
80
+    switch ($_GET['action']) {
82 81
     case 'delete_db':
83
-      if (! has_mysql_database($_GET['db']))
82
+      if (! has_mysql_database($_GET['db'])) {
84 83
           system_failure('Ungültige Datenbank');
84
+      }
85 85
       $sure = user_is_sure();
86
-      if ($sure === NULL)
87
-      {
86
+      if ($sure === null) {
88 87
           are_you_sure("action=delete_db&db={$_GET['db']}", "Möchten Sie die Datenbank »{$_GET['db']}« wirklich löschen?");
89
-      }
90
-      elseif ($sure === true)
91
-      {
88
+      } elseif ($sure === true) {
92 89
           delete_mysql_database($_GET['db']);
93 90
           redirect('overview');
94
-      }
95
-      elseif ($sure === false)
96
-      {
91
+      } elseif ($sure === false) {
97 92
           redirect('overview');
98 93
       }
99 94
       break;
100 95
     case 'delete_user':
101
-      if (! has_mysql_user($_GET['user']))
96
+      if (! has_mysql_user($_GET['user'])) {
102 97
           system_failure('Ungültiger Benutzer');
98
+      }
103 99
       $sure = user_is_sure();
104
-      if ($sure === NULL)
105
-      {
100
+      if ($sure === null) {
106 101
           are_you_sure("action=delete_user&user={$_GET['user']}", "Möchten Sie den Benutzer »{$_GET['user']}« wirklich löschen?");
107
-      }
108
-      elseif ($sure === true)
109
-      {
102
+      } elseif ($sure === true) {
110 103
           delete_mysql_account($_GET['user']);
111 104
           redirect('overview');
112
-      }
113
-      elseif ($sure === false)
114
-      {
105
+      } elseif ($sure === false) {
115 106
           redirect('overview');
116 107
       }
117 108
       break;
... ...
@@ -128,24 +119,19 @@ if (isset($_GET['action'])) {
128 119
 $dbs = get_mysql_databases($_SESSION['userinfo']['uid']);
129 120
 $users = get_mysql_accounts($_SESSION['userinfo']['uid']);
130 121
 
131
-if (isset($_POST['accesseditor']))
132
-{
122
+if (isset($_POST['accesseditor'])) {
133 123
     check_form_token('mysql_databases');
134 124
   
135
-  foreach ($dbs as $db)
136
-  {
125
+    foreach ($dbs as $db) {
137 126
         $db = $db['name'];
138
-    foreach ($users as $user)
139
-    {
127
+        foreach ($users as $user) {
140 128
             $user = $user['username'];
141
-      if (! isset($_POST['access'][$db]))
129
+            if (! isset($_POST['access'][$db])) {
142 130
                 set_mysql_access($db, $user, false);
143
-      else
131
+            } else {
144 132
                 set_mysql_access($db, $user, in_array($user, $_POST['access'][$db]));
145 133
             }
146 134
         }
147
-  $mysql_access = NULL;
148 135
     }
149
-
150
-
151
-?>
136
+    $mysql_access = null;
137
+}
... ...
@@ -20,5 +20,5 @@ if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
20 20
                         'file'    => 'overview',
21 21
                         'icon'    => 'mysql.png',
22 22
                         'title'   => 'MySQL-Datenbanken',
23
-                        'alert'   => NULL );
23
+                        'alert'   => null );
24 24
 }
... ...
@@ -14,12 +14,14 @@ http://creativecommons.org/publicdomain/zero/1.0/
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.
15 15
 */
16 16
 
17
-function set_newsletter_address($address) {
17
+function set_newsletter_address($address)
18
+{
18 19
     $cid = $_SESSION['customerinfo']['customerno'];
19 20
     db_query("UPDATE kundendaten.kunden SET email_newsletter=:address WHERE id=:cid", array(":address" => $address, ":cid" => $cid));
20 21
 }
21 22
 
22
-function get_newsletter_address() {
23
+function get_newsletter_address()
24
+{
23 25
     $cid = $_SESSION['customerinfo']['customerno'];
24 26
     $result = db_query("SELECT email_newsletter FROM kundendaten.kunden WHERE id=?", array($cid));
25 27
     $r = $result->fetch();
... ...
@@ -27,7 +29,8 @@ function get_newsletter_address() {
27 29
 }
28 30
 
29 31
 
30
-function get_latest_news() {
32
+function get_latest_news()
33
+{
31 34
     $result = db_query("SELECT id, date, subject, content FROM misc.news WHERE date > CURDATE() - INTERVAL 2 YEAR ORDER BY date DESC");
32 35
     $ret = array();
33 36
     while ($item = $result->fetch()) {
... ...
@@ -38,7 +41,8 @@ function get_latest_news() {
38 41
 }
39 42
 
40 43
 
41
-function get_news_item($id) {
44
+function get_news_item($id)
45
+{
42 46
     $id = (int) $id;
43 47
     $result = db_query("SELECT date, subject, content FROM misc.news WHERE id=?", array($id));
44 48
     $ret = $result->fetch();
... ...
@@ -16,11 +16,6 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
16 16
 
17 17
 $role = $_SESSION['role'];
18 18
 
19
-if ($role & ROLE_CUSTOMER)
20
-{
19
+if ($role & ROLE_CUSTOMER) {
21 20
     $menu["newsletter_newsletter"] = array("label" => "Newsletter", "file" => "newsletter", "weight" => 5, "submenu" => "index_index");
22
-
23
-    
24 21
 }
25
-
26
-?>
... ...
@@ -21,30 +21,26 @@ require_once("inc/base.php");
21 21
 
22 22
 if ((isset($_REQUEST['newsletter']) && $_REQUEST['newsletter'] == 'no') || (isset($_REQUEST['recipient']) && $_REQUEST['recipient'] == "")) {
23 23
     $sure = user_is_sure();
24
-  if ($sure === NULL)
25
-  {
24
+    if ($sure === null) {
26 25
         check_form_token('newsletter');
27 26
         are_you_sure("newsletter=no", "Wenn Sie keinen Newsletter abonnieren, erhalten Sie von uns keine Informationen zu laufenden Änderungen bei schokokeks.org. Beachten Sie bitte dennoch regelmäßig die Einträge auf dieser Website, unser Weblog und unsere Status-Seite. Möchten Sie den Newsletter wirklich abbestellen?");
28
-  }
29
-  elseif ($sure === true)
30
-  {
31
-    set_newsletter_address(NULL);
32
-    if (! $debugmode)
27
+    } elseif ($sure === true) {
28
+        set_newsletter_address(null);
29
+        if (! $debugmode) {
33 30
             header('Location: newsletter');
34 31
         }
35
-  elseif ($sure === false)
36
-  {
37
-    if (! $debugmode)
32
+    } elseif ($sure === false) {
33
+        if (! $debugmode) {
38 34
             header('Location: newsletter');
39 35
         }
36
+    }
40 37
 } else {
41 38
     check_form_token('newsletter');
42 39
     if (! check_emailaddr($_REQUEST['recipient']) || filter_input_general($_REQUEST['recipient']) != $_REQUEST['recipient']) {
43 40
         system_failure("Keine gültige E-Mail-Adresse!");
44 41
     }
45 42
     set_newsletter_address($_REQUEST['recipient']);
46
-  if (! $debugmode)
43
+    if (! $debugmode) {
47 44
         header('Location: newsletter');
48 45
     }
49
-
50
-
46
+}
... ...
@@ -20,21 +20,20 @@ function customer_with_email($email)
20 20
 {
21 21
     $email = db_escape_string($email);
22 22
     $result = db_query("SELECT id FROM kundendaten.kunden WHERE email='{$email}' OR email_rechnung='{$email}' OR email_extern='{$email}' LIMIT 1;");
23
-  if ($result->rowCount() == 0)
24
-    return NULL;
25
-  else
23
+    if ($result->rowCount() == 0) {
24
+        return null;
25
+    } else {
26 26
         return $result->fetch(PDO::FETCH_OBJ)->id;
27 27
     }
28
+}
28 29
 
29 30
 
30 31
 
31 32
 function create_customer($data)
32 33
 {
33
-
34
-  if (customer_with_email($data['email']) !== NULL)
35
-  {
34
+    if (customer_with_email($data['email']) !== null) {
36 35
         logger(LOG_WARNING, 'modules/register/include/register', 'register', "Attempt to create customer with duplicate email »{$data['email']}«");
37
-    return NULL;
36
+        return null;
38 37
     }
39 38
 
40 39
     logger(LOG_INFO, 'modules/register/include/register', 'register', "Creating new account: ".print_r($data, true));
... ...
@@ -52,10 +50,11 @@ function send_initial_customer_token($customerno)
52 50
     $token = get_customer_token($customerno);
53 51
     $customer = get_customer_info($customerno);
54 52
     $anrede = "Sehr geehrte Damen und Herren";
55
-  if ($customer['title'] == 'Herr')
53
+    if ($customer['title'] == 'Herr') {
56 54
         $anrede = "Sehr geehrter Herr {$customer['name']}";
57
-  elseif ($customer['title'] == 'Frau')
55
+    } elseif ($customer['title'] == 'Frau') {
58 56
         $anrede = "Sehr geehrte Frau {$customer['name']}";
57
+    }
59 58
     $msg = "{$anrede},
60 59
 
61 60
 wir freuen uns, Sie bei schokokeks.org begrüßen zu dürfen.
... ...
@@ -109,10 +106,11 @@ function welcome_customer($customerno)
109 106
     $customerno = (int) $customerno;
110 107
     $customer = get_customer_info($customerno);
111 108
     $anrede = "Sehr geehrte Damen und Herren";
112
-  if ($customer['title'] == 'Herr')
109
+    if ($customer['title'] == 'Herr') {
113 110
         $anrede = "Sehr geehrter Herr {$customer['name']}";
114
-  elseif ($customer['title'] == 'Frau')
111
+    } elseif ($customer['title'] == 'Frau') {
115 112
         $anrede = "Sehr geehrte Frau {$customer['name']}";
113
+    }
116 114
     $msg = "{$anrede}.
117 115
 
118 116
 Herzlich willkommen bei schokokeks.org!
... ...
@@ -136,9 +134,3 @@ Informationen. Schauen Sie sich um, es lohnt sich!
136 134
 
137 135
     send_mail($customer['email'], "Willkommen bei schokokeks.org", $msg);
138 136
 }
139
-
140
-
141
-
142
-
143
-
144
-?>
... ...
@@ -16,12 +16,9 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
16 16
 
17 17
 $role = $_SESSION['role'];
18 18
 
19
-switch ($role)
20
-{
19
+switch ($role) {
21 20
   case ROLE_ANONYMOUS:
22 21
     $menu["register_index"] = array("label" => "Kunde werden", "file" => "index", "weight" => 0);
23 22
     break;
24 23
     
25 24
 }
26
-
27
-?>
... ...
@@ -22,7 +22,7 @@ if (! isset($_SESSION['admin_user'])) {
22 22
 }
23 23
 
24 24
 $admin_user = $_SESSION['admin_user'];
25
-$role = find_role($admin_user, '', True);
25
+$role = find_role($admin_user, '', true);
26 26
 if ($role & ROLE_SYSADMIN) {
27 27
     setup_session($role, $admin_user);
28 28
     unset($_SESSION['admin_user']);
... ...
@@ -21,8 +21,9 @@ function list_system_users()
21 21
     $result = db_query("SELECT uid,username FROM system.v_useraccounts ORDER BY username");
22 22
   
23 23
     $ret = array();
24
-  while ($item = $result->fetch(PDO::FETCH_OBJ))
24
+    while ($item = $result->fetch(PDO::FETCH_OBJ)) {
25 25
         array_push($ret, $item);
26
+    }
26 27
     return $ret;
27 28
 }
28 29
 
... ...
@@ -34,8 +35,9 @@ function list_customers()
34 35
     $result = db_query("SELECT id, IF(firma IS NULL, CONCAT_WS(' ', vorname, nachname), CONCAT(firma, ' (', CONCAT_WS(' ', vorname, nachname), ')')) AS name FROM kundendaten.kunden");
35 36
   
36 37
     $ret = array();
37
-  while ($item = $result->fetch(PDO::FETCH_OBJ))
38
+    while ($item = $result->fetch(PDO::FETCH_OBJ)) {
38 39
         array_push($ret, $item);
40
+    }
39 41
     return $ret;
40 42
 }
41 43
 
... ...
@@ -44,7 +46,7 @@ function customer_details($id)
44 46
     $id = (int) $id;
45 47
     $result = db_query("SELECT id, IF(firma IS NULL, CONCAT_WS(' ', vorname, nachname), CONCAT(firma, ' (', CONCAT_WS(' ', vorname, nachname), ')')) AS name FROM kundendaten.kunden WHERE id=?", array($id));
46 48
     if ($result->rowCount() < 1) {
47
-        return NULL;
49
+        return null;
48 50
     }
49 51
     $kunde = $result->fetch();
50 52
     return $kunde;
... ...
@@ -63,16 +65,18 @@ function find_customers($string)
63 65
                      "notizen LIKE :string OR email_rechnung LIKE :string OR ".
64 66
                      "email LIKE :string OR email_extern LIKE :string OR u.name LIKE :string OR ".
65 67
                      "u.username LIKE :string OR k.id=:number OR u.uid=:number", $args);
66
-  while ($entry = $result->fetch())
68
+    while ($entry = $result->fetch()) {
67 69
         $return[] = $entry['id'];
70
+    }
68 71
 
69 72
     unset($args[':number']);
70 73
     $result = db_query("SELECT kunde FROM kundendaten.domains WHERE kunde IS NOT NULL AND (
71 74
                       domainname LIKE :string OR CONCAT_WS('.', domainname, tld) LIKE :string
72 75
                       )", $args);
73 76
 
74
-  while ($entry = $result->fetch())
77
+    while ($entry = $result->fetch()) {
75 78
         $return[] = $entry['kunde'];
79
+    }
76 80
 
77 81
     return $return;
78 82
 }
... ...
@@ -84,8 +88,9 @@ function find_users_for_customer($id)
84 88
     $return = array();
85 89
     $result = db_query("SELECT uid, username, name FROM system.useraccounts WHERE ".
86 90
                      "kunde=?", array($id));
87
-  while ($entry = $result->fetch())
91
+    while ($entry = $result->fetch()) {
88 92
         $return[] = $entry;
93
+    }
89 94
 
90 95
     return $return;
91 96
 }
... ...
@@ -93,7 +98,8 @@ function find_users_for_customer($id)
93 98
 
94 99
 
95 100
 
96
-function build_results($term) {
101
+function build_results($term)
102
+{
97 103
     global $ret;
98 104
     $ret = array();
99 105
   
... ...
@@ -150,14 +156,15 @@ function build_results($term) {
150 156
 }
151 157
 
152 158
 
153
-function su($type, $id) {
154
-  $role = NULL;
159
+function su($type, $id)
160
+{
161
+    $role = null;
155 162
     $admin_user = $_SESSION['userinfo']['username'];
156 163
     $_SESSION['admin_user'] = $admin_user;
157
-  $role = find_role($id, '', True);
164
+    $role = find_role($id, '', true);
158 165
     if (!$role) {
159 166
         unset($_SESSION['admin_user']);
160
-    return False;
167
+        return false;
161 168
     }
162 169
     setup_session($role, $id);
163 170
     if ($type == 'c') {
... ...
@@ -16,17 +16,13 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
16 16
 
17 17
 $role = $_SESSION['role'];
18 18
 
19
-if ($role & ROLE_CUSTOMER)
20
-{
19
+if ($role & ROLE_CUSTOMER) {
21 20
     if (have_module('systemuser')) {
22 21
         $menu["su_su_customer"] = array("label" => "Benutzer wechseln", "file" => "su_customer", "weight" => -10, "submenu" => "systemuser_account");
23 22
     } else {
24 23
         $menu["su_su_customer"] = array("label" => "Benutzer wechseln", "file" => "su_customer", "weight" => 90);
25 24
     }
26 25
 }
27
-if ($role & ROLE_SYSADMIN)
28
-{
26
+if ($role & ROLE_SYSADMIN) {
29 27
     $menu["su_su"] = array("label" => "Su-Login", "file" => "su", "weight" => -10);
30 28
 }
31
-
32
-?>
... ...
@@ -25,8 +25,7 @@ require_role(ROLE_SYSADMIN);
25 25
 
26 26
 
27 27
 
28
-if (isset($_GET['do']))
29
-{
28
+if (isset($_GET['do'])) {
30 29
     if ($_SESSION['su_ajax_timestamp'] < time() - 30) {
31 30
         system_failure("Die su-Auswahl ist schon abgelaufen!");
32 31
     }
... ...
@@ -35,12 +34,11 @@ if (isset($_GET['do']))
35 34
     su($type, $id);
36 35
 }
37 36
 
38
-$search = NULL;
39
-if (isset($_POST['query']))
40
-{
37
+$search = null;
38
+if (isset($_POST['query'])) {
41 39
     check_form_token('su_su');
42 40
     $id = filter_input_general($_POST['query']);
43
-  if (! su(NULL, $id)) {
41
+    if (! su(null, $id)) {
44 42
         $search = $_POST['query'];
45 43
     }
46 44
 }
... ...
@@ -51,8 +49,9 @@ output('<p>Hiermit können Sie (als Admin) das Webinterface mit den Rechten eine
51 49
 ');
52 50
 
53 51
 $debug = '';
54
-if ($debugmode)
52
+if ($debugmode) {
55 53
     $debug = 'debug&amp;';
54
+}
56 55
 
57 56
 require_once('inc/jquery.php');
58 57
 // lädt die JS-Datei mit gleichem basename
... ...
@@ -23,8 +23,7 @@ require_once('su.php');
23 23
 
24 24
 require_role(ROLE_CUSTOMER);
25 25
 
26
-if (isset($_GET['uid']))
27
-{
26
+if (isset($_GET['uid'])) {
28 27
     $uid = (int) $_GET['uid'];
29 28
     $token = $_GET['token'];
30 29
     $cid = (int) $_SESSION['customerinfo']['customerno'];
... ...
@@ -22,23 +22,20 @@ $section = 'subusers_subusers';
22 22
 
23 23
 if (isset($_GET['subuser'])) {
24 24
     $sure = user_is_sure();
25
-  if ($sure === NULL)
26
-  {
25
+    if ($sure === null) {
27 26
         $subuser = load_subuser($_GET['subuser']);
28 27
         are_you_sure("subuser={$subuser['id']}", '
29 28
     <p>Soll der zusätzliche Admin-Zugang »'.$subuser['username'].'« wirklich gelöscht werden?</p>');
30
-  }
31
-  elseif ($sure === true)
32
-  {
29
+    } elseif ($sure === true) {
33 30
         delete_subuser($_GET['subuser']);
34
-    if (! $debugmode)
31
+        if (! $debugmode) {
35 32
             header('Location: subusers');
36
-    die();
37 33
         }
38
-  elseif ($sure === false)
39
-  {
40
-    if (! $debugmode)
34
+        die();
35
+    } elseif ($sure === false) {
36
+        if (! $debugmode) {
41 37
             header("Location: subusers");
38
+        }
42 39
         die();
43 40
     }
44 41
 }
... ...
@@ -25,8 +25,7 @@ function list_subusers()
25 25
     $uid = (int) $_SESSION['userinfo']['uid'];
26 26
     $result = db_query("SELECT id, username, modules FROM system.subusers WHERE uid=?", array($uid));
27 27
     $subusers = array();
28
-  while ($item = $result->fetch())
29
-  {
28
+    while ($item = $result->fetch()) {
30 29
         $item['modules'] = explode(',', $item['modules']);
31 30
         $subusers[] = $item;
32 31
     }
... ...
@@ -35,7 +34,8 @@ function list_subusers()
35 34
 }
36 35
 
37 36
 
38
-function load_subuser($id) {
37
+function load_subuser($id)
38
+{
39 39
     $args = array(":id" => $id, ":uid" => $_SESSION['userinfo']['uid']);
40 40
   
41 41
     $result = db_query("SELECT id, username, modules FROM system.subusers WHERE uid=:uid AND id=:id", $args);
... ...
@@ -53,15 +53,16 @@ function available_modules()
53 53
     // Das su-Modul ist hierfuer unwichtig
54 54
     unset($allmodules['su']);
55 55
 
56
-  foreach ($allmodules as $modname => $modinfo)
57
-  {
58
-    if (isset($modinfo['permission']))
56
+    foreach ($allmodules as $modname => $modinfo) {
57
+        if (isset($modinfo['permission'])) {
59 58
             $modules[$modname] = $modinfo['permission'];
60 59
         }
60
+    }
61 61
     return $modules;
62 62
 }
63 63
 
64
-function delete_subuser($id) {
64
+function delete_subuser($id)
65
+{
65 66
     $args = array(":id" => $id, ":uid" => $_SESSION['userinfo']['uid']);
66 67
   
67 68
     db_query("DELETE FROM system.subusers WHERE id=:id AND uid=:uid", $args);
... ...
@@ -69,7 +70,7 @@ function delete_subuser($id) {
69 70
 
70 71
 function empty_subuser()
71 72
 {
72
-  $subuser = array("id" => NULL, 
73
+    $subuser = array("id" => null,
73 74
                    "username" => $_SESSION['userinfo']['username'].'_',
74 75
                    "modules" => array('index'));
75 76
     return $subuser;
... ...
@@ -20,6 +20,3 @@ if ($role & ROLE_SYSTEMUSER) {
20 20
     $menu["subusers_subusers"] = array("label" => "Zusätzliche Admins", "file" => "subusers", "weight" => 1, "submenu" => "systemuser_account");
21 21
     //$menu["subusers_subusers"] = array("label" => "Zusätzliche Admins", "file" => "subusers", "weight" => 1);
22 22
 }
23
-
24
-
25
-?>
... ...
@@ -35,6 +35,6 @@ if (isset($_GET['id']) && (int) $_GET['id'] != 0) {
35 35
 }
36 36
 
37 37
 
38
-if (! $debugmode)
38
+if (! $debugmode) {
39 39
     header('Location: subusers');
40
-
40
+}
... ...
@@ -29,8 +29,7 @@ $subusers = list_subusers();
29 29
 $available_modules = available_modules();
30 30
 DEBUG($available_modules);
31 31
 
32
-if ($subusers)
33
-{
32
+if ($subusers) {
34 33
     output('<h4>Momentan vorhandene zusätzliche Admin-Zugänge</h4>');
35 34
     foreach ($subusers as $subuser) {
36 35
         output('<div><p><strong>'.$subuser['username'].'</strong> '.internal_link('delete.php', icon_delete('Löschen'), 'subuser='.$subuser['id']).' '.internal_link('edit.php', icon_edit('Bearbeiten'), 'subuser='.$subuser['id']).'</p>');
... ...
@@ -40,10 +39,7 @@ if ($subusers)
40 39
         }
41 40
         output('</ul></div>');
42 41
     }
43
-  
44
-}
45
-else
46
-{
42
+} else {
47 43
     output('<p><em>Sie haben bisher keine zusätzlichen Admin-Zugänge</em></p>');
48 44
 }
49 45
 
... ...
@@ -24,24 +24,19 @@ require_role(ROLE_CUSTOMER);
24 24
 title("System-Benutzeraccounts");
25 25
 
26 26
 
27
-if (! customer_may_have_useraccounts())
28
-{
27
+if (! customer_may_have_useraccounts()) {
29 28
     warning("Sie haben bisher keine Benutzeraccounts. Der erste (»Stamm-«)Account muss von einem Administrator angelegt werden.");
30
-}
31
-else
32
-{
29
+} else {
33 30
     $accounts = list_useraccounts();
34 31
     $shells = available_shells();
35 32
 
36 33
     output("<p>Folgende Benutzeraccounts haben Sie bisher:</p>");
37 34
     output("<table><tr><th>Benutzeraccount</th><th>Speicherplatz<sup>*</sup></th><th>Aktionen</th></tr>");
38
-  foreach ($accounts as $acc)
39
-  {
35
+    foreach ($accounts as $acc) {
40 36
         $shell = $shells[$acc['shell']];
41 37
         $usedquota = get_used_quota($acc['uid']);
42 38
         $quota = array();
43
-    foreach ($usedquota as $q)
44
-    {
39
+        foreach ($usedquota as $q) {
45 40
             $mailbar = '';
46 41
             $mailstring = '';
47 42
             $mailpercent = round(($q['mailquota'] / $q["systemquota"]) * 100);
... ...
@@ -67,8 +61,7 @@ else
67 61
         output("<td>{$quotastring}</td>");
68 62
         output("<td>".internal_link('edit', other_icon('user_edit.png', 'Bearbeiten'), "uid={$acc['uid']}"));
69 63
     
70
-    if (! customer_useraccount($acc['uid']))
71
-    {
64
+        if (! customer_useraccount($acc['uid'])) {
72 65
             output(" &#160; ".internal_link('pwchange', icon_pwchange('Passwort neu setzen'), "uid={$acc['uid']}"));
73 66
             #output(" &#160; ".internal_link('deluser', other_icon('user_delete.png', 'Benutzer löschen'), "uid={$acc['uid']}"));
74 67
         }
... ...
@@ -85,6 +78,3 @@ else
85 78
         }
86 79
     }
87 80
 }
88
-
89
-
90
-?>
... ...
@@ -24,14 +24,11 @@ require_role(array(ROLE_CUSTOMER, ROLE_SYSTEMUSER));
24 24
 title("System-Benutzeraccounts");
25 25
 $section = "systemuser_account";
26 26
 
27
-$account = NULL;
27
+$account = null;
28 28
 $role = $_SESSION['role'];
29
-if ($role & ROLE_CUSTOMER)
30
-{
29
+if ($role & ROLE_CUSTOMER) {
31 30
     $account = get_account_details($_GET['uid']);
32
-}
33
-else
34
-{
31
+} else {
35 32
     $account = get_account_details($_SESSION['userinfo']['uid'], $_SESSION['userinfo']['customerno']);
36 33
 }
37 34
 
... ...
@@ -50,8 +47,9 @@ $customerquota = get_customer_quota();
50 47
 $maxquota = $customerquota['max'] - $customerquota['assigned'] + $account['quota'];
51 48
 
52 49
 $customer = get_customer_info($_SESSION['userinfo']['customerno']);
53
-if ($role & ROLE_CUSTOMER)
50
+if ($role & ROLE_CUSTOMER) {
54 51
     $customer = $_SESSION['customerinfo'];
52
+}
55 53
 
56 54
 $form = '
57 55
 
... ...
@@ -62,8 +60,7 @@ $form = '
62 60
 </div>
63 61
 ';
64 62
 
65
-if ($role & ROLE_CUSTOMER)
66
-{
63
+if ($role & ROLE_CUSTOMER) {
67 64
     $form .= '
68 65
 <h5>Speicherplatz</h5>
69 66
 <div style="margin-left: 2em;">
... ...
@@ -86,6 +83,3 @@ $form .= '
86 83
 ';
87 84
 
88 85
 output(html_form('systemuser_edit', 'save', 'action=edit&uid='.$account['uid'], $form));
89
-
90
-
91
-?>
... ...
@@ -25,7 +25,8 @@ function customer_may_have_useraccounts()
25 25
     return ($result->rowCount() > 0);
26 26
 }
27 27
 
28
-function customer_useraccount($uid) {
28
+function customer_useraccount($uid)
29
+{
29 30
     $args = array(":uid" => $uid, ":customerno" => $_SESSION['customerinfo']['customerno']);
30 31
     $result = db_query("SELECT 1 FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid AND kundenaccount=1", $args);
31 32
     return $result->rowCount() > 0;
... ...
@@ -33,8 +34,9 @@ function customer_useraccount($uid) {
33 34
 
34 35
 function primary_useraccount()
35 36
 {
36
-  if (! ($_SESSION['role'] & ROLE_SYSTEMUSER))
37
-    return NULL;
37
+    if (! ($_SESSION['role'] & ROLE_SYSTEMUSER)) {
38
+        return null;
39
+    }
38 40
     $customerno = (int) $_SESSION['customerinfo']['customerno'];
39 41
     $result = db_query("SELECT MIN(uid) AS uid FROM system.useraccounts WHERE kunde=?", array($customerno));
40 42
     $uid = $result->fetch(PDO::FETCH_OBJ)->uid;
... ...
@@ -47,8 +49,7 @@ function available_shells()
47 49
 {
48 50
     $result = db_query("SELECT path, name FROM system.shells WHERE usable=?", array(1));
49 51
     $ret = array();
50
-  while ($s = $result->fetch())
51
-  {
52
+    while ($s = $result->fetch()) {
52 53
         $ret[$s['path']] = $s['name'];
53 54
     }
54 55
     DEBUG($ret);
... ...
@@ -61,8 +62,7 @@ function list_useraccounts()
61 62
     $customerno = (int) $_SESSION['customerinfo']['customerno'];
62 63
     $result = db_query("SELECT uid,username,name,erstellungsdatum,quota,shell FROM system.useraccounts WHERE kunde=?", array($customerno));
63 64
     $ret = array();
64
-  while ($item = $result->fetch())
65
-  {
65
+    while ($item = $result->fetch()) {
66 66
         array_push($ret, $item);
67 67
     }
68 68
     #DEBUG($ret);
... ...
@@ -74,12 +74,14 @@ function get_account_details($uid, $customerno=0)
74 74
 {
75 75
     $uid = (int) $uid;
76 76
     $customerno = (int) $customerno;
77
-  if ($customerno == 0)
77
+    if ($customerno == 0) {
78 78
         $customerno = $_SESSION['customerinfo']['customerno'];
79
+    }
79 80
     $args = array(":uid" => $uid, ":customerno" => $customerno);
80 81
     $result = db_query("SELECT uid,username,name,shell,server,quota,erstellungsdatum FROM system.useraccounts WHERE kunde=:customerno AND uid=:uid", $args);
81
-  if ($result->rowCount() == 0)
82
+    if ($result->rowCount() == 0) {
82 83
         system_failure("Cannot find the requestes useraccount (for this customer).");
84
+    }
83 85
     return $result->fetch();
84 86
 }
85 87
 
... ...
@@ -88,8 +90,9 @@ function get_used_quota($uid)
88 90
     $uid = (int) $uid;
89 91
     $result = db_query("SELECT s.hostname AS server, systemquota, systemquota_used, mailquota, mailquota_used FROM system.v_quota AS q LEFT JOIN system.servers AS s ON (s.id=q.server) WHERE uid=?", array($uid));
90 92
     $ret = array();
91
-  while ($line = $result->fetch())
93
+    while ($line = $result->fetch()) {
92 94
         $ret[] = $line;
95
+    }
93 96
     #DEBUG($ret);
94 97
     return $ret;
95 98
 }
... ...
@@ -97,14 +100,15 @@ function get_used_quota($uid)
97 100
 
98 101
 function set_account_details($account)
99 102
 {
100
-  $customerno = NULL;
101
-  if ($_SESSION['role'] & ROLE_CUSTOMER)
103
+    $customerno = null;
104
+    if ($_SESSION['role'] & ROLE_CUSTOMER) {
102 105
         $customerno = (int) $_SESSION['customerinfo']['customerno'];
103
-  else
106
+    } else {
104 107
         $customerno = (int) $_SESSION['userinfo']['customerno'];
108
+    }
105 109
 
106 110
     if ($account['name'] == '') {
107
-    $account['name'] = NULL;
111
+        $account['name'] = null;
108 112
     }
109 113
     $args = array(":fullname" => filter_input_general($account['name']),
110 114
                 ":shell" => filter_input_general($account['shell']),
... ...
@@ -125,6 +128,3 @@ function get_customer_quota()
125 128
     DEBUG($ret);
126 129
     return $ret;
127 130
 }
128
-
129
-
130
-?>
... ...
@@ -16,13 +16,8 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
16 16
 
17 17
 $role = $_SESSION['role'];
18 18
 
19
-if ($role & ROLE_CUSTOMER)
20
-{
19
+if ($role & ROLE_CUSTOMER) {
21 20
     $menu["systemuser_account"] = array("label" => "Benutzeraccounts", "file" => "account", "weight" => 30);
22
-}
23
-elseif ($role & ROLE_SYSTEMUSER)
24
-{
21
+} elseif ($role & ROLE_SYSTEMUSER) {
25 22
     $menu["systemuser_account"] = array("label" => "Benutzeraccount", "file" => "myaccount", "weight" => 30);
26 23
 }
27
-
28
-?>
... ...
@@ -31,8 +31,7 @@ $acc = get_account_details($_SESSION['userinfo']['uid'], $_SESSION['userinfo']['
31 31
 $shell = $shells[$acc['shell']];
32 32
 $usedquota = get_used_quota($acc['uid']);
33 33
 $quota = array();
34
-foreach ($usedquota as $q)
35
-{
34
+foreach ($usedquota as $q) {
36 35
     $mailbar = '';
37 36
     $mailstring = '';
38 37
     $mailpercent = round(($q['mailquota'] / $q["systemquota"]) * 100);
... ...
@@ -61,6 +59,3 @@ output("</div>\n");
61 59
 output("<h5>Speicherplatz</h5><div style=\"margin-left: 2em;\">{$quotastring}</div>");
62 60
     
63 61
 output("<p><sup>*</sup>) Die Werte für den verbrauchten Speicherplatz werden periodisch eingelesen und hier erst verspätet angezeigt!</p>");
64
-
65
-
66
-?>
... ...
@@ -28,8 +28,7 @@ $usedquota = get_used_quota($acc['uid']);
28 28
 $quota = array();
29 29
 $multiserver = count($usedquota) > 1;
30 30
 $need_more_storage = false;
31
-foreach ($usedquota as $q)
32
-{
31
+foreach ($usedquota as $q) {
33 32
     $mailbar = '';
34 33
     $mailstring = '';
35 34
     $mailpercent = round(($q['mailquota'] / $q["systemquota"]) * 100);
... ...
@@ -71,6 +69,3 @@ if (have_module('invoice') && $need_more_storage) {
71 69
 }
72 70
     
73 71
 output("<p>Die Werte für den verbrauchten Speicherplatz werden periodisch eingelesen und hier verzögert angezeigt!</p>");
74
-
75
-
76
-?>
... ...
@@ -29,8 +29,9 @@ $account = get_account_details($_GET['uid']);
29 29
 
30 30
 headline("Rücksetzen des Passworts für Benutzer »{$account['username']}«");
31 31
 
32
-if (customer_useraccount($account['uid']))
32
+if (customer_useraccount($account['uid'])) {
33 33
     system_failure('Zum Ändern des Passwortes für den Hauptbenutzer verwenden Sie bitte die entsprechende Funktion im Hauptmenü!');
34
+}
34 35
 
35 36
 output(html_form('systemuser_pwchange', 'save', 'action=pwchange&uid='.$account['uid'], '
36 37
 
... ...
@@ -45,7 +46,3 @@ output(html_form('systemuser_pwchange', 'save', 'action=pwchange&uid='.$account[
45 46
 <input type="submit" name="submit" value="Speichern" />
46 47
 </p>
47 48
 '));
48
-
49
-
50
-
51
-?>
... ...
@@ -28,8 +28,7 @@ $role = $_SESSION['role'];
28 28
 require_once("inc/debug.php");
29 29
 global $debugmode;
30 30
 
31
-if ($_GET['action'] == 'new')
32
-{
31
+if ($_GET['action'] == 'new') {
33 32
     system_failure('not implemented');
34 33
 /*
35 34
 check_form_token('systemuser_new');
... ...
@@ -45,65 +44,63 @@ if ($_GET['action'] == 'new')
45 44
     header('Location: account');
46 45
 }
47 46
 */
48
-}
49
-elseif ($_GET['action'] == 'pwchange')
50
-{
51
-  if (! $role & ROLE_CUSTOMER)
47
+} elseif ($_GET['action'] == 'pwchange') {
48
+    if (! $role & ROLE_CUSTOMER) {
52 49
         system_failure("Zum Ändern Ihres Passworts verwenden Sie bitte die Funktion im Hauptmenü!");
50
+    }
53 51
     $error = false;
54 52
     check_form_token('systemuser_pwchange');
55
-  if (customer_useraccount($_REQUEST['uid']))
53
+    if (customer_useraccount($_REQUEST['uid'])) {
56 54
         system_failure('Zum Ändern dieses Passworts verwenden Sie bitte die Funktion im Hauptmenü!');
55
+    }
57 56
 
58 57
     //if (! strong_password($_POST['newpass']))
59 58
     //  input_error('Das Passwort ist zu einfach');
60 59
     //else
61 60
     if ($_POST['newpass1'] == '' ||
62
-      $_POST['newpass1'] != $_POST['newpass2'])
63
-  {
61
+      $_POST['newpass1'] != $_POST['newpass2']) {
64 62
         input_error('Bitte zweimal ein neues Passwort eingeben!');
65 63
         $error = true;
66
-  }
67
-  else
68
-  {
64
+    } else {
69 65
         $user = get_account_details($_REQUEST['uid']);
70 66
         # set_systemuser_password kommt aus den Session-Funktionen!
71 67
         set_systemuser_password($user['uid'], $_POST['newpass1']);
72 68
     }
73
-  if (! ($debugmode || $error))
69
+    if (! ($debugmode || $error)) {
74 70
         header('Location: account');
75 71
     }
76
-elseif ($_GET['action'] == 'edit')
77
-{
72
+} elseif ($_GET['action'] == 'edit') {
78 73
     check_form_token('systemuser_edit');
79
-  $account = NULL;
80
-  if ($role & ROLE_CUSTOMER)
74
+    $account = null;
75
+    if ($role & ROLE_CUSTOMER) {
81 76
         $account = get_account_details($_REQUEST['uid']);
82
-  else
77
+    } else {
83 78
         $account = get_account_details($_SESSION['userinfo']['uid'], $_SESSION['userinfo']['customerno']);
79
+    }
84 80
 
85
-  if ($role & ROLE_CUSTOMER)
86
-  {
81
+    if ($role & ROLE_CUSTOMER) {
87 82
         $customerquota = get_customer_quota();
88 83
         $maxquota = $customerquota['max'] - $customerquota['assigned'] + $account['quota'];
89 84
    
90 85
         $quota = (int) $_POST['quota'];
91
-    if ($quota > $maxquota) 
86
+        if ($quota > $maxquota) {
92 87
             system_failure("Sie können diesem Account maximal {$maxquota} MB Speicherplatz zuweisen.");
88
+        }
93 89
         $account['quota'] = $quota;
94 90
     }
95 91
 
96
-  if ($_POST['defaultname'] == 1)
97
-    $account['name'] = NULL;
98
-  else
92
+    if ($_POST['defaultname'] == 1) {
93
+        $account['name'] = null;
94
+    } else {
99 95
         $account['name'] = filter_input_general($_POST['fullname']);
96
+    }
100 97
   
101 98
     $shells = available_shells();
102
-  if (isset($shells[$_POST['shell']]))
99
+    if (isset($shells[$_POST['shell']])) {
103 100
         $account['shell'] = $_POST['shell'];
104
-  else
105
-    if (isset($_POST['shell']) && $_POST['shell'] != '')
101
+    } elseif (isset($_POST['shell']) && $_POST['shell'] != '') {
106 102
         system_failure('Ungültige Shell');
103
+    }
107 104
 
108 105
     set_account_details($account);
109 106
     if (! ($debugmode || $error)) {
... ...
@@ -113,10 +110,7 @@ elseif ($_GET['action'] == 'edit')
113 110
         }
114 111
         header('Location: '.$location);
115 112
     }
116
-  
117
-}
118
-elseif ($_GET['action'] == 'delete')
119
-{
113
+} elseif ($_GET['action'] == 'delete') {
120 114
     system_failure("Benutzeraccounts zu löschen ist momentan nicht über diese Oberfläche möglich. Bitte wenden Sie sich an einen Administrator.");
121 115
 /*
122 116
 $account_string = filter_input_general( $account['local'].'@'.$account['domain'] );
... ...
@@ -137,11 +131,8 @@ elseif ($_GET['action'] == 'delete')
137 131
     header("Location: account");
138 132
 }
139 133
 */
140
-}
141
-else
134
+} else {
142 135
     system_failure("Unimplemented action");
136
+}
143 137
 
144 138
 output('');
145
-
146
-
147
-?>
... ...
@@ -40,7 +40,7 @@ $form = "
40 40
     <tr><td><strong>{$vhost['fqdn']}</strong>{$mainalias}</td><td>Haupt-Adresse</td><td>&#160;</td></tr>
41 41
 ";
42 42
 
43
-foreach ($aliases AS $alias) {
43
+foreach ($aliases as $alias) {
44 44
     $aliastype = 'Zusätzliche Adresse';
45 45
     if (strstr($alias['options'], 'forward')) {
46 46
         $aliastype = 'Umleitung auf Haupt-Adresse';
... ...
@@ -88,6 +88,3 @@ output(html_form('vhosts_add_alias', 'save', 'action=addalias&vhost='.$vhost['id
88 88
 output("<p>
89 89
   ".internal_link("vhosts", "Zurück zur Übersicht")."
90 90
 </p>");
91
-
92
-
93
-?>
... ...
@@ -30,13 +29,14 @@ if (isset($_GET['aliaswww'])) {
30 29
     DEBUG($alias);
31 30
     $old_options = explode(',', $alias['options']);
32 31
     $new_options = array();
33
-  foreach ($old_options AS $op)
34
-  {
35
-    if ($op != 'aliaswww')
32
+    foreach ($old_options as $op) {
33
+        if ($op != 'aliaswww') {
36 34
             array_push($new_options, $op);
37 35
         }
38
-  if ($aliaswww)
36
+    }
37
+    if ($aliaswww) {
39 38
         array_push($new_options, 'aliaswww');
39
+    }
40 40
   
41 41
     DEBUG($old_options);
42 42
     DEBUG($new_options);
... ...
@@ -46,24 +46,25 @@ if (isset($_GET['aliaswww'])) {
46 46
     $alias['domainid'] = $alias['domain_id'];
47 47
     save_alias($alias);
48 48
 
49
-  if (! $debugmode)
49
+    if (! $debugmode) {
50 50
         header('Location: aliases?vhost='.$alias['vhost']);
51 51
     }
52
+}
52 53
 if (isset($_GET['forward'])) {
53
-
54 54
     $forward = (bool) ((int) $_GET['forward']);
55 55
 
56 56
     $alias = get_alias_details($_GET['alias']);
57 57
     DEBUG($alias);
58 58
     $old_options = explode(',', $alias['options']);
59 59
     $new_options = array();
60
-  foreach ($old_options AS $op)
61
-  {
62
-    if ($op != 'forward')
60
+    foreach ($old_options as $op) {
61
+        if ($op != 'forward') {
63 62
             array_push($new_options, $op);
64 63
         }
65
-  if ($forward)
64
+    }
65
+    if ($forward) {
66 66
         array_push($new_options, 'forward');
67
+    }
67 68
   
68 69
     DEBUG($old_options);
69 70
     DEBUG($new_options);
... ...
@@ -73,10 +74,7 @@ if (isset($_GET['forward'])) {
73 74
     $alias['domainid'] = $alias['domain_id'];
74 75
     save_alias($alias);
75 76
 
76
-  if (! $debugmode)
77
+    if (! $debugmode) {
77 78
         header('Location: aliases?vhost='.$alias['vhost']);
78 79
     }
79
-
80
-
81
-
82
-?>
80
+}
... ...
@@ -27,24 +27,19 @@ Beim Anlegen von Webserver-Konfigurationen können Sie dann eines Ihrer Zertifik
27 27
 
28 28
 $certs = user_certs();
29 29
 
30
-if (count($certs) > 0)
31
-{
30
+if (count($certs) > 0) {
32 31
     output("<table><tr><th>Name/Details</th><th>CommonName</th><th>Gültig ab</th><th>Gültig bis</th><th>&#160;</th></tr>");
33
-  foreach ($certs as $c)
34
-  {
32
+    foreach ($certs as $c) {
35 33
         $style="";
36 34
         if ($c['valid_until'] <= date('Y-m-d')) {
37 35
             $style=' style="background-color: #f88;" ';
38
-    }
39
-    elseif ($c['valid_until'] <= date('Y-m-d', time()+(30*24*3600)) && !cert_is_letsencrypt($c['id'])) {
36
+        } elseif ($c['valid_until'] <= date('Y-m-d', time()+(30*24*3600)) && !cert_is_letsencrypt($c['id'])) {
40 37
             $style=' style="background-color: #ff8;" ';
41 38
         }
42 39
         output("<tr><td{$style}>".internal_link('showcert', $c['subject'], "mode=cert&id={$c['id']}")."</td><td{$style}>{$c['cn']}</td><td{$style}>{$c['valid_from']}</td><td{$style}>{$c['valid_until']}</td><td>".internal_link('newcert', '<img src="'.$prefix.'images/refresh.png" title="Neue Version des Zertifikats einspielen" />', 'replace='.$c['id'])." &#160; ".internal_link('savecert', '<img src="'.$prefix.'images/delete.png" />', 'action=delete&id='.$c['id'])."</td></tr>");
43 40
     }
44 41
     output("</table>");
45
-}
46
-else
47
-{
42
+} else {
48 43
     output('<p><em>Bisher haben Sie keine Zertifikate eingetragen</em></p>');
49 44
 }
50 45
 
... ...
@@ -53,12 +48,10 @@ addnew('newcert', 'Neues Zertifikat erzeugen / eintragen');
53 48
 
54 49
 
55 50
 $csr = user_csr();
56
-if (count($csr) > 0)
57
-{
51
+if (count($csr) > 0) {
58 52
     output('<h3>offene CSRs</h3>');
59 53
     output("<table><tr><th>Host-/Domainname</th><th>Bitlänge</th><th>Erzeugt am</th><th>&#160;</th></tr>");
60
-  foreach ($csr AS $c)
61
-  {
54
+    foreach ($csr as $c) {
62 55
         output("<tr><td>".internal_link('showcert', $c['hostname'], 'mode=csr&id='.$c['id'])."</td><td>{$c['bits']}</td><td>{$c['created']}</td><td>".internal_link('savecert', '<img src="'.$prefix.'images/delete.png" />', 'action=deletecsr&id='.$c['id'])." &#160; ".internal_link('certfromcsr', '<img src="'.$prefix.'images/ok.png" alt="Zertifikat hinzufügen" title="Zertifikat hinzufügen" />', "id={$c['id']}")."</td></tr>");
63 56
     }
64 57
     output("</table>");
... ...
@@ -29,19 +29,20 @@ require_role(ROLE_SYSTEMUSER);
29 29
 $id = (isset($_GET['vhost']) ? (int) $_GET['vhost'] : 0);
30 30
 $vhost = empty_vhost();
31 31
 
32
-if ($id != 0)
32
+if ($id != 0) {
33 33
     $vhost = get_vhost_details($id);
34
+}
34 35
 
35 36
 $have_v6 = false;
36 37
 $server = (isset($vhost['server']) ? $vhost['server'] : $_SESSION['userinfo']['server']);
37
-if (ipv6_possible($server))
38
+if (ipv6_possible($server)) {
38 39
     $have_v6 = true;
40
+}
39 41
 
40 42
 DEBUG($vhost);
41 43
 if ($id == 0) {
42 44
     title("Neue Subdomain anlegen");
43
-}
44
-else {
45
+} else {
45 46
     title("Subdomain bearbeiten");
46 47
 }
47 48
 
... ...
@@ -52,40 +53,43 @@ if (! $vhost['domain']) {
52 53
 if ($vhost['domain_id'] == -1) {
53 54
     $defaultdocroot = $_SESSION['userinfo']['username'].'.'.config('user_vhosts_domain');
54 55
 }
55
-if ($vhost['hostname'])
56
+if ($vhost['hostname']) {
56 57
     $defaultdocroot = $vhost['hostname'].'.'.$defaultdocroot;
58
+}
57 59
 
58 60
 $defaultdocroot = $defaultdocroot.'/htdocs';
59 61
 
60
-$is_default_docroot = ($vhost['docroot'] == NULL) || ($vhost['homedir'].'/websites/'.$defaultdocroot == $vhost['docroot']);
62
+$is_default_docroot = ($vhost['docroot'] == null) || ($vhost['homedir'].'/websites/'.$defaultdocroot == $vhost['docroot']);
61 63
 
62
-if ($vhost['docroot'] != '' && ! strstr($vhost['docroot'], '/websites/'))
63
-{
64
+if ($vhost['docroot'] != '' && ! strstr($vhost['docroot'], '/websites/')) {
64 65
     warning("Sie verwenden einen Speicherplatz außerhalb von »~/websites/«. Diese Einstellung ist momentan nicht mehr gestattet. Ihre Einstellung wurde daher auf die Standardeinstellung zurückgesetzt. Prüfen Sie dies bitte und verschieben Sie ggf. ihre Dateien.");
65
-  $is_default_docroot = True;
66
+    $is_default_docroot = true;
66 67
 }
67 68
 
68 69
 $docroot = '';
69
-if ($is_default_docroot)
70
+if ($is_default_docroot) {
70 71
     $docroot = $defaultdocroot;
71
-else
72
+} else {
72 73
     $docroot = substr($vhost['docroot'], strlen($vhost['homedir'].'/websites/'));
74
+}
73 75
 
74 76
 $s = (strstr($vhost['options'], 'aliaswww') ? ' checked="checked" ' : '');
75 77
 $errorlog = ($vhost['errorlog'] == 1 ? ' checked="checked" ' : '');
76 78
 
77 79
 $vhost_type = 'regular';
78
-if ($vhost['is_dav'])
80
+if ($vhost['is_dav']) {
79 81
     $vhost_type = 'dav';
80
-elseif ($vhost['is_svn'])
82
+} elseif ($vhost['is_svn']) {
81 83
     $vhost_type = 'svn';
82
-elseif ($vhost['is_webapp'])
84
+} elseif ($vhost['is_webapp']) {
83 85
     $vhost_type = 'webapp';
86
+}
84 87
 
85 88
 $applist = list_available_webapps();
86 89
 $webapp_options = '';
87
-foreach ($applist as $app)
90
+foreach ($applist as $app) {
88 91
     $webapp_options .= "<option value=\"{$app['id']}\">{$app['displayname']}</option>\n";
92
+}
89 93
 
90 94
 $aliaswww_options = array("forwardwww" => "Umleiten auf www-Subdomain", "forwardnowww" => "Umleiten auf Stammdomain (ohne www)", "noforward" => "Keine Umleitung");
91 95
 $aliaswww_option = 'forwardwww';
... ...
@@ -172,8 +176,7 @@ $form .= "
172 176
         <div style=\"margin-left: 2em;\">
173 177
 	  <input class=\"usageoption\" type=\"radio\" name=\"vhost_type\" id=\"vhost_type_regular\" value=\"regular\" ".(($vhost_type=='regular') ? 'checked="checked" ' : '')."/><label for=\"vhost_type_regular\">&#160;Normal (selbst Dateien hinterlegen)</label><br />
174 178
 ";
175
-if ($vhost_type=='webapp')
176
-{
179
+if ($vhost_type=='webapp') {
177 180
     // Wird nur noch angezeigt wenn der Vhost schon auf webapp konfiguriert ist, ansonsten nicht.
178 181
     // Die User sollen den Webapp-Installer benutzen.
179 182
     $form .= "
... ...
@@ -200,7 +203,7 @@ $form .= "
200 203
     <h5>Sichere Verbindung erzwingen</h5>
201 204
     <div style=\"margin-left: 2em;\">
202 205
     <select name=\"ssl\" id=\"ssl\">
203
-      <option value=\"none\" ".($vhost['ssl'] == NULL ? 'selected="selected"' : '')." >Nein</option>
206
+      <option value=\"none\" ".($vhost['ssl'] == null ? 'selected="selected"' : '')." >Nein</option>
204 207
       ".($vhost['ssl'] == 'http' ? "<option value=\"http\" selected=\"selected\">kein HTTPS anbieten</option>" : '')."
205 208
       ".($vhost['ssl'] == 'https' ? "<option value=\"https\" selected=\"selected\">Konfiguration nur für HTTPS verwenden</option>" : '')."
206 209
       <option value=\"forward\" ".($vhost['ssl'] == 'forward' ? 'selected="selected"' : '')." >Ja, immer auf HTTPS umleiten</option>
... ...
@@ -216,8 +219,7 @@ $certselect[0] = 'kein Zertifikat / System-Standard benutzen';
216 219
 if ($vhost_type != 'dav' && $vhost_type != 'svn') {
217 220
     $certselect[-1] = 'Automatische Zertifikatsverwaltung mit Let\'s Encrypt';
218 221
 }
219
-foreach ($certs as $c)
220
-{
222
+foreach ($certs as $c) {
221 223
     if (! cert_is_letsencrypt($c['id'])) {
222 224
         $certselect[$c['id']] = $c['subject'];
223 225
     }
... ...
@@ -246,12 +247,12 @@ $form.="
246 247
 <h5>Logfiles</h5>
247 248
     <div style=\"margin-left: 2em;\">
248 249
       <select name=\"logtype\" id=\"logtype\">
249
-        <option value=\"none\" ".($vhost['logtype'] == NULL ? 'selected="selected"' : '')." >keine Logfiles</option>
250
+        <option value=\"none\" ".($vhost['logtype'] == null ? 'selected="selected"' : '')." >keine Logfiles</option>
250 251
         <option value=\"anonymous\" ".($vhost['logtype'] == 'anonymous' ? 'selected="selected"' : '')." >anonymisiert</option>
251 252
         <option value=\"default\" ".($vhost['logtype'] == 'default' ? 'selected="selected"' : '')." >vollständige Logfile</option>
252 253
       </select><br />
253 254
       <input type=\"checkbox\" id=\"errorlog\" name=\"errorlog\" value=\"1\" ".($vhost['errorlog'] == 1 ? ' checked="checked" ' : '')." />&#160;<label for=\"errorlog\">Fehlerprotokoll (error_log) einschalten</label><br />
254
-      <input type=\"checkbox\" id=\"stats\" name=\"stats\" value=\"1\" ".($vhost['stats'] != NULL ? ' checked="checked" ' : '')." />&#160;<label for=\"stats\">Statistiken/Auswertungen erzeugen</label>
255
+      <input type=\"checkbox\" id=\"stats\" name=\"stats\" value=\"1\" ".($vhost['stats'] != null ? ' checked="checked" ' : '')." />&#160;<label for=\"stats\">Statistiken/Auswertungen erzeugen</label>
255 256
     </div>
256 257
     <p>Logfiles werden unter <b>/var/log/apache2/".$_SESSION['userinfo']['username']."</b> abgelegt.</p>
257 258
     ";
... ...
@@ -273,11 +274,9 @@ if (!$vhost['server']) {
273 274
     $vhost['server'] = my_server_id();
274 275
 }
275 276
 
276
-  if (count($ipaddrs))
277
-  {
277
+  if (count($ipaddrs)) {
278 278
       $ipselect = array(0 => 'System-Standard');
279
-    foreach ($ipaddrs AS $i)
280
-    {
279
+      foreach ($ipaddrs as $i) {
281 280
           $ipselect[$i] = $i;
282 281
       }
283 282
       $form .= "
... ...
@@ -286,11 +285,9 @@ if (!$vhost['server']) {
286 285
       ".html_select('ipv4', $ipselect, $vhost['ipv4'])."
287 286
       </div>";
288 287
   }
289
-  if (count($available_users))
290
-  {
288
+  if (count($available_users)) {
291 289
       $userselect = array(0 => 'Eigener Benutzeraccount');
292
-    foreach ($available_users AS $u)
293
-    {
290
+      foreach ($available_users as $u) {
294 291
           $userselect[$u['uid']] = $u['username'];
295 292
       }
296 293
       $form .= "
... ...
@@ -299,20 +296,18 @@ if (!$vhost['server']) {
299 296
       ".html_select('suexec_user', $userselect, $vhost['suexec_user'])."
300 297
       </div>";
301 298
   }
302
-  if (count($available_servers) > 1)
303
-  {
299
+  if (count($available_servers) > 1) {
304 300
       $form .= "
305 301
       <h5>Einrichten auf Server</h5>
306 302
       <div style=\"margin-left: 2em;\">
307 303
       ".html_select('server', $selectable_servers, $vhost['server'])."
308 304
       </div>";
309
-
310 305
   }
311
-if ($have_v6) 
312
-{
306
+if ($have_v6) {
313 307
     $ipv6_address = '';
314
-  if ($vhost['id'] && ($vhost['autoipv6'] >0 ))
308
+    if ($vhost['id'] && ($vhost['autoipv6'] >0)) {
315 309
         $ipv6_address = '<strong>IPv6-Adresse dieser Subdomain:</strong> '.autoipv6_address($vhost['id'], $vhost['autoipv6']);
310
+    }
316 311
     $checked = ($vhost['autoipv6'] > 0) ? ' checked="checked"' : '';
317 312
     $checked2 = ($vhost['autoipv6'] == 2) ? ' checked="checked"' : '';
318 313
     $form .= '<h5>IPv6</h5>
... ...
@@ -329,6 +324,3 @@ $form .= '
329 324
   <p><input type="submit" value="Speichern" />&#160;&#160;&#160;&#160;'.internal_link('vhosts', 'Abbrechen').'</p>
330 325
 ';
331 326
 output(html_form('vhosts_edit_vhost', 'save', 'action=edit&vhost='.$vhost['id'], $form));
332
-
333
-
334
-?>
... ...
@@ -26,8 +26,9 @@ function user_certs()
26 26
     $uid = (int) $_SESSION['userinfo']['uid'];
27 27
     $result = db_query("SELECT id, valid_from, valid_until, subject, cn FROM vhosts.certs WHERE uid=? ORDER BY cn", array($uid));
28 28
     $ret = array();
29
-  while ($i = $result->fetch())
29
+    while ($i = $result->fetch()) {
30 30
         $ret[] = $i;
31
+    }
31 32
     #DEBUG($ret);
32 33
     return $ret;
33 34
 }
... ...
@@ -37,8 +38,9 @@ function user_csr()
37 38
     $uid = (int) $_SESSION['userinfo']['uid'];
38 39
     $result = db_query("SELECT id, created, hostname, bits FROM vhosts.csr WHERE uid=? ORDER BY hostname", array($uid));
39 40
     $ret = array();
40
-  while ($i = $result->fetch())
41
+    while ($i = $result->fetch()) {
41 42
         $ret[] = $i;
43
+    }
42 44
     #DEBUG($ret);
43 45
     return $ret;
44 46
 }
... ...
@@ -62,8 +64,9 @@ function cert_details($id)
62 64
     $uid = (int) $_SESSION['userinfo']['uid'];
63 65
   
64 66
     $result = db_query("SELECT id, lastchange, valid_from, valid_until, subject, cn, chain, cert, `key` FROM vhosts.certs WHERE uid=:uid AND id=:id", array(":uid" => $uid, ":id" => $id));
65
-  if ($result->rowCount() != 1)
67
+    if ($result->rowCount() != 1) {
66 68
         system_failure("Ungültiges Zertifikat #{$id}");
69
+    }
67 70
     return $result->fetch();
68 71
 }
69 72
 
... ...
@@ -84,8 +87,9 @@ function csr_details($id)
84 87
     $uid = (int) $_SESSION['userinfo']['uid'];
85 88
   
86 89
     $result = db_query("SELECT id, created, hostname, bits, `replace`, csr, `key` FROM vhosts.csr WHERE uid=:uid AND id=:id", array(":uid" => $uid, ":id" => $id));
87
-  if ($result->rowCount() != 1)
90
+    if ($result->rowCount() != 1) {
88 91
         system_failure("Ungültiger CSR");
92
+    }
89 93
     return $result->fetch();
90 94
 }
91 95
 
... ...
@@ -94,8 +98,9 @@ function get_available_CAs()
94 98
 {
95 99
     $path = '/etc/apache2/certs/cabundle/';
96 100
     $ret = glob($path.'*.pem');
97
-  if (! $ret)
101
+    if (! $ret) {
98 102
         system_failure("Konnte die CA-Zertifikate nicht laden");
103
+    }
99 104
     DEBUG($ret);
100 105
     return $ret;
101 106
 }
... ...
@@ -104,15 +109,14 @@ function get_available_CAs()
104 109
 function get_chain($cert)
105 110
 {
106 111
     $certdata = openssl_x509_parse($cert, true);
107
-  if ($certdata === FALSE) {
112
+    if ($certdata === false) {
108 113
         system_failure("Das Zertifikat konnte nicht gelesen werden");
109 114
     }
110 115
     if (! isset($certdata['issuer']['CN'])) {
111
-    return NULL;
116
+        return null;
112 117
     }
113 118
     $result = db_query("SELECT id FROM vhosts.certchain WHERE cn=?", array($certdata['issuer']['CN']));
114
-  if ($result->rowCount() > 0)
115
-  {
119
+    if ($result->rowCount() > 0) {
116 120
         $c = $result->fetch();
117 121
         //$chainfile = '/etc/apache2/certs/chains/'.$c['id'].'.pem';
118 122
         DEBUG("identified fitting certificate chain #".$c['id']);
... ...
@@ -125,18 +129,18 @@ function validate_certificate($cert, $key)
125 129
 {
126 130
     // Lade private key
127 131
     $seckey = openssl_get_privatekey($key);
128
-  if ($seckey === FALSE) {
132
+    if ($seckey === false) {
129 133
         system_failure("Der private Schlüssel konnte (ohne Passwort) nicht gelesen werden.");
130 134
     }
131 135
     // Lade public key
132 136
     $pubkey = openssl_get_publickey($cert);
133
-  if ($pubkey === FALSE) {
137
+    if ($pubkey === false) {
134 138
         system_failure("In dem eingetragenen Zertifikat wurde kein öffentlicher Schlüssel gefunden.");
135 139
     }
136 140
     // Parse Details über den pubkey
137 141
     $certinfo = openssl_pkey_get_details($pubkey);
138 142
     DEBUG($certinfo);
139
-  if ($certinfo === FALSE) {
143
+    if ($certinfo === false) {
140 144
         system_failure("Der öffentliche Schlüssel des Zertifikats konnte nicht gelesen werden");
141 145
     }
142 146
 
... ...
@@ -151,16 +155,14 @@ function validate_certificate($cert, $key)
151 155
     }
152 156
 
153 157
     // Prüfe ob Key und Zertifikat zusammen passen
154
-  if (openssl_x509_check_private_key($cert, $key) !== true)
155
-  {
158
+    if (openssl_x509_check_private_key($cert, $key) !== true) {
156 159
         DEBUG("Zertifikat und Key passen nicht zusammen: ".openssl_x509_check_private_key($cert, $key));
157 160
         return CERT_INVALID;
158 161
     }
159 162
 
160 163
     $cacerts = array('/etc/ssl/certs');
161 164
     $chain = (int) get_chain($cert);
162
-  if ($chain)
163
-  {
165
+    if ($chain) {
164 166
         $result = db_query("SELECT content FROM vhosts.certchain WHERE id=?", array($chain));
165 167
         $tmp = $result->fetch();
166 168
         $chaincert = $tmp['content'];
... ...
@@ -175,8 +177,7 @@ function validate_certificate($cert, $key)
175 177
     if ($chain) {
176 178
         unlink($chainfile);
177 179
     }
178
-  if ($valid !== true)
179
-  { 
180
+    if ($valid !== true) {
180 181
         DEBUG('certificate was not validated as a server certificate with the available chain');
181 182
         return CERT_NOCHAIN;
182 183
     }
... ...
@@ -223,13 +224,15 @@ function save_cert($info, $cert, $key)
223 224
     openssl_x509_export($cert, $cert);
224 225
     $uid = (int) $_SESSION['userinfo']['uid'];
225 226
 
226
-  db_query("INSERT INTO vhosts.certs (uid, subject, cn, san, valid_from, valid_until, chain, cert, `key`) VALUES (:uid, :subject, :cn, :san, :valid_from, :valid_until, :chain, :cert, :key)", 
227
+    db_query(
228
+      "INSERT INTO vhosts.certs (uid, subject, cn, san, valid_from, valid_until, chain, cert, `key`) VALUES (:uid, :subject, :cn, :san, :valid_from, :valid_until, :chain, :cert, :key)",
227 229
         array(":uid" => $uid, ":subject" => filter_input_general($info['subject']), ":cn" => filter_input_general($info['cn']), ":san" => $info['san'], ":valid_from" => $info['valid_from'],
228
-              ":valid_until" => $info['valid_until'], ":chain" => get_chain($cert), ":cert" => $cert, ":key" => $key));
230
+              ":valid_until" => $info['valid_until'], ":chain" => get_chain($cert), ":cert" => $cert, ":key" => $key)
231
+  );
229 232
 }
230 233
 
231 234
 
232
-function refresh_cert($id, $info, $cert, $key = NULL)
235
+function refresh_cert($id, $info, $cert, $key = null)
233 236
 {
234 237
     openssl_x509_export($cert, $cert);
235 238
     $chain = get_chain($cert);
... ...
@@ -299,8 +302,9 @@ function create_csr($cn, $bits)
299 302
     DEBUG($SAN);
300 303
     $cn = $domains[0];
301 304
     $bits = (int) $bits;
302
-  if ($bits == 0)
305
+    if ($bits == 0) {
303 306
         $bits = 4096;
307
+    }
304 308
 
305 309
     $keyfile = tempnam(ini_get('upload_tmp_dir'), 'key');
306 310
     $csrfile = tempnam(ini_get('upload_tmp_dir'), 'csr');
... ...
@@ -338,8 +342,7 @@ commonName_default = {$cn}
338 342
     exec($cmdline, $output, $retval);
339 343
     DEBUG($output);
340 344
     DEBUG($retval);
341
-  if ($retval != 0)
342
-  {
345
+    if ($retval != 0) {
343 346
         system_failure("Die Erzeugung des CSR ist fehlgeschlagen. Ausgabe des OpenSSL-Befehls: ".print_r($output, true));
344 347
     }
345 348
   
... ...
@@ -355,7 +358,7 @@ commonName_default = {$cn}
355 358
 
356 359
 
357 360
 
358
-function save_csr($cn, $bits, $replace=NULL)
361
+function save_csr($cn, $bits, $replace=null)
359 362
 {
360 363
     if (! $cn) {
361 364
         system_failure("Sie müssen einen Domainname eingeben!");
... ...
@@ -363,14 +366,16 @@ function save_csr($cn, $bits, $replace=NULL)
363 366
     $domains = split_cn($cn);
364 367
     $cn = $domains[0];
365 368
     $san = implode("\n", $domains);
366
-  $csr = NULL;
367
-  $key = NULL;
369
+    $csr = null;
370
+    $key = null;
368 371
     list($csr, $key) = create_csr(implode(',', $domains), $bits);
369 372
   
370 373
     $uid = (int) $_SESSION['userinfo']['uid'];
371
-  db_query("INSERT INTO vhosts.csr (uid, hostname, san, bits, `replace`, csr, `key`) VALUES (:uid, :cn, :san, :bits, :replace, :csr, :key)",
374
+    db_query(
375
+      "INSERT INTO vhosts.csr (uid, hostname, san, bits, `replace`, csr, `key`) VALUES (:uid, :cn, :san, :bits, :replace, :csr, :key)",
372 376
            array(":uid" => $uid, ":cn" => $cn, ":san" => $san, ":bits" => $bits,
373
-                 ":replace" => $replace, ":csr" => $csr, ":key" => $key));
377
+                 ":replace" => $replace, ":csr" => $csr, ":key" => $key)
378
+  );
374 379
     $id = db_insert_id();
375 380
     return $id;
376 381
 }
... ...
@@ -35,8 +35,7 @@ function autoipv6_address($vhost_id, $mode = 1)
35 35
 {
36 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 37
     $data = $result->fetch();
38
-  if (!$data['v6_prefix'])
39
-  {
38
+    if (!$data['v6_prefix']) {
40 39
         warning("IPv6-Adresse nicht verfügbar, Server unterstützt kein IPv6");
41 40
         return "";
42 41
     }
... ...
@@ -50,7 +49,7 @@ function autoipv6_address($vhost_id, $mode = 1)
50 49
 }
51 50
 
52 51
 
53
-function list_vhosts($filter=NULL)
52
+function list_vhosts($filter=null)
54 53
 {
55 54
     $uid = (int) $_SESSION['userinfo']['uid'];
56 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";
... ...
@@ -61,8 +60,9 @@ function list_vhosts($filter=NULL)
61 60
     }
62 61
     $result = db_query($query, $params);
63 62
     $ret = array();
64
-  while ($item = $result->fetch())
63
+    while ($item = $result->fetch()) {
65 64
         array_push($ret, $item);
65
+    }
66 66
     return $ret;
67 67
 }
68 68
 
... ...
@@ -71,59 +71,60 @@ function ipv6_possible($server)
71 71
     $args = array(":server" => $server);
72 72
     $result = db_query("SELECT v6_prefix FROM system.servers WHERE id=:server OR hostname=:server", $args);
73 73
     $line = $result->fetch();
74
-  DEBUG("Server {$server} is v6-capable: ". ($line['v6_prefix'] != NULL));
75
-  return ($line['v6_prefix'] != NULL);
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 86
     $vhost['homedir'] = $_SESSION['userinfo']['homedir'];
87
-  $vhost['docroot'] = NULL;
87
+    $vhost['docroot'] = null;
88 88
     $vhost['php'] = 'fpm72';
89 89
     $vhost['cgi'] = 1;
90
-  $vhost['ssl'] = NULL;
90
+    $vhost['ssl'] = null;
91 91
     $vhost['hsts'] = -1;
92
-  $vhost['suexec_user'] = NULL;
93
-  $vhost['server'] = NULL;
94
-  $vhost['logtype'] = NULL;
92
+    $vhost['suexec_user'] = null;
93
+    $vhost['server'] = null;
94
+    $vhost['logtype'] = null;
95 95
     $vhost['errorlog'] = 0;
96 96
     $vhost['is_dav'] = 0;
97 97
     $vhost['is_svn'] = 0;
98 98
     $vhost['is_webapp'] = 0;
99
-  $vhost['webapp_id'] = NULL;
99
+    $vhost['webapp_id'] = null;
100 100
   
101
-  $vhost['cert'] = NULL;
102
-  $vhost['certid'] = NULL;
103
-  $vhost['ipv4'] = NULL;
101
+    $vhost['cert'] = null;
102
+    $vhost['certid'] = null;
103
+    $vhost['ipv4'] = null;
104 104
     $vhost['autoipv6'] = 2; // 1 => Eine IP pro User, 2 => Eine IP pro VHost
105 105
 
106 106
     $vhost['options'] = 'forwardwww';
107
-  $vhost['stats'] = NULL;
107
+    $vhost['stats'] = null;
108 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 116
     $alias['domain_id'] = -1;
117 117
     $alias['domain'] = $_SESSION['userinfo']['username'].'.'.config('masterdomain');
118 118
   
119
-  $alias['options'] = NULL;
119
+    $alias['options'] = null;
120 120
     return $alias;
121 121
 }
122 122
 
123 123
 
124
-function userdomain() {
125
-  if (config('user_vhosts_domain') === NULL) {
126
-    return NULL;
124
+function userdomain()
125
+{
126
+    if (config('user_vhosts_domain') === null) {
127
+        return null;
127 128
     }
128 129
     $result = db_query("SELECT id,name FROM vhosts.v_domains WHERE name=:dom", array(":dom" => config('user_vhosts_domain')));
129 130
     $res = $result->fetch();
... ...
@@ -138,24 +139,26 @@ function user_uses_userdomain()
138 139
     $result = db_query("SELECT id FROM vhosts.vhost WHERE domain=:domid AND user=:uid", array(":uid" => $uid, ":domid" => $userdomain['id']));
139 140
     if ($result->rowCount() > 0) {
140 141
         DEBUG("User hat ".$result->rowCount()." Domains *.schokokeks.net");
141
-    return True;
142
+        return true;
142 143
     }
143 144
     DEBUG("User hat keine Domains *.schokokeks.net");
144 145
     return false;
145 146
 }
146 147
 
147
-function domainselect($selected = NULL, $selectattribute = '')
148
+function domainselect($selected = null, $selectattribute = '')
148 149
 {
149 150
     global $domainlist, $config;
150
-  if ($domainlist == NULL)
151
-    $domainlist = get_domain_list($_SESSION['customerinfo']['customerno'],
152
-                                  $_SESSION['userinfo']['uid']);
151
+    if ($domainlist == null) {
152
+        $domainlist = get_domain_list(
153
+        $_SESSION['customerinfo']['customerno'],
154
+                                  $_SESSION['userinfo']['uid']
155
+    );
156
+    }
153 157
     $selected = (int) $selected;
154 158
 
155 159
     $ret = '<select id="domain" name="domain" size="1" '.$selectattribute.' >';
156 160
     $found = false;
157
-  foreach ($domainlist as $dom)
158
-  {
161
+    foreach ($domainlist as $dom) {
159 162
         $s = '';
160 163
         if ($selected == $dom->id) {
161 164
             $s = ' selected="selected" ';
... ...
@@ -192,12 +195,13 @@ function get_vhost_details($id)
192 195
     $id = (int) $id;
193 196
     $uid = (int) $_SESSION['userinfo']['uid'];
194 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));
195
-  if ($result->rowCount() != 1)
198
+    if ($result->rowCount() != 1) {
196 199
         system_failure('Interner Fehler beim Auslesen der Daten');
200
+    }
197 201
 
198 202
     $ret = $result->fetch();
199 203
 
200
-  if ($ret['domain_id'] === NULL) {
204
+    if ($ret['domain_id'] === null) {
201 205
         $ret['domain_id'] = -2;
202 206
     }
203 207
     $ret['cert'] = $ret['certid'];
... ...
@@ -206,14 +210,14 @@ function get_vhost_details($id)
206 210
         $user = $_SESSION['userinfo']['username'];
207 211
         $ret['domain_id'] = -1;
208 212
         if ($ret['hostname'] == $user) {
209
-      $ret['hostname'] = NULL;
213
+            $ret['hostname'] = null;
210 214
         } elseif (substr($ret['hostname'], -strlen($user), strlen($user)) == $user) {
211 215
             $ret['hostname'] = substr($ret['hostname'], 0, -strlen($user)-1); // Punkt mit entfernen!
212 216
         } else {
213 217
             system_failure('Userdomain ohne Username!');
214 218
         }
215 219
     }
216
-  if ($ret['hsts'] === NULL) {
220
+    if ($ret['hsts'] === null) {
217 221
         DEBUG('HSTS: '.$ret['hsts']);
218 222
         $ret['hsts'] = -1;
219 223
     }
... ...
@@ -241,12 +245,12 @@ function get_all_aliases($vhost)
241 245
     $aliases = get_aliases($vhost['id']);
242 246
     $ret = array();
243 247
     if (strstr($vhost['options'], 'aliaswww')) {
244
-    array_push($ret, array('id' => 'www', 'fqdn' => 'www.'.$vhost['fqdn'], 'options' => (strstr($vhost['options'], 'forwardwww') ? 'forward' : NULL)));
248
+        array_push($ret, array('id' => 'www', 'fqdn' => 'www.'.$vhost['fqdn'], 'options' => (strstr($vhost['options'], 'forwardwww') ? 'forward' : null)));
245 249
     }
246 250
     foreach ($aliases as $item) {
247 251
         array_push($ret, $item);
248 252
         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)));
253
+            array_push($ret, array('id' => 'www_'.$item['id'], 'fqdn' => 'www.'.$item['fqdn'], 'options' => (strstr($item['options'], 'forward') ? 'forward' : null)));
250 254
         }
251 255
     }
252 256
     return $ret;
... ...
@@ -257,8 +261,9 @@ function list_available_webapps()
257 261
 {
258 262
     $result = db_query("SELECT id,displayname FROM vhosts.global_webapps");
259 263
     $ret = array();
260
-  while ($item = $result->fetch())
264
+    while ($item = $result->fetch()) {
261 265
         array_push($ret, $item);
266
+    }
262 267
     return $ret;
263 268
 }
264 269
 
... ...
@@ -266,8 +271,9 @@ function list_available_webapps()
266 271
 function delete_vhost($id)
267 272
 {
268 273
     $id = (int) $id;
269
-  if ($id == 0)
274
+    if ($id == 0) {
270 275
         system_failure("id == 0");
276
+    }
271 277
     $vhost = get_vhost_details($id);
272 278
     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Removing vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
273 279
     db_query("DELETE FROM vhosts.vhost WHERE id=?", array($vhost['id']));
... ...
@@ -278,8 +284,9 @@ function delete_vhost($id)
278 284
 function make_svn_vhost($id)
279 285
 {
280 286
     $id = (int) $id;
281
-  if ($id == 0)
287
+    if ($id == 0) {
282 288
         system_failure("id == 0");
289
+    }
283 290
     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to SVN');
284 291
     db_query("REPLACE INTO vhosts.dav (vhost, type) VALUES (?, 'svn')", array($id));
285 292
     db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
... ...
@@ -288,8 +295,9 @@ function make_svn_vhost($id)
288 295
 function make_dav_vhost($id)
289 296
 {
290 297
     $id = (int) $id;
291
-  if ($id == 0)
298
+    if ($id == 0) {
292 299
         system_failure("id == 0");
300
+    }
293 301
     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to WebDAV');
294 302
     db_query("REPLACE INTO vhosts.dav (vhost, type, options) VALUES (?, 'dav', 'nouserfile')", array($id));
295 303
     db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
... ...
@@ -298,8 +306,9 @@ function make_dav_vhost($id)
298 306
 function make_regular_vhost($id)
299 307
 {
300 308
     $id = (int) $id;
301
-  if ($id == 0)
309
+    if ($id == 0) {
302 310
         system_failure("id == 0");
311
+    }
303 312
     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Converting vhost #'.$id.' to regular');
304 313
     db_query("DELETE FROM vhosts.dav WHERE vhost=?", array($id));
305 314
     db_query("DELETE FROM vhosts.webapps WHERE vhost=?", array($id));
... ...
@@ -310,11 +319,13 @@ function make_webapp_vhost($id, $webapp)
310 319
 {
311 320
     $id = (int) $id;
312 321
     $webapp = (int) $webapp;
313
-  if ($id == 0)
322
+    if ($id == 0) {
314 323
         system_failure("id == 0");
324
+    }
315 325
     $result = db_query("SELECT displayname FROM vhosts.global_webapps WHERE id=?", array($webapp));
316
-  if ($result->rowCount() == 0)
326
+    if ($result->rowCount() == 0) {
317 327
         system_failure("webapp-id invalid");
328
+    }
318 329
     $webapp_name = $result->fetch(PDO::FETCH_OBJ)->displayname;
319 330
     logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Setting up webapp '.$webapp_name.' on vhost #'.$id);
320 331
     db_query("REPLACE INTO vhosts.webapps (vhost, webapp) VALUES (?, ?)", array($id, $webapp));
... ...
@@ -362,36 +373,41 @@ function check_hostname_collision($hostname, $domain)
362 373
 
363 374
 function save_vhost($vhost)
364 375
 {
365
-  if (! is_array($vhost))
376
+    if (! is_array($vhost)) {
366 377
         system_failure('$vhost kein array!');
378
+    }
367 379
     $id = (int) $vhost['id'];
368 380
     $hostname = $vhost['hostname'];
369 381
     $domain = (int) $vhost['domain_id'];
370
-  if ($domain == 0)
382
+    if ($domain == 0) {
371 383
         system_failure('$domain == 0');
372
-  if ($vhost['domain_id'] == -2)
373
-    $domain = NULL;
384
+    }
385
+    if ($vhost['domain_id'] == -2) {
386
+        $domain = null;
387
+    }
374 388
     if ($id == 0) {
375 389
         check_hostname_collision($vhost['hostname'], $vhost['domain_id']);
376 390
     }
377 391
     $hsts = (int) $vhost['hsts'];
378 392
     if ($hsts < 0) {
379
-    $hsts = NULL;
393
+        $hsts = null;
380 394
     }
381
-  $suexec_user = NULL;
395
+    $suexec_user = null;
382 396
 
383 397
     $available_suexec = available_suexec_users();
384
-  foreach ($available_suexec AS $u)
385
-    if ($u['uid'] == $vhost['suexec_user'])
398
+    foreach ($available_suexec as $u) {
399
+        if ($u['uid'] == $vhost['suexec_user']) {
386 400
             $suexec_user = $u['uid'];
401
+        }
402
+    }
387 403
 
388
-  $server = NULL;
404
+    $server = null;
389 405
     $available_servers = additional_servers();
390 406
     if (in_array($vhost['server'], $available_servers)) {
391 407
         $server = (int) $vhost['server'];
392 408
     }
393 409
     if ($server == my_server_id()) {
394
-    $server = NULL;
410
+        $server = null;
395 411
     }
396 412
 
397 413
     if ($vhost['is_svn']) {
... ...
@@ -402,16 +418,17 @@ function save_vhost($vhost)
402 418
         }
403 419
     }
404 420
 
405
-  $cert = NULL;
421
+    $cert = null;
406 422
     $certs = user_certs();
407
-  foreach ($certs as $c)
408
-    if ($c['id'] == $vhost['cert'])
423
+    foreach ($certs as $c) {
424
+        if ($c['id'] == $vhost['cert']) {
409 425
             $cert = $c['id'];
426
+        }
427
+    }
410 428
 
411
-  $ipv4 = NULL;
429
+    $ipv4 = null;
412 430
     $ipv4_avail = user_ipaddrs();
413
-  if (in_array($vhost['ipv4'], $ipv4_avail))
414
-  {
431
+    if (in_array($vhost['ipv4'], $ipv4_avail)) {
415 432
         $ipv4 = $vhost['ipv4'];
416 433
     }
417 434
 
... ...
@@ -422,31 +439,30 @@ function save_vhost($vhost)
422 439
 
423 440
     if (!($vhost['ssl'] == 'forward' || $vhost['ssl'] == 'http' ||
424 441
         $vhost['ssl'] == 'https')) {
425
-    $vhost['ssl'] = NULL;
442
+        $vhost['ssl'] = null;
426 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 462
     if ($id != 0) {
446 463
         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Updating vhost #'.$id.' ('.$vhost['hostname'].'.'.$vhost['domain'].')');
447 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);
448
-  }
449
-  else {
465
+    } else {
450 466
         $args[":user"] = $_SESSION['userinfo']['uid'];
451 467
         unset($args[":id"]);
452 468
         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'vhosts', 'Creating vhost '.$vhost['hostname'].'.'.$vhost['domain'].'');
... ...
@@ -459,15 +475,16 @@ function save_vhost($vhost)
459 475
       these vars may be 0 or 1.
460 476
       So newval > oldval means that it has been switched on yet.
461 477
     */
462
-  if ($vhost['is_dav'] > $oldvhost['is_dav'])
478
+    if ($vhost['is_dav'] > $oldvhost['is_dav']) {
463 479
         make_dav_vhost($id);
464
-  elseif ($vhost['is_svn'] > $oldvhost['is_svn'])
480
+    } elseif ($vhost['is_svn'] > $oldvhost['is_svn']) {
465 481
         make_svn_vhost($id);
466
-  elseif ($vhost['is_webapp'] > $oldvhost['is_webapp'])
482
+    } elseif ($vhost['is_webapp'] > $oldvhost['is_webapp']) {
467 483
         make_webapp_vhost($id, $vhost['webapp_id']);
468
-  elseif ($vhost['is_dav'] == 0 && $vhost['is_svn'] == 0 && $vhost['is_webapp'] == 0)
484
+    } elseif ($vhost['is_dav'] == 0 && $vhost['is_svn'] == 0 && $vhost['is_webapp'] == 0) {
469 485
         make_regular_vhost($id);
470 486
     }
487
+}
471 488
 
472 489
 
473 490
 function get_alias_details($id)
... ...
@@ -476,12 +493,13 @@ function get_alias_details($id)
476 493
     $uid = (int) $_SESSION['userinfo']['uid'];
477 494
     $result = db_query("SELECT * FROM vhosts.v_alias WHERE id=?", array($id));
478 495
   
479
-  if ($result->rowCount() != 1)
496
+    if ($result->rowCount() != 1) {
480 497
         system_failure('Interner Fehler beim Auslesen der Alias-Daten');
498
+    }
481 499
   
482 500
     $alias = $result->fetch();
483 501
   
484
-  if ($alias['domain_id'] == NULL) {
502
+    if ($alias['domain_id'] == null) {
485 503
         $alias['domain_id'] = -1;
486 504
     }
487 505
 
... ...
@@ -503,17 +521,20 @@ function delete_alias($id)
503 521
 
504 522
 function save_alias($alias)
505 523
 {
506
-  if (! is_array($alias))
524
+    if (! is_array($alias)) {
507 525
         system_failure('$alias kein array!');
526
+    }
508 527
     $id = (isset($alias['id']) ? (int) $alias['id'] : 0);
509 528
     $domain = (int) $alias['domain_id'];
510
-  if ($domain == 0)
529
+    if ($domain == 0) {
511 530
         system_failure('$domain == 0');
512
-  if ($alias['domain_id'] == -2)
513
-    $domain = NULL;
531
+    }
532
+    if ($alias['domain_id'] == -2) {
533
+        $domain = null;
534
+    }
514 535
     $vhost = get_vhost_details((int) $alias['vhost']);
515 536
     if (! $alias['hostname']) {
516
-    $alias['hostname'] = NULL;
537
+        $alias['hostname'] = null;
517 538
     }
518 539
     $args = array(":hostname" => $alias['hostname'],
519 540
                 ":domain" => $domain,
... ...
@@ -524,8 +545,7 @@ function save_alias($alias)
524 545
         unset($args[":id"]);
525 546
         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Creating alias '.$alias['hostname'].'.'.$alias['domain'].' for VHost '.$vhost['id']);
526 547
         db_query("INSERT INTO vhosts.alias (hostname, domain, vhost, options) VALUES (:hostname, :domain, :vhost, :options)", $args);
527
-  }
528
-  else {
548
+    } else {
529 549
         unset($args[":vhost"]);
530 550
         logger(LOG_INFO, 'modules/vhosts/include/vhosts', 'aliases', 'Updating alias #'.$id.' ('.$alias['hostname'].'.'.$alias['domain'].')');
531 551
         db_query("UPDATE vhosts.alias SET hostname=:hostname, domain=:domain, options=:options WHERE id=:id", $args);
... ...
@@ -538,8 +558,9 @@ function available_suexec_users()
538 558
     $uid = (int) $_SESSION['userinfo']['uid'];
539 559
     $result = db_query("SELECT uid, username FROM vhosts.available_users LEFT JOIN vhosts.v_useraccounts ON (uid = suexec_user) WHERE mainuser=?", array($uid));
540 560
     $ret = array();
541
-  while ($i = $result->fetch())
561
+    while ($i = $result->fetch()) {
542 562
         $ret[] = $i;
563
+    }
543 564
     DEBUG('available suexec-users:');
544 565
     DEBUG($ret);
545 566
     return $ret;
... ...
@@ -552,13 +572,9 @@ function user_ipaddrs()
552 572
     $uid = (int) $_SESSION['userinfo']['uid'];
553 573
     $result = db_query("SELECT ipaddr FROM vhosts.ipaddr_available WHERE uid=?", array($uid));
554 574
     $ret = array();
555
-  while ($i = $result->fetch())
556
-  {
575
+    while ($i = $result->fetch()) {
557 576
         $ret[] = $i['ipaddr'];
558 577
     }
559 578
     DEBUG($ret);
560 579
     return $ret;
561 580
 }
562
-
563
-
564
-?>
... ...
@@ -18,8 +18,7 @@ require_once('include/certs.php');
18 18
 
19 19
 $role = $_SESSION['role'];
20 20
 
21
-if ($role & ROLE_SYSTEMUSER)
22
-{
21
+if ($role & ROLE_SYSTEMUSER) {
23 22
     $menu["vhosts_vhosts"] = array("label" => "Websites", "file" => "vhosts", "weight" => 2);
24 23
     $menu["vhosts_stats"] = array("label" => "Zugriffs-Statistiken", "file" => "stats", "weight" => 12, "submenu" => "vhosts_vhosts");
25 24
   
... ...
@@ -27,5 +26,3 @@ if ($role & ROLE_SYSTEMUSER)
27 26
         $menu["vhosts_certs"] = array("label" => "TLS-Zertifikate", "file" => "certs", "weight" => 10, "submenu" => "vhosts_vhosts");
28 27
     }
29 28
 }
30
-
31
-?>
... ...
@@ -18,9 +18,8 @@ include_once('certs.php');
18 18
 require_role(ROLE_SYSTEMUSER);
19 19
 
20 20
 $hint = '';
21
-$oldcert = NULL;
22
-if (isset($_REQUEST['replace']))
23
-{
21
+$oldcert = null;
22
+if (isset($_REQUEST['replace'])) {
24 23
     title('Zertifikat ersetzen');
25 24
 
26 25
     $cert = cert_details($_REQUEST['replace']);
... ...
@@ -28,26 +28,25 @@ require_once("inc/debug.php");
28 28
 global $debugmode;
29 29
 
30 30
 
31
-if ($_GET['action'] == 'edit')
32
-{
31
+if ($_GET['action'] == 'edit') {
33 32
     check_form_token('vhosts_edit_vhost');
34 33
     $id = (int) $_GET['vhost'];
35 34
     $vhost = empty_vhost();
36
-  if ($id != 0)
35
+    if ($id != 0) {
37 36
         $vhost = get_vhost_details($id);
37
+    }
38 38
     DEBUG($vhost);
39 39
 
40 40
     $hostname = filter_input_hostname($_POST['hostname'], true);
41 41
 
42
-  $domainname = NULL;
42
+    $domainname = null;
43 43
     $domain_id = (int) $_POST['domain'];
44 44
     if ($domain_id >= 0) {
45 45
         $domain = new Domain((int) $_POST['domain']);
46 46
         $domain->ensure_userdomain();
47 47
         $domain_id = $domain->id;
48 48
         $domainname = $domain->fqdn;
49
-  }
50
-  elseif ($domain_id == -1) {
49
+    } elseif ($domain_id == -1) {
51 50
         # use configured user_vhosts_domain
52 51
         $userdomain = userdomain();
53 52
         $domain = new Domain((int) $userdomain['id']);
... ...
@@ -55,14 +54,13 @@ if ($_GET['action'] == 'edit')
55 54
         $domainname = $domain->fqdn;
56 55
         $hostname = $hostname.'.'.$_SESSION['userinfo']['username'];
57 56
         $hostname = trim($hostname, " .-");
58
-  }
59
-  elseif ($domain_id == -2) {
57
+    } elseif ($domain_id == -2) {
60 58
         # use system masterdomain
61 59
         $domainname = $_SESSION['userinfo']['username'].".".config('masterdomain');
62 60
     }
63 61
 
64 62
     $aliaswww = (isset($_POST['aliaswww']) && $_POST['aliaswww'] == 'aliaswww');
65
-  $forwardwww = NULL;
63
+    $forwardwww = null;
66 64
     if ($aliaswww && isset($_POST['forwardwww'])) {
67 65
         if ($_POST['forwardwww'] == 'forwardwww') {
68 66
             $forwardwww = 'forwardwww';
... ...
@@ -72,26 +70,24 @@ if ($_GET['action'] == 'edit')
72 70
     }
73 71
 
74 72
     $docroot = '';
75
-  if ($_POST['vhost_type'] == 'regular' || $_POST['vhost_type'] == 'dav')
76
-  {
73
+    if ($_POST['vhost_type'] == 'regular' || $_POST['vhost_type'] == 'dav') {
77 74
         $defaultdocroot = $vhost['homedir'].'/websites/'.((strlen($hostname) > 0) ? $hostname.'.' : '').($domainname).'/htdocs';
78 75
   
79 76
         $docroot = '';
80
-    if (isset($_POST['docroot']))
81
-    {
82
-      if (! check_path( $_POST['docroot'] ))
77
+        if (isset($_POST['docroot'])) {
78
+            if (! check_path($_POST['docroot'])) {
83 79
                 system_failure("Eingegebener Pfad enthält ungültige Angaben");
80
+            }
84 81
             $docroot = $vhost['homedir'].'/websites/'.$_POST['docroot'];
85 82
         }
86 83
         if ((isset($_POST['use_default_docroot']) && $_POST['use_default_docroot'] == '1') || ($docroot == $defaultdocroot)) {
87
-      $docroot = NULL;
84
+            $docroot = null;
88 85
         }
89 86
   
90 87
         DEBUG("Document-Root: ".$docroot);
91 88
     }
92
-  $php = NULL;
93
-  if ($_POST['vhost_type'] == 'regular' && isset($_POST['php']))
94
-  {
89
+    $php = null;
90
+    if ($_POST['vhost_type'] == 'regular' && isset($_POST['php'])) {
95 91
         switch ($_POST['php']) {
96 92
       case 'php56':
97 93
         $php = 'php56';
... ...
@@ -109,33 +105,31 @@ if ($_GET['action'] == 'edit')
109 105
     }
110 106
     }
111 107
     $cgi = 1;
112
-  if (isset($_POST['safemode']) && $_POST['safemode'] == 'yes')
113
-  {
108
+    if (isset($_POST['safemode']) && $_POST['safemode'] == 'yes') {
114 109
         $cgi = 0;
115 110
     }
116 111
 
117
-  if (isset($_POST['suexec_user']))
112
+    if (isset($_POST['suexec_user'])) {
118 113
         $vhost['suexec_user'] = $_POST['suexec_user'];
114
+    }
119 115
 
120
-  if (isset($_POST['server']))
116
+    if (isset($_POST['server'])) {
121 117
         $vhost['server'] = $_POST['server'];
118
+    }
122 119
 
123 120
     if ($_POST['vhost_type'] == 'regular') {
124 121
         $vhost['is_dav'] = 0;
125 122
         $vhost['is_svn'] = 0;
126 123
         $vhost['is_webapp'] = 0;
127
-  }
128
-  elseif ($_POST['vhost_type'] == 'dav') {
124
+    } elseif ($_POST['vhost_type'] == 'dav') {
129 125
         $vhost['is_dav'] = 1;
130 126
         $vhost['is_svn'] = 0;
131 127
         $vhost['is_webapp'] = 0;
132
-  }
133
-  elseif ($_POST['vhost_type'] == 'svn') {
128
+    } elseif ($_POST['vhost_type'] == 'svn') {
134 129
         $vhost['is_dav'] = 0;
135 130
         $vhost['is_svn'] = 1;
136 131
         $vhost['is_webapp'] = 0;
137
-  }
138
-  elseif ($_POST['vhost_type'] == 'webapp') {
132
+    } elseif ($_POST['vhost_type'] == 'webapp') {
139 133
         $vhost['is_dav'] = 0;
140 134
         $vhost['is_svn'] = 0;
141 135
         $vhost['is_webapp'] = 1;
... ...
@@ -143,7 +137,7 @@ if ($_GET['action'] == 'edit')
143 137
     }
144 138
 
145 139
   
146
-  $ssl = NULL;
140
+    $ssl = null;
147 141
     switch ($_POST['ssl']) {
148 142
     case 'http':
149 143
       $ssl = 'http';
... ...
@@ -157,7 +151,7 @@ if ($_GET['action'] == 'edit')
157 151
     /* Wenn etwas anderes kommt, ist das "beides". So einfach ist das. */
158 152
   }
159 153
 
160
-  $hsts = NULL;
154
+    $hsts = null;
161 155
     $hsts_subdomains = false;
162 156
     $hsts_preload = false;
163 157
     if (isset($_POST['hsts'])) {
... ...
@@ -174,15 +168,13 @@ if ($_GET['action'] == 'edit')
174 168
         }
175 169
     }
176 170
  
177
-  $cert = (isset($_POST['cert']) ? (int) $_POST['cert'] : NULL);
171
+    $cert = (isset($_POST['cert']) ? (int) $_POST['cert'] : null);
178 172
 
179
-  $ipv4 = (isset($_POST['ipv4']) ? $_POST['ipv4'] : NULL);
173
+    $ipv4 = (isset($_POST['ipv4']) ? $_POST['ipv4'] : null);
180 174
 
181
-  if (isset($_POST['ipv6']) && $_POST['ipv6'] == 'yes')
182
-  {
175
+    if (isset($_POST['ipv6']) && $_POST['ipv6'] == 'yes') {
183 176
         $vhost['autoipv6'] = 1;
184
-    if (isset($_POST['ipv6_separate']) && $_POST['ipv6_separate'] = 'yes')
185
-    {
177
+        if (isset($_POST['ipv6_separate']) && $_POST['ipv6_separate'] = 'yes') {
186 178
             $vhost['autoipv6'] = 2;
187 179
         }
188 180
     } else {
... ...
@@ -202,27 +194,28 @@ if ($_GET['action'] == 'edit')
202 194
   }
203 195
 
204 196
     $errorlog = 0;
205
-  if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
197
+    if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1)) {
206 198
         $errorlog = 1;
199
+    }
207 200
 
208 201
 
209
-  if (isset($_POST['stats']) && $_POST['stats'] == 1)
210
-  {
211
-    if ($vhost['stats'] == NULL)
202
+    if (isset($_POST['stats']) && $_POST['stats'] == 1) {
203
+        if ($vhost['stats'] == null) {
212 204
             $vhost['stats'] = 'private';
213 205
         }
214
-  else
215
-    $vhost['stats'] = NULL;
206
+    } else {
207
+        $vhost['stats'] = null;
208
+    }
216 209
 
217
-  if ($logtype == '')
218
-    $vhost['stats'] = NULL;
210
+    if ($logtype == '') {
211
+        $vhost['stats'] = null;
212
+    }
219 213
   
220 214
     DEBUG("PHP: {$php} / Logging: {$logtype}");
221 215
 
222 216
     $old_options = explode(',', $vhost['options']);
223 217
     $new_options = array();
224
-  foreach ($old_options AS $op)
225
-  {
218
+    foreach ($old_options as $op) {
226 219
         if (! in_array($op, array('aliaswww', 'forwardwww', 'forwardnowww', 'hsts_subdomains', 'hsts_preload'))) {
227 220
             array_push($new_options, $op);
228 221
         }
... ...
@@ -285,12 +278,10 @@ if ($_GET['action'] == 'edit')
285 278
     save_vhost($vhost);
286 279
     success_msg("Ihre Einstellungen wurden gespeichert. Es dauert jedoch einige Minuten bis die Änderungen wirksam werden.");
287 280
 
288
-  if (! $debugmode)
281
+    if (! $debugmode) {
289 282
         header('Location: vhosts');
290
-
291 283
     }
292
-elseif ($_GET['action'] == 'addalias')
293
-{
284
+} elseif ($_GET['action'] == 'addalias') {
294 285
     check_form_token('vhosts_add_alias');
295 286
     $id = (int) $_GET['vhost'];
296 287
     $vhost = get_vhost_details($id);
... ...
@@ -316,16 +307,19 @@ elseif ($_GET['action'] == 'addalias')
316 307
         $hostname = trim($hostname, " .-");
317 308
     }
318 309
 
319
-  if (! is_array($_POST['options']))
310
+    if (! is_array($_POST['options'])) {
320 311
         $_POST['options'] = array();
312
+    }
321 313
     $aliaswww = in_array('aliaswww', $_POST['options']);
322 314
     $forward = in_array('forward', $_POST['options']);
323 315
 
324 316
     $new_options = array();
325
-  if ($aliaswww)
317
+    if ($aliaswww) {
326 318
         array_push($new_options, 'aliaswww');
327
-  if ($forward)
319
+    }
320
+    if ($forward) {
328 321
         array_push($new_options, 'forward');
322
+    }
329 323
     DEBUG($new_options);
330 324
     $options = implode(',', $new_options);
331 325
     DEBUG('New options: '.$options);
... ...
@@ -337,12 +331,10 @@ elseif ($_GET['action'] == 'addalias')
337 331
     
338 332
     save_alias($alias);
339 333
 
340
-  if (! $debugmode)
334
+    if (! $debugmode) {
341 335
         header('Location: aliases?vhost='.$vhost['id']);
342
-
343 336
     }
344
-elseif ($_GET['action'] == 'deletealias')
345
-{
337
+} elseif ($_GET['action'] == 'deletealias') {
346 338
     $title = "Subdomain löschen";
347 339
     $section = 'vhosts_vhosts';
348 340
   
... ...
@@ -355,24 +347,19 @@ elseif ($_GET['action'] == 'deletealias')
355 347
     $vhost_string = $vhost['fqdn'];
356 348
   
357 349
     $sure = user_is_sure();
358
-  if ($sure === NULL)
359
-  {
350
+    if ($sure === null) {
360 351
         are_you_sure("action=deletealias&alias={$_GET['alias']}", "Möchten Sie das Alias »{$alias_string}« für die Subdomain »{$vhost_string}« wirklich löschen?");
361
-  }
362
-  elseif ($sure === true)
363
-  {
352
+    } elseif ($sure === true) {
364 353
         delete_alias($alias['id']);
365
-    if (! $debugmode)
354
+        if (! $debugmode) {
366 355
             header('Location: aliases?vhost='.$vhost['id']);
367 356
         }
368
-  elseif ($sure === false)
369
-  {
370
-    if (! $debugmode)
357
+    } elseif ($sure === false) {
358
+        if (! $debugmode) {
371 359
             header('Location: aliases?vhost='.$vhost['id']);
372 360
         }
373 361
     }
374
-elseif ($_GET['action'] == 'delete')
375
-{
362
+} elseif ($_GET['action'] == 'delete') {
376 363
     $title = "Subdomain löschen";
377 364
     $section = 'vhosts_vhosts';
378 365
   
... ...
@@ -380,26 +367,20 @@ elseif ($_GET['action'] == 'delete')
380 367
     $vhost_string = $vhost['fqdn'];
381 368
   
382 369
     $sure = user_is_sure();
383
-  if ($sure === NULL)
384
-  {
370
+    if ($sure === null) {
385 371
         are_you_sure("action=delete&vhost={$_GET['vhost']}", "Möchten Sie die Subdomain »{$vhost_string}« wirklich löschen?");
386
-  }
387
-  elseif ($sure === true)
388
-  {
372
+    } elseif ($sure === true) {
389 373
         delete_vhost($vhost['id']);
390
-    if (! $debugmode)
374
+        if (! $debugmode) {
391 375
             header("Location: vhosts");
392 376
         }
393
-  elseif ($sure === false)
394
-  {
395
-    if (! $debugmode)
377
+    } elseif ($sure === false) {
378
+        if (! $debugmode) {
396 379
             header("Location: vhosts");
397 380
         }
398 381
     }
399
-else
382
+} else {
400 383
     system_failure("Unimplemented action");
384
+}
401 385
 
402 386
 output('');
403
-
404
-
405
-?>
... ...
@@ -19,23 +19,20 @@ require_role(ROLE_SYSTEMUSER);
19 19
 
20 20
 $section = 'vhosts_certs';
21 21
 
22
-if ($_GET['action'] == 'new')
23
-{
22
+if ($_GET['action'] == 'new') {
24 23
     check_form_token('vhosts_certs_new');
25 24
     if (! isset($_POST['cert'])) {
26 25
         system_failure("Es wurde kein Zertifikat eingegeben");
27 26
     }
28 27
     $cert = $_POST['cert'];
29
-  $oldcert = NULL;
30
-  if (isset($_REQUEST['replace']) && is_numeric($_REQUEST['replace']))
31
-  {
28
+    $oldcert = null;
29
+    if (isset($_REQUEST['replace']) && is_numeric($_REQUEST['replace'])) {
32 30
         $oldcert = cert_details($_REQUEST['replace']);
33 31
         DEBUG('altes cert:');
34 32
         DEBUG($oldcert);
35 33
     }
36
-  $key = NULL;
37
-  if (! isset($_POST['key']) && isset($_REQUEST['csr']))
38
-  {
34
+    $key = null;
35
+    if (! isset($_POST['key']) && isset($_REQUEST['csr'])) {
39 36
         $csr = csr_details($_REQUEST['csr']);
40 37
         $key = $csr['key'];
41 38
     } elseif (isset($_POST['key']) and $_POST['key']) {
... ...
@@ -44,20 +41,22 @@ if ($_GET['action'] == 'new')
44 41
         $key = $oldcert['key'];
45 42
     }
46 43
 
47
-  if (! $cert or ! $key)
44
+    if (! $cert or ! $key) {
48 45
         system_failure('Es muss ein Zertifikat und der dazu passende private Schlüssel eingetragen werden');
46
+    }
49 47
 
50 48
     $result = validate_certificate($cert, $key);
51
-  switch ($result)
52
-  {
49
+    switch ($result) {
53 50
     case CERT_OK:
54 51
       $certinfo = parse_cert_details($cert);
55
-      if ($oldcert)
52
+      if ($oldcert) {
56 53
           refresh_cert($oldcert['id'], $certinfo, $cert, $key);
57
-      else
54
+      } else {
58 55
           save_cert($certinfo, $cert, $key);
59
-      if (isset($_REQUEST['csr']))
56
+      }
57
+      if (isset($_REQUEST['csr'])) {
60 58
           delete_csr($_REQUEST['csr']);
59
+      }
61 60
       header('Location: certs');
62 61
       die();
63 62
       break;
... ...
@@ -67,35 +66,35 @@ if ($_GET['action'] == 'new')
67 66
     case CERT_NOCHAIN:
68 67
       warning('Ihr Zertifikat konnte nicht mit einer Zertifikats-Kette validiert werden. Dies wird zu Problemen beim Betrachten der damit betriebenen Websites führen. Dies kann daran liegen dass es abgelaufen ist oder wenn kein passendes CA-Bundle hinterlegt wurde. Die Admins können Ihr Zertifikats-Bundle auf dem System eintragen. Das Zertifikat wurde dennoch gespeichert.');
69 68
       $certinfo = parse_cert_details($cert);
70
-      if ($oldcert)
69
+      if ($oldcert) {
71 70
           refresh_cert($oldcert['id'], $certinfo, $cert, $key);
72
-      else
71
+      } else {
73 72
           save_cert($certinfo, $cert, $key);
73
+      }
74 74
       output('<p>'.internal_link('certs', 'Zurück zur Übersicht').'</p>');
75
-      if (isset($_REQUEST['csr']))
75
+      if (isset($_REQUEST['csr'])) {
76 76
           delete_csr($_REQUEST['csr']);
77
-      break;
78 77
       }
79
-
78
+      break;
80 79
   }
81
-elseif ($_GET['action'] == 'refresh')
82
-{
80
+} elseif ($_GET['action'] == 'refresh') {
83 81
     check_form_token('vhosts_certs_refresh');
84 82
     $cert = $_POST['cert'];
85 83
     $oldcert = cert_details($_REQUEST['id']);
86 84
     $key = $oldcert['key'];
87 85
     $id = (int) $_REQUEST['id'];
88 86
 
89
-  if (! $cert )
87
+    if (! $cert) {
90 88
         system_failure('Es muss ein Zertifikat eingetragen werden');
89
+    }
91 90
 
92 91
     $result = validate_certificate($cert, $key);
93
-  switch ($result)
94
-  {
92
+    switch ($result) {
95 93
     case CERT_OK:
96 94
       $certinfo = parse_cert_details($cert);
97
-      if ($certinfo['cn'] != $oldcert['cn'])
95
+      if ($certinfo['cn'] != $oldcert['cn']) {
98 96
           system_failure("Das neue Zertifikat enthält abweichende Daten. Legen Sie bitte ein neues Zertifikat an.");
97
+      }
99 98
 
100 99
       refresh_cert($id, $certinfo, $cert);
101 100
       header('Location: certs');
... ...
@@ -107,58 +106,42 @@ elseif ($_GET['action'] == 'refresh')
107 106
     case CERT_NOCHAIN:
108 107
       warning('Ihr Zertifikat konnte nicht mit einer Zertifikats-Kette validiert werden. Dies wird zu Problemen beim Betrachten der damit betriebenen Websites führen. Meist liegt dies an einem nicht hinterlegten CA-Bundle. Die Admins können Ihr Zertifikats-Bundle auf dem System eintragen. Das Zertifikat wurde dennoch gespeichert.');
109 108
       $certinfo = parse_cert_details($cert);
110
-      if ($certinfo['cn'] != $oldcert['cn'])
109
+      if ($certinfo['cn'] != $oldcert['cn']) {
111 110
           system_failure("Das neue Zertifikat enthält abweichende Daten. Legen Sie bitte ein neues Zertifikat an.");
111
+      }
112 112
 
113 113
       refresh_cert($id, $certinfo, $cert);
114 114
       output('<p>'.internal_link('certs', 'Zurück zur Übersicht').'</p>');
115 115
       break;
116 116
   }
117
-
118
-}
119
-elseif ($_GET['action'] == 'delete')
120
-{
117
+} elseif ($_GET['action'] == 'delete') {
121 118
     $cert = cert_details($_GET['id']);
122 119
     $sure = user_is_sure();
123
-  if ($sure === NULL)
124
-  {
120
+    if ($sure === null) {
125 121
         are_you_sure("action=delete&id={$cert['id']}", "Soll das Zertifikat für »{$cert['subject']}« (gültig von {$cert['valid_from']} bis {$cert['valid_until']}) wirklich entfernt werden?");
126
-  }
127
-  elseif ($sure === false)
128
-  {
122
+    } elseif ($sure === false) {
129 123
         header('Location: certs');
130 124
         die();
131
-  }
132
-  elseif ($sure === true)
133
-  { 
125
+    } elseif ($sure === true) {
134 126
         delete_cert($cert['id']);
135 127
         header('Location: certs');
136 128
         die();
137 129
     }
138
-}
139
-elseif ($_GET['action'] == 'deletecsr')
140
-{
130
+} elseif ($_GET['action'] == 'deletecsr') {
141 131
     $csr = csr_details($_GET['id']);
142 132
     $sure = user_is_sure();
143
-  if ($sure === NULL)
144
-  {
133
+    if ($sure === null) {
145 134
         are_you_sure("action=deletecsr&id={$csr['id']}", "Soll der CSR für »{$csr['hostname']}« ({$csr['bits']} Bits, erstellt am {$csr['created']}) wirklich entfernt werden?");
146
-  }
147
-  elseif ($sure === false)
148
-  {
135
+    } elseif ($sure === false) {
149 136
         header('Location: certs');
150 137
         die();
151
-  }
152
-  elseif ($sure === true)
153
-  { 
138
+    } elseif ($sure === true) {
154 139
         delete_csr($csr['id']);
155 140
         header('Location: certs');
156 141
         die();
157 142
     }
158
-}
159
-elseif ($_GET['action'] == 'newcsr')
160
-{
161
-  $replace = NULL;
143
+} elseif ($_GET['action'] == 'newcsr') {
144
+    $replace = null;
162 145
     if (isset($_REQUEST['replace'])) {
163 146
         $replace = $_REQUEST['replace'];
164 147
     }
... ...
@@ -172,11 +155,6 @@ elseif ($_GET['action'] == 'newcsr')
172 155
 
173 156
     header("Location: showcert?mode=csr&id={$id}");
174 157
     die();
175
-}
176
-else
177
-{
158
+} else {
178 159
     system_failure('not implemented');
179 160
 }
180
-
181
-
182
-
... ...
@@ -20,18 +20,16 @@ if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
20 20
                         'file'    => 'vhosts',
21 21
                         'icon'    => 'webserver.png',
22 22
                         'title'   => 'Websites verwalten',
23
-                        'alert'   => NULL );
23
+                        'alert'   => null );
24 24
 }
25 25
 if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
26 26
     $alert = '';
27 27
     include_once('modules/vhosts/include/certs.php');
28 28
     $certs = user_certs();
29
-  if (count($certs) > 0)
30
-  {
29
+    if (count($certs) > 0) {
31 30
         $num_expired = 0;
32 31
         $num_warn = 0;
33
-    foreach ($certs as $c)
34
-    {
32
+        foreach ($certs as $c) {
35 33
             if (cert_is_letsencrypt($c['id'])) {
36 34
                 continue;
37 35
             }
... ...
@@ -18,15 +18,15 @@ require_once('certs.php');
18 18
 require_role(ROLE_SYSTEMUSER);
19 19
 
20 20
 $mode = 'cert';
21
-if ($_REQUEST['mode'] == 'csr')
21
+if ($_REQUEST['mode'] == 'csr') {
22 22
     $mode = 'csr';
23
+}
23 24
 
24 25
 
25 26
 $section = 'vhosts_certs';
26 27
 
27 28
 
28
-if ($mode == 'csr')
29
-{
29
+if ($mode == 'csr') {
30 30
     $data = csr_details($_REQUEST['id']);
31 31
     $cert = $data['csr'];
32 32
     $key = $data['key'];
... ...
@@ -44,25 +44,18 @@ if ($mode == 'csr')
44 44
 {$cert}
45 45
 </textarea>");
46 46
   
47
-  if (isset($_REQUEST['private']) && $_REQUEST['private'] == 'yes')
48
-  {
47
+    if (isset($_REQUEST['private']) && $_REQUEST['private'] == 'yes') {
49 48
         output("<h4>privater Schlüssel</h4>
50 49
 <textarea cols=\"70\" rows=\"20\">
51 50
 {$key}
52 51
 </textarea>");
53
-  }
54
-  else
55
-  {
52
+    } else {
56 53
         output('<p>'.internal_link('', 'privaten Schlüssel auch anzeigen', "mode={$_REQUEST['mode']}&id={$_REQUEST['id']}&private=yes").'</p>');
57 54
     }
58 55
 
59 56
 
60 57
     addnew('certfromcsr', 'Unterschriebenes Zertifikat eingeben', "id={$_REQUEST['id']}");
61
-
62
-
63
-}
64
-else
65
-{
58
+} else {
66 59
     $data = cert_details($_REQUEST['id']);
67 60
     $cert = $data['cert'];
68 61
     $key = $data['key'];
... ...
@@ -79,30 +72,12 @@ else
79 72
 {$cert}
80 73
 </textarea>");
81 74
   
82
-  if (isset($_REQUEST['private']) && $_REQUEST['private'] == 'yes')
83
-  {
75
+    if (isset($_REQUEST['private']) && $_REQUEST['private'] == 'yes') {
84 76
         output("<h4>privater Schlüssel</h4>
85 77
 <textarea cols=\"70\" rows=\"20\">
86 78
 {$key}
87 79
 </textarea>");
88
-  }
89
-  else
90
-  {
80
+    } else {
91 81
         output('<p>'.internal_link('', 'privaten Schlüssel auch anzeigen', "mode={$_REQUEST['mode']}&id={$_REQUEST['id']}&private=yes").'</p>');
92 82
     }
93
-
94
-
95
-
96
-
97 83
 }
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
... ...
@@ -24,24 +24,20 @@ $section = 'vhosts_stats';
24 24
 // Stellt sicher, dass der angegebene VHost dem User gehört
25 25
 $vhost = get_vhost_details($_REQUEST['vhost']);
26 26
 
27
-if (! isset($_REQUEST['file']))
28
-{
27
+if (! isset($_REQUEST['file'])) {
29 28
     $_REQUEST['file'] = 'index.html';
30 29
 }
31 30
 
32
-if (!preg_match('/((daily_|hourly_|ctry_)?(usage|agent|search|ref|url|site)(_[0-9]+)?|index)\.(png|html)/', $_REQUEST['file']))
33
-{
31
+if (!preg_match('/((daily_|hourly_|ctry_)?(usage|agent|search|ref|url|site)(_[0-9]+)?|index)\.(png|html)/', $_REQUEST['file'])) {
34 32
     system_failure("Ungültiger Dateiname: »".filter_input_general($_REQUEST['file'])."«");
35 33
 }
36 34
 
37 35
 $path = '/home/stats/webalizer/data/' . idn_to_ascii($vhost['fqdn'], 0, INTL_IDNA_VARIANT_UTS46);
38 36
 $file = $path . '/' . $_REQUEST['file'];
39 37
 
40
-if ( is_file($file) )
41
-{
38
+if (is_file($file)) {
42 39
     DEBUG("opening file ".$file);
43
-  if (preg_match('/\.png/', $file))
44
-  {
40
+    if (preg_match('/\.png/', $file)) {
45 41
         //Binärdateien
46 42
         header("Content-Type: image/png");
47 43
         header("Content-Length: " . filesize($file));
... ...
@@ -67,8 +63,12 @@ if ( is_file($file) )
67 63
     // NOWRAP rewriten
68 64
     $html = preg_replace('/NOWRAP/', 'nowrap="nowrap"', $html);
69 65
     // lowercase tag names and keys
70
-  $html = preg_replace_callback('/(<[^ >]+[ >])/', function ($s) { return strtolower($s[0]); }, $html);
71
-  $html = preg_replace_callback('/( [A-Z]+=)/', function ($s) { return strtolower($s[0]); }, $html);
66
+    $html = preg_replace_callback('/(<[^ >]+[ >])/', function ($s) {
67
+        return strtolower($s[0]);
68
+    }, $html);
69
+    $html = preg_replace_callback('/( [A-Z]+=)/', function ($s) {
70
+        return strtolower($s[0]);
71
+    }, $html);
72 72
     // xml-values mit anführungszeichen
73 73
     $html = preg_replace('/=([-0-9a-zA-Z]+)([ >])/', '="$1"$2', $html);
74 74
     // Bilder rewriten
... ...
@@ -79,11 +79,6 @@ if ( is_file($file) )
79 79
     // Interne Links rewriten
80 80
     $html = preg_replace('!href="(./)?((usage|agent|search|ref|url|site|index)(_[0-9]+)?\.html)"!', 'href="showstats?vhost='.$vhost['id'].'&amp;file=$2"', $html);
81 81
     output($html);
82
-}
83
-else
84
-{
82
+} else {
85 83
     system_failure("Die Statistiken konnten nicht gefunden werden. Beachten Sie bitte, dass die Erstellung regelmäßig nachts geschieht. Neu in Auftrag gegebene Statistiken können Sie erst am darauffolgenden Tag betrachten.");
86 84
 }
87
-
88
-
89
-
... ...
@@ -22,33 +22,30 @@ require_role(ROLE_SYSTEMUSER);
22 22
 
23 23
 title("Zugriffs-Statistiken");
24 24
 
25
-if (isset($_REQUEST['vhost']))
26
-{
25
+if (isset($_REQUEST['vhost'])) {
27 26
     $v = get_vhost_details($_REQUEST['vhost']);
28 27
 
29
-  if (isset($_REQUEST['public']))
30
-  {
28
+    if (isset($_REQUEST['public'])) {
31 29
         $v['stats'] = ($_REQUEST['public'] == 1) ? 'public' : 'private';
32 30
     }
33
-  if (isset($_REQUEST['action']))
34
-  {
35
-    if ($_REQUEST['action'] == 'delete')
36
-      $v['stats'] = NULL;
37
-    elseif ($_REQUEST['action'] == 'new')
31
+    if (isset($_REQUEST['action'])) {
32
+        if ($_REQUEST['action'] == 'delete') {
33
+            $v['stats'] = null;
34
+        } elseif ($_REQUEST['action'] == 'new') {
38 35
             check_form_token('stats_new');
39 36
         }
37
+    }
40 38
     save_vhost($v);
41 39
     redirect('stats');
42
-}
43
-else
44
-{
45
-
40
+} else {
46 41
     $all_vhosts = list_vhosts();
47 42
     $stats_vhosts = array();
48 43
 
49
-foreach ($all_vhosts AS $v)
50
-  if ($v['stats'])
44
+    foreach ($all_vhosts as $v) {
45
+        if ($v['stats']) {
51 46
             $stats_vhosts[] = $v;
47
+        }
48
+    }
52 49
 
53 50
 
54 51
     output('<p>Um die Reichweite und das Publikum Ihrer Internet-Seiten besser einschätzen zu können, besteht die Möglichkeit aus den ggf. vorhandenen Webserver-Logfiles grafisch aufbereitete Statistiken erstellen zu lassen.</p>
... ...
@@ -56,57 +53,55 @@ output('<p>Um die Reichweite und das Publikum Ihrer Internet-Seiten besser einsc
56 53
 <h3>Statistiken für Ihre Seiten</h3>
57 54
 ');
58 55
 
59
-if (count($stats_vhosts) > 0)
60
-{
56
+    if (count($stats_vhosts) > 0) {
61 57
         output('
62 58
   <table><tr><th>Für Website</th><th>Öffentlich abrufbar?</th><th>Operationen</th></tr>
63 59
   ');
64 60
 
65
-  foreach ($stats_vhosts AS $v)
66
-  {
61
+        foreach ($stats_vhosts as $v) {
67 62
             output("<tr>");
68 63
             output("<td>".internal_link('showstats', $v['fqdn'], "vhost={$v['id']}")."</td>");
69 64
 
70
-    if ($v['stats'] == 'public')
65
+            if ($v['stats'] == 'public') {
71 66
                 output("<td><a href=\"http://".config('stats_hostname')."/{$v['fqdn']}\">".icon_enabled("Diese Statistiken können von jedermann aufgerufen werden. Klicken Sie hier um die öffentliche Version zu sehen.")."</a></td>");
72
-    else
67
+            } else {
73 68
                 output("<td>".icon_disabled("Diese Statistiken können nur hier im Webinterface betrachtet werden.")."</td>");
69
+            }
74 70
     
75 71
             output("<td>");
76
-    if ($v['stats'] == 'public')
72
+            if ($v['stats'] == 'public') {
77 73
                 output(internal_link("", other_icon("lock.png", "Statistiken nicht mehr öffentlich anzeigen"), "vhost={$v['id']}&public=0"));
78
-    else
74
+            } else {
79 75
                 output(internal_link("", other_icon("world.png", "Statistiken veröffentlichen"), "vhost={$v['id']}&public=1"));
76
+            }
80 77
             output(" &#160; ".internal_link("", icon_delete("Diese Statistiken löschen"), "vhost={$v['id']}&action=delete")."</td>");
81 78
             output("</tr>");
82
-  
83 79
         }
84 80
         output('</table>');
85
-}
86
-else
81
+    } else {
87 82
         output('<em>Für Ihre Seiten werden bisher keine Statistiken erzeugt</em>');
83
+    }
88 84
 
89 85
 
90 86
     output("<h3>Weitere Statistiken</h3>");
91 87
 
92 88
     $sel = array();
93
-foreach ($all_vhosts AS $v)
94
-{
95
-  if ($v['logtype'])
96
-  {
97
-    $found = False;
98
-    foreach ($stats_vhosts AS $s)
99
-      if ($s['id'] == $v['id'])
100
-        $found = True;
101
-    if (! $found)
89
+    foreach ($all_vhosts as $v) {
90
+        if ($v['logtype']) {
91
+            $found = false;
92
+            foreach ($stats_vhosts as $s) {
93
+                if ($s['id'] == $v['id']) {
94
+                    $found = true;
95
+                }
96
+            }
97
+            if (! $found) {
102 98
                 $sel[$v['id']] = $v['fqdn'];
103 99
             }
104 100
         }
101
+    }
105 102
 
106 103
 
107
-if (count($sel) > 0)
108
-{
109
-
104
+    if (count($sel) > 0) {
110 105
         output(html_form('stats_new', '', 'action=new', "<p>".html_select("vhost", $sel).'<br/>
111 106
 <input type="radio" name="public" id="public_0" value="0" checked="checked" /><label for="public_0"> Statistiken hier im Webinterface anzeigen</label><br />
112 107
 <input type="radio" name="public" id="public_1" value="1" /><label for="public_1"> Statistiken unter '.config('stats_hostname').' veröffentlichen (Ohne Passwortschutz)</label><br />
... ...
@@ -118,9 +113,7 @@ if (count($sel) > 0)
118 113
 
119 114
 <p><strong>Hinweis:</strong> Die Statistiken werden mindestens täglich erzeugt. Bis zum ersten Durchlauf nach der Aktivierung der Statistik wird der obige Link eine Fehlermeldung erzeugen. Bitte warten Sie mindestens einen Tag ab bevor Sie die Statistik zum ersten Mal aufrufen.</p>
120 115
 ');
121
-}
122
-else
123
-{
116
+    } else {
124 117
         # keine VHosts mehr verfügbar
125 118
         output('<p><em>Sie haben aktuell keine Domains/Subdomains, für die Protokolle erstellt aber noch nicht ausgewertet werden.</em></p>');
126 119
     }
... ...
@@ -55,8 +55,7 @@ if (count($vhosts) > 10 || $filter) {
55 55
     output(html_form('vhosts_filter', 'vhosts', '', $form));
56 56
 }
57 57
 
58
-if (count($vhosts) > 0)
59
-{
58
+if (count($vhosts) > 0) {
60 59
     /*
61 60
     if ($letsencrypt) {
62 61
       warning("Sie haben für eine oder mehrere Domains die Nutzung eines Let's-Encrypt-Zertifikats aktiviert. Wir haben diese Funktion nach allgemeiner Verfügbarkeit von Let's Encrypt umgehend freigeschaltet und sind mit der ersten Erfahrungen sehr zufrieden. Dennoch befindet sich Let's Encrypt momentan im Beta-Betrieb (d.h. Testbetrieb). Störungen sind daher nicht auszuschließen.");
... ...
@@ -68,14 +67,15 @@ if (count($vhosts) > 0)
68 67
     }
69 68
     output("<table><tr><th>(Sub-)Domain</th><th></th><th>Zusätzliche Alias-Namen</th><th>Protokoll</th><th>HTTPS</th><th>Traffic<sup>*</sup></th><th>PHP</th><th>Lokaler Pfad<sup>**</sup></th></tr>\n");
70 69
 
71
-  $even = True;
70
+    $even = true;
72 71
 
73
-  foreach ($vhosts as $vhost)
74
-  {
72
+    foreach ($vhosts as $vhost) {
75 73
         $even = ! $even;
76 74
         $fqdn = $vhost['fqdn'];
77 75
         $class = 'odd';
78
-    if ($even) $class = 'even';
76
+        if ($even) {
77
+            $class = 'even';
78
+        }
79 79
         $proto = 'http';
80 80
         if ($vhost['ssl'] == 'https' || $vhost['ssl'] == 'forward') {
81 81
             $proto = 'https';
... ...
@@ -87,10 +87,8 @@ if (count($vhosts) > 0)
87 87
         output("<tr class=\"{$class}\"><td>".internal_link('edit', $fqdn, "vhost={$vhost['id']}", 'title="Einstellungen bearbeiten"')."</td><td><a href=\"{$proto}://{$linkuri}\">".other_icon('world_link.png', 'Website aufrufen')."</a> ".internal_link('save', icon_delete("»{$vhost['fqdn']}« löschen"), 'action=delete&vhost='.$vhost['id'])."</td><td>");
88 88
         $aliases = get_all_aliases($vhost);
89 89
         $tmp = '';
90
-    if (count($aliases) > 0)
91
-    {
92
-      foreach ($aliases as $alias)
93
-      {
90
+        if (count($aliases) > 0) {
91
+            foreach ($aliases as $alias) {
94 92
                 $tmp .= $alias['fqdn'].'<br />';
95 93
             }
96 94
         } else {
... ...
@@ -99,26 +97,24 @@ if (count($vhosts) > 0)
99 97
         output(internal_link('aliases', $tmp, 'vhost='.$vhost['id'], 'title="Aliase verwalten"'));
100 98
         output('</td>');
101 99
         $logfiles = 'Kein Log';
102
-    if ($vhost['logtype'] == 'default')
100
+        if ($vhost['logtype'] == 'default') {
103 101
             $logfiles = 'Zugriffe ';
104
-    elseif ($vhost['logtype'] == 'anonymous')
102
+        } elseif ($vhost['logtype'] == 'anonymous') {
105 103
             $logfiles = 'Anonym';
106
-    if ($vhost['errorlog'] == 1)
107
-    {
108
-      if ($vhost['logtype'] == NULL)
104
+        }
105
+        if ($vhost['errorlog'] == 1) {
106
+            if ($vhost['logtype'] == null) {
109 107
                 $logfiles = 'Fehler';
110
-      else
108
+            } else {
111 109
                 $logfiles .= ' + Fehler';
112 110
             }
111
+        }
113 112
         $stats = $vhost['stats'] ? internal_link("showstats", other_icon("chart_bar.png", "Statistiken anzeigen"), "vhost={$vhost['id']}").' ' : '';
114 113
         output("<td>{$stats}{$logfiles}</td>");
115 114
   
116
-    if ($vhost['ssl'] == 'http')
117
-    {
115
+        if ($vhost['ssl'] == 'http') {
118 116
             output("<td>".icon_disabled('HTTPS ausgeschaltet')."</td>");
119
-    }
120
-    elseif (strstr($vhost['options'], "letsencrypt") && $vhost['cert'])
121
-    {
117
+        } elseif (strstr($vhost['options'], "letsencrypt") && $vhost['cert']) {
122 118
             $forward = '';
123 119
             if ($vhost['ssl'] == 'forward') {
124 120
                 $forward = " ".other_icon("refresh.png", 'Auf HTTPS umleiten');
... ...
@@ -126,18 +122,13 @@ if (count($vhosts) > 0)
126 122
                 $forward = " ".other_icon("warning.png", 'Ungeschützter Aufruf weiterhin möglich');
127 123
             }
128 124
             output("<td>".other_icon("letsencrypt.png", "Automatische Zertifikatsverwaltung mit Let's Encrypt").$forward."</td>");
129
-    }
130
-    elseif ($vhost['cert'])
131
-    {
125
+        } elseif ($vhost['cert']) {
132 126
             output("<td>".other_icon("key.png", "HTTPS mit eigenem Zertifikat")."</td>");
133
-    }
134
-    elseif (strstr($vhost['options'], "letsencrypt")) {
127
+        } elseif (strstr($vhost['options'], "letsencrypt")) {
135 128
             // Letsencrypt gewählt aber noch nicht aktiv
136 129
             $message = "Let's Encrypt-Zertifikat ist noch nicht bereit";
137 130
             output("<td>".other_icon("letsencrypt.png", $message).icon_warning($message)."</td>");
138
-    }
139
-    else
140
-    {
131
+        } else {
141 132
             output("<td>".icon_enabled('HTTPS eingeschaltet')."</td>");
142 133
         }
143 134
 
... ...
@@ -147,28 +138,24 @@ if (count($vhosts) > 0)
147 138
         if ($traffic > 1024) {
148 139
             $traffic_string = round($traffic / 1024, 2).' GB';
149 140
         }
150
-    if ($traffic === NULL) {
141
+        if ($traffic === null) {
151 142
             $traffic_string = '--';
152 143
         }
153 144
         output("<td style=\"text-align: right;\">{$traffic_string}</td>");
154 145
 
155 146
         if ($vhost['is_webapp'] == 1) {
156 147
             output('<td colspan="2"><em><strong>Sonderanwendung:</strong> Vorinstallierte Webanwendung</em></td>');
157
-    }
158
-    elseif ($vhost['is_dav'] == 1) {
148
+        } elseif ($vhost['is_dav'] == 1) {
159 149
             output('<td colspan="2"><em><strong>Sonderanwendung:</strong> WebDAV</em></td>');
160
-    }
161
-    elseif ($vhost['is_svn'] == 1) {
150
+        } elseif ($vhost['is_svn'] == 1) {
162 151
             output('<td colspan="2"><em><strong>Sonderanwendung:</strong> Subversion-Server</em></td>');
163
-    }
164
-    else {
152
+        } else {
165 153
             $php = $vhost['php'];
166
-      switch ($php)
167
-      {
154
+            switch ($php) {
168 155
         /* To create new PHP icon:
169 156
            convert ok.png -gravity center -draw "text 0,0 '7.2'" ok-php72.png
170 157
         */
171
-        case NULL:
158
+        case null:
172 159
           $php = icon_disabled('PHP ausgeschaltet');
173 160
           break;
174 161
         case 'php56':
... ...
@@ -185,11 +172,12 @@ if (count($vhosts) > 0)
185 172
           break;
186 173
       }
187 174
             output("<td>{$php}</td>");
188
-      if ($vhost['docroot_is_default'] == 1)
175
+            if ($vhost['docroot_is_default'] == 1) {
189 176
                 output("<td><span style=\"color:#777;\">{$vhost['docroot']}</span></td>");
190
-      else
177
+            } else {
191 178
                 output("<td><strong>{$vhost['docroot']}</strong></td>");
192 179
             }
180
+        }
193 181
         output("</tr>\n");
194 182
     }
195 183
     output('</table>');
... ...
@@ -202,12 +190,9 @@ if (count($vhosts) > 0)
202 190
     }
203 191
     output('<p style="font-size: 90%;"><sup>*</sup>)&#160;Dieser Wert stellt den Datenverkehr dieser Website für die letzten 30 Tage dar.</p>');
204 192
     output('<p style="font-size: 90%;"><sup>**</sup>)&#160;schwach geschriebene Pfadangaben bezeichnen die Standardeinstellung. Ist ein Pfad fett dargestellt, so haben Sie einen davon abweichenden Wert eingegeben.</p>');
205
-}
206
-elseif ($filter) {
193
+} elseif ($filter) {
207 194
     output("<p><strong><em>Keine Einträge für Ihre aktuellen Filterkrieterien.</em></strong></p>");
208
-}
209
-else // keine VHosts vorhanden
210
-{
195
+} else { // keine VHosts vorhanden
211 196
     output("<p><strong><em>Bisher haben Sie keine Domain bzw. Subdomain eingerichtet.</em></strong></p>");
212 197
 }
213 198
 
... ...
@@ -215,5 +200,3 @@ addnew('edit', 'Neue Domain bzw. Subdomain einrichten');
215 200
 
216 201
 output('<p>Bei passenden Einstellungen wird für jede Ihrer Websites automatisch ein Zertifikat von Let\'s Encrypt verwaltet und regelmäßig erneuert. Wenn Sie ein Zertifikat einsetzen möchten, das von einer anderen Zertifizierungsstelle ausgestellt ist, können Sie dieses hier hochladen.</p>');
217 202
 addnew('newcert', 'Ein eigenes HTTPS-Zertifikat eintragen');
218
-
219
-?>
... ...
@@ -47,7 +47,7 @@ $results = load_results();
47 47
 
48 48
 output('<h3>Aktuell installierte Web-Anwendungen</h3>
49 49
 <p>Die folgenden Web-Anwendungen wurden beim letzten Programmdurchlauf gefunden. Diese Liste wird i.d.R. täglich aktualisiert.</p>');
50
-foreach ($results AS $app) {
50
+foreach ($results as $app) {
51 51
     $url = get_url_for_dir($app['directory']);
52 52
     output("<div class='freewvs freewvs-{$app['state']}'>\n");
53 53
     if ($app['state'] == 'ok') {
... ...
@@ -55,8 +55,7 @@ foreach ($results AS $app) {
55 55
         output("<p><strong>{$app['appname']} {$app['version']}</strong></p>\n");
56 56
         output("<p>Gefunden in {$app['directory']} (<a href=\"{$url}\">{$url}</a>)</p>\n");
57 57
         output("<p>Diese Anwendung hat keine allgemein bekannten Sicherheitsprobleme.</p>\n");
58
-  }
59
-  else {
58
+    } else {
60 59
         $vulnlink = $app['vulninfo'];
61 60
         $doclink = get_upgradeinstructions($app['appname']);
62 61
         if (substr($vulnlink, 0, 3) == 'CVE') {
... ...
@@ -71,17 +70,18 @@ foreach ($results AS $app) {
71 70
             output("<p>Diese Anwendung ist von Sicherheits-Problemen betroffen. Leider gibt es <strong>momentan keine aktualisierte Version</strong>. Prüfen Sie bitte anhand der unten genannten Beschreibung des Problem die möglichen Gefahren eines weiteren Betriebs dieser Anwendung.</p>\n");
72 71
         }
73 72
         output("<p><strong>Referenz zu diesem Sicherheitsproblem: <a href='{$vulnlink}'>{$app['vulninfo']}</a></strong></p>");
74
-    if ($doclink != NULL)
73
+        if ($doclink != null) {
75 74
             output('<p><strong>Hinweis:</strong> Um Ihnen das Upgrade leichter zu machen, möchten wir Sie auf eine <a href="'.$doclink.'">deutschsprachige Upgrade-Anleitung</a> aufmerksam machen.</p>'."\n");
75
+        }
76 76
         $up = upgradeable($app['appname'], $app['version']);
77
-    if ($up)
78
-    {
79
-      if (directory_in_use($app['directory']))
77
+        if ($up) {
78
+            if (directory_in_use($app['directory'])) {
80 79
                 output('<p><em>Automatische Update-Aktion heute nicht mehr möglich</em></p>');
81
-      else
80
+            } else {
82 81
                 output('<p>'.internal_link('requestupdate', 'Update automatisch durchführen', "dir={$app['directory']}&app={$up}")."</p>\n");
83 82
             }
84 83
         }
84
+    }
85 85
     output("</div>\n");
86 86
     #output("<tr><td>{$app['appname']} ({$app['version']})</td><td>{$app['state']}</td></tr>");
87 87
 }
... ...
@@ -28,14 +28,12 @@ function load_results()
28 28
     return $ret;
29 29
 }
30 30
 
31
-function get_upgradeinstructions($appname) {
31
+function get_upgradeinstructions($appname)
32
+{
32 33
     $result = db_query("SELECT url FROM qatools.freewvs_upgradeinstructions WHERE appname=?", array($appname));
33 34
     if ($result->rowCount() > 0) {
34 35
         $tmp = $result->fetch();
35 36
         return $tmp[0];
36 37
     }
37
-  return NULL;
38
+    return null;
38 39
 }
39
-
40
-
41
-
... ...
@@ -24,9 +24,11 @@ function validate_data($post)
24 24
     DEBUG('Validating Data:');
25 25
     DEBUG($post);
26 26
     $fields = array('adminuser', 'adminpassword', 'adminemail', 'sitename', 'siteemail');
27
-  foreach ($fields AS $field)
28
-    if ((! isset($post[$field])) || $post[$field] == '')
27
+    foreach ($fields as $field) {
28
+        if ((! isset($post[$field])) || $post[$field] == '') {
29 29
             system_failure('Nicht alle Werte angegeben ('.$field.')');
30
+        }
31
+    }
30 32
 
31 33
     $dbdata = create_webapp_mysqldb('drupal6', $post['sitename']);
32 34
 
... ...
@@ -24,9 +24,11 @@ function validate_data($post)
24 24
     DEBUG('Validating Data:');
25 25
     DEBUG($post);
26 26
     $fields = array('adminuser', 'adminpassword', 'adminemail', 'sitename', 'siteemail');
27
-  foreach ($fields AS $field)
28
-    if ((! isset($post[$field])) || $post[$field] == '')
27
+    foreach ($fields as $field) {
28
+        if ((! isset($post[$field])) || $post[$field] == '') {
29 29
             system_failure('Nicht alle Werte angegeben ('.$field.')');
30
+        }
31
+    }
30 32
 
31 33
     $dbdata = create_webapp_mysqldb('drupal7', $post['sitename']);
32 34
 
... ...
@@ -24,9 +24,11 @@ function validate_data($post)
24 24
     DEBUG('Validating Data:');
25 25
     DEBUG($post);
26 26
     $fields = array('adminuser', 'adminpassword', 'adminemail', 'wikiname');
27
-  foreach ($fields AS $field)
28
-    if ((! isset($post[$field])) || $post[$field] == '')
27
+    foreach ($fields as $field) {
28
+        if ((! isset($post[$field])) || $post[$field] == '') {
29 29
             system_failure('Nicht alle Werte angegeben ('.$field.')');
30
+        }
31
+    }
30 32
 
31 33
     $dbdata = create_webapp_mysqldb('mediawiki', $post['wikiname']);
32 34
 
... ...
@@ -18,8 +18,9 @@ require_once('inc/base.php');
18 18
 
19 19
 function create_new_webapp($appname, $directory, $url, $data)
20 20
 {
21
-  if (directory_in_use($directory))
21
+    if (directory_in_use($directory)) {
22 22
         system_failure('Sie haben erst kürzlich eine Anwendung in diesem Verzeichnis installieren lassen. Aus Sicherheitsgründen können Sie in diesem Verzeichnis am selben Tag nicht schon wieder eine Anwendung installieren.');
23
+    }
23 24
     $args = array(":username" => $_SESSION['userinfo']['username'],
24 25
                 ":appname" => $appname,
25 26
                 ":dir" => $directory,
... ...
@@ -31,8 +32,9 @@ function create_new_webapp($appname, $directory, $url, $data)
31 32
 
32 33
 function request_update($appname, $directory, $url)
33 34
 {
34
-  if (directory_in_use($directory))
35
+    if (directory_in_use($directory)) {
35 36
         system_failure('Sie haben erst kürzlich eine Anwendung in diesem Verzeichnis installieren lassen oder ein Update in diesem Verzeichnis angefordert. Bitte warten Sie bis diese Aktion durchgeführt wurde.');
37
+    }
36 38
     $args = array(":username" => $_SESSION['userinfo']['username'],
37 39
                 ":appname" => $appname,
38 40
                 ":dir" => $directory,
... ...
@@ -43,31 +45,27 @@ function request_update($appname, $directory, $url)
43 45
 function directory_in_use($directory)
44 46
 {
45 47
     $result = db_query("SELECT id FROM vhosts.webapp_installer WHERE (state IN ('new','old') OR DATE(lastchange)=CURDATE()) AND directory=?", array($directory));
46
-  if ($result->rowCount() > 0)
48
+    if ($result->rowCount() > 0) {
47 49
         return true;
50
+    }
48 51
     return false;
49 52
 }
50 53
 
51 54
 function upgradeable($appname, $version)
52 55
 {
53 56
     DEBUG("Is {$appname}-{$version} upgradeable?");
54
-  if ($appname == 'Drupal7') 
55
-  {
57
+    if ($appname == 'Drupal7') {
56 58
         DEBUG("found Drupal-7.*!");
57 59
         return 'drupal7';
58 60
     }
59
-  if ($appname == 'Drupal')
60
-  {
61
+    if ($appname == 'Drupal') {
61 62
         DEBUG("found Drupal!");
62
-    if (substr($version, 0, 2) == '7.')
63
-    {
63
+        if (substr($version, 0, 2) == '7.') {
64 64
             DEBUG("found Drupal-7.*!");
65 65
             return 'drupal7';
66 66
         }
67 67
         DEBUG("Version: ".substr($version, 0, 2));
68
-  }
69
-  elseif ($appname == 'MediaWiki')
70
-  {
68
+    } elseif ($appname == 'MediaWiki') {
71 69
         DEBUG("found MediaWiki");
72 70
         return 'mediawiki';
73 71
     }
... ...
@@ -77,25 +75,27 @@ function upgradeable($appname, $version)
77 75
       return 'owncloud';
78 76
     }*/
79 77
     DEBUG("found no upgradeable webapp!");
80
-  return NULL;
78
+    return null;
81 79
 }
82 80
 
83 81
 
84 82
 function get_url_for_dir($docroot, $cutoff = '')
85 83
 {
86
-  if (substr($docroot, -1) == '/')
84
+    if (substr($docroot, -1) == '/') {
87 85
         $docroot = substr($docroot, 0, -1);
86
+    }
88 87
     $result = db_query("SELECT `ssl`, IF(FIND_IN_SET('aliaswww', options), CONCAT('www.',fqdn), fqdn) AS fqdn FROM vhosts.v_vhost WHERE docroot IN (?, ?)", array($docroot, $docroot.'/'));
89
-  if ($result->rowCount() < 1)
90
-  {
91
-    if (!strstr($docroot, '/'))
92
-      return NULL;
88
+    if ($result->rowCount() < 1) {
89
+        if (!strstr($docroot, '/')) {
90
+            return null;
91
+        }
93 92
         return get_url_for_dir(substr($docroot, 0, strrpos($docroot, '/')), substr($docroot, strrpos($docroot, '/')).$cutoff);
94 93
     }
95 94
     $tmp = $result->fetch();
96 95
     $prefix = 'http://';
97
-  if ($tmp['ssl'] == 'forward' || $tmp['ssl'] == 'https')
96
+    if ($tmp['ssl'] == 'forward' || $tmp['ssl'] == 'https') {
98 97
         $prefix = 'https://';
98
+    }
99 99
     return $prefix.$tmp['fqdn'].$cutoff;
100 100
 }
101 101
 
... ...
@@ -111,8 +111,7 @@ function create_webapp_mysqldb($application, $sitename)
111 111
     // zuerst versuchen wir username_webappname. Wenn das nicht klappt, dann wird hochgezählt
112 112
     $handle = $username.'_'.$application;
113 113
   
114
-  if (validate_mysql_username($handle) && validate_mysql_dbname($handle) && ! (has_mysql_user($handle) || has_mysql_database($handle)))
115
-  {
114
+    if (validate_mysql_username($handle) && validate_mysql_dbname($handle) && ! (has_mysql_user($handle) || has_mysql_database($handle))) {
116 115
         logger(LOG_INFO, "webapps/include/webapp-installer", "create", "creating db and user »{$handle}«");
117 116
         create_mysql_database($handle, $description);
118 117
         create_mysql_account($handle, $description);
... ...
@@ -124,8 +123,7 @@ function create_webapp_mysqldb($application, $sitename)
124 123
 
125 124
     for ($i = 0; $i < 100 ; $i++) {
126 125
         $handle = $username.'_'.$i;
127
-    if (validate_mysql_username($handle) && validate_mysql_dbname($handle) && ! (has_mysql_user($handle) || has_mysql_database($handle)))
128
-    {
126
+        if (validate_mysql_username($handle) && validate_mysql_dbname($handle) && ! (has_mysql_user($handle) || has_mysql_database($handle))) {
129 127
             logger(LOG_INFO, "webapps/include/webapp-installer", "create", "creating db and user »{$handle}«");
130 128
             create_mysql_database($handle, $description);
131 129
             create_mysql_account($handle, $description);
... ...
@@ -71,8 +71,7 @@ $form .= "
71 71
 $vhosts = list_vhosts();
72 72
 
73 73
 $options = array();
74
-foreach ($vhosts AS $vhost)
75
-{
74
+foreach ($vhosts as $vhost) {
76 75
     $options[$vhost['docroot']] = $vhost['fqdn'];
77 76
 }
78 77
 
... ...
@@ -26,32 +26,27 @@ $section = 'webapps_install';
26 26
 $docroot = $_SESSION['webapp_docroot'];
27 27
 $url = $_SESSION['webapp_url'];
28 28
 
29
-if (! $docroot)
30
-{
29
+if (! $docroot) {
31 30
     system_failure('Kann die Session-Daten nicht auslesen. So geht das nicht.');
32 31
 }
33 32
 
34 33
 
35
-if (isset($_POST['submit']))
36
-{
34
+if (isset($_POST['submit'])) {
37 35
     require_once('install-drupal6.php');
38 36
     require_once('webapp-installer.php');
39 37
   
40 38
     check_form_token('install_drupal6');
41 39
 
42 40
     $data = validate_data($_POST);
43
-  if (! $data)
41
+    if (! $data) {
44 42
         system_failure('wtf?!');
43
+    }
45 44
     create_new_webapp('drupal6', $docroot, $url, $data);
46 45
   
47 46
     title("Drupal wird installiert");
48 47
     output('<p>Ihr Drupal wird jetzt installiert. Sie erhalten eine E-Mail, sobald die Website betriebsbereit ist.</p>
49 48
 ');
50
-  
51
-}
52
-else
53
-{
54
-
49
+} else {
55 50
     require_once('modules/vhosts/include/vhosts.php');
56 51
     $vhosts = list_vhosts();
57 52
   
... ...
@@ -26,32 +26,27 @@ $section = 'webapps_install';
26 26
 $docroot = $_SESSION['webapp_docroot'];
27 27
 $url = $_SESSION['webapp_url'];
28 28
 
29
-if (! $docroot)
30
-{
29
+if (! $docroot) {
31 30
     system_failure('Kann die Session-Daten nicht auslesen. So geht das nicht.');
32 31
 }
33 32
 
34 33
 
35
-if (isset($_POST['submit']))
36
-{
34
+if (isset($_POST['submit'])) {
37 35
     require_once('install-drupal7.php');
38 36
     require_once('webapp-installer.php');
39 37
   
40 38
     check_form_token('install_drupal7');
41 39
 
42 40
     $data = validate_data($_POST);
43
-  if (! $data)
41
+    if (! $data) {
44 42
         system_failure('wtf?!');
43
+    }
45 44
     create_new_webapp('drupal7', $docroot, $url, $data);
46 45
   
47 46
     title("Drupal wird installiert");
48 47
     output('<p>Ihre Drupal-Website wird jetzt installiert. Sie erhalten eine E-Mail, sobald die Website betriebsbereit ist.</p>
49 48
 ');
50
-  
51
-}
52
-else
53
-{
54
-
49
+} else {
55 50
     require_once('modules/vhosts/include/vhosts.php');
56 51
     $vhosts = list_vhosts();
57 52
   
... ...
@@ -26,32 +26,27 @@ $section = 'webapps_install';
26 26
 $docroot = $_SESSION['webapp_docroot'];
27 27
 $url = $_SESSION['webapp_url'];
28 28
 
29
-if (! $docroot)
30
-{
29
+if (! $docroot) {
31 30
     system_failure('Kann die Session-Daten nicht auslesen. So geht das nicht.');
32 31
 }
33 32
 
34 33
 
35
-if (isset($_POST['submit']))
36
-{
34
+if (isset($_POST['submit'])) {
37 35
     require_once('install-mediawiki.php');
38 36
     require_once('webapp-installer.php');
39 37
   
40 38
     check_form_token('install_mediawiki');
41 39
 
42 40
     $data = validate_data($_POST);
43
-  if (! $data)
41
+    if (! $data) {
44 42
         system_failure('wtf?!');
43
+    }
45 44
     create_new_webapp('mediawiki', $docroot, $url, $data);
46 45
   
47 46
     title("MediaWiki wird installiert");
48 47
     output('<p>Ihr MediaWiki wird jetzt installiert. Sie erhalten eine E-Mail, sobald das Wiki betriebsbereit ist.</p>
49 48
 ');
50
-  
51
-}
52
-else
53
-{
54
-
49
+} else {
55 50
     require_once('modules/vhosts/include/vhosts.php');
56 51
     $vhosts = list_vhosts();
57 52
   
... ...
@@ -26,14 +26,12 @@ $section = 'webapps_install';
26 26
 $docroot = $_SESSION['webapp_docroot'];
27 27
 $url = $_SESSION['webapp_url'];
28 28
 
29
-if (! $docroot)
30
-{
29
+if (! $docroot) {
31 30
     system_failure('Kann die Session-Daten nicht auslesen. So geht das nicht.');
32 31
 }
33 32
 
34 33
 
35
-if (isset($_POST['submit']))
36
-{
34
+if (isset($_POST['submit'])) {
37 35
     require_once('webapp-installer.php');
38 36
   
39 37
     check_form_token('install_owncloud');
... ...
@@ -44,11 +42,7 @@ if (isset($_POST['submit']))
44 42
     title("OwnCloud wird installiert");
45 43
     output('<p>Ihre OwnCloud wird in Kürze installiert. Sie erhalten eine E-Mail, sobald die Anwendung betriebsbereit ist.</p>
46 44
 ');
47
-  
48
-}
49
-else
50
-{
51
-
45
+} else {
52 46
     require_once('modules/vhosts/include/vhosts.php');
53 47
     $vhosts = list_vhosts();
54 48
   
... ...
@@ -16,8 +16,7 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
16 16
 
17 17
 $role = $_SESSION['role'];
18 18
 
19
-if ($role & ROLE_SYSTEMUSER)
20
-{
19
+if ($role & ROLE_SYSTEMUSER) {
21 20
     $menu["webapps_freewvs"] = array("label" => "Anwendungen", "file" => "freewvs", "weight" => 1, "submenu" => "vhosts_vhosts");
22 21
     #$menu["webapps_install"] = array("label" => "Anwendung installieren", "file" => "install", "weight" => 1, "submenu" => "vhosts_vhosts");
23 22
 }
... ...
@@ -22,28 +22,24 @@ require_role(ROLE_SYSTEMUSER);
22 22
 $section = 'webapps_freewvs';
23 23
 $directory = $_GET['dir'];
24 24
 
25
-if (! in_homedir($directory))
25
+if (! in_homedir($directory)) {
26 26
     system_failure('Pfad nicht im Homedir oder ungültige Zeichen im Pfad');
27
+}
27 28
 
28 29
 $app = $_GET['app'];
29 30
 verify_input_general($app);
30 31
 
31 32
 
32 33
 $sure = user_is_sure();
33
-if ($sure === NULL)
34
-{
34
+if ($sure === null) {
35 35
     are_you_sure("dir={$directory}&app={$app}", "Möchten Sie ein Update der Anwendung »{$app}« im Verzeichnis »{$directory}« automatisch durchführen lassen?");
36
-}
37
-elseif ($sure === true)
38
-{
36
+} elseif ($sure === true) {
39 37
     request_update($app, $directory, get_url_for_dir($directory));
40
-  if (! $debugmode)
38
+    if (! $debugmode) {
41 39
         header("Location: waitforupdate");
42 40
     }
43
-elseif ($sure === false)
44
-{
45
-  if (! $debugmode)
41
+} elseif ($sure === false) {
42
+    if (! $debugmode) {
46 43
         header("Location: freewvs");
47 44
     }
48
-
49
-
45
+}
... ...
@@ -22,15 +22,14 @@ require_once('class/domain.php');
22 22
 $url = '';
23 23
 $docroot = '';
24 24
 
25
-if ($_POST['target'] == 'new')
26
-{
25
+if ($_POST['target'] == 'new') {
27 26
     check_form_token('webapp_install');
28 27
     $vhost = empty_vhost();
29 28
 
30 29
     $hostname = filter_input_hostname($_POST['hostname']);
31 30
 
32 31
     $domainid = (int) $_POST['domain'];
33
-  $domainname = NULL;
32
+    $domainname = null;
34 33
     if ($domainid != -1) {
35 34
         $domain = new Domain((int) $_POST['domain']);
36 35
         $domain->ensure_userdomain();
... ...
@@ -39,8 +38,9 @@ if ($_POST['target'] == 'new')
39 38
     }
40 39
     DEBUG('Domain: '.$domainid.' / '.$domainname);
41 40
 
42
-  if (! isset($_POST['options']) || ! is_array($_POST['options']))
41
+    if (! isset($_POST['options']) || ! is_array($_POST['options'])) {
43 42
         $_POST['options'] = array();
43
+    }
44 44
     $aliaswww = in_array('aliaswww', $_POST['options']);
45 45
 
46 46
     $vhost['is_dav'] = 0;
... ...
@@ -73,20 +73,22 @@ if ($_POST['target'] == 'new')
73 73
   }
74 74
 
75 75
     $errorlog = 0;
76
-  if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1))
76
+    if (isset($_POST['errorlog']) and ($_POST['errorlog'] == 1)) {
77 77
         $errorlog = 1;
78
+    }
78 79
 
79 80
     DEBUG("Logging: {$logtype}");
80 81
 
81 82
     $old_options = explode(',', $vhost['options']);
82 83
     $new_options = array();
83
-  foreach ($old_options AS $op)
84
-  {
85
-    if ($op != 'aliaswww')
84
+    foreach ($old_options as $op) {
85
+        if ($op != 'aliaswww') {
86 86
             array_push($new_options, $op);
87 87
         }
88
-  if ($aliaswww)
88
+    }
89
+    if ($aliaswww) {
89 90
         array_push($new_options, 'aliaswww');
91
+    }
90 92
 
91 93
     DEBUG($old_options);
92 94
     DEBUG($new_options);
... ...
@@ -104,8 +106,7 @@ if ($_POST['target'] == 'new')
104 106
     $vhost['options'] = $options;
105 107
   
106 108
     $domain = $domainname;
107
-  if ($domainid == -1)
108
-  {
109
+    if ($domainid == -1) {
109 110
         $domain = $_SESSION['userinfo']['username'].'.'.config('masterdomain');
110 111
     }
111 112
 
... ...
@@ -114,55 +115,50 @@ if ($_POST['target'] == 'new')
114 115
     DEBUG($vhost);
115 116
     DEBUG("New Vhost: {$url} / {$docroot}");
116 117
     save_vhost($vhost);
117
-}
118
-elseif ($_POST['target'] == 'vhost')
119
-{
118
+} elseif ($_POST['target'] == 'vhost') {
120 119
     $docroot = $_POST['vhost'];
121 120
 
122 121
     $vhosts = list_vhosts();
123
-  foreach ($vhosts AS $vhost)
124
-  {
125
-    if ($docroot == $vhost['docroot'])
126
-    {
122
+    foreach ($vhosts as $vhost) {
123
+        if ($docroot == $vhost['docroot']) {
127 124
             $url = $vhost['fqdn'];
128
-      if (strstr($vhost['options'], 'aliaswww'))
125
+            if (strstr($vhost['options'], 'aliaswww')) {
129 126
                 $url = 'www.'.$url;
127
+            }
130 128
 
131
-      if ($vhost['ssl'] == 'forward' || $vhost['ssl'] == 'https')
129
+            if ($vhost['ssl'] == 'forward' || $vhost['ssl'] == 'https') {
132 130
                 $url = 'https://'.$url;
133
-      else
131
+            } else {
134 132
                 $url = 'http://'.$url;
135 133
             }
136 134
         }
137
-  if (! $url)
138
-  {
135
+    }
136
+    if (! $url) {
139 137
         system_failure('Datenchaos, so geht das nicht.');
140 138
     }
141 139
     DEBUG("Existing Vhost: {$url} / {$docroot}");
142
-}
143
-else
144
-{
140
+} else {
145 141
     input_error('Fehler im System');
146 142
 }
147 143
 
148
-if ($docroot && $url)
149
-{
144
+if ($docroot && $url) {
150 145
     $application = $_POST['application'];
151
-  if (! $application)
146
+    if (! $application) {
152 147
         system_failure('Keine Web-Anwendung ausgewählt');
148
+    }
153 149
 
154
-  if (! check_path($application))
150
+    if (! check_path($application)) {
155 151
         system_failure('HTML-Krams im Namen der Anwendung');
152
+    }
156 153
 
157
-  if (! file_exists(dirname(__FILE__).'/install/'.$application.'.php'))
154
+    if (! file_exists(dirname(__FILE__).'/install/'.$application.'.php')) {
158 155
         system_failure('Unbekannte Web-Anwendung.');
156
+    }
159 157
 
160 158
     $_SESSION['webapp_docroot'] = $docroot;
161 159
     $_SESSION['webapp_url'] = $url;
162 160
   
163
-  if (!$debugmode)
161
+    if (!$debugmode) {
164 162
         header('Location: install/'.$application);
165 163
     }
166
-
167
-
168
-
164
+}
... ...
@@ -15,7 +15,7 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
15 15
 */
16 16
 
17 17
 if ($_SESSION['role'] & ROLE_SYSTEMUSER) {
18
-  $alert = NULL;
18
+    $alert = null;
19 19
     include_once('modules/webapps/include/freewvs.php');
20 20
 
21 21
     $result = load_results();
... ...
@@ -23,22 +23,17 @@ $id = (int) $_REQUEST['id'];
23 23
 
24 24
 $account = accountname($id);
25 25
 $sure = user_is_sure();
26
-if ($sure === NULL)
27
-{
26
+if ($sure === null) {
28 27
     $section='webmailtotp_overview';
29 28
     title("Zwei-Faktor-Anmeldung am Webmailer");
30 29
     are_you_sure("id={$id}", "Möchten Sie die Zwei-Faktor-Anmeldung für das Postfach »{$account}« wirklich entfernen?");
31
-}
32
-elseif ($sure === true)
33
-{
30
+} elseif ($sure === true) {
34 31
     delete_totp($id);
35
-  if (! $debugmode)
32
+    if (! $debugmode) {
36 33
         header("Location: overview");
37 34
     }
38
-elseif ($sure === false)
39
-{
40
-  if (! $debugmode)
35
+} elseif ($sure === false) {
36
+    if (! $debugmode) {
41 37
         header("Location: overview");
42 38
     }
43
-
44
-
39
+}
... ...
@@ -49,6 +49,3 @@ $form = '<p>Ihr Webmail-Benutzername: <input type="text" name="username" value="
49 49
 
50 50
 
51 51
 output(html_form('webmailtotp_test', 'test', '', $form));
52
-
53
-
54
-?>
... ...
@@ -85,7 +85,8 @@ function decode_webmail_password($crypted, $webmailpw)
85 85
 }
86 86
 
87 87
 
88
-function get_imap_password($username, $webmailpass) {
88
+function get_imap_password($username, $webmailpass)
89
+{
89 90
     $result = db_query("SELECT webmailpass FROM mail.webmail_totp WHERE email=?", array($username));
90 91
     $tmp = $result->fetch();
91 92
   
... ...
@@ -122,7 +123,8 @@ function check_locked($username)
122 123
     return ($result->rowCount() > 0);
123 124
 }
124 125
 
125
-function check_totp($username, $code) {
126
+function check_totp($username, $code)
127
+{
126 128
     if (check_blacklist($username, $code)) {
127 129
         DEBUG('Replay-Attack');
128 130
         return false;
... ...
@@ -150,10 +152,10 @@ function check_totp($username, $code) {
150 152
         DEBUG('FAILED');
151 153
     }
152 154
     return $checkResult;
153
-
154 155
 }
155 156
 
156
-function generate_qrcode_image($secret) {
157
+function generate_qrcode_image($secret)
158
+{
157 159
     $url = 'otpauth://totp/Webmail?secret='.$secret;
158 160
   
159 161
     $descriptorspec = array(
... ...
@@ -19,6 +19,3 @@ $role = $_SESSION['role'];
19 19
 if ($role & (ROLE_SYSTEMUSER | ROLE_MAILACCOUNT | ROLE_VMAIL_ACCOUNT)) {
20 20
     $menu["webmailtotp_overview"] = array("label" => "Zwei-Faktor-Anmeldung", "file" => "overview", "weight" => 5, "submenu" => "email_vmail" );
21 21
 }
22
-
23
-
24
-?>
... ...
@@ -31,11 +31,8 @@ require_once('modules/email/include/hasaccount.php');
31 31
 require_once('modules/email/include/vmail.php');
32 32
 
33 33
 if (! (user_has_accounts() || count(get_vmail_accounts())>0)) {
34
-  
35 34
     output('<p><em>Bisher haben Sie kein Postfach. Bitte erstellen sie zunächst ein Postfach.</em></p>');
36
-}
37
-else
38
-{
35
+} else {
39 36
 
40 37
 /* VMAIL */
41 38
 
... ...
@@ -43,29 +40,26 @@ $domains = get_vmail_domains();
43 40
     $vmail_accounts = get_vmail_accounts();
44 41
 
45 42
     $sorted_by_domains = array();
46
-foreach ($vmail_accounts AS $account)
47
-{
43
+    foreach ($vmail_accounts as $account) {
48 44
         if ($account['password'] == '') {
49 45
             continue;
50 46
         }
51
-  if (array_key_exists($account['domain'], $sorted_by_domains))
47
+        if (array_key_exists($account['domain'], $sorted_by_domains)) {
52 48
             array_push($sorted_by_domains[$account['domain']], $account);
53
-  else
49
+        } else {
54 50
             $sorted_by_domains[$account['domain']] = array($account);
55 51
         }
52
+    }
56 53
 
57 54
     DEBUG($sorted_by_domains);
58 55
 
59
-if (count($sorted_by_domains) > 0)
60
-{
61
-  foreach ($sorted_by_domains as $accounts_on_domain)
62
-  {
56
+    if (count($sorted_by_domains) > 0) {
57
+        foreach ($sorted_by_domains as $accounts_on_domain) {
63 58
             if (count($sorted_by_domains) > 2) {
64 59
                 output('<h4>'.$accounts_on_domain[0]['domainname'].'</h4>');
65 60
             }
66 61
 
67
-	    foreach ($accounts_on_domain AS $this_account)
68
-	    {
62
+            foreach ($accounts_on_domain as $this_account) {
69 63
                 $username = $this_account['local'].'@'.$this_account['domainname'];
70 64
                 output('<div style="margin-left: 2em;"><p style="margin-left: -2em;"><strong>'.$username.'</strong></p>');
71 65
                 $id = account_has_totp($username);
... ...
@@ -92,7 +85,7 @@ if (count($sorted_by_domains) > 0) {
92 85
         }
93 86
 
94 87
 
95
-foreach ($accounts AS $acc) {
88
+        foreach ($accounts as $acc) {
96 89
             if ($acc['mailbox']) {
97 90
                 output('<div style="margin-left: 2em;"><p style="margin-left: -2em;"><strong>'.$acc['account'].'</strong></p>');
98 91
                 $username = $acc['account'];
... ...
@@ -105,10 +98,5 @@ foreach ($accounts AS $acc) {
105 98
                 output('</div>');
106 99
             }
107 100
         }
108
-
109
-
110 101
     }
111
-
112 102
 }
113
-
114
-?>
... ...
@@ -35,5 +35,3 @@ $form .= '<p>Geben sie hier bitte das neue Passwort ein, mit dem sich der Benutz
35 35
 $form .= '<p><input type="submit" value="Einrichten" /></p>';
36 36
 
37 37
 output(html_form('webmailtotp_setup', 'generate', 'username='.urlencode($username), $form));
38
-
39
-?>
... ...
@@ -69,6 +69,3 @@ $form = '<p>Ihr Webmail-Benutzername: <input type="text" name="username" value="
69 69
 
70 70
 
71 71
 output(html_form('webmailtotp_test', 'test', '', $form));
72
-
73
-
74
-?>
... ...
@@ -30,32 +30,33 @@ define('ROLE_SUBUSER', 32);
30 30
 
31 31
 // Gibt die Rolle aus, wenn das Passwort stimmt
32 32
 
33
-function find_role($login, $password, $i_am_admin = False)
33
+function find_role($login, $password, $i_am_admin = false)
34 34
 {
35 35
     // Domain-Admin?  <not implemented>
36 36
     // System-User?
37 37
     $uid = (int) $login;
38
-  if ($uid == 0)
39
-    $uid = NULL;
38
+    if ($uid == 0) {
39
+        $uid = null;
40
+    }
40 41
     $result = db_query("SELECT username, passwort AS password, kundenaccount AS `primary`, status, ((SELECT acc.uid FROM system.v_useraccounts AS acc LEFT JOIN system.gruppenzugehoerigkeit USING (uid) LEFT JOIN system.gruppen AS g ON (g.gid=gruppenzugehoerigkeit.gid) WHERE g.name='admin' AND acc.uid=u.uid) IS NOT NULL) AS admin FROM system.v_useraccounts AS u LEFT JOIN system.passwoerter USING(uid) WHERE u.uid=:uid OR username=:login LIMIT 1;", array(":uid" => $uid, ":login" => $login));
41
-  if (@$result->rowCount() > 0)
42
-  {
42
+    if (@$result->rowCount() > 0) {
43 43
         $entry = $result->fetch(PDO::FETCH_OBJ);
44 44
         if (strcasecmp($entry->username, $login) == 0 && $entry->username != $login) {
45 45
             // MySQL matched (warum auch immer) ohne Beachtung der Schreibweise. Wir wollen aber case-sensitive sein.
46 46
             logger(LOG_WARNING, "session/checkuser", "login", "denying login to wrong cased username »{$login}«.");
47 47
             warning('Beachten Sie bei der Eingabe Ihrer Zugangsdaten bitte die Groß- und Kleinschreibung.');
48
-      return NULL;  
48
+            return null;
49 49
         }
50 50
         $db_password = $entry->password;
51 51
         $hash = crypt($password, $db_password);
52
-    if (($entry->status == 0 && $hash == $db_password) || $i_am_admin)
53
-    {
52
+        if (($entry->status == 0 && $hash == $db_password) || $i_am_admin) {
54 53
             $role = ROLE_SYSTEMUSER;
55
-      if ($entry->primary)
54
+            if ($entry->primary) {
56 55
                 $role = $role | ROLE_CUSTOMER;
57
-      if ($entry->admin)
56
+            }
57
+            if ($entry->admin) {
58 58
                 $role = $role | ROLE_SYSADMIN;
59
+            }
59 60
             logger(LOG_INFO, "session/checkuser", "login", "logged in systemuser »{$login}«.");
60 61
             return $role;
61 62
         }
... ...
@@ -68,23 +69,21 @@ function find_role($login, $password, $i_am_admin = False)
68 69
     $customerno = (int) $login;
69 70
     $pass = sha1($password);
70 71
     $result = db_query("SELECT passwort AS password FROM kundendaten.kunden WHERE status=0 AND id=:customerno AND passwort=:pass", array(":customerno" => $customerno, ":pass" => $pass));
71
-  if ($i_am_admin)
72
+    if ($i_am_admin) {
72 73
         $result = db_query("SELECT passwort AS password FROM kundendaten.kunden WHERE status=0 AND id=?", array($customerno));
73
-  if (@$result->rowCount() > 0)
74
-  {
74
+    }
75
+    if (@$result->rowCount() > 0) {
75 76
         return ROLE_CUSTOMER;
76 77
     }
77 78
 
78 79
     // Sub-User
79 80
 
80 81
     $result = db_query("SELECT password FROM system.subusers WHERE username=?", array($login));
81
-  if (@$result->rowCount() > 0)
82
-  {
82
+    if (@$result->rowCount() > 0) {
83 83
         $entry = $result->fetch(PDO::FETCH_OBJ);
84 84
         $db_password = $entry->password;
85 85
         // SHA1 für alte Subuser (kaylee), SHA256 für neue Subuser
86
-    if (hash("sha1", $password) == $db_password || hash("sha256", $password) == $db_password || $i_am_admin)
87
-    {
86
+        if (hash("sha1", $password) == $db_password || hash("sha256", $password) == $db_password || $i_am_admin) {
88 87
             logger(LOG_INFO, "session/checkuser", "login", "logged in virtual subuser »{$login}«.");
89 88
             return ROLE_SUBUSER;
90 89
         }
... ...
@@ -102,22 +101,20 @@ function find_role($login, $password, $i_am_admin = False)
102 101
         if (account_has_totp($account)) {
103 102
             if (check_webmail_password($account, $password)) {
104 103
                 $_SESSION['totp_username'] = $account;
105
-        $_SESSION['totp'] = True;
104
+                $_SESSION['totp'] = true;
106 105
                 show_page('webmailtotp-login');
107 106
                 die();
108 107
             } else {
109
-        return NULL;
108
+                return null;
110 109
             }
111 110
         }
112 111
     }
113 112
     $result = db_query("SELECT cryptpass FROM mail.courier_mailaccounts WHERE account=?", array($account));
114
-  if (@$result->rowCount() > 0)
115
-  {
113
+    if (@$result->rowCount() > 0) {
116 114
         $entry = $result->fetch(PDO::FETCH_OBJ);
117 115
         $db_password = $entry->cryptpass;
118 116
         $hash = crypt($password, $db_password);
119
-    if ($hash == $db_password || $i_am_admin)
120
-    {
117
+        if ($hash == $db_password || $i_am_admin) {
121 118
             logger(LOG_INFO, "session/checkuser", "login", "logged in e-mail-account »{$account}«.");
122 119
             return ROLE_MAILACCOUNT;
123 120
         }
... ...
@@ -127,13 +124,11 @@ function find_role($login, $password, $i_am_admin = False)
127 124
     // virtueller Mail-Account
128 125
     $account = $login;
129 126
     $result = db_query("SELECT cryptpass FROM mail.courier_virtual_accounts WHERE account=?", array($account));
130
-  if (@$result->rowCount() > 0)
131
-  {
127
+    if (@$result->rowCount() > 0) {
132 128
         $entry = $result->fetch(PDO::FETCH_OBJ);
133 129
         $db_password = $entry->cryptpass;
134 130
         $hash = crypt($password, $db_password);
135
-    if ($hash == $db_password || $i_am_admin)
136
-    {
131
+        if ($hash == $db_password || $i_am_admin) {
137 132
             logger(LOG_INFO, "session/checkuser", "login", "logged in virtual e-mail-account »{$account}«.");
138 133
             return ROLE_VMAIL_ACCOUNT;
139 134
         }
... ...
@@ -143,29 +138,28 @@ function find_role($login, $password, $i_am_admin = False)
143 138
 
144 139
 
145 140
     // Nothing?
146
-  return NULL;
141
+    return null;
147 142
 }
148 143
 
149 144
 
150 145
 function get_customer_info($customer)
151 146
 {
152
-  if (! $_SESSION['role'] & ROLE_CUSTOMER)
147
+    if (! $_SESSION['role'] & ROLE_CUSTOMER) {
153 148
         return array();
149
+    }
154 150
     $ret = array();
155 151
     $customerno = (int) $customer;
156
-  if ($customerno != 0)
157
-  {
152
+    if ($customerno != 0) {
158 153
         DEBUG('Looking up customerinfo for customer no. '.$customerno);
159 154
         $result = db_query("SELECT id, anrede, firma, CONCAT_WS(' ', vorname, nachname) AS name, COALESCE(email,email_rechnung,email_extern) AS email FROM kundendaten.kunden WHERE id=?", array($customerno));
160
-  }
161
-  else
162
-  {
155
+    } else {
163 156
         $username = $customer;
164 157
         DEBUG('looking up customer info for username '.$username);
165 158
         $result = db_query("SELECT id, anrede, firma, CONCAT_WS(' ', vorname, nachname) AS name, COALESCE(email,email_rechnung,email_extern) AS email FROM kundendaten.kunden AS k JOIN system.v_useraccounts AS u ON (u.kunde=k.id) WHERE u.username=?", array($username));
166 159
     }
167
-  if (@$result->rowCount() == 0)
160
+    if (@$result->rowCount() == 0) {
168 161
         system_failure("Konnte Kundendaten nicht auslesen!");
162
+    }
169 163
     $data = $result->fetch();
170 164
     DEBUG($data);
171 165
     $ret['customerno'] = $data['id'];
... ...
@@ -181,8 +175,7 @@ function get_customer_info($customer)
181 175
 function get_subuser_info($username)
182 176
 {
183 177
     $result = db_query("SELECT uid, modules FROM system.subusers WHERE username=?", array($username));
184
-  if ($result->rowCount() < 1)
185
-  {
178
+    if ($result->rowCount() < 1) {
186 179
         logger(LOG_ERR, "session/checkuser", "login", "error reading subuser's data: »{$username}«");
187 180
         system_failure('Das Auslesen Ihrer Benutzerdaten ist fehlgeschlagen. Bitte melden Sie dies einem Administrator');
188 181
     }
... ...
@@ -197,8 +190,7 @@ function get_user_info($username)
197 190
 {
198 191
     $result = db_query("SELECT kunde AS customerno, username, uid, homedir, name, server
199 192
                       FROM system.v_useraccounts WHERE username=:username OR uid=:username", array(":username" => $username));
200
-  if ($result->rowCount() < 1)
201
-  {
193
+    if ($result->rowCount() < 1) {
202 194
         logger(LOG_ERR, "session/checkuser", "login", "error reading user's data: »{$username}«");
203 195
         system_failure('Das Auslesen Ihrer Benutzerdaten ist fehlgeschlagen. Bitte melden Sie dies einem Administrator');
204 196
     }
... ...
@@ -247,14 +239,11 @@ function set_systemuser_password($uid, $newpass)
247 239
 {
248 240
     $uid = (int) $uid;
249 241
     require_once('inc/base.php');
250
-  if (defined("CRYPT_SHA512") && CRYPT_SHA512 == 1)
251
-  {
242
+    if (defined("CRYPT_SHA512") && CRYPT_SHA512 == 1) {
252 243
         $rounds = rand(1000, 5000);
253 244
         $salt = "rounds=".$rounds."$".random_string(8);
254 245
         $newpass = crypt($newpass, "\$6\${$salt}\$");
255
-  }
256
-  else
257
-  {
246
+    } else {
258 247
         $salt = random_string(8);
259 248
         $newpass = crypt($newpass, "\$1\${$salt}\$");
260 249
     }
... ...
@@ -288,8 +277,7 @@ function setup_session($role, $useridentity)
288 277
 {
289 278
     session_regenerate_id();
290 279
     $_SESSION['role'] = $role;
291
-  if ($role & ROLE_SUBUSER)
292
-  {
280
+    if ($role & ROLE_SUBUSER) {
293 281
         DEBUG("We are a sub-user");
294 282
         $info = get_subuser_info($useridentity);
295 283
         $_SESSION['userinfo'] = $info;
... ...
@@ -306,16 +294,14 @@ function setup_session($role, $useridentity)
306 294
         }
307 295
         logger(LOG_INFO, "session/start", "login", "logged in user »{$info['username']}«");
308 296
     }
309
-  if ($role & ROLE_SYSTEMUSER)
310
-  {
297
+    if ($role & ROLE_SYSTEMUSER) {
311 298
         DEBUG("We are system user");
312 299
         $info = get_user_info($useridentity);
313 300
         $_SESSION['userinfo'] = $info;
314 301
         logger(LOG_INFO, "session/start", "login", "logged in user »{$info['username']}«");
315 302
         $useridentity = $info['customerno'];
316 303
     }
317
-  if ($role & ROLE_CUSTOMER)
318
-  {
304
+    if ($role & ROLE_CUSTOMER) {
319 305
         $info = get_customer_info($useridentity);
320 306
         $_SESSION['customerinfo'] = $info;
321 307
         if (!isset($_SESSION['admin_user'])) {
... ...
@@ -323,25 +309,21 @@ function setup_session($role, $useridentity)
323 309
         }
324 310
         logger(LOG_INFO, "session/start", "login", "logged in customer no »{$info['customerno']}«");
325 311
     }
326
-  if ($role & ROLE_MAILACCOUNT)
327
-  {
312
+    if ($role & ROLE_MAILACCOUNT) {
328 313
         $id = $useridentity;
329
-    if (! strstr($id, '@'))
314
+        if (! strstr($id, '@')) {
330 315
             $id .= '@'.config('masterdomain');
316
+        }
331 317
         $uid = user_for_mailaccount($id);
332 318
         $_SESSION['mailaccount'] = $id;
333 319
         $_SESSION['userinfo'] = get_user_info($uid);
334 320
         DEBUG("We are mailaccount: {$_SESSION['mailaccount']}");
335 321
     }
336
-  if ($role & ROLE_VMAIL_ACCOUNT)
337
-  {
322
+    if ($role & ROLE_VMAIL_ACCOUNT) {
338 323
         $id = $useridentity;
339 324
         $uid = user_for_vmail_account($id);
340 325
         $_SESSION['mailaccount'] = $id;
341 326
         $_SESSION['userinfo'] = get_user_info($uid);
342 327
         DEBUG("We are virtual mailaccount: {$_SESSION['mailaccount']}");
343 328
     }
344
-
345 329
 }
346
-
347
-?>
... ...
@@ -13,10 +13,11 @@ require_once('inc/base.php');
13 13
 
14 14
 session_name(config('session_name'));
15 15
 
16
-if ($_SERVER['HTTPS']) session_set_cookie_params( 0, '/', '', true, true );
16
+if ($_SERVER['HTTPS']) {
17
+    session_set_cookie_params(0, '/', '', true, true);
18
+}
17 19
 
18
-if (!session_start())
19
-{
20
+if (!session_start()) {
20 21
     logger(LOG_ERR, "session/start", "session", "Die session konnte nicht gestartet werden!");
21 22
     system_failure('Die Sitzung konnte nicht gestartet werden, bitte benachrichtigen Sie den Administrator!');
22 23
 }
... ...
@@ -25,20 +26,17 @@ DEBUG("<pre>POST-DATA: ".htmlspecialchars(print_r($_POST, true))."\nSESSION_DATA
25 26
 
26 27
 if (have_module('webmailtotp') && isset($_POST['webinterface_totpcode']) && isset($_SESSION['totp']) && isset($_SESSION['totp_username'])) {
27 28
     require_once('modules/webmailtotp/include/totp.php');
28
-  $role = NULL;
29
+    $role = null;
29 30
     if (check_totp($_SESSION['totp_username'], $_POST['webinterface_totpcode'])) {
30 31
         $role = find_role($_SESSION['totp_username'], '', true);
31 32
     }
32
-  if ($role === NULL)
33
-  {
33
+    if ($role === null) {
34 34
         $_SESSION['role'] = ROLE_ANONYMOUS;
35 35
         logger(LOG_WARNING, "session/start", "login", "wrong totp code (username: »{$_SESSION['totp_username']}«)");
36 36
         warning('Ihre Anmeldung konnte nicht durchgeführt werden. Geben Sie bitte einen neuen Code ein.');
37 37
         show_page('webmailtotp-login');
38 38
         die();
39
-  }
40
-  else
41
-  {
39
+    } else {
42 40
         setup_session($role, $_SESSION['totp_username']);
43 41
     }
44 42
     unset($_POST['webinterface_totpcode']);
... ...
@@ -46,35 +44,23 @@ if (have_module('webmailtotp') && isset($_POST['webinterface_totpcode']) && isse
46 44
     unset($_SESSION['totp_username']);
47 45
 }
48 46
 
49
-if (isset($_POST['webinterface_username']) && isset($_POST['webinterface_password']))
50
-{
47
+if (isset($_POST['webinterface_username']) && isset($_POST['webinterface_password'])) {
51 48
     $role = find_role($_POST['webinterface_username'], $_POST['webinterface_password']);
52
-  if ($role === NULL)
53
-  {
49
+    if ($role === null) {
54 50
         $_SESSION['role'] = ROLE_ANONYMOUS;
55 51
         logger(LOG_WARNING, "session/start", "login", "wrong user data (username: »{$_POST['webinterface_username']}«)");
56 52
         login_screen('Ihre Anmeldung konnte nicht durchgeführt werden. Vermutlich haben Sie falsche Zugangsdaten eingegeben.');
57
-  }
58
-  else
59
-  {
53
+    } else {
60 54
         setup_session($role, $_POST['webinterface_username']);
61 55
     }
62 56
     unset($_POST['webinterface_username']);
63 57
     unset($_POST['webinterface_password']);
64
-}
65
-
66
-elseif (isset($_SESSION['role']))
67
-{
58
+} elseif (isset($_SESSION['role'])) {
68 59
     /* User ist eingeloggt (aber vielleicht als ROLE_ANONYMOUS!) */
69
-}
70
-
71
-else
72
-{
60
+} else {
73 61
     $_SESSION['role'] = ROLE_ANONYMOUS;
74 62
 }
75 63
 // Wenn wir hier sind, ist der Benutzer eingeloggt. Möglicherweise nur als ANONYMOUS
76 64
 
77 65
 
78 66
 DEBUG("Role: ".$_SESSION['role']);
79
-
80
-?>
... ...
@@ -20,10 +20,11 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
20 20
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
21 21
 
22 22
 <?php 
23
-if ($title)
23
+if ($title) {
24 24
     echo "<title>$title - Administration</title>";
25
-else
25
+} else {
26 26
     echo "<title>Administration</title>";
27
+}
27 28
 ?>
28 29
 <link rel="stylesheet" href="<?php echo $THEME_PATH; ?>style.css" type="text/css" media="screen" title="Normal" />
29 30
 <link rel="shortcut icon" href="<?php echo $THEME_PATH; ?>favicon.ico" type="image/x-icon" />
... ...
@@ -21,10 +21,11 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
21 21
 <head>
22 22
 
23 23
 <?php 
24
-if ($title)
24
+if ($title) {
25 25
     echo "<title>$title - Administration</title>";
26
-else
26
+} else {
27 27
     echo "<title>Administration</title>";
28
+}
28 29
 ?>
29 30
 <link rel="stylesheet" href="<?php echo $THEME_PATH; ?>style.css" type="text/css" media="screen" title="Normal" />
30 31
 <link rel="shortcut icon" href="<?php echo $THEME_PATH; ?>favicon.ico" type="image/x-icon" />
... ...
@@ -20,10 +20,11 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
20 20
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
21 21
 
22 22
 <?php 
23
-if ($title)
23
+if ($title) {
24 24
     echo "<title>$title - Administration</title>";
25
-else
25
+} else {
26 26
     echo "<title>Administration</title>";
27
+}
27 28
 ?>
28 29
 <link rel="shortcut icon" href="<?php echo $THEME_PATH; ?>favicon.ico" type="image/x-icon" />
29 30
 <?php echo $html_header; ?>
30 31