@@ -230,7 +230,7 @@ |
||
230 | 230 | * @param string $user persistent identifier of the user who triggered the action |
231 | 231 | * @param string $category type of modification, from the fixed vocabulary: "NEW", "OWN", "MOD", "DEL" |
232 | 232 | * @param string $message message to log into the audit log |
233 | - * @return boolean TRUE if successful. Will terminate script execution on failure. |
|
233 | + * @return boolean|null TRUE if successful. Will terminate script execution on failure. |
|
234 | 234 | */ |
235 | 235 | public static function writeAudit($user, $category, $message) { |
236 | 236 | switch ($category) { |
@@ -74,14 +74,16 @@ discard block |
||
74 | 74 | |
75 | 75 | if (CAT::$RELEASE_VERSION) { |
76 | 76 | $temp_version = "CAT-".CAT::$VERSION_MAJOR.".".CAT::$VERSION_MINOR; |
77 | - if (CAT::$VERSION_PATCH != 0) |
|
78 | - $temp_version .= ".".CAT::$VERSION_PATCH; |
|
79 | - if (CAT::$VERSION_EXTRA != "") |
|
80 | - $temp_version .= "-".CAT::$VERSION_EXTRA; |
|
77 | + if (CAT::$VERSION_PATCH != 0) { |
|
78 | + $temp_version .= ".".CAT::$VERSION_PATCH; |
|
79 | + } |
|
80 | + if (CAT::$VERSION_EXTRA != "") { |
|
81 | + $temp_version .= "-".CAT::$VERSION_EXTRA; |
|
82 | + } |
|
81 | 83 | CAT::$VERSION = sprintf(_("Release %s"), $temp_version ); |
84 | + } else { |
|
85 | + CAT::$VERSION = _("Unreleased SVN Revision"); |
|
82 | 86 | } |
83 | - else |
|
84 | - CAT::$VERSION = _("Unreleased SVN Revision"); |
|
85 | 87 | } |
86 | 88 | |
87 | 89 | /** |
@@ -170,16 +172,18 @@ discard block |
||
170 | 172 | // we need to map stuff manually |
171 | 173 | $thelang = $try_lang; |
172 | 174 | |
173 | - foreach (Config::$LANGUAGES as $language => $value) |
|
174 | - if (preg_match("/^" . $language . ".*/", $try_lang)) { |
|
175 | + foreach (Config::$LANGUAGES as $language => $value) { |
|
176 | + if (preg_match("/^" . $language . ".*/", $try_lang)) { |
|
175 | 177 | $thelang = $value['locale']; |
178 | + } |
|
176 | 179 | $lang_index = $language; |
177 | 180 | } |
178 | 181 | |
179 | 182 | // echo "Trying to set language to $thelang..."; |
180 | 183 | // putenv("LC_ALL=$thelang"); |
181 | - if (setlocale(LC_ALL, $thelang)) |
|
182 | - break; |
|
184 | + if (setlocale(LC_ALL, $thelang)) { |
|
185 | + break; |
|
186 | + } |
|
183 | 187 | } |
184 | 188 | putenv("LC_ALL=" . $thelang); |
185 | 189 | debug(4, "selected lang:$lang_index:$thelang\n"); |
@@ -191,8 +195,9 @@ discard block |
||
191 | 195 | * gets the language setting in CAT |
192 | 196 | */ |
193 | 197 | static public function get_lang() { |
194 | - if(self::$LANG === '') |
|
195 | - list(self::$LANG, $xx) = self::set_lang(); |
|
198 | + if(self::$LANG === '') { |
|
199 | + list(self::$LANG, $xx) = self::set_lang(); |
|
200 | + } |
|
196 | 201 | return self::$LANG; |
197 | 202 | } |
198 | 203 |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * named the same as device_id. The second option takes precedence. |
173 | 173 | * |
174 | 174 | * @param string $source_name The source file name |
175 | - * @param string $output_name The destination file name |
|
175 | + * @param integer $output_name The destination file name |
|
176 | 176 | * |
177 | 177 | * @return bool result of the copy operation |
178 | 178 | * @final not to be redefined |
@@ -216,8 +216,7 @@ discard block |
||
216 | 216 | * named the same as device_id. The second option takes precedence. |
217 | 217 | * |
218 | 218 | * @param string $source_name The source file name |
219 | - * @param string $output_name The destination file name |
|
220 | - * @param int $use_win_cp Set Windows charset if non-zero |
|
219 | + * @param integer $output_name The destination file name |
|
221 | 220 | * |
222 | 221 | * @final not to be redefined |
223 | 222 | */ |
@@ -262,8 +261,6 @@ discard block |
||
262 | 261 | * The second optional parameter, if nonzero, should be the character set understood by iconv |
263 | 262 | * This is required by the Windows installer and is expected to go away in the future. |
264 | 263 | * |
265 | - * @param string $source_name The source file name |
|
266 | - * @param int $use_win_cp Set Windows charset if non-zero |
|
267 | 264 | * |
268 | 265 | * @final not to be redefined |
269 | 266 | */ |
@@ -107,8 +107,9 @@ discard block |
||
107 | 107 | $CAs = []; |
108 | 108 | if(isset($this->attributes['eap:ca_file'])) { |
109 | 109 | foreach ($this->attributes['eap:ca_file'] as $ca) { |
110 | - if($c = X509::processCertificate($ca)) |
|
111 | - $CAs[] = $c; |
|
110 | + if($c = X509::processCertificate($ca)) { |
|
111 | + $CAs[] = $c; |
|
112 | + } |
|
112 | 113 | } |
113 | 114 | $this->attributes['internal:CAs'][0]=$CAs; |
114 | 115 | } |
@@ -116,9 +117,10 @@ discard block |
||
116 | 117 | $this->attributes['internal:info_file'][0] = |
117 | 118 | $this->saveInfoFile($this->attributes['support:info_file'][0]); |
118 | 119 | } |
119 | - if(isset($this->attributes['general:logo_file'])) |
|
120 | - $this->attributes['internal:logo_file'] = |
|
120 | + if(isset($this->attributes['general:logo_file'])) { |
|
121 | + $this->attributes['internal:logo_file'] = |
|
121 | 122 | $this->saveLogoFile($this->attributes['general:logo_file']); |
123 | + } |
|
122 | 124 | $this->attributes['internal:SSID'] = $this->getSSIDs()['add'];; |
123 | 125 | $this->attributes['internal:remove_SSID'] = $this->getSSIDs()['del'];; |
124 | 126 | $this->attributes['internal:consortia'] = $this->getConsortia(); |
@@ -130,8 +132,9 @@ discard block |
||
130 | 132 | $this->support_url_substitute = sprintf(_("your local %s support page"),Config::$CONSORTIUM['name']); |
131 | 133 | CAT::set_locale($olddomain); |
132 | 134 | |
133 | - if($this->signer && $this->options['sign']) |
|
134 | - $this->sign = CAT::$root . '/signer/'. $this->signer; |
|
135 | + if($this->signer && $this->options['sign']) { |
|
136 | + $this->sign = CAT::$root . '/signer/'. $this->signer; |
|
137 | + } |
|
135 | 138 | $this->installerBasename = $this->getInstallerBasename(); |
136 | 139 | } |
137 | 140 | |
@@ -178,22 +181,24 @@ discard block |
||
178 | 181 | * @final not to be redefined |
179 | 182 | */ |
180 | 183 | final protected function copyFile($source_name, $output_name = 0) { |
181 | - if ( $output_name === 0) |
|
182 | - $output_name = $source_name; |
|
184 | + if ( $output_name === 0) { |
|
185 | + $output_name = $source_name; |
|
186 | + } |
|
183 | 187 | |
184 | 188 | debug(4,"fileCopy($source_name, $output_name)\n"); |
185 | - if(is_file($this->module_path.'/Files/'.$this->device_id.'/'.$source_name)) |
|
186 | - $source = $this->module_path.'/Files/'.$this->device_id.'/'.$source_name; |
|
187 | - elseif(is_file($this->module_path.'/Files/'.$source_name)) |
|
188 | - $source = $this->module_path.'/Files/'.$source_name; |
|
189 | - else { |
|
189 | + if(is_file($this->module_path.'/Files/'.$this->device_id.'/'.$source_name)) { |
|
190 | + $source = $this->module_path.'/Files/'.$this->device_id.'/'.$source_name; |
|
191 | + } elseif(is_file($this->module_path.'/Files/'.$source_name)) { |
|
192 | + $source = $this->module_path.'/Files/'.$source_name; |
|
193 | + } else { |
|
190 | 194 | debug(2,"fileCopy:reqested file $source_name does not exist\n"); |
191 | 195 | return(FALSE); |
192 | 196 | } |
193 | 197 | debug(4,"Copying $source to $output_name\n"); |
194 | 198 | $result = copy($source,"$output_name"); |
195 | - if(! $result ) |
|
196 | - debug(2,"fileCopy($source_name, $output_name) failed\n"); |
|
199 | + if(! $result ) { |
|
200 | + debug(2,"fileCopy($source_name, $output_name) failed\n"); |
|
201 | + } |
|
197 | 202 | return($result); |
198 | 203 | } |
199 | 204 | |
@@ -223,28 +228,33 @@ discard block |
||
223 | 228 | */ |
224 | 229 | |
225 | 230 | final protected function translateFile($source_name, $output_name = 0, $encoding = 0) { |
226 | - if(Config::$NSIS_VERSION >= 3) |
|
227 | - $encoding = 0; |
|
228 | - if ( $output_name === 0) |
|
229 | - $output_name = $source_name; |
|
231 | + if(Config::$NSIS_VERSION >= 3) { |
|
232 | + $encoding = 0; |
|
233 | + } |
|
234 | + if ( $output_name === 0) { |
|
235 | + $output_name = $source_name; |
|
236 | + } |
|
230 | 237 | |
231 | 238 | debug(4,"translateFile($source_name, $output_name, $encoding)\n"); |
232 | 239 | ob_start(); |
233 | 240 | debug(4,$this->module_path.'/Files/'.$this->device_id.'/'.$source_name."\n"); |
234 | - if(is_file($this->module_path.'/Files/'.$this->device_id.'/'.$source_name)) |
|
235 | - $source = $this->module_path.'/Files/'.$this->device_id.'/'.$source_name; |
|
236 | - elseif(is_file($this->module_path.'/Files/'.$source_name)) |
|
237 | - $source = $this->module_path.'/Files/'.$source_name; |
|
241 | + if(is_file($this->module_path.'/Files/'.$this->device_id.'/'.$source_name)) { |
|
242 | + $source = $this->module_path.'/Files/'.$this->device_id.'/'.$source_name; |
|
243 | + } elseif(is_file($this->module_path.'/Files/'.$source_name)) { |
|
244 | + $source = $this->module_path.'/Files/'.$source_name; |
|
245 | + } |
|
238 | 246 | include($source); |
239 | 247 | $output = ob_get_clean(); |
240 | 248 | if($encoding) { |
241 | 249 | $output_c = iconv('UTF-8',$encoding.'//TRANSLIT',$output); |
242 | - if($output_c) |
|
243 | - $output = $output_c; |
|
250 | + if($output_c) { |
|
251 | + $output = $output_c; |
|
252 | + } |
|
244 | 253 | } |
245 | 254 | $f = fopen("$output_name","w"); |
246 | - if(! $f) |
|
247 | - debug(2,"translateFile($source, $output_name, $encoding) failed\n"); |
|
255 | + if(! $f) { |
|
256 | + debug(2,"translateFile($source, $output_name, $encoding) failed\n"); |
|
257 | + } |
|
248 | 258 | fwrite($f,$output); |
249 | 259 | fclose($f); |
250 | 260 | debug(4,"translateFile($source, $output_name, $encoding) end\n"); |
@@ -269,16 +279,19 @@ discard block |
||
269 | 279 | */ |
270 | 280 | |
271 | 281 | final protected function translateString($source_string,$encoding = 0) { |
272 | - if(Config::$NSIS_VERSION >= 3) |
|
273 | - $encoding = 0; |
|
274 | - if($encoding) |
|
275 | - $output_c = iconv('UTF-8',$encoding.'//TRANSLIT',$source_string); |
|
276 | - else |
|
277 | - $output_c = $source_string; |
|
278 | - if($output_c) |
|
279 | - $source_string = str_replace('"','$\\"',$output_c); |
|
280 | - else |
|
281 | - debug(2,"Failed to convert string $source_string\n"); |
|
282 | + if(Config::$NSIS_VERSION >= 3) { |
|
283 | + $encoding = 0; |
|
284 | + } |
|
285 | + if($encoding) { |
|
286 | + $output_c = iconv('UTF-8',$encoding.'//TRANSLIT',$source_string); |
|
287 | + } else { |
|
288 | + $output_c = $source_string; |
|
289 | + } |
|
290 | + if($output_c) { |
|
291 | + $source_string = str_replace('"','$\\"',$output_c); |
|
292 | + } else { |
|
293 | + debug(2,"Failed to convert string $source_string\n"); |
|
294 | + } |
|
282 | 295 | return $source_string; |
283 | 296 | } |
284 | 297 | |
@@ -299,15 +312,19 @@ discard block |
||
299 | 312 | $i = 0; |
300 | 313 | $CA_files = []; |
301 | 314 | $ca_array = $this->attributes['internal:CAs'][0]; |
302 | - if(! $ca_array) |
|
303 | - return(FALSE); |
|
315 | + if(! $ca_array) { |
|
316 | + return(FALSE); |
|
317 | + } |
|
304 | 318 | foreach ($ca_array as $CA) { |
305 | 319 | $f = fopen("cert-$i.crt","w"); |
306 | - if(! $f) die("problem opening the file\n"); |
|
307 | - if($format == "pem") |
|
308 | - fwrite($f,$CA['pem']); |
|
309 | - else |
|
310 | - fwrite($f,$CA['der']); |
|
320 | + if(! $f) { |
|
321 | + die("problem opening the file\n"); |
|
322 | + } |
|
323 | + if($format == "pem") { |
|
324 | + fwrite($f,$CA['pem']); |
|
325 | + } else { |
|
326 | + fwrite($f,$CA['der']); |
|
327 | + } |
|
311 | 328 | fclose($f); |
312 | 329 | $C = []; |
313 | 330 | $C['file'] = "cert-$i.crt"; |
@@ -340,8 +357,9 @@ discard block |
||
340 | 357 | $Inst_a = explode('_',$inst); |
341 | 358 | if(count($Inst_a) > 2) { |
342 | 359 | $inst = ''; |
343 | - foreach($Inst_a as $i) |
|
344 | - $inst .= $i[0]; |
|
360 | + foreach($Inst_a as $i) { |
|
361 | + $inst .= $i[0]; |
|
362 | + } |
|
345 | 363 | } |
346 | 364 | $c_name = iconv("UTF-8", "US-ASCII//TRANSLIT", preg_replace($replace_pattern, '_', Config::$CONSORTIUM['name'])); |
347 | 365 | if($this->attributes['internal:profile_count'][0] > 1) { |
@@ -356,10 +374,12 @@ discard block |
||
356 | 374 | |
357 | 375 | private function getDeviceId() { |
358 | 376 | $d_id = $this->device_id; |
359 | - if(isset($this->options['device_id'])) |
|
360 | - $d_id = $this->options['device_id']; |
|
361 | - if($d_id !== '') |
|
362 | - $d_id .= '-'; |
|
377 | + if(isset($this->options['device_id'])) { |
|
378 | + $d_id = $this->options['device_id']; |
|
379 | + } |
|
380 | + if($d_id !== '') { |
|
381 | + $d_id .= '-'; |
|
382 | + } |
|
363 | 383 | return $d_id; |
364 | 384 | } |
365 | 385 | |
@@ -369,9 +389,9 @@ discard block |
||
369 | 389 | $S['del']=[]; |
370 | 390 | if (isset(Config::$CONSORTIUM['ssid'])) { |
371 | 391 | foreach (Config::$CONSORTIUM['ssid'] as $ssid) { |
372 | - if(isset(Config::$CONSORTIUM['tkipsupport']) && Config::$CONSORTIUM['tkipsupport'] == TRUE) |
|
373 | - $S['add'][$ssid] = 'TKIP'; |
|
374 | - else { |
|
392 | + if(isset(Config::$CONSORTIUM['tkipsupport']) && Config::$CONSORTIUM['tkipsupport'] == TRUE) { |
|
393 | + $S['add'][$ssid] = 'TKIP'; |
|
394 | + } else { |
|
375 | 395 | $S['add'][$ssid] = 'AES'; |
376 | 396 | $S['del'][$ssid] = 'TKIP'; |
377 | 397 | } |
@@ -380,18 +400,21 @@ discard block |
||
380 | 400 | if(isset($this->attributes['media:SSID'])) { |
381 | 401 | $SSID = $this->attributes['media:SSID']; |
382 | 402 | |
383 | - foreach($SSID as $ssid) |
|
384 | - $S['add'][$ssid] = 'AES'; |
|
403 | + foreach($SSID as $ssid) { |
|
404 | + $S['add'][$ssid] = 'AES'; |
|
405 | + } |
|
385 | 406 | } |
386 | 407 | if(isset($this->attributes['media:SSID_with_legacy'])) { |
387 | 408 | $SSID = $this->attributes['media:SSID_with_legacy']; |
388 | - foreach($SSID as $ssid) |
|
389 | - $S['add'][$ssid] = 'TKIP'; |
|
409 | + foreach($SSID as $ssid) { |
|
410 | + $S['add'][$ssid] = 'TKIP'; |
|
411 | + } |
|
390 | 412 | } |
391 | 413 | if(isset($this->attributes['media:remove_SSID'])) { |
392 | 414 | $SSID = $this->attributes['media:remove_SSID']; |
393 | - foreach($SSID as $ssid) |
|
394 | - $S['del'][$ssid] = 'DEL'; |
|
415 | + foreach($SSID as $ssid) { |
|
416 | + $S['del'][$ssid] = 'DEL'; |
|
417 | + } |
|
395 | 418 | } |
396 | 419 | return $S; |
397 | 420 | } |
@@ -399,9 +422,10 @@ discard block |
||
399 | 422 | private function getConsortia() { |
400 | 423 | $OIs = []; |
401 | 424 | $OIs = array_merge($OIs, Config::$CONSORTIUM['interworking-consortium-oi']); |
402 | - if (isset($this->attributes['media:consortium_OI'])) |
|
403 | - foreach ($this->attributes['media:consortium_OI'] as $new_oi) |
|
425 | + if (isset($this->attributes['media:consortium_OI'])) { |
|
426 | + foreach ($this->attributes['media:consortium_OI'] as $new_oi) |
|
404 | 427 | $OIs[] = $new_oi; |
428 | + } |
|
405 | 429 | return $OIs; |
406 | 430 | } |
407 | 431 | |
@@ -421,10 +445,11 @@ discard block |
||
421 | 445 | foreach ($Logos as $blob) { |
422 | 446 | $finfo = new finfo(FILEINFO_MIME_TYPE); |
423 | 447 | $mime = $finfo->buffer($blob); |
424 | - if(preg_match('/^image\/(.*)/',$mime,$m)) |
|
425 | - $ext = $m[1]; |
|
426 | - else |
|
427 | - $ext = 'unsupported'; |
|
448 | + if(preg_match('/^image\/(.*)/',$mime,$m)) { |
|
449 | + $ext = $m[1]; |
|
450 | + } else { |
|
451 | + $ext = 'unsupported'; |
|
452 | + } |
|
428 | 453 | debug(4,"saveLogoFile: $mime : $ext\n"); |
429 | 454 | $f_name = 'logo-'.$i.'.'.$ext; |
430 | 455 | $f = fopen($f_name,"w"); |
@@ -447,7 +472,9 @@ discard block |
||
447 | 472 | $ext = isset($this->mime_extensions[$mime]) ? $this->mime_extensions[$mime] : 'usupported'; |
448 | 473 | debug(4,"saveInfoFile: $mime : $ext\n"); |
449 | 474 | $f = fopen('local-info.'.$ext,"w"); |
450 | - if(! $f) die("problem opening the file\n"); |
|
475 | + if(! $f) { |
|
476 | + die("problem opening the file\n"); |
|
477 | + } |
|
451 | 478 | fwrite($f,$blob); |
452 | 479 | fclose($f); |
453 | 480 | return(['name'=>'local-info.'.$ext,'mime'=>$ext]); |
@@ -32,6 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * write debug messages to the log |
34 | 34 | * |
35 | + * @param integer $level |
|
35 | 36 | */ |
36 | 37 | function debug($level, $t) { |
37 | 38 | if (Config::$DEBUG_LEVEL >= $level) { |
@@ -130,7 +131,7 @@ discard block |
||
130 | 131 | * generates a UUID |
131 | 132 | * |
132 | 133 | * @param string $prefix an extra prefix to set before the UUID |
133 | - * @return UUID (possibly prefixed) |
|
134 | + * @return string (possibly prefixed) |
|
134 | 135 | */ |
135 | 136 | function uuid($prefix = '', $deterministic_source = NULL) { |
136 | 137 | if ($deterministic_source === NULL) |
@@ -56,10 +56,11 @@ discard block |
||
56 | 56 | |
57 | 57 | function rrmdir($dir) { |
58 | 58 | foreach (glob($dir . '/*') as $file) { |
59 | - if (is_dir($file)) |
|
60 | - rrmdir($file); |
|
61 | - else |
|
62 | - unlink($file); |
|
59 | + if (is_dir($file)) { |
|
60 | + rrmdir($file); |
|
61 | + } else { |
|
62 | + unlink($file); |
|
63 | + } |
|
63 | 64 | } |
64 | 65 | rmdir($dir); |
65 | 66 | } |
@@ -73,36 +74,42 @@ discard block |
||
73 | 74 | */ |
74 | 75 | function calculateCommonHostSuffix(array $hosts) { |
75 | 76 | // massage names. A trailing dot can be omitted |
76 | - foreach ($hosts as $index => $host) |
|
77 | - if (substr($host, -1) == '.') { |
|
77 | + foreach ($hosts as $index => $host) { |
|
78 | + if (substr($host, -1) == '.') { |
|
78 | 79 | $hosts[$index] = substr($host, 0, -1); |
80 | + } |
|
79 | 81 | echo "Changed host to " . $hosts[$index] . "\n"; |
80 | 82 | } |
81 | 83 | // easy :-) |
82 | - if (count($hosts) == 1) |
|
83 | - return $hosts[0]; |
|
84 | + if (count($hosts) == 1) { |
|
85 | + return $hosts[0]; |
|
86 | + } |
|
84 | 87 | // not so easy :-( |
85 | 88 | else { |
86 | 89 | // look for the last dot from the end; if the corresponding substring is |
87 | 90 | // different, no common match! |
88 | 91 | $explodednames = []; |
89 | - foreach ($hosts as $host) |
|
90 | - $explodednames[] = explode('.', $host); |
|
92 | + foreach ($hosts as $host) { |
|
93 | + $explodednames[] = explode('.', $host); |
|
94 | + } |
|
91 | 95 | $commonsuffix = []; |
92 | 96 | while (count($explodednames[0]) > 0) { |
93 | 97 | $match = TRUE; |
94 | 98 | $testname = array_pop($explodednames[0]); |
95 | 99 | for ($i = 1; $i < count($explodednames); $i = $i + 1) { |
96 | - if (count($explodednames[$i]) == 0) |
|
97 | - $match = FALSE; |
|
100 | + if (count($explodednames[$i]) == 0) { |
|
101 | + $match = FALSE; |
|
102 | + } |
|
98 | 103 | $bla = array_pop($explodednames[$i]); |
99 | - if ($bla != $testname) |
|
100 | - $match = FALSE; |
|
104 | + if ($bla != $testname) { |
|
105 | + $match = FALSE; |
|
106 | + } |
|
107 | + } |
|
108 | + if ($match == TRUE) { |
|
109 | + $commonsuffix[] = $testname; |
|
110 | + } else { |
|
111 | + break; |
|
101 | 112 | } |
102 | - if ($match == TRUE) |
|
103 | - $commonsuffix[] = $testname; |
|
104 | - else |
|
105 | - break; |
|
106 | 113 | } |
107 | 114 | $finalsuffix = array_reverse($commonsuffix); |
108 | 115 | return implode('.', $finalsuffix); |
@@ -133,10 +140,11 @@ discard block |
||
133 | 140 | * @return UUID (possibly prefixed) |
134 | 141 | */ |
135 | 142 | function uuid($prefix = '', $deterministic_source = NULL) { |
136 | - if ($deterministic_source === NULL) |
|
137 | - $chars = md5(uniqid(mt_rand(), true)); |
|
138 | - else |
|
139 | - $chars = md5($deterministic_source); |
|
143 | + if ($deterministic_source === NULL) { |
|
144 | + $chars = md5(uniqid(mt_rand(), true)); |
|
145 | + } else { |
|
146 | + $chars = md5($deterministic_source); |
|
147 | + } |
|
140 | 148 | $uuid = substr($chars, 0, 8) . '-'; |
141 | 149 | $uuid .= substr($chars, 8, 4) . '-'; |
142 | 150 | $uuid .= substr($chars, 12, 4) . '-'; |
@@ -159,12 +167,13 @@ discard block |
||
159 | 167 | $try = unserialize($val['value']); |
160 | 168 | $r_val[$try['lang']] = $try['content']; |
161 | 169 | } |
162 | - if (isset($r_val[$locale])) |
|
163 | - $out = $r_val[$locale]; |
|
164 | - elseif (isset($r_val['C'])) |
|
165 | - $out = $r_val['C']; |
|
166 | - else |
|
167 | - $out = 0; |
|
170 | + if (isset($r_val[$locale])) { |
|
171 | + $out = $r_val[$locale]; |
|
172 | + } elseif (isset($r_val['C'])) { |
|
173 | + $out = $r_val['C']; |
|
174 | + } else { |
|
175 | + $out = 0; |
|
176 | + } |
|
168 | 177 | } else { |
169 | 178 | $out = 0; |
170 | 179 | } |
@@ -203,8 +212,9 @@ discard block |
||
203 | 212 | debug(4, "Directory creation failed for $tmp_dir\n"); |
204 | 213 | return ['base'=>$path,'dir'=>'',$name=>'']; |
205 | 214 | } |
206 | - } else |
|
207 | - debug(4, "Directory created: $tmp_dir\n"); |
|
215 | + } else { |
|
216 | + debug(4, "Directory created: $tmp_dir\n"); |
|
217 | + } |
|
208 | 218 | return ['base'=>$path,'dir'=>$tmp_dir,'name'=>$name]; |
209 | 219 | } |
210 | 220 |
@@ -96,6 +96,10 @@ discard block |
||
96 | 96 | define('QR_FORMAT_PNG', 1); |
97 | 97 | |
98 | 98 | class qrstr { |
99 | + |
|
100 | + /** |
|
101 | + * @param string $repl |
|
102 | + */ |
|
99 | 103 | public static function set(&$srctab, $x, $y, $repl, $replLen = false) { |
100 | 104 | $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl)); |
101 | 105 | } |
@@ -231,6 +235,11 @@ discard block |
||
231 | 235 | } |
232 | 236 | |
233 | 237 | //---------------------------------------------------------------------- |
238 | + |
|
239 | + /** |
|
240 | + * @param boolean $outfile |
|
241 | + * @param string $err |
|
242 | + */ |
|
234 | 243 | public static function log($outfile, $err) |
235 | 244 | { |
236 | 245 | if (QR_LOG_DIR !== false) { |
@@ -256,6 +265,10 @@ discard block |
||
256 | 265 | } |
257 | 266 | |
258 | 267 | //---------------------------------------------------------------------- |
268 | + |
|
269 | + /** |
|
270 | + * @param string $markerId |
|
271 | + */ |
|
259 | 272 | public static function markTime($markerId) |
260 | 273 | { |
261 | 274 | list($usec, $sec) = explode(" ", microtime()); |
@@ -410,18 +423,30 @@ discard block |
||
410 | 423 | } |
411 | 424 | |
412 | 425 | //---------------------------------------------------------------------- |
426 | + |
|
427 | + /** |
|
428 | + * @param integer $version |
|
429 | + */ |
|
413 | 430 | public static function getWidth($version) |
414 | 431 | { |
415 | 432 | return self::$capacity[$version][QRCAP_WIDTH]; |
416 | 433 | } |
417 | 434 | |
418 | 435 | //---------------------------------------------------------------------- |
436 | + |
|
437 | + /** |
|
438 | + * @param integer $version |
|
439 | + */ |
|
419 | 440 | public static function getRemainder($version) |
420 | 441 | { |
421 | 442 | return self::$capacity[$version][QRCAP_REMINDER]; |
422 | 443 | } |
423 | 444 | |
424 | 445 | //---------------------------------------------------------------------- |
446 | + |
|
447 | + /** |
|
448 | + * @param integer $size |
|
449 | + */ |
|
425 | 450 | public static function getMinimumVersion($size, $level) |
426 | 451 | { |
427 | 452 | |
@@ -535,6 +560,9 @@ discard block |
||
535 | 560 | //---------------------------------------------------------------------- |
536 | 561 | // CACHEABLE!!! |
537 | 562 | |
563 | + /** |
|
564 | + * @param integer $version |
|
565 | + */ |
|
538 | 566 | public static function getEccSpec($version, $level, array &$spec) |
539 | 567 | { |
540 | 568 | if (count($spec) < 5) { |
@@ -857,12 +885,20 @@ discard block |
||
857 | 885 | } |
858 | 886 | |
859 | 887 | //---------------------------------------------------------------------- |
888 | + |
|
889 | + /** |
|
890 | + * @param string $code |
|
891 | + */ |
|
860 | 892 | public static function unserial($code) |
861 | 893 | { |
862 | 894 | return explode("\n", gzuncompress($code)); |
863 | 895 | } |
864 | 896 | |
865 | 897 | //---------------------------------------------------------------------- |
898 | + |
|
899 | + /** |
|
900 | + * @param integer $version |
|
901 | + */ |
|
866 | 902 | public static function newFrame($version) |
867 | 903 | { |
868 | 904 | if($version < 1 || $version > QRSPEC_VERSION_MAX) |
@@ -1236,6 +1272,10 @@ discard block |
||
1236 | 1272 | } |
1237 | 1273 | |
1238 | 1274 | //---------------------------------------------------------------------- |
1275 | + |
|
1276 | + /** |
|
1277 | + * @param integer $version |
|
1278 | + */ |
|
1239 | 1279 | public function encodeBitStream($version) |
1240 | 1280 | { |
1241 | 1281 | try { |
@@ -1313,6 +1353,10 @@ discard block |
||
1313 | 1353 | } |
1314 | 1354 | |
1315 | 1355 | //---------------------------------------------------------------------- |
1356 | + |
|
1357 | + /** |
|
1358 | + * @param integer $version |
|
1359 | + */ |
|
1316 | 1360 | public function setVersion($version) |
1317 | 1361 | { |
1318 | 1362 | if($version < 0 || $version > QRSPEC_VERSION_MAX) { |
@@ -1351,6 +1395,12 @@ discard block |
||
1351 | 1395 | } |
1352 | 1396 | |
1353 | 1397 | //---------------------------------------------------------------------- |
1398 | + |
|
1399 | + /** |
|
1400 | + * @param QRinput $mode |
|
1401 | + * @param integer $size |
|
1402 | + * @param integer $data |
|
1403 | + */ |
|
1354 | 1404 | public function append($mode, $size, $data) |
1355 | 1405 | { |
1356 | 1406 | try { |
@@ -1446,6 +1496,10 @@ discard block |
||
1446 | 1496 | ]; |
1447 | 1497 | |
1448 | 1498 | //---------------------------------------------------------------------- |
1499 | + |
|
1500 | + /** |
|
1501 | + * @param integer $c |
|
1502 | + */ |
|
1449 | 1503 | public static function lookAnTable($c) |
1450 | 1504 | { |
1451 | 1505 | return (($c > 127)?-1:self::$anTable[$c]); |
@@ -1531,6 +1585,10 @@ discard block |
||
1531 | 1585 | |
1532 | 1586 | |
1533 | 1587 | //---------------------------------------------------------------------- |
1588 | + |
|
1589 | + /** |
|
1590 | + * @param integer $version |
|
1591 | + */ |
|
1534 | 1592 | public function estimateBitStreamSize($version) |
1535 | 1593 | { |
1536 | 1594 | $bits = 0; |
@@ -1648,6 +1706,10 @@ discard block |
||
1648 | 1706 | } |
1649 | 1707 | |
1650 | 1708 | //---------------------------------------------------------------------- |
1709 | + |
|
1710 | + /** |
|
1711 | + * @param QRbitstream $bstream |
|
1712 | + */ |
|
1651 | 1713 | public function appendPaddingBit(&$bstream) |
1652 | 1714 | { |
1653 | 1715 | $bits = $bstream->size(); |
@@ -1977,6 +2039,10 @@ discard block |
||
1977 | 2039 | public $modeHint; |
1978 | 2040 | |
1979 | 2041 | //---------------------------------------------------------------------- |
2042 | + |
|
2043 | + /** |
|
2044 | + * @param QRinput $input |
|
2045 | + */ |
|
1980 | 2046 | public function __construct($dataStr, $input, $modeHint) |
1981 | 2047 | { |
1982 | 2048 | $this->dataStr = $dataStr; |
@@ -1985,6 +2051,10 @@ discard block |
||
1985 | 2051 | } |
1986 | 2052 | |
1987 | 2053 | //---------------------------------------------------------------------- |
2054 | + |
|
2055 | + /** |
|
2056 | + * @param string $str |
|
2057 | + */ |
|
1988 | 2058 | public static function isdigitat($str, $pos) |
1989 | 2059 | { |
1990 | 2060 | if ($pos >= strlen($str)) |
@@ -1994,6 +2064,10 @@ discard block |
||
1994 | 2064 | } |
1995 | 2065 | |
1996 | 2066 | //---------------------------------------------------------------------- |
2067 | + |
|
2068 | + /** |
|
2069 | + * @param string $str |
|
2070 | + */ |
|
1997 | 2071 | public static function isalnumat($str, $pos) |
1998 | 2072 | { |
1999 | 2073 | if ($pos >= strlen($str)) |
@@ -2114,6 +2188,10 @@ discard block |
||
2114 | 2188 | } |
2115 | 2189 | |
2116 | 2190 | //---------------------------------------------------------------------- |
2191 | + |
|
2192 | + /** |
|
2193 | + * @return integer |
|
2194 | + */ |
|
2117 | 2195 | public function eatKanji() |
2118 | 2196 | { |
2119 | 2197 | $p = 0; |
@@ -2447,6 +2525,13 @@ discard block |
||
2447 | 2525 | public static $items = []; |
2448 | 2526 | |
2449 | 2527 | //---------------------------------------------------------------------- |
2528 | + |
|
2529 | + /** |
|
2530 | + * @param integer $symsize |
|
2531 | + * @param integer $gfpoly |
|
2532 | + * @param integer $fcr |
|
2533 | + * @param integer $prim |
|
2534 | + */ |
|
2450 | 2535 | public static function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) |
2451 | 2536 | { |
2452 | 2537 | foreach(self::$items as $rs) { |
@@ -2601,6 +2686,10 @@ discard block |
||
2601 | 2686 | } |
2602 | 2687 | |
2603 | 2688 | //---------------------------------------------------------------------- |
2689 | + |
|
2690 | + /** |
|
2691 | + * @param string $code |
|
2692 | + */ |
|
2604 | 2693 | public static function unserial($code) |
2605 | 2694 | { |
2606 | 2695 | $codeArr = []; |
@@ -2661,6 +2750,10 @@ discard block |
||
2661 | 2750 | } |
2662 | 2751 | |
2663 | 2752 | //---------------------------------------------------------------------- |
2753 | + |
|
2754 | + /** |
|
2755 | + * @param integer $length |
|
2756 | + */ |
|
2664 | 2757 | public function calcN1N3($length) |
2665 | 2758 | { |
2666 | 2759 | $demerit = 0; |
@@ -2971,6 +3064,10 @@ discard block |
||
2971 | 3064 | public $data; |
2972 | 3065 | |
2973 | 3066 | //---------------------------------------------------------------------- |
3067 | + |
|
3068 | + /** |
|
3069 | + * @param integer $mask |
|
3070 | + */ |
|
2974 | 3071 | public function encodeMask(QRinput $input, $mask) |
2975 | 3072 | { |
2976 | 3073 | if($input->getVersion() < 0 || $input->getVersion() > QRSPEC_VERSION_MAX) { |
@@ -3052,6 +3149,11 @@ discard block |
||
3052 | 3149 | } |
3053 | 3150 | |
3054 | 3151 | //---------------------------------------------------------------------- |
3152 | + |
|
3153 | + /** |
|
3154 | + * @param integer $version |
|
3155 | + * @param integer $level |
|
3156 | + */ |
|
3055 | 3157 | public function encodeString8bit($string, $version, $level) |
3056 | 3158 | { |
3057 | 3159 | if(string == NULL) { |
@@ -3071,6 +3173,12 @@ discard block |
||
3071 | 3173 | } |
3072 | 3174 | |
3073 | 3175 | //---------------------------------------------------------------------- |
3176 | + |
|
3177 | + /** |
|
3178 | + * @param integer $version |
|
3179 | + * @param integer $level |
|
3180 | + * @param boolean $casesensitive |
|
3181 | + */ |
|
3074 | 3182 | public function encodeString($string, $version, $level, $hint, $casesensitive) |
3075 | 3183 | { |
3076 | 3184 |
@@ -176,8 +176,9 @@ discard block |
||
176 | 176 | { |
177 | 177 | $barcode_array = []; |
178 | 178 | |
179 | - if (!is_array($mode)) |
|
180 | - $mode = explode(',', $mode); |
|
179 | + if (!is_array($mode)) { |
|
180 | + $mode = explode(',', $mode); |
|
181 | + } |
|
181 | 182 | |
182 | 183 | $eccLevel = 'L'; |
183 | 184 | |
@@ -194,8 +195,9 @@ discard block |
||
194 | 195 | |
195 | 196 | foreach ($qrTab as $line) { |
196 | 197 | $arrAdd = []; |
197 | - foreach(str_split($line) as $char) |
|
198 | - $arrAdd[] = ($char=='1')?1:0; |
|
198 | + foreach(str_split($line) as $char) { |
|
199 | + $arrAdd[] = ($char=='1')?1:0; |
|
200 | + } |
|
199 | 201 | $barcode_array['bcode'][] = $arrAdd; |
200 | 202 | } |
201 | 203 | |
@@ -223,8 +225,9 @@ discard block |
||
223 | 225 | |
224 | 226 | $width = count($frame); |
225 | 227 | $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
226 | - for ($maskNo=0; $maskNo<8; $maskNo++) |
|
227 | - $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
228 | + for ($maskNo=0; $maskNo<8; $maskNo++) { |
|
229 | + $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
230 | + } |
|
228 | 231 | } |
229 | 232 | |
230 | 233 | QRtools::markTime('after_build_cache'); |
@@ -261,8 +264,9 @@ discard block |
||
261 | 264 | list($usec, $sec) = explode(" ", microtime()); |
262 | 265 | $time = ((float)$usec + (float)$sec); |
263 | 266 | |
264 | - if (!isset($GLOBALS['qr_time_bench'])) |
|
265 | - $GLOBALS['qr_time_bench'] = []; |
|
267 | + if (!isset($GLOBALS['qr_time_bench'])) { |
|
268 | + $GLOBALS['qr_time_bench'] = []; |
|
269 | + } |
|
266 | 270 | |
267 | 271 | $GLOBALS['qr_time_bench'][$markerId] = $time; |
268 | 272 | } |
@@ -427,8 +431,9 @@ discard block |
||
427 | 431 | |
428 | 432 | for($i=1; $i<= QRSPEC_VERSION_MAX; $i++) { |
429 | 433 | $words = self::$capacity[$i][QRCAP_WORDS] - self::$capacity[$i][QRCAP_EC][$level]; |
430 | - if($words >= $size) |
|
431 | - return $i; |
|
434 | + if($words >= $size) { |
|
435 | + return $i; |
|
436 | + } |
|
432 | 437 | } |
433 | 438 | |
434 | 439 | return -1; |
@@ -446,8 +451,9 @@ discard block |
||
446 | 451 | //---------------------------------------------------------------------- |
447 | 452 | public static function lengthIndicator($mode, $version) |
448 | 453 | { |
449 | - if ($mode == QR_MODE_STRUCTURE) |
|
450 | - return 0; |
|
454 | + if ($mode == QR_MODE_STRUCTURE) { |
|
455 | + return 0; |
|
456 | + } |
|
451 | 457 | |
452 | 458 | if ($version <= 9) { |
453 | 459 | $l = 0; |
@@ -463,8 +469,9 @@ discard block |
||
463 | 469 | //---------------------------------------------------------------------- |
464 | 470 | public static function maximumWords($mode, $version) |
465 | 471 | { |
466 | - if($mode == QR_MODE_STRUCTURE) |
|
467 | - return 3; |
|
472 | + if($mode == QR_MODE_STRUCTURE) { |
|
473 | + return 3; |
|
474 | + } |
|
468 | 475 | |
469 | 476 | if($version <= 9) { |
470 | 477 | $l = 0; |
@@ -610,8 +617,9 @@ discard block |
||
610 | 617 | //---------------------------------------------------------------------- |
611 | 618 | public static function putAlignmentPattern($version, &$frame, $width) |
612 | 619 | { |
613 | - if($version < 2) |
|
614 | - return; |
|
620 | + if($version < 2) { |
|
621 | + return; |
|
622 | + } |
|
615 | 623 | |
616 | 624 | $d = self::$alignmentPattern[$version][1] - self::$alignmentPattern[$version][0]; |
617 | 625 | if($d < 0) { |
@@ -663,8 +671,9 @@ discard block |
||
663 | 671 | //---------------------------------------------------------------------- |
664 | 672 | public static function getVersionPattern($version) |
665 | 673 | { |
666 | - if($version < 7 || $version > QRSPEC_VERSION_MAX) |
|
667 | - return 0; |
|
674 | + if($version < 7 || $version > QRSPEC_VERSION_MAX) { |
|
675 | + return 0; |
|
676 | + } |
|
668 | 677 | |
669 | 678 | return self::$versionPattern[$version -7]; |
670 | 679 | } |
@@ -681,11 +690,13 @@ discard block |
||
681 | 690 | |
682 | 691 | public static function getFormatInfo($mask, $level) |
683 | 692 | { |
684 | - if($mask < 0 || $mask > 7) |
|
685 | - return 0; |
|
693 | + if($mask < 0 || $mask > 7) { |
|
694 | + return 0; |
|
695 | + } |
|
686 | 696 | |
687 | - if($level < 0 || $level > 3) |
|
688 | - return 0; |
|
697 | + if($level < 0 || $level > 3) { |
|
698 | + return 0; |
|
699 | + } |
|
689 | 700 | |
690 | 701 | return self::$formatInfo[$level][$mask]; |
691 | 702 | } |
@@ -865,8 +876,9 @@ discard block |
||
865 | 876 | //---------------------------------------------------------------------- |
866 | 877 | public static function newFrame($version) |
867 | 878 | { |
868 | - if($version < 1 || $version > QRSPEC_VERSION_MAX) |
|
869 | - return null; |
|
879 | + if($version < 1 || $version > QRSPEC_VERSION_MAX) { |
|
880 | + return null; |
|
881 | + } |
|
870 | 882 | |
871 | 883 | if(!isset(self::$frames[$version])) { |
872 | 884 | |
@@ -884,8 +896,9 @@ discard block |
||
884 | 896 | } |
885 | 897 | } |
886 | 898 | |
887 | - if(is_null(self::$frames[$version])) |
|
888 | - return null; |
|
899 | + if(is_null(self::$frames[$version])) { |
|
900 | + return null; |
|
901 | + } |
|
889 | 902 | |
890 | 903 | return self::$frames[$version]; |
891 | 904 | } |
@@ -953,7 +966,7 @@ discard block |
||
953 | 966 | ImagePng($image, $filename); |
954 | 967 | header("Content-type: image/png"); |
955 | 968 | ImagePng($image); |
956 | - }else{ |
|
969 | + } else{ |
|
957 | 970 | ImagePng($image, $filename); |
958 | 971 | } |
959 | 972 | } |
@@ -1213,8 +1226,9 @@ discard block |
||
1213 | 1226 | { |
1214 | 1227 | $bits = 0; |
1215 | 1228 | |
1216 | - if($version == 0) |
|
1217 | - $version = 1; |
|
1229 | + if($version == 0) { |
|
1230 | + $version = 1; |
|
1231 | + } |
|
1218 | 1232 | |
1219 | 1233 | switch($this->mode) { |
1220 | 1234 | case QR_MODE_NUM: $bits = QRinput::estimateBitsModeNum($this->size); break; |
@@ -1273,8 +1287,9 @@ discard block |
||
1273 | 1287 | break; |
1274 | 1288 | } |
1275 | 1289 | |
1276 | - if($ret < 0) |
|
1277 | - return -1; |
|
1290 | + if($ret < 0) { |
|
1291 | + return -1; |
|
1292 | + } |
|
1278 | 1293 | } |
1279 | 1294 | |
1280 | 1295 | return $this->bstream->size(); |
@@ -1491,8 +1506,9 @@ discard block |
||
1491 | 1506 | //---------------------------------------------------------------------- |
1492 | 1507 | public static function checkModeKanji($size, $data) |
1493 | 1508 | { |
1494 | - if($size & 1) |
|
1495 | - return false; |
|
1509 | + if($size & 1) { |
|
1510 | + return false; |
|
1511 | + } |
|
1496 | 1512 | |
1497 | 1513 | for($i=0; $i<$size; $i+=2) { |
1498 | 1514 | $val = (ord($data[$i]) << 8) | ord($data[$i+1]); |
@@ -1512,8 +1528,9 @@ discard block |
||
1512 | 1528 | |
1513 | 1529 | public static function check($mode, $size, $data) |
1514 | 1530 | { |
1515 | - if($size <= 0) |
|
1516 | - return false; |
|
1531 | + if($size <= 0) { |
|
1532 | + return false; |
|
1533 | + } |
|
1517 | 1534 | |
1518 | 1535 | switch($mode) { |
1519 | 1536 | case QR_MODE_NUM: return self::checkModeNum($size, $data); break; |
@@ -1578,8 +1595,9 @@ discard block |
||
1578 | 1595 | $chunks = (int)($payload / 11); |
1579 | 1596 | $remain = $payload - $chunks * 11; |
1580 | 1597 | $size = $chunks * 2; |
1581 | - if($remain >= 6) |
|
1582 | - $size++; |
|
1598 | + if($remain >= 6) { |
|
1599 | + $size++; |
|
1600 | + } |
|
1583 | 1601 | break; |
1584 | 1602 | case QR_MODE_8: |
1585 | 1603 | $size = (int)($payload / 8); |
@@ -1596,8 +1614,12 @@ discard block |
||
1596 | 1614 | } |
1597 | 1615 | |
1598 | 1616 | $maxsize = QRspec::maximumWords($mode, $version); |
1599 | - if($size < 0) $size = 0; |
|
1600 | - if($size > $maxsize) $size = $maxsize; |
|
1617 | + if($size < 0) { |
|
1618 | + $size = 0; |
|
1619 | + } |
|
1620 | + if($size > $maxsize) { |
|
1621 | + $size = $maxsize; |
|
1622 | + } |
|
1601 | 1623 | |
1602 | 1624 | return $size; |
1603 | 1625 | } |
@@ -1610,8 +1632,9 @@ discard block |
||
1610 | 1632 | foreach($this->items as $item) { |
1611 | 1633 | $bits = $item->encodeBitStream($this->version); |
1612 | 1634 | |
1613 | - if($bits < 0) |
|
1614 | - return -1; |
|
1635 | + if($bits < 0) { |
|
1636 | + return -1; |
|
1637 | + } |
|
1615 | 1638 | |
1616 | 1639 | $total += $bits; |
1617 | 1640 | } |
@@ -1630,8 +1653,9 @@ discard block |
||
1630 | 1653 | for(;;) { |
1631 | 1654 | $bits = $this->createBitStream(); |
1632 | 1655 | |
1633 | - if($bits < 0) |
|
1634 | - return -1; |
|
1656 | + if($bits < 0) { |
|
1657 | + return -1; |
|
1658 | + } |
|
1635 | 1659 | |
1636 | 1660 | $ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level); |
1637 | 1661 | if($ver < 0) { |
@@ -1668,8 +1692,9 @@ discard block |
||
1668 | 1692 | $padding = new QRbitstream(); |
1669 | 1693 | $ret = $padding->appendNum($words * 8 - $bits + 4, 0); |
1670 | 1694 | |
1671 | - if($ret < 0) |
|
1672 | - return $ret; |
|
1695 | + if($ret < 0) { |
|
1696 | + return $ret; |
|
1697 | + } |
|
1673 | 1698 | |
1674 | 1699 | $padlen = $maxwords - $words; |
1675 | 1700 | |
@@ -1682,8 +1707,9 @@ discard block |
||
1682 | 1707 | |
1683 | 1708 | $ret = $padding->appendBytes($padlen, $padbuf); |
1684 | 1709 | |
1685 | - if($ret < 0) |
|
1686 | - return $ret; |
|
1710 | + if($ret < 0) { |
|
1711 | + return $ret; |
|
1712 | + } |
|
1687 | 1713 | |
1688 | 1714 | } |
1689 | 1715 | |
@@ -1860,13 +1886,15 @@ discard block |
||
1860 | 1886 | //---------------------------------------------------------------------- |
1861 | 1887 | public function appendNum($bits, $num) |
1862 | 1888 | { |
1863 | - if ($bits == 0) |
|
1864 | - return 0; |
|
1889 | + if ($bits == 0) { |
|
1890 | + return 0; |
|
1891 | + } |
|
1865 | 1892 | |
1866 | 1893 | $b = QRbitstream::newFromNum($bits, $num); |
1867 | 1894 | |
1868 | - if(is_null($b)) |
|
1869 | - return -1; |
|
1895 | + if(is_null($b)) { |
|
1896 | + return -1; |
|
1897 | + } |
|
1870 | 1898 | |
1871 | 1899 | $ret = $this->append($b); |
1872 | 1900 | unset($b); |
@@ -1877,13 +1905,15 @@ discard block |
||
1877 | 1905 | //---------------------------------------------------------------------- |
1878 | 1906 | public function appendBytes($size, $data) |
1879 | 1907 | { |
1880 | - if ($size == 0) |
|
1881 | - return 0; |
|
1908 | + if ($size == 0) { |
|
1909 | + return 0; |
|
1910 | + } |
|
1882 | 1911 | |
1883 | 1912 | $b = QRbitstream::newFromBytes($size, $data); |
1884 | 1913 | |
1885 | - if(is_null($b)) |
|
1886 | - return -1; |
|
1914 | + if(is_null($b)) { |
|
1915 | + return -1; |
|
1916 | + } |
|
1887 | 1917 | |
1888 | 1918 | $ret = $this->append($b); |
1889 | 1919 | unset($b); |
@@ -1987,8 +2017,9 @@ discard block |
||
1987 | 2017 | //---------------------------------------------------------------------- |
1988 | 2018 | public static function isdigitat($str, $pos) |
1989 | 2019 | { |
1990 | - if ($pos >= strlen($str)) |
|
1991 | - return false; |
|
2020 | + if ($pos >= strlen($str)) { |
|
2021 | + return false; |
|
2022 | + } |
|
1992 | 2023 | |
1993 | 2024 | return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9'))); |
1994 | 2025 | } |
@@ -1996,8 +2027,9 @@ discard block |
||
1996 | 2027 | //---------------------------------------------------------------------- |
1997 | 2028 | public static function isalnumat($str, $pos) |
1998 | 2029 | { |
1999 | - if ($pos >= strlen($str)) |
|
2000 | - return false; |
|
2030 | + if ($pos >= strlen($str)) { |
|
2031 | + return false; |
|
2032 | + } |
|
2001 | 2033 | |
2002 | 2034 | return (QRinput::lookAnTable(ord($str[$pos])) >= 0); |
2003 | 2035 | } |
@@ -2005,8 +2037,9 @@ discard block |
||
2005 | 2037 | //---------------------------------------------------------------------- |
2006 | 2038 | public function identifyMode($pos) |
2007 | 2039 | { |
2008 | - if ($pos >= strlen($this->dataStr)) |
|
2009 | - return QR_MODE_NUL; |
|
2040 | + if ($pos >= strlen($this->dataStr)) { |
|
2041 | + return QR_MODE_NUL; |
|
2042 | + } |
|
2010 | 2043 | |
2011 | 2044 | $c = $this->dataStr[$pos]; |
2012 | 2045 | |
@@ -2060,8 +2093,9 @@ discard block |
||
2060 | 2093 | } |
2061 | 2094 | |
2062 | 2095 | $ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr)); |
2063 | - if($ret < 0) |
|
2064 | - return -1; |
|
2096 | + if($ret < 0) { |
|
2097 | + return -1; |
|
2098 | + } |
|
2065 | 2099 | |
2066 | 2100 | return $run; |
2067 | 2101 | } |
@@ -2107,8 +2141,9 @@ discard block |
||
2107 | 2141 | } |
2108 | 2142 | |
2109 | 2143 | $ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr)); |
2110 | - if($ret < 0) |
|
2111 | - return -1; |
|
2144 | + if($ret < 0) { |
|
2145 | + return -1; |
|
2146 | + } |
|
2112 | 2147 | |
2113 | 2148 | return $run; |
2114 | 2149 | } |
@@ -2123,8 +2158,9 @@ discard block |
||
2123 | 2158 | } |
2124 | 2159 | |
2125 | 2160 | $ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr)); |
2126 | - if($ret < 0) |
|
2127 | - return -1; |
|
2161 | + if($ret < 0) { |
|
2162 | + return -1; |
|
2163 | + } |
|
2128 | 2164 | |
2129 | 2165 | return $run; |
2130 | 2166 | } |
@@ -2178,8 +2214,9 @@ discard block |
||
2178 | 2214 | $run = $p; |
2179 | 2215 | $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr)); |
2180 | 2216 | |
2181 | - if($ret < 0) |
|
2182 | - return -1; |
|
2217 | + if($ret < 0) { |
|
2218 | + return -1; |
|
2219 | + } |
|
2183 | 2220 | |
2184 | 2221 | return $run; |
2185 | 2222 | } |
@@ -2189,8 +2226,9 @@ discard block |
||
2189 | 2226 | { |
2190 | 2227 | while (strlen($this->dataStr) > 0) |
2191 | 2228 | { |
2192 | - if($this->dataStr == '') |
|
2193 | - return 0; |
|
2229 | + if($this->dataStr == '') { |
|
2230 | + return 0; |
|
2231 | + } |
|
2194 | 2232 | |
2195 | 2233 | $mode = $this->identifyMode(0); |
2196 | 2234 | |
@@ -2198,16 +2236,22 @@ discard block |
||
2198 | 2236 | case QR_MODE_NUM: $length = $this->eatNum(); break; |
2199 | 2237 | case QR_MODE_AN: $length = $this->eatAn(); break; |
2200 | 2238 | case QR_MODE_KANJI: |
2201 | - if ($hint == QR_MODE_KANJI) |
|
2202 | - $length = $this->eatKanji(); |
|
2203 | - else $length = $this->eat8(); |
|
2239 | + if ($hint == QR_MODE_KANJI) { |
|
2240 | + $length = $this->eatKanji(); |
|
2241 | + } else { |
|
2242 | + $length = $this->eat8(); |
|
2243 | + } |
|
2204 | 2244 | break; |
2205 | 2245 | default: $length = $this->eat8(); break; |
2206 | 2246 | |
2207 | 2247 | } |
2208 | 2248 | |
2209 | - if($length == 0) return 0; |
|
2210 | - if($length < 0) return -1; |
|
2249 | + if($length == 0) { |
|
2250 | + return 0; |
|
2251 | + } |
|
2252 | + if($length < 0) { |
|
2253 | + return -1; |
|
2254 | + } |
|
2211 | 2255 | |
2212 | 2256 | $this->dataStr = substr($this->dataStr, $length); |
2213 | 2257 | } |
@@ -2243,8 +2287,9 @@ discard block |
||
2243 | 2287 | |
2244 | 2288 | $split = new QRsplit($string, $input, $modeHint); |
2245 | 2289 | |
2246 | - if(!$casesensitive) |
|
2247 | - $split->toUpper(); |
|
2290 | + if(!$casesensitive) { |
|
2291 | + $split->toUpper(); |
|
2292 | + } |
|
2248 | 2293 | |
2249 | 2294 | return $split->splitString(); |
2250 | 2295 | } |
@@ -2321,11 +2366,23 @@ discard block |
||
2321 | 2366 | $rs = null; |
2322 | 2367 | |
2323 | 2368 | // Check parameter ranges |
2324 | - if($symsize < 0 || $symsize > 8) return $rs; |
|
2325 | - if($fcr < 0 || $fcr >= (1<<$symsize)) return $rs; |
|
2326 | - if($prim <= 0 || $prim >= (1<<$symsize)) return $rs; |
|
2327 | - if($nroots < 0 || $nroots >= (1<<$symsize)) return $rs; // Can't have more roots than symbol values! |
|
2328 | - if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) return $rs; // Too much padding |
|
2369 | + if($symsize < 0 || $symsize > 8) { |
|
2370 | + return $rs; |
|
2371 | + } |
|
2372 | + if($fcr < 0 || $fcr >= (1<<$symsize)) { |
|
2373 | + return $rs; |
|
2374 | + } |
|
2375 | + if($prim <= 0 || $prim >= (1<<$symsize)) { |
|
2376 | + return $rs; |
|
2377 | + } |
|
2378 | + if($nroots < 0 || $nroots >= (1<<$symsize)) { |
|
2379 | + return $rs; |
|
2380 | + } |
|
2381 | + // Can't have more roots than symbol values! |
|
2382 | + if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) { |
|
2383 | + return $rs; |
|
2384 | + } |
|
2385 | + // Too much padding |
|
2329 | 2386 | |
2330 | 2387 | $rs = new QRrsItem(); |
2331 | 2388 | $rs->mm = $symsize; |
@@ -2391,8 +2448,9 @@ discard block |
||
2391 | 2448 | } |
2392 | 2449 | |
2393 | 2450 | // convert rs->genpoly[] to index form for quicker encoding |
2394 | - for ($i = 0; $i <= $nroots; $i++) |
|
2395 | - $rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]]; |
|
2451 | + for ($i = 0; $i <= $nroots; $i++) { |
|
2452 | + $rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]]; |
|
2453 | + } |
|
2396 | 2454 | |
2397 | 2455 | return $rs; |
2398 | 2456 | } |
@@ -2450,12 +2508,24 @@ discard block |
||
2450 | 2508 | public static function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) |
2451 | 2509 | { |
2452 | 2510 | foreach(self::$items as $rs) { |
2453 | - if($rs->pad != $pad) continue; |
|
2454 | - if($rs->nroots != $nroots) continue; |
|
2455 | - if($rs->mm != $symsize) continue; |
|
2456 | - if($rs->gfpoly != $gfpoly) continue; |
|
2457 | - if($rs->fcr != $fcr) continue; |
|
2458 | - if($rs->prim != $prim) continue; |
|
2511 | + if($rs->pad != $pad) { |
|
2512 | + continue; |
|
2513 | + } |
|
2514 | + if($rs->nroots != $nroots) { |
|
2515 | + continue; |
|
2516 | + } |
|
2517 | + if($rs->mm != $symsize) { |
|
2518 | + continue; |
|
2519 | + } |
|
2520 | + if($rs->gfpoly != $gfpoly) { |
|
2521 | + continue; |
|
2522 | + } |
|
2523 | + if($rs->fcr != $fcr) { |
|
2524 | + continue; |
|
2525 | + } |
|
2526 | + if($rs->prim != $prim) { |
|
2527 | + continue; |
|
2528 | + } |
|
2459 | 2529 | |
2460 | 2530 | return $rs; |
2461 | 2531 | } |
@@ -2594,8 +2664,9 @@ discard block |
||
2594 | 2664 | { |
2595 | 2665 | $codeArr = []; |
2596 | 2666 | |
2597 | - foreach ($bitFrame as $line) |
|
2598 | - $codeArr[] = join('', $line); |
|
2667 | + foreach ($bitFrame as $line) { |
|
2668 | + $codeArr[] = join('', $line); |
|
2669 | + } |
|
2599 | 2670 | |
2600 | 2671 | return gzcompress(join("\n", $codeArr), 9); |
2601 | 2672 | } |
@@ -2606,8 +2677,9 @@ discard block |
||
2606 | 2677 | $codeArr = []; |
2607 | 2678 | |
2608 | 2679 | $codeLines = explode("\n", gzuncompress($code)); |
2609 | - foreach ($codeLines as $line) |
|
2610 | - $codeArr[] = str_split($line); |
|
2680 | + foreach ($codeLines as $line) { |
|
2681 | + $codeArr[] = str_split($line); |
|
2682 | + } |
|
2611 | 2683 | |
2612 | 2684 | return $codeArr; |
2613 | 2685 | } |
@@ -2625,16 +2697,18 @@ discard block |
||
2625 | 2697 | $bitMask = self::unserial(file_get_contents($fileName)); |
2626 | 2698 | } else { |
2627 | 2699 | $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d); |
2628 | - if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo)) |
|
2629 | - mkdir(QR_CACHE_DIR.'mask_'.$maskNo); |
|
2700 | + if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo)) { |
|
2701 | + mkdir(QR_CACHE_DIR.'mask_'.$maskNo); |
|
2702 | + } |
|
2630 | 2703 | file_put_contents($fileName, self::serial($bitMask)); |
2631 | 2704 | } |
2632 | 2705 | } else { |
2633 | 2706 | $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d); |
2634 | 2707 | } |
2635 | 2708 | |
2636 | - if ($maskGenOnly) |
|
2637 | - return; |
|
2709 | + if ($maskGenOnly) { |
|
2710 | + return; |
|
2711 | + } |
|
2638 | 2712 | |
2639 | 2713 | $d = $s; |
2640 | 2714 | |
@@ -2701,8 +2775,9 @@ discard block |
||
2701 | 2775 | |
2702 | 2776 | $frameY = $frame[$y]; |
2703 | 2777 | |
2704 | - if ($y>0) |
|
2705 | - $frameYM = $frame[$y-1]; |
|
2778 | + if ($y>0) { |
|
2779 | + $frameYM = $frame[$y-1]; |
|
2780 | + } |
|
2706 | 2781 | |
2707 | 2782 | for($x=0; $x<$width; $x++) { |
2708 | 2783 | if(($x > 0) && ($y > 0)) { |
@@ -2915,14 +2990,17 @@ discard block |
||
2915 | 2990 | $blockNo++; |
2916 | 2991 | } |
2917 | 2992 | |
2918 | - if(QRspec::rsBlockNum2($spec) == 0) |
|
2919 | - return 0; |
|
2993 | + if(QRspec::rsBlockNum2($spec) == 0) { |
|
2994 | + return 0; |
|
2995 | + } |
|
2920 | 2996 | |
2921 | 2997 | $dl = QRspec::rsDataCodes2($spec); |
2922 | 2998 | $el = QRspec::rsEccCodes2($spec); |
2923 | 2999 | $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el); |
2924 | 3000 | |
2925 | - if($rs == NULL) return -1; |
|
3001 | + if($rs == NULL) { |
|
3002 | + return -1; |
|
3003 | + } |
|
2926 | 3004 | |
2927 | 3005 | for($i=0; $i<QRspec::rsBlockNum2($spec); $i++) { |
2928 | 3006 | $ecc = array_slice($this->ecccode,$eccPos); |
@@ -3060,7 +3138,9 @@ discard block |
||
3060 | 3138 | } |
3061 | 3139 | |
3062 | 3140 | $input = new QRinput($version, $level); |
3063 | - if($input == NULL) return NULL; |
|
3141 | + if($input == NULL) { |
|
3142 | + return NULL; |
|
3143 | + } |
|
3064 | 3144 | |
3065 | 3145 | $ret = $input->append($input, QR_MODE_8, strlen($string), str_split($string)); |
3066 | 3146 | if($ret < 0) { |
@@ -3080,7 +3160,9 @@ discard block |
||
3080 | 3160 | } |
3081 | 3161 | |
3082 | 3162 | $input = new QRinput($version, $level); |
3083 | - if($input == NULL) return NULL; |
|
3163 | + if($input == NULL) { |
|
3164 | + return NULL; |
|
3165 | + } |
|
3084 | 3166 | |
3085 | 3167 | $ret = QRsplit::splitStringToQRinput($string, $input, $hint, $casesensitive); |
3086 | 3168 | if($ret < 0) { |
@@ -3190,7 +3272,9 @@ discard block |
||
3190 | 3272 | } |
3191 | 3273 | } |
3192 | 3274 | } |
3193 | - if($x < 0 || $y < 0) return null; |
|
3275 | + if($x < 0 || $y < 0) { |
|
3276 | + return null; |
|
3277 | + } |
|
3194 | 3278 | |
3195 | 3279 | $this->x = $x; |
3196 | 3280 | $this->y = $y; |
@@ -3297,8 +3381,9 @@ discard block |
||
3297 | 3381 | $err = ob_get_contents(); |
3298 | 3382 | ob_end_clean(); |
3299 | 3383 | |
3300 | - if ($err != '') |
|
3301 | - QRtools::log($outfile, $err); |
|
3384 | + if ($err != '') { |
|
3385 | + QRtools::log($outfile, $err); |
|
3386 | + } |
|
3302 | 3387 | |
3303 | 3388 | $maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin)); |
3304 | 3389 |
@@ -957,6 +957,11 @@ discard block |
||
957 | 957 | return $anon_id; |
958 | 958 | } |
959 | 959 | |
960 | + /** |
|
961 | + * @param string $inner_user |
|
962 | + * @param string $password |
|
963 | + * @param string $clientcertdata |
|
964 | + */ |
|
960 | 965 | public function UDP_login($probeindex, $eaptype, $inner_user, $password, $outer_user = '', $opname_check = TRUE, $frag = TRUE, $clientcertdata = NULL) { |
961 | 966 | if (!isset(Config::$RADIUSTESTS['UDP-hosts'][$probeindex])) { |
962 | 967 | $this->UDP_reachability_executed = RETVAL_NOTCONFIGURED; |
@@ -1478,10 +1483,8 @@ discard block |
||
1478 | 1483 | /** |
1479 | 1484 | * This function executes openssl s_client command |
1480 | 1485 | * |
1481 | - * @param string $key points NAPTR_hostname_records |
|
1482 | - * @param string $bracketaddr IP address |
|
1483 | - * @param int $port |
|
1484 | - * @param string $arg arguments to add to the openssl command |
|
1486 | + * @param string $arg arguments to add to the openssl command |
|
1487 | + * @param string $host |
|
1485 | 1488 | * @return string result of oenssl s_client ... |
1486 | 1489 | */ |
1487 | 1490 | function openssl_s_client($host, $arg, &$testresults) { |
@@ -274,10 +274,11 @@ discard block |
||
274 | 274 | ]; |
275 | 275 | $this->errorlist = []; |
276 | 276 | $this->initialise_errors(); |
277 | - if ($profile_id !== 0) |
|
278 | - $this->profile = new Profile($profile_id); |
|
279 | - else |
|
280 | - $this->profile = FALSE; |
|
277 | + if ($profile_id !== 0) { |
|
278 | + $this->profile = new Profile($profile_id); |
|
279 | + } else { |
|
280 | + $this->profile = FALSE; |
|
281 | + } |
|
281 | 282 | |
282 | 283 | CAT::set_locale($oldlocale); |
283 | 284 | } |
@@ -303,8 +304,9 @@ discard block |
||
303 | 304 | if ($NAPTRs !== FALSE && count($NAPTRs) > 0) { |
304 | 305 | $NAPTRs_consortium = []; |
305 | 306 | foreach ($NAPTRs as $naptr) { |
306 | - if ($naptr["services"] == Config::$RADIUSTESTS['TLS-discoverytag']) |
|
307 | - $NAPTRs_consortium[] = $naptr; |
|
307 | + if ($naptr["services"] == Config::$RADIUSTESTS['TLS-discoverytag']) { |
|
308 | + $NAPTRs_consortium[] = $naptr; |
|
309 | + } |
|
308 | 310 | } |
309 | 311 | |
310 | 312 | if (count($NAPTRs_consortium) > 0) { |
@@ -333,8 +335,9 @@ discard block |
||
333 | 335 | */ |
334 | 336 | public function NAPTR_compliance() { |
335 | 337 | // did we query DNS for the NAPTRs yet? If not, do so now. |
336 | - if ($this->NAPTR_executed === FALSE) |
|
337 | - $this->NAPTR(); |
|
338 | + if ($this->NAPTR_executed === FALSE) { |
|
339 | + $this->NAPTR(); |
|
340 | + } |
|
338 | 341 | // if the NAPTR checks aren't configured, tell the caller |
339 | 342 | if ($this->NAPTR_executed === RETVAL_NOTCONFIGURED) { |
340 | 343 | $this->NAPTR_compliance_executed = RETVAL_NOTCONFIGURED; |
@@ -351,11 +354,13 @@ discard block |
||
351 | 354 | if (Config::$CONSORTIUM['name'] == "eduroam") { // SW: APPROVED |
352 | 355 | foreach ($this->NAPTR_records as $edupointer) { |
353 | 356 | // must be "s" type for SRV |
354 | - if ($edupointer["flags"] != "s" && $edupointer["flags"] != "S") |
|
355 | - $format_errors[] = ["TYPE" => "NAPTR-FLAG", "TARGET" => $edupointer['flag']]; |
|
357 | + if ($edupointer["flags"] != "s" && $edupointer["flags"] != "S") { |
|
358 | + $format_errors[] = ["TYPE" => "NAPTR-FLAG", "TARGET" => $edupointer['flag']]; |
|
359 | + } |
|
356 | 360 | // no regex |
357 | - if ($edupointer["regex"] != "") |
|
358 | - $format_errors[] = ["TYPE" => "NAPTR-REGEX", "TARGET" => $edupointer['regex']]; |
|
361 | + if ($edupointer["regex"] != "") { |
|
362 | + $format_errors[] = ["TYPE" => "NAPTR-REGEX", "TARGET" => $edupointer['regex']]; |
|
363 | + } |
|
359 | 364 | } |
360 | 365 | } |
361 | 366 | if (count($format_errors) > 0) { |
@@ -665,8 +670,9 @@ discard block |
||
665 | 670 | function NAPTR_SRV() { |
666 | 671 | // see if preceding checks have been run, and run them if not |
667 | 672 | // compliance check will cascade NAPTR check on its own |
668 | - if ($this->NAPTR_compliance_executed === FALSE) |
|
669 | - $this->NAPTR_compliance(); |
|
673 | + if ($this->NAPTR_compliance_executed === FALSE) { |
|
674 | + $this->NAPTR_compliance(); |
|
675 | + } |
|
670 | 676 | // we only run the SRV checks if all records are compliant and more than one relevant NAPTR exists |
671 | 677 | if ($this->NAPTR_executed <= 0 || $this->NAPTR_compliance_executed == RETVAL_INVALID) { |
672 | 678 | $this->NAPTR_SRV_executed = RETVAL_SKIPPED; |
@@ -680,9 +686,10 @@ discard block |
||
680 | 686 | $temp_result = dns_get_record($edupointer["replacement"], DNS_SRV); |
681 | 687 | if ($temp_result === FALSE || count($temp_result) == 0) { |
682 | 688 | $SRV_errors[] = ["TYPE" => "SRV_NOT_RESOLVING", "TARGET" => $edupointer['replacement']]; |
683 | - } else |
|
684 | - foreach ($temp_result as $res) |
|
689 | + } else { |
|
690 | + foreach ($temp_result as $res) |
|
685 | 691 | $SRV_targets[] = ["hostname" => $res["target"], "port" => $res["port"]]; |
692 | + } |
|
686 | 693 | } |
687 | 694 | $this->NAPTR_SRV_records = $SRV_targets; |
688 | 695 | if (count($SRV_errors) > 0) { |
@@ -697,8 +704,9 @@ discard block |
||
697 | 704 | function NAPTR_hostnames() { |
698 | 705 | // make sure the previous tests have been run before we go on |
699 | 706 | // preceeding tests will cascade automatically if needed |
700 | - if ($this->NAPTR_SRV_executed === FALSE) |
|
701 | - $this->NAPTR_SRV(); |
|
707 | + if ($this->NAPTR_SRV_executed === FALSE) { |
|
708 | + $this->NAPTR_SRV(); |
|
709 | + } |
|
702 | 710 | // if previous are SKIPPED, skip this one, too |
703 | 711 | if ($this->NAPTR_SRV_executed == RETVAL_SKIPPED) { |
704 | 712 | $this->NAPTR_hostname_executed = RETVAL_SKIPPED; |
@@ -717,12 +725,14 @@ discard block |
||
717 | 725 | $host_resolution = array_merge($host_resolution_6, $host_resolution_4); |
718 | 726 | if ($host_resolution === FALSE || count($host_resolution) == 0) { |
719 | 727 | $resolution_errors[] = ["TYPE" => "HOST_NO_ADDRESS", "TARGET" => $server['hostname']]; |
720 | - } else |
|
721 | - foreach ($host_resolution as $address) |
|
728 | + } else { |
|
729 | + foreach ($host_resolution as $address) |
|
722 | 730 | if (isset($address["ip"])) |
723 | 731 | $ip_addresses[] = ["family" => "IPv4", "IP" => $address["ip"], "port" => $server["port"], "status" => ""]; |
724 | - else |
|
725 | - $ip_addresses[] = ["family" => "IPv6", "IP" => $address["ipv6"], "port" => $server["port"], "status" => ""]; |
|
732 | + } |
|
733 | + else { |
|
734 | + $ip_addresses[] = ["family" => "IPv6", "IP" => $address["ipv6"], "port" => $server["port"], "status" => ""]; |
|
735 | + } |
|
726 | 736 | } |
727 | 737 | |
728 | 738 | $this->NAPTR_hostname_records = $ip_addresses; |
@@ -761,38 +771,43 @@ discard block |
||
761 | 771 | // check for wildcards |
762 | 772 | |
763 | 773 | if (isset($servercert['full_details']['subject']['CN'])) { |
764 | - if (is_array($servercert['full_details']['subject']['CN'])) |
|
765 | - $CN = $servercert['full_details']['subject']['CN']; |
|
766 | - else |
|
767 | - $CN = [$servercert['full_details']['subject']['CN']]; |
|
768 | - } |
|
769 | - else { |
|
774 | + if (is_array($servercert['full_details']['subject']['CN'])) { |
|
775 | + $CN = $servercert['full_details']['subject']['CN']; |
|
776 | + } else { |
|
777 | + $CN = [$servercert['full_details']['subject']['CN']]; |
|
778 | + } |
|
779 | + } else { |
|
770 | 780 | $CN = [""]; |
771 | 781 | } |
772 | 782 | |
773 | - if (isset($servercert['full_details']['extensions']) && isset($servercert['full_details']['extensions']['subjectAltName'])) |
|
774 | - $sAN_list = explode(", ", $servercert['full_details']['extensions']['subjectAltName']); |
|
775 | - else |
|
776 | - $sAN_list = []; |
|
783 | + if (isset($servercert['full_details']['extensions']) && isset($servercert['full_details']['extensions']['subjectAltName'])) { |
|
784 | + $sAN_list = explode(", ", $servercert['full_details']['extensions']['subjectAltName']); |
|
785 | + } else { |
|
786 | + $sAN_list = []; |
|
787 | + } |
|
777 | 788 | |
778 | 789 | $sAN_DNS = []; |
779 | - foreach ($sAN_list as $san_name) |
|
780 | - if (preg_match("/^DNS:/", $san_name)) |
|
790 | + foreach ($sAN_list as $san_name) { |
|
791 | + if (preg_match("/^DNS:/", $san_name)) |
|
781 | 792 | $sAN_DNS[] = substr($san_name, 4); |
793 | + } |
|
782 | 794 | |
783 | 795 | $allnames = array_unique(array_merge($CN, $sAN_DNS)); |
784 | 796 | |
785 | - if (preg_match("/\*/", implode($allnames))) |
|
786 | - $returnarray[] = CERTPROB_WILDCARD_IN_NAME; |
|
797 | + if (preg_match("/\*/", implode($allnames))) { |
|
798 | + $returnarray[] = CERTPROB_WILDCARD_IN_NAME; |
|
799 | + } |
|
787 | 800 | |
788 | 801 | // is there more than one CN? None or one is okay, more is asking for trouble. |
789 | - if (count($CN) > 1) |
|
790 | - $returnarray[] = CERTPROB_MULTIPLE_CN; |
|
802 | + if (count($CN) > 1) { |
|
803 | + $returnarray[] = CERTPROB_MULTIPLE_CN; |
|
804 | + } |
|
791 | 805 | |
792 | 806 | // check for real hostname |
793 | 807 | foreach ($allnames as $onename) { |
794 | - if ($onename != "" && filter_var("foo@" . idn_to_ascii($onename), FILTER_VALIDATE_EMAIL) === FALSE) |
|
795 | - $returnarray[] = CERTPROB_NOT_A_HOSTNAME; |
|
808 | + if ($onename != "" && filter_var("foo@" . idn_to_ascii($onename), FILTER_VALIDATE_EMAIL) === FALSE) { |
|
809 | + $returnarray[] = CERTPROB_NOT_A_HOSTNAME; |
|
810 | + } |
|
796 | 811 | } |
797 | 812 | $servercert['incoming_server_names'] = $allnames; |
798 | 813 | $servercert['sAN_DNS'] = $sAN_DNS; |
@@ -816,16 +831,19 @@ discard block |
||
816 | 831 | if ($intermediate_ca['basicconstraints_set'] == 0) { |
817 | 832 | $returnarray[] = CERTPROB_NO_BASICCONSTRAINTS; |
818 | 833 | } |
819 | - if ($intermediate_ca['full_details']['public_key_length'] < 1024) |
|
820 | - $returnarray[] = CERTPROB_LOW_KEY_LENGTH; |
|
834 | + if ($intermediate_ca['full_details']['public_key_length'] < 1024) { |
|
835 | + $returnarray[] = CERTPROB_LOW_KEY_LENGTH; |
|
836 | + } |
|
821 | 837 | $from = $intermediate_ca['full_details']['validFrom_time_t']; |
822 | 838 | $now = time(); |
823 | 839 | $to = $intermediate_ca['full_details']['validTo_time_t']; |
824 | - if ($from > $now || $to < $now) |
|
825 | - $returnarray[] = CERTPROB_OUTSIDE_VALIDITY_PERIOD; |
|
840 | + if ($from > $now || $to < $now) { |
|
841 | + $returnarray[] = CERTPROB_OUTSIDE_VALIDITY_PERIOD; |
|
842 | + } |
|
826 | 843 | $add_cert_crl_result = $this->add_cert_crl($intermediate_ca); |
827 | - if ($add_cert_crl_result !== 0 && $server_cert) |
|
828 | - $returnarray[] = $add_cert_crl_result; |
|
844 | + if ($add_cert_crl_result !== 0 && $server_cert) { |
|
845 | + $returnarray[] = $add_cert_crl_result; |
|
846 | + } |
|
829 | 847 | |
830 | 848 | return $returnarray; |
831 | 849 | } |
@@ -869,8 +887,9 @@ discard block |
||
869 | 887 | $returnresult = CERTPROB_NO_CDP_HTTP; |
870 | 888 | } else { // first and second sub-match is the full URL... check it |
871 | 889 | $crlcontent = downloadFile($crl_url[1] . $crl_url[2]); |
872 | - if ($crlcontent === FALSE) |
|
873 | - $returnresult = CERTPROB_NO_CRL_AT_CDP_URL; |
|
890 | + if ($crlcontent === FALSE) { |
|
891 | + $returnresult = CERTPROB_NO_CRL_AT_CDP_URL; |
|
892 | + } |
|
874 | 893 | $begin_crl = strpos($crlcontent, "-----BEGIN X509 CRL-----"); |
875 | 894 | if ($begin_crl === FALSE) { |
876 | 895 | $pem = chunk_split(base64_encode($crlcontent), 64, "\n"); |
@@ -1074,11 +1093,16 @@ discard block |
||
1074 | 1093 | " -c ./udp_login_test.conf" . |
1075 | 1094 | " -M 22:44:66:CA:20:" . sprintf("%02d", $probeindex) . " " . |
1076 | 1095 | " -t " . Config::$RADIUSTESTS['UDP-hosts'][$probeindex]['timeout'] . " "; |
1077 | - if ($opname_check) |
|
1078 | - $cmdline .= '-N126:s:"1cat.eduroam.org" '; |
|
1079 | - if ($frag) |
|
1080 | - for ($i = 0; $i < 6; $i++) // 6 x 250 bytes means UDP fragmentation will occur - good! |
|
1096 | + if ($opname_check) { |
|
1097 | + $cmdline .= '-N126:s:"1cat.eduroam.org" '; |
|
1098 | + } |
|
1099 | + if ($frag) { |
|
1100 | + for ($i = 0; |
|
1101 | + } |
|
1102 | + $i < 6; $i++) { |
|
1103 | + // 6 x 250 bytes means UDP fragmentation will occur - good! |
|
1081 | 1104 | $cmdline .= '-N26:x:0000625A0BF961616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161616161 '; |
1105 | + } |
|
1082 | 1106 | |
1083 | 1107 | debug(4, "Shallow reachability check cmdline: $cmdline\n"); |
1084 | 1108 | debug(4, "Shallow reachability check config: $tmp_dir\n$log_config\n"); |
@@ -1087,8 +1111,9 @@ discard block |
||
1087 | 1111 | $time_stop = microtime(true); |
1088 | 1112 | debug(5, print_r($this->redact($password, $packetflow_orig), TRUE)); |
1089 | 1113 | $packetflow = $this->filter_packettype($packetflow_orig); |
1090 | - if ($packetflow[count($packetflow) - 1] == 11 && $this->check_mschap_691_r($packetflow_orig)) |
|
1091 | - $packetflow[count($packetflow) - 1] = 3; |
|
1114 | + if ($packetflow[count($packetflow) - 1] == 11 && $this->check_mschap_691_r($packetflow_orig)) { |
|
1115 | + $packetflow[count($packetflow) - 1] = 3; |
|
1116 | + } |
|
1092 | 1117 | debug(5, "Packetflow: " . print_r($packetflow, TRUE)); |
1093 | 1118 | $testresults['time_millisec'] = ($time_stop - $time_start) * 1000; |
1094 | 1119 | $packetcount = array_count_values($packetflow); |
@@ -1099,10 +1124,11 @@ discard block |
||
1099 | 1124 | $accepts = (isset($packetcount[2]) ? $packetcount[2] : 0); |
1100 | 1125 | $rejects = (isset($packetcount[3]) ? $packetcount[3] : 0); |
1101 | 1126 | $challenges = (isset($packetcount[11]) ? $packetcount[11] : 0); |
1102 | - if ($reqs - $accepts - $rejects - $challenges != 0 || $accepts > 1 || $rejects > 1) |
|
1103 | - $testresults['packetflow_sane'] = FALSE; |
|
1104 | - else |
|
1105 | - $testresults['packetflow_sane'] = TRUE; |
|
1127 | + if ($reqs - $accepts - $rejects - $challenges != 0 || $accepts > 1 || $rejects > 1) { |
|
1128 | + $testresults['packetflow_sane'] = FALSE; |
|
1129 | + } else { |
|
1130 | + $testresults['packetflow_sane'] = TRUE; |
|
1131 | + } |
|
1106 | 1132 | |
1107 | 1133 | // calculate the main return values that this test yielded |
1108 | 1134 | |
@@ -1127,8 +1153,9 @@ discard block |
||
1127 | 1153 | |
1128 | 1154 | if ($finalretval == RETVAL_CONVERSATION_REJECT) { |
1129 | 1155 | $ackedmethod = $this->check_conversation_eap_method_ack($packetflow_orig); |
1130 | - if (!$ackedmethod) |
|
1131 | - $testresults['cert_oddities'][] = CERTPROB_NO_COMMON_EAP_METHOD; |
|
1156 | + if (!$ackedmethod) { |
|
1157 | + $testresults['cert_oddities'][] = CERTPROB_NO_COMMON_EAP_METHOD; |
|
1158 | + } |
|
1132 | 1159 | }; |
1133 | 1160 | |
1134 | 1161 | |
@@ -1189,8 +1216,9 @@ discard block |
||
1189 | 1216 | |
1190 | 1217 | foreach ($eap_certarray as $cert_pem) { |
1191 | 1218 | $cert = $x509->processCertificate($cert_pem); |
1192 | - if ($cert == FALSE) |
|
1193 | - continue; |
|
1219 | + if ($cert == FALSE) { |
|
1220 | + continue; |
|
1221 | + } |
|
1194 | 1222 | // consider the certificate a server cert |
1195 | 1223 | // a) if it is not a CA and is not a self-signed root |
1196 | 1224 | // b) if it is a CA, and self-signed, and it is the only cert in |
@@ -1236,12 +1264,15 @@ discard block |
||
1236 | 1264 | $testresults['certdata'][] = $cert['full_details']; |
1237 | 1265 | } |
1238 | 1266 | fclose($server_file); |
1239 | - if ($number_root > 0 && !$totally_selfsigned) |
|
1240 | - $testresults['cert_oddities'][] = CERTPROB_ROOT_INCLUDED; |
|
1241 | - if ($number_server > 1) |
|
1242 | - $testresults['cert_oddities'][] = CERTPROB_TOO_MANY_SERVER_CERTS; |
|
1243 | - if ($number_server == 0) |
|
1244 | - $testresults['cert_oddities'][] = CERTPROB_NO_SERVER_CERT; |
|
1267 | + if ($number_root > 0 && !$totally_selfsigned) { |
|
1268 | + $testresults['cert_oddities'][] = CERTPROB_ROOT_INCLUDED; |
|
1269 | + } |
|
1270 | + if ($number_server > 1) { |
|
1271 | + $testresults['cert_oddities'][] = CERTPROB_TOO_MANY_SERVER_CERTS; |
|
1272 | + } |
|
1273 | + if ($number_server == 0) { |
|
1274 | + $testresults['cert_oddities'][] = CERTPROB_NO_SERVER_CERT; |
|
1275 | + } |
|
1245 | 1276 | // check server cert properties |
1246 | 1277 | if ($number_server > 0) { |
1247 | 1278 | $testresults['cert_oddities'] = array_merge($testresults['cert_oddities'], $this->property_check_servercert($servercert)); |
@@ -1287,8 +1318,9 @@ discard block |
||
1287 | 1318 | } |
1288 | 1319 | } |
1289 | 1320 | } |
1290 | - if ($number_server > 0) |
|
1291 | - debug(4, "This is the server certificate, with CRL content if applicable: " . print_r($servercert, true)); |
|
1321 | + if ($number_server > 0) { |
|
1322 | + debug(4, "This is the server certificate, with CRL content if applicable: " . print_r($servercert, true)); |
|
1323 | + } |
|
1292 | 1324 | $checkstring = ""; |
1293 | 1325 | if (isset($servercert['CRL']) && isset($servercert['CRL'][0])) { |
1294 | 1326 | debug(4, "got a server CRL; adding them to the chain checks. (Remember: checking end-entity cert only, not the whole chain"); |
@@ -1365,8 +1397,9 @@ discard block |
||
1365 | 1397 | // WARN if the configured name is only in either CN or sAN:DNS |
1366 | 1398 | $confnames = $my_profile->getAttributes("eap:server_name"); |
1367 | 1399 | $expected_names = []; |
1368 | - foreach ($confnames as $tuple) |
|
1369 | - $expected_names[] = $tuple['value']; |
|
1400 | + foreach ($confnames as $tuple) { |
|
1401 | + $expected_names[] = $tuple['value']; |
|
1402 | + } |
|
1370 | 1403 | |
1371 | 1404 | // Strategy for checks: we are TOTALLY happy if any one of the |
1372 | 1405 | // configured names shows up in both the CN and a sAN |
@@ -1437,9 +1470,10 @@ discard block |
||
1437 | 1470 | function property_check_policy($cert) { |
1438 | 1471 | $oids = []; |
1439 | 1472 | if ($cert['extensions']['certificatePolicies']) { |
1440 | - foreach (Config::$RADIUSTESTS['TLS-acceptableOIDs'] as $key => $oid) |
|
1441 | - if (preg_match("/Policy: $oid/", $cert['extensions']['certificatePolicies'])) |
|
1473 | + foreach (Config::$RADIUSTESTS['TLS-acceptableOIDs'] as $key => $oid) { |
|
1474 | + if (preg_match("/Policy: $oid/", $cert['extensions']['certificatePolicies'])) |
|
1442 | 1475 | $oids[$key] = $oid; |
1476 | + } |
|
1443 | 1477 | } |
1444 | 1478 | return $oids; |
1445 | 1479 | } |
@@ -1452,12 +1486,14 @@ discard block |
||
1452 | 1486 | */ |
1453 | 1487 | function property_certificate_get_issuer($cert) { |
1454 | 1488 | $issuer = ''; |
1455 | - foreach ($cert['issuer'] as $key => $val) |
|
1456 | - if (is_array($val)) |
|
1489 | + foreach ($cert['issuer'] as $key => $val) { |
|
1490 | + if (is_array($val)) |
|
1457 | 1491 | foreach ($val as $v) |
1458 | 1492 | $issuer .= "/$key=$v"; |
1459 | - else |
|
1460 | - $issuer .= "/$key=$val"; |
|
1493 | + } |
|
1494 | + else { |
|
1495 | + $issuer .= "/$key=$val"; |
|
1496 | + } |
|
1461 | 1497 | return $issuer; |
1462 | 1498 | } |
1463 | 1499 | |
@@ -1532,8 +1568,9 @@ discard block |
||
1532 | 1568 | } |
1533 | 1569 | $oids = $this->property_check_policy($data); |
1534 | 1570 | if (!empty($oids)) { |
1535 | - foreach ($oids as $k => $o) |
|
1536 | - $testresults[$host]['certdata']['extensions']['policyoid'][] = " $o ($k)"; |
|
1571 | + foreach ($oids as $k => $o) { |
|
1572 | + $testresults[$host]['certdata']['extensions']['policyoid'][] = " $o ($k)"; |
|
1573 | + } |
|
1537 | 1574 | } |
1538 | 1575 | if (($crl = $this->property_certificate_get_field($data, 'crlDistributionPoints'))) { |
1539 | 1576 | $testresults[$host]['certdata']['extensions']['crlDistributionPoint'] = $crl; |
@@ -1547,23 +1584,24 @@ discard block |
||
1547 | 1584 | $ret = $testresults[$host]['ca'][$type]['certificate'][$k]['returncode']; |
1548 | 1585 | $output = implode($opensslbabble); |
1549 | 1586 | $unknownca = 0; |
1550 | - if ($ret == 0) |
|
1551 | - $testresults[$host]['ca'][$type]['certificate'][$k]['connected'] = 1; |
|
1552 | - else { |
|
1587 | + if ($ret == 0) { |
|
1588 | + $testresults[$host]['ca'][$type]['certificate'][$k]['connected'] = 1; |
|
1589 | + } else { |
|
1553 | 1590 | $testresults[$host]['ca'][$type]['certificate'][$k]['connected'] = 0; |
1554 | 1591 | if (preg_match('/connect: Connection refused/', implode($opensslbabble))) { |
1555 | 1592 | $testresults[$host]['ca'][$type]['certificate'][$k]['returncode'] = RETVAL_CONNECTION_REFUSED; |
1556 | - } elseif (preg_match('/sslv3 alert certificate expired/', $output)) |
|
1557 | - $res_comment = _("certificate expired"); |
|
1558 | - elseif (preg_match('/sslv3 alert certificate revoked/', $output)) |
|
1559 | - $res_comment = _("certificate was revoked"); |
|
1560 | - elseif (preg_match('/SSL alert number 46/', $output)) |
|
1561 | - $res_comment = _("bad policy"); |
|
1562 | - elseif (preg_match('/tlsv1 alert unknown ca/', $output)) { |
|
1593 | + } elseif (preg_match('/sslv3 alert certificate expired/', $output)) { |
|
1594 | + $res_comment = _("certificate expired"); |
|
1595 | + } elseif (preg_match('/sslv3 alert certificate revoked/', $output)) { |
|
1596 | + $res_comment = _("certificate was revoked"); |
|
1597 | + } elseif (preg_match('/SSL alert number 46/', $output)) { |
|
1598 | + $res_comment = _("bad policy"); |
|
1599 | + } elseif (preg_match('/tlsv1 alert unknown ca/', $output)) { |
|
1563 | 1600 | $res_comment = _("unknown authority"); |
1564 | 1601 | $testresults[$host]['ca'][$type]['certificate'][$k]['reason'] = CERTPROB_UNKNOWN_CA; |
1565 | - } else |
|
1566 | - $res_comment = _("unknown authority or no certificate policy or another problem"); |
|
1602 | + } else { |
|
1603 | + $res_comment = _("unknown authority or no certificate policy or another problem"); |
|
1604 | + } |
|
1567 | 1605 | $testresults[$host]['ca'][$type]['certificate'][$k]['resultcomment'] = $res_comment; |
1568 | 1606 | } |
1569 | 1607 | break; |
@@ -1583,8 +1621,9 @@ discard block |
||
1583 | 1621 | $res = RETVAL_OK; |
1584 | 1622 | /* if (preg_match("/\[/", $host)) |
1585 | 1623 | return RETVAL_INVALID; */ |
1586 | - if (!isset($this->TLS_CA_checks_result[$host])) |
|
1587 | - $this->TLS_CA_checks_result[$host] = []; |
|
1624 | + if (!isset($this->TLS_CA_checks_result[$host])) { |
|
1625 | + $this->TLS_CA_checks_result[$host] = []; |
|
1626 | + } |
|
1588 | 1627 | $opensslbabble = $this->openssl_s_client($host, '', $this->TLS_CA_checks_result[$host]); |
1589 | 1628 | fputs($f, serialize($this->TLS_CA_checks_result) . "\n"); |
1590 | 1629 | $res = $this->openssl_result($host, 'capath', $opensslbabble, $this->TLS_CA_checks_result); |
@@ -1600,8 +1639,9 @@ discard block |
||
1600 | 1639 | public function TLS_clients_side_check($host) { |
1601 | 1640 | $res = RETVAL_OK; |
1602 | 1641 | if (is_array(Config::$RADIUSTESTS['TLS-clientcerts']) && count(Config::$RADIUSTESTS['TLS-clientcerts']) > 0) { |
1603 | - if (preg_match("/\[/", $host)) |
|
1604 | - return RETVAL_INVALID; |
|
1642 | + if (preg_match("/\[/", $host)) { |
|
1643 | + return RETVAL_INVALID; |
|
1644 | + } |
|
1605 | 1645 | foreach (Config::$RADIUSTESTS['TLS-clientcerts'] as $type => $tlsclient) { |
1606 | 1646 | $this->TLS_clients_checks_result[$host]['ca'][$type]['clientcertinfo']['from'] = $type; |
1607 | 1647 | $this->TLS_clients_checks_result[$host]['ca'][$type]['clientcertinfo']['status'] = $tlsclient['status']; |
@@ -1612,8 +1652,9 @@ discard block |
||
1612 | 1652 | $this->TLS_clients_checks_result[$host]['ca'][$type]['certificate'][$k]['message'] = $this->TLS_certkeys[$cert['status']]; |
1613 | 1653 | $this->TLS_clients_checks_result[$host]['ca'][$type]['certificate'][$k]['expected'] = $cert['expected']; |
1614 | 1654 | $add = ' -cert ' . CAT::$root . '/config/cli-certs/' . $cert['public'] . ' -key ' . CAT::$root . '/config/cli-certs/' . $cert['private']; |
1615 | - if (!isset($this->TLS_clients_checks_result[$host]['ca'][$type]['certificate'][$k])) |
|
1616 | - $this->TLS_clients_checks_result[$host]['ca'][$type]['certificate'][$k] = []; |
|
1655 | + if (!isset($this->TLS_clients_checks_result[$host]['ca'][$type]['certificate'][$k])) { |
|
1656 | + $this->TLS_clients_checks_result[$host]['ca'][$type]['certificate'][$k] = []; |
|
1657 | + } |
|
1617 | 1658 | $opensslbabble = $this->openssl_s_client($host, $add, $this->TLS_clients_checks_result[$host]['ca'][$type]['certificate'][$k]); |
1618 | 1659 | $res = $this->openssl_result($host, 'clients', $opensslbabble, $this->TLS_clients_checks_result, $type, $k); |
1619 | 1660 | if ($cert['expected'] == 'PASS') { |
@@ -1625,8 +1666,9 @@ discard block |
||
1625 | 1666 | } |
1626 | 1667 | } |
1627 | 1668 | } else { |
1628 | - if ($this->TLS_clients_checks_result[$host]['ca'][$type]['certificate'][$k]['connected']) |
|
1629 | - $this->TLS_clients_checks_result[$host]['ca'][$type]['certificate'][$k]['returncode'] = CERTPROB_WRONGLY_ACCEPTED; |
|
1669 | + if ($this->TLS_clients_checks_result[$host]['ca'][$type]['certificate'][$k]['connected']) { |
|
1670 | + $this->TLS_clients_checks_result[$host]['ca'][$type]['certificate'][$k]['returncode'] = CERTPROB_WRONGLY_ACCEPTED; |
|
1671 | + } |
|
1630 | 1672 | |
1631 | 1673 | if (($this->TLS_clients_checks_result[$host]['ca'][$type]['certificate'][$k]['reason'] == CERTPROB_UNKNOWN_CA) && ($tlsclient['status'] == 'ACCREDITED') && ($cert['status'] == 'CORRECT')) { |
1632 | 1674 | $this->TLS_clients_checks_result[$host]['ca'][$type]['certificate'][$k]['finalerror'] = 1; |
@@ -138,6 +138,9 @@ |
||
138 | 138 | $this->test_result['global'] = max($this->test_result['global'],$level); |
139 | 139 | } |
140 | 140 | |
141 | + /** |
|
142 | + * @param string $s |
|
143 | + */ |
|
141 | 144 | private function get_exec_path($s) { |
142 | 145 | $the_path = ""; |
143 | 146 | $exec_is = "UNDEFINED"; |
@@ -100,11 +100,12 @@ discard block |
||
100 | 100 | if(preg_match('/(.+)=>(.+)/',$t,$m)) { |
101 | 101 | $tst = $m[1]; |
102 | 102 | $subtst=$m[2]; |
103 | - if($this->test_result[$tst] < L_ERROR) |
|
104 | - $this->test($subtst); |
|
103 | + if($this->test_result[$tst] < L_ERROR) { |
|
104 | + $this->test($subtst); |
|
105 | + } |
|
106 | + } else { |
|
107 | + $this->test($t); |
|
105 | 108 | } |
106 | - else |
|
107 | - $this->test($t); |
|
108 | 109 | } |
109 | 110 | } |
110 | 111 | |
@@ -145,10 +146,11 @@ discard block |
||
145 | 146 | preg_match('/([^ ]+) ?/',Config::$PATHS[$s],$m); |
146 | 147 | $exe = $m[1]; |
147 | 148 | $the_path = exec("which " . Config::$PATHS[$s]); |
148 | - if ($the_path == $exe) |
|
149 | - $exec_is = "EXPLICIT"; |
|
150 | - else |
|
151 | - $exec_is = "IMPLICIT"; |
|
149 | + if ($the_path == $exe) { |
|
150 | + $exec_is = "EXPLICIT"; |
|
151 | + } else { |
|
152 | + $exec_is = "IMPLICIT"; |
|
153 | + } |
|
152 | 154 | } |
153 | 155 | return(['exec'=>$the_path,'exec_is'=>$exec_is]); |
154 | 156 | } |
@@ -157,38 +159,42 @@ discard block |
||
157 | 159 | * Test for php version |
158 | 160 | */ |
159 | 161 | private function php_test() { |
160 | - if (version_compare(phpversion(), $this->php_needversion, '>=')) |
|
161 | - $this->test_return(L_OK,"<strong>PHP</strong> is sufficiently recent. You are running " . phpversion() . "."); |
|
162 | - else |
|
163 | - $this->test_return(L_ERROR,"<strong>PHP</strong> is too old. We need at least $this->php_needversion, but you only have ".phpversion(). "."); |
|
162 | + if (version_compare(phpversion(), $this->php_needversion, '>=')) { |
|
163 | + $this->test_return(L_OK,"<strong>PHP</strong> is sufficiently recent. You are running " . phpversion() . "."); |
|
164 | + } else { |
|
165 | + $this->test_return(L_ERROR,"<strong>PHP</strong> is too old. We need at least $this->php_needversion, but you only have ".phpversion(). "."); |
|
166 | + } |
|
164 | 167 | } |
165 | 168 | |
166 | 169 | /** |
167 | 170 | * test for simpleSAMLphp |
168 | 171 | */ |
169 | 172 | private function ssp_test() { |
170 | - if (!is_file(CONFIG::$AUTHENTICATION['ssp-path-to-autoloader'])) |
|
171 | - $this->test_return(L_ERROR,"<strong>simpleSAMLphp</strong> not found!"); |
|
172 | - else |
|
173 | - $this->test_return(L_OK,"<strong>simpleSAMLphp</strong> autoloader found."); |
|
173 | + if (!is_file(CONFIG::$AUTHENTICATION['ssp-path-to-autoloader'])) { |
|
174 | + $this->test_return(L_ERROR,"<strong>simpleSAMLphp</strong> not found!"); |
|
175 | + } else { |
|
176 | + $this->test_return(L_OK,"<strong>simpleSAMLphp</strong> autoloader found."); |
|
177 | + } |
|
174 | 178 | } |
175 | 179 | |
176 | 180 | /** |
177 | 181 | * test for security setting |
178 | 182 | */ |
179 | 183 | private function security_test() { |
180 | - if (in_array("I do not care about security!", Config::$SUPERADMINS)) |
|
181 | - $this->test_return(L_WARN,"You do not care about security. This page should be made accessible to the CAT admin only! See config.php 'Superadmins'!"); |
|
184 | + if (in_array("I do not care about security!", Config::$SUPERADMINS)) { |
|
185 | + $this->test_return(L_WARN,"You do not care about security. This page should be made accessible to the CAT admin only! See config.php 'Superadmins'!"); |
|
186 | + } |
|
182 | 187 | } |
183 | 188 | |
184 | 189 | /** |
185 | 190 | * test if zip is available |
186 | 191 | */ |
187 | 192 | private function zip_test() { |
188 | - if (exec("which zip") != "") |
|
189 | - $this->test_return(L_OK,"<strong>zip</strong> binary found."); |
|
190 | - else |
|
191 | - $this->test_return(L_ERROR,"<strong>zip</strong> not found in your \$PATH!"); |
|
193 | + if (exec("which zip") != "") { |
|
194 | + $this->test_return(L_OK,"<strong>zip</strong> binary found."); |
|
195 | + } else { |
|
196 | + $this->test_return(L_ERROR,"<strong>zip</strong> not found in your \$PATH!"); |
|
197 | + } |
|
192 | 198 | } |
193 | 199 | |
194 | 200 | /** |
@@ -198,59 +204,67 @@ discard block |
||
198 | 204 | exec(Config::$PATHS['eapol_test'], $out, $retval); |
199 | 205 | if($retval == 255 ) { |
200 | 206 | $o = preg_grep('/-o<server cert/',$out); |
201 | - if(count($o) > 0) |
|
202 | - $this->test_return(L_OK,"<strong>eapol_test</strong> script found."); |
|
203 | - else |
|
204 | - $this->test_return(L_ERROR,"<strong>eapol_test</strong> found, but is too old!"); |
|
207 | + if(count($o) > 0) { |
|
208 | + $this->test_return(L_OK,"<strong>eapol_test</strong> script found."); |
|
209 | + } else { |
|
210 | + $this->test_return(L_ERROR,"<strong>eapol_test</strong> found, but is too old!"); |
|
211 | + } |
|
212 | + } else { |
|
213 | + $this->test_return(L_ERROR,"<strong>eapol_test</strong> not found!"); |
|
205 | 214 | } |
206 | - else |
|
207 | - $this->test_return(L_ERROR,"<strong>eapol_test</strong> not found!"); |
|
208 | 215 | } |
209 | 216 | |
210 | 217 | /** |
211 | 218 | * test if logdir exists and is writable |
212 | 219 | */ |
213 | 220 | private function logdir_test() { |
214 | - if (fopen(Config::$PATHS['logdir'] . "/debug.log", "a") == FALSE) |
|
215 | - $this->test_return(L_WARN,"Log files in <strong>" . Config::$PATHS['logdir'] . "</strong> are not writable!"); |
|
216 | - else |
|
217 | - $this->test_return(L_OK,"Log directory is writable."); |
|
221 | + if (fopen(Config::$PATHS['logdir'] . "/debug.log", "a") == FALSE) { |
|
222 | + $this->test_return(L_WARN,"Log files in <strong>" . Config::$PATHS['logdir'] . "</strong> are not writable!"); |
|
223 | + } else { |
|
224 | + $this->test_return(L_OK,"Log directory is writable."); |
|
225 | + } |
|
218 | 226 | } |
219 | 227 | |
220 | 228 | /** |
221 | 229 | * test for required PHP modules |
222 | 230 | */ |
223 | 231 | private function phpModules_test() { |
224 | - if (function_exists('idn_to_ascii')) |
|
225 | - $this->test_return(L_OK,"PHP can handle internationalisation."); |
|
226 | - else |
|
227 | - $this->test_return(L_ERROR,"PHP can <strongNOT</strong> handle internationalisation (idn_to_ascii() from php5-intl)."); |
|
232 | + if (function_exists('idn_to_ascii')) { |
|
233 | + $this->test_return(L_OK,"PHP can handle internationalisation."); |
|
234 | + } else { |
|
235 | + $this->test_return(L_ERROR,"PHP can <strongNOT</strong> handle internationalisation (idn_to_ascii() from php5-intl)."); |
|
236 | + } |
|
228 | 237 | |
229 | - if (function_exists('gettext')) |
|
230 | - $this->test_return(L_OK,"PHP extension <strong>GNU Gettext</strong> is installed."); |
|
231 | - else |
|
232 | - $this->test_return(L_ERROR,"PHP extension <strong>GNU Gettext</strong> not found!"); |
|
238 | + if (function_exists('gettext')) { |
|
239 | + $this->test_return(L_OK,"PHP extension <strong>GNU Gettext</strong> is installed."); |
|
240 | + } else { |
|
241 | + $this->test_return(L_ERROR,"PHP extension <strong>GNU Gettext</strong> not found!"); |
|
242 | + } |
|
233 | 243 | |
234 | - if (function_exists('openssl_sign')) |
|
235 | - $this->test_return(L_OK,"PHP extension <strong>OpenSSL</strong> is installed."); |
|
236 | - else |
|
237 | - $this->test_return(L_ERROR,"PHP extension <strong>OpenSSL</strong> not found!"); |
|
244 | + if (function_exists('openssl_sign')) { |
|
245 | + $this->test_return(L_OK,"PHP extension <strong>OpenSSL</strong> is installed."); |
|
246 | + } else { |
|
247 | + $this->test_return(L_ERROR,"PHP extension <strong>OpenSSL</strong> not found!"); |
|
248 | + } |
|
238 | 249 | |
239 | - if (class_exists('Imagick')) |
|
240 | - $this->test_return(L_OK,"PHP extension <strong>Imagick</strong> is installed."); |
|
241 | - else |
|
242 | - $this->test_return(L_ERROR,"PHP extension <strong>Imagick</strong> not found! Get it from your distribution or <a href='http://pecl.php.net/package/imagick'>here</a>."); |
|
250 | + if (class_exists('Imagick')) { |
|
251 | + $this->test_return(L_OK,"PHP extension <strong>Imagick</strong> is installed."); |
|
252 | + } else { |
|
253 | + $this->test_return(L_ERROR,"PHP extension <strong>Imagick</strong> not found! Get it from your distribution or <a href='http://pecl.php.net/package/imagick'>here</a>."); |
|
254 | + } |
|
243 | 255 | |
244 | - if (function_exists('ImageCreate')) |
|
245 | - $this->test_return(L_OK,"PHP extension <strong>GD</strong> is installed."); |
|
246 | - else |
|
247 | - $this->test_return(L_ERROR,"PHP extension <strong>GD</strong> not found!</a>."); |
|
256 | + if (function_exists('ImageCreate')) { |
|
257 | + $this->test_return(L_OK,"PHP extension <strong>GD</strong> is installed."); |
|
258 | + } else { |
|
259 | + $this->test_return(L_ERROR,"PHP extension <strong>GD</strong> not found!</a>."); |
|
260 | + } |
|
248 | 261 | |
249 | - if (function_exists('mysqli_connect')) |
|
250 | - $this->test_return(L_OK,"PHP extension <strong>MySQL</strong> is installed."); |
|
251 | - else |
|
252 | - $this->test_return(L_ERROR,"PHP extension <strong>MySQL</strong> not found!"); |
|
253 | -/* |
|
262 | + if (function_exists('mysqli_connect')) { |
|
263 | + $this->test_return(L_OK,"PHP extension <strong>MySQL</strong> is installed."); |
|
264 | + } else { |
|
265 | + $this->test_return(L_ERROR,"PHP extension <strong>MySQL</strong> not found!"); |
|
266 | + } |
|
267 | + /* |
|
254 | 268 | if (function_exists('geoip_record_by_name')) { |
255 | 269 | $host = '158.75.1.10'; |
256 | 270 | $record = geoip_record_by_name($host); |
@@ -339,12 +353,14 @@ discard block |
||
339 | 353 | $A = $this->get_exec_path('openssl'); |
340 | 354 | if($A['exec'] != "") { |
341 | 355 | $t = exec($A['exec'] . ' version'); |
342 | - if($A['exec_is'] == "EXPLICIT") |
|
343 | - $this->test_return(L_OK,"<strong>$t</strong> was found and is configured explicitly in your config."); |
|
344 | - else |
|
345 | - $this->test_return(L_WARN,"<strong>$t</strong> was found, but is not configured with an absolute path in your config."); |
|
346 | - } else |
|
347 | - $this->test_return(L_ERROR,"<strong>openssl</strong> was not found on your system!"); |
|
356 | + if($A['exec_is'] == "EXPLICIT") { |
|
357 | + $this->test_return(L_OK,"<strong>$t</strong> was found and is configured explicitly in your config."); |
|
358 | + } else { |
|
359 | + $this->test_return(L_WARN,"<strong>$t</strong> was found, but is not configured with an absolute path in your config."); |
|
360 | + } |
|
361 | + } else { |
|
362 | + $this->test_return(L_ERROR,"<strong>openssl</strong> was not found on your system!"); |
|
363 | + } |
|
348 | 364 | } |
349 | 365 | |
350 | 366 | /** |
@@ -362,18 +378,22 @@ discard block |
||
362 | 378 | $A = $this->get_exec_path('makensis'); |
363 | 379 | if($A['exec'] != "") { |
364 | 380 | $t = exec($A['exec'] . ' -VERSION'); |
365 | - if($A['exec_is'] == "EXPLICIT") |
|
366 | - $this->test_return(L_OK,"<strong>makensis $t</strong> was found and is configured explicitly in your config."); |
|
367 | - else |
|
368 | - $this->test_return(L_WARN,"<strong>makensis $t</strong> was found, but is not configured with an absolute path in your config."); |
|
381 | + if($A['exec_is'] == "EXPLICIT") { |
|
382 | + $this->test_return(L_OK,"<strong>makensis $t</strong> was found and is configured explicitly in your config."); |
|
383 | + } else { |
|
384 | + $this->test_return(L_WARN,"<strong>makensis $t</strong> was found, but is not configured with an absolute path in your config."); |
|
385 | + } |
|
369 | 386 | exec($A['exec'] . ' -HELP',$t); |
370 | 387 | $t1 = count(preg_grep('/INPUTCHARSET/',$t)); |
371 | - if($t1 == 1 && Config::$NSIS_VERSION == 2) |
|
372 | - $this->test_return(L_ERROR,"Declared NSIS_VERSION does not seem to match the file pointed to by PATHS['makensis']!"); |
|
373 | - if($t1 == 0 && Config::$NSIS_VERSION >= 3) |
|
374 | - $this->test_return(L_ERROR,"Declared NSIS_VERSION does not seem to match the file pointed to by PATHS['makensis']!"); |
|
375 | - } else |
|
376 | - $this->test_return(L_ERROR,"<strong>makensis</strong> was not found on your system!"); |
|
388 | + if($t1 == 1 && Config::$NSIS_VERSION == 2) { |
|
389 | + $this->test_return(L_ERROR,"Declared NSIS_VERSION does not seem to match the file pointed to by PATHS['makensis']!"); |
|
390 | + } |
|
391 | + if($t1 == 0 && Config::$NSIS_VERSION >= 3) { |
|
392 | + $this->test_return(L_ERROR,"Declared NSIS_VERSION does not seem to match the file pointed to by PATHS['makensis']!"); |
|
393 | + } |
|
394 | + } else { |
|
395 | + $this->test_return(L_ERROR,"<strong>makensis</strong> was not found on your system!"); |
|
396 | + } |
|
377 | 397 | } |
378 | 398 | |
379 | 399 | /** |
@@ -391,18 +411,21 @@ discard block |
||
391 | 411 | foreach ($this->NSIS_Modules as $module) { |
392 | 412 | unset($out); |
393 | 413 | exec(Config::$PATHS['makensis']." -V1 '-X!include $module' '-XOutFile $exe' '-XSection X' '-XSectionEnd'", $out, $retval); |
394 | - if($retval > 0) |
|
395 | - $NSIS_Module_status[$module] = 0; |
|
396 | - else |
|
397 | - $NSIS_Module_status[$module] = 1; |
|
414 | + if($retval > 0) { |
|
415 | + $NSIS_Module_status[$module] = 0; |
|
416 | + } else { |
|
417 | + $NSIS_Module_status[$module] = 1; |
|
418 | + } |
|
419 | + } |
|
420 | + if(is_file($exe)) { |
|
421 | + unlink($exe); |
|
398 | 422 | } |
399 | - if(is_file($exe)) |
|
400 | - unlink($exe); |
|
401 | 423 | foreach ($NSIS_Module_status as $module => $status) { |
402 | - if($status == 1) |
|
403 | - $this->test_return(L_OK,"NSIS module <strong>$module</strong> was found."); |
|
404 | - else |
|
405 | - $this->test_return(L_ERROR,"NSIS module <strong>$module</strong> was not found or is not working correctly."); |
|
424 | + if($status == 1) { |
|
425 | + $this->test_return(L_OK,"NSIS module <strong>$module</strong> was found."); |
|
426 | + } else { |
|
427 | + $this->test_return(L_ERROR,"NSIS module <strong>$module</strong> was not found or is not working correctly."); |
|
428 | + } |
|
406 | 429 | } |
407 | 430 | } |
408 | 431 | private function NSIS_GetVersion_test() { |
@@ -414,12 +437,14 @@ discard block |
||
414 | 437 | } |
415 | 438 | $exe= 'tt.exe'; |
416 | 439 | exec(Config::$PATHS['makensis']." -V1 '-XOutFile $exe' '-XSection X' '-XGetVersion::WindowsName' '-XSectionEnd'", $out, $retval); |
417 | - if($retval > 0) |
|
418 | - $this->test_return(L_ERROR,"NSIS module <strong>GetVersion</strong> was not found or is not working correctly."); |
|
419 | - else |
|
420 | - $this->test_return(L_OK,"NSIS module <strong>GetVersion</strong> was found."); |
|
421 | - if(is_file($exe)) |
|
422 | - unlink($exe); |
|
440 | + if($retval > 0) { |
|
441 | + $this->test_return(L_ERROR,"NSIS module <strong>GetVersion</strong> was not found or is not working correctly."); |
|
442 | + } else { |
|
443 | + $this->test_return(L_OK,"NSIS module <strong>GetVersion</strong> was found."); |
|
444 | + } |
|
445 | + if(is_file($exe)) { |
|
446 | + unlink($exe); |
|
447 | + } |
|
423 | 448 | } |
424 | 449 | |
425 | 450 | /** |
@@ -461,21 +486,24 @@ discard block |
||
461 | 486 | private function locales_test() { |
462 | 487 | $locales = shell_exec("locale -a"); |
463 | 488 | $allthere = ""; |
464 | - foreach (Config::$LANGUAGES as $onelanguage) |
|
465 | - if (preg_match("/" . $onelanguage['locale'] . "/", $locales) == 0) |
|
489 | + foreach (Config::$LANGUAGES as $onelanguage) { |
|
490 | + if (preg_match("/" . $onelanguage['locale'] . "/", $locales) == 0) |
|
466 | 491 | $allthere .= $onelanguage['locale'] . " "; |
492 | + } |
|
467 | 493 | |
468 | - if ($allthere == "") |
|
469 | - $this->test_return(L_OK,"All of your configured locales are available on your system."); |
|
470 | - else |
|
471 | - $this->test_return(L_WARN,"Some of your configured locales (<strong>$allthere</strong>) are not installed and will not be displayed correctly!"); |
|
494 | + if ($allthere == "") { |
|
495 | + $this->test_return(L_OK,"All of your configured locales are available on your system."); |
|
496 | + } else { |
|
497 | + $this->test_return(L_WARN,"Some of your configured locales (<strong>$allthere</strong>) are not installed and will not be displayed correctly!"); |
|
498 | + } |
|
472 | 499 | } |
473 | 500 | |
474 | 501 | private function check_config_default($type,$key,$value) { |
475 | - if (empty(Config::$type[$key])) |
|
476 | - $missingvalues .="type/webcert_OCSP "; |
|
477 | - elseif (Config::$type['webcert_OCSP'] == $value) |
|
478 | - $defaultvalues .="type/$key "; |
|
502 | + if (empty(Config::$type[$key])) { |
|
503 | + $missingvalues .="type/webcert_OCSP "; |
|
504 | + } elseif (Config::$type['webcert_OCSP'] == $value) { |
|
505 | + $defaultvalues .="type/$key "; |
|
506 | + } |
|
479 | 507 | } |
480 | 508 | |
481 | 509 | |
@@ -485,32 +513,44 @@ discard block |
||
485 | 513 | private function defaults_test() { |
486 | 514 | $defaultvalues = ""; |
487 | 515 | $missingvalues = ""; |
488 | - if (Config::$APPEARANCE['from-mail'] == "[email protected]") |
|
489 | - $defaultvalues .="APPEARANCE/from-mail "; |
|
490 | - if (Config::$APPEARANCE['support-contact']['url'] == "[email protected]?body=Only%20English%20language%20please!") |
|
491 | - $defaultvalues .="APPEARANCE/support-contact/url "; |
|
492 | - if (Config::$APPEARANCE['support-contact']['display'] == "[email protected]") |
|
493 | - $defaultvalues .="APPEARANCE/support-contact/display "; |
|
494 | - if (Config::$APPEARANCE['support-contact']['developer-mail'] == "[email protected]") |
|
495 | - $defaultvalues .="APPEARANCE/support-contact/mail "; |
|
496 | - if (Config::$APPEARANCE['abuse-mail'] == "[email protected]") |
|
497 | - $defaultvalues .="APPEARANCE/abuse-mail "; |
|
498 | - if (Config::$APPEARANCE['MOTD'] == "Release Candidate. All bugs to be shot on sight!") |
|
499 | - $defaultvalues .="APPEARANCE/MOTD "; |
|
500 | - if (Config::$APPEARANCE['webcert_CRLDP'] == ['list', 'of', 'CRL', 'pointers']) |
|
501 | - $defaultvalues .="APPEARANCE/webcert_CRLDP "; |
|
502 | - if (empty(Config::$APPEARANCE['webcert_OCSP'])) |
|
503 | - $missingvalues .="APPEARANCE/webcert_OCSP "; |
|
504 | - elseif (Config::$APPEARANCE['webcert_OCSP'] == ['list', 'of', 'OCSP', 'pointers']) |
|
505 | - $defaultvalues .="APPEARANCE/webcert_OCSP "; |
|
506 | - if (isset(Config::$RADIUSTESTS['UDP-hosts'][0]) && Config::$RADIUSTESTS['UDP-hosts'][0]['ip'] == "192.0.2.1") |
|
507 | - $defaultvalues .="RADIUSTESTS/UDP-hosts "; |
|
508 | - if (Config::$DB['INST']['host'] == "db.host.example") |
|
509 | - $defaultvalues .="DB/INST "; |
|
510 | - if (Config::$DB['INST']['host'] == "db.host.example") |
|
511 | - $defaultvalues .="DB/USER "; |
|
512 | - if(!empty(Config::$DB['EXTERNAL']) && Config::$DB['EXTERNAL']['host'] == "customerdb.otherhost.example") |
|
513 | - $defaultvalues .="DB/EXTERNAL "; |
|
516 | + if (Config::$APPEARANCE['from-mail'] == "[email protected]") { |
|
517 | + $defaultvalues .="APPEARANCE/from-mail "; |
|
518 | + } |
|
519 | + if (Config::$APPEARANCE['support-contact']['url'] == "[email protected]?body=Only%20English%20language%20please!") { |
|
520 | + $defaultvalues .="APPEARANCE/support-contact/url "; |
|
521 | + } |
|
522 | + if (Config::$APPEARANCE['support-contact']['display'] == "[email protected]") { |
|
523 | + $defaultvalues .="APPEARANCE/support-contact/display "; |
|
524 | + } |
|
525 | + if (Config::$APPEARANCE['support-contact']['developer-mail'] == "[email protected]") { |
|
526 | + $defaultvalues .="APPEARANCE/support-contact/mail "; |
|
527 | + } |
|
528 | + if (Config::$APPEARANCE['abuse-mail'] == "[email protected]") { |
|
529 | + $defaultvalues .="APPEARANCE/abuse-mail "; |
|
530 | + } |
|
531 | + if (Config::$APPEARANCE['MOTD'] == "Release Candidate. All bugs to be shot on sight!") { |
|
532 | + $defaultvalues .="APPEARANCE/MOTD "; |
|
533 | + } |
|
534 | + if (Config::$APPEARANCE['webcert_CRLDP'] == ['list', 'of', 'CRL', 'pointers']) { |
|
535 | + $defaultvalues .="APPEARANCE/webcert_CRLDP "; |
|
536 | + } |
|
537 | + if (empty(Config::$APPEARANCE['webcert_OCSP'])) { |
|
538 | + $missingvalues .="APPEARANCE/webcert_OCSP "; |
|
539 | + } elseif (Config::$APPEARANCE['webcert_OCSP'] == ['list', 'of', 'OCSP', 'pointers']) { |
|
540 | + $defaultvalues .="APPEARANCE/webcert_OCSP "; |
|
541 | + } |
|
542 | + if (isset(Config::$RADIUSTESTS['UDP-hosts'][0]) && Config::$RADIUSTESTS['UDP-hosts'][0]['ip'] == "192.0.2.1") { |
|
543 | + $defaultvalues .="RADIUSTESTS/UDP-hosts "; |
|
544 | + } |
|
545 | + if (Config::$DB['INST']['host'] == "db.host.example") { |
|
546 | + $defaultvalues .="DB/INST "; |
|
547 | + } |
|
548 | + if (Config::$DB['INST']['host'] == "db.host.example") { |
|
549 | + $defaultvalues .="DB/USER "; |
|
550 | + } |
|
551 | + if(!empty(Config::$DB['EXTERNAL']) && Config::$DB['EXTERNAL']['host'] == "customerdb.otherhost.example") { |
|
552 | + $defaultvalues .="DB/EXTERNAL "; |
|
553 | + } |
|
514 | 554 | $files = []; |
515 | 555 | foreach (Config::$RADIUSTESTS['TLS-clientcerts'] as $cadata) { |
516 | 556 | foreach ($cadata['certificates'] as $cert_files) { |
@@ -521,15 +561,17 @@ discard block |
||
521 | 561 | |
522 | 562 | foreach ($files as $file) { |
523 | 563 | $handle = fopen(CAT::$root . "/config/cli-certs/" . $file, 'r'); |
524 | - if (!$handle) |
|
525 | - $defaultvalues .="CERTIFICATE/$file "; |
|
526 | - else |
|
527 | - fclose($handle); |
|
564 | + if (!$handle) { |
|
565 | + $defaultvalues .="CERTIFICATE/$file "; |
|
566 | + } else { |
|
567 | + fclose($handle); |
|
568 | + } |
|
569 | + } |
|
570 | + if ($defaultvalues != "") { |
|
571 | + $this->test_return(L_WARN,"Your configuration in config/config.php contains unchanged default values or links to inexistent files: <strong>$defaultvalues</strong>!"); |
|
572 | + } else { |
|
573 | + $this->test_return(L_OK,"Your configuration does not contain any unchanged defaults, which is a good sign."); |
|
528 | 574 | } |
529 | - if ($defaultvalues != "") |
|
530 | - $this->test_return(L_WARN,"Your configuration in config/config.php contains unchanged default values or links to inexistent files: <strong>$defaultvalues</strong>!"); |
|
531 | - else |
|
532 | - $this->test_return(L_OK,"Your configuration does not contain any unchanged defaults, which is a good sign."); |
|
533 | 575 | } |
534 | 576 | |
535 | 577 | /** |
@@ -542,10 +584,11 @@ discard block |
||
542 | 584 | $this->test_return(L_ERROR,"Connection to the $DB database failed"); |
543 | 585 | } else { |
544 | 586 | $r = mysqli_query($db,'select * from profile_option_dict'); |
545 | - if($r->num_rows == $this->profile_option_ct) |
|
546 | - $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
547 | - else |
|
548 | - $this->test_return(L_ERROR,"The $DB database is reacheable but probably not updated to this version of CAT."); |
|
587 | + if($r->num_rows == $this->profile_option_ct) { |
|
588 | + $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
589 | + } else { |
|
590 | + $this->test_return(L_ERROR,"The $DB database is reacheable but probably not updated to this version of CAT."); |
|
591 | + } |
|
549 | 592 | } |
550 | 593 | $DB = 'USER'; |
551 | 594 | $db = mysqli_connect(Config::$DB[$DB]['host'], Config::$DB[$DB]['user'], Config::$DB[$DB]['pass'], Config::$DB[$DB]['db']); |
@@ -553,10 +596,11 @@ discard block |
||
553 | 596 | $this->test_return(L_ERROR,"Connection to the $DB database failed"); |
554 | 597 | } else { |
555 | 598 | $r = mysqli_query($db,'desc view_admin'); |
556 | - if($r->num_rows == $this->view_admin_ct) |
|
557 | - $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
558 | - else |
|
559 | - $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema"); |
|
599 | + if($r->num_rows == $this->view_admin_ct) { |
|
600 | + $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
601 | + } else { |
|
602 | + $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema"); |
|
603 | + } |
|
560 | 604 | } |
561 | 605 | $DB = 'EXTERNAL'; |
562 | 606 | if(! empty(Config::$DB[$DB])) { |
@@ -565,10 +609,11 @@ discard block |
||
565 | 609 | $this->test_return(L_ERROR,"Connection to the $DB database failed"); |
566 | 610 | } else { |
567 | 611 | $r = mysqli_query($db,'desc view_admin'); |
568 | - if($r->num_rows == $this->view_admin_ct) |
|
569 | - $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
570 | - else |
|
571 | - $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema"); |
|
612 | + if($r->num_rows == $this->view_admin_ct) { |
|
613 | + $this->test_return(L_OK,"The $DB database appears to be OK."); |
|
614 | + } else { |
|
615 | + $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema"); |
|
616 | + } |
|
572 | 617 | } |
573 | 618 | } |
574 | 619 | } |
@@ -578,13 +623,15 @@ discard block |
||
578 | 623 | * test devices.php for the no_cache option |
579 | 624 | */ |
580 | 625 | private function device_cache_test() { |
581 | - if((! empty(Devices::$Options['no_cache'])) && Devices::$Options['no_cache']) |
|
582 | - $global_no_cache = 1; |
|
583 | - else |
|
584 | - $global_no_cache = 0; |
|
626 | + if((! empty(Devices::$Options['no_cache'])) && Devices::$Options['no_cache']) { |
|
627 | + $global_no_cache = 1; |
|
628 | + } else { |
|
629 | + $global_no_cache = 0; |
|
630 | + } |
|
585 | 631 | |
586 | - if($global_no_cache == 1) |
|
587 | - $this->test_return(L_WARN,"Devices no_cache global option is set, this is not a good idea in a production setting\n"); |
|
632 | + if($global_no_cache == 1) { |
|
633 | + $this->test_return(L_WARN,"Devices no_cache global option is set, this is not a good idea in a production setting\n"); |
|
634 | + } |
|
588 | 635 | $Devs = Devices::listDevices(); |
589 | 636 | $no_cache_dev = ''; |
590 | 637 | $no_cache_dev_count = 0; |
@@ -605,10 +652,12 @@ discard block |
||
605 | 652 | } |
606 | 653 | |
607 | 654 | |
608 | - if($no_cache_dev_count > 1 ) |
|
609 | - $this->test_return(L_WARN,"The following devices will not be cached: $no_cache_dev"); |
|
610 | - if($no_cache_dev_count == 1 ) |
|
611 | - $this->test_return(L_WARN,"The following device will not be cached: $no_cache_dev"); |
|
655 | + if($no_cache_dev_count > 1 ) { |
|
656 | + $this->test_return(L_WARN,"The following devices will not be cached: $no_cache_dev"); |
|
657 | + } |
|
658 | + if($no_cache_dev_count == 1 ) { |
|
659 | + $this->test_return(L_WARN,"The following device will not be cached: $no_cache_dev"); |
|
660 | + } |
|
612 | 661 | |
613 | 662 | } |
614 | 663 | |
@@ -637,10 +686,11 @@ discard block |
||
637 | 686 | $mail->Subject = "testing CAT configuration mail"; |
638 | 687 | $mail->Body = "Testing CAT mailing\n"; |
639 | 688 | $sent = $mail->send(); |
640 | - if($sent) |
|
641 | - $this->test_return(L_OK,"mailer settings appear to be working, check ".Config::$APPEARANCE['abuse-mail']." mailbox if the message was receiced."); |
|
642 | - else |
|
643 | - $this->test_return(L_ERROR,"mailer settings failed, check the Config::MAILSETTINGS"); |
|
689 | + if($sent) { |
|
690 | + $this->test_return(L_OK,"mailer settings appear to be working, check ".Config::$APPEARANCE['abuse-mail']." mailbox if the message was receiced."); |
|
691 | + } else { |
|
692 | + $this->test_return(L_ERROR,"mailer settings failed, check the Config::MAILSETTINGS"); |
|
693 | + } |
|
644 | 694 | |
645 | 695 | } |
646 | 696 |
@@ -260,7 +260,6 @@ discard block |
||
260 | 260 | /** |
261 | 261 | * Return the list of IdPs in a given country |
262 | 262 | * |
263 | - * @param int $idp_id the IdP identifier |
|
264 | 263 | * @return string JSON encoded data |
265 | 264 | */ |
266 | 265 | |
@@ -301,7 +300,6 @@ discard block |
||
301 | 300 | /** |
302 | 301 | * Return the list of IdPs in a given country ordered with respect to the user location |
303 | 302 | * |
304 | - * @param int $idp_id the IdP identifier |
|
305 | 303 | * @return string JSON encoded data |
306 | 304 | */ |
307 | 305 |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | $a = []; |
83 | 83 | $a['profile'] = $prof_id; |
84 | 84 | $a['device'] = $device; |
85 | - if( (isset(Devices::$Options['no_cache']) && Devices::$Options['no_cache'] ) || ( isset($Config['options']['no_cache']) && $Config['options']['no_cache'] )) |
|
86 | - $this->i_path = FALSE; |
|
87 | - else { |
|
85 | + if( (isset(Devices::$Options['no_cache']) && Devices::$Options['no_cache'] ) || ( isset($Config['options']['no_cache']) && $Config['options']['no_cache'] )) { |
|
86 | + $this->i_path = FALSE; |
|
87 | + } else { |
|
88 | 88 | $cache = $profile->testCache($device); |
89 | 89 | $this->i_path = $cache['cache']; |
90 | 90 | } |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | $installer = $dev->writeInstaller(); |
101 | 101 | $i_path = $dev->FPATH.'/tmp/'.$installer; |
102 | 102 | if($i_path && is_file($i_path)) { |
103 | - if(isset($dev->options['mime'])) |
|
104 | - $a['mime'] = $dev->options['mime']; |
|
105 | - else { |
|
103 | + if(isset($dev->options['mime'])) { |
|
104 | + $a['mime'] = $dev->options['mime']; |
|
105 | + } else { |
|
106 | 106 | $info = new finfo(); |
107 | 107 | $a['mime'] = $info->file($i_path, FILEINFO_MIME_TYPE); |
108 | 108 | } |
@@ -129,19 +129,23 @@ discard block |
||
129 | 129 | $Dev = Devices::listDevices(); |
130 | 130 | $R = []; |
131 | 131 | $ct = 0; |
132 | - if($show_hidden !== 0 && $show_hidden != 1) |
|
133 | - return; |
|
132 | + if($show_hidden !== 0 && $show_hidden != 1) { |
|
133 | + return; |
|
134 | + } |
|
134 | 135 | foreach ($Dev as $device => $D) { |
135 | - if(isset($D['options']['hidden']) && $D['options']['hidden'] && $show_hidden == 0) |
|
136 | - continue; |
|
136 | + if(isset($D['options']['hidden']) && $D['options']['hidden'] && $show_hidden == 0) { |
|
137 | + continue; |
|
138 | + } |
|
137 | 139 | $ct ++; |
138 | - if($this->version == 1) |
|
139 | - $D['device'] = $device; |
|
140 | - else |
|
141 | - $D['device'] = $device; |
|
140 | + if($this->version == 1) { |
|
141 | + $D['device'] = $device; |
|
142 | + } else { |
|
143 | + $D['device'] = $device; |
|
144 | + } |
|
142 | 145 | $group = isset($D['group']) ? $D['group'] : 'other'; |
143 | - if (! isset($R[$group])) |
|
144 | - $R[$group] = []; |
|
146 | + if (! isset($R[$group])) { |
|
147 | + $R[$group] = []; |
|
148 | + } |
|
145 | 149 | $R[$group][$device] = $D; |
146 | 150 | } |
147 | 151 | return $R; |
@@ -178,14 +182,18 @@ discard block |
||
178 | 182 | $profile = new Profile($prof_id); |
179 | 183 | $attr = $profile->getCollapsedAttributes(); |
180 | 184 | $a = []; |
181 | - if(isset($attr['support:email'])) |
|
182 | - $a['local_email'] = $attr['support:email'][0]; |
|
183 | - if(isset($attr['support:phone'])) |
|
184 | - $a['local_phone'] = $attr['support:phone'][0]; |
|
185 | - if(isset($attr['support:url'])) |
|
186 | - $a['local_url'] = $attr['support:url'][0]; |
|
187 | - if(isset($attr['profile:description'])) |
|
188 | - $a['description'] = $attr['profile:description'][0]; |
|
185 | + if(isset($attr['support:email'])) { |
|
186 | + $a['local_email'] = $attr['support:email'][0]; |
|
187 | + } |
|
188 | + if(isset($attr['support:phone'])) { |
|
189 | + $a['local_phone'] = $attr['support:phone'][0]; |
|
190 | + } |
|
191 | + if(isset($attr['support:url'])) { |
|
192 | + $a['local_url'] = $attr['support:url'][0]; |
|
193 | + } |
|
194 | + if(isset($attr['profile:description'])) { |
|
195 | + $a['description'] = $attr['profile:description'][0]; |
|
196 | + } |
|
189 | 197 | $a['devices'] = $profile->listDevices(); |
190 | 198 | $this->set_locale("web_user"); |
191 | 199 | return($a); |
@@ -200,14 +208,17 @@ discard block |
||
200 | 208 | $F = array_pop($backtrace); |
201 | 209 | $file= $F['file']; |
202 | 210 | $file = substr($file,strlen(dirname(__DIR__))); |
203 | - while(substr($file,0,1) == '/') |
|
204 | - $file = substr($file,1); |
|
211 | + while(substr($file,0,1) == '/') { |
|
212 | + $file = substr($file,1); |
|
213 | + } |
|
205 | 214 | $n = count(explode('/',$file)); |
206 | 215 | $out = $_SERVER['SCRIPT_NAME']; |
207 | - for ($i= 0; $i < $n; $i++) |
|
208 | - $out = dirname($out); |
|
209 | - if ($out == '/') |
|
210 | - $out = ''; |
|
216 | + for ($i= 0; $i < $n; $i++) { |
|
217 | + $out = dirname($out); |
|
218 | + } |
|
219 | + if ($out == '/') { |
|
220 | + $out = ''; |
|
221 | + } |
|
211 | 222 | $s = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http'; |
212 | 223 | $s .= '://'.$_SERVER['HTTP_HOST'] . $out; |
213 | 224 | return $s; |
@@ -231,10 +242,11 @@ discard block |
||
231 | 242 | public function JSON_listLanguages() { |
232 | 243 | $return_array = []; |
233 | 244 | foreach(Config::$LANGUAGES as $id => $val){ |
234 | - if($this->version == 1) |
|
235 | - $return_array[] = ['id'=>$id,'display'=>$val['display'],'locale'=>$val['locale']]; |
|
236 | - else |
|
237 | - $return_array[] = ['lang'=>$id,'display'=>$val['display'],'locale'=>$val['locale']]; |
|
245 | + if($this->version == 1) { |
|
246 | + $return_array[] = ['id'=>$id,'display'=>$val['display'],'locale'=>$val['locale']]; |
|
247 | + } else { |
|
248 | + $return_array[] = ['lang'=>$id,'display'=>$val['display'],'locale'=>$val['locale']]; |
|
249 | + } |
|
238 | 250 | } |
239 | 251 | echo $this->return_json($return_array); |
240 | 252 | } |
@@ -249,10 +261,11 @@ discard block |
||
249 | 261 | $FED = $this->printCountryList(1); |
250 | 262 | $return_array = []; |
251 | 263 | foreach ($FED as $id => $val) { |
252 | - if($this->version == 1) |
|
253 | - $return_array[] = ['id'=>$id,'display'=>$val]; |
|
254 | - else |
|
255 | - $return_array[] = ['federation'=>$id,'display'=>$val]; |
|
264 | + if($this->version == 1) { |
|
265 | + $return_array[] = ['id'=>$id,'display'=>$val]; |
|
266 | + } else { |
|
267 | + $return_array[] = ['federation'=>$id,'display'=>$val]; |
|
268 | + } |
|
256 | 269 | } |
257 | 270 | echo $this->return_json($return_array); |
258 | 271 | } |
@@ -268,10 +281,11 @@ discard block |
||
268 | 281 | $idps = Federation::listAllIdentityProviders(1,$country); |
269 | 282 | $return_array = []; |
270 | 283 | foreach ($idps as $idp) { |
271 | - if($this->version == 1) |
|
272 | - $return_array[] = ['id'=>$idp['entityID'],'display'=>$idp['title']]; |
|
273 | - else |
|
274 | - $return_array[] = ['idp'=>$idp['entityID'],'display'=>$idp['title']]; |
|
284 | + if($this->version == 1) { |
|
285 | + $return_array[] = ['id'=>$idp['entityID'],'display'=>$idp['title']]; |
|
286 | + } else { |
|
287 | + $return_array[] = ['idp'=>$idp['entityID'],'display'=>$idp['title']]; |
|
288 | + } |
|
275 | 289 | } |
276 | 290 | echo $this->return_json($return_array); |
277 | 291 | } |
@@ -287,10 +301,11 @@ discard block |
||
287 | 301 | $idps = Federation::listAllIdentityProviders(1); |
288 | 302 | $return_array = []; |
289 | 303 | foreach ($idps as $idp) { |
290 | - if($this->version == 1) |
|
291 | - $idp['id'] = $idp['entityID']; |
|
292 | - else |
|
293 | - $idp['idp'] = $idp['entityID']; |
|
304 | + if($this->version == 1) { |
|
305 | + $idp['id'] = $idp['entityID']; |
|
306 | + } else { |
|
307 | + $idp['idp'] = $idp['entityID']; |
|
308 | + } |
|
294 | 309 | $return_array[] = $idp; |
295 | 310 | } |
296 | 311 | echo json_encode($return_array); |
@@ -310,10 +325,11 @@ discard block |
||
310 | 325 | $idps = $this->orderIdentityProviders($country,$L); |
311 | 326 | $return_array = []; |
312 | 327 | foreach ($idps as $idp) { |
313 | - if($this->version == 1) |
|
314 | - $return_array[] = ['id'=>$idp['id'],'display'=>$idp['title']]; |
|
315 | - else |
|
316 | - $return_array[] = ['idp'=>$idp['id'],'display'=>$idp['title']]; |
|
328 | + if($this->version == 1) { |
|
329 | + $return_array[] = ['id'=>$idp['id'],'display'=>$idp['title']]; |
|
330 | + } else { |
|
331 | + $return_array[] = ['idp'=>$idp['id'],'display'=>$idp['title']]; |
|
332 | + } |
|
317 | 333 | } |
318 | 334 | echo $this->return_json($return_array); |
319 | 335 | } |
@@ -329,23 +345,25 @@ discard block |
||
329 | 345 | $return_array = []; |
330 | 346 | try { |
331 | 347 | $idp = new IdP($idp_id); |
332 | - } |
|
333 | - catch (Exception $fail) { |
|
348 | + } catch (Exception $fail) { |
|
334 | 349 | echo $this->return_json($return_array,0); |
335 | 350 | return; |
336 | 351 | } |
337 | 352 | $l = 0; |
338 | 353 | $logo = $idp->getAttributes('general:logo_file'); |
339 | - if($logo) |
|
340 | - $l = 1; |
|
354 | + if($logo) { |
|
355 | + $l = 1; |
|
356 | + } |
|
341 | 357 | $profiles = $idp->listProfiles(1); |
342 | - if($sort == 1) |
|
343 | - usort($profiles,"profile_sort"); |
|
358 | + if($sort == 1) { |
|
359 | + usort($profiles,"profile_sort"); |
|
360 | + } |
|
344 | 361 | foreach ($profiles as $P) { |
345 | - if($this->version == 1) |
|
346 | - $return_array[] = ['id'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; |
|
347 | - else |
|
348 | - $return_array[] = ['profile'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; |
|
362 | + if($this->version == 1) { |
|
363 | + $return_array[] = ['id'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; |
|
364 | + } else { |
|
365 | + $return_array[] = ['profile'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; |
|
366 | + } |
|
349 | 367 | } |
350 | 368 | echo $this->return_json($return_array); |
351 | 369 | } |
@@ -364,8 +382,9 @@ discard block |
||
364 | 382 | if(!isset($profile_redirect) || ! $profile_redirect) { |
365 | 383 | $profile_redirect = 0; |
366 | 384 | foreach ($thedevices as $D) { |
367 | - if(isset($D['options']) && isset($D['options']['hidden']) && $D['options']['hidden']) |
|
368 | - continue; |
|
385 | + if(isset($D['options']) && isset($D['options']['hidden']) && $D['options']['hidden']) { |
|
386 | + continue; |
|
387 | + } |
|
369 | 388 | $disp = $D['display']; |
370 | 389 | if($this->version == 1) { |
371 | 390 | if($D['id'] === '0') { |
@@ -449,10 +468,12 @@ discard block |
||
449 | 468 | $resize = 0; |
450 | 469 | if(($width || $height) && is_numeric($width) && is_numeric($height)) { |
451 | 470 | $resize = 1; |
452 | - if($height == 0) |
|
453 | - $height = 10000; |
|
454 | - if($width == 0) |
|
455 | - $width = 10000; |
|
471 | + if($height == 0) { |
|
472 | + $height = 10000; |
|
473 | + } |
|
474 | + if($width == 0) { |
|
475 | + $width = 10000; |
|
476 | + } |
|
456 | 477 | $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png'; |
457 | 478 | } elseif($disco == 1) { |
458 | 479 | $width = 120; |
@@ -465,8 +486,7 @@ discard block |
||
465 | 486 | debug(4,"Using cached logo $logo_file for: $idp_id\n"); |
466 | 487 | $blob = file_get_contents($logo_file); |
467 | 488 | $filetype = 'image/png'; |
468 | - } |
|
469 | - else { |
|
489 | + } else { |
|
470 | 490 | $idp = new IdP($idp_id); |
471 | 491 | $at = $idp->getAttributes('general:logo_file'); |
472 | 492 | $blob = $at[0]['value']; |
@@ -483,9 +503,9 @@ discard block |
||
483 | 503 | $blob = $image->getImageBlob(); |
484 | 504 | debug(4,"Writing cached logo $logo_file for: $idp_id\n"); |
485 | 505 | file_put_contents($logo_file,$blob); |
506 | + } else { |
|
507 | + $blob = "XXXXXX"; |
|
486 | 508 | } |
487 | - else |
|
488 | - $blob = "XXXXXX"; |
|
489 | 509 | } |
490 | 510 | } |
491 | 511 | header( "Content-type: ".$filetype ); |
@@ -501,8 +521,9 @@ discard block |
||
501 | 521 | $result = ['status' => 'ok']; |
502 | 522 | $result['country'] = $record['country_code']; |
503 | 523 | // the two lines below are a dirty hack to take of the error in naming the UK federation |
504 | - if($result['country'] == 'GB') |
|
505 | - $result['country'] = 'UK'; |
|
524 | + if($result['country'] == 'GB') { |
|
525 | + $result['country'] = 'UK'; |
|
526 | + } |
|
506 | 527 | $result['region'] = $record['region']; |
507 | 528 | $result['geo'] = ['lat' => (float)$record['latitude'] , 'lon' => (float)$record['longitude']]; |
508 | 529 | } else { |
@@ -525,8 +546,9 @@ discard block |
||
525 | 546 | $result = ['status' => 'ok']; |
526 | 547 | $result['country'] = $record->country->isoCode; |
527 | 548 | // the two lines below are a dirty hack to take of the error in naming the UK federation |
528 | - if($result['country'] == 'GB') |
|
529 | - $result['country'] = 'UK'; |
|
549 | + if($result['country'] == 'GB') { |
|
550 | + $result['country'] = 'UK'; |
|
551 | + } |
|
530 | 552 | $result['region'] = $record->continent->name; |
531 | 553 | |
532 | 554 | $result['geo'] = ['lat' => (float)$record->location->latitude , 'lon' => (float)$record->location->longitude]; |
@@ -536,13 +558,16 @@ discard block |
||
536 | 558 | public function JSON_locateUser() { |
537 | 559 | header('Content-type: application/json; utf-8'); |
538 | 560 | |
539 | - if(empty(Config::$GEOIP['version']) || Config::$GEOIP['version'] == 0) |
|
540 | - echo json_encode(['status' => 'error', 'error' =>'Geolocation not supported']); |
|
541 | - if(Config::$GEOIP['version'] == 1) |
|
542 | - echo json_encode($this->locateUser()); |
|
543 | - if(Config::$GEOIP['version'] == 2) |
|
544 | - echo json_encode($this->locateUser2()); |
|
545 | -} |
|
561 | + if(empty(Config::$GEOIP['version']) || Config::$GEOIP['version'] == 0) { |
|
562 | + echo json_encode(['status' => 'error', 'error' =>'Geolocation not supported']); |
|
563 | + } |
|
564 | + if(Config::$GEOIP['version'] == 1) { |
|
565 | + echo json_encode($this->locateUser()); |
|
566 | + } |
|
567 | + if(Config::$GEOIP['version'] == 2) { |
|
568 | + echo json_encode($this->locateUser2()); |
|
569 | + } |
|
570 | + } |
|
546 | 571 | |
547 | 572 | /** |
548 | 573 | * Produce support data prepared within {@link GUI::profileAttributes()} |
@@ -594,27 +619,31 @@ discard block |
||
594 | 619 | $G=$idp['geo']; |
595 | 620 | if(isset($G['lon'])) { |
596 | 621 | $d1 = $this->geoDistance($L,$G); |
597 | - if( $d1 < $dist) |
|
598 | - $dist = $d1; |
|
622 | + if( $d1 < $dist) { |
|
623 | + $dist = $d1; |
|
624 | + } |
|
599 | 625 | } else { |
600 | 626 | foreach ($G as $g) { |
601 | 627 | $d1 = $this->geoDistance($L,$g); |
602 | - if( $d1 < $dist) |
|
603 | - $dist = $d1; |
|
628 | + if( $d1 < $dist) { |
|
629 | + $dist = $d1; |
|
630 | + } |
|
604 | 631 | } |
605 | 632 | } |
606 | 633 | } |
607 | - if($dist > 100) |
|
608 | - $dist=10000; |
|
634 | + if($dist > 100) { |
|
635 | + $dist=10000; |
|
636 | + } |
|
609 | 637 | $d = sprintf("%06d",$dist); |
610 | 638 | $R[$idp['entityID']] = $d." ".$idp['title']; |
611 | 639 | } |
612 | 640 | asort($R); |
613 | 641 | foreach (array_keys($R) as $r) { |
614 | - if($this->version == 1) |
|
615 | - $outarray[] = ['id'=>$r, 'title'=>$T[$r]]; |
|
616 | - else |
|
617 | - $outarray[] = ['idp'=>$r, 'title'=>$T[$r]]; |
|
642 | + if($this->version == 1) { |
|
643 | + $outarray[] = ['id'=>$r, 'title'=>$T[$r]]; |
|
644 | + } else { |
|
645 | + $outarray[] = ['idp'=>$r, 'title'=>$T[$r]]; |
|
646 | + } |
|
618 | 647 | } |
619 | 648 | return($outarray); |
620 | 649 | } |
@@ -632,25 +661,27 @@ discard block |
||
632 | 661 | if( isset($_REQUEST['device']) && isset($Dev[$_REQUEST['device']]) && (!isset($device['options']['hidden']) || $device['options']['hidden'] == 0)) { |
633 | 662 | $dev_id = $_REQUEST['device']; |
634 | 663 | $device = $Dev[$dev_id]; |
635 | - if($this->version == 1) |
|
636 | - return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
637 | - else |
|
638 | - return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
664 | + if($this->version == 1) { |
|
665 | + return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
666 | + } else { |
|
667 | + return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
668 | + } |
|
639 | 669 | } |
640 | 670 | $browser = $_SERVER['HTTP_USER_AGENT']; |
641 | 671 | debug(4,"HTTP_USER_AGENT=$browser\n"); |
642 | 672 | foreach ($Dev as $dev_id => $device) { |
643 | - if(!isset($device['match'])) |
|
644 | - continue; |
|
673 | + if(!isset($device['match'])) { |
|
674 | + continue; |
|
675 | + } |
|
645 | 676 | if(preg_match('/'.$device['match'].'/',$browser)) { |
646 | 677 | if(!isset($device['options']['hidden']) || $device['options']['hidden'] == 0) { |
647 | 678 | debug(4,"Browser_id: $dev_id\n"); |
648 | - if($this->version == 1) |
|
649 | - return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
650 | - else |
|
651 | - return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
652 | - } |
|
653 | - else { |
|
679 | + if($this->version == 1) { |
|
680 | + return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
681 | + } else { |
|
682 | + return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]); |
|
683 | + } |
|
684 | + } else { |
|
654 | 685 | debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n"); |
655 | 686 | return(false); |
656 | 687 | } |
@@ -662,10 +693,11 @@ discard block |
||
662 | 693 | |
663 | 694 | public function JSON_detectOS() { |
664 | 695 | $return_array=$this->detectOS(); |
665 | - if($return_array) |
|
666 | - $status = 1; |
|
667 | - else |
|
668 | - $status = 0; |
|
696 | + if($return_array) { |
|
697 | + $status = 1; |
|
698 | + } else { |
|
699 | + $status = 0; |
|
700 | + } |
|
669 | 701 | echo $this->return_json($return_array,$status); |
670 | 702 | } |
671 | 703 |
@@ -78,9 +78,6 @@ |
||
78 | 78 | * It is CRUTCIAL that the constructor sets $this->supportedEapMethods to an array of methods |
79 | 79 | * available for the particular device. |
80 | 80 | * {@source} |
81 | - * @param string $device a pointer to a device module, which must |
|
82 | - * be an index of one of the devices defined in the {@link Devices} |
|
83 | - * array in {@link devices.php}. |
|
84 | 81 | * @final not to be redefined |
85 | 82 | */ |
86 | 83 | final public function __construct() { |
@@ -108,8 +108,9 @@ discard block |
||
108 | 108 | $outerId = 0; |
109 | 109 | if (isset($this->attributes['internal:use_anon_outer']) && $this->attributes['internal:use_anon_outer'][0] == "1" && isset($this->attributes['internal:realm'])) { |
110 | 110 | $outerId = "@" . $this->attributes['internal:realm'][0]; |
111 | - if (isset($this->attributes['internal:anon_local_value'])) |
|
112 | - $outerId = $this->attributes['internal:anon_local_value'][0] . $outerId; |
|
111 | + if (isset($this->attributes['internal:anon_local_value'])) { |
|
112 | + $outerId = $this->attributes['internal:anon_local_value'][0] . $outerId; |
|
113 | + } |
|
113 | 114 | } |
114 | 115 | |
115 | 116 | // define networks |
@@ -117,26 +118,30 @@ discard block |
||
117 | 118 | $networkUuid = uuid($prefix, $ssid); |
118 | 119 | $eapPrettyprint = EAP::eapDisplayName($this->selected_eap); |
119 | 120 | // ONC has its own enums, and guess what, they don't always match |
120 | - if ($eapPrettyprint["OUTER"] == "PEAP" && $eapPrettyprint["INNER"] == "MSCHAPV2") |
|
121 | - // the dictionary entry EAP-MSCHAPv2 does not work. Setting MSCHAPv2 does. (ChromeOS 50) |
|
121 | + if ($eapPrettyprint["OUTER"] == "PEAP" && $eapPrettyprint["INNER"] == "MSCHAPV2") { |
|
122 | + // the dictionary entry EAP-MSCHAPv2 does not work. Setting MSCHAPv2 does. (ChromeOS 50) |
|
122 | 123 | $eapPrettyprint["INNER"] = "MSCHAPv2"; |
124 | + } |
|
123 | 125 | if ($eapPrettyprint["OUTER"] == "TTLS" && $eapPrettyprint["INNER"] == "MSCHAPV2") { |
124 | 126 | $eapPrettyprint["OUTER"] = "EAP-TTLS"; |
125 | 127 | $eapPrettyprint["INNER"] = "MSCHAPv2"; |
126 | 128 | } |
127 | - if ($eapPrettyprint["OUTER"] == "TLS") |
|
128 | - $eapPrettyprint["OUTER"] = "EAP-TLS"; |
|
129 | + if ($eapPrettyprint["OUTER"] == "TLS") { |
|
130 | + $eapPrettyprint["OUTER"] = "EAP-TLS"; |
|
131 | + } |
|
129 | 132 | // define EAP properties |
130 | 133 | |
131 | 134 | $eaparray = array("Outer" => $eapPrettyprint["OUTER"]); |
132 | - if ($eapPrettyprint["INNER"] == "MSCHAPv2") |
|
133 | - $eaparray["Inner"] = $eapPrettyprint["INNER"]; |
|
135 | + if ($eapPrettyprint["INNER"] == "MSCHAPv2") { |
|
136 | + $eaparray["Inner"] = $eapPrettyprint["INNER"]; |
|
137 | + } |
|
134 | 138 | $eaparray["SaveCredentials"] = true; |
135 | 139 | $eaparray["ServerCARefs"] = $caRefs; // maybe takes just one CA? |
136 | 140 | $eaparray["UseSystemCAs"] = false; |
137 | 141 | |
138 | - if ($outerId) |
|
139 | - $eaparray["AnonymousIdentity"] = "$outerId"; |
|
142 | + if ($outerId) { |
|
143 | + $eaparray["AnonymousIdentity"] = "$outerId"; |
|
144 | + } |
|
140 | 145 | |
141 | 146 | $jsonArray["NetworkConfigurations"][] = [ |
142 | 147 | "GUID" => $networkUuid, |
@@ -308,6 +308,9 @@ |
||
308 | 308 | |
309 | 309 | /** |
310 | 310 | * produce PEAP, TLS and TTLS configuration files for Windows 8 |
311 | + * @param string $auth |
|
312 | + * @param string $encryption |
|
313 | + * @param integer $i |
|
311 | 314 | */ |
312 | 315 | private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) { |
313 | 316 | $profile_file_contents = '<?xml version="1.0"?> |
@@ -46,10 +46,12 @@ discard block |
||
46 | 46 | // create a list of profiles to be deleted after installation |
47 | 47 | $delProfiles = []; |
48 | 48 | foreach ($delSSIDs as $ssid => $cipher) { |
49 | - if($cipher == 'DEL') |
|
50 | - $delProfiles[] = $ssid; |
|
51 | - if($cipher == 'TKIP') |
|
52 | - $delProfiles[] = $ssid.' (TKIP)'; |
|
49 | + if($cipher == 'DEL') { |
|
50 | + $delProfiles[] = $ssid; |
|
51 | + } |
|
52 | + if($cipher == 'TKIP') { |
|
53 | + $delProfiles[] = $ssid.' (TKIP)'; |
|
54 | + } |
|
53 | 55 | } |
54 | 56 | |
55 | 57 | |
@@ -76,11 +78,13 @@ discard block |
||
76 | 78 | |
77 | 79 | $this->writeProfilesNSH($WindowsProfile, $CA_files,$set_wired); |
78 | 80 | $this->writeAdditionalDeletes($delProfiles); |
79 | - if(isset($additional_deletes) && count($additional_deletes)) |
|
80 | - $this->writeAdditionalDeletes($additional_deletes); |
|
81 | + if(isset($additional_deletes) && count($additional_deletes)) { |
|
82 | + $this->writeAdditionalDeletes($additional_deletes); |
|
83 | + } |
|
81 | 84 | $this->copyFiles($this->selected_eap); |
82 | - if(isset($this->attributes['internal:logo_file'])) |
|
83 | - $this->combineLogo($this->attributes['internal:logo_file']); |
|
85 | + if(isset($this->attributes['internal:logo_file'])) { |
|
86 | + $this->combineLogo($this->attributes['internal:logo_file']); |
|
87 | + } |
|
84 | 88 | $this->writeMainNSH($this->selected_eap,$this->attributes); |
85 | 89 | $this->compileNSIS(); |
86 | 90 | $installer_path = $this->signInstaller($this->attributes); |
@@ -97,13 +101,15 @@ discard block |
||
97 | 101 | if($ssid_ct > 1) { |
98 | 102 | if($ssid_ct > 2) { |
99 | 103 | $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to the following networks:"),implode(', ',Config::$CONSORTIUM['ssid']))." "; |
100 | - } else |
|
101 | - $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." "; |
|
104 | + } else { |
|
105 | + $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." "; |
|
106 | + } |
|
102 | 107 | $i = 0; |
103 | 108 | foreach ($this->attributes['internal:SSID'] as $ssid=>$v) { |
104 | 109 | if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) { |
105 | - if($i > 0) |
|
106 | - $out .= ", "; |
|
110 | + if($i > 0) { |
|
111 | + $out .= ", "; |
|
112 | + } |
|
107 | 113 | $i++; |
108 | 114 | $out .= "<strong>$ssid</strong>"; |
109 | 115 | } |
@@ -111,9 +117,9 @@ discard block |
||
111 | 117 | $out .= "<p>"; |
112 | 118 | } |
113 | 119 | |
114 | -if($this->eap == EAP::$TLS) |
|
120 | +if($this->eap == EAP::$TLS) { |
|
115 | 121 | $out .= _("In order to connect to the network you will need an a personal certificate in the form of a p12 file. You should obtain this certificate from your home institution. Consult the support page to find out how this certificate can be obtained. Such certificate files are password protected. You should have both the file and the password available during the installation process."); |
116 | -else { |
|
122 | +} else { |
|
117 | 123 | $out .= _("In order to connect to the network you will need an account from your home institution. You should consult the support page to find out how this account can be obtained. It is very likely that your account is already activated."); |
118 | 124 | $out .= "<p>"; |
119 | 125 | $out .= _("When you are connecting to the network for the first time, Windows will pop up a login box, where you should enter your user name and password. This information will be saved so that you will reconnect to the network automatically each time you are in the range."); |
@@ -122,8 +128,9 @@ discard block |
||
122 | 128 | $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." "; |
123 | 129 | $i = 0; |
124 | 130 | foreach ($this->attributes['internal:SSID'] as $ssid=>$v) { |
125 | - if($i > 0) |
|
126 | - $out .= ", "; |
|
131 | + if($i > 0) { |
|
132 | + $out .= ", "; |
|
133 | + } |
|
127 | 134 | $i++; |
128 | 135 | $out .= "<strong>$ssid</strong>"; |
129 | 136 | } |
@@ -176,26 +183,29 @@ discard block |
||
176 | 183 | <eapTls:DisableUserPromptForServerValidation>true</eapTls:DisableUserPromptForServerValidation> |
177 | 184 | <eapTls:ServerNames>'.$servers.'</eapTls:ServerNames>'; |
178 | 185 | if($ca_array) { |
179 | -foreach ($ca_array as $CA) |
|
186 | +foreach ($ca_array as $CA) { |
|
180 | 187 | if($CA['root']) |
181 | 188 | $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n"; |
182 | 189 | } |
190 | +} |
|
183 | 191 | $profile_file_contents .= '</eapTls:ServerValidation> |
184 | 192 | '; |
185 | -if(isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on') |
|
193 | +if(isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on') { |
|
186 | 194 | $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>'; |
187 | -else |
|
195 | +} else { |
|
188 | 196 | $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>'; |
197 | +} |
|
189 | 198 | $profile_file_contents .= ' |
190 | 199 | </eapTls:EapType> |
191 | 200 | </baseEap:Eap> |
192 | 201 | </Config> |
193 | 202 | '; |
194 | 203 | } elseif ( $eap == EAP::$PEAP_MSCHAP2) { |
195 | -if(isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on') |
|
204 | +if(isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on') { |
|
196 | 205 | $nea = 'true'; |
197 | -else |
|
206 | +} else { |
|
198 | 207 | $nea = 'false'; |
208 | +} |
|
199 | 209 | $profile_file_contents .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId> |
200 | 210 | </EapMethod> |
201 | 211 | '; |
@@ -207,10 +217,11 @@ discard block |
||
207 | 217 | <DisableUserPromptForServerValidation>true</DisableUserPromptForServerValidation> |
208 | 218 | <ServerNames>'.$servers.'</ServerNames>'; |
209 | 219 | if($ca_array) { |
210 | -foreach ($ca_array as $CA) |
|
220 | +foreach ($ca_array as $CA) { |
|
211 | 221 | if($CA['root']) |
212 | 222 | $w8_ext .= "<TrustedRootCA>".$CA['sha1']."</TrustedRootCA>\n"; |
213 | 223 | } |
224 | +} |
|
214 | 225 | $w8_ext .= '</ServerValidation> |
215 | 226 | <FastReconnect>true</FastReconnect> |
216 | 227 | <InnerEapOptional>false</InnerEapOptional> |
@@ -228,12 +239,13 @@ discard block |
||
228 | 239 | <IdentityPrivacy xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV2"> |
229 | 240 | <EnableIdentityPrivacy>true</EnableIdentityPrivacy> |
230 | 241 | '; |
231 | -if(isset($outer_user) && $outer_user) |
|
232 | -$w8_ext .='<AnonymousUserName>'.$outer_user.'</AnonymousUserName> |
|
242 | +if(isset($outer_user) && $outer_user) { |
|
243 | + $w8_ext .='<AnonymousUserName>'.$outer_user.'</AnonymousUserName> |
|
233 | 244 | '; |
234 | -else |
|
235 | -$w8_ext .='<AnonymousUserName/> |
|
245 | +} else { |
|
246 | + $w8_ext .='<AnonymousUserName/> |
|
236 | 247 | '; |
248 | +} |
|
237 | 249 | $w8_ext .='</IdentityPrivacy> |
238 | 250 | </PeapExtensions> |
239 | 251 | '; |
@@ -251,10 +263,11 @@ discard block |
||
251 | 263 | <ServerValidation> |
252 | 264 | <ServerNames>'.$servers.'</ServerNames> '; |
253 | 265 | if($ca_array) { |
254 | -foreach ($ca_array as $CA) |
|
266 | +foreach ($ca_array as $CA) { |
|
255 | 267 | if($CA['root']) |
256 | 268 | $w8_ext .= "<TrustedRootCAHash>".chunk_split($CA['sha1'],2,' ')."</TrustedRootCAHash>\n"; |
257 | 269 | } |
270 | +} |
|
258 | 271 | $w8_ext .='<DisablePrompt>true</DisablePrompt> |
259 | 272 | </ServerValidation> |
260 | 273 | <Phase2Authentication> |
@@ -274,13 +287,14 @@ discard block |
||
274 | 287 | if($use_anon == 1) { |
275 | 288 | $w8_ext .= '<IdentityPrivacy>true</IdentityPrivacy> |
276 | 289 | '; |
277 | - if(isset($outer_id) && $outer_id) |
|
278 | - $w8_ext .='<AnonymousIdentity>'.$outer_id.'</AnonymousIdentity> |
|
290 | + if(isset($outer_id) && $outer_id) { |
|
291 | + $w8_ext .='<AnonymousIdentity>'.$outer_id.'</AnonymousIdentity> |
|
279 | 292 | '; |
280 | - else |
|
281 | - $w8_ext .='<AnonymousIdentity/> |
|
293 | + } else { |
|
294 | + $w8_ext .='<AnonymousIdentity/> |
|
282 | 295 | '; |
283 | -} else { |
|
296 | + } |
|
297 | + } else { |
|
284 | 298 | $w8_ext .= '<IdentityPrivacy>false</IdentityPrivacy> |
285 | 299 | '; |
286 | 300 | } |
@@ -330,12 +344,13 @@ discard block |
||
330 | 344 | <useOneX>true</useOneX> |
331 | 345 | </authEncryption> |
332 | 346 | '; |
333 | -if($auth == 'WPA2') |
|
334 | -$profile_file_contents .= '<PMKCacheMode>enabled</PMKCacheMode> |
|
347 | +if($auth == 'WPA2') { |
|
348 | + $profile_file_contents .= '<PMKCacheMode>enabled</PMKCacheMode> |
|
335 | 349 | <PMKCacheTTL>720</PMKCacheTTL> |
336 | 350 | <PMKCacheSize>128</PMKCacheSize> |
337 | 351 | <preAuthMode>disabled</preAuthMode> |
338 | 352 | '; |
353 | +} |
|
339 | 354 | $profile_file_contents .= '<OneX xmlns="http://www.microsoft.com/networking/OneX/v1"> |
340 | 355 | <cacheUserData>true</cacheUserData> |
341 | 356 | <authMode>user</authMode> |
@@ -348,8 +363,9 @@ discard block |
||
348 | 363 | </WLANProfile> |
349 | 364 | '; |
350 | 365 | |
351 | -if(! is_dir('w8')) |
|
366 | +if(! is_dir('w8')) { |
|
352 | 367 | mkdir('w8'); |
368 | +} |
|
353 | 369 | $xml_f_name = "w8/wlan_prof-$i.xml"; |
354 | 370 | $xml_f = fopen($xml_f_name,'w'); |
355 | 371 | fwrite($xml_f,$profile_file_contents. $eap_config['w8']. $closing) ; |
@@ -375,8 +391,9 @@ discard block |
||
375 | 391 | </LANProfile> |
376 | 392 | '; |
377 | 393 | |
378 | -if(! is_dir('w8')) |
|
394 | +if(! is_dir('w8')) { |
|
379 | 395 | mkdir('w8'); |
396 | +} |
|
380 | 397 | $xml_f_name = "w8/lan_prof.xml"; |
381 | 398 | $xml_f = fopen($xml_f_name,'w'); |
382 | 399 | fwrite($xml_f,$profile_file_contents. $eap_config['w8']. $closing) ; |
@@ -389,8 +406,9 @@ discard block |
||
389 | 406 | private function writeMainNSH($eap,$attr) { |
390 | 407 | debug(4,"writeMainNSH"); debug(4,$attr); |
391 | 408 | $fcontents = "!define W8\n"; |
392 | -if(Config::$NSIS_VERSION >= 3) |
|
409 | +if(Config::$NSIS_VERSION >= 3) { |
|
393 | 410 | $fcontents .= "Unicode true\n"; |
411 | +} |
|
394 | 412 | |
395 | 413 | |
396 | 414 | $EAP_OPTS = [ |
@@ -410,8 +428,9 @@ discard block |
||
410 | 428 | $fcontents .= '!define '.$eap_str; |
411 | 429 | $fcontents .= "\n".'!define EXECLEVEL "'.$exec_level.'"'; |
412 | 430 | |
413 | -if($attr['internal:profile_count'][0] > 1) |
|
414 | -$fcontents .= "\n".'!define USER_GROUP "'.$this->translateString(str_replace('"','$\\"',$attr['profile:name'][0]), $this->code_page).'"'; |
|
431 | +if($attr['internal:profile_count'][0] > 1) { |
|
432 | + $fcontents .= "\n".'!define USER_GROUP "'.$this->translateString(str_replace('"','$\\"',$attr['profile:name'][0]), $this->code_page).'"'; |
|
433 | +} |
|
415 | 434 | $fcontents .= ' |
416 | 435 | Caption "'. $this->translateString(sprintf(sprint_nsi(_("%s installer for %s")),Config::$CONSORTIUM['name'],$attr['general:instname'][0]), $this->code_page).'" |
417 | 436 | !define APPLICATION "'. $this->translateString(sprintf(sprint_nsi(_("%s installer for %s")),Config::$CONSORTIUM['name'],$attr['general:instname'][0]), $this->code_page).'" |
@@ -434,9 +453,10 @@ discard block |
||
434 | 453 | !endif |
435 | 454 | '; |
436 | 455 | |
437 | -if(isset($this->attributes['media:wired'][0]) && $attr['media:wired'][0] == 'on') |
|
456 | +if(isset($this->attributes['media:wired'][0]) && $attr['media:wired'][0] == 'on') { |
|
438 | 457 | $fcontents .= '!define WIRED |
439 | 458 | '; |
459 | +} |
|
440 | 460 | |
441 | 461 | $f = fopen('main.nsh','w'); |
442 | 462 | fwrite($f, $fcontents); |
@@ -448,8 +468,9 @@ discard block |
||
448 | 468 | debug(4,"writeProfilesNSH"); |
449 | 469 | debug(4,$P); |
450 | 470 | $fcontents = ''; |
451 | - foreach($P as $p) |
|
452 | - $fcontents .= "!insertmacro define_wlan_profile $p\n"; |
|
471 | + foreach($P as $p) { |
|
472 | + $fcontents .= "!insertmacro define_wlan_profile $p\n"; |
|
473 | + } |
|
453 | 474 | |
454 | 475 | $f = fopen('profiles.nsh','w'); |
455 | 476 | fwrite($f, $fcontents); |