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
-?>