Completed
Branch master (03ec64)
by Brook
14:43
created
core/SanityTests.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -138,6 +138,9 @@
 block discarded – undo
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";
Please login to merge, or discard this patch.
Indentation   +301 added lines, -301 removed lines patch added patch discarded remove patch
@@ -46,13 +46,13 @@  discard block
 block discarded – undo
46 46
 
47 47
 /* List all required NSIS modules below */
48 48
     private $NSIS_Modules = [
49
-             "nsArray.nsh",
50
-             "FileFunc.nsh",
51
-             "LogicLib.nsh",
52
-             "WordFunc.nsh",
53
-             "FileFunc.nsh",
54
-             "x64.nsh",
55
-         ];
49
+                "nsArray.nsh",
50
+                "FileFunc.nsh",
51
+                "LogicLib.nsh",
52
+                "WordFunc.nsh",
53
+                "FileFunc.nsh",
54
+                "x64.nsh",
55
+            ];
56 56
 
57 57
 /* set $profile_option_ct to the number of rows returned by "SELECT * FROM profile_option_dict" */
58 58
     private $profile_option_ct = 28;
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
     public $name;
66 66
 
67 67
     public function __construct() {
68
-       parent::__construct();
69
-       $this->test_result = [];
70
-       $this->test_result['global'] = 0;
68
+        parent::__construct();
69
+        $this->test_result = [];
70
+        $this->test_result['global'] = 0;
71 71
     }
72 72
 
73 73
     /**
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
      * @param string $test the test name
76 76
      */
77 77
     public function test($test) {
78
-       $this->out[$test] =[];
79
-       $this->name = $test;
80
-       $m_name = $test.'_test';
81
-       $this->test_result[$test] = 0;
82
-       if(! method_exists($this,$m_name)) {
83
-           $this->test_return($test,L_ERROR,"Configuration error, no test configured for <strong>$test</strong>.");
84
-           return;
85
-       }
86
-       $this->$m_name();
78
+        $this->out[$test] =[];
79
+        $this->name = $test;
80
+        $m_name = $test.'_test';
81
+        $this->test_result[$test] = 0;
82
+        if(! method_exists($this,$m_name)) {
83
+            $this->test_return($test,L_ERROR,"Configuration error, no test configured for <strong>$test</strong>.");
84
+            return;
85
+        }
86
+        $this->$m_name();
87 87
     }
88 88
 
89 89
     /**
@@ -96,27 +96,27 @@  discard block
 block discarded – undo
96 96
      * and returned a success.
97 97
      */
98 98
     public function run_tests($Tests) {
99
-       foreach ($Tests as $t) {
100
-         if(preg_match('/(.+)=>(.+)/',$t,$m)) {
99
+        foreach ($Tests as $t) {
100
+            if(preg_match('/(.+)=>(.+)/',$t,$m)) {
101 101
             $tst = $m[1];
102 102
             $subtst=$m[2];
103 103
             if($this->test_result[$tst]  < L_ERROR)
104
-               $this->test($subtst);
105
-         }
106
-         else
104
+                $this->test($subtst);
105
+            }
106
+            else
107 107
             $this->test($t);
108
-       }
108
+        }
109 109
     }
110 110
 
111 111
     public function get_test_names() {
112
-       $T = get_class_methods($this);
113
-       $out = [];
114
-       foreach($T as $t) {
115
-         if(preg_match('/^(.*)_test$/',$t,$m)) {
112
+        $T = get_class_methods($this);
113
+        $out = [];
114
+        foreach($T as $t) {
115
+            if(preg_match('/^(.*)_test$/',$t,$m)) {
116 116
             $out[] = $m[1];
117
-         } 
118
-       }
119
-       return $out;
117
+            } 
118
+        }
119
+        return $out;
120 120
     }
121 121
 
122 122
     /**
@@ -142,84 +142,84 @@  discard block
 block discarded – undo
142 142
         $the_path = "";
143 143
         $exec_is = "UNDEFINED";
144 144
         if (!empty(Config::$PATHS[$s])) {
145
-             preg_match('/([^ ]+) ?/',Config::$PATHS[$s],$m);
146
-             $exe = $m[1];
147
-             $the_path = exec("which " . Config::$PATHS[$s]);
148
-             if ($the_path == $exe)
149
-                 $exec_is = "EXPLICIT";
150
-             else
151
-                 $exec_is = "IMPLICIT";
152
-         } 
145
+                preg_match('/([^ ]+) ?/',Config::$PATHS[$s],$m);
146
+                $exe = $m[1];
147
+                $the_path = exec("which " . Config::$PATHS[$s]);
148
+                if ($the_path == $exe)
149
+                    $exec_is = "EXPLICIT";
150
+                else
151
+                    $exec_is = "IMPLICIT";
152
+            } 
153 153
         return(['exec'=>$the_path,'exec_is'=>$exec_is]);
154 154
     }
155 155
 
156 156
     /**
157
-      *  Test for php version
158
-      */
157
+     *  Test for php version
158
+     */
159 159
     private function php_test() {
160
-         if (version_compare(phpversion(), $this->php_needversion, '>='))
160
+            if (version_compare(phpversion(), $this->php_needversion, '>='))
161 161
             $this->test_return(L_OK,"<strong>PHP</strong> is sufficiently recent. You are running " . phpversion() . ".");
162
-         else
162
+            else
163 163
             $this->test_return(L_ERROR,"<strong>PHP</strong> is too old. We need at least $this->php_needversion, but you only have ".phpversion(). ".");
164 164
     }
165 165
 
166 166
     /**
167
-      * test for simpleSAMLphp
168
-      */
167
+     * test for simpleSAMLphp
168
+     */
169 169
     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.");
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.");
174 174
     }
175 175
 
176 176
     /**
177
-      * test for security setting
178
-      */
177
+     * test for security setting
178
+     */
179 179
     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'!");
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'!");
182 182
     }
183 183
 
184 184
     /**
185
-      * test if zip is available
186
-      */
185
+     * test if zip is available
186
+     */
187 187
     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!");
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!");
192 192
     }
193 193
 
194 194
     /**
195
-      * test if eapol_test is availabe and reacent enough
196
-      */
195
+     * test if eapol_test is availabe and reacent enough
196
+     */
197 197
     private function eapol_test_test() {
198
-         exec(Config::$PATHS['eapol_test'], $out, $retval);
199
-         if($retval == 255 ) {
198
+            exec(Config::$PATHS['eapol_test'], $out, $retval);
199
+            if($retval == 255 ) {
200 200
             $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!");
205
-         }
206
-         else
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!");
205
+            }
206
+            else
207 207
             $this->test_return(L_ERROR,"<strong>eapol_test</strong> not found!");
208 208
     }
209 209
 
210 210
     /**
211
-      * test if logdir exists and is writable
212
-      */
211
+     * test if logdir exists and is writable
212
+     */
213 213
     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.");
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.");
218 218
     }
219 219
 
220 220
     /**
221
-      * test for required PHP modules
222
-      */
221
+     * test for required PHP modules
222
+     */
223 223
     private function phpModules_test() {
224 224
         if (function_exists('idn_to_ascii'))
225 225
             $this->test_return(L_OK,"PHP can handle internationalisation.");
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
         if (function_exists('gettext'))
230 230
             $this->test_return(L_OK,"PHP extension <strong>GNU Gettext</strong> is installed.");
231 231
         else
232
-           $this->test_return(L_ERROR,"PHP extension <strong>GNU Gettext</strong> not found!");
232
+            $this->test_return(L_ERROR,"PHP extension <strong>GNU Gettext</strong> not found!");
233 233
 
234 234
         if (function_exists('openssl_sign'))
235 235
             $this->test_return(L_OK,"PHP extension <strong>OpenSSL</strong> is installed.");
@@ -271,193 +271,193 @@  discard block
 block discarded – undo
271 271
      */
272 272
 
273 273
     private function geoip_test() {
274
-       $host_4 = '145.0.2.50';
275
-       $host_6 = '2001:610:188:444::50';
276
-       switch (Config::$GEOIP['version']) {
277
-           case 0:
274
+        $host_4 = '145.0.2.50';
275
+        $host_6 = '2001:610:188:444::50';
276
+        switch (Config::$GEOIP['version']) {
277
+            case 0:
278 278
               $this->test_return(L_REMARK,"As set in the config, no geolocation service will be used");
279
-              break;
280
-           case 1:
279
+                break;
280
+            case 1:
281 281
               if (!function_exists('geoip_record_by_name')) {
282
-                  $this->test_return(L_ERROR,"PHP extension <strong>GeoIP</strong> (legacy) not found! Get it from your distribution or <a href='http://pecl.php.net/package/geoip'>here</a> or better install GeoIP2 from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>.");
283
-                  return;
284
-              }
285
-              $record = geoip_record_by_name($host_4);
286
-              if(! $record) {
287
-                 $this->test_return(L_ERROR,"PHP extension <strong>GeoIP</strong> (legacy) found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
288
-                 return;
289
-              }
290
-              if($record['city'] != 'Utrecht') {
291
-                 $this->test_return(L_ERROR,"PHP extension <strong>GeoIP</strong> (legacy) found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
292
-                 return;
293
-              }
294
-              $this->test_return(L_REMARK,"PHP extension <strong>GeoIP</strong> (legacy) is installed and working. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly. We stronly advise to replace the legacy GeoIP with GeoIP2 from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>.");
295
-              break;
296
-           case 2:
282
+                    $this->test_return(L_ERROR,"PHP extension <strong>GeoIP</strong> (legacy) not found! Get it from your distribution or <a href='http://pecl.php.net/package/geoip'>here</a> or better install GeoIP2 from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>.");
283
+                    return;
284
+                }
285
+                $record = geoip_record_by_name($host_4);
286
+                if(! $record) {
287
+                    $this->test_return(L_ERROR,"PHP extension <strong>GeoIP</strong> (legacy) found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
288
+                    return;
289
+                }
290
+                if($record['city'] != 'Utrecht') {
291
+                    $this->test_return(L_ERROR,"PHP extension <strong>GeoIP</strong> (legacy) found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
292
+                    return;
293
+                }
294
+                $this->test_return(L_REMARK,"PHP extension <strong>GeoIP</strong> (legacy) is installed and working. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly. We stronly advise to replace the legacy GeoIP with GeoIP2 from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>.");
295
+                break;
296
+            case 2:
297 297
               if(! is_file(Config::$GEOIP['geoip2-path-to-autoloader'])) {
298
-                 $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> not found! Get it from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>.");
299
-                 return;
300
-              }
301
-              if(! is_file(Config::$GEOIP['geoip2-path-to-db'])) {
302
-                 $this->test_return(L_ERROR,"<strong>GeoIP2 database</strong> not found! See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
303
-                 return;
304
-              }
305
-              require_once Config::$GEOIP['geoip2-path-to-autoloader'];
306
-              $reader = new Reader(Config::$GEOIP['geoip2-path-to-db']);
307
-              try {
308
-                 $record = $reader->city($host_4);
309
-              } catch (Exception $e) {
310
-                 $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
311
-                 return;
312
-              }
313
-              if( $record->city->name != 'Utrecht') {
314
-                 $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
315
-                 return;
316
-              }
317
-              try {
318
-                 $record = $reader->city($host_6);
319
-              } catch (Exception $e) {
320
-                 $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly with IPv6, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
321
-                 return;
322
-              }
323
-              if( $record->city->name != 'Utrecht') {
324
-                 $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly with IPv6, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
325
-                 return;
326
-              }
327
-              $this->test_return(L_OK,"PHP extension <strong>GeoIP2</strong> is installed and working. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
328
-              break;
329
-           default:
298
+                    $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> not found! Get it from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>.");
299
+                    return;
300
+                }
301
+                if(! is_file(Config::$GEOIP['geoip2-path-to-db'])) {
302
+                    $this->test_return(L_ERROR,"<strong>GeoIP2 database</strong> not found! See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
303
+                    return;
304
+                }
305
+                require_once Config::$GEOIP['geoip2-path-to-autoloader'];
306
+                $reader = new Reader(Config::$GEOIP['geoip2-path-to-db']);
307
+                try {
308
+                    $record = $reader->city($host_4);
309
+                } catch (Exception $e) {
310
+                    $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
311
+                    return;
312
+                }
313
+                if( $record->city->name != 'Utrecht') {
314
+                    $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
315
+                    return;
316
+                }
317
+                try {
318
+                    $record = $reader->city($host_6);
319
+                } catch (Exception $e) {
320
+                    $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly with IPv6, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
321
+                    return;
322
+                }
323
+                if( $record->city->name != 'Utrecht') {
324
+                    $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly with IPv6, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
325
+                    return;
326
+                }
327
+                $this->test_return(L_OK,"PHP extension <strong>GeoIP2</strong> is installed and working. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
328
+                break;
329
+            default:
330 330
               $this->test_return(L_ERROR,'Check Config::$GEOIP[\'version\'], it must be set to either 1 or 2');
331
-              break;
332
-       }
331
+                break;
332
+        }
333 333
     }
334 334
 
335 335
     /**
336
-      * test if openssl is available
337
-      */
336
+     * test if openssl is available
337
+     */
338 338
     private function openssl_test() {
339
-         $A = $this->get_exec_path('openssl');    
340
-         if($A['exec'] != "") {
341
-             $t = exec($A['exec'] . ' version');
342
-             if($A['exec_is'] == "EXPLICIT")
339
+            $A = $this->get_exec_path('openssl');    
340
+            if($A['exec'] != "") {
341
+                $t = exec($A['exec'] . ' version');
342
+                if($A['exec_is'] == "EXPLICIT")
343 343
                 $this->test_return(L_OK,"<strong>$t</strong> was found and is configured explicitly in your config.");
344
-             else
344
+                else
345 345
                 $this->test_return(L_WARN,"<strong>$t</strong> was found, but is not configured with an absolute path in your config.");
346
-         } else
346
+            } else
347 347
             $this->test_return(L_ERROR,"<strong>openssl</strong> was not found on your system!");
348 348
     }
349 349
 
350 350
     /**
351
-      * test if makensis is available
352
-      */
351
+     * test if makensis is available
352
+     */
353 353
     private function makensis_test() {
354
-         if(! is_numeric(Config::$NSIS_VERSION)) {
354
+            if(! is_numeric(Config::$NSIS_VERSION)) {
355 355
             $this->test_return(L_ERROR,"NSIS_VERSION needs to be numeric!");
356 356
             return;
357
-         }
358
-         if(Config::$NSIS_VERSION < 2) {
357
+            }
358
+            if(Config::$NSIS_VERSION < 2) {
359 359
             $this->test_return(L_ERROR,"NSIS_VERSION needs to be at least 2!");
360 360
             return;
361
-         }
362
-         $A = $this->get_exec_path('makensis');    
363
-         if($A['exec'] != "") {
364
-             $t = exec($A['exec'] . ' -VERSION');
365
-             if($A['exec_is'] == "EXPLICIT") 
361
+            }
362
+            $A = $this->get_exec_path('makensis');    
363
+            if($A['exec'] != "") {
364
+                $t = exec($A['exec'] . ' -VERSION');
365
+                if($A['exec_is'] == "EXPLICIT") 
366 366
                 $this->test_return(L_OK,"<strong>makensis $t</strong> was found and is configured explicitly in your config.");
367
-             else
367
+                else
368 368
                 $this->test_return(L_WARN,"<strong>makensis $t</strong> was found, but is not configured with an absolute path in your config.");
369
-             exec($A['exec'] . ' -HELP',$t);
370
-             $t1 = count(preg_grep('/INPUTCHARSET/',$t));
371
-             if($t1 == 1 && Config::$NSIS_VERSION == 2)
369
+                exec($A['exec'] . ' -HELP',$t);
370
+                $t1 = count(preg_grep('/INPUTCHARSET/',$t));
371
+                if($t1 == 1 && Config::$NSIS_VERSION == 2)
372 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)
373
+                if($t1 == 0 && Config::$NSIS_VERSION >= 3)
374 374
                 $this->test_return(L_ERROR,"Declared NSIS_VERSION does not seem to match the file pointed to by PATHS['makensis']!");
375
-         } else
375
+            } else
376 376
             $this->test_return(L_ERROR,"<strong>makensis</strong> was not found on your system!");
377 377
     }
378 378
 
379 379
     /**
380
-      * test if all required NSIS modules are available
381
-      */
380
+     * test if all required NSIS modules are available
381
+     */
382 382
     private function NSISmodules_test() {
383
-         $tmp_dir = createTemporaryDirectory('installer',0)['dir'];
384
-         if(!chdir($tmp_dir)) {
385
-           debug(2, "Cannot chdir to $tmp_dir\n");
386
-           $this->test_return(L_ERROR,"NSIS modules test - problem with temporary directory permissions, cannot continue");
387
-           return;
388
-         }
389
-         $exe= 'tt.exe';
390
-         $NSIS_Module_status = [];
391
-         foreach ($this->NSIS_Modules as $module) {
383
+            $tmp_dir = createTemporaryDirectory('installer',0)['dir'];
384
+            if(!chdir($tmp_dir)) {
385
+            debug(2, "Cannot chdir to $tmp_dir\n");
386
+            $this->test_return(L_ERROR,"NSIS modules test - problem with temporary directory permissions, cannot continue");
387
+            return;
388
+            }
389
+            $exe= 'tt.exe';
390
+            $NSIS_Module_status = [];
391
+            foreach ($this->NSIS_Modules as $module) {
392 392
             unset($out);
393 393
             exec(Config::$PATHS['makensis']." -V1 '-X!include $module' '-XOutFile $exe' '-XSection X' '-XSectionEnd'", $out, $retval);
394 394
             if($retval > 0) 
395
-               $NSIS_Module_status[$module] = 0;
395
+                $NSIS_Module_status[$module] = 0;
396 396
             else
397
-               $NSIS_Module_status[$module] = 1;
398
-         }
399
-         if(is_file($exe))
397
+                $NSIS_Module_status[$module] = 1;
398
+            }
399
+            if(is_file($exe))
400 400
             unlink($exe);
401
-         foreach ($NSIS_Module_status as $module => $status) {
401
+            foreach ($NSIS_Module_status as $module => $status) {
402 402
             if($status == 1)
403
-               $this->test_return(L_OK,"NSIS module <strong>$module</strong> was found.");
403
+                $this->test_return(L_OK,"NSIS module <strong>$module</strong> was found.");
404 404
             else
405
-               $this->test_return(L_ERROR,"NSIS module <strong>$module</strong> was not found or is not working correctly.");
406
-         }
405
+                $this->test_return(L_ERROR,"NSIS module <strong>$module</strong> was not found or is not working correctly.");
406
+            }
407 407
     }
408 408
     private function NSIS_GetVersion_test() {
409
-         $tmp_dir = createTemporaryDirectory('installer',0)['dir'];
410
-         if(!chdir($tmp_dir)) {
411
-           debug(2, "Cannot chdir to $tmp_dir\n");
412
-           $this->test_return(L_ERROR,"NSIS module <strong>GetVersion</strong> - problem with temporary directory permissions, cannot continue");
413
-           return;
414
-         }
415
-         $exe= 'tt.exe';
416
-         exec(Config::$PATHS['makensis']." -V1 '-XOutFile $exe' '-XSection X' '-XGetVersion::WindowsName' '-XSectionEnd'", $out, $retval);
417
-         if($retval > 0)
409
+            $tmp_dir = createTemporaryDirectory('installer',0)['dir'];
410
+            if(!chdir($tmp_dir)) {
411
+            debug(2, "Cannot chdir to $tmp_dir\n");
412
+            $this->test_return(L_ERROR,"NSIS module <strong>GetVersion</strong> - problem with temporary directory permissions, cannot continue");
413
+            return;
414
+            }
415
+            $exe= 'tt.exe';
416
+            exec(Config::$PATHS['makensis']." -V1 '-XOutFile $exe' '-XSection X' '-XGetVersion::WindowsName' '-XSectionEnd'", $out, $retval);
417
+            if($retval > 0)
418 418
             $this->test_return(L_ERROR,"NSIS module <strong>GetVersion</strong> was not found or is not working correctly.");
419
-         else
419
+            else
420 420
             $this->test_return(L_OK,"NSIS module <strong>GetVersion</strong> was found.");
421
-         if(is_file($exe))
421
+            if(is_file($exe))
422 422
             unlink($exe);
423 423
     }
424 424
 
425 425
     /**
426
-      * test access to dowloads directories
427
-      */
426
+     * test access to dowloads directories
427
+     */
428 428
     private function directories_test() {
429
-               $Dir = createTemporaryDirectory('installer',0);
430
-               $dir = $Dir['dir'];
431
-               $base = $Dir['base'];
432
-               if($dir) {
433
-                  $this->test_return(L_OK,"Installer cache directory is writable.");
434
-                  rrmdir($dir);
435
-               } else {
436
-                  $this->test_return(L_ERROR,"Installer cache directory $base does not exist or is not writable!");
437
-               }
438
-               $Dir = createTemporaryDirectory('test',0);
439
-               $dir = $Dir['dir'];
440
-               $base = $Dir['base'];
441
-               if($dir) {
442
-                  $this->test_return(L_OK,"Test directory is writable.");
443
-                  rrmdir($dir);
444
-               } else {
445
-                  $this->test_return(L_ERROR,"Test directory  $base does not exist or is not writable!");
446
-               }
447
-               $Dir = createTemporaryDirectory('logo',0);
448
-               $dir = $Dir['dir'];
449
-               $base = $Dir['base'];
450
-               if($dir) {
451
-                  $this->test_return(L_OK,"Logos cache directory is writable.");
452
-                  rrmdir($dir);
453
-               } else {
454
-                  $this->test_return(L_ERROR,"Logos cache directory  $base does not exist or is not writable!");
455
-               }
429
+                $Dir = createTemporaryDirectory('installer',0);
430
+                $dir = $Dir['dir'];
431
+                $base = $Dir['base'];
432
+                if($dir) {
433
+                    $this->test_return(L_OK,"Installer cache directory is writable.");
434
+                    rrmdir($dir);
435
+                } else {
436
+                    $this->test_return(L_ERROR,"Installer cache directory $base does not exist or is not writable!");
437
+                }
438
+                $Dir = createTemporaryDirectory('test',0);
439
+                $dir = $Dir['dir'];
440
+                $base = $Dir['base'];
441
+                if($dir) {
442
+                    $this->test_return(L_OK,"Test directory is writable.");
443
+                    rrmdir($dir);
444
+                } else {
445
+                    $this->test_return(L_ERROR,"Test directory  $base does not exist or is not writable!");
446
+                }
447
+                $Dir = createTemporaryDirectory('logo',0);
448
+                $dir = $Dir['dir'];
449
+                $base = $Dir['base'];
450
+                if($dir) {
451
+                    $this->test_return(L_OK,"Logos cache directory is writable.");
452
+                    rrmdir($dir);
453
+                } else {
454
+                    $this->test_return(L_ERROR,"Logos cache directory  $base does not exist or is not writable!");
455
+                }
456 456
     }
457 457
 
458 458
     /**
459
-      * test if all required locales are enabled
460
-      */
459
+     * test if all required locales are enabled
460
+     */
461 461
     private function locales_test() {
462 462
                 $locales = shell_exec("locale -a");
463 463
                 $allthere = "";
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
 
481 481
 
482 482
     /**
483
-      * test if detalts in the config have been replaced with some real values
484
-      */
483
+     * test if detalts in the config have been replaced with some real values
484
+     */
485 485
     private function defaults_test() {
486 486
                 $defaultvalues = "";
487 487
                 $missingvalues = "";
@@ -532,121 +532,121 @@  discard block
 block discarded – undo
532 532
                     $this->test_return(L_OK,"Your configuration does not contain any unchanged defaults, which is a good sign.");
533 533
     }
534 534
 
535
-   /**
535
+    /**
536 536
      * test access to databases
537 537
      */
538
-   private function databases_test() {
538
+    private function databases_test() {
539 539
         $DB = 'INST';
540 540
         $db = mysqli_connect(Config::$DB[$DB]['host'], Config::$DB[$DB]['user'], Config::$DB[$DB]['pass'], Config::$DB[$DB]['db']);
541 541
         if(! $db) {
542
-           $this->test_return(L_ERROR,"Connection to the  $DB database failed");
542
+            $this->test_return(L_ERROR,"Connection to the  $DB database failed");
543 543
         } else {
544
-           $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.");
544
+            $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.");
549 549
         }
550 550
         $DB = 'USER';
551 551
         $db = mysqli_connect(Config::$DB[$DB]['host'], Config::$DB[$DB]['user'], Config::$DB[$DB]['pass'], Config::$DB[$DB]['db']);
552 552
         if(! $db) {
553
-           $this->test_return(L_ERROR,"Connection to the  $DB database failed");
553
+            $this->test_return(L_ERROR,"Connection to the  $DB database failed");
554 554
         } else {
555
-           $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");
555
+            $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");
560 560
         }
561 561
         $DB = 'EXTERNAL';
562 562
         if(! empty(Config::$DB[$DB])) {
563 563
         $db = mysqli_connect(Config::$DB[$DB]['host'], Config::$DB[$DB]['user'], Config::$DB[$DB]['pass'], Config::$DB[$DB]['db']);
564 564
         if(! $db) {
565
-           $this->test_return(L_ERROR,"Connection to the  $DB database failed");
565
+            $this->test_return(L_ERROR,"Connection to the  $DB database failed");
566 566
         } else {
567
-           $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");
567
+            $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");
572 572
         }
573 573
         }
574
-   }
574
+    }
575 575
 
576 576
 
577
-   /**
577
+    /**
578 578
      * test devices.php for the no_cache option
579 579
      */
580
-   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;
585
-
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");
588
-       $Devs = Devices::listDevices();
589
-       $no_cache_dev = '';
590
-       $no_cache_dev_count = 0;
591
-       if($global_no_cache) {
592
-          foreach ($Devs as $dev=>$D) {
593
-             if(empty($D['options']['no_cache']) || $D['options']['no_cache'] != 0) {
580
+    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;
585
+
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");
588
+        $Devs = Devices::listDevices();
589
+        $no_cache_dev = '';
590
+        $no_cache_dev_count = 0;
591
+        if($global_no_cache) {
592
+            foreach ($Devs as $dev=>$D) {
593
+                if(empty($D['options']['no_cache']) || $D['options']['no_cache'] != 0) {
594 594
                 $no_cache_dev .= $dev." ";
595 595
                 $no_cache_dev_count++;
596
-             }
597
-          }
598
-       } else {
599
-          foreach ($Devs as $dev=>$D) {
600
-             if(!empty($D['options']['no_cache']) && $D['options']['no_cache'] != 0) {
596
+                }
597
+            }
598
+        } else {
599
+            foreach ($Devs as $dev=>$D) {
600
+                if(!empty($D['options']['no_cache']) && $D['options']['no_cache'] != 0) {
601 601
                 $no_cache_dev .= $dev." ";
602 602
                 $no_cache_dev_count++;
603
-             }
604
-          }
605
-       }
603
+                }
604
+            }
605
+        }
606 606
 
607 607
 
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");
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");
612 612
 
613
-   }
613
+    }
614 614
 
615
-   /**
615
+    /**
616 616
      * test if mailer works
617 617
      */
618
-   private function mailer_test() {
619
-      if (empty(Config::$APPEARANCE['abuse-mail']) || Config::$APPEARANCE['abuse-mail'] == "[email protected]") {
620
-         $this->test_return(L_ERROR,"Your abuse-mail has not been set, cannot continue with mailer tests.");
621
-         return;
622
-      }
623
-      $mail = new PHPMailer();
624
-      $mail->isSMTP();
625
-      $mail->Port = 587;
626
-      $mail->SMTPAuth = true;
627
-      $mail->SMTPSecure = 'tls';
628
-      $mail->Host = Config::$MAILSETTINGS['host'];
629
-      $mail->Username = Config::$MAILSETTINGS['user'];
630
-      $mail->Password = Config::$MAILSETTINGS['pass'];
631
-      $mail->WordWrap = 72;
632
-      $mail->isHTML(FALSE);
633
-      $mail->CharSet = 'UTF-8';
634
-      $mail->From = Config::$APPEARANCE['from-mail'];
635
-      $mail->FromName = Config::$APPEARANCE['productname'] . " Invitation System";
636
-      $mail->addAddress(Config::$APPEARANCE['abuse-mail']);
637
-      $mail->Subject = "testing CAT configuration mail";
638
-      $mail->Body = "Testing CAT mailing\n";
639
-      $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");
644
-
645
-   }
618
+    private function mailer_test() {
619
+        if (empty(Config::$APPEARANCE['abuse-mail']) || Config::$APPEARANCE['abuse-mail'] == "[email protected]") {
620
+            $this->test_return(L_ERROR,"Your abuse-mail has not been set, cannot continue with mailer tests.");
621
+            return;
622
+        }
623
+        $mail = new PHPMailer();
624
+        $mail->isSMTP();
625
+        $mail->Port = 587;
626
+        $mail->SMTPAuth = true;
627
+        $mail->SMTPSecure = 'tls';
628
+        $mail->Host = Config::$MAILSETTINGS['host'];
629
+        $mail->Username = Config::$MAILSETTINGS['user'];
630
+        $mail->Password = Config::$MAILSETTINGS['pass'];
631
+        $mail->WordWrap = 72;
632
+        $mail->isHTML(FALSE);
633
+        $mail->CharSet = 'UTF-8';
634
+        $mail->From = Config::$APPEARANCE['from-mail'];
635
+        $mail->FromName = Config::$APPEARANCE['productname'] . " Invitation System";
636
+        $mail->addAddress(Config::$APPEARANCE['abuse-mail']);
637
+        $mail->Subject = "testing CAT configuration mail";
638
+        $mail->Body = "Testing CAT mailing\n";
639
+        $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");
644
+
645
+    }
646 646
 
647 647
     /**
648
-      * TODO test if RADIUS connections work
649
-      */
648
+     * TODO test if RADIUS connections work
649
+     */
650 650
     private function UDPhosts_test() {
651 651
 //        if(empty)
652 652
     }
Please login to merge, or discard this patch.
Spacing   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
      * @param string $test the test name
76 76
      */
77 77
     public function test($test) {
78
-       $this->out[$test] =[];
78
+       $this->out[$test] = [];
79 79
        $this->name = $test;
80
-       $m_name = $test.'_test';
80
+       $m_name = $test . '_test';
81 81
        $this->test_result[$test] = 0;
82
-       if(! method_exists($this,$m_name)) {
83
-           $this->test_return($test,L_ERROR,"Configuration error, no test configured for <strong>$test</strong>.");
82
+       if (!method_exists($this, $m_name)) {
83
+           $this->test_return($test, L_ERROR, "Configuration error, no test configured for <strong>$test</strong>.");
84 84
            return;
85 85
        }
86 86
        $this->$m_name();
@@ -97,10 +97,10 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function run_tests($Tests) {
99 99
        foreach ($Tests as $t) {
100
-         if(preg_match('/(.+)=>(.+)/',$t,$m)) {
100
+         if (preg_match('/(.+)=>(.+)/', $t, $m)) {
101 101
             $tst = $m[1];
102
-            $subtst=$m[2];
103
-            if($this->test_result[$tst]  < L_ERROR)
102
+            $subtst = $m[2];
103
+            if ($this->test_result[$tst] < L_ERROR)
104 104
                $this->test($subtst);
105 105
          }
106 106
          else
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
     public function get_test_names() {
112 112
        $T = get_class_methods($this);
113 113
        $out = [];
114
-       foreach($T as $t) {
115
-         if(preg_match('/^(.*)_test$/',$t,$m)) {
114
+       foreach ($T as $t) {
115
+         if (preg_match('/^(.*)_test$/', $t, $m)) {
116 116
             $out[] = $m[1];
117 117
          } 
118 118
        }
@@ -132,17 +132,17 @@  discard block
 block discarded – undo
132 132
      */
133 133
     public $test_result;
134 134
 
135
-    private function test_return($level,$message) {
135
+    private function test_return($level, $message) {
136 136
         $this->out[$this->name][] = ['level'=>$level, 'message'=>$message];
137
-        $this->test_result[$this->name] = max($this->test_result[$this->name],$level);
138
-        $this->test_result['global'] = max($this->test_result['global'],$level);
137
+        $this->test_result[$this->name] = max($this->test_result[$this->name], $level);
138
+        $this->test_result['global'] = max($this->test_result['global'], $level);
139 139
     }
140 140
 
141 141
     private function get_exec_path($s) {
142 142
         $the_path = "";
143 143
         $exec_is = "UNDEFINED";
144 144
         if (!empty(Config::$PATHS[$s])) {
145
-             preg_match('/([^ ]+) ?/',Config::$PATHS[$s],$m);
145
+             preg_match('/([^ ]+) ?/', Config::$PATHS[$s], $m);
146 146
              $exe = $m[1];
147 147
              $the_path = exec("which " . Config::$PATHS[$s]);
148 148
              if ($the_path == $exe)
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
              else
151 151
                  $exec_is = "IMPLICIT";
152 152
          } 
153
-        return(['exec'=>$the_path,'exec_is'=>$exec_is]);
153
+        return(['exec'=>$the_path, 'exec_is'=>$exec_is]);
154 154
     }
155 155
 
156 156
     /**
@@ -158,9 +158,9 @@  discard block
 block discarded – undo
158 158
       */
159 159
     private function php_test() {
160 160
          if (version_compare(phpversion(), $this->php_needversion, '>='))
161
-            $this->test_return(L_OK,"<strong>PHP</strong> is sufficiently recent. You are running " . phpversion() . ".");
161
+            $this->test_return(L_OK, "<strong>PHP</strong> is sufficiently recent. You are running " . phpversion() . ".");
162 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(). ".");
163
+            $this->test_return(L_ERROR, "<strong>PHP</strong> is too old. We need at least $this->php_needversion, but you only have " . phpversion() . ".");
164 164
     }
165 165
 
166 166
     /**
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
       */
169 169
     private function ssp_test() {
170 170
          if (!is_file(CONFIG::$AUTHENTICATION['ssp-path-to-autoloader']))
171
-             $this->test_return(L_ERROR,"<strong>simpleSAMLphp</strong> not found!");
171
+             $this->test_return(L_ERROR, "<strong>simpleSAMLphp</strong> not found!");
172 172
          else
173
-             $this->test_return(L_OK,"<strong>simpleSAMLphp</strong> autoloader found.");
173
+             $this->test_return(L_OK, "<strong>simpleSAMLphp</strong> autoloader found.");
174 174
     }
175 175
 
176 176
     /**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
       */
179 179
     private function security_test() {
180 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'!");
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'!");
182 182
     }
183 183
 
184 184
     /**
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
       */
187 187
     private function zip_test() {
188 188
          if (exec("which zip") != "")
189
-             $this->test_return(L_OK,"<strong>zip</strong> binary found.");
189
+             $this->test_return(L_OK, "<strong>zip</strong> binary found.");
190 190
          else
191
-             $this->test_return(L_ERROR,"<strong>zip</strong> not found in your \$PATH!");
191
+             $this->test_return(L_ERROR, "<strong>zip</strong> not found in your \$PATH!");
192 192
     }
193 193
 
194 194
     /**
@@ -196,15 +196,15 @@  discard block
 block discarded – undo
196 196
       */
197 197
     private function eapol_test_test() {
198 198
          exec(Config::$PATHS['eapol_test'], $out, $retval);
199
-         if($retval == 255 ) {
200
-            $o = preg_grep('/-o<server cert/',$out);
201
-               if(count($o) > 0)
202
-                   $this->test_return(L_OK,"<strong>eapol_test</strong> script found.");
199
+         if ($retval == 255) {
200
+            $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 203
                else
204
-                   $this->test_return(L_ERROR,"<strong>eapol_test</strong> found, but is too old!");
204
+                   $this->test_return(L_ERROR, "<strong>eapol_test</strong> found, but is too old!");
205 205
          }
206 206
          else
207
-            $this->test_return(L_ERROR,"<strong>eapol_test</strong> not found!");
207
+            $this->test_return(L_ERROR, "<strong>eapol_test</strong> not found!");
208 208
     }
209 209
 
210 210
     /**
@@ -212,9 +212,9 @@  discard block
 block discarded – undo
212 212
       */
213 213
     private function logdir_test() {
214 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!");
215
+             $this->test_return(L_WARN, "Log files in <strong>" . Config::$PATHS['logdir'] . "</strong> are not writable!");
216 216
          else
217
-             $this->test_return(L_OK,"Log directory is writable.");
217
+             $this->test_return(L_OK, "Log directory is writable.");
218 218
     }
219 219
 
220 220
     /**
@@ -222,34 +222,34 @@  discard block
 block discarded – undo
222 222
       */
223 223
     private function phpModules_test() {
224 224
         if (function_exists('idn_to_ascii'))
225
-            $this->test_return(L_OK,"PHP can handle internationalisation.");
225
+            $this->test_return(L_OK, "PHP can handle internationalisation.");
226 226
         else
227
-            $this->test_return(L_ERROR,"PHP can <strongNOT</strong> handle internationalisation (idn_to_ascii() from php5-intl).");
227
+            $this->test_return(L_ERROR, "PHP can <strongNOT</strong> handle internationalisation (idn_to_ascii() from php5-intl).");
228 228
 
229 229
         if (function_exists('gettext'))
230
-            $this->test_return(L_OK,"PHP extension <strong>GNU Gettext</strong> is installed.");
230
+            $this->test_return(L_OK, "PHP extension <strong>GNU Gettext</strong> is installed.");
231 231
         else
232
-           $this->test_return(L_ERROR,"PHP extension <strong>GNU Gettext</strong> not found!");
232
+           $this->test_return(L_ERROR, "PHP extension <strong>GNU Gettext</strong> not found!");
233 233
 
234 234
         if (function_exists('openssl_sign'))
235
-            $this->test_return(L_OK,"PHP extension <strong>OpenSSL</strong> is installed.");
235
+            $this->test_return(L_OK, "PHP extension <strong>OpenSSL</strong> is installed.");
236 236
         else
237
-            $this->test_return(L_ERROR,"PHP extension <strong>OpenSSL</strong> not found!");
237
+            $this->test_return(L_ERROR, "PHP extension <strong>OpenSSL</strong> not found!");
238 238
 
239 239
         if (class_exists('Imagick'))
240
-            $this->test_return(L_OK,"PHP extension <strong>Imagick</strong> is installed.");
240
+            $this->test_return(L_OK, "PHP extension <strong>Imagick</strong> is installed.");
241 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>.");
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>.");
243 243
 
244 244
         if (function_exists('ImageCreate'))
245
-            $this->test_return(L_OK,"PHP extension <strong>GD</strong> is installed.");
245
+            $this->test_return(L_OK, "PHP extension <strong>GD</strong> is installed.");
246 246
         else
247
-            $this->test_return(L_ERROR,"PHP extension <strong>GD</strong> not found!</a>.");
247
+            $this->test_return(L_ERROR, "PHP extension <strong>GD</strong> not found!</a>.");
248 248
 
249 249
         if (function_exists('mysqli_connect'))
250
-            $this->test_return(L_OK,"PHP extension <strong>MySQL</strong> is installed.");
250
+            $this->test_return(L_OK, "PHP extension <strong>MySQL</strong> is installed.");
251 251
         else
252
-            $this->test_return(L_ERROR,"PHP extension <strong>MySQL</strong> not found!");
252
+            $this->test_return(L_ERROR, "PHP extension <strong>MySQL</strong> not found!");
253 253
 /*
254 254
         if (function_exists('geoip_record_by_name')) {
255 255
            $host = '158.75.1.10';
@@ -275,31 +275,31 @@  discard block
 block discarded – undo
275 275
        $host_6 = '2001:610:188:444::50';
276 276
        switch (Config::$GEOIP['version']) {
277 277
            case 0:
278
-              $this->test_return(L_REMARK,"As set in the config, no geolocation service will be used");
278
+              $this->test_return(L_REMARK, "As set in the config, no geolocation service will be used");
279 279
               break;
280 280
            case 1:
281 281
               if (!function_exists('geoip_record_by_name')) {
282
-                  $this->test_return(L_ERROR,"PHP extension <strong>GeoIP</strong> (legacy) not found! Get it from your distribution or <a href='http://pecl.php.net/package/geoip'>here</a> or better install GeoIP2 from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>.");
282
+                  $this->test_return(L_ERROR, "PHP extension <strong>GeoIP</strong> (legacy) not found! Get it from your distribution or <a href='http://pecl.php.net/package/geoip'>here</a> or better install GeoIP2 from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>.");
283 283
                   return;
284 284
               }
285 285
               $record = geoip_record_by_name($host_4);
286
-              if(! $record) {
287
-                 $this->test_return(L_ERROR,"PHP extension <strong>GeoIP</strong> (legacy) found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
286
+              if (!$record) {
287
+                 $this->test_return(L_ERROR, "PHP extension <strong>GeoIP</strong> (legacy) found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
288 288
                  return;
289 289
               }
290
-              if($record['city'] != 'Utrecht') {
291
-                 $this->test_return(L_ERROR,"PHP extension <strong>GeoIP</strong> (legacy) found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
290
+              if ($record['city'] != 'Utrecht') {
291
+                 $this->test_return(L_ERROR, "PHP extension <strong>GeoIP</strong> (legacy) found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
292 292
                  return;
293 293
               }
294
-              $this->test_return(L_REMARK,"PHP extension <strong>GeoIP</strong> (legacy) is installed and working. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly. We stronly advise to replace the legacy GeoIP with GeoIP2 from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>.");
294
+              $this->test_return(L_REMARK, "PHP extension <strong>GeoIP</strong> (legacy) is installed and working. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly. We stronly advise to replace the legacy GeoIP with GeoIP2 from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>.");
295 295
               break;
296 296
            case 2:
297
-              if(! is_file(Config::$GEOIP['geoip2-path-to-autoloader'])) {
298
-                 $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> not found! Get it from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>.");
297
+              if (!is_file(Config::$GEOIP['geoip2-path-to-autoloader'])) {
298
+                 $this->test_return(L_ERROR, "PHP extension <strong>GeoIP2</strong> not found! Get it from <a href='https://github.com/maxmind/GeoIP2-php'>here</a>.");
299 299
                  return;
300 300
               }
301
-              if(! is_file(Config::$GEOIP['geoip2-path-to-db'])) {
302
-                 $this->test_return(L_ERROR,"<strong>GeoIP2 database</strong> not found! See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
301
+              if (!is_file(Config::$GEOIP['geoip2-path-to-db'])) {
302
+                 $this->test_return(L_ERROR, "<strong>GeoIP2 database</strong> not found! See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
303 303
                  return;
304 304
               }
305 305
               require_once Config::$GEOIP['geoip2-path-to-autoloader'];
@@ -307,27 +307,27 @@  discard block
 block discarded – undo
307 307
               try {
308 308
                  $record = $reader->city($host_4);
309 309
               } catch (Exception $e) {
310
-                 $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
310
+                 $this->test_return(L_ERROR, "PHP extension <strong>GeoIP2</strong> found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
311 311
                  return;
312 312
               }
313
-              if( $record->city->name != 'Utrecht') {
314
-                 $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
313
+              if ($record->city->name != 'Utrecht') {
314
+                 $this->test_return(L_ERROR, "PHP extension <strong>GeoIP2</strong> found but not working properly, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
315 315
                  return;
316 316
               }
317 317
               try {
318 318
                  $record = $reader->city($host_6);
319 319
               } catch (Exception $e) {
320
-                 $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly with IPv6, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
320
+                 $this->test_return(L_ERROR, "PHP extension <strong>GeoIP2</strong> found but not working properly with IPv6, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
321 321
                  return;
322 322
               }
323
-              if( $record->city->name != 'Utrecht') {
324
-                 $this->test_return(L_ERROR,"PHP extension <strong>GeoIP2</strong> found but not working properly with IPv6, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
323
+              if ($record->city->name != 'Utrecht') {
324
+                 $this->test_return(L_ERROR, "PHP extension <strong>GeoIP2</strong> found but not working properly with IPv6, perhaps you need to download the databases. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
325 325
                  return;
326 326
               }
327
-              $this->test_return(L_OK,"PHP extension <strong>GeoIP2</strong> is installed and working. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
327
+              $this->test_return(L_OK, "PHP extension <strong>GeoIP2</strong> is installed and working. See utils/GeoIP-update.sh in the CAT distribution and use it tu update the GeoIP database regularly.");
328 328
               break;
329 329
            default:
330
-              $this->test_return(L_ERROR,'Check Config::$GEOIP[\'version\'], it must be set to either 1 or 2');
330
+              $this->test_return(L_ERROR, 'Check Config::$GEOIP[\'version\'], it must be set to either 1 or 2');
331 331
               break;
332 332
        }
333 333
     }
@@ -337,88 +337,88 @@  discard block
 block discarded – undo
337 337
       */
338 338
     private function openssl_test() {
339 339
          $A = $this->get_exec_path('openssl');    
340
-         if($A['exec'] != "") {
340
+         if ($A['exec'] != "") {
341 341
              $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.");
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 344
              else
345
-                $this->test_return(L_WARN,"<strong>$t</strong> was found, but is not configured with an absolute path in your config.");
345
+                $this->test_return(L_WARN, "<strong>$t</strong> was found, but is not configured with an absolute path in your config.");
346 346
          } else
347
-            $this->test_return(L_ERROR,"<strong>openssl</strong> was not found on your system!");
347
+            $this->test_return(L_ERROR, "<strong>openssl</strong> was not found on your system!");
348 348
     }
349 349
 
350 350
     /**
351 351
       * test if makensis is available
352 352
       */
353 353
     private function makensis_test() {
354
-         if(! is_numeric(Config::$NSIS_VERSION)) {
355
-            $this->test_return(L_ERROR,"NSIS_VERSION needs to be numeric!");
354
+         if (!is_numeric(Config::$NSIS_VERSION)) {
355
+            $this->test_return(L_ERROR, "NSIS_VERSION needs to be numeric!");
356 356
             return;
357 357
          }
358
-         if(Config::$NSIS_VERSION < 2) {
359
-            $this->test_return(L_ERROR,"NSIS_VERSION needs to be at least 2!");
358
+         if (Config::$NSIS_VERSION < 2) {
359
+            $this->test_return(L_ERROR, "NSIS_VERSION needs to be at least 2!");
360 360
             return;
361 361
          }
362 362
          $A = $this->get_exec_path('makensis');    
363
-         if($A['exec'] != "") {
363
+         if ($A['exec'] != "") {
364 364
              $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.");
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 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.");
369
-             exec($A['exec'] . ' -HELP',$t);
370
-             $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']!");
368
+                $this->test_return(L_WARN, "<strong>makensis $t</strong> was found, but is not configured with an absolute path in your config.");
369
+             exec($A['exec'] . ' -HELP', $t);
370
+             $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 375
          } else
376
-            $this->test_return(L_ERROR,"<strong>makensis</strong> was not found on your system!");
376
+            $this->test_return(L_ERROR, "<strong>makensis</strong> was not found on your system!");
377 377
     }
378 378
 
379 379
     /**
380 380
       * test if all required NSIS modules are available
381 381
       */
382 382
     private function NSISmodules_test() {
383
-         $tmp_dir = createTemporaryDirectory('installer',0)['dir'];
384
-         if(!chdir($tmp_dir)) {
383
+         $tmp_dir = createTemporaryDirectory('installer', 0)['dir'];
384
+         if (!chdir($tmp_dir)) {
385 385
            debug(2, "Cannot chdir to $tmp_dir\n");
386
-           $this->test_return(L_ERROR,"NSIS modules test - problem with temporary directory permissions, cannot continue");
386
+           $this->test_return(L_ERROR, "NSIS modules test - problem with temporary directory permissions, cannot continue");
387 387
            return;
388 388
          }
389
-         $exe= 'tt.exe';
389
+         $exe = 'tt.exe';
390 390
          $NSIS_Module_status = [];
391 391
          foreach ($this->NSIS_Modules as $module) {
392 392
             unset($out);
393
-            exec(Config::$PATHS['makensis']." -V1 '-X!include $module' '-XOutFile $exe' '-XSection X' '-XSectionEnd'", $out, $retval);
394
-            if($retval > 0) 
393
+            exec(Config::$PATHS['makensis'] . " -V1 '-X!include $module' '-XOutFile $exe' '-XSection X' '-XSectionEnd'", $out, $retval);
394
+            if ($retval > 0) 
395 395
                $NSIS_Module_status[$module] = 0;
396 396
             else
397 397
                $NSIS_Module_status[$module] = 1;
398 398
          }
399
-         if(is_file($exe))
399
+         if (is_file($exe))
400 400
             unlink($exe);
401 401
          foreach ($NSIS_Module_status as $module => $status) {
402
-            if($status == 1)
403
-               $this->test_return(L_OK,"NSIS module <strong>$module</strong> was found.");
402
+            if ($status == 1)
403
+               $this->test_return(L_OK, "NSIS module <strong>$module</strong> was found.");
404 404
             else
405
-               $this->test_return(L_ERROR,"NSIS module <strong>$module</strong> was not found or is not working correctly.");
405
+               $this->test_return(L_ERROR, "NSIS module <strong>$module</strong> was not found or is not working correctly.");
406 406
          }
407 407
     }
408 408
     private function NSIS_GetVersion_test() {
409
-         $tmp_dir = createTemporaryDirectory('installer',0)['dir'];
410
-         if(!chdir($tmp_dir)) {
409
+         $tmp_dir = createTemporaryDirectory('installer', 0)['dir'];
410
+         if (!chdir($tmp_dir)) {
411 411
            debug(2, "Cannot chdir to $tmp_dir\n");
412
-           $this->test_return(L_ERROR,"NSIS module <strong>GetVersion</strong> - problem with temporary directory permissions, cannot continue");
412
+           $this->test_return(L_ERROR, "NSIS module <strong>GetVersion</strong> - problem with temporary directory permissions, cannot continue");
413 413
            return;
414 414
          }
415
-         $exe= 'tt.exe';
416
-         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.");
415
+         $exe = 'tt.exe';
416
+         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 419
          else
420
-            $this->test_return(L_OK,"NSIS module <strong>GetVersion</strong> was found.");
421
-         if(is_file($exe))
420
+            $this->test_return(L_OK, "NSIS module <strong>GetVersion</strong> was found.");
421
+         if (is_file($exe))
422 422
             unlink($exe);
423 423
     }
424 424
 
@@ -426,32 +426,32 @@  discard block
 block discarded – undo
426 426
       * test access to dowloads directories
427 427
       */
428 428
     private function directories_test() {
429
-               $Dir = createTemporaryDirectory('installer',0);
429
+               $Dir = createTemporaryDirectory('installer', 0);
430 430
                $dir = $Dir['dir'];
431 431
                $base = $Dir['base'];
432
-               if($dir) {
433
-                  $this->test_return(L_OK,"Installer cache directory is writable.");
432
+               if ($dir) {
433
+                  $this->test_return(L_OK, "Installer cache directory is writable.");
434 434
                   rrmdir($dir);
435 435
                } else {
436
-                  $this->test_return(L_ERROR,"Installer cache directory $base does not exist or is not writable!");
436
+                  $this->test_return(L_ERROR, "Installer cache directory $base does not exist or is not writable!");
437 437
                }
438
-               $Dir = createTemporaryDirectory('test',0);
438
+               $Dir = createTemporaryDirectory('test', 0);
439 439
                $dir = $Dir['dir'];
440 440
                $base = $Dir['base'];
441
-               if($dir) {
442
-                  $this->test_return(L_OK,"Test directory is writable.");
441
+               if ($dir) {
442
+                  $this->test_return(L_OK, "Test directory is writable.");
443 443
                   rrmdir($dir);
444 444
                } else {
445
-                  $this->test_return(L_ERROR,"Test directory  $base does not exist or is not writable!");
445
+                  $this->test_return(L_ERROR, "Test directory  $base does not exist or is not writable!");
446 446
                }
447
-               $Dir = createTemporaryDirectory('logo',0);
447
+               $Dir = createTemporaryDirectory('logo', 0);
448 448
                $dir = $Dir['dir'];
449 449
                $base = $Dir['base'];
450
-               if($dir) {
451
-                  $this->test_return(L_OK,"Logos cache directory is writable.");
450
+               if ($dir) {
451
+                  $this->test_return(L_OK, "Logos cache directory is writable.");
452 452
                   rrmdir($dir);
453 453
                } else {
454
-                  $this->test_return(L_ERROR,"Logos cache directory  $base does not exist or is not writable!");
454
+                  $this->test_return(L_ERROR, "Logos cache directory  $base does not exist or is not writable!");
455 455
                }
456 456
     }
457 457
 
@@ -466,16 +466,16 @@  discard block
 block discarded – undo
466 466
                         $allthere .= $onelanguage['locale'] . " ";
467 467
 
468 468
                 if ($allthere == "")
469
-                    $this->test_return(L_OK,"All of your configured locales are available on your system.");
469
+                    $this->test_return(L_OK, "All of your configured locales are available on your system.");
470 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!");
471
+                    $this->test_return(L_WARN, "Some of your configured locales (<strong>$allthere</strong>) are not installed and will not be displayed correctly!");
472 472
     }
473 473
 
474
-    private function check_config_default($type,$key,$value) {
474
+    private function check_config_default($type, $key, $value) {
475 475
                 if (empty(Config::$type[$key]))
476
-                    $missingvalues .="type/webcert_OCSP ";
476
+                    $missingvalues .= "type/webcert_OCSP ";
477 477
                 elseif (Config::$type['webcert_OCSP'] == $value)
478
-                    $defaultvalues .="type/$key ";
478
+                    $defaultvalues .= "type/$key ";
479 479
     }
480 480
 
481 481
 
@@ -486,31 +486,31 @@  discard block
 block discarded – undo
486 486
                 $defaultvalues = "";
487 487
                 $missingvalues = "";
488 488
                 if (Config::$APPEARANCE['from-mail'] == "[email protected]")
489
-                    $defaultvalues .="APPEARANCE/from-mail ";
489
+                    $defaultvalues .= "APPEARANCE/from-mail ";
490 490
                 if (Config::$APPEARANCE['support-contact']['url'] == "[email protected]?body=Only%20English%20language%20please!")
491
-                    $defaultvalues .="APPEARANCE/support-contact/url ";
491
+                    $defaultvalues .= "APPEARANCE/support-contact/url ";
492 492
                 if (Config::$APPEARANCE['support-contact']['display'] == "[email protected]")
493
-                    $defaultvalues .="APPEARANCE/support-contact/display ";
493
+                    $defaultvalues .= "APPEARANCE/support-contact/display ";
494 494
                 if (Config::$APPEARANCE['support-contact']['developer-mail'] == "[email protected]")
495
-                    $defaultvalues .="APPEARANCE/support-contact/mail ";
495
+                    $defaultvalues .= "APPEARANCE/support-contact/mail ";
496 496
                 if (Config::$APPEARANCE['abuse-mail'] == "[email protected]")
497
-                    $defaultvalues .="APPEARANCE/abuse-mail ";
497
+                    $defaultvalues .= "APPEARANCE/abuse-mail ";
498 498
                 if (Config::$APPEARANCE['MOTD'] == "Release Candidate. All bugs to be shot on sight!")
499
-                    $defaultvalues .="APPEARANCE/MOTD ";
499
+                    $defaultvalues .= "APPEARANCE/MOTD ";
500 500
                 if (Config::$APPEARANCE['webcert_CRLDP'] == ['list', 'of', 'CRL', 'pointers'])
501
-                    $defaultvalues .="APPEARANCE/webcert_CRLDP ";
501
+                    $defaultvalues .= "APPEARANCE/webcert_CRLDP ";
502 502
                 if (empty(Config::$APPEARANCE['webcert_OCSP']))
503
-                    $missingvalues .="APPEARANCE/webcert_OCSP ";
503
+                    $missingvalues .= "APPEARANCE/webcert_OCSP ";
504 504
                 elseif (Config::$APPEARANCE['webcert_OCSP'] == ['list', 'of', 'OCSP', 'pointers'])
505
-                    $defaultvalues .="APPEARANCE/webcert_OCSP ";
505
+                    $defaultvalues .= "APPEARANCE/webcert_OCSP ";
506 506
                 if (isset(Config::$RADIUSTESTS['UDP-hosts'][0]) && Config::$RADIUSTESTS['UDP-hosts'][0]['ip'] == "192.0.2.1")
507
-                    $defaultvalues .="RADIUSTESTS/UDP-hosts ";
507
+                    $defaultvalues .= "RADIUSTESTS/UDP-hosts ";
508 508
                 if (Config::$DB['INST']['host'] == "db.host.example")
509
-                    $defaultvalues .="DB/INST ";
509
+                    $defaultvalues .= "DB/INST ";
510 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 ";
511
+                    $defaultvalues .= "DB/USER ";
512
+                if (!empty(Config::$DB['EXTERNAL']) && Config::$DB['EXTERNAL']['host'] == "customerdb.otherhost.example")
513
+                    $defaultvalues .= "DB/EXTERNAL ";
514 514
                 $files = [];
515 515
                 foreach (Config::$RADIUSTESTS['TLS-clientcerts'] as $cadata) {
516 516
                     foreach ($cadata['certificates'] as $cert_files) {
@@ -522,14 +522,14 @@  discard block
 block discarded – undo
522 522
                 foreach ($files as $file) {
523 523
                     $handle = fopen(CAT::$root . "/config/cli-certs/" . $file, 'r');
524 524
                     if (!$handle)
525
-                        $defaultvalues .="CERTIFICATE/$file ";
525
+                        $defaultvalues .= "CERTIFICATE/$file ";
526 526
                     else
527 527
                         fclose($handle);
528 528
                 }
529 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>!");
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 531
                 else
532
-                    $this->test_return(L_OK,"Your configuration does not contain any unchanged defaults, which is a good sign.");
532
+                    $this->test_return(L_OK, "Your configuration does not contain any unchanged defaults, which is a good sign.");
533 533
     }
534 534
 
535 535
    /**
@@ -538,37 +538,37 @@  discard block
 block discarded – undo
538 538
    private function databases_test() {
539 539
         $DB = 'INST';
540 540
         $db = mysqli_connect(Config::$DB[$DB]['host'], Config::$DB[$DB]['user'], Config::$DB[$DB]['pass'], Config::$DB[$DB]['db']);
541
-        if(! $db) {
542
-           $this->test_return(L_ERROR,"Connection to the  $DB database failed");
541
+        if (!$db) {
542
+           $this->test_return(L_ERROR, "Connection to the  $DB database failed");
543 543
         } else {
544
-           $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.");
544
+           $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 547
            else
548
-              $this->test_return(L_ERROR,"The $DB database is reacheable but probably not updated to this version of CAT.");
548
+              $this->test_return(L_ERROR, "The $DB database is reacheable but probably not updated to this version of CAT.");
549 549
         }
550 550
         $DB = 'USER';
551 551
         $db = mysqli_connect(Config::$DB[$DB]['host'], Config::$DB[$DB]['user'], Config::$DB[$DB]['pass'], Config::$DB[$DB]['db']);
552
-        if(! $db) {
553
-           $this->test_return(L_ERROR,"Connection to the  $DB database failed");
552
+        if (!$db) {
553
+           $this->test_return(L_ERROR, "Connection to the  $DB database failed");
554 554
         } else {
555
-           $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.");
555
+           $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 558
            else
559
-              $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema");
559
+              $this->test_return(L_ERROR, "The $DB is reacheable but there is something wrong with the schema");
560 560
         }
561 561
         $DB = 'EXTERNAL';
562
-        if(! empty(Config::$DB[$DB])) {
562
+        if (!empty(Config::$DB[$DB])) {
563 563
         $db = mysqli_connect(Config::$DB[$DB]['host'], Config::$DB[$DB]['user'], Config::$DB[$DB]['pass'], Config::$DB[$DB]['db']);
564
-        if(! $db) {
565
-           $this->test_return(L_ERROR,"Connection to the  $DB database failed");
564
+        if (!$db) {
565
+           $this->test_return(L_ERROR, "Connection to the  $DB database failed");
566 566
         } else {
567
-           $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.");
567
+           $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 570
            else
571
-              $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema");
571
+              $this->test_return(L_ERROR, "The $DB is reacheable but there is something wrong with the schema");
572 572
         }
573 573
         }
574 574
    }
@@ -578,37 +578,37 @@  discard block
 block discarded – undo
578 578
      * test devices.php for the no_cache option
579 579
      */
580 580
    private function device_cache_test() {
581
-       if((! empty(Devices::$Options['no_cache'])) && Devices::$Options['no_cache'])
581
+       if ((!empty(Devices::$Options['no_cache'])) && Devices::$Options['no_cache'])
582 582
           $global_no_cache = 1;
583 583
        else
584 584
           $global_no_cache = 0;
585 585
 
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");
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");
588 588
        $Devs = Devices::listDevices();
589 589
        $no_cache_dev = '';
590 590
        $no_cache_dev_count = 0;
591
-       if($global_no_cache) {
591
+       if ($global_no_cache) {
592 592
           foreach ($Devs as $dev=>$D) {
593
-             if(empty($D['options']['no_cache']) || $D['options']['no_cache'] != 0) {
594
-                $no_cache_dev .= $dev." ";
593
+             if (empty($D['options']['no_cache']) || $D['options']['no_cache'] != 0) {
594
+                $no_cache_dev .= $dev . " ";
595 595
                 $no_cache_dev_count++;
596 596
              }
597 597
           }
598 598
        } else {
599 599
           foreach ($Devs as $dev=>$D) {
600
-             if(!empty($D['options']['no_cache']) && $D['options']['no_cache'] != 0) {
601
-                $no_cache_dev .= $dev." ";
600
+             if (!empty($D['options']['no_cache']) && $D['options']['no_cache'] != 0) {
601
+                $no_cache_dev .= $dev . " ";
602 602
                 $no_cache_dev_count++;
603 603
              }
604 604
           }
605 605
        }
606 606
 
607 607
 
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");
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");
612 612
 
613 613
    }
614 614
 
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
      */
618 618
    private function mailer_test() {
619 619
       if (empty(Config::$APPEARANCE['abuse-mail']) || Config::$APPEARANCE['abuse-mail'] == "[email protected]") {
620
-         $this->test_return(L_ERROR,"Your abuse-mail has not been set, cannot continue with mailer tests.");
620
+         $this->test_return(L_ERROR, "Your abuse-mail has not been set, cannot continue with mailer tests.");
621 621
          return;
622 622
       }
623 623
       $mail = new PHPMailer();
@@ -637,10 +637,10 @@  discard block
 block discarded – undo
637 637
       $mail->Subject = "testing CAT configuration mail";
638 638
       $mail->Body = "Testing CAT mailing\n";
639 639
       $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.");
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 642
       else
643
-          $this->test_return(L_ERROR,"mailer settings failed, check the Config::MAILSETTINGS");
643
+          $this->test_return(L_ERROR, "mailer settings failed, check the Config::MAILSETTINGS");
644 644
 
645 645
    }
646 646
 
Please login to merge, or discard this patch.
Braces   +209 added lines, -159 removed lines patch added patch discarded remove patch
@@ -100,11 +100,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
core/User.php 4 patches
Doc Comments   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      * The function's single parameter $option_name is optional - if specified, it only returns the attributes of the given type.
125 125
      * Otherwise, all known attributes are returned.
126 126
      * 
127
-     * @param string $option_name name of the option whose values are to be returned
127
+     * @param integer $option_name name of the option whose values are to be returned
128 128
      * @return array of attributes
129 129
      */
130 130
     public function getAttributes($option_name = 0) {
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
      * user is a federation administrator of *any* federation. When given a parameter (ISO shortname of federation), it checks
195 195
      * if the user administers this particular federation.
196 196
      * 
197
-     * @param string $federation optional: federation to be checked
197
+     * @param integer $federation optional: federation to be checked
198 198
      * @return boolean TRUE if the user is federation admin, FALSE if not 
199 199
      */
200 200
     public function isFederationAdmin($federation = 0) {
@@ -226,6 +226,7 @@  discard block
 block discarded – undo
226 226
    /**
227 227
     *  This function tests if the current user is an ovner of a given IdP
228 228
     *
229
+    * @param integer $idp
229 230
     * @return boolean TRUE if the user is an owner, FALSE if not 
230 231
     */
231 232
     public function isIdPOwner($idp) {
@@ -236,6 +237,9 @@  discard block
 block discarded – undo
236 237
        return FALSE;
237 238
     }
238 239
 
240
+    /**
241
+     * @param string $content
242
+     */
239 243
     public function sendMailToUser($subject, $content) {
240 244
         // use PHPMailer to send the mail
241 245
         $mail = new PHPMailer();
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -213,27 +213,27 @@
 block discarded – undo
213 213
         }
214 214
     }
215 215
 
216
-   /**
217
-    * This function tests if the current user has been configured as the system superadmin, i.e. if the user is allowed
218
-    * to execute the 112365365321.php script
219
-    *
220
-    * @return boolean TRUE if the user is a superadmin, FALSE if not 
221
-    */
216
+    /**
217
+     * This function tests if the current user has been configured as the system superadmin, i.e. if the user is allowed
218
+     * to execute the 112365365321.php script
219
+     *
220
+     * @return boolean TRUE if the user is a superadmin, FALSE if not 
221
+     */
222 222
     public function isSuperadmin() {
223
-       return in_array($this->identifier, Config::$SUPERADMINS);
223
+        return in_array($this->identifier, Config::$SUPERADMINS);
224 224
     }
225 225
 
226
-   /**
227
-    *  This function tests if the current user is an ovner of a given IdP
228
-    *
229
-    * @return boolean TRUE if the user is an owner, FALSE if not 
230
-    */
226
+    /**
227
+     *  This function tests if the current user is an ovner of a given IdP
228
+     *
229
+     * @return boolean TRUE if the user is an owner, FALSE if not 
230
+     */
231 231
     public function isIdPOwner($idp) {
232
-       $temp = new IdP($idp);
233
-       foreach ($temp->owner() as $oneowner)
232
+        $temp = new IdP($idp);
233
+        foreach ($temp->owner() as $oneowner)
234 234
             if ($oneowner['ID'] == $this->identifier)
235 235
                 return TRUE;
236
-       return FALSE;
236
+        return FALSE;
237 237
     }
238 238
 
239 239
     public function sendMailToUser($subject, $content) {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -253,7 +253,7 @@
 block discarded – undo
253 253
         // who to whom?
254 254
         $mail->From = Config::$APPEARANCE['from-mail'];
255 255
         $mail->FromName = Config::$APPEARANCE['productname'] . " Notification System";
256
-        $mail->addReplyTo(Config::$APPEARANCE['support-contact']['mail'], Config::$APPEARANCE['productname'] . " " ._("Feedback"));
256
+        $mail->addReplyTo(Config::$APPEARANCE['support-contact']['mail'], Config::$APPEARANCE['productname'] . " " . _("Feedback"));
257 257
         
258 258
         $mailaddr = $this->getAttributes("user:email");
259 259
         if (count($mailaddr) == 0) // we don't know his mail address
Please login to merge, or discard this 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.
core/UserAPI.php 4 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -260,7 +260,6 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Indentation   +391 added lines, -391 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
  *  link - the path name of the resulting installer
53 53
  *  mime - the mimetype of the installer
54 54
  */
55
-  public function generateInstaller($device,$prof_id, $generated_for = "user") {
55
+    public function generateInstaller($device,$prof_id, $generated_for = "user") {
56 56
     $this->set_locale("devices");
57 57
     $Dev = Devices::listDevices();
58 58
     $Config = $Dev[$device];
@@ -61,93 +61,93 @@  discard block
 block discarded – undo
61 61
     $attribs = $profile->getCollapsedAttributes();
62 62
     // test if the profile is production-ready and if not if the authenticated user is an owner
63 63
     if (!isset($attribs['profile:production']) || (isset($attribs['profile:production']) && $attribs['profile:production'][0] != "on")) {
64
-       debug(4,"Attempt to download a non-production ready installer fir profile: $prof_id\n");
65
-       require_once(Config::$AUTHENTICATION['ssp-path-to-autoloader']);
66
-       $as = new SimpleSAML_Auth_Simple(Config::$AUTHENTICATION['ssp-authsource']);
67
-       if($as->isAuthenticated()) {
68
-          $user_object = new User($_SESSION['user']);
69
-          if($user_object->isIdPOwner($profile->institution)) {
70
-              debug(4, "User is the owner - allowing access\n");
71
-          } else {
72
-             debug(2, "User not an owner of a non-production profile - access forbidden\n");
73
-       header("HTTP/1.0 403 Not Authorized");
74
-             return;
75
-          }
76
-       } else {
77
-          debug(2, "User NOT authenticated, rejecting request for a non-production installer\n");
78
-          header("HTTP/1.0 403 Not Authorized");
79
-          return;
80
-       }
64
+        debug(4,"Attempt to download a non-production ready installer fir profile: $prof_id\n");
65
+        require_once(Config::$AUTHENTICATION['ssp-path-to-autoloader']);
66
+        $as = new SimpleSAML_Auth_Simple(Config::$AUTHENTICATION['ssp-authsource']);
67
+        if($as->isAuthenticated()) {
68
+            $user_object = new User($_SESSION['user']);
69
+            if($user_object->isIdPOwner($profile->institution)) {
70
+                debug(4, "User is the owner - allowing access\n");
71
+            } else {
72
+                debug(2, "User not an owner of a non-production profile - access forbidden\n");
73
+        header("HTTP/1.0 403 Not Authorized");
74
+                return;
75
+            }
76
+        } else {
77
+            debug(2, "User NOT authenticated, rejecting request for a non-production installer\n");
78
+            header("HTTP/1.0 403 Not Authorized");
79
+            return;
80
+        }
81 81
     }
82 82
     $a = [];
83 83
     $a['profile'] = $prof_id;
84 84
     $a['device'] = $device;
85 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;
86
+        $this->i_path = FALSE;
87 87
     else {
88
-      $cache = $profile->testCache($device);
89
-      $this->i_path = $cache['cache'];
88
+        $cache = $profile->testCache($device);
89
+        $this->i_path = $cache['cache'];
90 90
     }
91 91
     if($this->i_path && is_file($this->i_path)) { 
92
-      debug(4,"Using cached installer for: $device\n");
93
-      $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for";
94
-      $a['mime'] = $cache['mime'];
92
+        debug(4,"Using cached installer for: $device\n");
93
+        $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for";
94
+        $a['mime'] = $cache['mime'];
95 95
     } else {
96
-      $factory = new DeviceFactory($device);
97
-      $dev = $factory->device;
98
-      if(isset($dev)) {
99
-         $dev->setup($profile);
100
-         $installer = $dev->writeInstaller();
101
-         $i_path = $dev->FPATH.'/tmp/'.$installer;
102
-         if($i_path && is_file($i_path)) {
103
-         if(isset($dev->options['mime']))
104
-               $a['mime'] = $dev->options['mime'];
105
-         else {
106
-           $info = new finfo();
107
-           $a['mime'] = $info->file($i_path, FILEINFO_MIME_TYPE);
108
-         }
109
-         $this->i_path = $dev->FPATH.'/'.$installer;
110
-         rename($i_path, $this->i_path);
111
-         $profile->updateCache($device,$this->i_path,$a['mime']);
96
+        $factory = new DeviceFactory($device);
97
+        $dev = $factory->device;
98
+        if(isset($dev)) {
99
+            $dev->setup($profile);
100
+            $installer = $dev->writeInstaller();
101
+            $i_path = $dev->FPATH.'/tmp/'.$installer;
102
+            if($i_path && is_file($i_path)) {
103
+            if(isset($dev->options['mime']))
104
+                $a['mime'] = $dev->options['mime'];
105
+            else {
106
+            $info = new finfo();
107
+            $a['mime'] = $info->file($i_path, FILEINFO_MIME_TYPE);
108
+            }
109
+            $this->i_path = $dev->FPATH.'/'.$installer;
110
+            rename($i_path, $this->i_path);
111
+            $profile->updateCache($device,$this->i_path,$a['mime']);
112 112
 //         rrmdir($dev->FPATH.'/tmp');
113
-         debug(4,"Generated installer: ".$this->i_path.": for: $device\n");
114
-         $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for";
115
-         } else {
116
-         debug(2,"Installer generation failed for: $prof_id:$device:".CAT::get_lang()."\n");
117
-         $a['link'] = 0;
118
-         }
119
-      } 
113
+            debug(4,"Generated installer: ".$this->i_path.": for: $device\n");
114
+            $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for";
115
+            } else {
116
+            debug(2,"Installer generation failed for: $prof_id:$device:".CAT::get_lang()."\n");
117
+            $a['link'] = 0;
118
+            }
119
+        } 
120 120
     }
121 121
     $this->set_locale("web_user");
122 122
     return($a);
123
- }
123
+    }
124 124
 
125
- /**
126
-  * interface to Devices::listDevices() 
127
-  */
128
- public function listDevices($show_hidden = 0) {
125
+    /**
126
+     * interface to Devices::listDevices() 
127
+     */
128
+    public function listDevices($show_hidden = 0) {
129 129
     $Dev = Devices::listDevices();
130 130
     $R = [];
131 131
     $ct = 0;
132 132
     if($show_hidden !== 0 && $show_hidden != 1)
133
-      return;
133
+        return;
134 134
     foreach ($Dev as $device => $D) {
135
-      if(isset($D['options']['hidden']) && $D['options']['hidden'] && $show_hidden == 0)
136
-         continue;
137
-      $ct ++;
138
-      if($this->version == 1)
139
-         $D['device'] = $device;
140
-      else
141
-         $D['device'] = $device;
142
-      $group = isset($D['group']) ? $D['group'] : 'other';
143
-      if (! isset($R[$group]))
144
-         $R[$group] = [];
145
-      $R[$group][$device] = $D;
146
-    }
147
-   return $R;
148
- }
149
-
150
- public function deviceInfo($device,$prof_id) {
135
+        if(isset($D['options']['hidden']) && $D['options']['hidden'] && $show_hidden == 0)
136
+            continue;
137
+        $ct ++;
138
+        if($this->version == 1)
139
+            $D['device'] = $device;
140
+        else
141
+            $D['device'] = $device;
142
+        $group = isset($D['group']) ? $D['group'] : 'other';
143
+        if (! isset($R[$group]))
144
+            $R[$group] = [];
145
+        $R[$group][$device] = $D;
146
+    }
147
+    return $R;
148
+    }
149
+
150
+    public function deviceInfo($device,$prof_id) {
151 151
     $this->set_locale("devices");
152 152
     $out = 0;
153 153
     $profile = new Profile($prof_id);
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
     $dev = $factory->device;
156 156
     if(isset($dev)) {
157 157
 //       $dev->setup($profile);
158
-       $out = $dev->writeDeviceInfo();
159
-   }
158
+        $out = $dev->writeDeviceInfo();
159
+    }
160 160
     $this->set_locale("web_user");
161 161
     echo $out;
162
- }
162
+    }
163 163
 
164 164
 /**
165 165
  * Prepare the support data for a given profile
@@ -173,23 +173,23 @@  discard block
 block discarded – undo
173 173
  * - description
174 174
  * - devices - an array of device names and their statuses (for a given profile)
175 175
  */
176
- public function profileAttributes($prof_id) {
176
+    public function profileAttributes($prof_id) {
177 177
     $this->set_locale("devices");
178
-      $profile = new Profile($prof_id);
179
-      $attr = $profile->getCollapsedAttributes();
180
-      $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];
189
-      $a['devices'] = $profile->listDevices();
190
-      $this->set_locale("web_user");
191
-      return($a);
192
- }
178
+        $profile = new Profile($prof_id);
179
+        $attr = $profile->getCollapsedAttributes();
180
+        $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];
189
+        $a['devices'] = $profile->listDevices();
190
+        $this->set_locale("web_user");
191
+        return($a);
192
+    }
193 193
 
194 194
 /*
195 195
    this method needs to be used with care, it could give wrong results in some
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
     $file= $F['file'];
202 202
     $file = substr($file,strlen(dirname(__DIR__)));
203 203
     while(substr($file,0,1) == '/')
204
-       $file = substr($file,1);
204
+        $file = substr($file,1);
205 205
     $n = count(explode('/',$file));
206 206
     $out = $_SERVER['SCRIPT_NAME'];
207 207
     for ($i= 0; $i < $n; $i++)
208
-      $out = dirname($out);
208
+        $out = dirname($out);
209 209
     if ($out == '/')
210
-      $out = '';
210
+        $out = '';
211 211
     $s = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http';
212 212
     $s .= '://'.$_SERVER['HTTP_HOST'] . $out;
213 213
     return $s;
@@ -215,29 +215,29 @@  discard block
 block discarded – undo
215 215
 
216 216
 /* JSON functions */
217 217
 
218
-  public function return_json($data,$status=1) {
219
-     $return_array = [];
220
-     $return_array['status'] = $status;
221
-     $return_array['data'] = $data;
222
-     $return_array['tou'] =  "Please consult Terms of Use at: ".$this->GetRootURL()."/tou.php";
223
-     return(json_encode($return_array));
224
-  }
218
+    public function return_json($data,$status=1) {
219
+        $return_array = [];
220
+        $return_array['status'] = $status;
221
+        $return_array['data'] = $data;
222
+        $return_array['tou'] =  "Please consult Terms of Use at: ".$this->GetRootURL()."/tou.php";
223
+        return(json_encode($return_array));
224
+    }
225 225
 
226 226
 /**
227
-  * Return the list of supported languages.
228
-  *
229
-  * 
230
-  */
231
-  public function JSON_listLanguages() {
232
-     $return_array = [];
233
-     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']];
238
-     }
239
-     echo $this->return_json($return_array);
240
-  }
227
+ * Return the list of supported languages.
228
+ *
229
+ * 
230
+ */
231
+    public function JSON_listLanguages() {
232
+        $return_array = [];
233
+        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']];
238
+        }
239
+        echo $this->return_json($return_array);
240
+    }
241 241
 
242 242
 /**
243 243
  * Return the list of countiers with configured IdPs
@@ -245,17 +245,17 @@  discard block
 block discarded – undo
245 245
  * @return string JSON encoded data
246 246
  */
247 247
 
248
-  public function JSON_listCountries() {
249
-     $FED = $this->printCountryList(1);
250
-     $return_array = [];
251
-     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];
256
-     }
257
-     echo $this->return_json($return_array);
258
-  }
248
+    public function JSON_listCountries() {
249
+        $FED = $this->printCountryList(1);
250
+        $return_array = [];
251
+        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];
256
+        }
257
+        echo $this->return_json($return_array);
258
+    }
259 259
 
260 260
 /**
261 261
  * Return the list of IdPs in a given country
@@ -264,17 +264,17 @@  discard block
 block discarded – undo
264 264
  * @return string JSON encoded data
265 265
  */
266 266
 
267
-  public function JSON_listIdentityProviders($country) {
268
-     $idps = Federation::listAllIdentityProviders(1,$country);
269
-     $return_array = [];
270
-     foreach ($idps as $idp) {
267
+    public function JSON_listIdentityProviders($country) {
268
+        $idps = Federation::listAllIdentityProviders(1,$country);
269
+        $return_array = [];
270
+        foreach ($idps as $idp) {
271 271
         if($this->version == 1)
272
-           $return_array[] = ['id'=>$idp['entityID'],'display'=>$idp['title']];
272
+            $return_array[] = ['id'=>$idp['entityID'],'display'=>$idp['title']];
273 273
         else
274
-           $return_array[] = ['idp'=>$idp['entityID'],'display'=>$idp['title']];
275
-     }
276
-     echo $this->return_json($return_array);
277
-  }
274
+            $return_array[] = ['idp'=>$idp['entityID'],'display'=>$idp['title']];
275
+        }
276
+        echo $this->return_json($return_array);
277
+    }
278 278
 
279 279
 /**
280 280
  * return the list of all active IdPs
@@ -283,18 +283,18 @@  discard block
 block discarded – undo
283 283
  * @return string JSON encoded data
284 284
  */
285 285
 
286
-  public function JSON_listIdentityProvidersForDisco() {
287
-     $idps = Federation::listAllIdentityProviders(1);
288
-     $return_array = [];
289
-     foreach ($idps as $idp) {
286
+    public function JSON_listIdentityProvidersForDisco() {
287
+        $idps = Federation::listAllIdentityProviders(1);
288
+        $return_array = [];
289
+        foreach ($idps as $idp) {
290 290
         if($this->version == 1)
291
-           $idp['id'] = $idp['entityID'];
292
-         else
293
-           $idp['idp'] = $idp['entityID'];
291
+            $idp['id'] = $idp['entityID'];
292
+            else
293
+            $idp['idp'] = $idp['entityID'];
294 294
         $return_array[] = $idp;
295
-      }
296
-     echo json_encode($return_array);
297
-  }
295
+        }
296
+        echo json_encode($return_array);
297
+    }
298 298
 
299 299
 
300 300
 
@@ -306,17 +306,17 @@  discard block
 block discarded – undo
306 306
  */
307 307
 
308 308
 
309
-  public function JSON_orderIdentityProviders($country,$L=NULL) {
310
-     $idps = $this->orderIdentityProviders($country,$L);
311
-     $return_array = [];
312
-     foreach ($idps as $idp) {
309
+    public function JSON_orderIdentityProviders($country,$L=NULL) {
310
+        $idps = $this->orderIdentityProviders($country,$L);
311
+        $return_array = [];
312
+        foreach ($idps as $idp) {
313 313
         if($this->version == 1)
314
-           $return_array[] = ['id'=>$idp['id'],'display'=>$idp['title']];
314
+            $return_array[] = ['id'=>$idp['id'],'display'=>$idp['title']];
315 315
         else
316
-           $return_array[] = ['idp'=>$idp['id'],'display'=>$idp['title']];
317
-     }
318
-     echo $this->return_json($return_array);
319
-  }
316
+            $return_array[] = ['idp'=>$idp['id'],'display'=>$idp['title']];
317
+        }
318
+        echo $this->return_json($return_array);
319
+    }
320 320
 
321 321
 /**
322 322
  * Produce a list of profiles available for a given IdP
@@ -324,31 +324,31 @@  discard block
 block discarded – undo
324 324
  * @param int $idp_id the IdP identifier
325 325
  * @return string JSON encoded data
326 326
  */
327
-  public function JSON_listProfiles($idp_id,$sort = 0) {
328
-     $this->set_locale("web_user");
329
-     $return_array = [];
330
-     try {     
331
-         $idp = new IdP($idp_id);
332
-     }
333
-     catch (Exception $fail) {
327
+    public function JSON_listProfiles($idp_id,$sort = 0) {
328
+        $this->set_locale("web_user");
329
+        $return_array = [];
330
+        try {     
331
+            $idp = new IdP($idp_id);
332
+        }
333
+        catch (Exception $fail) {
334 334
         echo $this->return_json($return_array,0);
335 335
         return;
336
-     }
337
-     $l = 0;
338
-     $logo = $idp->getAttributes('general:logo_file');
339
-     if($logo)
340
-       $l = 1;
341
-     $profiles = $idp->listProfiles(1);
342
-     if($sort == 1)
336
+        }
337
+        $l = 0;
338
+        $logo = $idp->getAttributes('general:logo_file');
339
+        if($logo)
340
+        $l = 1;
341
+        $profiles = $idp->listProfiles(1);
342
+        if($sort == 1)
343 343
         usort($profiles,"profile_sort");
344
-     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]; 
349
-     }
350
-     echo $this->return_json($return_array);
351
-  }
344
+        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]; 
349
+        }
350
+        echo $this->return_json($return_array);
351
+    }
352 352
 
353 353
 /**
354 354
  * Return the list of devices available for the given profile
@@ -356,34 +356,34 @@  discard block
 block discarded – undo
356 356
  * @param int $profile_id the Profile identifier
357 357
  * @return string JSON encoded data
358 358
  */
359
-  public function JSON_listDevices($profile_id) {
360
-     $this->set_locale("web_user");
361
-     $return_array = [];
362
-     $a = $this->profileAttributes($profile_id);
363
-     $thedevices = $a['devices'];
364
-     if(!isset($profile_redirect) || ! $profile_redirect) {
365
-         $profile_redirect = 0;
366
-         foreach ($thedevices as $D) {
367
-              if(isset($D['options']) && isset($D['options']['hidden']) &&  $D['options']['hidden'])
368
-                   continue;
369
-              $disp = $D['display'];
370
-              if($this->version == 1) {
371
-                 if($D['id'] === '0') {
372
-                     $profile_redirect = 1;
373
-                     $disp = $c;
374
-                 }
359
+    public function JSON_listDevices($profile_id) {
360
+        $this->set_locale("web_user");
361
+        $return_array = [];
362
+        $a = $this->profileAttributes($profile_id);
363
+        $thedevices = $a['devices'];
364
+        if(!isset($profile_redirect) || ! $profile_redirect) {
365
+            $profile_redirect = 0;
366
+            foreach ($thedevices as $D) {
367
+                if(isset($D['options']) && isset($D['options']['hidden']) &&  $D['options']['hidden'])
368
+                    continue;
369
+                $disp = $D['display'];
370
+                if($this->version == 1) {
371
+                    if($D['id'] === '0') {
372
+                        $profile_redirect = 1;
373
+                        $disp = $c;
374
+                    }
375 375
                 $return_array[] = ['id'=>$D['id'], 'display'=>$disp, 'status'=>$D['status'], 'redirect'=>$D['redirect']];
376
-             } else {
377
-                 if($D['device'] === '0') {
378
-                     $profile_redirect = 1;
379
-                     $disp = $c;
380
-                 }
376
+                } else {
377
+                    if($D['device'] === '0') {
378
+                        $profile_redirect = 1;
379
+                        $disp = $c;
380
+                    }
381 381
                 $return_array[] = ['device'=>$D['id'], 'display'=>$disp, 'status'=>$D['status'], 'redirect'=>$D['redirect']];
382
-             }
383
-         }
382
+                }
383
+            }
384 384
 
385
-  }
386
-  echo $this->return_json($return_array);
385
+    }
386
+    echo $this->return_json($return_array);
387 387
 }
388 388
   
389 389
 /**
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
  * @param int $prof_id profile identifier
394 394
  * @return string JSON encoded data
395 395
  */
396
-  public function JSON_generateInstaller($device,$prof_id) {
396
+    public function JSON_generateInstaller($device,$prof_id) {
397 397
     debug(4,"JSON::generateInstaller arguments: $device,$prof_id\n");
398 398
     $o = $this->generateInstaller($device,$prof_id);
399 399
     debug(4,"output from GUI::generateInstaller:");
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
     debug(4,json_encode($o));
402 402
 //    header('Content-type: application/json; utf-8');
403 403
     echo $this->return_json($o);
404
- }
404
+    }
405 405
 
406 406
 /**
407 407
  * Generate and send the installer
@@ -411,14 +411,14 @@  discard block
 block discarded – undo
411 411
  * @return binary installerFile
412 412
  */
413 413
 
414
- public function downloadInstaller($device,$prof_id,$generated_for='user') {
414
+    public function downloadInstaller($device,$prof_id,$generated_for='user') {
415 415
     debug(4,"downloadInstaller arguments: $device,$prof_id,$generated_for\n");
416 416
     $o = $this->generateInstaller($device,$prof_id);
417 417
     debug(4,"output from GUI::generateInstaller:");
418 418
     debug(4,$o);
419 419
     if(! $o['link']) {
420
-       header("HTTP/1.0 404 Not Found");
421
-       return;
420
+        header("HTTP/1.0 404 Not Found");
421
+        return;
422 422
     }
423 423
     $profile = new Profile($prof_id);
424 424
     $profile->incrementDownloadStats($device, $generated_for);
@@ -431,242 +431,242 @@  discard block
 block discarded – undo
431 431
     ob_clean();
432 432
     flush();
433 433
     readfile($file);
434
- }
434
+    }
435 435
 /**
436
- * Get and prepare logo file 
437
- *
438
- * When called for DiscoJuice, first check if file cache exists
439
- * If not then generate the file and save it in the cache
440
- * @param int $idp_id IdP identifier
441
- * @param int $disco flag turning on image generation for DiscoJuice
442
- * @param int $width, $height  maximum width and height of the generated image 
443
- * if one of these is 0 then it is treated as no upper bound
444
- *
445
- */
436
+     * Get and prepare logo file 
437
+     *
438
+     * When called for DiscoJuice, first check if file cache exists
439
+     * If not then generate the file and save it in the cache
440
+     * @param int $idp_id IdP identifier
441
+     * @param int $disco flag turning on image generation for DiscoJuice
442
+     * @param int $width, $height  maximum width and height of the generated image 
443
+     * if one of these is 0 then it is treated as no upper bound
444
+     *
445
+     */
446
+
447
+    public function sendLogo($idp_id, $disco=FALSE, $width=0, $height=0) {
448
+    $ExpStr = '';
449
+    $resize = 0;
450
+    if(($width || $height) && is_numeric($width) && is_numeric($height)) {
451
+        $resize = 1;
452
+        if($height == 0)
453
+            $height = 10000;
454
+        if($width == 0)
455
+            $width = 10000;
456
+        $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png';
457
+    } elseif($disco == 1) {
458
+        $width = 120;
459
+        $height = 40;
460
+        $resize = 1;
461
+        $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png';
462
+    }
446 463
 
447
- public function sendLogo($idp_id, $disco=FALSE, $width=0, $height=0) {
448
-   $ExpStr = '';
449
-   $resize = 0;
450
-   if(($width || $height) && is_numeric($width) && is_numeric($height)) {
451
-       $resize = 1;
452
-       if($height == 0)
453
-          $height = 10000;
454
-       if($width == 0)
455
-          $width = 10000;
456
-       $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png';
457
-   } elseif($disco == 1) {
458
-       $width = 120;
459
-       $height = 40;
460
-       $resize = 1;
461
-       $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png';
462
-   }
463
-
464
-   if($resize && is_file($logo_file)){
465
-      debug(4,"Using cached logo $logo_file for: $idp_id\n");
466
-      $blob = file_get_contents($logo_file);
467
-      $filetype = 'image/png';
468
-   }
469
-   else {
470
-      $idp = new IdP($idp_id);
471
-      $at = $idp->getAttributes('general:logo_file');
472
-      $blob =  $at[0]['value'];
473
-      $info = new finfo();
474
-      $filetype = $info->buffer($blob, FILEINFO_MIME_TYPE);
475
-      $offset = 60 * 60 * 24 * 30;
476
-      $ExpStr = "Expires: " . gmdate( "D, d M Y H:i:s", time() + $offset ) . " GMT";
477
-      if($resize) {
478
-         $filetype = 'image/png';
479
-         $image = new Imagick();
480
-         $image->readImageBlob($blob);
481
-         if( $image->setImageFormat('PNG')) {
482
-           $image->thumbnailImage($width,$height,1);
483
-           $blob = $image->getImageBlob();
484
-           debug(4,"Writing cached logo $logo_file for: $idp_id\n");
485
-           file_put_contents($logo_file,$blob);
486
-         }
487
-         else
488
-           $blob = "XXXXXX";
489
-      }
490
-   }
491
-   header( "Content-type: ".$filetype );
492
-   header( "Cache-Control:max-age=36000, must-revalidate" );
493
-   header( $ExpStr );
494
-   echo $blob;
495
- }
496
-
497
- public function locateUser() {
498
-   $host = $_SERVER['REMOTE_ADDR'];
499
-   $record = geoip_record_by_name($host);
500
-   if($record) {
501
-     $result = ['status' => 'ok'];
502
-     $result['country'] = $record['country_code'];
464
+    if($resize && is_file($logo_file)){
465
+        debug(4,"Using cached logo $logo_file for: $idp_id\n");
466
+        $blob = file_get_contents($logo_file);
467
+        $filetype = 'image/png';
468
+    }
469
+    else {
470
+        $idp = new IdP($idp_id);
471
+        $at = $idp->getAttributes('general:logo_file');
472
+        $blob =  $at[0]['value'];
473
+        $info = new finfo();
474
+        $filetype = $info->buffer($blob, FILEINFO_MIME_TYPE);
475
+        $offset = 60 * 60 * 24 * 30;
476
+        $ExpStr = "Expires: " . gmdate( "D, d M Y H:i:s", time() + $offset ) . " GMT";
477
+        if($resize) {
478
+            $filetype = 'image/png';
479
+            $image = new Imagick();
480
+            $image->readImageBlob($blob);
481
+            if( $image->setImageFormat('PNG')) {
482
+            $image->thumbnailImage($width,$height,1);
483
+            $blob = $image->getImageBlob();
484
+            debug(4,"Writing cached logo $logo_file for: $idp_id\n");
485
+            file_put_contents($logo_file,$blob);
486
+            }
487
+            else
488
+            $blob = "XXXXXX";
489
+        }
490
+    }
491
+    header( "Content-type: ".$filetype );
492
+    header( "Cache-Control:max-age=36000, must-revalidate" );
493
+    header( $ExpStr );
494
+    echo $blob;
495
+    }
496
+
497
+    public function locateUser() {
498
+    $host = $_SERVER['REMOTE_ADDR'];
499
+    $record = geoip_record_by_name($host);
500
+    if($record) {
501
+        $result = ['status' => 'ok'];
502
+        $result['country'] = $record['country_code'];
503 503
 //  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';
506
-     $result['region'] = $record['region'];
507
-     $result['geo'] = ['lat' => (float)$record['latitude'] , 'lon' => (float)$record['longitude']];
508
-   } else {
509
-     $result = ['status' => 'error', 'error' =>'Problem listing countries']; 
510
-   }
511
-   return($result);
512
- }
513
-
514
-
515
- public function locateUser2() {
516
-   require_once Config::$GEOIP['geoip2-path-to-autoloader'];
517
-   $reader = new Reader(Config::$GEOIP['geoip2-path-to-db']);
518
-   $host = $_SERVER['REMOTE_ADDR'];
519
-   try {
520
-      $record = $reader->city($host);
521
-   } catch (Exception $e) {
522
-      $result = ['status' => 'error', 'error' =>'Problem listing countries']; 
523
-      return($result);
524
-   }
525
-   $result = ['status' => 'ok'];
526
-   $result['country'] = $record->country->isoCode;
504
+        if($result['country'] == 'GB')
505
+            $result['country'] = 'UK';
506
+        $result['region'] = $record['region'];
507
+        $result['geo'] = ['lat' => (float)$record['latitude'] , 'lon' => (float)$record['longitude']];
508
+    } else {
509
+        $result = ['status' => 'error', 'error' =>'Problem listing countries']; 
510
+    }
511
+    return($result);
512
+    }
513
+
514
+
515
+    public function locateUser2() {
516
+    require_once Config::$GEOIP['geoip2-path-to-autoloader'];
517
+    $reader = new Reader(Config::$GEOIP['geoip2-path-to-db']);
518
+    $host = $_SERVER['REMOTE_ADDR'];
519
+    try {
520
+        $record = $reader->city($host);
521
+    } catch (Exception $e) {
522
+        $result = ['status' => 'error', 'error' =>'Problem listing countries']; 
523
+        return($result);
524
+    }
525
+    $result = ['status' => 'ok'];
526
+    $result['country'] = $record->country->isoCode;
527 527
 //  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';
530
-   $result['region'] = $record->continent->name;
528
+    if($result['country'] == 'GB')
529
+        $result['country'] = 'UK';
530
+    $result['region'] = $record->continent->name;
531 531
 
532
-   $result['geo'] = ['lat' => (float)$record->location->latitude , 'lon' => (float)$record->location->longitude];
533
-   return($result);
534
- }
532
+    $result['geo'] = ['lat' => (float)$record->location->latitude , 'lon' => (float)$record->location->longitude];
533
+    return($result);
534
+    }
535 535
 
536 536
 public function JSON_locateUser() {
537 537
     header('Content-type: application/json; utf-8');
538 538
    
539 539
     if(empty(Config::$GEOIP['version']) || Config::$GEOIP['version'] == 0)
540
-      echo json_encode(['status' => 'error', 'error' =>'Geolocation not supported']);
540
+        echo json_encode(['status' => 'error', 'error' =>'Geolocation not supported']);
541 541
     if(Config::$GEOIP['version'] == 1)
542
-      echo json_encode($this->locateUser());
542
+        echo json_encode($this->locateUser());
543 543
     if(Config::$GEOIP['version'] == 2)
544
-      echo json_encode($this->locateUser2());
544
+        echo json_encode($this->locateUser2());
545 545
 }
546 546
 
547 547
 /**
548 548
  * Produce support data prepared within {@link GUI::profileAttributes()}
549 549
  * @return string JSON encoded data
550 550
  */
551
-  public function JSON_profileAttributes($prof_id) {
551
+    public function JSON_profileAttributes($prof_id) {
552 552
 //    header('Content-type: application/json; utf-8');
553 553
     echo $this->return_json($this->profileAttributes($prof_id));
554
-  }
554
+    }
555 555
 
556 556
 /**
557
-  * Calculate the distence in km between two points given their
558
-  * geo coordinates.
559
-  * @param array $P1 - first point as an 'lat', 'lon' array 
560
-  * @param array $P2 - second point as an 'lat', 'lon' array 
561
-  * @return float distance in km
562
-  */
557
+ * Calculate the distence in km between two points given their
558
+ * geo coordinates.
559
+ * @param array $P1 - first point as an 'lat', 'lon' array 
560
+ * @param array $P2 - second point as an 'lat', 'lon' array 
561
+ * @return float distance in km
562
+ */
563 563
 private function geoDistance($P1,$P2) {
564 564
 
565
-  $dist = sin(deg2rad($P1['lat'])) * sin(deg2rad($P2['lat'])) +  
565
+    $dist = sin(deg2rad($P1['lat'])) * sin(deg2rad($P2['lat'])) +  
566 566
          cos(deg2rad($P1['lat'])) * cos(deg2rad($P2['lat'])) * cos(deg2rad($P1['lon'] - $P2['lon']));
567
-  $dist = rad2deg(acos($dist)) * 60 * 1.1852 ;
568
-  return(round($dist));
567
+    $dist = rad2deg(acos($dist)) * 60 * 1.1852 ;
568
+    return(round($dist));
569 569
 }
570 570
 
571 571
 /**
572
-  * Order active identity providers according to their distance and name
573
-  * @param array $L - current location
574
-  * @return array $IdPs -  list of arrays ('id', 'name');
575
-  */
572
+ * Order active identity providers according to their distance and name
573
+ * @param array $L - current location
574
+ * @return array $IdPs -  list of arrays ('id', 'name');
575
+ */
576 576
 
577 577
 public function orderIdentityProviders($country,$L=NULL) {
578
-     $idps = Federation::listAllIdentityProviders(1,$country);
579
-
580
-  if(is_null($L)) {
581
-     $U = $this->locateUser();
582
-     if($U['status'] == 'ok') {
583
-     $L = $U['geo'];
584
-     } else {
585
-       $L = ['lat'=>"90",'lon'=>"0"];
586
-     }
587
-  }
588
-  $T=[];
589
-  $R=[];
590
-     foreach ($idps as $idp) {
578
+        $idps = Federation::listAllIdentityProviders(1,$country);
579
+
580
+    if(is_null($L)) {
581
+        $U = $this->locateUser();
582
+        if($U['status'] == 'ok') {
583
+        $L = $U['geo'];
584
+        } else {
585
+        $L = ['lat'=>"90",'lon'=>"0"];
586
+        }
587
+    }
588
+    $T=[];
589
+    $R=[];
590
+        foreach ($idps as $idp) {
591 591
         $T[$idp['entityID']] = $idp['title'];
592 592
         $dist = 10000;
593 593
         if(isset($idp['geo'])) {
594
-          $G=$idp['geo'];
595
-          if(isset($G['lon'])) {
596
-             $d1 = $this->geoDistance($L,$G); 
597
-             if( $d1 < $dist)
594
+            $G=$idp['geo'];
595
+            if(isset($G['lon'])) {
596
+                $d1 = $this->geoDistance($L,$G); 
597
+                if( $d1 < $dist)
598 598
                 $dist = $d1;
599
-          } else {
599
+            } else {
600 600
             foreach ($G as $g) {
601
-             $d1 = $this->geoDistance($L,$g); 
602
-             if( $d1 < $dist)
601
+                $d1 = $this->geoDistance($L,$g); 
602
+                if( $d1 < $dist)
603 603
                 $dist = $d1;
604 604
             }
605
-          }
605
+            }
606 606
         }
607
-       if($dist > 100)
608
-         $dist=10000;
609
-      $d = sprintf("%06d",$dist);
610
-      $R[$idp['entityID']] = $d." ".$idp['title'];
611
-     }
612
-     asort($R);
613
-     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]];
618
-      }
619
-     return($outarray);
607
+        if($dist > 100)
608
+            $dist=10000;
609
+        $d = sprintf("%06d",$dist);
610
+        $R[$idp['entityID']] = $d." ".$idp['title'];
611
+        }
612
+        asort($R);
613
+        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]];
618
+        }
619
+        return($outarray);
620 620
 }
621 621
 
622 622
 /**
623
-  * Detect the best device driver form the browser
624
-  *
625
-  * Detects the operating system and returns its id 
626
-  * display name and group membership (as in devices.php)
627
-  * @return array indexed by 'id', 'display', 'group'
628
-  */
623
+ * Detect the best device driver form the browser
624
+ *
625
+ * Detects the operating system and returns its id 
626
+ * display name and group membership (as in devices.php)
627
+ * @return array indexed by 'id', 'display', 'group'
628
+ */
629 629
 
630 630
 public function detectOS() {
631
-   $Dev = Devices::listDevices();
632
-   if( isset($_REQUEST['device']) && isset($Dev[$_REQUEST['device']]) && (!isset($device['options']['hidden']) || $device['options']['hidden'] == 0)) {
633
-      $dev_id = $_REQUEST['device'];
634
-      $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']]);
639
-   }
640
-   $browser = $_SERVER['HTTP_USER_AGENT'];
641
-   debug(4,"HTTP_USER_AGENT=$browser\n");
642
-   foreach ($Dev as $dev_id => $device) {
643
-     if(!isset($device['match']))
631
+    $Dev = Devices::listDevices();
632
+    if( isset($_REQUEST['device']) && isset($Dev[$_REQUEST['device']]) && (!isset($device['options']['hidden']) || $device['options']['hidden'] == 0)) {
633
+        $dev_id = $_REQUEST['device'];
634
+        $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']]);
639
+    }
640
+    $browser = $_SERVER['HTTP_USER_AGENT'];
641
+    debug(4,"HTTP_USER_AGENT=$browser\n");
642
+    foreach ($Dev as $dev_id => $device) {
643
+        if(!isset($device['match']))
644 644
         continue;
645
-     if(preg_match('/'.$device['match'].'/',$browser)) {
646
-       if(!isset($device['options']['hidden']) || $device['options']['hidden'] == 0) {
647
-          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 {
654
-         debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n");
655
-         return(false);
656
-       }
657
-     }
658
-   }
659
-   debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n");
660
-   return(false);
645
+        if(preg_match('/'.$device['match'].'/',$browser)) {
646
+        if(!isset($device['options']['hidden']) || $device['options']['hidden'] == 0) {
647
+            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 {
654
+            debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n");
655
+            return(false);
656
+        }
657
+        }
658
+    }
659
+    debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n");
660
+    return(false);
661 661
 }
662 662
 
663 663
 public function JSON_detectOS() {
664
-     $return_array=$this->detectOS();
665
-     if($return_array)
664
+        $return_array=$this->detectOS();
665
+        if($return_array)
666 666
         $status = 1;
667
-     else
667
+        else
668 668
         $status = 0;
669
-     echo $this->return_json($return_array,$status);
669
+        echo $this->return_json($return_array,$status);
670 670
 }
671 671
 
672 672
 
@@ -676,6 +676,6 @@  discard block
 block discarded – undo
676 676
   
677 677
 }
678 678
 function profile_sort($P1,$P2) {
679
-   return strcasecmp($P1->name, $P2->name);
679
+    return strcasecmp($P1->name, $P2->name);
680 680
 } 
681 681
 ?>
Please login to merge, or discard this patch.
Spacing   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -52,21 +52,21 @@  discard block
 block discarded – undo
52 52
  *  link - the path name of the resulting installer
53 53
  *  mime - the mimetype of the installer
54 54
  */
55
-  public function generateInstaller($device,$prof_id, $generated_for = "user") {
55
+  public function generateInstaller($device, $prof_id, $generated_for = "user") {
56 56
     $this->set_locale("devices");
57 57
     $Dev = Devices::listDevices();
58 58
     $Config = $Dev[$device];
59
-    debug(4,"installer:$device:$prof_id\n");
59
+    debug(4, "installer:$device:$prof_id\n");
60 60
     $profile = new Profile($prof_id);
61 61
     $attribs = $profile->getCollapsedAttributes();
62 62
     // test if the profile is production-ready and if not if the authenticated user is an owner
63 63
     if (!isset($attribs['profile:production']) || (isset($attribs['profile:production']) && $attribs['profile:production'][0] != "on")) {
64
-       debug(4,"Attempt to download a non-production ready installer fir profile: $prof_id\n");
64
+       debug(4, "Attempt to download a non-production ready installer fir profile: $prof_id\n");
65 65
        require_once(Config::$AUTHENTICATION['ssp-path-to-autoloader']);
66 66
        $as = new SimpleSAML_Auth_Simple(Config::$AUTHENTICATION['ssp-authsource']);
67
-       if($as->isAuthenticated()) {
67
+       if ($as->isAuthenticated()) {
68 68
           $user_object = new User($_SESSION['user']);
69
-          if($user_object->isIdPOwner($profile->institution)) {
69
+          if ($user_object->isIdPOwner($profile->institution)) {
70 70
               debug(4, "User is the owner - allowing access\n");
71 71
           } else {
72 72
              debug(2, "User not an owner of a non-production profile - access forbidden\n");
@@ -82,38 +82,38 @@  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'] ))
85
+    if ((isset(Devices::$Options['no_cache']) && Devices::$Options['no_cache']) || (isset($Config['options']['no_cache']) && $Config['options']['no_cache']))
86 86
       $this->i_path = FALSE;
87 87
     else {
88 88
       $cache = $profile->testCache($device);
89 89
       $this->i_path = $cache['cache'];
90 90
     }
91
-    if($this->i_path && is_file($this->i_path)) { 
92
-      debug(4,"Using cached installer for: $device\n");
93
-      $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for";
91
+    if ($this->i_path && is_file($this->i_path)) { 
92
+      debug(4, "Using cached installer for: $device\n");
93
+      $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=" . CAT::get_lang() . "&profile=$prof_id&device=$device&generatedfor=$generated_for";
94 94
       $a['mime'] = $cache['mime'];
95 95
     } else {
96 96
       $factory = new DeviceFactory($device);
97 97
       $dev = $factory->device;
98
-      if(isset($dev)) {
98
+      if (isset($dev)) {
99 99
          $dev->setup($profile);
100 100
          $installer = $dev->writeInstaller();
101
-         $i_path = $dev->FPATH.'/tmp/'.$installer;
102
-         if($i_path && is_file($i_path)) {
103
-         if(isset($dev->options['mime']))
101
+         $i_path = $dev->FPATH . '/tmp/' . $installer;
102
+         if ($i_path && is_file($i_path)) {
103
+         if (isset($dev->options['mime']))
104 104
                $a['mime'] = $dev->options['mime'];
105 105
          else {
106 106
            $info = new finfo();
107 107
            $a['mime'] = $info->file($i_path, FILEINFO_MIME_TYPE);
108 108
          }
109
-         $this->i_path = $dev->FPATH.'/'.$installer;
109
+         $this->i_path = $dev->FPATH . '/' . $installer;
110 110
          rename($i_path, $this->i_path);
111
-         $profile->updateCache($device,$this->i_path,$a['mime']);
111
+         $profile->updateCache($device, $this->i_path, $a['mime']);
112 112
 //         rrmdir($dev->FPATH.'/tmp');
113
-         debug(4,"Generated installer: ".$this->i_path.": for: $device\n");
114
-         $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for";
113
+         debug(4, "Generated installer: " . $this->i_path . ": for: $device\n");
114
+         $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=" . CAT::get_lang() . "&profile=$prof_id&device=$device&generatedfor=$generated_for";
115 115
          } else {
116
-         debug(2,"Installer generation failed for: $prof_id:$device:".CAT::get_lang()."\n");
116
+         debug(2, "Installer generation failed for: $prof_id:$device:" . CAT::get_lang() . "\n");
117 117
          $a['link'] = 0;
118 118
          }
119 119
       } 
@@ -129,31 +129,31 @@  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)
132
+    if ($show_hidden !== 0 && $show_hidden != 1)
133 133
       return;
134 134
     foreach ($Dev as $device => $D) {
135
-      if(isset($D['options']['hidden']) && $D['options']['hidden'] && $show_hidden == 0)
135
+      if (isset($D['options']['hidden']) && $D['options']['hidden'] && $show_hidden == 0)
136 136
          continue;
137
-      $ct ++;
138
-      if($this->version == 1)
137
+      $ct++;
138
+      if ($this->version == 1)
139 139
          $D['device'] = $device;
140 140
       else
141 141
          $D['device'] = $device;
142 142
       $group = isset($D['group']) ? $D['group'] : 'other';
143
-      if (! isset($R[$group]))
143
+      if (!isset($R[$group]))
144 144
          $R[$group] = [];
145 145
       $R[$group][$device] = $D;
146 146
     }
147 147
    return $R;
148 148
  }
149 149
 
150
- public function deviceInfo($device,$prof_id) {
150
+ public function deviceInfo($device, $prof_id) {
151 151
     $this->set_locale("devices");
152 152
     $out = 0;
153 153
     $profile = new Profile($prof_id);
154 154
     $factory = new DeviceFactory($device);
155 155
     $dev = $factory->device;
156
-    if(isset($dev)) {
156
+    if (isset($dev)) {
157 157
 //       $dev->setup($profile);
158 158
        $out = $dev->writeDeviceInfo();
159 159
    }
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
       $profile = new Profile($prof_id);
179 179
       $attr = $profile->getCollapsedAttributes();
180 180
       $a = [];
181
-      if(isset($attr['support:email']))
181
+      if (isset($attr['support:email']))
182 182
          $a['local_email'] = $attr['support:email'][0];
183
-      if(isset($attr['support:phone']))
183
+      if (isset($attr['support:phone']))
184 184
          $a['local_phone'] = $attr['support:phone'][0];
185
-      if(isset($attr['support:url']))
185
+      if (isset($attr['support:url']))
186 186
          $a['local_url'] = $attr['support:url'][0];
187
-      if(isset($attr['profile:description']))
187
+      if (isset($attr['profile:description']))
188 188
          $a['description'] = $attr['profile:description'][0];
189 189
       $a['devices'] = $profile->listDevices();
190 190
       $this->set_locale("web_user");
@@ -196,30 +196,30 @@  discard block
 block discarded – undo
196 196
    cicumstances
197 197
 */
198 198
 private function GetRootURL() {
199
-    $backtrace =  debug_backtrace();
199
+    $backtrace = debug_backtrace();
200 200
     $F = array_pop($backtrace);
201
-    $file= $F['file'];
202
-    $file = substr($file,strlen(dirname(__DIR__)));
203
-    while(substr($file,0,1) == '/')
204
-       $file = substr($file,1);
205
-    $n = count(explode('/',$file));
201
+    $file = $F['file'];
202
+    $file = substr($file, strlen(dirname(__DIR__)));
203
+    while (substr($file, 0, 1) == '/')
204
+       $file = substr($file, 1);
205
+    $n = count(explode('/', $file));
206 206
     $out = $_SERVER['SCRIPT_NAME'];
207
-    for ($i= 0; $i < $n; $i++)
207
+    for ($i = 0; $i < $n; $i++)
208 208
       $out = dirname($out);
209 209
     if ($out == '/')
210 210
       $out = '';
211 211
     $s = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http';
212
-    $s .= '://'.$_SERVER['HTTP_HOST'] . $out;
212
+    $s .= '://' . $_SERVER['HTTP_HOST'] . $out;
213 213
     return $s;
214 214
 }
215 215
 
216 216
 /* JSON functions */
217 217
 
218
-  public function return_json($data,$status=1) {
218
+  public function return_json($data, $status = 1) {
219 219
      $return_array = [];
220 220
      $return_array['status'] = $status;
221 221
      $return_array['data'] = $data;
222
-     $return_array['tou'] =  "Please consult Terms of Use at: ".$this->GetRootURL()."/tou.php";
222
+     $return_array['tou'] = "Please consult Terms of Use at: " . $this->GetRootURL() . "/tou.php";
223 223
      return(json_encode($return_array));
224 224
   }
225 225
 
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
   */
231 231
   public function JSON_listLanguages() {
232 232
      $return_array = [];
233
-     foreach(Config::$LANGUAGES as $id => $val){
234
-       if($this->version == 1)
235
-          $return_array[] = ['id'=>$id,'display'=>$val['display'],'locale'=>$val['locale']];
233
+     foreach (Config::$LANGUAGES as $id => $val) {
234
+       if ($this->version == 1)
235
+          $return_array[] = ['id'=>$id, 'display'=>$val['display'], 'locale'=>$val['locale']];
236 236
        else
237
-          $return_array[] = ['lang'=>$id,'display'=>$val['display'],'locale'=>$val['locale']];
237
+          $return_array[] = ['lang'=>$id, 'display'=>$val['display'], 'locale'=>$val['locale']];
238 238
      }
239 239
      echo $this->return_json($return_array);
240 240
   }
@@ -249,10 +249,10 @@  discard block
 block discarded – undo
249 249
      $FED = $this->printCountryList(1);
250 250
      $return_array = [];
251 251
      foreach ($FED as $id => $val) {
252
-       if($this->version == 1)
253
-          $return_array[] = ['id'=>$id,'display'=>$val];
252
+       if ($this->version == 1)
253
+          $return_array[] = ['id'=>$id, 'display'=>$val];
254 254
        else
255
-          $return_array[] = ['federation'=>$id,'display'=>$val];
255
+          $return_array[] = ['federation'=>$id, 'display'=>$val];
256 256
      }
257 257
      echo $this->return_json($return_array);
258 258
   }
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
  */
266 266
 
267 267
   public function JSON_listIdentityProviders($country) {
268
-     $idps = Federation::listAllIdentityProviders(1,$country);
268
+     $idps = Federation::listAllIdentityProviders(1, $country);
269 269
      $return_array = [];
270 270
      foreach ($idps as $idp) {
271
-        if($this->version == 1)
272
-           $return_array[] = ['id'=>$idp['entityID'],'display'=>$idp['title']];
271
+        if ($this->version == 1)
272
+           $return_array[] = ['id'=>$idp['entityID'], 'display'=>$idp['title']];
273 273
         else
274
-           $return_array[] = ['idp'=>$idp['entityID'],'display'=>$idp['title']];
274
+           $return_array[] = ['idp'=>$idp['entityID'], 'display'=>$idp['title']];
275 275
      }
276 276
      echo $this->return_json($return_array);
277 277
   }
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
      $idps = Federation::listAllIdentityProviders(1);
288 288
      $return_array = [];
289 289
      foreach ($idps as $idp) {
290
-        if($this->version == 1)
290
+        if ($this->version == 1)
291 291
            $idp['id'] = $idp['entityID'];
292 292
          else
293 293
            $idp['idp'] = $idp['entityID'];
@@ -306,14 +306,14 @@  discard block
 block discarded – undo
306 306
  */
307 307
 
308 308
 
309
-  public function JSON_orderIdentityProviders($country,$L=NULL) {
310
-     $idps = $this->orderIdentityProviders($country,$L);
309
+  public function JSON_orderIdentityProviders($country, $L = NULL) {
310
+     $idps = $this->orderIdentityProviders($country, $L);
311 311
      $return_array = [];
312 312
      foreach ($idps as $idp) {
313
-        if($this->version == 1)
314
-           $return_array[] = ['id'=>$idp['id'],'display'=>$idp['title']];
313
+        if ($this->version == 1)
314
+           $return_array[] = ['id'=>$idp['id'], 'display'=>$idp['title']];
315 315
         else
316
-           $return_array[] = ['idp'=>$idp['id'],'display'=>$idp['title']];
316
+           $return_array[] = ['idp'=>$idp['id'], 'display'=>$idp['title']];
317 317
      }
318 318
      echo $this->return_json($return_array);
319 319
   }
@@ -324,28 +324,28 @@  discard block
 block discarded – undo
324 324
  * @param int $idp_id the IdP identifier
325 325
  * @return string JSON encoded data
326 326
  */
327
-  public function JSON_listProfiles($idp_id,$sort = 0) {
327
+  public function JSON_listProfiles($idp_id, $sort = 0) {
328 328
      $this->set_locale("web_user");
329 329
      $return_array = [];
330 330
      try {     
331 331
          $idp = new IdP($idp_id);
332 332
      }
333 333
      catch (Exception $fail) {
334
-        echo $this->return_json($return_array,0);
334
+        echo $this->return_json($return_array, 0);
335 335
         return;
336 336
      }
337 337
      $l = 0;
338 338
      $logo = $idp->getAttributes('general:logo_file');
339
-     if($logo)
339
+     if ($logo)
340 340
        $l = 1;
341 341
      $profiles = $idp->listProfiles(1);
342
-     if($sort == 1)
343
-        usort($profiles,"profile_sort");
342
+     if ($sort == 1)
343
+        usort($profiles, "profile_sort");
344 344
      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]; 
345
+       if ($this->version == 1)
346
+          $return_array[] = ['id'=>$P->identifier, 'display'=>$P->name, 'idp_name'=>$P->inst_name, 'logo'=>$l]; 
347 347
        else
348
-          $return_array[] = ['profile'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; 
348
+          $return_array[] = ['profile'=>$P->identifier, 'display'=>$P->name, 'idp_name'=>$P->inst_name, 'logo'=>$l]; 
349 349
      }
350 350
      echo $this->return_json($return_array);
351 351
   }
@@ -361,20 +361,20 @@  discard block
 block discarded – undo
361 361
      $return_array = [];
362 362
      $a = $this->profileAttributes($profile_id);
363 363
      $thedevices = $a['devices'];
364
-     if(!isset($profile_redirect) || ! $profile_redirect) {
364
+     if (!isset($profile_redirect) || !$profile_redirect) {
365 365
          $profile_redirect = 0;
366 366
          foreach ($thedevices as $D) {
367
-              if(isset($D['options']) && isset($D['options']['hidden']) &&  $D['options']['hidden'])
367
+              if (isset($D['options']) && isset($D['options']['hidden']) && $D['options']['hidden'])
368 368
                    continue;
369 369
               $disp = $D['display'];
370
-              if($this->version == 1) {
371
-                 if($D['id'] === '0') {
370
+              if ($this->version == 1) {
371
+                 if ($D['id'] === '0') {
372 372
                      $profile_redirect = 1;
373 373
                      $disp = $c;
374 374
                  }
375 375
                 $return_array[] = ['id'=>$D['id'], 'display'=>$disp, 'status'=>$D['status'], 'redirect'=>$D['redirect']];
376 376
              } else {
377
-                 if($D['device'] === '0') {
377
+                 if ($D['device'] === '0') {
378 378
                      $profile_redirect = 1;
379 379
                      $disp = $c;
380 380
                  }
@@ -393,12 +393,12 @@  discard block
 block discarded – undo
393 393
  * @param int $prof_id profile identifier
394 394
  * @return string JSON encoded data
395 395
  */
396
-  public function JSON_generateInstaller($device,$prof_id) {
397
-    debug(4,"JSON::generateInstaller arguments: $device,$prof_id\n");
398
-    $o = $this->generateInstaller($device,$prof_id);
399
-    debug(4,"output from GUI::generateInstaller:");
400
-    debug(4,$o);
401
-    debug(4,json_encode($o));
396
+  public function JSON_generateInstaller($device, $prof_id) {
397
+    debug(4, "JSON::generateInstaller arguments: $device,$prof_id\n");
398
+    $o = $this->generateInstaller($device, $prof_id);
399
+    debug(4, "output from GUI::generateInstaller:");
400
+    debug(4, $o);
401
+    debug(4, json_encode($o));
402 402
 //    header('Content-type: application/json; utf-8');
403 403
     echo $this->return_json($o);
404 404
  }
@@ -411,12 +411,12 @@  discard block
 block discarded – undo
411 411
  * @return binary installerFile
412 412
  */
413 413
 
414
- public function downloadInstaller($device,$prof_id,$generated_for='user') {
415
-    debug(4,"downloadInstaller arguments: $device,$prof_id,$generated_for\n");
416
-    $o = $this->generateInstaller($device,$prof_id);
417
-    debug(4,"output from GUI::generateInstaller:");
418
-    debug(4,$o);
419
-    if(! $o['link']) {
414
+ public function downloadInstaller($device, $prof_id, $generated_for = 'user') {
415
+    debug(4, "downloadInstaller arguments: $device,$prof_id,$generated_for\n");
416
+    $o = $this->generateInstaller($device, $prof_id);
417
+    debug(4, "output from GUI::generateInstaller:");
418
+    debug(4, $o);
419
+    if (!$o['link']) {
420 420
        header("HTTP/1.0 404 Not Found");
421 421
        return;
422 422
     }
@@ -424,9 +424,9 @@  discard block
 block discarded – undo
424 424
     $profile->incrementDownloadStats($device, $generated_for);
425 425
     $file = $this->i_path;
426 426
     $filetype = $o['mime'];
427
-    debug(4,"installer MIME type:$filetype\n");
428
-    header("Content-type: ".$filetype);
429
-    header('Content-Disposition: inline; filename="'.basename($file).'"');
427
+    debug(4, "installer MIME type:$filetype\n");
428
+    header("Content-type: " . $filetype);
429
+    header('Content-Disposition: inline; filename="' . basename($file) . '"');
430 430
     header('Content-Length: ' . filesize($file));
431 431
     ob_clean();
432 432
     flush();
@@ -444,67 +444,67 @@  discard block
 block discarded – undo
444 444
  *
445 445
  */
446 446
 
447
- public function sendLogo($idp_id, $disco=FALSE, $width=0, $height=0) {
447
+ public function sendLogo($idp_id, $disco = FALSE, $width = 0, $height = 0) {
448 448
    $ExpStr = '';
449 449
    $resize = 0;
450
-   if(($width || $height) && is_numeric($width) && is_numeric($height)) {
450
+   if (($width || $height) && is_numeric($width) && is_numeric($height)) {
451 451
        $resize = 1;
452
-       if($height == 0)
452
+       if ($height == 0)
453 453
           $height = 10000;
454
-       if($width == 0)
454
+       if ($width == 0)
455 455
           $width = 10000;
456
-       $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png';
457
-   } elseif($disco == 1) {
456
+       $logo_file = CAT::$root . '/web/downloads/logos/' . $idp_id . '_' . $width . '_' . $height . '.png';
457
+   } elseif ($disco == 1) {
458 458
        $width = 120;
459 459
        $height = 40;
460 460
        $resize = 1;
461
-       $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png';
461
+       $logo_file = CAT::$root . '/web/downloads/logos/' . $idp_id . '_' . $width . '_' . $height . '.png';
462 462
    }
463 463
 
464
-   if($resize && is_file($logo_file)){
465
-      debug(4,"Using cached logo $logo_file for: $idp_id\n");
464
+   if ($resize && is_file($logo_file)) {
465
+      debug(4, "Using cached logo $logo_file for: $idp_id\n");
466 466
       $blob = file_get_contents($logo_file);
467 467
       $filetype = 'image/png';
468 468
    }
469 469
    else {
470 470
       $idp = new IdP($idp_id);
471 471
       $at = $idp->getAttributes('general:logo_file');
472
-      $blob =  $at[0]['value'];
472
+      $blob = $at[0]['value'];
473 473
       $info = new finfo();
474 474
       $filetype = $info->buffer($blob, FILEINFO_MIME_TYPE);
475 475
       $offset = 60 * 60 * 24 * 30;
476
-      $ExpStr = "Expires: " . gmdate( "D, d M Y H:i:s", time() + $offset ) . " GMT";
477
-      if($resize) {
476
+      $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
477
+      if ($resize) {
478 478
          $filetype = 'image/png';
479 479
          $image = new Imagick();
480 480
          $image->readImageBlob($blob);
481
-         if( $image->setImageFormat('PNG')) {
482
-           $image->thumbnailImage($width,$height,1);
481
+         if ($image->setImageFormat('PNG')) {
482
+           $image->thumbnailImage($width, $height, 1);
483 483
            $blob = $image->getImageBlob();
484
-           debug(4,"Writing cached logo $logo_file for: $idp_id\n");
485
-           file_put_contents($logo_file,$blob);
484
+           debug(4, "Writing cached logo $logo_file for: $idp_id\n");
485
+           file_put_contents($logo_file, $blob);
486 486
          }
487 487
          else
488 488
            $blob = "XXXXXX";
489 489
       }
490 490
    }
491
-   header( "Content-type: ".$filetype );
492
-   header( "Cache-Control:max-age=36000, must-revalidate" );
493
-   header( $ExpStr );
491
+   header("Content-type: " . $filetype);
492
+   header("Cache-Control:max-age=36000, must-revalidate");
493
+   header($ExpStr);
494 494
    echo $blob;
495 495
  }
496 496
 
497 497
  public function locateUser() {
498 498
    $host = $_SERVER['REMOTE_ADDR'];
499 499
    $record = geoip_record_by_name($host);
500
-   if($record) {
500
+   if ($record) {
501 501
      $result = ['status' => 'ok'];
502 502
      $result['country'] = $record['country_code'];
503 503
 //  the two lines below are a dirty hack to take of the error in naming the UK federation
504
-     if($result['country'] == 'GB')
504
+     if ($result['country'] == 'GB')
505 505
          $result['country'] = 'UK';
506 506
      $result['region'] = $record['region'];
507
-     $result['geo'] = ['lat' => (float)$record['latitude'] , 'lon' => (float)$record['longitude']];
507
+     $result['geo'] = ['lat' => (float) $record['latitude'], 'lon' => (float) $record['longitude']];
508 508
    } else {
509 509
      $result = ['status' => 'error', 'error' =>'Problem listing countries']; 
510 510
    }
@@ -525,22 +525,22 @@  discard block
 block discarded – undo
525 525
    $result = ['status' => 'ok'];
526 526
    $result['country'] = $record->country->isoCode;
527 527
 //  the two lines below are a dirty hack to take of the error in naming the UK federation
528
-   if($result['country'] == 'GB')
528
+   if ($result['country'] == 'GB')
529 529
        $result['country'] = 'UK';
530 530
    $result['region'] = $record->continent->name;
531 531
 
532
-   $result['geo'] = ['lat' => (float)$record->location->latitude , 'lon' => (float)$record->location->longitude];
532
+   $result['geo'] = ['lat' => (float) $record->location->latitude, 'lon' => (float) $record->location->longitude];
533 533
    return($result);
534 534
  }
535 535
 
536 536
 public function JSON_locateUser() {
537 537
     header('Content-type: application/json; utf-8');
538 538
    
539
-    if(empty(Config::$GEOIP['version']) || Config::$GEOIP['version'] == 0)
539
+    if (empty(Config::$GEOIP['version']) || Config::$GEOIP['version'] == 0)
540 540
       echo json_encode(['status' => 'error', 'error' =>'Geolocation not supported']);
541
-    if(Config::$GEOIP['version'] == 1)
541
+    if (Config::$GEOIP['version'] == 1)
542 542
       echo json_encode($this->locateUser());
543
-    if(Config::$GEOIP['version'] == 2)
543
+    if (Config::$GEOIP['version'] == 2)
544 544
       echo json_encode($this->locateUser2());
545 545
 }
546 546
 
@@ -560,11 +560,11 @@  discard block
 block discarded – undo
560 560
   * @param array $P2 - second point as an 'lat', 'lon' array 
561 561
   * @return float distance in km
562 562
   */
563
-private function geoDistance($P1,$P2) {
563
+private function geoDistance($P1, $P2) {
564 564
 
565 565
   $dist = sin(deg2rad($P1['lat'])) * sin(deg2rad($P2['lat'])) +  
566 566
          cos(deg2rad($P1['lat'])) * cos(deg2rad($P2['lat'])) * cos(deg2rad($P1['lon'] - $P2['lon']));
567
-  $dist = rad2deg(acos($dist)) * 60 * 1.1852 ;
567
+  $dist = rad2deg(acos($dist)) * 60 * 1.1852;
568 568
   return(round($dist));
569 569
 }
570 570
 
@@ -574,44 +574,44 @@  discard block
 block discarded – undo
574 574
   * @return array $IdPs -  list of arrays ('id', 'name');
575 575
   */
576 576
 
577
-public function orderIdentityProviders($country,$L=NULL) {
578
-     $idps = Federation::listAllIdentityProviders(1,$country);
577
+public function orderIdentityProviders($country, $L = NULL) {
578
+     $idps = Federation::listAllIdentityProviders(1, $country);
579 579
 
580
-  if(is_null($L)) {
580
+  if (is_null($L)) {
581 581
      $U = $this->locateUser();
582
-     if($U['status'] == 'ok') {
582
+     if ($U['status'] == 'ok') {
583 583
      $L = $U['geo'];
584 584
      } else {
585
-       $L = ['lat'=>"90",'lon'=>"0"];
585
+       $L = ['lat'=>"90", 'lon'=>"0"];
586 586
      }
587 587
   }
588
-  $T=[];
589
-  $R=[];
588
+  $T = [];
589
+  $R = [];
590 590
      foreach ($idps as $idp) {
591 591
         $T[$idp['entityID']] = $idp['title'];
592 592
         $dist = 10000;
593
-        if(isset($idp['geo'])) {
594
-          $G=$idp['geo'];
595
-          if(isset($G['lon'])) {
596
-             $d1 = $this->geoDistance($L,$G); 
597
-             if( $d1 < $dist)
593
+        if (isset($idp['geo'])) {
594
+          $G = $idp['geo'];
595
+          if (isset($G['lon'])) {
596
+             $d1 = $this->geoDistance($L, $G); 
597
+             if ($d1 < $dist)
598 598
                 $dist = $d1;
599 599
           } else {
600 600
             foreach ($G as $g) {
601
-             $d1 = $this->geoDistance($L,$g); 
602
-             if( $d1 < $dist)
601
+             $d1 = $this->geoDistance($L, $g); 
602
+             if ($d1 < $dist)
603 603
                 $dist = $d1;
604 604
             }
605 605
           }
606 606
         }
607
-       if($dist > 100)
608
-         $dist=10000;
609
-      $d = sprintf("%06d",$dist);
610
-      $R[$idp['entityID']] = $d." ".$idp['title'];
607
+       if ($dist > 100)
608
+         $dist = 10000;
609
+      $d = sprintf("%06d", $dist);
610
+      $R[$idp['entityID']] = $d . " " . $idp['title'];
611 611
      }
612 612
      asort($R);
613 613
      foreach (array_keys($R) as $r) {
614
-      if($this->version == 1)
614
+      if ($this->version == 1)
615 615
          $outarray[] = ['id'=>$r, 'title'=>$T[$r]];
616 616
       else
617 617
          $outarray[] = ['idp'=>$r, 'title'=>$T[$r]];
@@ -629,44 +629,44 @@  discard block
 block discarded – undo
629 629
 
630 630
 public function detectOS() {
631 631
    $Dev = Devices::listDevices();
632
-   if( isset($_REQUEST['device']) && isset($Dev[$_REQUEST['device']]) && (!isset($device['options']['hidden']) || $device['options']['hidden'] == 0)) {
632
+   if (isset($_REQUEST['device']) && isset($Dev[$_REQUEST['device']]) && (!isset($device['options']['hidden']) || $device['options']['hidden'] == 0)) {
633 633
       $dev_id = $_REQUEST['device'];
634 634
       $device = $Dev[$dev_id];
635
-      if($this->version == 1)
636
-         return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]);
635
+      if ($this->version == 1)
636
+         return(['id'=>$dev_id, 'display'=>$device['display'], 'group'=>$device['group']]);
637 637
       else
638
-         return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]);
638
+         return(['device'=>$dev_id, 'display'=>$device['display'], 'group'=>$device['group']]);
639 639
    }
640 640
    $browser = $_SERVER['HTTP_USER_AGENT'];
641
-   debug(4,"HTTP_USER_AGENT=$browser\n");
641
+   debug(4, "HTTP_USER_AGENT=$browser\n");
642 642
    foreach ($Dev as $dev_id => $device) {
643
-     if(!isset($device['match']))
643
+     if (!isset($device['match']))
644 644
         continue;
645
-     if(preg_match('/'.$device['match'].'/',$browser)) {
646
-       if(!isset($device['options']['hidden']) || $device['options']['hidden'] == 0) {
647
-          debug(4,"Browser_id: $dev_id\n");
648
-          if($this->version == 1)
649
-             return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]);
645
+     if (preg_match('/' . $device['match'] . '/', $browser)) {
646
+       if (!isset($device['options']['hidden']) || $device['options']['hidden'] == 0) {
647
+          debug(4, "Browser_id: $dev_id\n");
648
+          if ($this->version == 1)
649
+             return(['id'=>$dev_id, 'display'=>$device['display'], 'group'=>$device['group']]);
650 650
           else
651
-             return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]);
651
+             return(['device'=>$dev_id, 'display'=>$device['display'], 'group'=>$device['group']]);
652 652
        }
653 653
        else {
654
-         debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n");
654
+         debug(2, "Unrecognised system: " . $_SERVER['HTTP_USER_AGENT'] . "\n");
655 655
          return(false);
656 656
        }
657 657
      }
658 658
    }
659
-   debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n");
659
+   debug(2, "Unrecognised system: " . $_SERVER['HTTP_USER_AGENT'] . "\n");
660 660
    return(false);
661 661
 }
662 662
 
663 663
 public function JSON_detectOS() {
664
-     $return_array=$this->detectOS();
665
-     if($return_array)
664
+     $return_array = $this->detectOS();
665
+     if ($return_array)
666 666
         $status = 1;
667 667
      else
668 668
         $status = 0;
669
-     echo $this->return_json($return_array,$status);
669
+     echo $this->return_json($return_array, $status);
670 670
 }
671 671
 
672 672
 
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 private $i_path;
676 676
   
677 677
 }
678
-function profile_sort($P1,$P2) {
678
+function profile_sort($P1, $P2) {
679 679
    return strcasecmp($P1->name, $P2->name);
680 680
 } 
681 681
 ?>
Please login to merge, or discard this 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/UserManagement.php 3 patches
Doc Comments   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -211,10 +211,9 @@  discard block
 block discarded – undo
211 211
      * 
212 212
      * @param boolean $by_fedadmin is the invitation token created for a federation admin or from an existing inst admin
213 213
      * @param type $for identifier (typically email address) for which the invitation is created
214
-     * @param mixed $inst either an instance of the IdP class (for existing institutions to invite new admins) or a string (new institution - this is the inst name then)
215
-     * @param string $external_id if the IdP to be created is related to an external DB entity, this parameter contains that ID
216
-     * @param type $country if the institution is new (i.e. $inst is a string) this parameter needs to specify the federation of the new inst
217
-     * @return mixed The function returns either the token (as string) or FALSE if something went wrong
214
+     * @param integer $external_id if the IdP to be created is related to an external DB entity, this parameter contains that ID
215
+     * @param integer $country if the institution is new (i.e. $inst is a string) this parameter needs to specify the federation of the new inst
216
+     * @return string|false The function returns either the token (as string) or FALSE if something went wrong
218 217
      */
219 218
     public function createToken($by_fedadmin, $for, $inst_identifier, $external_id = 0, $country = 0) {
220 219
         $for = DBConnection::escape_value(UserManagement::$DB_TYPE, $for);
@@ -245,7 +244,7 @@  discard block
 block discarded – undo
245 244
     /**
246 245
      * Retrieves all pending invitations for an institution or for a federation.
247 246
      * 
248
-     * @param type $idp_identifier the identifier of the institution. If not set, returns invitations for not-yet-created insts
247
+     * @param integer $idp_identifier the identifier of the institution. If not set, returns invitations for not-yet-created insts
249 248
      * @return if idp_identifier is set: an array of strings (mail addresses); otherwise an array of tuples (country;name;mail)
250 249
      */
251 250
     public function listPendingInvitations($idp_identifier = 0) {
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 %s"), $bestnameguess, Config::$CONSORTIUM['name'], strtoupper($fed->identifier), Config::$APPEARANCE['productname'], Config::$APPEARANCE['productname_long']);
159 159
                     $retval = $user->sendMailToUser(_("IdP in your federation was created"), $message);
160 160
                     if ($retval == FALSE)
161
-                        debug (2, "Mail to federation admin was NOT sent!\n");
161
+                        debug(2, "Mail to federation admin was NOT sent!\n");
162 162
                 }
163 163
 
164 164
                 return $idp;
@@ -226,14 +226,14 @@  discard block
 block discarded – undo
226 226
             return $token;
227 227
         } else if (func_num_args() == 4) { // string name, but no country - new IdP with link to external DB
228 228
             // what country are we talking about?
229
-            $newname = DBConnection::escape_value(UserManagement::$DB_TYPE,valid_string_db($inst_identifier));
229
+            $newname = DBConnection::escape_value(UserManagement::$DB_TYPE, valid_string_db($inst_identifier));
230 230
             $extinfo = Federation::getExternalDBEntityDetails($external_id);
231
-            $externalhandle = DBConnection::escape_value(UserManagement::$DB_TYPE,valid_string_db($external_id));
231
+            $externalhandle = DBConnection::escape_value(UserManagement::$DB_TYPE, valid_string_db($external_id));
232 232
             DBConnection::exec(UserManagement::$DB_TYPE, "INSERT INTO invitations (invite_issuer_level, invite_dest_mail, invite_token,name,country, external_db_uniquehandle) VALUES('$level', '$for', '$token', '" . $newname . "', '" . $extinfo['country'] . "',  '" . $externalhandle . "')");
233 233
             return $token;
234 234
         } else if (func_num_args() == 5) { // string name, and country set - whole new IdP
235
-            $newname = DBConnection::escape_value(UserManagement::$DB_TYPE,valid_string_db($inst_identifier));
236
-            $newcountry = DBConnection::escape_value(UserManagement::$DB_TYPE,valid_string_db($country));
235
+            $newname = DBConnection::escape_value(UserManagement::$DB_TYPE, valid_string_db($inst_identifier));
236
+            $newcountry = DBConnection::escape_value(UserManagement::$DB_TYPE, valid_string_db($country));
237 237
             DBConnection::exec(UserManagement::$DB_TYPE, "INSERT INTO invitations (invite_issuer_level, invite_dest_mail, invite_token,name,country) VALUES('$level', '$for', '$token', '" . $newname . "', '" . $newcountry . "')");
238 238
             return $token;
239 239
         } else {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         $retval = [];
253 253
         $invitations = DBConnection::exec(UserManagement::$DB_TYPE, "SELECT cat_institution_id, country, name, invite_issuer_level, invite_dest_mail, invite_token 
254 254
                                         FROM invitations 
255
-                                        WHERE cat_institution_id " . ( $idp_identifier != 0 ? "= $idp_identifier" : "IS NULL") . " AND invite_created >= TIMESTAMPADD(DAY, -1, NOW()) AND used = 0");
255
+                                        WHERE cat_institution_id " . ($idp_identifier != 0 ? "= $idp_identifier" : "IS NULL") . " AND invite_created >= TIMESTAMPADD(DAY, -1, NOW()) AND used = 0");
256 256
         if ($idp_identifier != 0) { // list invitations for existing institution, must match cat_institution_id
257 257
             while ($a = mysqli_fetch_object($invitations)) {
258 258
                 debug(4, "Retrieving pending invitations for IdP $idp_identifier.\n");
Please login to merge, or discard this patch.
Braces   +22 added lines, -16 removed lines patch added patch discarded remove patch
@@ -78,10 +78,11 @@  discard block
 block discarded – undo
78 78
         } else { // invalid token... be a little verbose what's wrong with it
79 79
             $check_reason = DBConnection::exec(UserManagement::$DB_TYPE, "SELECT invite_token, used FROM invitations WHERE invite_token = '$token'");
80 80
             if ($a = mysqli_fetch_object($check_reason)) {
81
-                if ($a->used == 1)
82
-                    return "FAIL-ALREADYCONSUMED";
83
-                else
84
-                    return "FAIL-EXPIRED";
81
+                if ($a->used == 1) {
82
+                                    return "FAIL-ALREADYCONSUMED";
83
+                } else {
84
+                                    return "FAIL-EXPIRED";
85
+                }
85 86
             } else {
86 87
                 return "FAIL-NONEXISTINGTOKEN";
87 88
             }
@@ -157,8 +158,9 @@  discard block
 block discarded – undo
157 158
 
158 159
 %s"), $bestnameguess, Config::$CONSORTIUM['name'], strtoupper($fed->identifier), Config::$APPEARANCE['productname'], Config::$APPEARANCE['productname_long']);
159 160
                     $retval = $user->sendMailToUser(_("IdP in your federation was created"), $message);
160
-                    if ($retval == FALSE)
161
-                        debug (2, "Mail to federation admin was NOT sent!\n");
161
+                    if ($retval == FALSE) {
162
+                                            debug (2, "Mail to federation admin was NOT sent!\n");
163
+                    }
162 164
                 }
163 165
 
164 166
                 return $idp;
@@ -256,14 +258,16 @@  discard block
 block discarded – undo
256 258
         if ($idp_identifier != 0) { // list invitations for existing institution, must match cat_institution_id
257 259
             while ($a = mysqli_fetch_object($invitations)) {
258 260
                 debug(4, "Retrieving pending invitations for IdP $idp_identifier.\n");
259
-                if ($a->cat_institution_id == $idp_identifier)
260
-                    $retval[] = $a->invite_dest_mail;
261
+                if ($a->cat_institution_id == $idp_identifier) {
262
+                                    $retval[] = $a->invite_dest_mail;
263
+                }
261 264
             }
262 265
         } else { // list all invitations for *new* institutions
263 266
             while ($a = mysqli_fetch_object($invitations)) {
264 267
                 debug(4, "Retrieving pending invitations for NEW institutions.\n");
265
-                if ($a->cat_institution_id == NULL)
266
-                    $retval[] = ["country" => $a->country, "name" => $a->name, "mail" => $a->invite_dest_mail, "token" => $a->invite_token];
268
+                if ($a->cat_institution_id == NULL) {
269
+                                    $retval[] = ["country" => $a->country, "name" => $a->name, "mail" => $a->invite_dest_mail, "token" => $a->invite_token];
270
+                }
267 271
             }
268 272
         };
269 273
         return $retval;
@@ -280,10 +284,11 @@  discard block
 block discarded – undo
280 284
                                         WHERE invite_created >= TIMESTAMPADD(HOUR, -25, NOW()) AND invite_created < TIMESTAMPADD(HOUR, -24, NOW()) AND used = 0");
281 285
         while ($a = mysqli_fetch_object($invitations)) {
282 286
                 debug(4, "Retrieving recently expired invitations (expired in last hour)\n");
283
-                if ($a->cat_institution_id == NULL)
284
-                    $retval[] = ["country" => $a->country, "level" => $a->invite_issuer_level, "name" => $a->name, "mail" => $a->invite_dest_mail];
285
-                else
286
-                    $retval[] = ["country" => $a->country, "level" => $a->invite_issuer_level, "name" => "Existing IdP", "mail" => $a->invite_dest_mail];
287
+                if ($a->cat_institution_id == NULL) {
288
+                                    $retval[] = ["country" => $a->country, "level" => $a->invite_issuer_level, "name" => $a->name, "mail" => $a->invite_dest_mail];
289
+                } else {
290
+                                    $retval[] = ["country" => $a->country, "level" => $a->invite_issuer_level, "name" => "Existing IdP", "mail" => $a->invite_dest_mail];
291
+                }
287 292
             }
288 293
         return $retval;
289 294
     }
@@ -299,8 +304,9 @@  discard block
 block discarded – undo
299 304
         $returnarray = [];
300 305
         $userid = DBConnection::escape_value(UserManagement::$DB_TYPE, $userid);
301 306
         $institutions = DBConnection::exec(UserManagement::$DB_TYPE, "SELECT institution_id FROM ownership WHERE user_id = '$userid' ORDER BY institution_id");
302
-        while ($a = mysqli_fetch_object($institutions))
303
-            $returnarray[] = $a->institution_id;
307
+        while ($a = mysqli_fetch_object($institutions)) {
308
+                    $returnarray[] = $a->institution_id;
309
+        }
304 310
         return $returnarray;
305 311
     }
306 312
 
Please login to merge, or discard this patch.
core/X509.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 /** transform PEM formed certificate to DER format
29 29
  *
30 30
  *  @param mixed $pem_data blob of data, which is hopefully a PEM certificate
31
- *  @return the DER representation of the certificate
31
+ *  @return string DER representation of the certificate
32 32
  *
33 33
  *  @author http://php.net/manual/en/ref.openssl.php (comment from 29-Mar-2007)
34 34
  */
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
   * returns an array containing the PEM format of the certificate (s)
138 138
   * if the file contains multiple certificates it gets split into components
139 139
   *
140
-  * @param blob $cadata certificate in ether PEM or DER format
140
+  * @param string $cadata certificate in ether PEM or DER format
141 141
   * @return array
142 142
   */
143 143
 
Please login to merge, or discard this patch.
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -33,42 +33,42 @@  discard block
 block discarded – undo
33 33
  *  @author http://php.net/manual/en/ref.openssl.php (comment from 29-Mar-2007)
34 34
  */
35 35
 public function pem2der($pem_data) {
36
-   $begin = "CERTIFICATE-----";
37
-   $end   = "-----END";
38
-   $pem_data = substr($pem_data, strpos($pem_data, $begin)+strlen($begin));
39
-   $pem_data = substr($pem_data, 0, strpos($pem_data, $end));
40
-   $der = base64_decode($pem_data);
41
-   return $der;
36
+    $begin = "CERTIFICATE-----";
37
+    $end   = "-----END";
38
+    $pem_data = substr($pem_data, strpos($pem_data, $begin)+strlen($begin));
39
+    $pem_data = substr($pem_data, 0, strpos($pem_data, $end));
40
+    $der = base64_decode($pem_data);
41
+    return $der;
42 42
 }
43 43
 
44 44
 public function der2pem($der_data) {
45
-   $pem = chunk_split(base64_encode($der_data), 64, "\n");
46
-   $pem = "-----BEGIN CERTIFICATE-----\n".$pem."-----END CERTIFICATE-----\n";
47
-   return $pem;
45
+    $pem = chunk_split(base64_encode($der_data), 64, "\n");
46
+    $pem = "-----BEGIN CERTIFICATE-----\n".$pem."-----END CERTIFICATE-----\n";
47
+    return $pem;
48 48
 }
49 49
 /**
50
-  * prepare PEM and DER formats, MD5 and SHA1 fingerprints and subject of the certificate
51
-  *
52
-  * returns an array with the following fields:
53
-  * <pre> uuid
54
-  * pem	certificate in PEM format
55
-  * der	certificate in DER format
56
-  * md5	MD5 fingerprint
57
-  * sha1	SHA1 fingerprint
58
-  * name	certificate subject
59
-  * root value 1 if root certificate 0 otherwise
60
-  * ca   value 1 if CA certificate 0 otherwise
61
-  *
62
-  * </pre>
63
-  * @param blob $cadata certificate in ether PEM or DER format
64
-  * @return array
65
-  */
50
+ * prepare PEM and DER formats, MD5 and SHA1 fingerprints and subject of the certificate
51
+ *
52
+ * returns an array with the following fields:
53
+ * <pre> uuid
54
+ * pem	certificate in PEM format
55
+ * der	certificate in DER format
56
+ * md5	MD5 fingerprint
57
+ * sha1	SHA1 fingerprint
58
+ * name	certificate subject
59
+ * root value 1 if root certificate 0 otherwise
60
+ * ca   value 1 if CA certificate 0 otherwise
61
+ *
62
+ * </pre>
63
+ * @param blob $cadata certificate in ether PEM or DER format
64
+ * @return array
65
+ */
66 66
 public function processCertificate ($cadata) {
67 67
     $begin_pem = strpos($cadata,"-----BEGIN CERTIFICATE-----");
68
-   if($begin_pem !== FALSE) {
68
+    if($begin_pem !== FALSE) {
69 69
         $end_c = strpos($cadata,"-----END CERTIFICATE-----") + 25;
70 70
         if($end_c !== FALSE) {
71
-           $cadata = substr($cadata,$begin_pem,$end_c - $begin_pem);
71
+            $cadata = substr($cadata,$begin_pem,$end_c - $begin_pem);
72 72
         }
73 73
         $ca_der = X509::pem2der($cadata);
74 74
         $ca_pem = X509::der2pem($ca_der);
@@ -91,25 +91,25 @@  discard block
 block discarded – undo
91 91
     $out =  ["uuid" => uuid(), "pem" => $ca_pem, "der" => $ca_der, "md5"=>$md5, "sha1"=>$sha1, "name"=>$mydetails['name']];
92 92
     $diff_a = array_diff($mydetails['issuer'], $mydetails['subject']);
93 93
     if(count($diff_a) == 0 ) {
94
-     $out['root'] = 1;
95
-     $mydetails['type'] = 'root';
94
+        $out['root'] = 1;
95
+        $mydetails['type'] = 'root';
96 96
     } else {
97
-     $out['root'] = 0;
97
+        $out['root'] = 0;
98 98
     }
99 99
     // if no basicContraints are set at all, this is a problem in itself
100 100
     // is this a CA? or not? Treat as server, but add a warning...
101 101
     if (isset($mydetails['extensions']['basicConstraints'])) {
102
-       $out['ca'] = preg_match('/^CA:TRUE/',$mydetails['extensions']['basicConstraints']);
103
-       $out['basicconstraints_set'] = 1;
102
+        $out['ca'] = preg_match('/^CA:TRUE/',$mydetails['extensions']['basicConstraints']);
103
+        $out['basicconstraints_set'] = 1;
104 104
     } else {
105
-       $out['ca'] = 0; // we need to resolve this ambiguity
106
-       $out['basicconstraints_set'] = 0;
105
+        $out['ca'] = 0; // we need to resolve this ambiguity
106
+        $out['basicconstraints_set'] = 0;
107 107
     }
108 108
     
109 109
     if( $out['ca'] > 0 && $out['root'] == 0 )
110
-     $mydetails['type'] = 'interm_ca';
110
+        $mydetails['type'] = 'interm_ca';
111 111
     if( $out['ca'] == 0 && $out['root'] == 0 )
112
-     $mydetails['type'] = 'server';
112
+        $mydetails['type'] = 'server';
113 113
     $mydetails['sha1'] = $sha1;
114 114
     $out['full_details'] = $mydetails;
115 115
     
@@ -119,51 +119,51 @@  discard block
 block discarded – undo
119 119
     
120 120
     openssl_x509_export($myca, $output, FALSE);
121 121
     if(preg_match('/^\s+Signature Algorithm:\s*(.*)\s*$/m', $output, $match)) 
122
-      $out['full_details']['signature_algorithm'] = $match[1];
122
+        $out['full_details']['signature_algorithm'] = $match[1];
123 123
     else
124
-      $out['full_details']['signature_algorithm'] = $output;
124
+        $out['full_details']['signature_algorithm'] = $output;
125 125
  
126 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];
127
+        $out['full_details']['public_key_length'] = $match[1];
128 128
     else
129
-      $out['full_details']['public_key_length'] = $output;
129
+        $out['full_details']['public_key_length'] = $output;
130 130
     
131 131
     return $out;
132 132
 }
133 133
 
134 134
 /**
135
-  * split a certificate file into components 
136
-  *
137
-  * returns an array containing the PEM format of the certificate (s)
138
-  * if the file contains multiple certificates it gets split into components
139
-  *
140
-  * @param blob $cadata certificate in ether PEM or DER format
141
-  * @return array
142
-  */
135
+ * split a certificate file into components 
136
+ *
137
+ * returns an array containing the PEM format of the certificate (s)
138
+ * if the file contains multiple certificates it gets split into components
139
+ *
140
+ * @param blob $cadata certificate in ether PEM or DER format
141
+ * @return array
142
+ */
143 143
 
144 144
 public function splitCertificate($cadata) {
145
-  $returnarray = [];
146
-  // maybe we got no real cert data at all? The code is hardened, but will
147
-  // produce ugly WARNING level output in the logfiles, so let's avoid at least
148
-  // the trivial case: if the file is empty, there's no cert in it
149
-  if ($cadata == "")
150
-      return $returnarray;
151
-  $start_c = strpos($cadata,"-----BEGIN CERTIFICATE-----" );
152
-  if( $start_c !== FALSE) {
145
+    $returnarray = [];
146
+    // maybe we got no real cert data at all? The code is hardened, but will
147
+    // produce ugly WARNING level output in the logfiles, so let's avoid at least
148
+    // the trivial case: if the file is empty, there's no cert in it
149
+    if ($cadata == "")
150
+        return $returnarray;
151
+    $start_c = strpos($cadata,"-----BEGIN CERTIFICATE-----" );
152
+    if( $start_c !== FALSE) {
153 153
         $cadata = substr($cadata,$start_c);
154 154
         $end_c = strpos($cadata,"-----END CERTIFICATE-----") + 25;
155 155
         $next_c = strpos($cadata,"-----BEGIN CERTIFICATE-----",30);
156 156
         while ( $next_c !== FALSE) {
157
-          $returnarray[] = substr($cadata,0,$end_c);
158
-          $cadata = substr($cadata,$next_c);
159
-          $end_c = strpos($cadata,"-----END CERTIFICATE-----") + 25;
160
-          $next_c = strpos($cadata,"-----BEGIN CERTIFICATE-----",30);
157
+            $returnarray[] = substr($cadata,0,$end_c);
158
+            $cadata = substr($cadata,$next_c);
159
+            $end_c = strpos($cadata,"-----END CERTIFICATE-----") + 25;
160
+            $next_c = strpos($cadata,"-----BEGIN CERTIFICATE-----",30);
161 161
         }
162 162
         $returnarray[] = substr($cadata,0,$end_c);
163 163
     } else {
164 164
         // TODO: before we blindly hand it over to der2pem - is this valid DER
165 165
         // data at all?
166
-      $returnarray[] = X509::der2pem($cadata);
166
+        $returnarray[] = X509::der2pem($cadata);
167 167
     }
168 168
     // print_r($returnarray);
169 169
     
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 public function pem2der($pem_data) {
36 36
    $begin = "CERTIFICATE-----";
37 37
    $end   = "-----END";
38
-   $pem_data = substr($pem_data, strpos($pem_data, $begin)+strlen($begin));
38
+   $pem_data = substr($pem_data, strpos($pem_data, $begin) + strlen($begin));
39 39
    $pem_data = substr($pem_data, 0, strpos($pem_data, $end));
40 40
    $der = base64_decode($pem_data);
41 41
    return $der;
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
 public function der2pem($der_data) {
45 45
    $pem = chunk_split(base64_encode($der_data), 64, "\n");
46
-   $pem = "-----BEGIN CERTIFICATE-----\n".$pem."-----END CERTIFICATE-----\n";
46
+   $pem = "-----BEGIN CERTIFICATE-----\n" . $pem . "-----END CERTIFICATE-----\n";
47 47
    return $pem;
48 48
 }
49 49
 /**
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
   * @param blob $cadata certificate in ether PEM or DER format
64 64
   * @return array
65 65
   */
66
-public function processCertificate ($cadata) {
67
-    $begin_pem = strpos($cadata,"-----BEGIN CERTIFICATE-----");
68
-   if($begin_pem !== FALSE) {
69
-        $end_c = strpos($cadata,"-----END CERTIFICATE-----") + 25;
70
-        if($end_c !== FALSE) {
71
-           $cadata = substr($cadata,$begin_pem,$end_c - $begin_pem);
66
+public function processCertificate($cadata) {
67
+    $begin_pem = strpos($cadata, "-----BEGIN CERTIFICATE-----");
68
+   if ($begin_pem !== FALSE) {
69
+        $end_c = strpos($cadata, "-----END CERTIFICATE-----") + 25;
70
+        if ($end_c !== FALSE) {
71
+           $cadata = substr($cadata, $begin_pem, $end_c - $begin_pem);
72 72
         }
73 73
         $ca_der = X509::pem2der($cadata);
74 74
         $ca_pem = X509::der2pem($ca_der);
75 75
         // echo "XXXXXXXXXXXXX".$cadata."XXXXXXXXXXXXX"; exit;
76 76
     } else {
77 77
         $ca_der = $cadata;
78
-        $ca_pem =  X509::der2pem($cadata);
78
+        $ca_pem = X509::der2pem($cadata);
79 79
     }
80 80
 
81 81
     # check that the certificate is OK
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
     $mydetails = openssl_x509_parse($myca);
87 87
     if (!isset($mydetails['subject']))
88 88
         return FALSE;
89
-    $md5 = openssl_digest($ca_der,'MD5');
90
-    $sha1 = openssl_digest($ca_der,'SHA1');
91
-    $out =  ["uuid" => uuid(), "pem" => $ca_pem, "der" => $ca_der, "md5"=>$md5, "sha1"=>$sha1, "name"=>$mydetails['name']];
89
+    $md5 = openssl_digest($ca_der, 'MD5');
90
+    $sha1 = openssl_digest($ca_der, 'SHA1');
91
+    $out = ["uuid" => uuid(), "pem" => $ca_pem, "der" => $ca_der, "md5"=>$md5, "sha1"=>$sha1, "name"=>$mydetails['name']];
92 92
     $diff_a = array_diff($mydetails['issuer'], $mydetails['subject']);
93
-    if(count($diff_a) == 0 ) {
93
+    if (count($diff_a) == 0) {
94 94
      $out['root'] = 1;
95 95
      $mydetails['type'] = 'root';
96 96
     } else {
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
     // if no basicContraints are set at all, this is a problem in itself
100 100
     // is this a CA? or not? Treat as server, but add a warning...
101 101
     if (isset($mydetails['extensions']['basicConstraints'])) {
102
-       $out['ca'] = preg_match('/^CA:TRUE/',$mydetails['extensions']['basicConstraints']);
102
+       $out['ca'] = preg_match('/^CA:TRUE/', $mydetails['extensions']['basicConstraints']);
103 103
        $out['basicconstraints_set'] = 1;
104 104
     } else {
105 105
        $out['ca'] = 0; // we need to resolve this ambiguity
106 106
        $out['basicconstraints_set'] = 0;
107 107
     }
108 108
     
109
-    if( $out['ca'] > 0 && $out['root'] == 0 )
109
+    if ($out['ca'] > 0 && $out['root'] == 0)
110 110
      $mydetails['type'] = 'interm_ca';
111
-    if( $out['ca'] == 0 && $out['root'] == 0 )
111
+    if ($out['ca'] == 0 && $out['root'] == 0)
112 112
      $mydetails['type'] = 'server';
113 113
     $mydetails['sha1'] = $sha1;
114 114
     $out['full_details'] = $mydetails;
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
     
119 119
     
120 120
     openssl_x509_export($myca, $output, FALSE);
121
-    if(preg_match('/^\s+Signature Algorithm:\s*(.*)\s*$/m', $output, $match)) 
121
+    if (preg_match('/^\s+Signature Algorithm:\s*(.*)\s*$/m', $output, $match)) 
122 122
       $out['full_details']['signature_algorithm'] = $match[1];
123 123
     else
124 124
       $out['full_details']['signature_algorithm'] = $output;
125 125
  
126
-    if((preg_match('/^\s+Public-Key:\s*\((.*) bit\)\s*$/m', $output, $match)) && is_numeric($match[1])) 
126
+    if ((preg_match('/^\s+Public-Key:\s*\((.*) bit\)\s*$/m', $output, $match)) && is_numeric($match[1])) 
127 127
       $out['full_details']['public_key_length'] = $match[1];
128 128
     else
129 129
       $out['full_details']['public_key_length'] = $output;
@@ -148,18 +148,18 @@  discard block
 block discarded – undo
148 148
   // the trivial case: if the file is empty, there's no cert in it
149 149
   if ($cadata == "")
150 150
       return $returnarray;
151
-  $start_c = strpos($cadata,"-----BEGIN CERTIFICATE-----" );
152
-  if( $start_c !== FALSE) {
153
-        $cadata = substr($cadata,$start_c);
154
-        $end_c = strpos($cadata,"-----END CERTIFICATE-----") + 25;
155
-        $next_c = strpos($cadata,"-----BEGIN CERTIFICATE-----",30);
156
-        while ( $next_c !== FALSE) {
157
-          $returnarray[] = substr($cadata,0,$end_c);
158
-          $cadata = substr($cadata,$next_c);
159
-          $end_c = strpos($cadata,"-----END CERTIFICATE-----") + 25;
160
-          $next_c = strpos($cadata,"-----BEGIN CERTIFICATE-----",30);
151
+  $start_c = strpos($cadata, "-----BEGIN CERTIFICATE-----");
152
+  if ($start_c !== FALSE) {
153
+        $cadata = substr($cadata, $start_c);
154
+        $end_c = strpos($cadata, "-----END CERTIFICATE-----") + 25;
155
+        $next_c = strpos($cadata, "-----BEGIN CERTIFICATE-----", 30);
156
+        while ($next_c !== FALSE) {
157
+          $returnarray[] = substr($cadata, 0, $end_c);
158
+          $cadata = substr($cadata, $next_c);
159
+          $end_c = strpos($cadata, "-----END CERTIFICATE-----") + 25;
160
+          $next_c = strpos($cadata, "-----BEGIN CERTIFICATE-----", 30);
161 161
         }
162
-        $returnarray[] = substr($cadata,0,$end_c);
162
+        $returnarray[] = substr($cadata, 0, $end_c);
163 163
     } else {
164 164
         // TODO: before we blindly hand it over to der2pem - is this valid DER
165 165
         // data at all?
Please login to merge, or discard this 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.
devices/chromebook/chromebook.php 3 patches
Doc Comments   -3 removed lines patch added patch discarded remove patch
@@ -78,9 +78,6 @@
 block discarded – undo
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() {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -172,13 +172,13 @@
 block discarded – undo
172 172
         // define CA certificates
173 173
         foreach ($this->attributes['internal:CAs'][0] as $ca) {
174 174
             // strip -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----
175
-            debug(2,$ca['pem']);
175
+            debug(2, $ca['pem']);
176 176
             $ca_sanitized = substr($ca['pem'], 27, strlen($ca['pem']) - 27 - 25 - 1);
177
-            debug(2,$ca_sanitized."\n");
177
+            debug(2, $ca_sanitized . "\n");
178 178
             // remove \n
179 179
             $ca_sanitized = str_replace("\n", "", $ca_sanitized);
180 180
             $json_array["Certificates"][] = ["GUID" => "{" . $ca['uuid'] . "}", "Type" => "Authority", "X509" => $ca_sanitized];
181
-            debug(2,$ca_sanitized."\n");
181
+            debug(2, $ca_sanitized . "\n");
182 182
         }
183 183
                 
184 184
         $output_json = json_encode($json_array, JSON_PRETTY_PRINT);
Please login to merge, or discard this patch.
Braces   +16 added lines, -12 removed lines patch added patch discarded remove patch
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
         // construct outer id, if anonymity is desired
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
             $outer_id = "@" . $this->attributes['internal:realm'][0];
111
-            if (isset($this->attributes['internal:anon_local_value']))
112
-                $outer_id = $this->attributes['internal:anon_local_value'][0] . $outer_id;
113
-        }
114
-        else {
111
+            if (isset($this->attributes['internal:anon_local_value'])) {
112
+                            $outer_id = $this->attributes['internal:anon_local_value'][0] . $outer_id;
113
+            }
114
+        } else {
115 115
             $outer_id = 0;
116 116
         }
117 117
         // define networks
@@ -119,26 +119,30 @@  discard block
 block discarded – undo
119 119
             $network_uuid = uuid($prefix, $ssid);
120 120
             $eap_prettyprint = EAP::eapDisplayName($this->selected_eap);
121 121
             // ONC has its own enums, and guess what, they don't always match
122
-            if ($eap_prettyprint["OUTER"] == "PEAP" && $eap_prettyprint["INNER"] == "MSCHAPV2")
123
-                // the dictionary entry EAP-MSCHAPv2 does not work. Setting MSCHAPv2 does. (ChromeOS 50)
122
+            if ($eap_prettyprint["OUTER"] == "PEAP" && $eap_prettyprint["INNER"] == "MSCHAPV2") {
123
+                            // the dictionary entry EAP-MSCHAPv2 does not work. Setting MSCHAPv2 does. (ChromeOS 50)
124 124
                 $eap_prettyprint["INNER"] = "MSCHAPv2";
125
+            }
125 126
             if ($eap_prettyprint["OUTER"] == "TTLS" && $eap_prettyprint["INNER"] == "MSCHAPV2") {
126 127
                 $eap_prettyprint["OUTER"] = "EAP-TTLS";
127 128
                 $eap_prettyprint["INNER"] = "MSCHAPv2";
128 129
             }
129
-            if ($eap_prettyprint["OUTER"] == "TLS")
130
-                $eap_prettyprint["OUTER"] = "EAP-TLS";
130
+            if ($eap_prettyprint["OUTER"] == "TLS") {
131
+                            $eap_prettyprint["OUTER"] = "EAP-TLS";
132
+            }
131 133
             // define EAP properties
132 134
 
133 135
             $eaparray = array("Outer" => $eap_prettyprint["OUTER"]);
134
-            if ($eap_prettyprint["INNER"] == "MSCHAPv2")
135
-                $eaparray["Inner"] = $eap_prettyprint["INNER"];
136
+            if ($eap_prettyprint["INNER"] == "MSCHAPv2") {
137
+                            $eaparray["Inner"] = $eap_prettyprint["INNER"];
138
+            }
136 139
             $eaparray["SaveCredentials"] = true;
137 140
             $eaparray["ServerCARefs"] = $ca_refs; // maybe takes just one CA?
138 141
             $eaparray["UseSystemCAs"] = false;
139 142
                     
140
-            if ($outer_id)
141
-                $eaparray["AnonymousIdentity"] = "$outer_id";
143
+            if ($outer_id) {
144
+                            $eaparray["AnonymousIdentity"] = "$outer_id";
145
+            }
142 146
             
143 147
             $json_array["NetworkConfigurations"][] = [
144 148
                 "GUID" => $network_uuid,
Please login to merge, or discard this patch.
devices/ms/Vista7.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -350,6 +350,9 @@
 block discarded – undo
350 350
 
351 351
 /**
352 352
  * produce PEAP and TLS configuration files for Vista and Windows 7
353
+ * @param string $auth
354
+ * @param string $encryption
355
+ * @param integer $i
353 356
  */
354 357
   private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) {
355 358
 $profile_file_contents = '<?xml version="1.0"?>
Please login to merge, or discard this patch.
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -26,66 +26,66 @@  discard block
 block discarded – undo
26 26
  */
27 27
 class Device_Vista7 extends WindowsCommon {
28 28
     final public function __construct() {
29
-      $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$PWD];
30
-      debug(4,"This device supports the following EAP methods: ");
31
-      debug(4,$this->supportedEapMethods);
32
-      $this->specialities['anon_id'][serialize(EAP::$PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead.");
29
+        $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$PWD];
30
+        debug(4,"This device supports the following EAP methods: ");
31
+        debug(4,$this->supportedEapMethods);
32
+        $this->specialities['anon_id'][serialize(EAP::$PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead.");
33 33
     }
34 34
 
35
-  public function writeInstaller() {
36
-      $dom = textdomain(NULL);
37
-      textdomain("devices");
38
-   // create certificate files and save their names in $CA_files arrary
39
-     $CA_files = $this->saveCertificateFiles('der');
35
+    public function writeInstaller() {
36
+        $dom = textdomain(NULL);
37
+        textdomain("devices");
38
+    // create certificate files and save their names in $CA_files arrary
39
+        $CA_files = $this->saveCertificateFiles('der');
40 40
 
41
-     $SSIDs = $this->attributes['internal:SSID'];
42
-     $delSSIDs = $this->attributes['internal:remove_SSID'];
43
-     $this->prepareInstallerLang();
44
-     $set_wired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0;
41
+        $SSIDs = $this->attributes['internal:SSID'];
42
+        $delSSIDs = $this->attributes['internal:remove_SSID'];
43
+        $this->prepareInstallerLang();
44
+        $set_wired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0;
45 45
 //   create a list of profiles to be deleted after installation
46
-     $delProfiles = [];
47
-     foreach ($delSSIDs as $ssid => $cipher) {
48
-         if($cipher == 'DEL') 
49
-          $delProfiles[] = $ssid;
50
-         if($cipher == 'TKIP') 
51
-          $delProfiles[] = $ssid.' (TKIP)';
52
-     }
53
-
54
-     if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap == EAP::$PWD || $this->selected_eap == EAP::$TTLS_PAP) {
55
-       $WindowsProfile = [];
56
-       $eap_config = $this->prepareEapConfig($this->attributes);
57
-       $i = 0;
58
-       foreach ($SSIDs as $ssid => $cipher) {
59
-          if($cipher == 'TKIP') {
60
-             $WindowsProfile[$i] = $this->writeWLANprofile ($ssid.' (TKIP)',$ssid,'WPA','TKIP',$eap_config,$i);
61
-             $i++;
62
-          }
63
-          $WindowsProfile[$i] = $this->writeWLANprofile ($ssid,$ssid,'WPA2','AES',$eap_config,$i);
64
-          $i++;
65
-       }
66
-       if($set_wired) {
67
-         $this->writeLANprofile($eap_config);
68
-       }
69
-     } else {
70
-       error("  this EAP type is not handled yet");
71
-       return;
72
-     }
46
+        $delProfiles = [];
47
+        foreach ($delSSIDs as $ssid => $cipher) {
48
+            if($cipher == 'DEL') 
49
+            $delProfiles[] = $ssid;
50
+            if($cipher == 'TKIP') 
51
+            $delProfiles[] = $ssid.' (TKIP)';
52
+        }
53
+
54
+        if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap == EAP::$PWD || $this->selected_eap == EAP::$TTLS_PAP) {
55
+        $WindowsProfile = [];
56
+        $eap_config = $this->prepareEapConfig($this->attributes);
57
+        $i = 0;
58
+        foreach ($SSIDs as $ssid => $cipher) {
59
+            if($cipher == 'TKIP') {
60
+                $WindowsProfile[$i] = $this->writeWLANprofile ($ssid.' (TKIP)',$ssid,'WPA','TKIP',$eap_config,$i);
61
+                $i++;
62
+            }
63
+            $WindowsProfile[$i] = $this->writeWLANprofile ($ssid,$ssid,'WPA2','AES',$eap_config,$i);
64
+            $i++;
65
+        }
66
+        if($set_wired) {
67
+            $this->writeLANprofile($eap_config);
68
+        }
69
+        } else {
70
+        error("  this EAP type is not handled yet");
71
+        return;
72
+        }
73 73
     debug(4,"WindowsProfile"); debug(4,$WindowsProfile);
74 74
     
75 75
     $this->writeProfilesNSH($WindowsProfile, $CA_files,$set_wired);
76 76
     $this->writeAdditionalDeletes($delProfiles);
77 77
     $this->copyFiles($this->selected_eap);
78 78
     if(isset($this->attributes['internal:logo_file']))
79
-       $this->combineLogo($this->attributes['internal:logo_file']);
79
+        $this->combineLogo($this->attributes['internal:logo_file']);
80 80
     $this->writeMainNSH($this->selected_eap,$this->attributes);
81 81
     $this->compileNSIS();
82 82
     $installer_path = $this->signInstaller($this->attributes); 
83 83
 
84 84
     textdomain($dom);
85 85
     return($installer_path);  
86
-  }
86
+    }
87 87
 
88
-  public function writeDeviceInfo() {
88
+    public function writeDeviceInfo() {
89 89
     $ssid_ct=count($this->attributes['internal:SSID']);
90 90
     $out = "<p>";
91 91
     $out .= sprintf(_("%s installer will be in the form of an EXE file. It will configure %s on your device, by creating wireless network profiles.<p>When you click the download button, the installer will be saved by your browser. Copy it to the machine you want to configure and execute."),Config::$CONSORTIUM['name'],Config::$CONSORTIUM['name']);
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
             $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
98 98
         $i = 0;
99 99
         foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
100
-           if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) {
101
-             if($i > 0)
102
-           $out .= ", ";
103
-         $i++;
104
-         $out .= "<strong>$ssid</strong>";
105
-       }
100
+            if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) {
101
+                if($i > 0)
102
+            $out .= ", ";
103
+            $i++;
104
+            $out .= "<strong>$ssid</strong>";
105
+        }
106 106
     }
107 107
     $out .= "<p>";
108 108
     }
@@ -115,21 +115,21 @@  discard block
 block discarded – undo
115 115
         $out .= "<p>";
116 116
         $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.");
117 117
         if($ssid_ct > 1) {
118
-             $out .= "<p>";
119
-             $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." ";
120
-             $i = 0;
118
+                $out .= "<p>";
119
+                $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." ";
120
+                $i = 0;
121 121
             foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
122
-                 if($i > 0)
123
-                   $out .= ", ";
124
-                 $i++;
125
-                 $out .= "<strong>$ssid</strong>";
122
+                    if($i > 0)
123
+                    $out .= ", ";
124
+                    $i++;
125
+                    $out .= "<strong>$ssid</strong>";
126 126
             }
127 127
     }
128 128
 
129
-   }
129
+    }
130 130
 
131
-   }
132
-  return($out);
131
+    }
132
+    return($out);
133 133
 }
134 134
 
135 135
 private function prepareEapConfig($attr) {
@@ -137,25 +137,25 @@  discard block
 block discarded – undo
137 137
     $w7_ext = '';
138 138
     $eap = $this->selected_eap;
139 139
     if ($eap != EAP::$TLS && $eap != EAP::$PEAP_MSCHAP2 && $eap != EAP::$PWD && $eap != EAP::$TTLS_PAP) {
140
-      debug(2,"this method only allows TLS, PEAP, TTLS-PAP or EAP-pwd");
141
-      error("this method only allows TLS, PEAP, TTLS-PAP or EAP-pwd");
142
-     return;
140
+        debug(2,"this method only allows TLS, PEAP, TTLS-PAP or EAP-pwd");
141
+        error("this method only allows TLS, PEAP, TTLS-PAP or EAP-pwd");
142
+        return;
143
+    }
144
+    $use_anon = $attr['internal:use_anon_outer'] [0];
145
+    $realm = $attr['internal:realm'] [0];
146
+    if ($use_anon) {
147
+        $outer_user = $attr['internal:anon_local_value'][0];
143 148
     }
144
-   $use_anon = $attr['internal:use_anon_outer'] [0];
145
-   $realm = $attr['internal:realm'] [0];
146
-   if ($use_anon) {
147
-     $outer_user = $attr['internal:anon_local_value'][0];
148
-   }
149 149
 //   $servers = preg_quote(implode(';',$attr['eap:server_name']));
150
-   $servers = implode(';',$attr['eap:server_name']);
151
-   $ca_array = $attr['internal:CAs'][0];
152
-   $author_id = "0";
153
-   if( $eap == EAP::$TTLS_PAP) {
154
-      $author_id = "17236";
155
-      $servers = implode('</ServerName><ServerName>',$attr['eap:server_name']);
156
-   }
157
-
158
-  $profile_file_contents = '<EAPConfig><EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
150
+    $servers = implode(';',$attr['eap:server_name']);
151
+    $ca_array = $attr['internal:CAs'][0];
152
+    $author_id = "0";
153
+    if( $eap == EAP::$TTLS_PAP) {
154
+        $author_id = "17236";
155
+        $servers = implode('</ServerName><ServerName>',$attr['eap:server_name']);
156
+    }
157
+
158
+    $profile_file_contents = '<EAPConfig><EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
159 159
 <EapMethod>
160 160
 <Type xmlns="http://www.microsoft.com/provisioning/EapCommon">'.
161 161
     $this->selected_eap["OUTER"] .'</Type>
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 ';
167 167
 
168 168
 
169
-   if( $eap == EAP::$TTLS_PAP) {
169
+    if( $eap == EAP::$TTLS_PAP) {
170 170
 $profile_file_contents .= '
171 171
 <Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
172 172
 <EAPIdentityProviderList xmlns="urn:ietf:params:xml:ns:yang:ietf-eap-metadata">
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
 $profile_file_contents .= '<ServerSideCredential>
202 202
 ';
203 203
 
204
-   foreach ($ca_array as $ca) {
204
+    foreach ($ca_array as $ca) {
205 205
       
206
-      $profile_file_contents .= '<CA><format>PEM</format><cert-data>';
207
-      $profile_file_contents .= base64_encode($ca['der']);
208
-      $profile_file_contents .= '</cert-data></CA>
206
+        $profile_file_contents .= '<CA><format>PEM</format><cert-data>';
207
+        $profile_file_contents .= base64_encode($ca['der']);
208
+        $profile_file_contents .= '</cert-data></CA>
209 209
 ';
210
-   }
211
-   $profile_file_contents .= "<ServerName>$servers</ServerName>\n";
210
+    }
211
+    $profile_file_contents .= "<ServerName>$servers</ServerName>\n";
212 212
 
213 213
 $profile_file_contents .= '
214 214
 </ServerSideCredential>
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 }
229 229
 
230 230
 elseif( $eap == EAP::$TLS) {
231
-  $profile_file_contents .= '
231
+    $profile_file_contents .= '
232 232
 
233 233
 <Config xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" 
234 234
   xmlns:eapTls="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV1">
@@ -244,14 +244,14 @@  discard block
 block discarded – undo
244 244
 if($ca_array) {
245 245
 foreach ($ca_array as $CA)
246 246
     if($CA['root'])
247
-       $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n";
247
+        $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n";
248 248
 }
249 249
 $profile_file_contents .= '</eapTls:ServerValidation>
250 250
 ';
251 251
 if(isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on')
252
-   $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>';
252
+    $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>';
253 253
 else
254
-   $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>';
254
+    $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>';
255 255
 $profile_file_contents .= '
256 256
 </eapTls:EapType>
257 257
 </baseEap:Eap>
@@ -259,9 +259,9 @@  discard block
 block discarded – undo
259 259
 ';
260 260
 } elseif ( $eap == EAP::$PEAP_MSCHAP2) {
261 261
 if(isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on')
262
-   $nea = 'true';
262
+    $nea = 'true';
263 263
 else
264
-   $nea = 'false';
264
+    $nea = 'false';
265 265
 $vista_ext = '<Config xmlns:eapUser="http://www.microsoft.com/provisioning/EapUserPropertiesV1" 
266 266
 xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" 
267 267
   xmlns:msPeap="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV1" 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 if($ca_array) {
276 276
 foreach ($ca_array as $CA)
277 277
     if($CA['root'])
278
-       $vista_ext .= "<msPeap:TrustedRootCA>".$CA['sha1']."</msPeap:TrustedRootCA>\n";
278
+        $vista_ext .= "<msPeap:TrustedRootCA>".$CA['sha1']."</msPeap:TrustedRootCA>\n";
279 279
 }
280 280
 $vista_ext .= '</msPeap:ServerValidation>
281 281
 <msPeap:FastReconnect>true</msPeap:FastReconnect> 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 </Config>
330 330
 ';
331 331
 } elseif ( $eap == EAP::$PWD) {
332
-   $profile_file_contents .= '<ConfigBlob></ConfigBlob>';
332
+    $profile_file_contents .= '<ConfigBlob></ConfigBlob>';
333 333
 } 
334 334
 
335 335
 
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 /**
352 352
  * produce PEAP and TLS configuration files for Vista and Windows 7
353 353
  */
354
-  private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) {
354
+    private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) {
355 355
 $profile_file_contents = '<?xml version="1.0"?>
356 356
 <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
357 357
 <name>'.$wlan_profile_name.'</name>
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
 ';
392 392
 
393 393
 if(! is_dir('w7'))
394
-  mkdir('w7');
394
+    mkdir('w7');
395 395
 if(! is_dir('vista'))
396
-  mkdir('vista');
396
+    mkdir('vista');
397 397
 $xml_f_name = "vista/wlan_prof-$i.xml";
398 398
 $xml_f = fopen($xml_f_name,'w');
399 399
 fwrite($xml_f,$profile_file_contents. $eap_config['vista']. $closing) ;
@@ -423,9 +423,9 @@  discard block
 block discarded – undo
423 423
 </LANProfile>
424 424
 ';
425 425
 if(! is_dir('w7'))
426
-  mkdir('w7');
426
+    mkdir('w7');
427 427
 if(! is_dir('vista'))
428
-  mkdir('vista');
428
+    mkdir('vista');
429 429
 $xml_f_name = "vista/lan_prof.xml";
430 430
 $xml_f = fopen($xml_f_name,'w');
431 431
 fwrite($xml_f,$profile_file_contents. $eap_config['vista']. $closing) ;
@@ -438,16 +438,16 @@  discard block
 block discarded – undo
438 438
 
439 439
 private function glueServerNames($server_list) {
440 440
 //print_r($server_list);
441
- $A0 =  array_reverse(explode('.',array_shift($server_list)));
442
- $B = $A0;
443
- if($server_list) {
444
-   foreach($server_list as $a) {
445
-   $A= array_reverse(explode('.',$a));
446
-   $B = array_intersect_assoc($A0,$A);
447
-   $A0 = $B;
448
-   }
449
-  }
450
-  return(implode('.',array_reverse($B)));
441
+    $A0 =  array_reverse(explode('.',array_shift($server_list)));
442
+    $B = $A0;
443
+    if($server_list) {
444
+    foreach($server_list as $a) {
445
+    $A= array_reverse(explode('.',$a));
446
+    $B = array_intersect_assoc($A0,$A);
447
+    $A0 = $B;
448
+    }
449
+    }
450
+    return(implode('.',array_reverse($B)));
451 451
 }
452 452
 
453 453
 
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 ';
503 503
 
504 504
 if(isset($this->attributes['media:wired'][0]) && $attr['media:wired'][0] == 'on')
505
-  $fcontents .= '!define WIRED
505
+    $fcontents .= '!define WIRED
506 506
 ';
507 507
 
508 508
 $f = fopen('main.nsh','w');
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
 private function writeProfilesNSH($P,$ca_array,$wired=0) {
515 515
 debug(4,"writeProfilesNSH");
516 516
 debug(4,$P);
517
-  $fcontents = '';
518
-  foreach($P as $p) 
517
+    $fcontents = '';
518
+    foreach($P as $p) 
519 519
     $fcontents .= "!insertmacro define_wlan_profile $p\n";
520 520
   
521 521
 $f = fopen('profiles.nsh','w');
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
 $f = fopen('certs.nsh','w');
527 527
 if($ca_array) {
528 528
 foreach ($ca_array as $CA) {
529
-      $store = $CA['root'] ? "root" : "ca";
530
-      $fcontents .= '!insertmacro install_ca_cert "'.$CA['file'].'" "'.$CA['sha1'].'" "'.$store."\"\n";
529
+        $store = $CA['root'] ? "root" : "ca";
530
+        $fcontents .= '!insertmacro install_ca_cert "'.$CA['file'].'" "'.$CA['sha1'].'" "'.$store."\"\n";
531 531
     }
532 532
 fwrite($f, $fcontents);
533 533
 }
@@ -537,33 +537,33 @@  discard block
 block discarded – undo
537 537
 private function copyFiles ($eap) {
538 538
 debug(4,"copyFiles start\n");
539 539
 debug(4,"code_page=".$this->code_page."\n");
540
-   $result;
541
-   $result = $this->copyFile('wlan_test.exe');
542
-   $result = $this->copyFile('check_wired.cmd');
543
-   $result = $this->copyFile('install_wired.cmd');
544
-   $result = $this->copyFile('setEAPCred.exe');
545
-   $result = $this->copyFile('base64.nsh');
546
-   $result = $this->copyFile('cat_bg.bmp');
547
-   $result = $result && $this->copyFile('cat32.ico');
548
-   $result = $result && $this->copyFile('cat_150.bmp');
549
-   $this->translateFile('common.inc','common.nsh',$this->code_page);
550
-   if( $eap["OUTER"] == TTLS)  {
551
-     $result = $this->copyFile('GPL3.rtf');
552
-     $result = $result && $this->copyFile('ArnesLinkEn32.msi');
553
-     $result = $result && $this->copyFile('ArnesLinkEn64.msi');
554
-     $result = $result && $this->copyFile('dump_arneslink_profile.cmd');
555
-     $result = $result && $this->copyFile('install_arneslink_profile.cmd');
556
-     $this->translateFile('arnes_link.inc','cat.NSI',$this->code_page);
557
-   } elseif($eap["OUTER"] == PWD) {
558
-     $this->translateFile('pwd.inc','cat.NSI',$this->code_page);
559
-     $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x32.msi');
560
-     $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi');
540
+    $result;
541
+    $result = $this->copyFile('wlan_test.exe');
542
+    $result = $this->copyFile('check_wired.cmd');
543
+    $result = $this->copyFile('install_wired.cmd');
544
+    $result = $this->copyFile('setEAPCred.exe');
545
+    $result = $this->copyFile('base64.nsh');
546
+    $result = $this->copyFile('cat_bg.bmp');
547
+    $result = $result && $this->copyFile('cat32.ico');
548
+    $result = $result && $this->copyFile('cat_150.bmp');
549
+    $this->translateFile('common.inc','common.nsh',$this->code_page);
550
+    if( $eap["OUTER"] == TTLS)  {
551
+        $result = $this->copyFile('GPL3.rtf');
552
+        $result = $result && $this->copyFile('ArnesLinkEn32.msi');
553
+        $result = $result && $this->copyFile('ArnesLinkEn64.msi');
554
+        $result = $result && $this->copyFile('dump_arneslink_profile.cmd');
555
+        $result = $result && $this->copyFile('install_arneslink_profile.cmd');
556
+        $this->translateFile('arnes_link.inc','cat.NSI',$this->code_page);
557
+    } elseif($eap["OUTER"] == PWD) {
558
+        $this->translateFile('pwd.inc','cat.NSI',$this->code_page);
559
+        $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x32.msi');
560
+        $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi');
561 561
     } else {
562
-     $this->translateFile('peap_tls.inc','cat.NSI',$this->code_page);
563
-     $result = 1;
562
+        $this->translateFile('peap_tls.inc','cat.NSI',$this->code_page);
563
+        $result = 1;
564 564
     }
565 565
 debug(4,"copyFiles end\n");
566
-   return($result);
566
+    return($result);
567 567
 }
568 568
 
569 569
 }
Please login to merge, or discard this patch.
Spacing   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 class Device_Vista7 extends WindowsCommon {
28 28
     final public function __construct() {
29 29
       $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$PWD];
30
-      debug(4,"This device supports the following EAP methods: ");
31
-      debug(4,$this->supportedEapMethods);
30
+      debug(4, "This device supports the following EAP methods: ");
31
+      debug(4, $this->supportedEapMethods);
32 32
       $this->specialities['anon_id'][serialize(EAP::$PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead.");
33 33
     }
34 34
 
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
 //   create a list of profiles to be deleted after installation
46 46
      $delProfiles = [];
47 47
      foreach ($delSSIDs as $ssid => $cipher) {
48
-         if($cipher == 'DEL') 
48
+         if ($cipher == 'DEL') 
49 49
           $delProfiles[] = $ssid;
50
-         if($cipher == 'TKIP') 
51
-          $delProfiles[] = $ssid.' (TKIP)';
50
+         if ($cipher == 'TKIP') 
51
+          $delProfiles[] = $ssid . ' (TKIP)';
52 52
      }
53 53
 
54 54
      if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap == EAP::$PWD || $this->selected_eap == EAP::$TTLS_PAP) {
@@ -56,28 +56,28 @@  discard block
 block discarded – undo
56 56
        $eap_config = $this->prepareEapConfig($this->attributes);
57 57
        $i = 0;
58 58
        foreach ($SSIDs as $ssid => $cipher) {
59
-          if($cipher == 'TKIP') {
60
-             $WindowsProfile[$i] = $this->writeWLANprofile ($ssid.' (TKIP)',$ssid,'WPA','TKIP',$eap_config,$i);
59
+          if ($cipher == 'TKIP') {
60
+             $WindowsProfile[$i] = $this->writeWLANprofile($ssid . ' (TKIP)', $ssid, 'WPA', 'TKIP', $eap_config, $i);
61 61
              $i++;
62 62
           }
63
-          $WindowsProfile[$i] = $this->writeWLANprofile ($ssid,$ssid,'WPA2','AES',$eap_config,$i);
63
+          $WindowsProfile[$i] = $this->writeWLANprofile($ssid, $ssid, 'WPA2', 'AES', $eap_config, $i);
64 64
           $i++;
65 65
        }
66
-       if($set_wired) {
66
+       if ($set_wired) {
67 67
          $this->writeLANprofile($eap_config);
68 68
        }
69 69
      } else {
70 70
        error("  this EAP type is not handled yet");
71 71
        return;
72 72
      }
73
-    debug(4,"WindowsProfile"); debug(4,$WindowsProfile);
73
+    debug(4, "WindowsProfile"); debug(4, $WindowsProfile);
74 74
     
75
-    $this->writeProfilesNSH($WindowsProfile, $CA_files,$set_wired);
75
+    $this->writeProfilesNSH($WindowsProfile, $CA_files, $set_wired);
76 76
     $this->writeAdditionalDeletes($delProfiles);
77 77
     $this->copyFiles($this->selected_eap);
78
-    if(isset($this->attributes['internal:logo_file']))
78
+    if (isset($this->attributes['internal:logo_file']))
79 79
        $this->combineLogo($this->attributes['internal:logo_file']);
80
-    $this->writeMainNSH($this->selected_eap,$this->attributes);
80
+    $this->writeMainNSH($this->selected_eap, $this->attributes);
81 81
     $this->compileNSIS();
82 82
     $installer_path = $this->signInstaller($this->attributes); 
83 83
 
@@ -86,19 +86,19 @@  discard block
 block discarded – undo
86 86
   }
87 87
 
88 88
   public function writeDeviceInfo() {
89
-    $ssid_ct=count($this->attributes['internal:SSID']);
89
+    $ssid_ct = count($this->attributes['internal:SSID']);
90 90
     $out = "<p>";
91
-    $out .= sprintf(_("%s installer will be in the form of an EXE file. It will configure %s on your device, by creating wireless network profiles.<p>When you click the download button, the installer will be saved by your browser. Copy it to the machine you want to configure and execute."),Config::$CONSORTIUM['name'],Config::$CONSORTIUM['name']);
91
+    $out .= sprintf(_("%s installer will be in the form of an EXE file. It will configure %s on your device, by creating wireless network profiles.<p>When you click the download button, the installer will be saved by your browser. Copy it to the machine you want to configure and execute."), Config::$CONSORTIUM['name'], Config::$CONSORTIUM['name']);
92 92
     $out .= "<p>";
93
-    if($ssid_ct > 1) {
94
-        if($ssid_ct > 2) {
95
-            $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to the following networks:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
93
+    if ($ssid_ct > 1) {
94
+        if ($ssid_ct > 2) {
95
+            $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to the following networks:"), implode(', ', Config::$CONSORTIUM['ssid'])) . " ";
96 96
         } else
97
-            $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
97
+            $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"), implode(', ', Config::$CONSORTIUM['ssid'])) . " ";
98 98
         $i = 0;
99 99
         foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
100
-           if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) {
101
-             if($i > 0)
100
+           if (!in_array($ssid, Config::$CONSORTIUM['ssid'])) {
101
+             if ($i > 0)
102 102
            $out .= ", ";
103 103
          $i++;
104 104
          $out .= "<strong>$ssid</strong>";
@@ -106,20 +106,20 @@  discard block
 block discarded – undo
106 106
     }
107 107
     $out .= "<p>";
108 108
     }
109
-    if($this->eap == EAP::$TLS)
109
+    if ($this->eap == EAP::$TLS)
110 110
         $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.");
111 111
     else {
112 112
     $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.");
113 113
 
114
-    if($this->eap == EAP::$PEAP_MSCHAP2) {
114
+    if ($this->eap == EAP::$PEAP_MSCHAP2) {
115 115
         $out .= "<p>";
116 116
         $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.");
117
-        if($ssid_ct > 1) {
117
+        if ($ssid_ct > 1) {
118 118
              $out .= "<p>";
119
-             $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." ";
119
+             $out .= _("You will be required to enter the same credentials for each of the configured notworks:") . " ";
120 120
              $i = 0;
121 121
             foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
122
-                 if($i > 0)
122
+                 if ($i > 0)
123 123
                    $out .= ", ";
124 124
                  $i++;
125 125
                  $out .= "<strong>$ssid</strong>";
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     $w7_ext = '';
138 138
     $eap = $this->selected_eap;
139 139
     if ($eap != EAP::$TLS && $eap != EAP::$PEAP_MSCHAP2 && $eap != EAP::$PWD && $eap != EAP::$TTLS_PAP) {
140
-      debug(2,"this method only allows TLS, PEAP, TTLS-PAP or EAP-pwd");
140
+      debug(2, "this method only allows TLS, PEAP, TTLS-PAP or EAP-pwd");
141 141
       error("this method only allows TLS, PEAP, TTLS-PAP or EAP-pwd");
142 142
      return;
143 143
     }
@@ -147,26 +147,26 @@  discard block
 block discarded – undo
147 147
      $outer_user = $attr['internal:anon_local_value'][0];
148 148
    }
149 149
 //   $servers = preg_quote(implode(';',$attr['eap:server_name']));
150
-   $servers = implode(';',$attr['eap:server_name']);
150
+   $servers = implode(';', $attr['eap:server_name']);
151 151
    $ca_array = $attr['internal:CAs'][0];
152 152
    $author_id = "0";
153
-   if( $eap == EAP::$TTLS_PAP) {
153
+   if ($eap == EAP::$TTLS_PAP) {
154 154
       $author_id = "17236";
155
-      $servers = implode('</ServerName><ServerName>',$attr['eap:server_name']);
155
+      $servers = implode('</ServerName><ServerName>', $attr['eap:server_name']);
156 156
    }
157 157
 
158 158
   $profile_file_contents = '<EAPConfig><EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
159 159
 <EapMethod>
160 160
 <Type xmlns="http://www.microsoft.com/provisioning/EapCommon">'.
161
-    $this->selected_eap["OUTER"] .'</Type>
161
+    $this->selected_eap["OUTER"] . '</Type>
162 162
 <VendorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorId>
163 163
 <VendorType xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorType>
164
-<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">'.$author_id.'</AuthorId>
164
+<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">'.$author_id . '</AuthorId>
165 165
 </EapMethod>
166 166
 ';
167 167
 
168 168
 
169
-   if( $eap == EAP::$TTLS_PAP) {
169
+   if ($eap == EAP::$TTLS_PAP) {
170 170
 $profile_file_contents .= '
171 171
 <Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
172 172
 <EAPIdentityProviderList xmlns="urn:ietf:params:xml:ns:yang:ietf-eap-metadata">
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 <ID>eduroam.si</ID>
175 175
 <ProviderInfo>
176 176
 <CredentialPrompt>
177
-<localized-text><lang>en</lang><text>'._("Please provide your user ID and password.").'</text></localized-text>
177
+<localized-text><lang>en</lang><text>'._("Please provide your user ID and password.") . '</text></localized-text>
178 178
 </CredentialPrompt>
179 179
 <UserNameLabel>
180 180
 <localized-text><lang>en</lang><text>Username@domain:</text></localized-text>
@@ -187,13 +187,13 @@  discard block
 block discarded – undo
187 187
 <AuthenticationMethod>
188 188
 <EAPMethod>21</EAPMethod>
189 189
 ';
190
-if($use_anon == 1) {
190
+if ($use_anon == 1) {
191 191
     $profile_file_contents .= '<ClientSideCredential>
192 192
 ';
193
-    if($outer_user == '')
193
+    if ($outer_user == '')
194 194
         $profile_file_contents .= '<AnonymousIdentity>@</AnonymousIdentity>';
195 195
     else
196
-        $profile_file_contents .= '<AnonymousIdentity>'.$outer_user.'@'.$realm.'</AnonymousIdentity>';
196
+        $profile_file_contents .= '<AnonymousIdentity>' . $outer_user . '@' . $realm . '</AnonymousIdentity>';
197 197
 $profile_file_contents .= '
198 198
 </ClientSideCredential>
199 199
 ';
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
 }
229 229
 
230
-elseif( $eap == EAP::$TLS) {
230
+elseif ($eap == EAP::$TLS) {
231 231
   $profile_file_contents .= '
232 232
 
233 233
 <Config xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" 
@@ -240,15 +240,15 @@  discard block
 block discarded – undo
240 240
 </eapTls:CredentialsSource>
241 241
 <eapTls:ServerValidation>
242 242
 <eapTls:DisableUserPromptForServerValidation>true</eapTls:DisableUserPromptForServerValidation>
243
-<eapTls:ServerNames>'.$servers.'</eapTls:ServerNames>';
244
-if($ca_array) {
243
+<eapTls:ServerNames>'.$servers . '</eapTls:ServerNames>';
244
+if ($ca_array) {
245 245
 foreach ($ca_array as $CA)
246
-    if($CA['root'])
247
-       $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n";
246
+    if ($CA['root'])
247
+       $profile_file_contents .= "<eapTls:TrustedRootCA>" . $CA['sha1'] . "</eapTls:TrustedRootCA>\n";
248 248
 }
249 249
 $profile_file_contents .= '</eapTls:ServerValidation>
250 250
 ';
251
-if(isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on')
251
+if (isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on')
252 252
    $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>';
253 253
 else
254 254
    $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>';
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 </baseEap:Eap>
258 258
 </Config>
259 259
 ';
260
-} elseif ( $eap == EAP::$PEAP_MSCHAP2) {
261
-if(isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on')
260
+} elseif ($eap == EAP::$PEAP_MSCHAP2) {
261
+if (isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on')
262 262
    $nea = 'true';
263 263
 else
264 264
    $nea = 'false';
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 <msPeap:EapType>
272 272
 <msPeap:ServerValidation>
273 273
 <msPeap:DisableUserPromptForServerValidation>true</msPeap:DisableUserPromptForServerValidation> 
274
-<msPeap:ServerNames>'.$servers.'</msPeap:ServerNames>';
275
-if($ca_array) {
274
+<msPeap:ServerNames>'.$servers . '</msPeap:ServerNames>';
275
+if ($ca_array) {
276 276
 foreach ($ca_array as $CA)
277
-    if($CA['root'])
278
-       $vista_ext .= "<msPeap:TrustedRootCA>".$CA['sha1']."</msPeap:TrustedRootCA>\n";
277
+    if ($CA['root'])
278
+       $vista_ext .= "<msPeap:TrustedRootCA>" . $CA['sha1'] . "</msPeap:TrustedRootCA>\n";
279 279
 }
280 280
 $vista_ext .= '</msPeap:ServerValidation>
281 281
 <msPeap:FastReconnect>true</msPeap:FastReconnect> 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 <msChapV2:UseWinLogonCredentials>false</msChapV2:UseWinLogonCredentials> 
287 287
 </msChapV2:EapType>
288 288
 </baseEap:Eap>
289
-<msPeap:EnableQuarantineChecks>'.$nea.'</msPeap:EnableQuarantineChecks>
289
+<msPeap:EnableQuarantineChecks>'.$nea . '</msPeap:EnableQuarantineChecks>
290 290
 <msPeap:RequireCryptoBinding>false</msPeap:RequireCryptoBinding>
291 291
 </msPeap:EapType>
292 292
 </baseEap:Eap>
@@ -298,11 +298,11 @@  discard block
 block discarded – undo
298 298
 <EapType xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV1">
299 299
 <ServerValidation>
300 300
 <DisableUserPromptForServerValidation>true</DisableUserPromptForServerValidation>
301
-<ServerNames>'.$servers.'</ServerNames>';
302
-if($ca_array) {
301
+<ServerNames>'.$servers . '</ServerNames>';
302
+if ($ca_array) {
303 303
 foreach ($ca_array as $CA)
304
-    if($CA['root'])
305
-        $w7_ext .= "<TrustedRootCA>".$CA['sha1']."</TrustedRootCA>\n";
304
+    if ($CA['root'])
305
+        $w7_ext .= "<TrustedRootCA>" . $CA['sha1'] . "</TrustedRootCA>\n";
306 306
 }
307 307
 $w7_ext .= '</ServerValidation>
308 308
 <FastReconnect>true</FastReconnect> 
@@ -313,22 +313,22 @@  discard block
 block discarded – undo
313 313
 <UseWinLogonCredentials>false</UseWinLogonCredentials> 
314 314
 </EapType>
315 315
 </Eap>
316
-<EnableQuarantineChecks>'.$nea.'</EnableQuarantineChecks>
316
+<EnableQuarantineChecks>'.$nea . '</EnableQuarantineChecks>
317 317
 <RequireCryptoBinding>false</RequireCryptoBinding>
318 318
 ';
319
-if($use_anon == 1)
320
-$w7_ext .='<PeapExtensions>
319
+if ($use_anon == 1)
320
+$w7_ext .= '<PeapExtensions>
321 321
 <IdentityPrivacy xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV2">
322 322
 <EnableIdentityPrivacy>true</EnableIdentityPrivacy>
323
-<AnonymousUserName>'.$outer_user.'</AnonymousUserName>
323
+<AnonymousUserName>'.$outer_user . '</AnonymousUserName>
324 324
 </IdentityPrivacy>
325 325
 </PeapExtensions>
326 326
 ';
327
-$w7_ext .='</EapType>
327
+$w7_ext .= '</EapType>
328 328
 </Eap>
329 329
 </Config>
330 330
 ';
331
-} elseif ( $eap == EAP::$PWD) {
331
+} elseif ($eap == EAP::$PWD) {
332 332
    $profile_file_contents .= '<ConfigBlob></ConfigBlob>';
333 333
 } 
334 334
 
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
 $profile_file_contents_end = '</EapHostConfig></EAPConfig>
338 338
 ';
339 339
 $return_array = [];
340
-$return_array['vista']= $profile_file_contents.$vista_ext.$profile_file_contents_end;
341
-$return_array['w7']= $profile_file_contents.$w7_ext.$profile_file_contents_end;
340
+$return_array['vista'] = $profile_file_contents . $vista_ext . $profile_file_contents_end;
341
+$return_array['w7'] = $profile_file_contents . $w7_ext . $profile_file_contents_end;
342 342
 return $return_array;
343 343
 }
344 344
 
@@ -351,13 +351,13 @@  discard block
 block discarded – undo
351 351
 /**
352 352
  * produce PEAP and TLS configuration files for Vista and Windows 7
353 353
  */
354
-  private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) {
354
+  private function writeWLANprofile($wlan_profile_name, $ssid, $auth, $encryption, $eap_config, $i) {
355 355
 $profile_file_contents = '<?xml version="1.0"?>
356 356
 <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
357
-<name>'.$wlan_profile_name.'</name>
357
+<name>'.$wlan_profile_name . '</name>
358 358
 <SSIDConfig>
359 359
 <SSID>
360
-<name>'.$ssid.'</name>
360
+<name>'.$ssid . '</name>
361 361
 </SSID>
362 362
 <nonBroadcast>true</nonBroadcast>
363 363
 </SSIDConfig>
@@ -367,12 +367,12 @@  discard block
 block discarded – undo
367 367
 <MSM>
368 368
 <security>
369 369
 <authEncryption>
370
-<authentication>'.$auth.'</authentication>
371
-<encryption>'.$encryption.'</encryption>
370
+<authentication>'.$auth . '</authentication>
371
+<encryption>'.$encryption . '</encryption>
372 372
 <useOneX>true</useOneX>
373 373
 </authEncryption>
374 374
 ';
375
-if($auth == 'WPA2')
375
+if ($auth == 'WPA2')
376 376
 $profile_file_contents .= '<PMKCacheMode>enabled</PMKCacheMode>
377 377
 <PMKCacheTTL>720</PMKCacheTTL>
378 378
 <PMKCacheSize>128</PMKCacheSize>
@@ -390,20 +390,20 @@  discard block
 block discarded – undo
390 390
 </WLANProfile>
391 391
 ';
392 392
 
393
-if(! is_dir('w7'))
393
+if (!is_dir('w7'))
394 394
   mkdir('w7');
395
-if(! is_dir('vista'))
395
+if (!is_dir('vista'))
396 396
   mkdir('vista');
397 397
 $xml_f_name = "vista/wlan_prof-$i.xml";
398
-$xml_f = fopen($xml_f_name,'w');
399
-fwrite($xml_f,$profile_file_contents. $eap_config['vista']. $closing) ;
398
+$xml_f = fopen($xml_f_name, 'w');
399
+fwrite($xml_f, $profile_file_contents . $eap_config['vista'] . $closing);
400 400
 fclose($xml_f);
401 401
 $xml_f_name = "w7/wlan_prof-$i.xml";
402
-$xml_f = fopen($xml_f_name,'w');
403
-fwrite($xml_f,$profile_file_contents. $eap_config['w7']. $closing) ;
402
+$xml_f = fopen($xml_f_name, 'w');
403
+fwrite($xml_f, $profile_file_contents . $eap_config['w7'] . $closing);
404 404
 fclose($xml_f);
405
-debug(2,"Installer has been written into directory $this->FPATH\n");
406
-debug(4,"WLAN_Profile:$wlan_profile_name:$encryption\n");
405
+debug(2, "Installer has been written into directory $this->FPATH\n");
406
+debug(4, "WLAN_Profile:$wlan_profile_name:$encryption\n");
407 407
 return("\"$wlan_profile_name\" \"$encryption\"");
408 408
 }
409 409
 
@@ -422,48 +422,48 @@  discard block
 block discarded – undo
422 422
 </MSM>
423 423
 </LANProfile>
424 424
 ';
425
-if(! is_dir('w7'))
425
+if (!is_dir('w7'))
426 426
   mkdir('w7');
427
-if(! is_dir('vista'))
427
+if (!is_dir('vista'))
428 428
   mkdir('vista');
429 429
 $xml_f_name = "vista/lan_prof.xml";
430
-$xml_f = fopen($xml_f_name,'w');
431
-fwrite($xml_f,$profile_file_contents. $eap_config['vista']. $closing) ;
430
+$xml_f = fopen($xml_f_name, 'w');
431
+fwrite($xml_f, $profile_file_contents . $eap_config['vista'] . $closing);
432 432
 fclose($xml_f);
433 433
 $xml_f_name = "w7/lan_prof.xml";
434
-$xml_f = fopen($xml_f_name,'w');
435
-fwrite($xml_f,$profile_file_contents. $eap_config['w7']. $closing) ;
434
+$xml_f = fopen($xml_f_name, 'w');
435
+fwrite($xml_f, $profile_file_contents . $eap_config['w7'] . $closing);
436 436
 fclose($xml_f);
437 437
 }
438 438
 
439 439
 private function glueServerNames($server_list) {
440 440
 //print_r($server_list);
441
- $A0 =  array_reverse(explode('.',array_shift($server_list)));
441
+ $A0 = array_reverse(explode('.', array_shift($server_list)));
442 442
  $B = $A0;
443
- if($server_list) {
444
-   foreach($server_list as $a) {
445
-   $A= array_reverse(explode('.',$a));
446
-   $B = array_intersect_assoc($A0,$A);
443
+ if ($server_list) {
444
+   foreach ($server_list as $a) {
445
+   $A = array_reverse(explode('.', $a));
446
+   $B = array_intersect_assoc($A0, $A);
447 447
    $A0 = $B;
448 448
    }
449 449
   }
450
-  return(implode('.',array_reverse($B)));
450
+  return(implode('.', array_reverse($B)));
451 451
 }
452 452
 
453 453
 
454
-private function writeMainNSH($eap,$attr) {
455
-debug(4,"writeMainNSH"); debug(4,$attr);
456
-debug(4,"MYLANG=".$this->lang."\n");
454
+private function writeMainNSH($eap, $attr) {
455
+debug(4, "writeMainNSH"); debug(4, $attr);
456
+debug(4, "MYLANG=" . $this->lang . "\n");
457 457
 
458 458
 $EAP_OPTS = [
459
-PEAP=>['str'=>'PEAP','exec'=>'user'],
460
-TLS=>['str'=>'TLS','exec'=>'user'],
461
-TTLS=>['str'=>'ArnesLink','exec'=>'user'],
462
-PWD=>['str'=>'PWD','exec'=>'user'],
459
+PEAP=>['str'=>'PEAP', 'exec'=>'user'],
460
+TLS=>['str'=>'TLS', 'exec'=>'user'],
461
+TTLS=>['str'=>'ArnesLink', 'exec'=>'user'],
462
+PWD=>['str'=>'PWD', 'exec'=>'user'],
463 463
 ];
464 464
 $fcontents = '';
465
-if(Config::$NSIS_VERSION >= 3)
466
-    $fcontents .=  "Unicode true\n";
465
+if (Config::$NSIS_VERSION >= 3)
466
+    $fcontents .= "Unicode true\n";
467 467
  
468 468
 // Uncomment the line below if you want this module to run under XP (only displaying a warning)
469 469
 // $fcontents .= "!define ALLOW_XP\n";
@@ -471,27 +471,27 @@  discard block
 block discarded – undo
471 471
 // $fcontents .= "!define DEBUG_CAT\n";
472 472
 $exec_level = $EAP_OPTS[$eap["OUTER"]]['exec'];
473 473
 $eap_str = $EAP_OPTS[$eap["OUTER"]]['str'];
474
-debug(4,"EAP_STR=$eap_str\n");
475
-debug(4,$eap);
474
+debug(4, "EAP_STR=$eap_str\n");
475
+debug(4, $eap);
476 476
 
477
-$fcontents .= '!define '.$eap_str;
478
-$fcontents .= "\n".'!define EXECLEVEL "'.$exec_level.'"';
479
-if($attr['internal:profile_count'][0] > 1)
480
-$fcontents .= "\n".'!define USER_GROUP "'.$this->translateString(str_replace('"','$\\"',$attr['profile:name'][0]), $this->code_page).'"';
477
+$fcontents .= '!define ' . $eap_str;
478
+$fcontents .= "\n" . '!define EXECLEVEL "' . $exec_level . '"';
479
+if ($attr['internal:profile_count'][0] > 1)
480
+$fcontents .= "\n" . '!define USER_GROUP "' . $this->translateString(str_replace('"', '$\\"', $attr['profile:name'][0]), $this->code_page) . '"';
481 481
 $fcontents .= '
482
-Caption "'. $this->translateString(sprintf(sprint_nsi(_("%s installer for %s")),Config::$CONSORTIUM['name'],$attr['general:instname'][0]), $this->code_page).'"
483
-!define APPLICATION "'. $this->translateString(sprintf(sprint_nsi(_("%s installer for %s")),Config::$CONSORTIUM['name'],$attr['general:instname'][0]), $this->code_page).'"
484
-!define VERSION "'.CAT::$VERSION_MAJOR.'.'.CAT::$VERSION_MINOR.'"
482
+Caption "'. $this->translateString(sprintf(sprint_nsi(_("%s installer for %s")), Config::$CONSORTIUM['name'], $attr['general:instname'][0]), $this->code_page) . '"
483
+!define APPLICATION "'. $this->translateString(sprintf(sprint_nsi(_("%s installer for %s")), Config::$CONSORTIUM['name'], $attr['general:instname'][0]), $this->code_page) . '"
484
+!define VERSION "'.CAT::$VERSION_MAJOR . '.' . CAT::$VERSION_MINOR . '"
485 485
 !define INSTALLER_NAME "installer.exe"
486
-!define LANG "'.$this->lang.'"
486
+!define LANG "'.$this->lang . '"
487 487
 ';
488 488
 $fcontents .= $this->msInfoFile($attr);
489 489
 
490 490
 
491 491
 $fcontents .= ';--------------------------------
492
-!define ORGANISATION "'.$this->translateString($attr['general:instname'][0], $this->code_page).'"
493
-!define SUPPORT "'. ((isset($attr['support:email'][0]) && $attr['support:email'][0] ) ? $attr['support:email'][0] : $this->translateString($this->support_email_substitute , $this->code_page)) .'"
494
-!define URL "'. ((isset($attr['support:url'][0]) && $attr['support:url'][0] ) ? $attr['support:url'][0] : $this->translateString($this->support_url_substitute, $this->code_page)) .'"
492
+!define ORGANISATION "'.$this->translateString($attr['general:instname'][0], $this->code_page) . '"
493
+!define SUPPORT "'. ((isset($attr['support:email'][0]) && $attr['support:email'][0]) ? $attr['support:email'][0] : $this->translateString($this->support_email_substitute, $this->code_page)) . '"
494
+!define URL "'. ((isset($attr['support:url'][0]) && $attr['support:url'][0]) ? $attr['support:url'][0] : $this->translateString($this->support_url_substitute, $this->code_page)) . '"
495 495
 
496 496
 !ifdef TLS
497 497
 ';
@@ -501,42 +501,42 @@  discard block
 block discarded – undo
501 501
 !endif
502 502
 ';
503 503
 
504
-if(isset($this->attributes['media:wired'][0]) && $attr['media:wired'][0] == 'on')
504
+if (isset($this->attributes['media:wired'][0]) && $attr['media:wired'][0] == 'on')
505 505
   $fcontents .= '!define WIRED
506 506
 ';
507 507
 
508
-$f = fopen('main.nsh','w');
508
+$f = fopen('main.nsh', 'w');
509 509
 fwrite($f, $fcontents);
510 510
 fclose($f);
511 511
 
512 512
 }
513 513
 
514
-private function writeProfilesNSH($P,$ca_array,$wired=0) {
515
-debug(4,"writeProfilesNSH");
516
-debug(4,$P);
514
+private function writeProfilesNSH($P, $ca_array, $wired = 0) {
515
+debug(4, "writeProfilesNSH");
516
+debug(4, $P);
517 517
   $fcontents = '';
518
-  foreach($P as $p) 
518
+  foreach ($P as $p) 
519 519
     $fcontents .= "!insertmacro define_wlan_profile $p\n";
520 520
   
521
-$f = fopen('profiles.nsh','w');
521
+$f = fopen('profiles.nsh', 'w');
522 522
 fwrite($f, $fcontents);
523 523
 fclose($f);
524 524
 
525 525
 $fcontents = '';
526
-$f = fopen('certs.nsh','w');
527
-if($ca_array) {
526
+$f = fopen('certs.nsh', 'w');
527
+if ($ca_array) {
528 528
 foreach ($ca_array as $CA) {
529 529
       $store = $CA['root'] ? "root" : "ca";
530
-      $fcontents .= '!insertmacro install_ca_cert "'.$CA['file'].'" "'.$CA['sha1'].'" "'.$store."\"\n";
530
+      $fcontents .= '!insertmacro install_ca_cert "' . $CA['file'] . '" "' . $CA['sha1'] . '" "' . $store . "\"\n";
531 531
     }
532 532
 fwrite($f, $fcontents);
533 533
 }
534 534
 fclose($f);
535 535
 }
536 536
 
537
-private function copyFiles ($eap) {
538
-debug(4,"copyFiles start\n");
539
-debug(4,"code_page=".$this->code_page."\n");
537
+private function copyFiles($eap) {
538
+debug(4, "copyFiles start\n");
539
+debug(4, "code_page=" . $this->code_page . "\n");
540 540
    $result;
541 541
    $result = $this->copyFile('wlan_test.exe');
542 542
    $result = $this->copyFile('check_wired.cmd');
@@ -546,23 +546,23 @@  discard block
 block discarded – undo
546 546
    $result = $this->copyFile('cat_bg.bmp');
547 547
    $result = $result && $this->copyFile('cat32.ico');
548 548
    $result = $result && $this->copyFile('cat_150.bmp');
549
-   $this->translateFile('common.inc','common.nsh',$this->code_page);
550
-   if( $eap["OUTER"] == TTLS)  {
549
+   $this->translateFile('common.inc', 'common.nsh', $this->code_page);
550
+   if ($eap["OUTER"] == TTLS) {
551 551
      $result = $this->copyFile('GPL3.rtf');
552 552
      $result = $result && $this->copyFile('ArnesLinkEn32.msi');
553 553
      $result = $result && $this->copyFile('ArnesLinkEn64.msi');
554 554
      $result = $result && $this->copyFile('dump_arneslink_profile.cmd');
555 555
      $result = $result && $this->copyFile('install_arneslink_profile.cmd');
556
-     $this->translateFile('arnes_link.inc','cat.NSI',$this->code_page);
557
-   } elseif($eap["OUTER"] == PWD) {
558
-     $this->translateFile('pwd.inc','cat.NSI',$this->code_page);
556
+     $this->translateFile('arnes_link.inc', 'cat.NSI', $this->code_page);
557
+   } elseif ($eap["OUTER"] == PWD) {
558
+     $this->translateFile('pwd.inc', 'cat.NSI', $this->code_page);
559 559
      $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x32.msi');
560 560
      $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi');
561 561
     } else {
562
-     $this->translateFile('peap_tls.inc','cat.NSI',$this->code_page);
562
+     $this->translateFile('peap_tls.inc', 'cat.NSI', $this->code_page);
563 563
      $result = 1;
564 564
     }
565
-debug(4,"copyFiles end\n");
565
+debug(4, "copyFiles end\n");
566 566
    return($result);
567 567
 }
568 568
 
Please login to merge, or discard this patch.
Braces   +64 added lines, -44 removed lines patch added patch discarded remove patch
@@ -45,10 +45,12 @@  discard block
 block discarded – undo
45 45
 //   create a list of profiles to be deleted after installation
46 46
      $delProfiles = [];
47 47
      foreach ($delSSIDs as $ssid => $cipher) {
48
-         if($cipher == 'DEL') 
49
-          $delProfiles[] = $ssid;
50
-         if($cipher == 'TKIP') 
51
-          $delProfiles[] = $ssid.' (TKIP)';
48
+         if($cipher == 'DEL') {
49
+                   $delProfiles[] = $ssid;
50
+         }
51
+         if($cipher == 'TKIP') {
52
+                   $delProfiles[] = $ssid.' (TKIP)';
53
+         }
52 54
      }
53 55
 
54 56
      if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap == EAP::$PWD || $this->selected_eap == EAP::$TTLS_PAP) {
@@ -75,8 +77,9 @@  discard block
 block discarded – undo
75 77
     $this->writeProfilesNSH($WindowsProfile, $CA_files,$set_wired);
76 78
     $this->writeAdditionalDeletes($delProfiles);
77 79
     $this->copyFiles($this->selected_eap);
78
-    if(isset($this->attributes['internal:logo_file']))
79
-       $this->combineLogo($this->attributes['internal:logo_file']);
80
+    if(isset($this->attributes['internal:logo_file'])) {
81
+           $this->combineLogo($this->attributes['internal:logo_file']);
82
+    }
80 83
     $this->writeMainNSH($this->selected_eap,$this->attributes);
81 84
     $this->compileNSIS();
82 85
     $installer_path = $this->signInstaller($this->attributes); 
@@ -93,22 +96,24 @@  discard block
 block discarded – undo
93 96
     if($ssid_ct > 1) {
94 97
         if($ssid_ct > 2) {
95 98
             $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to the following networks:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
96
-        } else
97
-            $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
99
+        } else {
100
+                    $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
101
+        }
98 102
         $i = 0;
99 103
         foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
100 104
            if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) {
101
-             if($i > 0)
102
-           $out .= ", ";
105
+             if($i > 0) {
106
+                        $out .= ", ";
107
+             }
103 108
          $i++;
104 109
          $out .= "<strong>$ssid</strong>";
105 110
        }
106 111
     }
107 112
     $out .= "<p>";
108 113
     }
109
-    if($this->eap == EAP::$TLS)
110
-        $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.");
111
-    else {
114
+    if($this->eap == EAP::$TLS) {
115
+            $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 {
112 117
     $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.");
113 118
 
114 119
     if($this->eap == EAP::$PEAP_MSCHAP2) {
@@ -119,8 +124,9 @@  discard block
 block discarded – undo
119 124
              $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." ";
120 125
              $i = 0;
121 126
             foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
122
-                 if($i > 0)
123
-                   $out .= ", ";
127
+                 if($i > 0) {
128
+                                    $out .= ", ";
129
+                 }
124 130
                  $i++;
125 131
                  $out .= "<strong>$ssid</strong>";
126 132
             }
@@ -190,11 +196,12 @@  discard block
 block discarded – undo
190 196
 if($use_anon == 1) {
191 197
     $profile_file_contents .= '<ClientSideCredential>
192 198
 ';
193
-    if($outer_user == '')
194
-        $profile_file_contents .= '<AnonymousIdentity>@</AnonymousIdentity>';
195
-    else
196
-        $profile_file_contents .= '<AnonymousIdentity>'.$outer_user.'@'.$realm.'</AnonymousIdentity>';
197
-$profile_file_contents .= '
199
+    if($outer_user == '') {
200
+            $profile_file_contents .= '<AnonymousIdentity>@</AnonymousIdentity>';
201
+    } else {
202
+            $profile_file_contents .= '<AnonymousIdentity>'.$outer_user.'@'.$realm.'</AnonymousIdentity>';
203
+    }
204
+    $profile_file_contents .= '
198 205
 </ClientSideCredential>
199 206
 ';
200 207
 }
@@ -225,9 +232,7 @@  discard block
 block discarded – undo
225 232
 </Config>
226 233
 ';
227 234
 
228
-}
229
-
230
-elseif( $eap == EAP::$TLS) {
235
+} elseif( $eap == EAP::$TLS) {
231 236
   $profile_file_contents .= '
232 237
 
233 238
 <Config xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" 
@@ -242,26 +247,29 @@  discard block
 block discarded – undo
242 247
 <eapTls:DisableUserPromptForServerValidation>true</eapTls:DisableUserPromptForServerValidation>
243 248
 <eapTls:ServerNames>'.$servers.'</eapTls:ServerNames>';
244 249
 if($ca_array) {
245
-foreach ($ca_array as $CA)
250
+foreach ($ca_array as $CA) {
246 251
     if($CA['root'])
247 252
        $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n";
248 253
 }
254
+}
249 255
 $profile_file_contents .= '</eapTls:ServerValidation>
250 256
 ';
251
-if(isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on')
257
+if(isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on') {
252 258
    $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>';
253
-else
259
+} else {
254 260
    $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>';
261
+}
255 262
 $profile_file_contents .= '
256 263
 </eapTls:EapType>
257 264
 </baseEap:Eap>
258 265
 </Config>
259 266
 ';
260 267
 } elseif ( $eap == EAP::$PEAP_MSCHAP2) {
261
-if(isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on')
268
+if(isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on') {
262 269
    $nea = 'true';
263
-else
270
+} else {
264 271
    $nea = 'false';
272
+}
265 273
 $vista_ext = '<Config xmlns:eapUser="http://www.microsoft.com/provisioning/EapUserPropertiesV1" 
266 274
 xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" 
267 275
   xmlns:msPeap="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV1" 
@@ -273,10 +281,11 @@  discard block
 block discarded – undo
273 281
 <msPeap:DisableUserPromptForServerValidation>true</msPeap:DisableUserPromptForServerValidation> 
274 282
 <msPeap:ServerNames>'.$servers.'</msPeap:ServerNames>';
275 283
 if($ca_array) {
276
-foreach ($ca_array as $CA)
284
+foreach ($ca_array as $CA) {
277 285
     if($CA['root'])
278 286
        $vista_ext .= "<msPeap:TrustedRootCA>".$CA['sha1']."</msPeap:TrustedRootCA>\n";
279 287
 }
288
+}
280 289
 $vista_ext .= '</msPeap:ServerValidation>
281 290
 <msPeap:FastReconnect>true</msPeap:FastReconnect> 
282 291
 <msPeap:InnerEapOptional>0</msPeap:InnerEapOptional> 
@@ -300,10 +309,11 @@  discard block
 block discarded – undo
300 309
 <DisableUserPromptForServerValidation>true</DisableUserPromptForServerValidation>
301 310
 <ServerNames>'.$servers.'</ServerNames>';
302 311
 if($ca_array) {
303
-foreach ($ca_array as $CA)
312
+foreach ($ca_array as $CA) {
304 313
     if($CA['root'])
305 314
         $w7_ext .= "<TrustedRootCA>".$CA['sha1']."</TrustedRootCA>\n";
306 315
 }
316
+}
307 317
 $w7_ext .= '</ServerValidation>
308 318
 <FastReconnect>true</FastReconnect> 
309 319
 <InnerEapOptional>false</InnerEapOptional> 
@@ -316,14 +326,15 @@  discard block
 block discarded – undo
316 326
 <EnableQuarantineChecks>'.$nea.'</EnableQuarantineChecks>
317 327
 <RequireCryptoBinding>false</RequireCryptoBinding>
318 328
 ';
319
-if($use_anon == 1)
320
-$w7_ext .='<PeapExtensions>
329
+if($use_anon == 1) {
330
+    $w7_ext .='<PeapExtensions>
321 331
 <IdentityPrivacy xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV2">
322 332
 <EnableIdentityPrivacy>true</EnableIdentityPrivacy>
323 333
 <AnonymousUserName>'.$outer_user.'</AnonymousUserName>
324 334
 </IdentityPrivacy>
325 335
 </PeapExtensions>
326 336
 ';
337
+}
327 338
 $w7_ext .='</EapType>
328 339
 </Eap>
329 340
 </Config>
@@ -372,12 +383,13 @@  discard block
 block discarded – undo
372 383
 <useOneX>true</useOneX>
373 384
 </authEncryption>
374 385
 ';
375
-if($auth == 'WPA2')
376
-$profile_file_contents .= '<PMKCacheMode>enabled</PMKCacheMode>
386
+if($auth == 'WPA2') {
387
+    $profile_file_contents .= '<PMKCacheMode>enabled</PMKCacheMode>
377 388
 <PMKCacheTTL>720</PMKCacheTTL>
378 389
 <PMKCacheSize>128</PMKCacheSize>
379 390
 <preAuthMode>disabled</preAuthMode>
380 391
 ';
392
+}
381 393
 $profile_file_contents .= '<OneX xmlns="http://www.microsoft.com/networking/OneX/v1">
382 394
 <cacheUserData>true</cacheUserData>
383 395
 <authMode>user</authMode>
@@ -390,10 +402,12 @@  discard block
 block discarded – undo
390 402
 </WLANProfile>
391 403
 ';
392 404
 
393
-if(! is_dir('w7'))
405
+if(! is_dir('w7')) {
394 406
   mkdir('w7');
395
-if(! is_dir('vista'))
407
+}
408
+if(! is_dir('vista')) {
396 409
   mkdir('vista');
410
+}
397 411
 $xml_f_name = "vista/wlan_prof-$i.xml";
398 412
 $xml_f = fopen($xml_f_name,'w');
399 413
 fwrite($xml_f,$profile_file_contents. $eap_config['vista']. $closing) ;
@@ -422,10 +436,12 @@  discard block
 block discarded – undo
422 436
 </MSM>
423 437
 </LANProfile>
424 438
 ';
425
-if(! is_dir('w7'))
439
+if(! is_dir('w7')) {
426 440
   mkdir('w7');
427
-if(! is_dir('vista'))
441
+}
442
+if(! is_dir('vista')) {
428 443
   mkdir('vista');
444
+}
429 445
 $xml_f_name = "vista/lan_prof.xml";
430 446
 $xml_f = fopen($xml_f_name,'w');
431 447
 fwrite($xml_f,$profile_file_contents. $eap_config['vista']. $closing) ;
@@ -462,8 +478,9 @@  discard block
 block discarded – undo
462 478
 PWD=>['str'=>'PWD','exec'=>'user'],
463 479
 ];
464 480
 $fcontents = '';
465
-if(Config::$NSIS_VERSION >= 3)
481
+if(Config::$NSIS_VERSION >= 3) {
466 482
     $fcontents .=  "Unicode true\n";
483
+}
467 484
  
468 485
 // Uncomment the line below if you want this module to run under XP (only displaying a warning)
469 486
 // $fcontents .= "!define ALLOW_XP\n";
@@ -476,8 +493,9 @@  discard block
 block discarded – undo
476 493
 
477 494
 $fcontents .= '!define '.$eap_str;
478 495
 $fcontents .= "\n".'!define EXECLEVEL "'.$exec_level.'"';
479
-if($attr['internal:profile_count'][0] > 1)
480
-$fcontents .= "\n".'!define USER_GROUP "'.$this->translateString(str_replace('"','$\\"',$attr['profile:name'][0]), $this->code_page).'"';
496
+if($attr['internal:profile_count'][0] > 1) {
497
+    $fcontents .= "\n".'!define USER_GROUP "'.$this->translateString(str_replace('"','$\\"',$attr['profile:name'][0]), $this->code_page).'"';
498
+}
481 499
 $fcontents .= '
482 500
 Caption "'. $this->translateString(sprintf(sprint_nsi(_("%s installer for %s")),Config::$CONSORTIUM['name'],$attr['general:instname'][0]), $this->code_page).'"
483 501
 !define APPLICATION "'. $this->translateString(sprintf(sprint_nsi(_("%s installer for %s")),Config::$CONSORTIUM['name'],$attr['general:instname'][0]), $this->code_page).'"
@@ -501,9 +519,10 @@  discard block
 block discarded – undo
501 519
 !endif
502 520
 ';
503 521
 
504
-if(isset($this->attributes['media:wired'][0]) && $attr['media:wired'][0] == 'on')
522
+if(isset($this->attributes['media:wired'][0]) && $attr['media:wired'][0] == 'on') {
505 523
   $fcontents .= '!define WIRED
506 524
 ';
525
+}
507 526
 
508 527
 $f = fopen('main.nsh','w');
509 528
 fwrite($f, $fcontents);
@@ -515,8 +534,9 @@  discard block
 block discarded – undo
515 534
 debug(4,"writeProfilesNSH");
516 535
 debug(4,$P);
517 536
   $fcontents = '';
518
-  foreach($P as $p) 
519
-    $fcontents .= "!insertmacro define_wlan_profile $p\n";
537
+  foreach($P as $p) {
538
+      $fcontents .= "!insertmacro define_wlan_profile $p\n";
539
+  }
520 540
   
521 541
 $f = fopen('profiles.nsh','w');
522 542
 fwrite($f, $fcontents);
Please login to merge, or discard this patch.
devices/ms/W8.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -308,6 +308,9 @@
 block discarded – undo
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"?>
Please login to merge, or discard this patch.
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -26,74 +26,74 @@  discard block
 block discarded – undo
26 26
  */
27 27
 class Device_W8 extends WindowsCommon {
28 28
     final public function __construct() {
29
-      $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$TTLS_MSCHAP2, EAP::$PWD];
29
+        $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$TTLS_MSCHAP2, EAP::$PWD];
30 30
 #      $this->supportedEapMethods = array(EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$PWD);
31
-      debug(4,"This device supports the following EAP methods: ");
32
-      debug(4,$this->supportedEapMethods);
33
-      $this->specialities['anon_id'][serialize(EAP::$PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead.");
31
+        debug(4,"This device supports the following EAP methods: ");
32
+        debug(4,$this->supportedEapMethods);
33
+        $this->specialities['anon_id'][serialize(EAP::$PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead.");
34 34
     }
35 35
 
36
-  public function writeInstaller() {
37
-      $dom = textdomain(NULL);
38
-      textdomain("devices");
39
-   // create certificate files and save their names in $CA_files arrary
40
-     $CA_files = $this->saveCertificateFiles('der');
36
+    public function writeInstaller() {
37
+        $dom = textdomain(NULL);
38
+        textdomain("devices");
39
+    // create certificate files and save their names in $CA_files arrary
40
+        $CA_files = $this->saveCertificateFiles('der');
41 41
 
42
-     $SSIDs = $this->attributes['internal:SSID'];
43
-     $delSSIDs = $this->attributes['internal:remove_SSID'];
44
-     $this->prepareInstallerLang();
45
-     $set_wired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0;
42
+        $SSIDs = $this->attributes['internal:SSID'];
43
+        $delSSIDs = $this->attributes['internal:remove_SSID'];
44
+        $this->prepareInstallerLang();
45
+        $set_wired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0;
46 46
 //   create a list of profiles to be deleted after installation
47
-     $delProfiles = [];
48
-     foreach ($delSSIDs as $ssid => $cipher) {
49
-         if($cipher == 'DEL')
50
-          $delProfiles[] = $ssid;
51
-         if($cipher == 'TKIP')
52
-          $delProfiles[] = $ssid.' (TKIP)';
53
-     }
54
-
55
-
56
-     if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap ==  EAP::$TTLS_PAP || $this->selected_eap == EAP::$TTLS_MSCHAP2 || $this->selected_eap == EAP::$PWD) {
57
-       $WindowsProfile = [];
58
-       $eap_config = $this->prepareEapConfig($this->attributes);
59
-       $i = 0;
60
-       foreach ($SSIDs as $ssid => $cipher) {
61
-          if($cipher == 'TKIP') {
62
-             $WindowsProfile[$i] = $this->writeWLANprofile ($ssid.' (TKIP)',$ssid,'WPA','TKIP',$eap_config,$i);
63
-             $i++;
64
-          }
65
-          $WindowsProfile[$i] = $this->writeWLANprofile ($ssid,$ssid,'WPA2','AES',$eap_config,$i);
66
-          $i++;
67
-       }
68
-       if($set_wired) {
69
-         $this->writeLANprofile($eap_config);
70
-       }
71
-     } else {
72
-       error("  this EAP type is not handled yet");
73
-       return;
74
-     }
47
+        $delProfiles = [];
48
+        foreach ($delSSIDs as $ssid => $cipher) {
49
+            if($cipher == 'DEL')
50
+            $delProfiles[] = $ssid;
51
+            if($cipher == 'TKIP')
52
+            $delProfiles[] = $ssid.' (TKIP)';
53
+        }
54
+
55
+
56
+        if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap ==  EAP::$TTLS_PAP || $this->selected_eap == EAP::$TTLS_MSCHAP2 || $this->selected_eap == EAP::$PWD) {
57
+        $WindowsProfile = [];
58
+        $eap_config = $this->prepareEapConfig($this->attributes);
59
+        $i = 0;
60
+        foreach ($SSIDs as $ssid => $cipher) {
61
+            if($cipher == 'TKIP') {
62
+                $WindowsProfile[$i] = $this->writeWLANprofile ($ssid.' (TKIP)',$ssid,'WPA','TKIP',$eap_config,$i);
63
+                $i++;
64
+            }
65
+            $WindowsProfile[$i] = $this->writeWLANprofile ($ssid,$ssid,'WPA2','AES',$eap_config,$i);
66
+            $i++;
67
+        }
68
+        if($set_wired) {
69
+            $this->writeLANprofile($eap_config);
70
+        }
71
+        } else {
72
+        error("  this EAP type is not handled yet");
73
+        return;
74
+        }
75 75
     debug(4,"WindowsProfile"); debug(4,$WindowsProfile);
76 76
     
77 77
     $this->writeProfilesNSH($WindowsProfile, $CA_files,$set_wired);
78 78
     $this->writeAdditionalDeletes($delProfiles);
79 79
     if(isset($additional_deletes) && count($additional_deletes))
80
-       $this->writeAdditionalDeletes($additional_deletes);
80
+        $this->writeAdditionalDeletes($additional_deletes);
81 81
     $this->copyFiles($this->selected_eap);
82 82
     if(isset($this->attributes['internal:logo_file']))
83
-       $this->combineLogo($this->attributes['internal:logo_file']);
83
+        $this->combineLogo($this->attributes['internal:logo_file']);
84 84
     $this->writeMainNSH($this->selected_eap,$this->attributes);
85 85
     $this->compileNSIS();
86 86
     $installer_path = $this->signInstaller($this->attributes); 
87 87
 
88 88
     textdomain($dom);
89 89
     return($installer_path);  
90
-  }
90
+    }
91 91
 
92
-  public function writeDeviceInfo() {
92
+    public function writeDeviceInfo() {
93 93
     $ssid_ct=count($this->attributes['internal:SSID']);
94
-   $out = "<p>";
95
-   $out .= sprintf(_("%s installer will be in the form of an EXE file. It will configure %s on your device, by creating wireless network profiles.<p>When you click the download button, the installer will be saved by your browser. Copy it to the machine you want to configure and execute."),Config::$CONSORTIUM['name'],Config::$CONSORTIUM['name']);
96
-   $out .= "<p>";
94
+    $out = "<p>";
95
+    $out .= sprintf(_("%s installer will be in the form of an EXE file. It will configure %s on your device, by creating wireless network profiles.<p>When you click the download button, the installer will be saved by your browser. Copy it to the machine you want to configure and execute."),Config::$CONSORTIUM['name'],Config::$CONSORTIUM['name']);
96
+    $out .= "<p>";
97 97
     if($ssid_ct > 1) {
98 98
         if($ssid_ct > 2) {
99 99
             $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to the following networks:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
@@ -101,52 +101,52 @@  discard block
 block discarded – undo
101 101
             $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
102 102
         $i = 0;
103 103
         foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
104
-           if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) {
105
-             if($i > 0)
106
-           $out .= ", ";
107
-         $i++;
108
-         $out .= "<strong>$ssid</strong>";
109
-       }
104
+            if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) {
105
+                if($i > 0)
106
+            $out .= ", ";
107
+            $i++;
108
+            $out .= "<strong>$ssid</strong>";
109
+        }
110 110
     }
111 111
     $out .= "<p>";
112 112
     }
113 113
 
114 114
 if($this->eap == EAP::$TLS)
115
-   $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.");
115
+    $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 116
 else {
117
-   $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
-   $out .= "<p>";
119
-   $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.");
117
+    $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
+    $out .= "<p>";
119
+    $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.");
120 120
         if($ssid_ct > 1) {
121
-             $out .= "<p>";
122
-             $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." ";
123
-             $i = 0;
121
+                $out .= "<p>";
122
+                $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." ";
123
+                $i = 0;
124 124
             foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
125
-                 if($i > 0)
126
-                   $out .= ", ";
127
-                 $i++;
128
-                 $out .= "<strong>$ssid</strong>";
125
+                    if($i > 0)
126
+                    $out .= ", ";
127
+                    $i++;
128
+                    $out .= "<strong>$ssid</strong>";
129 129
             }
130 130
     }
131 131
 
132 132
 
133 133
 }
134 134
     return $out;
135
-  }
135
+    }
136 136
 
137 137
 
138 138
 private function prepareEapConfig($attr) {
139
-   $eap = $this->selected_eap;
140
-   $w8_ext = '';
141
-   $use_anon = $attr['internal:use_anon_outer'] [0];
142
-   if ($use_anon) {
143
-     $outer_user = $attr['internal:anon_local_value'][0];
144
-     $outer_id = $outer_user.'@'.$attr['internal:realm'][0];
145
-   }
139
+    $eap = $this->selected_eap;
140
+    $w8_ext = '';
141
+    $use_anon = $attr['internal:use_anon_outer'] [0];
142
+    if ($use_anon) {
143
+        $outer_user = $attr['internal:anon_local_value'][0];
144
+        $outer_id = $outer_user.'@'.$attr['internal:realm'][0];
145
+    }
146 146
 //   $servers = preg_quote(implode(';',$attr['eap:server_name']));
147
-   $servers = implode(';',$attr['eap:server_name']);
147
+    $servers = implode(';',$attr['eap:server_name']);
148 148
    
149
-   $ca_array = $attr['internal:CAs'][0];
149
+    $ca_array = $attr['internal:CAs'][0];
150 150
 
151 151
 
152 152
 $profile_file_contents = '<EAPConfig><EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 $profile_file_contents .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId>
163 163
 </EapMethod>
164 164
 ';
165
-  $profile_file_contents .= '
165
+    $profile_file_contents .= '
166 166
 
167 167
 <Config xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" 
168 168
   xmlns:eapTls="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV1">
@@ -178,14 +178,14 @@  discard block
 block discarded – undo
178 178
 if($ca_array) {
179 179
 foreach ($ca_array as $CA)
180 180
     if($CA['root'])
181
-       $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n";
181
+        $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n";
182 182
 }
183 183
 $profile_file_contents .= '</eapTls:ServerValidation>
184 184
 ';
185 185
 if(isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on')
186
-   $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>';
186
+    $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>';
187 187
 else
188
-   $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>';
188
+    $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>';
189 189
 $profile_file_contents .= '
190 190
 </eapTls:EapType>
191 191
 </baseEap:Eap>
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 ';
194 194
 } elseif ( $eap == EAP::$PEAP_MSCHAP2) {
195 195
 if(isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on')
196
-   $nea = 'true';
196
+    $nea = 'true';
197 197
 else
198
-   $nea = 'false';
198
+    $nea = 'false';
199 199
 $profile_file_contents .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId>
200 200
 </EapMethod>
201 201
 ';
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 <Phase2Authentication>
261 261
 ';
262 262
 if ( $eap == EAP::$TTLS_PAP) {
263
-   $w8_ext .='<PAPAuthentication /> ';
263
+    $w8_ext .='<PAPAuthentication /> ';
264 264
 }
265 265
 if ( $eap == EAP::$TTLS_MSCHAP2)  {
266
-   $w8_ext .='<MSCHAPv2Authentication>
266
+    $w8_ext .='<MSCHAPv2Authentication>
267 267
 <UseWinlogonCredentials>false</UseWinlogonCredentials>
268 268
 </MSCHAPv2Authentication>
269 269
 ';
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
 <Phase1Identity>
273 273
 ';
274 274
 if($use_anon == 1) {
275
-  $w8_ext .= '<IdentityPrivacy>true</IdentityPrivacy> 
275
+    $w8_ext .= '<IdentityPrivacy>true</IdentityPrivacy> 
276 276
 ';
277
-  if(isset($outer_id) && $outer_id) 
277
+    if(isset($outer_id) && $outer_id) 
278 278
     $w8_ext .='<AnonymousIdentity>'.$outer_id.'</AnonymousIdentity>
279 279
 ';
280
-  else
280
+    else
281 281
     $w8_ext .='<AnonymousIdentity/>
282 282
 ';
283 283
 } else {
284
-  $w8_ext .= '<IdentityPrivacy>false</IdentityPrivacy>
284
+    $w8_ext .= '<IdentityPrivacy>false</IdentityPrivacy>
285 285
 ';
286 286
 }
287 287
 $w8_ext .='</Phase1Identity>
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 $profile_file_contents .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId>
293 293
 </EapMethod>
294 294
 ';
295
-   $profile_file_contents .= '<ConfigBlob></ConfigBlob>';
295
+    $profile_file_contents .= '<ConfigBlob></ConfigBlob>';
296 296
 }
297 297
 
298 298
 $profile_file_contents_end = '</EapHostConfig></EAPConfig>';
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 /**
310 310
  * produce PEAP, TLS and TTLS configuration files for Windows 8
311 311
  */
312
-  private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) {
312
+    private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) {
313 313
 $profile_file_contents = '<?xml version="1.0"?>
314 314
 <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
315 315
 <name>'.$wlan_profile_name.'</name>
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 ';
350 350
 
351 351
 if(! is_dir('w8'))
352
-  mkdir('w8');
352
+    mkdir('w8');
353 353
 $xml_f_name = "w8/wlan_prof-$i.xml";
354 354
 $xml_f = fopen($xml_f_name,'w');
355 355
 fwrite($xml_f,$profile_file_contents. $eap_config['w8']. $closing) ;
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 ';
377 377
 
378 378
 if(! is_dir('w8'))
379
-  mkdir('w8');
379
+    mkdir('w8');
380 380
 $xml_f_name = "w8/lan_prof.xml";
381 381
 $xml_f = fopen($xml_f_name,'w');
382 382
 fwrite($xml_f,$profile_file_contents. $eap_config['w8']. $closing) ;
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 ';
436 436
 
437 437
 if(isset($this->attributes['media:wired'][0]) && $attr['media:wired'][0] == 'on')
438
-  $fcontents .= '!define WIRED
438
+    $fcontents .= '!define WIRED
439 439
 ';
440 440
 
441 441
 $f = fopen('main.nsh','w');
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 debug(4,"writeProfilesNSH");
449 449
 debug(4,$P);
450 450
 $fcontents = '';
451
-  foreach($P as $p) 
451
+    foreach($P as $p) 
452 452
     $fcontents .= "!insertmacro define_wlan_profile $p\n";
453 453
 
454 454
 $f = fopen('profiles.nsh','w');
@@ -459,8 +459,8 @@  discard block
 block discarded – undo
459 459
 $f = fopen('certs.nsh','w');
460 460
 if($ca_array) {
461 461
 foreach ($ca_array as $CA) {
462
-      $store = $CA['root'] ? "root" : "ca";
463
-      $fcontents .= '!insertmacro install_ca_cert "'.$CA['file'].'" "'.$CA['sha1'].'" "'.$store."\"\n";
462
+        $store = $CA['root'] ? "root" : "ca";
463
+        $fcontents .= '!insertmacro install_ca_cert "'.$CA['file'].'" "'.$CA['sha1'].'" "'.$store."\"\n";
464 464
     }
465 465
 fwrite($f, $fcontents);
466 466
 }
@@ -471,26 +471,26 @@  discard block
 block discarded – undo
471 471
 
472 472
 private function copyFiles ($eap) {
473 473
 debug(4,"copyFiles start\n");
474
-   $result;
475
-   $result = $this->copyFile('wlan_test.exe');
476
-   $result = $this->copyFile('check_wired.cmd');
477
-   $result = $this->copyFile('install_wired.cmd');
478
-   $result = $this->copyFile('setEAPCred.exe');
479
-   $result = $this->copyFile('cat_bg.bmp');
480
-   $result = $this->copyFile('base64.nsh');
481
-   $result = $result && $this->copyFile('cat32.ico');
482
-   $result = $result && $this->copyFile('cat_150.bmp');
483
-   $this->translateFile('common.inc','common.nsh',$this->code_page);
484
-   if($eap["OUTER"] == PWD) {
485
-     $this->translateFile('pwd.inc','cat.NSI',$this->code_page);
486
-     $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x32.msi');
487
-     $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi');
488
-   } else {
489
-   $this->translateFile('eap_w8.inc','cat.NSI',$this->code_page);
490
-   $result = 1;
491
-   }
474
+    $result;
475
+    $result = $this->copyFile('wlan_test.exe');
476
+    $result = $this->copyFile('check_wired.cmd');
477
+    $result = $this->copyFile('install_wired.cmd');
478
+    $result = $this->copyFile('setEAPCred.exe');
479
+    $result = $this->copyFile('cat_bg.bmp');
480
+    $result = $this->copyFile('base64.nsh');
481
+    $result = $result && $this->copyFile('cat32.ico');
482
+    $result = $result && $this->copyFile('cat_150.bmp');
483
+    $this->translateFile('common.inc','common.nsh',$this->code_page);
484
+    if($eap["OUTER"] == PWD) {
485
+        $this->translateFile('pwd.inc','cat.NSI',$this->code_page);
486
+        $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x32.msi');
487
+        $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi');
488
+    } else {
489
+    $this->translateFile('eap_w8.inc','cat.NSI',$this->code_page);
490
+    $result = 1;
491
+    }
492 492
 debug(4,"copyFiles end\n");
493
-   return($result);
493
+    return($result);
494 494
 }
495 495
 
496 496
 }
Please login to merge, or discard this patch.
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
     final public function __construct() {
29 29
       $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$TTLS_MSCHAP2, EAP::$PWD];
30 30
 #      $this->supportedEapMethods = array(EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$PWD);
31
-      debug(4,"This device supports the following EAP methods: ");
32
-      debug(4,$this->supportedEapMethods);
31
+      debug(4, "This device supports the following EAP methods: ");
32
+      debug(4, $this->supportedEapMethods);
33 33
       $this->specialities['anon_id'][serialize(EAP::$PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead.");
34 34
     }
35 35
 
@@ -46,42 +46,42 @@  discard block
 block discarded – undo
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')
49
+         if ($cipher == 'DEL')
50 50
           $delProfiles[] = $ssid;
51
-         if($cipher == 'TKIP')
52
-          $delProfiles[] = $ssid.' (TKIP)';
51
+         if ($cipher == 'TKIP')
52
+          $delProfiles[] = $ssid . ' (TKIP)';
53 53
      }
54 54
 
55 55
 
56
-     if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap ==  EAP::$TTLS_PAP || $this->selected_eap == EAP::$TTLS_MSCHAP2 || $this->selected_eap == EAP::$PWD) {
56
+     if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap == EAP::$TTLS_PAP || $this->selected_eap == EAP::$TTLS_MSCHAP2 || $this->selected_eap == EAP::$PWD) {
57 57
        $WindowsProfile = [];
58 58
        $eap_config = $this->prepareEapConfig($this->attributes);
59 59
        $i = 0;
60 60
        foreach ($SSIDs as $ssid => $cipher) {
61
-          if($cipher == 'TKIP') {
62
-             $WindowsProfile[$i] = $this->writeWLANprofile ($ssid.' (TKIP)',$ssid,'WPA','TKIP',$eap_config,$i);
61
+          if ($cipher == 'TKIP') {
62
+             $WindowsProfile[$i] = $this->writeWLANprofile($ssid . ' (TKIP)', $ssid, 'WPA', 'TKIP', $eap_config, $i);
63 63
              $i++;
64 64
           }
65
-          $WindowsProfile[$i] = $this->writeWLANprofile ($ssid,$ssid,'WPA2','AES',$eap_config,$i);
65
+          $WindowsProfile[$i] = $this->writeWLANprofile($ssid, $ssid, 'WPA2', 'AES', $eap_config, $i);
66 66
           $i++;
67 67
        }
68
-       if($set_wired) {
68
+       if ($set_wired) {
69 69
          $this->writeLANprofile($eap_config);
70 70
        }
71 71
      } else {
72 72
        error("  this EAP type is not handled yet");
73 73
        return;
74 74
      }
75
-    debug(4,"WindowsProfile"); debug(4,$WindowsProfile);
75
+    debug(4, "WindowsProfile"); debug(4, $WindowsProfile);
76 76
     
77
-    $this->writeProfilesNSH($WindowsProfile, $CA_files,$set_wired);
77
+    $this->writeProfilesNSH($WindowsProfile, $CA_files, $set_wired);
78 78
     $this->writeAdditionalDeletes($delProfiles);
79
-    if(isset($additional_deletes) && count($additional_deletes))
79
+    if (isset($additional_deletes) && count($additional_deletes))
80 80
        $this->writeAdditionalDeletes($additional_deletes);
81 81
     $this->copyFiles($this->selected_eap);
82
-    if(isset($this->attributes['internal:logo_file']))
82
+    if (isset($this->attributes['internal:logo_file']))
83 83
        $this->combineLogo($this->attributes['internal:logo_file']);
84
-    $this->writeMainNSH($this->selected_eap,$this->attributes);
84
+    $this->writeMainNSH($this->selected_eap, $this->attributes);
85 85
     $this->compileNSIS();
86 86
     $installer_path = $this->signInstaller($this->attributes); 
87 87
 
@@ -90,19 +90,19 @@  discard block
 block discarded – undo
90 90
   }
91 91
 
92 92
   public function writeDeviceInfo() {
93
-    $ssid_ct=count($this->attributes['internal:SSID']);
93
+    $ssid_ct = count($this->attributes['internal:SSID']);
94 94
    $out = "<p>";
95
-   $out .= sprintf(_("%s installer will be in the form of an EXE file. It will configure %s on your device, by creating wireless network profiles.<p>When you click the download button, the installer will be saved by your browser. Copy it to the machine you want to configure and execute."),Config::$CONSORTIUM['name'],Config::$CONSORTIUM['name']);
95
+   $out .= sprintf(_("%s installer will be in the form of an EXE file. It will configure %s on your device, by creating wireless network profiles.<p>When you click the download button, the installer will be saved by your browser. Copy it to the machine you want to configure and execute."), Config::$CONSORTIUM['name'], Config::$CONSORTIUM['name']);
96 96
    $out .= "<p>";
97
-    if($ssid_ct > 1) {
98
-        if($ssid_ct > 2) {
99
-            $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to the following networks:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
97
+    if ($ssid_ct > 1) {
98
+        if ($ssid_ct > 2) {
99
+            $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to the following networks:"), implode(', ', Config::$CONSORTIUM['ssid'])) . " ";
100 100
         } else
101
-            $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
101
+            $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"), implode(', ', Config::$CONSORTIUM['ssid'])) . " ";
102 102
         $i = 0;
103 103
         foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
104
-           if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) {
105
-             if($i > 0)
104
+           if (!in_array($ssid, Config::$CONSORTIUM['ssid'])) {
105
+             if ($i > 0)
106 106
            $out .= ", ";
107 107
          $i++;
108 108
          $out .= "<strong>$ssid</strong>";
@@ -111,18 +111,18 @@  discard block
 block discarded – undo
111 111
     $out .= "<p>";
112 112
     }
113 113
 
114
-if($this->eap == EAP::$TLS)
114
+if ($this->eap == EAP::$TLS)
115 115
    $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 116
 else {
117 117
    $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 118
    $out .= "<p>";
119 119
    $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.");
120
-        if($ssid_ct > 1) {
120
+        if ($ssid_ct > 1) {
121 121
              $out .= "<p>";
122
-             $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." ";
122
+             $out .= _("You will be required to enter the same credentials for each of the configured notworks:") . " ";
123 123
              $i = 0;
124 124
             foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
125
-                 if($i > 0)
125
+                 if ($i > 0)
126 126
                    $out .= ", ";
127 127
                  $i++;
128 128
                  $out .= "<strong>$ssid</strong>";
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
    $use_anon = $attr['internal:use_anon_outer'] [0];
142 142
    if ($use_anon) {
143 143
      $outer_user = $attr['internal:anon_local_value'][0];
144
-     $outer_id = $outer_user.'@'.$attr['internal:realm'][0];
144
+     $outer_id = $outer_user . '@' . $attr['internal:realm'][0];
145 145
    }
146 146
 //   $servers = preg_quote(implode(';',$attr['eap:server_name']));
147
-   $servers = implode(';',$attr['eap:server_name']);
147
+   $servers = implode(';', $attr['eap:server_name']);
148 148
    
149 149
    $ca_array = $attr['internal:CAs'][0];
150 150
 
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
 <EapMethod>
154 154
 ';
155 155
 
156
-$profile_file_contents .= '<Type xmlns="http://www.microsoft.com/provisioning/EapCommon">'.
157
-    $this->selected_eap["OUTER"].'</Type>
156
+$profile_file_contents .= '<Type xmlns="http://www.microsoft.com/provisioning/EapCommon">' .
157
+    $this->selected_eap["OUTER"] . '</Type>
158 158
 <VendorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorId>
159 159
 <VendorType xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorType>
160 160
 ';
161
-if( $eap == EAP::$TLS) {
161
+if ($eap == EAP::$TLS) {
162 162
 $profile_file_contents .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId>
163 163
 </EapMethod>
164 164
 ';
@@ -174,15 +174,15 @@  discard block
 block discarded – undo
174 174
 </eapTls:CredentialsSource>
175 175
 <eapTls:ServerValidation>
176 176
 <eapTls:DisableUserPromptForServerValidation>true</eapTls:DisableUserPromptForServerValidation>
177
-<eapTls:ServerNames>'.$servers.'</eapTls:ServerNames>';
178
-if($ca_array) {
177
+<eapTls:ServerNames>'.$servers . '</eapTls:ServerNames>';
178
+if ($ca_array) {
179 179
 foreach ($ca_array as $CA)
180
-    if($CA['root'])
181
-       $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n";
180
+    if ($CA['root'])
181
+       $profile_file_contents .= "<eapTls:TrustedRootCA>" . $CA['sha1'] . "</eapTls:TrustedRootCA>\n";
182 182
 }
183 183
 $profile_file_contents .= '</eapTls:ServerValidation>
184 184
 ';
185
-if(isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on')
185
+if (isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on')
186 186
    $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>';
187 187
 else
188 188
    $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>';
@@ -191,8 +191,8 @@  discard block
 block discarded – undo
191 191
 </baseEap:Eap>
192 192
 </Config>
193 193
 ';
194
-} elseif ( $eap == EAP::$PEAP_MSCHAP2) {
195
-if(isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on')
194
+} elseif ($eap == EAP::$PEAP_MSCHAP2) {
195
+if (isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on')
196 196
    $nea = 'true';
197 197
 else
198 198
    $nea = 'false';
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
 <EapType xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV1">
206 206
 <ServerValidation>
207 207
 <DisableUserPromptForServerValidation>true</DisableUserPromptForServerValidation>
208
-<ServerNames>'.$servers.'</ServerNames>';
209
-if($ca_array) {
208
+<ServerNames>'.$servers . '</ServerNames>';
209
+if ($ca_array) {
210 210
 foreach ($ca_array as $CA)
211
-    if($CA['root'])
212
-        $w8_ext .= "<TrustedRootCA>".$CA['sha1']."</TrustedRootCA>\n";
211
+    if ($CA['root'])
212
+        $w8_ext .= "<TrustedRootCA>" . $CA['sha1'] . "</TrustedRootCA>\n";
213 213
 }
214 214
 $w8_ext .= '</ServerValidation>
215 215
 <FastReconnect>true</FastReconnect> 
@@ -220,50 +220,50 @@  discard block
 block discarded – undo
220 220
 <UseWinLogonCredentials>false</UseWinLogonCredentials> 
221 221
 </EapType>
222 222
 </Eap>
223
-<EnableQuarantineChecks>'.$nea.'</EnableQuarantineChecks>
223
+<EnableQuarantineChecks>'.$nea . '</EnableQuarantineChecks>
224 224
 <RequireCryptoBinding>false</RequireCryptoBinding>
225 225
 ';
226
-if($use_anon == 1) {
227
-$w8_ext .='<PeapExtensions>
226
+if ($use_anon == 1) {
227
+$w8_ext .= '<PeapExtensions>
228 228
 <IdentityPrivacy xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV2">
229 229
 <EnableIdentityPrivacy>true</EnableIdentityPrivacy>
230 230
 ';
231
-if(isset($outer_user) && $outer_user) 
232
-$w8_ext .='<AnonymousUserName>'.$outer_user.'</AnonymousUserName>
231
+if (isset($outer_user) && $outer_user) 
232
+$w8_ext .= '<AnonymousUserName>' . $outer_user . '</AnonymousUserName>
233 233
 ';
234 234
 else
235
-$w8_ext .='<AnonymousUserName/>
235
+$w8_ext .= '<AnonymousUserName/>
236 236
 ';
237
-$w8_ext .='</IdentityPrivacy>
237
+$w8_ext .= '</IdentityPrivacy>
238 238
 </PeapExtensions>
239 239
 ';
240 240
 }
241
-$w8_ext .='</EapType>
241
+$w8_ext .= '</EapType>
242 242
 </Eap>
243 243
 </Config>
244 244
 ';
245
-} elseif ( $eap == EAP::$TTLS_PAP || $eap == EAP::$TTLS_MSCHAP2) {
245
+} elseif ($eap == EAP::$TTLS_PAP || $eap == EAP::$TTLS_MSCHAP2) {
246 246
 $profile_file_contents .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">311</AuthorId>
247 247
 </EapMethod>
248 248
 ';
249 249
 $w8_ext = '<Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
250 250
 <EapTtls xmlns="http://www.microsoft.com/provisioning/EapTtlsConnectionPropertiesV1">
251 251
 <ServerValidation>
252
-<ServerNames>'.$servers.'</ServerNames> ';
253
-if($ca_array) {
252
+<ServerNames>'.$servers . '</ServerNames> ';
253
+if ($ca_array) {
254 254
 foreach ($ca_array as $CA)
255
-    if($CA['root'])
256
-        $w8_ext .= "<TrustedRootCAHash>".chunk_split($CA['sha1'],2,' ')."</TrustedRootCAHash>\n";
255
+    if ($CA['root'])
256
+        $w8_ext .= "<TrustedRootCAHash>" . chunk_split($CA['sha1'], 2, ' ') . "</TrustedRootCAHash>\n";
257 257
 }
258
-$w8_ext .='<DisablePrompt>true</DisablePrompt> 
258
+$w8_ext .= '<DisablePrompt>true</DisablePrompt> 
259 259
 </ServerValidation>
260 260
 <Phase2Authentication>
261 261
 ';
262
-if ( $eap == EAP::$TTLS_PAP) {
263
-   $w8_ext .='<PAPAuthentication /> ';
262
+if ($eap == EAP::$TTLS_PAP) {
263
+   $w8_ext .= '<PAPAuthentication /> ';
264 264
 }
265
-if ( $eap == EAP::$TTLS_MSCHAP2)  {
266
-   $w8_ext .='<MSCHAPv2Authentication>
265
+if ($eap == EAP::$TTLS_MSCHAP2) {
266
+   $w8_ext .= '<MSCHAPv2Authentication>
267 267
 <UseWinlogonCredentials>false</UseWinlogonCredentials>
268 268
 </MSCHAPv2Authentication>
269 269
 ';
@@ -271,24 +271,24 @@  discard block
 block discarded – undo
271 271
 $w8_ext .= '</Phase2Authentication>
272 272
 <Phase1Identity>
273 273
 ';
274
-if($use_anon == 1) {
274
+if ($use_anon == 1) {
275 275
   $w8_ext .= '<IdentityPrivacy>true</IdentityPrivacy> 
276 276
 ';
277
-  if(isset($outer_id) && $outer_id) 
278
-    $w8_ext .='<AnonymousIdentity>'.$outer_id.'</AnonymousIdentity>
277
+  if (isset($outer_id) && $outer_id) 
278
+    $w8_ext .= '<AnonymousIdentity>' . $outer_id . '</AnonymousIdentity>
279 279
 ';
280 280
   else
281
-    $w8_ext .='<AnonymousIdentity/>
281
+    $w8_ext .= '<AnonymousIdentity/>
282 282
 ';
283 283
 } else {
284 284
   $w8_ext .= '<IdentityPrivacy>false</IdentityPrivacy>
285 285
 ';
286 286
 }
287
-$w8_ext .='</Phase1Identity>
287
+$w8_ext .= '</Phase1Identity>
288 288
 </EapTtls>
289 289
 </Config>
290 290
 ';
291
-} elseif ( $eap == EAP::$PWD) {
291
+} elseif ($eap == EAP::$PWD) {
292 292
 $profile_file_contents .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId>
293 293
 </EapMethod>
294 294
 ';
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 
298 298
 $profile_file_contents_end = '</EapHostConfig></EAPConfig>';
299 299
 $return_array = [];
300
-$return_array['w8'] = $profile_file_contents.$w8_ext.$profile_file_contents_end;
300
+$return_array['w8'] = $profile_file_contents . $w8_ext . $profile_file_contents_end;
301 301
 return $return_array;
302 302
 }
303 303
 
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
 /**
310 310
  * produce PEAP, TLS and TTLS configuration files for Windows 8
311 311
  */
312
-  private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) {
312
+  private function writeWLANprofile($wlan_profile_name, $ssid, $auth, $encryption, $eap_config, $i) {
313 313
 $profile_file_contents = '<?xml version="1.0"?>
314 314
 <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
315
-<name>'.$wlan_profile_name.'</name>
315
+<name>'.$wlan_profile_name . '</name>
316 316
 <SSIDConfig>
317 317
 <SSID>
318
-<name>'.$ssid.'</name>
318
+<name>'.$ssid . '</name>
319 319
 </SSID>
320 320
 <nonBroadcast>true</nonBroadcast>
321 321
 </SSIDConfig>
@@ -325,12 +325,12 @@  discard block
 block discarded – undo
325 325
 <MSM>
326 326
 <security>
327 327
 <authEncryption>
328
-<authentication>'.$auth.'</authentication>
329
-<encryption>'.$encryption.'</encryption>
328
+<authentication>'.$auth . '</authentication>
329
+<encryption>'.$encryption . '</encryption>
330 330
 <useOneX>true</useOneX>
331 331
 </authEncryption>
332 332
 ';
333
-if($auth == 'WPA2') 
333
+if ($auth == 'WPA2') 
334 334
 $profile_file_contents .= '<PMKCacheMode>enabled</PMKCacheMode> 
335 335
 <PMKCacheTTL>720</PMKCacheTTL> 
336 336
 <PMKCacheSize>128</PMKCacheSize> 
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
 </WLANProfile>
349 349
 ';
350 350
 
351
-if(! is_dir('w8'))
351
+if (!is_dir('w8'))
352 352
   mkdir('w8');
353 353
 $xml_f_name = "w8/wlan_prof-$i.xml";
354
-$xml_f = fopen($xml_f_name,'w');
355
-fwrite($xml_f,$profile_file_contents. $eap_config['w8']. $closing) ;
354
+$xml_f = fopen($xml_f_name, 'w');
355
+fwrite($xml_f, $profile_file_contents . $eap_config['w8'] . $closing);
356 356
 fclose($xml_f);
357
-debug(2,"Installer has been written into directory $this->FPATH\n");
358
-debug(4,"WWWWLAN_Profile:$wlan_profile_name:$encryption\n");
357
+debug(2, "Installer has been written into directory $this->FPATH\n");
358
+debug(4, "WWWWLAN_Profile:$wlan_profile_name:$encryption\n");
359 359
 return("\"$wlan_profile_name\" \"$encryption\"");
360 360
 }
361 361
 
@@ -375,29 +375,29 @@  discard block
 block discarded – undo
375 375
 </LANProfile>
376 376
 ';
377 377
 
378
-if(! is_dir('w8'))
378
+if (!is_dir('w8'))
379 379
   mkdir('w8');
380 380
 $xml_f_name = "w8/lan_prof.xml";
381
-$xml_f = fopen($xml_f_name,'w');
382
-fwrite($xml_f,$profile_file_contents. $eap_config['w8']. $closing) ;
381
+$xml_f = fopen($xml_f_name, 'w');
382
+fwrite($xml_f, $profile_file_contents . $eap_config['w8'] . $closing);
383 383
 fclose($xml_f);
384
-debug(2,"Installer has been written into directory $this->FPATH\n");
384
+debug(2, "Installer has been written into directory $this->FPATH\n");
385 385
 }
386 386
 
387 387
 
388 388
 
389
-private function writeMainNSH($eap,$attr) {
390
-debug(4,"writeMainNSH"); debug(4,$attr);
389
+private function writeMainNSH($eap, $attr) {
390
+debug(4, "writeMainNSH"); debug(4, $attr);
391 391
 $fcontents = "!define W8\n";
392
-if(Config::$NSIS_VERSION >= 3)
393
-    $fcontents .=  "Unicode true\n";
392
+if (Config::$NSIS_VERSION >= 3)
393
+    $fcontents .= "Unicode true\n";
394 394
 
395 395
 
396 396
 $EAP_OPTS = [
397
-PEAP=>['str'=>'PEAP','exec'=>'user'],
398
-TLS=>['str'=>'TLS','exec'=>'user'],
399
-TTLS=>['str'=>'TTLS','exec'=>'user'],
400
-PWD=>['str'=>'PWD','exec'=>'user'],
397
+PEAP=>['str'=>'PEAP', 'exec'=>'user'],
398
+TLS=>['str'=>'TLS', 'exec'=>'user'],
399
+TTLS=>['str'=>'TTLS', 'exec'=>'user'],
400
+PWD=>['str'=>'PWD', 'exec'=>'user'],
401 401
 ];
402 402
  
403 403
 // Uncomment the line below if you want this module to run under XP (only displaying a warning)
@@ -407,24 +407,24 @@  discard block
 block discarded – undo
407 407
 $exec_level = $EAP_OPTS[$eap["OUTER"]]['exec'];
408 408
 $eap_str = $EAP_OPTS[$eap["OUTER"]]['str'];
409 409
 
410
-$fcontents .= '!define '.$eap_str;
411
-$fcontents .= "\n".'!define EXECLEVEL "'.$exec_level.'"';
410
+$fcontents .= '!define ' . $eap_str;
411
+$fcontents .= "\n" . '!define EXECLEVEL "' . $exec_level . '"';
412 412
 
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).'"';
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) . '"';
415 415
 $fcontents .= '
416
-Caption "'. $this->translateString(sprintf(sprint_nsi(_("%s installer for %s")),Config::$CONSORTIUM['name'],$attr['general:instname'][0]), $this->code_page).'"
417
-!define APPLICATION "'. $this->translateString(sprintf(sprint_nsi(_("%s installer for %s")),Config::$CONSORTIUM['name'],$attr['general:instname'][0]), $this->code_page).'"
418
-!define VERSION "'.CAT::$VERSION_MAJOR.'.'.CAT::$VERSION_MINOR.'"
416
+Caption "'. $this->translateString(sprintf(sprint_nsi(_("%s installer for %s")), Config::$CONSORTIUM['name'], $attr['general:instname'][0]), $this->code_page) . '"
417
+!define APPLICATION "'. $this->translateString(sprintf(sprint_nsi(_("%s installer for %s")), Config::$CONSORTIUM['name'], $attr['general:instname'][0]), $this->code_page) . '"
418
+!define VERSION "'.CAT::$VERSION_MAJOR . '.' . CAT::$VERSION_MINOR . '"
419 419
 !define INSTALLER_NAME "installer.exe"
420
-!define LANG "'.$this->lang.'"
420
+!define LANG "'.$this->lang . '"
421 421
 ';
422 422
 $fcontents .= $this->msInfoFile($attr);
423 423
 
424 424
 $fcontents .= ';--------------------------------
425
-!define ORGANISATION "'.$this->translateString($attr['general:instname'][0], $this->code_page).'"
426
-!define SUPPORT "'. ((isset($attr['support:email'][0]) && $attr['support:email'][0] ) ? $attr['support:email'][0] : $this->translateString($this->support_email_substitute , $this->code_page)) .'"
427
-!define URL "'. ((isset($attr['support:url'][0]) && $attr['support:url'][0] ) ? $attr['support:url'][0] : $this->translateString($this->support_url_substitute, $this->code_page)) .'"
425
+!define ORGANISATION "'.$this->translateString($attr['general:instname'][0], $this->code_page) . '"
426
+!define SUPPORT "'. ((isset($attr['support:email'][0]) && $attr['support:email'][0]) ? $attr['support:email'][0] : $this->translateString($this->support_email_substitute, $this->code_page)) . '"
427
+!define URL "'. ((isset($attr['support:url'][0]) && $attr['support:url'][0]) ? $attr['support:url'][0] : $this->translateString($this->support_url_substitute, $this->code_page)) . '"
428 428
 
429 429
 !ifdef TLS
430 430
 ';
@@ -434,33 +434,33 @@  discard block
 block discarded – undo
434 434
 !endif
435 435
 ';
436 436
 
437
-if(isset($this->attributes['media:wired'][0]) && $attr['media:wired'][0] == 'on')
437
+if (isset($this->attributes['media:wired'][0]) && $attr['media:wired'][0] == 'on')
438 438
   $fcontents .= '!define WIRED
439 439
 ';
440 440
 
441
-$f = fopen('main.nsh','w');
441
+$f = fopen('main.nsh', 'w');
442 442
 fwrite($f, $fcontents);
443 443
 fclose($f);
444 444
 
445 445
 }
446 446
 
447
-private function writeProfilesNSH($P,$ca_array,$wired=0) {
448
-debug(4,"writeProfilesNSH");
449
-debug(4,$P);
447
+private function writeProfilesNSH($P, $ca_array, $wired = 0) {
448
+debug(4, "writeProfilesNSH");
449
+debug(4, $P);
450 450
 $fcontents = '';
451
-  foreach($P as $p) 
451
+  foreach ($P as $p) 
452 452
     $fcontents .= "!insertmacro define_wlan_profile $p\n";
453 453
 
454
-$f = fopen('profiles.nsh','w');
454
+$f = fopen('profiles.nsh', 'w');
455 455
 fwrite($f, $fcontents);
456 456
 fclose($f);
457 457
 
458 458
 $fcontents = '';
459
-$f = fopen('certs.nsh','w');
460
-if($ca_array) {
459
+$f = fopen('certs.nsh', 'w');
460
+if ($ca_array) {
461 461
 foreach ($ca_array as $CA) {
462 462
       $store = $CA['root'] ? "root" : "ca";
463
-      $fcontents .= '!insertmacro install_ca_cert "'.$CA['file'].'" "'.$CA['sha1'].'" "'.$store."\"\n";
463
+      $fcontents .= '!insertmacro install_ca_cert "' . $CA['file'] . '" "' . $CA['sha1'] . '" "' . $store . "\"\n";
464 464
     }
465 465
 fwrite($f, $fcontents);
466 466
 }
@@ -469,8 +469,8 @@  discard block
 block discarded – undo
469 469
 
470 470
 //private function write
471 471
 
472
-private function copyFiles ($eap) {
473
-debug(4,"copyFiles start\n");
472
+private function copyFiles($eap) {
473
+debug(4, "copyFiles start\n");
474 474
    $result;
475 475
    $result = $this->copyFile('wlan_test.exe');
476 476
    $result = $this->copyFile('check_wired.cmd');
@@ -480,16 +480,16 @@  discard block
 block discarded – undo
480 480
    $result = $this->copyFile('base64.nsh');
481 481
    $result = $result && $this->copyFile('cat32.ico');
482 482
    $result = $result && $this->copyFile('cat_150.bmp');
483
-   $this->translateFile('common.inc','common.nsh',$this->code_page);
484
-   if($eap["OUTER"] == PWD) {
485
-     $this->translateFile('pwd.inc','cat.NSI',$this->code_page);
483
+   $this->translateFile('common.inc', 'common.nsh', $this->code_page);
484
+   if ($eap["OUTER"] == PWD) {
485
+     $this->translateFile('pwd.inc', 'cat.NSI', $this->code_page);
486 486
      $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x32.msi');
487 487
      $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi');
488 488
    } else {
489
-   $this->translateFile('eap_w8.inc','cat.NSI',$this->code_page);
489
+   $this->translateFile('eap_w8.inc', 'cat.NSI', $this->code_page);
490 490
    $result = 1;
491 491
    }
492
-debug(4,"copyFiles end\n");
492
+debug(4, "copyFiles end\n");
493 493
    return($result);
494 494
 }
495 495
 
Please login to merge, or discard this patch.
Braces   +63 added lines, -42 removed lines patch added patch discarded remove patch
@@ -46,10 +46,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
devices/ms/WindowsCommon.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -21,6 +21,9 @@
 block discarded – undo
21 21
   echo preg_replace('/"/','$\"',$in);
22 22
 }
23 23
 
24
+/**
25
+ * @return string
26
+ */
24 27
 function sprint_nsi($in) {
25 28
   return preg_replace('/"/','$\"',$in);
26 29
 }
Please login to merge, or discard this patch.
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
  * @param string $in input string
19 19
  */
20 20
 function echo_nsi($in) {
21
-  echo preg_replace('/"/','$\"',$in);
21
+    echo preg_replace('/"/','$\"',$in);
22 22
 }
23 23
 
24 24
 function sprint_nsi($in) {
25
-  return preg_replace('/"/','$\"',$in);
25
+    return preg_replace('/"/','$\"',$in);
26 26
 }
27 27
 
28 28
 /**
@@ -35,39 +35,39 @@  discard block
 block discarded – undo
35 35
 
36 36
 protected function prepareInstallerLang() {
37 37
     if(isset($this->LANGS[$this->lang_index])) {
38
-      $L = $this->LANGS[$this->lang_index];
39
-      $this->lang = $L['nsis'];
40
-      $this->code_page = 'cp'.$L['cp'];
38
+        $L = $this->LANGS[$this->lang_index];
39
+        $this->lang = $L['nsis'];
40
+        $this->code_page = 'cp'.$L['cp'];
41 41
     } else {
42
-      $this->lang = 'English';
43
-      $this->code_page = 'cp1252';
42
+        $this->lang = 'English';
43
+        $this->code_page = 'cp1252';
44 44
     }
45 45
 }
46 46
 
47 47
 protected function combineLogo($Logos) {
48 48
     // maximum size to which we want to resize
49
- $max_size= 120;
49
+    $max_size= 120;
50 50
 // logo wull be shited up by this much
51
- $vshift = 20;
52
- $bg_image = new Imagick('cat_bg.bmp');
53
- $bg_image->setFormat('BMP3');
54
- $bg_image_size = $bg_image->getImageGeometry();
55
- $logo = new Imagick($Logos[0]['name']);
56
- $logo_size = $logo->getImageGeometry();
57
- $max = max($logo_size);
58
- debug(4,"Logo size: "); debug(4,$logo_size); debug(4,"max=$max\n");
51
+    $vshift = 20;
52
+    $bg_image = new Imagick('cat_bg.bmp');
53
+    $bg_image->setFormat('BMP3');
54
+    $bg_image_size = $bg_image->getImageGeometry();
55
+    $logo = new Imagick($Logos[0]['name']);
56
+    $logo_size = $logo->getImageGeometry();
57
+    $max = max($logo_size);
58
+    debug(4,"Logo size: "); debug(4,$logo_size); debug(4,"max=$max\n");
59 59
 // resize logo if necessary
60
- if($max > $max_size) {
61
-   if($max == $logo_size['width'])
62
-      $logo->scaleImage($max_size,0);
63
-   else
64
-      $logo->scaleImage(0,$max_size);
65
- }
66
- $logo_size = $logo->getImageGeometry();
67
- debug(4,"New logo size: "); debug(4,$logo_size);
60
+    if($max > $max_size) {
61
+    if($max == $logo_size['width'])
62
+        $logo->scaleImage($max_size,0);
63
+    else
64
+        $logo->scaleImage(0,$max_size);
65
+    }
66
+    $logo_size = $logo->getImageGeometry();
67
+    debug(4,"New logo size: "); debug(4,$logo_size);
68 68
 // calculate logo offsets for composition with the background
69
- $hoffset = round(($bg_image_size['width'] - $logo_size['width'])/2);
70
- $voffset = round(($bg_image_size['height'] - $logo_size['height'])/2) - $vshift;
69
+    $hoffset = round(($bg_image_size['width'] - $logo_size['width'])/2);
70
+    $voffset = round(($bg_image_size['height'] - $logo_size['height'])/2) - $vshift;
71 71
 
72 72
 //logo image is put on top of the background
73 73
 $bg_image->compositeImage($logo, $logo->getImageCompose(), $hoffset, $voffset);
@@ -77,61 +77,61 @@  discard block
 block discarded – undo
77 77
 }
78 78
 
79 79
 protected function signInstaller($attr) {
80
-   $e = $this->installerBasename.'.exe';
81
-   if($this->sign) {
82
-      $o = system($this->sign." installer.exe '$e' > /dev/null");
83
-   }
84
-   else
85
-      rename("installer.exe",$e);
86
-   return $e;
80
+    $e = $this->installerBasename.'.exe';
81
+    if($this->sign) {
82
+        $o = system($this->sign." installer.exe '$e' > /dev/null");
83
+    }
84
+    else
85
+        rename("installer.exe",$e);
86
+    return $e;
87 87
 }
88 88
 
89 89
 protected function compileNSIS() {
90
-   if(Config::$NSIS_VERSION >= 3)
91
-      $makensis = Config::$PATHS['makensis'] . " -INPUTCHARSET UTF8";
92
-   else
93
-      $makensis = Config::$PATHS['makensis']; 
94
-   $o = $makensis.' -V4 cat.NSI > nsis.log';
95
-   system($o);
96
-   debug(4,"compileNSIS:$o\n");
90
+    if(Config::$NSIS_VERSION >= 3)
91
+        $makensis = Config::$PATHS['makensis'] . " -INPUTCHARSET UTF8";
92
+    else
93
+        $makensis = Config::$PATHS['makensis']; 
94
+    $o = $makensis.' -V4 cat.NSI > nsis.log';
95
+    system($o);
96
+    debug(4,"compileNSIS:$o\n");
97 97
 }
98 98
 
99 99
 protected function msInfoFile($attr) {
100
- $out = '';
100
+    $out = '';
101 101
 if(isset($attr['support:info_file'])) {
102 102
     $out .= '!define EXTERNAL_INFO "';
103 103
 //  debug(4,"Info file type ".$attr['support:info_file'][0]['mime']."\n");
104
-  if ($attr['internal:info_file'][0]['mime'] == 'rtf')
105
-     $out = '!define LICENSE_FILE "'. $attr['internal:info_file'][0]['name'];
106
-  elseif( $attr['internal:info_file'][0]['mime'] == 'txt') {
107
-     $in_txt = file_get_contents($attr['internal:info_file'][0]['name']);
108
-     if(Config::$NSIS_VERSION >= 3)
104
+    if ($attr['internal:info_file'][0]['mime'] == 'rtf')
105
+        $out = '!define LICENSE_FILE "'. $attr['internal:info_file'][0]['name'];
106
+    elseif( $attr['internal:info_file'][0]['mime'] == 'txt') {
107
+        $in_txt = file_get_contents($attr['internal:info_file'][0]['name']);
108
+        if(Config::$NSIS_VERSION >= 3)
109 109
         $out_txt = $in_txt;
110
-     else
110
+        else
111 111
         $out_txt = iconv('UTF-8',$this->code_page.'//TRANSLIT',$in_txt);
112
-     if($out_txt) {
112
+        if($out_txt) {
113 113
         file_put_contents('info_f.txt',$out_txt);
114 114
         $out = '!define LICENSE_FILE " info_f.txt';
115
-     }
116
-  }
117
-  else
118
-     $out = '!define EXTERNAL_INFO "'. $attr['internal:info_file'][0]['name'];
115
+        }
116
+    }
117
+    else
118
+        $out = '!define EXTERNAL_INFO "'. $attr['internal:info_file'][0]['name'];
119 119
 
120
-  $out .= "\"\n";
120
+    $out .= "\"\n";
121 121
 }
122
- debug(4,"Info file returned: $out");
123
-  return $out;
122
+    debug(4,"Info file returned: $out");
123
+    return $out;
124 124
 }
125 125
 
126 126
 
127 127
 protected function writeAdditionalDeletes($P) {
128
-  if(count($P) == 0 )
128
+    if(count($P) == 0 )
129 129
     return;
130
-  $f = fopen('profiles.nsh','a');
131
-  fwrite($f,"!define AdditionalDeletes\n");
132
-  foreach ($P as $p)
130
+    $f = fopen('profiles.nsh','a');
131
+    fwrite($f,"!define AdditionalDeletes\n");
132
+    foreach ($P as $p)
133 133
     fwrite($f,"!insertmacro define_delete_profile \"$p\"\n");
134
-  fclose($f);
134
+    fclose($f);
135 135
 }
136 136
 
137 137
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 'af'=>['nsis'=>"Afrikaans",'cp'=>'1252'],
182 182
 'ast'=>['nsis'=>"Asturian",'cp'=>'1252'],
183 183
 
184
-  ];
184
+    ];
185 185
 
186 186
 public $code_page;
187 187
 public $lang;
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
  * @param string $in input string
19 19
  */
20 20
 function echo_nsi($in) {
21
-  echo preg_replace('/"/','$\"',$in);
21
+  echo preg_replace('/"/', '$\"', $in);
22 22
 }
23 23
 
24 24
 function sprint_nsi($in) {
25
-  return preg_replace('/"/','$\"',$in);
25
+  return preg_replace('/"/', '$\"', $in);
26 26
 }
27 27
 
28 28
 /**
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
 class WindowsCommon extends DeviceConfig {
35 35
 
36 36
 protected function prepareInstallerLang() {
37
-    if(isset($this->LANGS[$this->lang_index])) {
37
+    if (isset($this->LANGS[$this->lang_index])) {
38 38
       $L = $this->LANGS[$this->lang_index];
39 39
       $this->lang = $L['nsis'];
40
-      $this->code_page = 'cp'.$L['cp'];
40
+      $this->code_page = 'cp' . $L['cp'];
41 41
     } else {
42 42
       $this->lang = 'English';
43 43
       $this->code_page = 'cp1252';
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
 protected function combineLogo($Logos) {
48 48
     // maximum size to which we want to resize
49
- $max_size= 120;
49
+ $max_size = 120;
50 50
 // logo wull be shited up by this much
51 51
  $vshift = 20;
52 52
  $bg_image = new Imagick('cat_bg.bmp');
@@ -55,19 +55,19 @@  discard block
 block discarded – undo
55 55
  $logo = new Imagick($Logos[0]['name']);
56 56
  $logo_size = $logo->getImageGeometry();
57 57
  $max = max($logo_size);
58
- debug(4,"Logo size: "); debug(4,$logo_size); debug(4,"max=$max\n");
58
+ debug(4, "Logo size: "); debug(4, $logo_size); debug(4, "max=$max\n");
59 59
 // resize logo if necessary
60
- if($max > $max_size) {
61
-   if($max == $logo_size['width'])
62
-      $logo->scaleImage($max_size,0);
60
+ if ($max > $max_size) {
61
+   if ($max == $logo_size['width'])
62
+      $logo->scaleImage($max_size, 0);
63 63
    else
64
-      $logo->scaleImage(0,$max_size);
64
+      $logo->scaleImage(0, $max_size);
65 65
  }
66 66
  $logo_size = $logo->getImageGeometry();
67
- debug(4,"New logo size: "); debug(4,$logo_size);
67
+ debug(4, "New logo size: "); debug(4, $logo_size);
68 68
 // calculate logo offsets for composition with the background
69
- $hoffset = round(($bg_image_size['width'] - $logo_size['width'])/2);
70
- $voffset = round(($bg_image_size['height'] - $logo_size['height'])/2) - $vshift;
69
+ $hoffset = round(($bg_image_size['width'] - $logo_size['width']) / 2);
70
+ $voffset = round(($bg_image_size['height'] - $logo_size['height']) / 2) - $vshift;
71 71
 
72 72
 //logo image is put on top of the background
73 73
 $bg_image->compositeImage($logo, $logo->getImageCompose(), $hoffset, $voffset);
@@ -77,109 +77,109 @@  discard block
 block discarded – undo
77 77
 }
78 78
 
79 79
 protected function signInstaller($attr) {
80
-   $e = $this->installerBasename.'.exe';
81
-   if($this->sign) {
82
-      $o = system($this->sign." installer.exe '$e' > /dev/null");
80
+   $e = $this->installerBasename . '.exe';
81
+   if ($this->sign) {
82
+      $o = system($this->sign . " installer.exe '$e' > /dev/null");
83 83
    }
84 84
    else
85
-      rename("installer.exe",$e);
85
+      rename("installer.exe", $e);
86 86
    return $e;
87 87
 }
88 88
 
89 89
 protected function compileNSIS() {
90
-   if(Config::$NSIS_VERSION >= 3)
90
+   if (Config::$NSIS_VERSION >= 3)
91 91
       $makensis = Config::$PATHS['makensis'] . " -INPUTCHARSET UTF8";
92 92
    else
93 93
       $makensis = Config::$PATHS['makensis']; 
94
-   $o = $makensis.' -V4 cat.NSI > nsis.log';
94
+   $o = $makensis . ' -V4 cat.NSI > nsis.log';
95 95
    system($o);
96
-   debug(4,"compileNSIS:$o\n");
96
+   debug(4, "compileNSIS:$o\n");
97 97
 }
98 98
 
99 99
 protected function msInfoFile($attr) {
100 100
  $out = '';
101
-if(isset($attr['support:info_file'])) {
101
+if (isset($attr['support:info_file'])) {
102 102
     $out .= '!define EXTERNAL_INFO "';
103 103
 //  debug(4,"Info file type ".$attr['support:info_file'][0]['mime']."\n");
104 104
   if ($attr['internal:info_file'][0]['mime'] == 'rtf')
105
-     $out = '!define LICENSE_FILE "'. $attr['internal:info_file'][0]['name'];
106
-  elseif( $attr['internal:info_file'][0]['mime'] == 'txt') {
105
+     $out = '!define LICENSE_FILE "' . $attr['internal:info_file'][0]['name'];
106
+  elseif ($attr['internal:info_file'][0]['mime'] == 'txt') {
107 107
      $in_txt = file_get_contents($attr['internal:info_file'][0]['name']);
108
-     if(Config::$NSIS_VERSION >= 3)
108
+     if (Config::$NSIS_VERSION >= 3)
109 109
         $out_txt = $in_txt;
110 110
      else
111
-        $out_txt = iconv('UTF-8',$this->code_page.'//TRANSLIT',$in_txt);
112
-     if($out_txt) {
113
-        file_put_contents('info_f.txt',$out_txt);
111
+        $out_txt = iconv('UTF-8', $this->code_page . '//TRANSLIT', $in_txt);
112
+     if ($out_txt) {
113
+        file_put_contents('info_f.txt', $out_txt);
114 114
         $out = '!define LICENSE_FILE " info_f.txt';
115 115
      }
116 116
   }
117 117
   else
118
-     $out = '!define EXTERNAL_INFO "'. $attr['internal:info_file'][0]['name'];
118
+     $out = '!define EXTERNAL_INFO "' . $attr['internal:info_file'][0]['name'];
119 119
 
120 120
   $out .= "\"\n";
121 121
 }
122
- debug(4,"Info file returned: $out");
122
+ debug(4, "Info file returned: $out");
123 123
   return $out;
124 124
 }
125 125
 
126 126
 
127 127
 protected function writeAdditionalDeletes($P) {
128
-  if(count($P) == 0 )
128
+  if (count($P) == 0)
129 129
     return;
130
-  $f = fopen('profiles.nsh','a');
131
-  fwrite($f,"!define AdditionalDeletes\n");
130
+  $f = fopen('profiles.nsh', 'a');
131
+  fwrite($f, "!define AdditionalDeletes\n");
132 132
   foreach ($P as $p)
133
-    fwrite($f,"!insertmacro define_delete_profile \"$p\"\n");
133
+    fwrite($f, "!insertmacro define_delete_profile \"$p\"\n");
134 134
   fclose($f);
135 135
 }
136 136
 
137 137
 
138
-public $LANGS=[
139
-'fr'=>['nsis'=>"French",'cp'=>'1252'],
140
-'de'=>['nsis'=>"German",'cp'=>'1252'],
141
-'es'=>['nsis'=>"SpanishInternational",'cp'=>'1252'],
142
-'it'=>['nsis'=>"Italian",'cp'=>'1252'],
143
-'nl'=>['nsis'=>"Dutch",'cp'=>'1252'],
144
-'sv'=>['nsis'=>"Swedish",'cp'=>'1252'],
145
-'fi'=>['nsis'=>"Finnish",'cp'=>'1252'],
146
-'pl'=>['nsis'=>"Polish",'cp'=>'1250'],
147
-'ca'=>['nsis'=>"Catalan",'cp'=>'1252'],
148
-'sr'=>['nsis'=>"SerbianLatin",'cp'=>'1250'],
149
-'hr'=>['nsis'=>"Croatian",'cp'=>'1250'],
150
-'sl'=>['nsis'=>"Slovenian",'cp'=>'1250'],
151
-'da'=>['nsis'=>"Danish",'cp'=>'1252'],
152
-'nb'=>['nsis'=>"Norwegian",'cp'=>'1252'],
153
-'nn'=>['nsis'=>"NorwegianNynorsk",'cp'=>'1252'],
154
-'el'=>['nsis'=>"Greek",'cp'=>'1253'],
155
-'ru'=>['nsis'=>"Russian",'cp'=>'1251'],
156
-'pt'=>['nsis'=>"Portuguese",'cp'=>'1252'],
157
-'uk'=>['nsis'=>"Ukrainian",'cp'=>'1251'],
158
-'cs'=>['nsis'=>"Czech",'cp'=>'1250'],
159
-'sk'=>['nsis'=>"Slovak",'cp'=>'1250'],
160
-'bg'=>['nsis'=>"Bulgarian",'cp'=>'1251'],
161
-'hu'=>['nsis'=>"Hungarian",'cp'=>'1250'],
162
-'ro'=>['nsis'=>"Romanian",'cp'=>'1250'],
163
-'lv'=>['nsis'=>"Latvian",'cp'=>'1257'],
164
-'mk'=>['nsis'=>"Macedonian",'cp'=>'1251'],
165
-'et'=>['nsis'=>"Estonian",'cp'=>'1257'],
166
-'tr'=>['nsis'=>"Turkish",'cp'=>'1254'],
167
-'lt'=>['nsis'=>"Lithuanian",'cp'=>'1257'],
168
-'ar'=>['nsis'=>"Arabic",'cp'=>'1256'],
169
-'he'=>['nsis'=>"Hebrew",'cp'=>'1255'],
170
-'id'=>['nsis'=>"Indonesian",'cp'=>'1252'],
171
-'mn'=>['nsis'=>"Mongolian",'cp'=>'1251'],
172
-'sq'=>['nsis'=>"Albanian",'cp'=>'1252'],
173
-'br'=>['nsis'=>"Breton",'cp'=>'1252'],
174
-'be'=>['nsis'=>"Belarusian",'cp'=>'1251'],
175
-'is'=>['nsis'=>"Icelandic",'cp'=>'1252'],
176
-'ms'=>['nsis'=>"Malay",'cp'=>'1252'],
177
-'bs'=>['nsis'=>"Bosnian",'cp'=>'1250'],
178
-'ga'=>['nsis'=>"Irish",'cp'=>'1250'],
179
-'uz'=>['nsis'=>"Uzbek",'cp'=>'1251'],
180
-'gl'=>['nsis'=>"Galician",'cp'=>'1252'],
181
-'af'=>['nsis'=>"Afrikaans",'cp'=>'1252'],
182
-'ast'=>['nsis'=>"Asturian",'cp'=>'1252'],
138
+public $LANGS = [
139
+'fr'=>['nsis'=>"French", 'cp'=>'1252'],
140
+'de'=>['nsis'=>"German", 'cp'=>'1252'],
141
+'es'=>['nsis'=>"SpanishInternational", 'cp'=>'1252'],
142
+'it'=>['nsis'=>"Italian", 'cp'=>'1252'],
143
+'nl'=>['nsis'=>"Dutch", 'cp'=>'1252'],
144
+'sv'=>['nsis'=>"Swedish", 'cp'=>'1252'],
145
+'fi'=>['nsis'=>"Finnish", 'cp'=>'1252'],
146
+'pl'=>['nsis'=>"Polish", 'cp'=>'1250'],
147
+'ca'=>['nsis'=>"Catalan", 'cp'=>'1252'],
148
+'sr'=>['nsis'=>"SerbianLatin", 'cp'=>'1250'],
149
+'hr'=>['nsis'=>"Croatian", 'cp'=>'1250'],
150
+'sl'=>['nsis'=>"Slovenian", 'cp'=>'1250'],
151
+'da'=>['nsis'=>"Danish", 'cp'=>'1252'],
152
+'nb'=>['nsis'=>"Norwegian", 'cp'=>'1252'],
153
+'nn'=>['nsis'=>"NorwegianNynorsk", 'cp'=>'1252'],
154
+'el'=>['nsis'=>"Greek", 'cp'=>'1253'],
155
+'ru'=>['nsis'=>"Russian", 'cp'=>'1251'],
156
+'pt'=>['nsis'=>"Portuguese", 'cp'=>'1252'],
157
+'uk'=>['nsis'=>"Ukrainian", 'cp'=>'1251'],
158
+'cs'=>['nsis'=>"Czech", 'cp'=>'1250'],
159
+'sk'=>['nsis'=>"Slovak", 'cp'=>'1250'],
160
+'bg'=>['nsis'=>"Bulgarian", 'cp'=>'1251'],
161
+'hu'=>['nsis'=>"Hungarian", 'cp'=>'1250'],
162
+'ro'=>['nsis'=>"Romanian", 'cp'=>'1250'],
163
+'lv'=>['nsis'=>"Latvian", 'cp'=>'1257'],
164
+'mk'=>['nsis'=>"Macedonian", 'cp'=>'1251'],
165
+'et'=>['nsis'=>"Estonian", 'cp'=>'1257'],
166
+'tr'=>['nsis'=>"Turkish", 'cp'=>'1254'],
167
+'lt'=>['nsis'=>"Lithuanian", 'cp'=>'1257'],
168
+'ar'=>['nsis'=>"Arabic", 'cp'=>'1256'],
169
+'he'=>['nsis'=>"Hebrew", 'cp'=>'1255'],
170
+'id'=>['nsis'=>"Indonesian", 'cp'=>'1252'],
171
+'mn'=>['nsis'=>"Mongolian", 'cp'=>'1251'],
172
+'sq'=>['nsis'=>"Albanian", 'cp'=>'1252'],
173
+'br'=>['nsis'=>"Breton", 'cp'=>'1252'],
174
+'be'=>['nsis'=>"Belarusian", 'cp'=>'1251'],
175
+'is'=>['nsis'=>"Icelandic", 'cp'=>'1252'],
176
+'ms'=>['nsis'=>"Malay", 'cp'=>'1252'],
177
+'bs'=>['nsis'=>"Bosnian", 'cp'=>'1250'],
178
+'ga'=>['nsis'=>"Irish", 'cp'=>'1250'],
179
+'uz'=>['nsis'=>"Uzbek", 'cp'=>'1251'],
180
+'gl'=>['nsis'=>"Galician", 'cp'=>'1252'],
181
+'af'=>['nsis'=>"Afrikaans", 'cp'=>'1252'],
182
+'ast'=>['nsis'=>"Asturian", 'cp'=>'1252'],
183 183
 
184 184
   ];
185 185
 
Please login to merge, or discard this patch.
Braces   +28 added lines, -23 removed lines patch added patch discarded remove patch
@@ -58,10 +58,11 @@  discard block
 block discarded – undo
58 58
  debug(4,"Logo size: "); debug(4,$logo_size); debug(4,"max=$max\n");
59 59
 // resize logo if necessary
60 60
  if($max > $max_size) {
61
-   if($max == $logo_size['width'])
62
-      $logo->scaleImage($max_size,0);
63
-   else
64
-      $logo->scaleImage(0,$max_size);
61
+   if($max == $logo_size['width']) {
62
+         $logo->scaleImage($max_size,0);
63
+   } else {
64
+         $logo->scaleImage(0,$max_size);
65
+   }
65 66
  }
66 67
  $logo_size = $logo->getImageGeometry();
67 68
  debug(4,"New logo size: "); debug(4,$logo_size);
@@ -80,17 +81,18 @@  discard block
 block discarded – undo
80 81
    $e = $this->installerBasename.'.exe';
81 82
    if($this->sign) {
82 83
       $o = system($this->sign." installer.exe '$e' > /dev/null");
84
+   } else {
85
+         rename("installer.exe",$e);
83 86
    }
84
-   else
85
-      rename("installer.exe",$e);
86 87
    return $e;
87 88
 }
88 89
 
89 90
 protected function compileNSIS() {
90
-   if(Config::$NSIS_VERSION >= 3)
91
-      $makensis = Config::$PATHS['makensis'] . " -INPUTCHARSET UTF8";
92
-   else
93
-      $makensis = Config::$PATHS['makensis']; 
91
+   if(Config::$NSIS_VERSION >= 3) {
92
+         $makensis = Config::$PATHS['makensis'] . " -INPUTCHARSET UTF8";
93
+   } else {
94
+         $makensis = Config::$PATHS['makensis'];
95
+   }
94 96
    $o = $makensis.' -V4 cat.NSI > nsis.log';
95 97
    system($o);
96 98
    debug(4,"compileNSIS:$o\n");
@@ -101,21 +103,22 @@  discard block
 block discarded – undo
101 103
 if(isset($attr['support:info_file'])) {
102 104
     $out .= '!define EXTERNAL_INFO "';
103 105
 //  debug(4,"Info file type ".$attr['support:info_file'][0]['mime']."\n");
104
-  if ($attr['internal:info_file'][0]['mime'] == 'rtf')
105
-     $out = '!define LICENSE_FILE "'. $attr['internal:info_file'][0]['name'];
106
-  elseif( $attr['internal:info_file'][0]['mime'] == 'txt') {
106
+  if ($attr['internal:info_file'][0]['mime'] == 'rtf') {
107
+       $out = '!define LICENSE_FILE "'. $attr['internal:info_file'][0]['name'];
108
+  } elseif( $attr['internal:info_file'][0]['mime'] == 'txt') {
107 109
      $in_txt = file_get_contents($attr['internal:info_file'][0]['name']);
108
-     if(Config::$NSIS_VERSION >= 3)
109
-        $out_txt = $in_txt;
110
-     else
111
-        $out_txt = iconv('UTF-8',$this->code_page.'//TRANSLIT',$in_txt);
110
+     if(Config::$NSIS_VERSION >= 3) {
111
+             $out_txt = $in_txt;
112
+     } else {
113
+             $out_txt = iconv('UTF-8',$this->code_page.'//TRANSLIT',$in_txt);
114
+     }
112 115
      if($out_txt) {
113 116
         file_put_contents('info_f.txt',$out_txt);
114 117
         $out = '!define LICENSE_FILE " info_f.txt';
115 118
      }
119
+  } else {
120
+       $out = '!define EXTERNAL_INFO "'. $attr['internal:info_file'][0]['name'];
116 121
   }
117
-  else
118
-     $out = '!define EXTERNAL_INFO "'. $attr['internal:info_file'][0]['name'];
119 122
 
120 123
   $out .= "\"\n";
121 124
 }
@@ -125,12 +128,14 @@  discard block
 block discarded – undo
125 128
 
126 129
 
127 130
 protected function writeAdditionalDeletes($P) {
128
-  if(count($P) == 0 )
129
-    return;
131
+  if(count($P) == 0 ) {
132
+      return;
133
+  }
130 134
   $f = fopen('profiles.nsh','a');
131 135
   fwrite($f,"!define AdditionalDeletes\n");
132
-  foreach ($P as $p)
133
-    fwrite($f,"!insertmacro define_delete_profile \"$p\"\n");
136
+  foreach ($P as $p) {
137
+      fwrite($f,"!insertmacro define_delete_profile \"$p\"\n");
138
+  }
134 139
   fclose($f);
135 140
 }
136 141
 
Please login to merge, or discard this patch.