Completed
Branch master (03ec64)
by Brook
14:43
created
core/Options.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,8 +79,9 @@
 block discarded – undo
79 79
         $this->type_db = [];
80 80
         debug(3,"--- BEGIN constructing Options instance ---\n");
81 81
         $options = DBConnection::exec(Options::$DB_TYPE, "SELECT name,type,flag from profile_option_dict ORDER BY name");
82
-        while($a = mysqli_fetch_object($options))
83
-            $this->type_db[$a->name]       =  ["type" => $a->type, "flag" => $a->flag];
82
+        while($a = mysqli_fetch_object($options)) {
83
+                    $this->type_db[$a->name]       =  ["type" => $a->type, "flag" => $a->flag];
84
+        }
84 85
         $this->type_db["general:logo_url"] =  ["type" => "string", "flag" => NULL];
85 86
         $this->type_db["eap:ca_url"]       =  ["type" => "string", "flag" => NULL];
86 87
         $this->type_db["internal:country"] =  ["type" => "string", "flag" => NULL];
Please login to merge, or discard this patch.
core/Profile.php 1 patch
Braces   +120 added lines, -88 removed lines patch added patch discarded remove patch
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
 
241 241
         $idpoptions = $idp->getAttributes();
242 242
 
243
-        foreach ($idpoptions as $the_attr)
244
-            $temparray[] = [
243
+        foreach ($idpoptions as $the_attr) {
244
+                    $temparray[] = [
245 245
                 "name" => $the_attr["name"],
246 246
                 "value" => $the_attr["value"],
247 247
                 "level" => $the_attr["level"],
@@ -250,30 +250,35 @@  discard block
 block discarded – undo
250 250
                 "device" => NULL,
251 251
                 "eapmethod" => NULL,
252 252
             ];
253
+        }
253 254
 
254 255
         $this->priv_attributes = [];
255 256
 
256 257
         // check sanity (device and eapmethod are mutually exclusive) and first batch of adding (method level)
257 258
 
258 259
         foreach ($temparray as $attrib) {
259
-            if ($attrib["device"] != NULL && $attrib["eapmethod"] != NULL)
260
-                debug(2, "Sanity check failed - device and eapmethod are set!\n");
260
+            if ($attrib["device"] != NULL && $attrib["eapmethod"] != NULL) {
261
+                            debug(2, "Sanity check failed - device and eapmethod are set!\n");
262
+            }
261 263
         }
262 264
 
263 265
         foreach ($temparray as $attrib) {
264
-            if ($attrib["device"] != NULL || $attrib["eapmethod"] != NULL)
265
-                $this->priv_attributes[] = $attrib;
266
+            if ($attrib["device"] != NULL || $attrib["eapmethod"] != NULL) {
267
+                            $this->priv_attributes[] = $attrib;
268
+            }
266 269
         }
267 270
         // pick all attributes which are profile specific and place into final array if no eap/device-specific exists
268 271
 
269 272
         foreach ($temparray as $attrib) {
270 273
             if ($attrib["level"] == "Profile") {
271 274
                 $ignore = "";
272
-                foreach ($this->priv_attributes as $approved_attrib)
273
-                    if ($attrib["name"] == $approved_attrib["name"] && $approved_attrib["level"] != "IdP" && $approved_attrib["level"] != "Profile")
275
+                foreach ($this->priv_attributes as $approved_attrib) {
276
+                                    if ($attrib["name"] == $approved_attrib["name"] && $approved_attrib["level"] != "IdP" && $approved_attrib["level"] != "Profile")
274 277
                         $ignore = "YES";
275
-                if ($ignore != "YES")
276
-                    $this->priv_attributes[] = $attrib;
278
+                }
279
+                if ($ignore != "YES") {
280
+                                    $this->priv_attributes[] = $attrib;
281
+                }
277 282
             }
278 283
         }
279 284
 
@@ -282,11 +287,13 @@  discard block
 block discarded – undo
282 287
         foreach ($temparray as $attrib) {
283 288
             if ($attrib["level"] == "IdP") {
284 289
                 $ignore = "";
285
-                foreach ($this->priv_attributes as $approved_attrib)
286
-                    if ($attrib["name"] == $approved_attrib["name"] && $approved_attrib["level"] != "IdP")
290
+                foreach ($this->priv_attributes as $approved_attrib) {
291
+                                    if ($attrib["name"] == $approved_attrib["name"] && $approved_attrib["level"] != "IdP")
287 292
                         $ignore = "YES";
288
-                if ($ignore != "YES")
289
-                    $this->priv_attributes[] = $attrib;
293
+                }
294
+                if ($ignore != "YES") {
295
+                                    $this->priv_attributes[] = $attrib;
296
+                }
290 297
             }
291 298
         }
292 299
 
@@ -315,8 +322,9 @@  discard block
 block discarded – undo
315 322
         $exec_query = DBConnection::exec(Profile::$DB_TYPE, "SELECT profile_id FROM profile WHERE realm LIKE '%@$realm'");
316 323
         if ($a = mysqli_fetch_object($exec_query)) {
317 324
             return $a->profile_id;
318
-        } else
319
-            return FALSE;
325
+        } else {
326
+                    return FALSE;
327
+        }
320 328
     }
321 329
     
322 330
     /**
@@ -356,15 +364,15 @@  discard block
 block discarded – undo
356 364
                 if ($lc < $cache->tm) {
357 365
                     debug(4, "Installer cached:$cache->download_path\n");
358 366
                     return(['cache'=>$cache->download_path,'mime'=>$cache->mime]);
367
+                } else {
368
+                                    return NULL;
359 369
                 }
360
-                else
361
-                    return NULL;
370
+            } else {
371
+                            return NULL;
362 372
             }
363
-            else
364
-                return NULL;
373
+        } else {
374
+                    return NULL;
365 375
         }
366
-        else
367
-            return NULL;
368 376
     }
369 377
 
370 378
     /**
@@ -405,20 +413,23 @@  discard block
 block discarded – undo
405 413
     public function getUserDownloadStats($device = 0) {
406 414
         $returnarray = [];
407 415
         $numbers_q = DBConnection::exec(Profile::$DB_TYPE, "SELECT device_id, SUM(downloads_user) AS downloads_user FROM downloads WHERE profile_id = $this->identifier GROUP BY device_id");
408
-        while ($a = mysqli_fetch_object($numbers_q))
409
-            $returnarray[$a->device_id] = $a->downloads_user;
416
+        while ($a = mysqli_fetch_object($numbers_q)) {
417
+                    $returnarray[$a->device_id] = $a->downloads_user;
418
+        }
410 419
         if ($device !== 0) {
411
-            if (isset($returnarray[$device]))
412
-                return $returnarray[$device];
413
-            else
414
-                return 0;
420
+            if (isset($returnarray[$device])) {
421
+                            return $returnarray[$device];
422
+            } else {
423
+                            return 0;
424
+            }
415 425
         }
416 426
         // we should pretty-print the device names
417 427
         $finalarray = [];
418 428
         $devlist = Devices::listDevices();
419
-        foreach ($returnarray as $dev_id => $count)
420
-            if (isset($devlist[$dev_id]))
429
+        foreach ($returnarray as $dev_id => $count) {
430
+                    if (isset($devlist[$dev_id]))
421 431
                     $finalarray[$devlist[$dev_id]['display']] = $count;
432
+        }
422 433
         return $finalarray;
423 434
     }
424 435
 
@@ -434,15 +445,16 @@  discard block
 block discarded – undo
434 445
         if ($device !== 0) {
435 446
             $device = DBConnection::escape_value(Profile::$DB_TYPE, $device);
436 447
             $devicetext = "AND device_id = '$device'";
448
+        } else {
449
+                    $devicetext = "";
437 450
         }
438
-        else
439
-            $devicetext = "";
440 451
         DBConnection::exec(Profile::$DB_TYPE, "DELETE FROM profile_option WHERE profile_id = $this->identifier $devicetext AND eap_method_id = $eap_type_id AND option_name NOT LIKE '%_file'");
441 452
         $this->updateFreshness();
442 453
         $exec_q = DBConnection::exec(Profile::$DB_TYPE, "SELECT row FROM profile_option WHERE profile_id = $this->identifier $devicetext AND eap_method_id = $eap_type_id");
443 454
         $return_array = [];
444
-        while ($a = mysqli_fetch_object($exec_q))
445
-            $return_array[$a->row] = "KILLME";
455
+        while ($a = mysqli_fetch_object($exec_q)) {
456
+                    $return_array[$a->row] = "KILLME";
457
+        }
446 458
         return $return_array;
447 459
     }
448 460
 
@@ -564,9 +576,10 @@  discard block
 block discarded – undo
564 576
         if ($complete_only == 0) {
565 577
             return $this->priv_eaptypes;
566 578
         } else {
567
-            foreach ($this->priv_eaptypes as $type)
568
-                if ($this->isEapTypeDefinitionComplete($type) === true)
579
+            foreach ($this->priv_eaptypes as $type) {
580
+                            if ($this->isEapTypeDefinitionComplete($type) === true)
569 581
                     $temparray[] = $type;
582
+            }
570 583
             return($temparray);
571 584
         }
572 585
     }
@@ -583,27 +596,31 @@  discard block
 block discarded – undo
583 596
         $outarray = [];
584 597
         $temparray = [];
585 598
         if ($eapmethod) {
586
-            foreach ($this->priv_attributes as $the_attr) 
587
-                if ($the_attr["eapmethod"] == $eapmethod)
599
+            foreach ($this->priv_attributes as $the_attr) {
600
+                            if ($the_attr["eapmethod"] == $eapmethod)
588 601
                     $temparray[] = $the_attr;
602
+            }
589 603
         } else
590 604
         if ($device) {
591
-            foreach ($this->priv_attributes as $the_attr)
592
-                if ($the_attr["device"] == $device)
605
+            foreach ($this->priv_attributes as $the_attr) {
606
+                            if ($the_attr["device"] == $device)
593 607
                     $temparray[] = $the_attr;
608
+            }
594 609
         };
595 610
 
596
-        foreach ($this->priv_attributes as $the_attr)
597
-            if ($the_attr["device"] == NULL && $the_attr["eapmethod"] == NULL)
611
+        foreach ($this->priv_attributes as $the_attr) {
612
+                    if ($the_attr["device"] == NULL && $the_attr["eapmethod"] == NULL)
598 613
                 $temparray[] = $the_attr;
614
+        }
599 615
 
600 616
 
601 617
         // return only options by one name, if asked for
602 618
 
603 619
         if ($option_name) {
604
-            foreach ($temparray as $the_attr)
605
-                if ($the_attr["name"] == $option_name)
620
+            foreach ($temparray as $the_attr) {
621
+                            if ($the_attr["name"] == $option_name)
606 622
                     $outarray[] = $the_attr;
623
+            }
607 624
         } else {
608 625
             $outarray = $temparray;
609 626
         }
@@ -631,15 +648,18 @@  discard block
 block discarded – undo
631 648
                 foreach ($ca_option as $one_ca) {
632 649
                     $x509 = new X509();
633 650
                     $ca_parsed = $x509->processCertificate($one_ca['value']);
634
-                    if ($ca_parsed['root'] == 1)
635
-                        return true;
651
+                    if ($ca_parsed['root'] == 1) {
652
+                                            return true;
653
+                    }
636 654
                 }
637 655
                 $missing[] = "eap:ca_file";
638 656
             }
639
-            if (count($ca_option) == 0)
640
-                $missing[] = "eap:ca_file";
641
-            if (count($cn_option) == 0)
642
-                $missing[] = "eap:server_name";
657
+            if (count($ca_option) == 0) {
658
+                            $missing[] = "eap:ca_file";
659
+            }
660
+            if (count($cn_option) == 0) {
661
+                            $missing[] = "eap:server_name";
662
+            }
643 663
             return $missing;
644 664
         } elseif ($eaptype["OUTER"] == PWD) {
645 665
             /*
@@ -662,8 +682,9 @@  discard block
 block discarded – undo
662 682
      * @return array of device ids display names and their status
663 683
      */
664 684
     public function listDevices($locale = 0) {
665
-        if ($locale == 0)
666
-            $locale = $this->lang_index;
685
+        if ($locale == 0) {
686
+                    $locale = $this->lang_index;
687
+        }
667 688
         $redirect_url = 0;
668 689
         $message = 0;
669 690
         $returnarray = [];
@@ -679,20 +700,21 @@  discard block
 block discarded – undo
679 700
             $dev = $factory->device;
680 701
             $redirect_url = getLocalisedValue($this->getAttributes("device-specific:redirect", 0, $d), $locale);
681 702
             $dev_status = AVAILABLE;
682
-            if(isset($D['options']) && isset($D['options']['message']) && $D['options']['message']) 
683
-               $message = $D['options']['message'];
684
-            else
685
-               $message = 0;
703
+            if(isset($D['options']) && isset($D['options']['message']) && $D['options']['message']) {
704
+                           $message = $D['options']['message'];
705
+            } else {
706
+                           $message = 0;
707
+            }
686 708
 
687 709
             if ($redirect_url === 0) {
688 710
                 if(isset($D['options']) && isset($D['options']['redirect']) && $D['options']['redirect']) {
689 711
                    $dev_status = HIDDEN;
690
-                }  else {
712
+                } else {
691 713
                    $eap = $dev->getPreferredEapType($preferred_eap);
692 714
                    if ($eap) {
693
-                       if (isset($EAP_options["eap-specific:customtext"][serialize($eap)]))
694
-                           $eap_customtext = $EAP_options["eap-specific:customtext"][serialize($eap)];
695
-                       else {
715
+                       if (isset($EAP_options["eap-specific:customtext"][serialize($eap)])) {
716
+                                                  $eap_customtext = $EAP_options["eap-specific:customtext"][serialize($eap)];
717
+                       } else {
696 718
                            $eap_customtext = getLocalisedValue($this->getAttributes("eap-specific:customtext", $eap, 0), $locale);
697 719
                            $EAP_options["eap-specific:customtext"][serialize($eap)] = $eap_customtext;
698 720
                        }
@@ -725,8 +747,9 @@  discard block
 block discarded – undo
725 747
             $level = $b['level'];
726 748
 //            $S[$l] = $z[$l];
727 749
             $value = $b['value'];
728
-            if (!isset($temp[$name][$level]))
729
-                $temp[$name][$level] = [];
750
+            if (!isset($temp[$name][$level])) {
751
+                            $temp[$name][$level] = [];
752
+            }
730 753
             if ($b['flag'] == 'ML') {
731 754
                 $v = unserialize($value);
732 755
                 $value = [$v['lang'] => $v['content']];
@@ -738,25 +761,29 @@  discard block
 block discarded – undo
738 761
             if ($flags[$name] == 'ML') {
739 762
                 $S = [];
740 763
                 if (isset($temp[$name]['Profile'])) {
741
-                    foreach ($temp[$name]['Profile'] as $z)
742
-                        foreach ($z as $l => $w)
764
+                    foreach ($temp[$name]['Profile'] as $z) {
765
+                                            foreach ($z as $l => $w)
743 766
                             $S[$l] = $w;
767
+                    }
744 768
                 }
745 769
                 if (!$S && isset($temp[$name]['IdP'])) {
746
-                    foreach ($temp[$name]['IdP'] as $z)
747
-                        foreach ($z as $l => $w)
770
+                    foreach ($temp[$name]['IdP'] as $z) {
771
+                                            foreach ($z as $l => $w)
748 772
                             $S[$l] = $w;
773
+                    }
749 774
                 }
750 775
                 $out[$name]['langs'] = $S;
751
-                if (isset($S[$this->lang_index]) || isset($S['C']))
752
-                    $out[$name][0] = (isset($S[$this->lang_index])) ? $S[$this->lang_index] : $S['C'];
776
+                if (isset($S[$this->lang_index]) || isset($S['C'])) {
777
+                                    $out[$name][0] = (isset($S[$this->lang_index])) ? $S[$this->lang_index] : $S['C'];
778
+                }
753 779
             } else {
754
-                if (isset($temp[$name]['Method']))
755
-                    $out[$name] = $temp[$name]['Method'];
756
-                elseif (isset($temp[$name]['Profile']))
757
-                    $out[$name] = $temp[$name]['Profile'];
758
-                else
759
-                    $out[$name] = $temp[$name]['IdP'];
780
+                if (isset($temp[$name]['Method'])) {
781
+                                    $out[$name] = $temp[$name]['Method'];
782
+                } elseif (isset($temp[$name]['Profile'])) {
783
+                                    $out[$name] = $temp[$name]['Profile'];
784
+                } else {
785
+                                    $out[$name] = $temp[$name]['IdP'];
786
+                }
760 787
             }
761 788
         }
762 789
         return($out);
@@ -794,20 +821,23 @@  discard block
 block discarded – undo
794 821
         $proper_config = FALSE;
795 822
         $attribs = $this->getCollapsedAttributes();
796 823
         // do we have enough to go live? Check if any of the configured EAP methods is completely configured ...
797
-        if (sizeof($this->getEapMethodsinOrderOfPreference(1)) > 0)
798
-            $proper_config = TRUE;
824
+        if (sizeof($this->getEapMethodsinOrderOfPreference(1)) > 0) {
825
+                    $proper_config = TRUE;
826
+        }
799 827
         // if not, it could still be that general redirect has been set
800 828
         if (!$proper_config) {
801
-            if (isset($attribs['device-specific:redirect']))
802
-                $proper_config = TRUE;
829
+            if (isset($attribs['device-specific:redirect'])) {
830
+                            $proper_config = TRUE;
831
+            }
803 832
             // TODO: or maybe just a per-device redirect? would be good enough...
804 833
         }
805 834
         // do we know at least one SSID to configure, or work with wired? If not, it's not ready...
806 835
         if (!isset($attribs['media:SSID']) &&
807 836
                 !isset($attribs['media:SSID_with_legacy']) &&
808 837
                 (!isset(Config::$CONSORTIUM['ssid']) || count(Config::$CONSORTIUM['ssid']) == 0) &&
809
-                !isset($attribs['media:wired']))
810
-            $proper_config = FALSE;
838
+                !isset($attribs['media:wired'])) {
839
+                    $proper_config = FALSE;
840
+        }
811 841
         return $proper_config;
812 842
     }
813 843
 
@@ -816,10 +846,11 @@  discard block
 block discarded – undo
816 846
      */
817 847
     public function prepShowtime() {
818 848
         $proper_config = $this->readyForShowtime();
819
-        if ($proper_config)
820
-            DBConnection::exec(Profile::$DB_TYPE, "UPDATE profile SET sufficient_config = TRUE WHERE profile_id = " . $this->identifier);
821
-        else
822
-            DBConnection::exec(Profile::$DB_TYPE, "UPDATE profile SET sufficient_config = FALSE WHERE profile_id = " . $this->identifier);
849
+        if ($proper_config) {
850
+                    DBConnection::exec(Profile::$DB_TYPE, "UPDATE profile SET sufficient_config = TRUE WHERE profile_id = " . $this->identifier);
851
+        } else {
852
+                    DBConnection::exec(Profile::$DB_TYPE, "UPDATE profile SET sufficient_config = FALSE WHERE profile_id = " . $this->identifier);
853
+        }
823 854
         $attribs = $this->getCollapsedAttributes();
824 855
         // if not enough info to go live, set FALSE
825 856
         // even if enough info is there, admin has the ultimate say: 
@@ -843,10 +874,11 @@  discard block
 block discarded – undo
843 874
         /* echo "<pre>";
844 875
           print_r($r);
845 876
           echo "</pre>"; */
846
-        if ($r[0] == "0")
847
-            return FALSE;
848
-        else
849
-            return TRUE;
877
+        if ($r[0] == "0") {
878
+                    return FALSE;
879
+        } else {
880
+                    return TRUE;
881
+        }
850 882
     }
851 883
 
852 884
     /**
Please login to merge, or discard this patch.
core/X509.php 1 patch
Braces   +25 added lines, -18 removed lines patch added patch discarded remove patch
@@ -81,11 +81,13 @@  discard block
 block discarded – undo
81 81
     # check that the certificate is OK
82 82
 //print "<pre>CA:\n$ca_pem</pre>\n";
83 83
     $myca = openssl_x509_read($ca_pem);
84
-    if ($myca == FALSE) 
85
-        return FALSE;
84
+    if ($myca == FALSE) {
85
+            return FALSE;
86
+    }
86 87
     $mydetails = openssl_x509_parse($myca);
87
-    if (!isset($mydetails['subject']))
88
-        return FALSE;
88
+    if (!isset($mydetails['subject'])) {
89
+            return FALSE;
90
+    }
89 91
     $md5 = openssl_digest($ca_der,'MD5');
90 92
     $sha1 = openssl_digest($ca_der,'SHA1');
91 93
     $out =  ["uuid" => uuid(), "pem" => $ca_pem, "der" => $ca_der, "md5"=>$md5, "sha1"=>$sha1, "name"=>$mydetails['name']];
@@ -106,10 +108,12 @@  discard block
 block discarded – undo
106 108
        $out['basicconstraints_set'] = 0;
107 109
     }
108 110
     
109
-    if( $out['ca'] > 0 && $out['root'] == 0 )
110
-     $mydetails['type'] = 'interm_ca';
111
-    if( $out['ca'] == 0 && $out['root'] == 0 )
112
-     $mydetails['type'] = 'server';
111
+    if( $out['ca'] > 0 && $out['root'] == 0 ) {
112
+         $mydetails['type'] = 'interm_ca';
113
+    }
114
+    if( $out['ca'] == 0 && $out['root'] == 0 ) {
115
+         $mydetails['type'] = 'server';
116
+    }
113 117
     $mydetails['sha1'] = $sha1;
114 118
     $out['full_details'] = $mydetails;
115 119
     
@@ -118,15 +122,17 @@  discard block
 block discarded – undo
118 122
     
119 123
     
120 124
     openssl_x509_export($myca, $output, FALSE);
121
-    if(preg_match('/^\s+Signature Algorithm:\s*(.*)\s*$/m', $output, $match)) 
122
-      $out['full_details']['signature_algorithm'] = $match[1];
123
-    else
124
-      $out['full_details']['signature_algorithm'] = $output;
125
+    if(preg_match('/^\s+Signature Algorithm:\s*(.*)\s*$/m', $output, $match)) {
126
+          $out['full_details']['signature_algorithm'] = $match[1];
127
+    } else {
128
+          $out['full_details']['signature_algorithm'] = $output;
129
+    }
125 130
  
126
-    if((preg_match('/^\s+Public-Key:\s*\((.*) bit\)\s*$/m', $output, $match)) && is_numeric($match[1])) 
127
-      $out['full_details']['public_key_length'] = $match[1];
128
-    else
129
-      $out['full_details']['public_key_length'] = $output;
131
+    if((preg_match('/^\s+Public-Key:\s*\((.*) bit\)\s*$/m', $output, $match)) && is_numeric($match[1])) {
132
+          $out['full_details']['public_key_length'] = $match[1];
133
+    } else {
134
+          $out['full_details']['public_key_length'] = $output;
135
+    }
130 136
     
131 137
     return $out;
132 138
 }
@@ -146,8 +152,9 @@  discard block
 block discarded – undo
146 152
   // maybe we got no real cert data at all? The code is hardened, but will
147 153
   // produce ugly WARNING level output in the logfiles, so let's avoid at least
148 154
   // the trivial case: if the file is empty, there's no cert in it
149
-  if ($cadata == "")
150
-      return $returnarray;
155
+  if ($cadata == "") {
156
+        return $returnarray;
157
+  }
151 158
   $start_c = strpos($cadata,"-----BEGIN CERTIFICATE-----" );
152 159
   if( $start_c !== FALSE) {
153 160
         $cadata = substr($cadata,$start_c);
Please login to merge, or discard this patch.
core/EAP.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -159,10 +159,12 @@
 block discarded – undo
159 159
             $out['METHOD'] = $eap["INNER"];
160 160
         } else {
161 161
             $out['EAP'] = 0;
162
-            if ($eap == EAP::$TTLS_PAP)
163
-                $out['METHOD'] = NE_PAP;
164
-            if ($eap == EAP::$TTLS_MSCHAP2)
165
-                $out['METHOD'] = NE_MSCHAP2;
162
+            if ($eap == EAP::$TTLS_PAP) {
163
+                            $out['METHOD'] = NE_PAP;
164
+            }
165
+            if ($eap == EAP::$TTLS_MSCHAP2) {
166
+                            $out['METHOD'] = NE_MSCHAP2;
167
+            }
166 168
         }
167 169
         return $out;
168 170
     }
Please login to merge, or discard this patch.
core/Helper.php 1 patch
Braces   +40 added lines, -30 removed lines patch added patch discarded remove patch
@@ -56,10 +56,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
core/UserAPI.php 1 patch
Braces   +139 added lines, -107 removed lines patch added patch discarded remove patch
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
core/User.php 1 patch
Braces   +27 added lines, -19 removed lines patch added patch discarded remove patch
@@ -130,12 +130,12 @@  discard block
 block discarded – undo
130 130
     public function getAttributes($option_name = 0) {
131 131
         if ($option_name) {
132 132
             $returnarray = [];
133
-            foreach ($this->priv_attributes as $the_attr)
134
-                if ($the_attr['name'] == $option_name)
133
+            foreach ($this->priv_attributes as $the_attr) {
134
+                            if ($the_attr['name'] == $option_name)
135 135
                     $returnarray[] = $the_attr;
136
+            }
136 137
             return $returnarray;
137
-        }
138
-        else {
138
+        } else {
139 139
             return $this->priv_attributes;
140 140
         }
141 141
     }
@@ -151,12 +151,13 @@  discard block
 block discarded – undo
151 151
         $escaped_name = DBConnection::escape_value(User::$DB_TYPE, $this->identifier);
152 152
         $attr_name = DBConnection::escape_value(User::$DB_TYPE, $attr_name);
153 153
         $attr_value = DBConnection::escape_value(User::$DB_TYPE, $attr_value);
154
-        if (!Config::$DB['userdb-readonly'])
155
-            DBConnection::exec(User::$DB_TYPE, "INSERT INTO user_options (user_id, option_name, option_value) VALUES('"
154
+        if (!Config::$DB['userdb-readonly']) {
155
+                    DBConnection::exec(User::$DB_TYPE, "INSERT INTO user_options (user_id, option_name, option_value) VALUES('"
156 156
                     . $escaped_name . "', '"
157 157
                     . $attr_name . "', '"
158 158
                     . $attr_value
159 159
                     . "')");
160
+        }
160 161
     }
161 162
 
162 163
     /**
@@ -171,8 +172,9 @@  discard block
 block discarded – undo
171 172
         DBConnection::exec(User::$DB_TYPE, "DELETE FROM user_options WHERE user_id = '$this->identifier' AND option_name NOT LIKE '%_file' AND option_name NOT LIKE 'user:fedadmin'");
172 173
         $exec_q = DBConnection::exec(User::$DB_TYPE, "SELECT id FROM user_options WHERE user_id = '$this->identifier' AND option_name NOT LIKE 'user:fedadmin'");
173 174
         $return_array = [];
174
-        while ($a = mysqli_fetch_object($exec_q))
175
-            $return_array[$a->row] = "KILLME";
175
+        while ($a = mysqli_fetch_object($exec_q)) {
176
+                    $return_array[$a->row] = "KILLME";
177
+        }
176 178
         return $return_array;
177 179
     }
178 180
 
@@ -200,14 +202,16 @@  discard block
 block discarded – undo
200 202
     public function isFederationAdmin($federation = 0) {
201 203
         $feds = $this->getAttributes("user:fedadmin");
202 204
         if ($federation === 0) {
203
-            if (count($feds) == 0)
204
-                return FALSE;
205
-            else
206
-                return TRUE;
205
+            if (count($feds) == 0) {
206
+                            return FALSE;
207
+            } else {
208
+                            return TRUE;
209
+            }
207 210
         } else {
208 211
             foreach ($feds as $fed) {
209
-                if (strtoupper($fed['value']) == strtoupper($federation))
210
-                    return TRUE;
212
+                if (strtoupper($fed['value']) == strtoupper($federation)) {
213
+                                    return TRUE;
214
+                }
211 215
             }
212 216
             return FALSE;
213 217
         }
@@ -230,9 +234,10 @@  discard block
 block discarded – undo
230 234
     */
231 235
     public function isIdPOwner($idp) {
232 236
        $temp = new IdP($idp);
233
-       foreach ($temp->owner() as $oneowner)
234
-            if ($oneowner['ID'] == $this->identifier)
237
+       foreach ($temp->owner() as $oneowner) {
238
+                   if ($oneowner['ID'] == $this->identifier)
235 239
                 return TRUE;
240
+       }
236 241
        return FALSE;
237 242
     }
238 243
 
@@ -256,8 +261,10 @@  discard block
 block discarded – undo
256 261
         $mail->addReplyTo(Config::$APPEARANCE['support-contact']['mail'], Config::$APPEARANCE['productname'] . " " ._("Feedback"));
257 262
         
258 263
         $mailaddr = $this->getAttributes("user:email");
259
-        if (count($mailaddr) == 0) // we don't know his mail address
264
+        if (count($mailaddr) == 0) {
265
+            // we don't know his mail address
260 266
             return FALSE;
267
+        }
261 268
         
262 269
         $mail->addAddress($mailaddr[0]["value"]);
263 270
         
@@ -268,8 +275,9 @@  discard block
 block discarded – undo
268 275
         // what do we want to say?
269 276
         $mail->Subject = $subject;
270 277
         $mail->Body = $content;
271
-        if (isset(Config::$CONSORTIUM['certfilename'], Config::$CONSORTIUM['keyfilename'], Config::$CONSORTIUM['keypass']))
272
-            $mail->sign(Config::$CONSORTIUM['certfilename'], Config::$CONSORTIUM['keyfilename'], Config::$CONSORTIUM['keypass']);
278
+        if (isset(Config::$CONSORTIUM['certfilename'], Config::$CONSORTIUM['keyfilename'], Config::$CONSORTIUM['keypass'])) {
279
+                    $mail->sign(Config::$CONSORTIUM['certfilename'], Config::$CONSORTIUM['keyfilename'], Config::$CONSORTIUM['keypass']);
280
+        }
273 281
 
274 282
 
275 283
         $sent = $mail->send();
Please login to merge, or discard this patch.
devices/linux/Linux.php 1 patch
Braces   +39 added lines, -28 removed lines patch added patch discarded remove patch
@@ -68,10 +68,11 @@  discard block
 block discarded – undo
68 68
 
69 69
      $out_string .= $this->printNMScript($SSIDs,$delSSIDs);
70 70
      $out_string .= $this->writeWpaConf($SSIDs);
71
-     if($this->selected_eap == EAP::$TLS) 
72
-       $out_string .= $this->printP12Dialog();
73
-     else
74
-       $out_string .= $this->printPasswordDialog();
71
+     if($this->selected_eap == EAP::$TLS) {
72
+            $out_string .= $this->printP12Dialog();
73
+     } else {
74
+            $out_string .= $this->printPasswordDialog();
75
+     }
75 76
      $out_string .= $this->checkNMResultAndCont();
76 77
      $installer_path = $this->installerBasename.'.sh';
77 78
       file_put_contents($installer_path, $out_string);
@@ -87,13 +88,15 @@  discard block
 block discarded – undo
87 88
     if($ssid_ct > 1) {
88 89
         if($ssid_ct > 2) {
89 90
             $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to the following networks:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
90
-        } else
91
-            $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
91
+        } else {
92
+                    $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
93
+        }
92 94
         $i = 0;
93 95
         foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
94 96
            if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) {
95
-             if($i > 0)
96
-           $out .= ", ";
97
+             if($i > 0) {
98
+                        $out .= ", ";
99
+             }
97 100
          $i++;
98 101
          $out .= "<strong>$ssid</strong>";
99 102
        }
@@ -101,9 +104,9 @@  discard block
 block discarded – undo
101 104
     $out .= "<p>";
102 105
     }
103 106
    $out .= _("The installer will create .cat_installer sub-directory in your home directory and will copy your server certificates there.");
104
-if($this->eap == EAP::$TLS)
107
+if($this->eap == EAP::$TLS) {
105 108
    $out .= _("In order to connect to the network you will need 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. Your p12 file will also be copied to the .cat_installer directory.");
106
-else {
109
+} else {
107 110
    $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.");
108 111
    $out .= "<p>";
109 112
    $out .= _("You will be requested to enter your account credentials during the installation. This information will be saved so that you will reconnect to the network automatically each time you are in the range.");
@@ -151,10 +154,11 @@  discard block
 block discarded – undo
151 154
 
152 155
 
153 156
 private function printProfileConfirmation() {
154
- if($this->attributes['internal:profile_count'][0] > 1)
155
-       $out = 'if ! ask "'.sprintf(_("This installer will only work properly if you are a member of %s and the user group: %s."),'${bf}'.$this->attributes['general:instname'][0].'${n}','${bf}'.$this->attributes['profile:name'][0]).'${n}"';
156
-    else
157
-       $out = 'if ! ask "'.sprintf(_("This installer will only work properly if you are a member of %s."),'${bf}'.$this->attributes['general:instname'][0]).'${n}"';
157
+ if($this->attributes['internal:profile_count'][0] > 1) {
158
+        $out = 'if ! ask "'.sprintf(_("This installer will only work properly if you are a member of %s and the user group: %s."),'${bf}'.$this->attributes['general:instname'][0].'${n}','${bf}'.$this->attributes['profile:name'][0]).'${n}"';
159
+ } else {
160
+           $out = 'if ! ask "'.sprintf(_("This installer will only work properly if you are a member of %s."),'${bf}'.$this->attributes['general:instname'][0]).'${n}"';
161
+    }
158 162
     $out .= ' "'._("Continue").'" 1 ; then exit; fi
159 163
 ';
160 164
   return $out;
@@ -405,9 +409,10 @@  discard block
 block discarded – undo
405 409
   eap='.$e['OUTER'].'
406 410
   ca_cert="${HOME}/'.$this->local_dir.'/ca.pem"
407 411
   identity="${USER_NAME}"';
408
-  if($this->server_name)
409
-    $out .= '
412
+  if($this->server_name) {
413
+      $out .= '
410 414
   domain_suffix_match="'.$this->server_name.'"';
415
+  }
411 416
   if($this->selected_eap == EAP::$TLS) {
412 417
     $out .= '
413 418
   private_key="${HOME}/'.$this->local_dir.'/user.p12"
@@ -416,10 +421,11 @@  discard block
 block discarded – undo
416 421
     $out .= '
417 422
   phase2="auth='.$e['INNER'].'"
418 423
   password="${PASSWORD}"';
419
-  if($this->attributes['internal:use_anon_outer'][0] == 1) 
420
-    $out .= '
424
+  if($this->attributes['internal:use_anon_outer'][0] == 1) {
425
+      $out .= '
421 426
   anonymous_identity="'.$this->attributes['internal:anon_local_value'][0].'@'.$this->attributes['internal:realm'][0].'"';
422 427
   }
428
+  }
423 429
     $out .= '
424 430
 }';
425 431
 }
@@ -504,8 +510,9 @@  discard block
 block discarded – undo
504 510
 
505 511
 
506 512
 private function glueServerNames($server_list) {
507
-  if(! $server_list)
508
-    return '';
513
+  if(! $server_list) {
514
+      return '';
515
+  }
509 516
   $A0 =  array_reverse(explode('.',array_shift($server_list)));
510 517
   $B = $A0;
511 518
   foreach($server_list as $a) {
@@ -517,12 +524,14 @@  discard block
 block discarded – undo
517 524
 }
518 525
 
519 526
 private function mkSubjectAltNameList($server_list) {
520
-  if(! $server_list)
521
-    return '';
527
+  if(! $server_list) {
528
+      return '';
529
+  }
522 530
   $out = '';
523 531
   foreach($server_list as $a) {
524
-     if($out)
525
-       $out .= ','; 
532
+     if($out) {
533
+            $out .= ',';
534
+     }
526 535
      $out .= "'DNS:$a'";
527 536
   }
528 537
   return $out;
@@ -680,9 +689,10 @@  discard block
 block discarded – undo
680 689
        $out .= '
681 690
             \'password\': \'$PASSWORD\',
682 691
             \'phase2-auth\': \''.strtolower($e['INNER']).'\',';
683
-         if($this->attributes['internal:use_anon_outer'][0] == 1) 
684
-              $out .= '
692
+         if($this->attributes['internal:use_anon_outer'][0] == 1) {
693
+                       $out .= '
685 694
             \'anonymous-identity\': \''.$this->attributes['internal:anon_local_value'][0].'@'.$this->attributes['internal:realm'][0].'\',';
695
+         }
686 696
     }
687 697
     $out .= '
688 698
         })
@@ -708,9 +718,10 @@  discard block
 block discarded – undo
708 718
      }
709 719
 //   create a list of profiles to be deleted after installation
710 720
      foreach ($delSSIDs as $ssid => $cipher) {
711
-         if($cipher == 'DEL')
712
-            $out .='
721
+         if($cipher == 'DEL') {
722
+                     $out .='
713 723
         self.delete_existing_connections(\''.$ssid.'\')';
724
+         }
714 725
      }
715 726
 
716 727
 $out .='
Please login to merge, or discard this patch.
devices/test_module/TestModule.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -99,12 +99,14 @@
 block discarded – undo
99 99
      $CA_files = $this->saveCertificateFiles('der');
100 100
   
101 101
     // copy a fixed file from the module Files directory
102
-       if(! $this->copyFile('Module.howto'))
103
-          debug(2, "copying of Module.howto failed\n");
102
+       if(! $this->copyFile('Module.howto')) {
103
+                 debug(2, "copying of Module.howto failed\n");
104
+       }
104 105
 
105 106
     // copy a fixed file from the module Files directory and saveunde a different name
106
-       if( ! $this->copyFile('test_file','copied_test_file'))
107
-          debug(2, "copying of Module.howto to copied_test_file failed\n");
107
+       if( ! $this->copyFile('test_file','copied_test_file')) {
108
+                 debug(2, "copying of Module.howto to copied_test_file failed\n");
109
+       }
108 110
        $this->dumpAttibutes('profile_attributes');
109 111
        $installer_path =  $this->zipInstaller($this->attributes);
110 112
        return($installer_path);
Please login to merge, or discard this patch.