Completed
Pull Request — master (#14)
by Janusz
10:08 queued 04:29
created
core/SanityTests.php 1 patch
Indentation   +301 added lines, -301 removed lines patch added patch discarded remove patch
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
 
46 46
 /* List all required NSIS modules below */
47 47
     private $NSIS_Modules = [
48
-             "nsArray.nsh",
49
-             "FileFunc.nsh",
50
-             "LogicLib.nsh",
51
-             "WordFunc.nsh",
52
-             "FileFunc.nsh",
53
-             "x64.nsh",
54
-         ];
48
+                "nsArray.nsh",
49
+                "FileFunc.nsh",
50
+                "LogicLib.nsh",
51
+                "WordFunc.nsh",
52
+                "FileFunc.nsh",
53
+                "x64.nsh",
54
+            ];
55 55
 
56 56
 /* set $profile_option_ct to the number of rows returned by "SELECT * FROM profile_option_dict" */
57 57
     private $profile_option_ct = 28;
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
     public $name;
65 65
 
66 66
     public function __construct() {
67
-       parent::__construct();
68
-       $this->test_result = [];
69
-       $this->test_result['global'] = 0;
67
+        parent::__construct();
68
+        $this->test_result = [];
69
+        $this->test_result['global'] = 0;
70 70
     }
71 71
 
72 72
     /**
@@ -74,15 +74,15 @@  discard block
 block discarded – undo
74 74
      * @param string $test the test name
75 75
      */
76 76
     public function test($test) {
77
-       $this->out[$test] =[];
78
-       $this->name = $test;
79
-       $m_name = $test.'_test';
80
-       $this->test_result[$test] = 0;
81
-       if(! method_exists($this,$m_name)) {
82
-           $this->test_return($test,L_ERROR,"Configuration error, no test configured for <strong>$test</strong>.");
83
-           return;
84
-       }
85
-       $this->$m_name();
77
+        $this->out[$test] =[];
78
+        $this->name = $test;
79
+        $m_name = $test.'_test';
80
+        $this->test_result[$test] = 0;
81
+        if(! method_exists($this,$m_name)) {
82
+            $this->test_return($test,L_ERROR,"Configuration error, no test configured for <strong>$test</strong>.");
83
+            return;
84
+        }
85
+        $this->$m_name();
86 86
     }
87 87
 
88 88
     /**
@@ -95,27 +95,27 @@  discard block
 block discarded – undo
95 95
      * and returned a success.
96 96
      */
97 97
     public function run_tests($Tests) {
98
-       foreach ($Tests as $t) {
99
-         if(preg_match('/(.+)=>(.+)/',$t,$m)) {
98
+        foreach ($Tests as $t) {
99
+            if(preg_match('/(.+)=>(.+)/',$t,$m)) {
100 100
             $tst = $m[1];
101 101
             $subtst=$m[2];
102 102
             if($this->test_result[$tst]  < L_ERROR)
103
-               $this->test($subtst);
104
-         }
105
-         else
103
+                $this->test($subtst);
104
+            }
105
+            else
106 106
             $this->test($t);
107
-       }
107
+        }
108 108
     }
109 109
 
110 110
     public function get_test_names() {
111
-       $T = get_class_methods($this);
112
-       $out = [];
113
-       foreach($T as $t) {
114
-         if(preg_match('/^(.*)_test$/',$t,$m)) {
111
+        $T = get_class_methods($this);
112
+        $out = [];
113
+        foreach($T as $t) {
114
+            if(preg_match('/^(.*)_test$/',$t,$m)) {
115 115
             $out[] = $m[1];
116
-         } 
117
-       }
118
-       return $out;
116
+            } 
117
+        }
118
+        return $out;
119 119
     }
120 120
 
121 121
     /**
@@ -141,84 +141,84 @@  discard block
 block discarded – undo
141 141
         $the_path = "";
142 142
         $exec_is = "UNDEFINED";
143 143
         if (!empty(Config::$PATHS[$s])) {
144
-             preg_match('/([^ ]+) ?/',Config::$PATHS[$s],$m);
145
-             $exe = $m[1];
146
-             $the_path = exec("which " . Config::$PATHS[$s]);
147
-             if ($the_path == $exe)
148
-                 $exec_is = "EXPLICIT";
149
-             else
150
-                 $exec_is = "IMPLICIT";
151
-         } 
144
+                preg_match('/([^ ]+) ?/',Config::$PATHS[$s],$m);
145
+                $exe = $m[1];
146
+                $the_path = exec("which " . Config::$PATHS[$s]);
147
+                if ($the_path == $exe)
148
+                    $exec_is = "EXPLICIT";
149
+                else
150
+                    $exec_is = "IMPLICIT";
151
+            } 
152 152
         return(['exec'=>$the_path,'exec_is'=>$exec_is]);
153 153
     }
154 154
 
155 155
     /**
156
-      *  Test for php version
157
-      */
156
+     *  Test for php version
157
+     */
158 158
     private function php_test() {
159
-         if (version_compare(phpversion(), $this->php_needversion, '>='))
159
+            if (version_compare(phpversion(), $this->php_needversion, '>='))
160 160
             $this->test_return(L_OK,"<strong>PHP</strong> is sufficiently recent. You are running " . phpversion() . ".");
161
-         else
161
+            else
162 162
             $this->test_return(L_ERROR,"<strong>PHP</strong> is too old. We need at least $this->php_needversion, but you only have ".phpversion(). ".");
163 163
     }
164 164
 
165 165
     /**
166
-      * test for simpleSAMLphp
167
-      */
166
+     * test for simpleSAMLphp
167
+     */
168 168
     private function ssp_test() {
169
-         if (!is_file(CONFIG::$AUTHENTICATION['ssp-path-to-autoloader']))
170
-             $this->test_return(L_ERROR,"<strong>simpleSAMLphp</strong> not found!");
171
-         else
172
-             $this->test_return(L_OK,"<strong>simpleSAMLphp</strong> autoloader found.");
169
+            if (!is_file(CONFIG::$AUTHENTICATION['ssp-path-to-autoloader']))
170
+                $this->test_return(L_ERROR,"<strong>simpleSAMLphp</strong> not found!");
171
+            else
172
+                $this->test_return(L_OK,"<strong>simpleSAMLphp</strong> autoloader found.");
173 173
     }
174 174
 
175 175
     /**
176
-      * test for security setting
177
-      */
176
+     * test for security setting
177
+     */
178 178
     private function security_test() {
179
-         if (in_array("I do not care about security!", Config::$SUPERADMINS))
180
-             $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'!");
179
+            if (in_array("I do not care about security!", Config::$SUPERADMINS))
180
+                $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 181
     }
182 182
 
183 183
     /**
184
-      * test if zip is available
185
-      */
184
+     * test if zip is available
185
+     */
186 186
     private function zip_test() {
187
-         if (exec("which zip") != "")
188
-             $this->test_return(L_OK,"<strong>zip</strong> binary found.");
189
-         else
190
-             $this->test_return(L_ERROR,"<strong>zip</strong> not found in your \$PATH!");
187
+            if (exec("which zip") != "")
188
+                $this->test_return(L_OK,"<strong>zip</strong> binary found.");
189
+            else
190
+                $this->test_return(L_ERROR,"<strong>zip</strong> not found in your \$PATH!");
191 191
     }
192 192
 
193 193
     /**
194
-      * test if eapol_test is availabe and reacent enough
195
-      */
194
+     * test if eapol_test is availabe and reacent enough
195
+     */
196 196
     private function eapol_test_test() {
197
-         exec(Config::$PATHS['eapol_test'], $out, $retval);
198
-         if($retval == 255 ) {
197
+            exec(Config::$PATHS['eapol_test'], $out, $retval);
198
+            if($retval == 255 ) {
199 199
             $o = preg_grep('/-o<server cert/',$out);
200
-               if(count($o) > 0)
201
-                   $this->test_return(L_OK,"<strong>eapol_test</strong> script found.");
202
-               else
203
-                   $this->test_return(L_ERROR,"<strong>eapol_test</strong> found, but is too old!");
204
-         }
205
-         else
200
+                if(count($o) > 0)
201
+                    $this->test_return(L_OK,"<strong>eapol_test</strong> script found.");
202
+                else
203
+                    $this->test_return(L_ERROR,"<strong>eapol_test</strong> found, but is too old!");
204
+            }
205
+            else
206 206
             $this->test_return(L_ERROR,"<strong>eapol_test</strong> not found!");
207 207
     }
208 208
 
209 209
     /**
210
-      * test if logdir exists and is writable
211
-      */
210
+     * test if logdir exists and is writable
211
+     */
212 212
     private function logdir_test() {
213
-         if (fopen(Config::$PATHS['logdir'] . "/debug.log", "a") == FALSE)
214
-             $this->test_return(L_WARN,"Log files in <strong>" . Config::$PATHS['logdir'] . "</strong> are not writable!");
215
-         else
216
-             $this->test_return(L_OK,"Log directory is writable.");
213
+            if (fopen(Config::$PATHS['logdir'] . "/debug.log", "a") == FALSE)
214
+                $this->test_return(L_WARN,"Log files in <strong>" . Config::$PATHS['logdir'] . "</strong> are not writable!");
215
+            else
216
+                $this->test_return(L_OK,"Log directory is writable.");
217 217
     }
218 218
 
219 219
     /**
220
-      * test for required PHP modules
221
-      */
220
+     * test for required PHP modules
221
+     */
222 222
     private function phpModules_test() {
223 223
         if (function_exists('idn_to_ascii'))
224 224
             $this->test_return(L_OK,"PHP can handle internationalisation.");
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
         if (function_exists('gettext'))
229 229
             $this->test_return(L_OK,"PHP extension <strong>GNU Gettext</strong> is installed.");
230 230
         else
231
-           $this->test_return(L_ERROR,"PHP extension <strong>GNU Gettext</strong> not found!");
231
+            $this->test_return(L_ERROR,"PHP extension <strong>GNU Gettext</strong> not found!");
232 232
 
233 233
         if (function_exists('openssl_sign'))
234 234
             $this->test_return(L_OK,"PHP extension <strong>OpenSSL</strong> is installed.");
@@ -270,193 +270,193 @@  discard block
 block discarded – undo
270 270
      */
271 271
 
272 272
     private function geoip_test() {
273
-       $host_4 = '145.0.2.50';
274
-       $host_6 = '2001:610:188:444::50';
275
-       switch (Config::$GEOIP['version']) {
276
-           case 0:
273
+        $host_4 = '145.0.2.50';
274
+        $host_6 = '2001:610:188:444::50';
275
+        switch (Config::$GEOIP['version']) {
276
+            case 0:
277 277
               $this->test_return(L_REMARK,"As set in the config, no geolocation service will be used");
278
-              break;
279
-           case 1:
278
+                break;
279
+            case 1:
280 280
               if (!function_exists('geoip_record_by_name')) {
281
-                  $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
-                  return;
283
-              }
284
-              $record = geoip_record_by_name($host_4);
285
-              if(! $record) {
286
-                 $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.");
287
-                 return;
288
-              }
289
-              if($record['city'] != 'Utrecht') {
290
-                 $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.");
291
-                 return;
292
-              }
293
-              $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
-              break;
295
-           case 2:
281
+                    $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
+                    return;
283
+                }
284
+                $record = geoip_record_by_name($host_4);
285
+                if(! $record) {
286
+                    $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.");
287
+                    return;
288
+                }
289
+                if($record['city'] != 'Utrecht') {
290
+                    $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.");
291
+                    return;
292
+                }
293
+                $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
+                break;
295
+            case 2:
296 296
               if(! is_file(Config::$GEOIP['geoip2-path-to-autoloader'])) {
297
-                 $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>.");
298
-                 return;
299
-              }
300
-              if(! is_file(Config::$GEOIP['geoip2-path-to-db'])) {
301
-                 $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.");
302
-                 return;
303
-              }
304
-              require_once Config::$GEOIP['geoip2-path-to-autoloader'];
305
-              $reader = new Reader(Config::$GEOIP['geoip2-path-to-db']);
306
-              try {
307
-                 $record = $reader->city($host_4);
308
-              } catch (Exception $e) {
309
-                 $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
-                 return;
311
-              }
312
-              if( $record->city->name != 'Utrecht') {
313
-                 $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.");
314
-                 return;
315
-              }
316
-              try {
317
-                 $record = $reader->city($host_6);
318
-              } catch (Exception $e) {
319
-                 $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
-                 return;
321
-              }
322
-              if( $record->city->name != 'Utrecht') {
323
-                 $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.");
324
-                 return;
325
-              }
326
-              $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
-              break;
328
-           default:
297
+                    $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>.");
298
+                    return;
299
+                }
300
+                if(! is_file(Config::$GEOIP['geoip2-path-to-db'])) {
301
+                    $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.");
302
+                    return;
303
+                }
304
+                require_once Config::$GEOIP['geoip2-path-to-autoloader'];
305
+                $reader = new Reader(Config::$GEOIP['geoip2-path-to-db']);
306
+                try {
307
+                    $record = $reader->city($host_4);
308
+                } catch (Exception $e) {
309
+                    $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
+                    return;
311
+                }
312
+                if( $record->city->name != 'Utrecht') {
313
+                    $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.");
314
+                    return;
315
+                }
316
+                try {
317
+                    $record = $reader->city($host_6);
318
+                } catch (Exception $e) {
319
+                    $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
+                    return;
321
+                }
322
+                if( $record->city->name != 'Utrecht') {
323
+                    $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.");
324
+                    return;
325
+                }
326
+                $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
+                break;
328
+            default:
329 329
               $this->test_return(L_ERROR,'Check Config::$GEOIP[\'version\'], it must be set to either 1 or 2');
330
-              break;
331
-       }
330
+                break;
331
+        }
332 332
     }
333 333
 
334 334
     /**
335
-      * test if openssl is available
336
-      */
335
+     * test if openssl is available
336
+     */
337 337
     private function openssl_test() {
338
-         $A = $this->get_exec_path('openssl');    
339
-         if($A['exec'] != "") {
340
-             $t = exec($A['exec'] . ' version');
341
-             if($A['exec_is'] == "EXPLICIT")
338
+            $A = $this->get_exec_path('openssl');    
339
+            if($A['exec'] != "") {
340
+                $t = exec($A['exec'] . ' version');
341
+                if($A['exec_is'] == "EXPLICIT")
342 342
                 $this->test_return(L_OK,"<strong>$t</strong> was found and is configured explicitly in your config.");
343
-             else
343
+                else
344 344
                 $this->test_return(L_WARN,"<strong>$t</strong> was found, but is not configured with an absolute path in your config.");
345
-         } else
345
+            } else
346 346
             $this->test_return(L_ERROR,"<strong>openssl</strong> was not found on your system!");
347 347
     }
348 348
 
349 349
     /**
350
-      * test if makensis is available
351
-      */
350
+     * test if makensis is available
351
+     */
352 352
     private function makensis_test() {
353
-         if(! is_numeric(Config::$NSIS_VERSION)) {
353
+            if(! is_numeric(Config::$NSIS_VERSION)) {
354 354
             $this->test_return(L_ERROR,"NSIS_VERSION needs to be numeric!");
355 355
             return;
356
-         }
357
-         if(Config::$NSIS_VERSION < 2) {
356
+            }
357
+            if(Config::$NSIS_VERSION < 2) {
358 358
             $this->test_return(L_ERROR,"NSIS_VERSION needs to be at least 2!");
359 359
             return;
360
-         }
361
-         $A = $this->get_exec_path('makensis');    
362
-         if($A['exec'] != "") {
363
-             $t = exec($A['exec'] . ' -VERSION');
364
-             if($A['exec_is'] == "EXPLICIT") 
360
+            }
361
+            $A = $this->get_exec_path('makensis');    
362
+            if($A['exec'] != "") {
363
+                $t = exec($A['exec'] . ' -VERSION');
364
+                if($A['exec_is'] == "EXPLICIT") 
365 365
                 $this->test_return(L_OK,"<strong>makensis $t</strong> was found and is configured explicitly in your config.");
366
-             else
366
+                else
367 367
                 $this->test_return(L_WARN,"<strong>makensis $t</strong> was found, but is not configured with an absolute path in your config.");
368
-             exec($A['exec'] . ' -HELP',$t);
369
-             $t1 = count(preg_grep('/INPUTCHARSET/',$t));
370
-             if($t1 == 1 && Config::$NSIS_VERSION == 2)
368
+                exec($A['exec'] . ' -HELP',$t);
369
+                $t1 = count(preg_grep('/INPUTCHARSET/',$t));
370
+                if($t1 == 1 && Config::$NSIS_VERSION == 2)
371 371
                 $this->test_return(L_ERROR,"Declared NSIS_VERSION does not seem to match the file pointed to by PATHS['makensis']!");
372
-             if($t1 == 0 && Config::$NSIS_VERSION >= 3)
372
+                if($t1 == 0 && Config::$NSIS_VERSION >= 3)
373 373
                 $this->test_return(L_ERROR,"Declared NSIS_VERSION does not seem to match the file pointed to by PATHS['makensis']!");
374
-         } else
374
+            } else
375 375
             $this->test_return(L_ERROR,"<strong>makensis</strong> was not found on your system!");
376 376
     }
377 377
 
378 378
     /**
379
-      * test if all required NSIS modules are available
380
-      */
379
+     * test if all required NSIS modules are available
380
+     */
381 381
     private function NSISmodules_test() {
382
-         $tmp_dir = createTemporaryDirectory('installer',0)['dir'];
383
-         if(!chdir($tmp_dir)) {
384
-           debug(2, "Cannot chdir to $tmp_dir\n");
385
-           $this->test_return(L_ERROR,"NSIS modules test - problem with temporary directory permissions, cannot continue");
386
-           return;
387
-         }
388
-         $exe= 'tt.exe';
389
-         $NSIS_Module_status = [];
390
-         foreach ($this->NSIS_Modules as $module) {
382
+            $tmp_dir = createTemporaryDirectory('installer',0)['dir'];
383
+            if(!chdir($tmp_dir)) {
384
+            debug(2, "Cannot chdir to $tmp_dir\n");
385
+            $this->test_return(L_ERROR,"NSIS modules test - problem with temporary directory permissions, cannot continue");
386
+            return;
387
+            }
388
+            $exe= 'tt.exe';
389
+            $NSIS_Module_status = [];
390
+            foreach ($this->NSIS_Modules as $module) {
391 391
             unset($out);
392 392
             exec(Config::$PATHS['makensis']." -V1 '-X!include $module' '-XOutFile $exe' '-XSection X' '-XSectionEnd'", $out, $retval);
393 393
             if($retval > 0) 
394
-               $NSIS_Module_status[$module] = 0;
394
+                $NSIS_Module_status[$module] = 0;
395 395
             else
396
-               $NSIS_Module_status[$module] = 1;
397
-         }
398
-         if(is_file($exe))
396
+                $NSIS_Module_status[$module] = 1;
397
+            }
398
+            if(is_file($exe))
399 399
             unlink($exe);
400
-         foreach ($NSIS_Module_status as $module => $status) {
400
+            foreach ($NSIS_Module_status as $module => $status) {
401 401
             if($status == 1)
402
-               $this->test_return(L_OK,"NSIS module <strong>$module</strong> was found.");
402
+                $this->test_return(L_OK,"NSIS module <strong>$module</strong> was found.");
403 403
             else
404
-               $this->test_return(L_ERROR,"NSIS module <strong>$module</strong> was not found or is not working correctly.");
405
-         }
404
+                $this->test_return(L_ERROR,"NSIS module <strong>$module</strong> was not found or is not working correctly.");
405
+            }
406 406
     }
407 407
     private function NSIS_GetVersion_test() {
408
-         $tmp_dir = createTemporaryDirectory('installer',0)['dir'];
409
-         if(!chdir($tmp_dir)) {
410
-           debug(2, "Cannot chdir to $tmp_dir\n");
411
-           $this->test_return(L_ERROR,"NSIS module <strong>GetVersion</strong> - problem with temporary directory permissions, cannot continue");
412
-           return;
413
-         }
414
-         $exe= 'tt.exe';
415
-         exec(Config::$PATHS['makensis']." -V1 '-XOutFile $exe' '-XSection X' '-XGetVersion::WindowsName' '-XSectionEnd'", $out, $retval);
416
-         if($retval > 0)
408
+            $tmp_dir = createTemporaryDirectory('installer',0)['dir'];
409
+            if(!chdir($tmp_dir)) {
410
+            debug(2, "Cannot chdir to $tmp_dir\n");
411
+            $this->test_return(L_ERROR,"NSIS module <strong>GetVersion</strong> - problem with temporary directory permissions, cannot continue");
412
+            return;
413
+            }
414
+            $exe= 'tt.exe';
415
+            exec(Config::$PATHS['makensis']." -V1 '-XOutFile $exe' '-XSection X' '-XGetVersion::WindowsName' '-XSectionEnd'", $out, $retval);
416
+            if($retval > 0)
417 417
             $this->test_return(L_ERROR,"NSIS module <strong>GetVersion</strong> was not found or is not working correctly.");
418
-         else
418
+            else
419 419
             $this->test_return(L_OK,"NSIS module <strong>GetVersion</strong> was found.");
420
-         if(is_file($exe))
420
+            if(is_file($exe))
421 421
             unlink($exe);
422 422
     }
423 423
 
424 424
     /**
425
-      * test access to dowloads directories
426
-      */
425
+     * test access to dowloads directories
426
+     */
427 427
     private function directories_test() {
428
-               $Dir = createTemporaryDirectory('installer',0);
429
-               $dir = $Dir['dir'];
430
-               $base = $Dir['base'];
431
-               if($dir) {
432
-                  $this->test_return(L_OK,"Installer cache directory is writable.");
433
-                  rrmdir($dir);
434
-               } else {
435
-                  $this->test_return(L_ERROR,"Installer cache directory $base does not exist or is not writable!");
436
-               }
437
-               $Dir = createTemporaryDirectory('test',0);
438
-               $dir = $Dir['dir'];
439
-               $base = $Dir['base'];
440
-               if($dir) {
441
-                  $this->test_return(L_OK,"Test directory is writable.");
442
-                  rrmdir($dir);
443
-               } else {
444
-                  $this->test_return(L_ERROR,"Test directory  $base does not exist or is not writable!");
445
-               }
446
-               $Dir = createTemporaryDirectory('logo',0);
447
-               $dir = $Dir['dir'];
448
-               $base = $Dir['base'];
449
-               if($dir) {
450
-                  $this->test_return(L_OK,"Logos cache directory is writable.");
451
-                  rrmdir($dir);
452
-               } else {
453
-                  $this->test_return(L_ERROR,"Logos cache directory  $base does not exist or is not writable!");
454
-               }
428
+                $Dir = createTemporaryDirectory('installer',0);
429
+                $dir = $Dir['dir'];
430
+                $base = $Dir['base'];
431
+                if($dir) {
432
+                    $this->test_return(L_OK,"Installer cache directory is writable.");
433
+                    rrmdir($dir);
434
+                } else {
435
+                    $this->test_return(L_ERROR,"Installer cache directory $base does not exist or is not writable!");
436
+                }
437
+                $Dir = createTemporaryDirectory('test',0);
438
+                $dir = $Dir['dir'];
439
+                $base = $Dir['base'];
440
+                if($dir) {
441
+                    $this->test_return(L_OK,"Test directory is writable.");
442
+                    rrmdir($dir);
443
+                } else {
444
+                    $this->test_return(L_ERROR,"Test directory  $base does not exist or is not writable!");
445
+                }
446
+                $Dir = createTemporaryDirectory('logo',0);
447
+                $dir = $Dir['dir'];
448
+                $base = $Dir['base'];
449
+                if($dir) {
450
+                    $this->test_return(L_OK,"Logos cache directory is writable.");
451
+                    rrmdir($dir);
452
+                } else {
453
+                    $this->test_return(L_ERROR,"Logos cache directory  $base does not exist or is not writable!");
454
+                }
455 455
     }
456 456
 
457 457
     /**
458
-      * test if all required locales are enabled
459
-      */
458
+     * test if all required locales are enabled
459
+     */
460 460
     private function locales_test() {
461 461
                 $locales = shell_exec("locale -a");
462 462
                 $allthere = "";
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 
480 480
 
481 481
     /**
482
-      * test if detalts in the config have been replaced with some real values
483
-      */
482
+     * test if detalts in the config have been replaced with some real values
483
+     */
484 484
     private function defaults_test() {
485 485
                 $defaultvalues = "";
486 486
                 $missingvalues = "";
@@ -531,121 +531,121 @@  discard block
 block discarded – undo
531 531
                     $this->test_return(L_OK,"Your configuration does not contain any unchanged defaults, which is a good sign.");
532 532
     }
533 533
 
534
-   /**
534
+    /**
535 535
      * test access to databases
536 536
      */
537
-   private function databases_test() {
537
+    private function databases_test() {
538 538
         $DB = 'INST';
539 539
         $db = mysqli_connect(Config::$DB[$DB]['host'], Config::$DB[$DB]['user'], Config::$DB[$DB]['pass'], Config::$DB[$DB]['db']);
540 540
         if(! $db) {
541
-           $this->test_return(L_ERROR,"Connection to the  $DB database failed");
541
+            $this->test_return(L_ERROR,"Connection to the  $DB database failed");
542 542
         } else {
543
-           $r = mysqli_query($db,'select * from profile_option_dict');
544
-           if($r->num_rows == $this->profile_option_ct)
545
-              $this->test_return(L_OK,"The $DB database appears to be OK.");
546
-           else
547
-              $this->test_return(L_ERROR,"The $DB database is reacheable but probably not updated to this version of CAT.");
543
+            $r = mysqli_query($db,'select * from profile_option_dict');
544
+            if($r->num_rows == $this->profile_option_ct)
545
+                $this->test_return(L_OK,"The $DB database appears to be OK.");
546
+            else
547
+                $this->test_return(L_ERROR,"The $DB database is reacheable but probably not updated to this version of CAT.");
548 548
         }
549 549
         $DB = 'USER';
550 550
         $db = mysqli_connect(Config::$DB[$DB]['host'], Config::$DB[$DB]['user'], Config::$DB[$DB]['pass'], Config::$DB[$DB]['db']);
551 551
         if(! $db) {
552
-           $this->test_return(L_ERROR,"Connection to the  $DB database failed");
552
+            $this->test_return(L_ERROR,"Connection to the  $DB database failed");
553 553
         } else {
554
-           $r = mysqli_query($db,'desc view_admin');
555
-           if($r->num_rows == $this->view_admin_ct)
556
-              $this->test_return(L_OK,"The $DB database appears to be OK.");
557
-           else
558
-              $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema");
554
+            $r = mysqli_query($db,'desc view_admin');
555
+            if($r->num_rows == $this->view_admin_ct)
556
+                $this->test_return(L_OK,"The $DB database appears to be OK.");
557
+            else
558
+                $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema");
559 559
         }
560 560
         $DB = 'EXTERNAL';
561 561
         if(! empty(Config::$DB[$DB])) {
562 562
         $db = mysqli_connect(Config::$DB[$DB]['host'], Config::$DB[$DB]['user'], Config::$DB[$DB]['pass'], Config::$DB[$DB]['db']);
563 563
         if(! $db) {
564
-           $this->test_return(L_ERROR,"Connection to the  $DB database failed");
564
+            $this->test_return(L_ERROR,"Connection to the  $DB database failed");
565 565
         } else {
566
-           $r = mysqli_query($db,'desc view_admin');
567
-           if($r->num_rows == $this->view_admin_ct)
568
-              $this->test_return(L_OK,"The $DB database appears to be OK.");
569
-           else
570
-              $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema");
566
+            $r = mysqli_query($db,'desc view_admin');
567
+            if($r->num_rows == $this->view_admin_ct)
568
+                $this->test_return(L_OK,"The $DB database appears to be OK.");
569
+            else
570
+                $this->test_return(L_ERROR,"The $DB is reacheable but there is something wrong with the schema");
571 571
         }
572 572
         }
573
-   }
573
+    }
574 574
 
575 575
 
576
-   /**
576
+    /**
577 577
      * test devices.php for the no_cache option
578 578
      */
579
-   private function device_cache_test() {
580
-       if((! empty(Devices::$Options['no_cache'])) && Devices::$Options['no_cache'])
581
-          $global_no_cache = 1;
582
-       else
583
-          $global_no_cache = 0;
584
-
585
-       if($global_no_cache == 1)
586
-          $this->test_return(L_WARN,"Devices no_cache global option is set, this is not a good idea in a production setting\n");
587
-       $Devs = Devices::listDevices();
588
-       $no_cache_dev = '';
589
-       $no_cache_dev_count = 0;
590
-       if($global_no_cache) {
591
-          foreach ($Devs as $dev=>$D) {
592
-             if(empty($D['options']['no_cache']) || $D['options']['no_cache'] != 0) {
579
+    private function device_cache_test() {
580
+        if((! empty(Devices::$Options['no_cache'])) && Devices::$Options['no_cache'])
581
+            $global_no_cache = 1;
582
+        else
583
+            $global_no_cache = 0;
584
+
585
+        if($global_no_cache == 1)
586
+            $this->test_return(L_WARN,"Devices no_cache global option is set, this is not a good idea in a production setting\n");
587
+        $Devs = Devices::listDevices();
588
+        $no_cache_dev = '';
589
+        $no_cache_dev_count = 0;
590
+        if($global_no_cache) {
591
+            foreach ($Devs as $dev=>$D) {
592
+                if(empty($D['options']['no_cache']) || $D['options']['no_cache'] != 0) {
593 593
                 $no_cache_dev .= $dev." ";
594 594
                 $no_cache_dev_count++;
595
-             }
596
-          }
597
-       } else {
598
-          foreach ($Devs as $dev=>$D) {
599
-             if(!empty($D['options']['no_cache']) && $D['options']['no_cache'] != 0) {
595
+                }
596
+            }
597
+        } else {
598
+            foreach ($Devs as $dev=>$D) {
599
+                if(!empty($D['options']['no_cache']) && $D['options']['no_cache'] != 0) {
600 600
                 $no_cache_dev .= $dev." ";
601 601
                 $no_cache_dev_count++;
602
-             }
603
-          }
604
-       }
602
+                }
603
+            }
604
+        }
605 605
 
606 606
 
607
-       if($no_cache_dev_count > 1 ) 
608
-          $this->test_return(L_WARN,"The following devices will not be cached: $no_cache_dev");
609
-       if($no_cache_dev_count == 1 ) 
610
-          $this->test_return(L_WARN,"The following device will not be cached: $no_cache_dev");
607
+        if($no_cache_dev_count > 1 ) 
608
+            $this->test_return(L_WARN,"The following devices will not be cached: $no_cache_dev");
609
+        if($no_cache_dev_count == 1 ) 
610
+            $this->test_return(L_WARN,"The following device will not be cached: $no_cache_dev");
611 611
 
612
-   }
612
+    }
613 613
 
614
-   /**
614
+    /**
615 615
      * test if mailer works
616 616
      */
617
-   private function mailer_test() {
618
-      if (empty(Config::$APPEARANCE['abuse-mail']) || Config::$APPEARANCE['abuse-mail'] == "[email protected]") {
619
-         $this->test_return(L_ERROR,"Your abuse-mail has not been set, cannot continue with mailer tests.");
620
-         return;
621
-      }
622
-      $mail = new PHPMailer\PHPMailer\PHPMailer();
623
-      $mail->isSMTP();
624
-      $mail->Port = 587;
625
-      $mail->SMTPAuth = true;
626
-      $mail->SMTPSecure = 'tls';
627
-      $mail->Host = Config::$MAILSETTINGS['host'];
628
-      $mail->Username = Config::$MAILSETTINGS['user'];
629
-      $mail->Password = Config::$MAILSETTINGS['pass'];
630
-      $mail->WordWrap = 72;
631
-      $mail->isHTML(FALSE);
632
-      $mail->CharSet = 'UTF-8';
633
-      $mail->From = Config::$APPEARANCE['from-mail'];
634
-      $mail->FromName = Config::$APPEARANCE['productname'] . " Invitation System";
635
-      $mail->addAddress(Config::$APPEARANCE['abuse-mail']);
636
-      $mail->Subject = "testing CAT configuration mail";
637
-      $mail->Body = "Testing CAT mailing\n";
638
-      $sent = $mail->send();
639
-      if($sent)
640
-          $this->test_return(L_OK,"mailer settings appear to be working, check ".Config::$APPEARANCE['abuse-mail']." mailbox if the message was receiced.");
641
-      else
642
-          $this->test_return(L_ERROR,"mailer settings failed, check the Config::MAILSETTINGS");
643
-
644
-   }
617
+    private function mailer_test() {
618
+        if (empty(Config::$APPEARANCE['abuse-mail']) || Config::$APPEARANCE['abuse-mail'] == "[email protected]") {
619
+            $this->test_return(L_ERROR,"Your abuse-mail has not been set, cannot continue with mailer tests.");
620
+            return;
621
+        }
622
+        $mail = new PHPMailer\PHPMailer\PHPMailer();
623
+        $mail->isSMTP();
624
+        $mail->Port = 587;
625
+        $mail->SMTPAuth = true;
626
+        $mail->SMTPSecure = 'tls';
627
+        $mail->Host = Config::$MAILSETTINGS['host'];
628
+        $mail->Username = Config::$MAILSETTINGS['user'];
629
+        $mail->Password = Config::$MAILSETTINGS['pass'];
630
+        $mail->WordWrap = 72;
631
+        $mail->isHTML(FALSE);
632
+        $mail->CharSet = 'UTF-8';
633
+        $mail->From = Config::$APPEARANCE['from-mail'];
634
+        $mail->FromName = Config::$APPEARANCE['productname'] . " Invitation System";
635
+        $mail->addAddress(Config::$APPEARANCE['abuse-mail']);
636
+        $mail->Subject = "testing CAT configuration mail";
637
+        $mail->Body = "Testing CAT mailing\n";
638
+        $sent = $mail->send();
639
+        if($sent)
640
+            $this->test_return(L_OK,"mailer settings appear to be working, check ".Config::$APPEARANCE['abuse-mail']." mailbox if the message was receiced.");
641
+        else
642
+            $this->test_return(L_ERROR,"mailer settings failed, check the Config::MAILSETTINGS");
643
+
644
+    }
645 645
 
646 646
     /**
647
-      * TODO test if RADIUS connections work
648
-      */
647
+     * TODO test if RADIUS connections work
648
+     */
649 649
     private function UDPhosts_test() {
650 650
 //        if(empty)
651 651
     }
Please login to merge, or discard this patch.
config/config-template.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -148,13 +148,13 @@  discard block
 block discarded – undo
148 148
     ];
149 149
 
150 150
     /**
151
-      * Configuration for GeoIP2 
152
-      * Beware, the legacy version does not really work with IPv6 addresses
153
-      * version: set to 2 if you wish to use GeoIP2, to 1 for the legacy version or set to 0 to turn off geolocation service
154
-      * geoip2-path-to-autoloader: points to the GeoIP2 autoloader 
155
-      * geoip2-path-to-db: points to the GeoIP2 city database
156
-      * @var array
157
-      */
151
+     * Configuration for GeoIP2 
152
+     * Beware, the legacy version does not really work with IPv6 addresses
153
+     * version: set to 2 if you wish to use GeoIP2, to 1 for the legacy version or set to 0 to turn off geolocation service
154
+     * geoip2-path-to-autoloader: points to the GeoIP2 autoloader 
155
+     * geoip2-path-to-db: points to the GeoIP2 city database
156
+     * @var array
157
+     */
158 158
       
159 159
     public static $GEOIP = [
160 160
         'version' => 0,
@@ -181,21 +181,21 @@  discard block
 block discarded – undo
181 181
      * @var array
182 182
      */
183 183
     public static $LANGUAGES = [
184
-      'ca' => ['display' => 'Català',      'locale' => 'ca_ES.utf8',    'latin_based' => TRUE],
185
-      'de' => ['display' => 'Deutsch',     'locale' => 'de_DE.utf8',    'latin_based' => TRUE],
186
-      'en' => ['display' => 'English(GB)', 'locale' => 'en_GB.utf8',    'latin_based' => TRUE],
187
-      'es' => ['display' => 'Español',     'locale' => 'es_ES.utf8',    'latin_based' => TRUE],
188
-      'gl' => ['display' => 'Galego',      'locale' => 'gl_ES.utf8',    'latin_based' => TRUE],
189
-      'hr' => ['display' => 'Hrvatski',    'locale' => 'hr_HR.utf8',    'latin_based' => TRUE],
190
-      'it' => ['display' => 'Italiano',    'locale' => 'it_IT.utf8',    'latin_based' => TRUE],
191
-      'nb' => ['display' => 'Norsk',       'locale' => 'nb_NO.utf8',    'latin_based' => TRUE],
192
-      'pl' => ['display' => 'Polski',      'locale' => 'pl_PL.utf8',    'latin_based' => TRUE],
193
-      'sl' => ['display' => 'Slovenščina', 'locale' => 'sl_SI.utf8',    'latin_based' => TRUE],
194
-      'sr' => ['display' => 'Srpski',      'locale' => 'sr_RS@latin',    'latin_based' => TRUE],
195
-      'fi' => ['display' => 'Suomi',       'locale' => 'fi_FI.utf8',    'latin_based' => TRUE],
196
-      'el' => ['display' => 'Ελληνικά',    'locale' => 'el_GR.utf8',    'latin_based' => FALSE],
197
-      'hu' => ['display' => 'Magyar',      'locale' => 'hu_HU.utf8',    'latin_based' => TRUE],
198
-      'pt' => ['display' => 'Português',   'locale' => 'pt_PT.utf8',    'latin_based' => TRUE],
184
+        'ca' => ['display' => 'Català',      'locale' => 'ca_ES.utf8',    'latin_based' => TRUE],
185
+        'de' => ['display' => 'Deutsch',     'locale' => 'de_DE.utf8',    'latin_based' => TRUE],
186
+        'en' => ['display' => 'English(GB)', 'locale' => 'en_GB.utf8',    'latin_based' => TRUE],
187
+        'es' => ['display' => 'Español',     'locale' => 'es_ES.utf8',    'latin_based' => TRUE],
188
+        'gl' => ['display' => 'Galego',      'locale' => 'gl_ES.utf8',    'latin_based' => TRUE],
189
+        'hr' => ['display' => 'Hrvatski',    'locale' => 'hr_HR.utf8',    'latin_based' => TRUE],
190
+        'it' => ['display' => 'Italiano',    'locale' => 'it_IT.utf8',    'latin_based' => TRUE],
191
+        'nb' => ['display' => 'Norsk',       'locale' => 'nb_NO.utf8',    'latin_based' => TRUE],
192
+        'pl' => ['display' => 'Polski',      'locale' => 'pl_PL.utf8',    'latin_based' => TRUE],
193
+        'sl' => ['display' => 'Slovenščina', 'locale' => 'sl_SI.utf8',    'latin_based' => TRUE],
194
+        'sr' => ['display' => 'Srpski',      'locale' => 'sr_RS@latin',    'latin_based' => TRUE],
195
+        'fi' => ['display' => 'Suomi',       'locale' => 'fi_FI.utf8',    'latin_based' => TRUE],
196
+        'el' => ['display' => 'Ελληνικά',    'locale' => 'el_GR.utf8',    'latin_based' => FALSE],
197
+        'hu' => ['display' => 'Magyar',      'locale' => 'hu_HU.utf8',    'latin_based' => TRUE],
198
+        'pt' => ['display' => 'Português',   'locale' => 'pt_PT.utf8',    'latin_based' => TRUE],
199 199
 
200 200
 // For the following languages, partial translations exist in Transifex, but
201 201
 // they are not complete enough for display. Their Transifex content is not
@@ -244,45 +244,45 @@  discard block
 block discarded – undo
244 244
         ],
245 245
 
246 246
         'TLS-clientcerts' => [
247
-          'CA1' => [
247
+            'CA1' => [
248 248
             'status' => 'ACCREDITED',
249 249
             'issuerCA' => '/DC=org/DC=pki1/CN=PKI 1',
250 250
             'certificates' => [
251
-              [
251
+                [
252 252
                 'status' => 'CORRECT',
253 253
                 'public' => 'ca1-client-cert.pem',
254 254
                 'private' => 'ca1-client-key.pem',
255 255
                 'expected' => 'PASS'],
256
-              [
256
+                [
257 257
                 'status' => 'WRONGPOLICY',
258 258
                 'public' => 'ca1-nopolicy-cert.pem',
259 259
                 'private' => 'ca1-nopolicy-key.key',
260 260
                 'expected' => 'FAIL'],
261
-              [
261
+                [
262 262
                 'status' => 'EXPIRED',
263 263
                 'public' => 'ca1-exp.pem',
264 264
                 'private' => 'ca1-exp.key',
265 265
                 'expected' => 'FAIL'],
266
-              [
266
+                [
267 267
                 'status' => 'REVOKED',
268 268
                 'public' => 'ca1-revoked.pem',
269 269
                 'private' => 'ca1-revoked.key',
270 270
                 'expected' => 'FAIL'],
271 271
             ]
272
-          ],
273
-          'CA-N' => [
272
+            ],
273
+            'CA-N' => [
274 274
             'status' => 'NONACCREDITED',
275 275
             'issuerCA' => '/DC=org/DC=pkiN/CN=PKI N',
276 276
             'certificates' => [
277
-               [
277
+                [
278 278
                 'status' => 'CORRECT',
279 279
                 'public' => 'caN-client-cert.pem',
280 280
                 'private' => 'caN-client-cert.key',
281 281
                 'expected' => 'FAIL'],
282
-               ]
283
-          ]
284
-      ],
285
-      'accreditedCAsURL' => '',
282
+                ]
283
+            ]
284
+        ],
285
+        'accreditedCAsURL' => '',
286 286
     ];
287 287
 
288 288
     /**
@@ -320,11 +320,11 @@  discard block
 block discarded – undo
320 320
             'db' => 'customer_db',
321 321
             'user' => 'customerservice',
322 322
             'pass' => '2lame4u'],
323
-         'enforce-external-sync' => TRUE,
324
-         /* if you feed your user database from a third-party source and do not want CAT to update it on its own, you can 
323
+            'enforce-external-sync' => TRUE,
324
+            /* if you feed your user database from a third-party source and do not want CAT to update it on its own, you can 
325 325
           * make it read-only
326 326
           */
327
-         'userdb-readonly' => FALSE,
327
+            'userdb-readonly' => FALSE,
328 328
     ];
329 329
 
330 330
     /**
Please login to merge, or discard this patch.
core/DeviceConfig.php 1 patch
Indentation   +422 added lines, -422 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@  discard block
 block discarded – undo
6 6
 ?>
7 7
 <?php
8 8
 /**
9
-  * This file defines the abstract Device class
10
-  *
11
-  * @package ModuleWriting
12
-  */
9
+ * This file defines the abstract Device class
10
+ *
11
+ * @package ModuleWriting
12
+ */
13 13
 
14 14
 /**
15 15
  * 
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
  */
47 47
 
48 48
 abstract class DeviceConfig {
49
-   /**
50
-    * stores the path to the temporary working directory for a module instance
51
-    * @var string $FPATH
52
-    */
49
+    /**
50
+     * stores the path to the temporary working directory for a module instance
51
+     * @var string $FPATH
52
+     */
53 53
     public $FPATH;
54 54
 
55 55
     /**
@@ -58,391 +58,391 @@  discard block
 block discarded – undo
58 58
      */
59 59
     public $specialities;
60 60
 
61
-   /**
61
+    /**
62 62
      * device module constructor should be defined by each module, but if it is not, then here is a default one
63 63
      */
64 64
 
65
-      public function __construct() {
66
-      $this->supportedEapMethods  = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP];
67
-      debug(4,"This device supports the following EAP methods: ");
68
-      debug(4,$this->supportedEapMethods);
65
+        public function __construct() {
66
+        $this->supportedEapMethods  = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP];
67
+        debug(4,"This device supports the following EAP methods: ");
68
+        debug(4,$this->supportedEapMethods);
69 69
     }
70 70
 
71 71
 
72
-   /**
73
-    * Set up working environment for a device module
74
-    *
75
-    * Sets up the device module environment taking into account the actual profile
76
-    * selected by the user in the GUI. The selected profile is passed as the
77
-    * Profile $profile argumant.
78
-    *
79
-    * This method needs to be called after the device instance has been created (the GUI class does that)
80
-    *
81
-    * setup performs the following tasks:
82
-    * - collect profile attributes and pass them as the attributes property;
83
-    * - create the temporary working directory
84
-    * - process CA certificates and store them as 'internal:CAs' attribute
85
-    * - process and save optional info files and store references to them in
86
-    *   'internal:info_file' attribute
87
-    * @param Profile $profile the profile object which will be passed by the caller
88
-    * @final not to be redefined
89
-    */
72
+    /**
73
+     * Set up working environment for a device module
74
+     *
75
+     * Sets up the device module environment taking into account the actual profile
76
+     * selected by the user in the GUI. The selected profile is passed as the
77
+     * Profile $profile argumant.
78
+     *
79
+     * This method needs to be called after the device instance has been created (the GUI class does that)
80
+     *
81
+     * setup performs the following tasks:
82
+     * - collect profile attributes and pass them as the attributes property;
83
+     * - create the temporary working directory
84
+     * - process CA certificates and store them as 'internal:CAs' attribute
85
+     * - process and save optional info files and store references to them in
86
+     *   'internal:info_file' attribute
87
+     * @param Profile $profile the profile object which will be passed by the caller
88
+     * @final not to be redefined
89
+     */
90 90
     final public function setup(Profile $profile) {
91
-       debug(4,"module setup start\n");
92
-       if(! $profile instanceof Profile) {
93
-          debug(2,"No profile has been set\n");
94
-          error("No profile has been set");
95
-          exit;
96
-       }
97
-       $this->attributes = $this->getProfileAttributes($profile);
98
-       if(! $this->selected_eap) {
99
-          error("No EAP type specified.");
100
-          exit;
101
-       }
102
-       // create temporary directory, its full path will be saved in $this->FPATH;
103
-       $T = createTemporaryDirectory('installer');
104
-       $this->FPATH = $T['dir'];
105
-       mkdir($T['dir'].'/tmp');
106
-       chdir($T['dir'].'/tmp');
107
-       $CAs = [];
108
-       if(isset($this->attributes['eap:ca_file'])) {
109
-       foreach ($this->attributes['eap:ca_file'] as $ca) {
110
-          if($c = X509::processCertificate($ca))
111
-             $CAs[] = $c;
112
-          }
113
-          $this->attributes['internal:CAs'][0]=$CAs;
114
-       }
115
-       if(isset($this->attributes['support:info_file'])) {
116
-          $this->attributes['internal:info_file'][0] = 
117
-             $this->saveInfoFile($this->attributes['support:info_file'][0]);
118
-       }
119
-       if(isset($this->attributes['general:logo_file']))
120
-          $this->attributes['internal:logo_file'] = 
121
-             $this->saveLogoFile($this->attributes['general:logo_file']);
122
-       $this->attributes['internal:SSID'] = $this->getSSIDs()['add'];;
123
-       $this->attributes['internal:remove_SSID'] = $this->getSSIDs()['del'];;
124
-       $this->attributes['internal:consortia'] = $this->getConsortia();
125
-       $this->lang_index = CAT::get_lang();
126
-       // phpMD says the below is not needed. Wow.
127
-       // $idp = new IdP($profile->institution);
128
-       $olddomain = CAT::set_locale("core");
129
-       $this->support_email_substitute = sprintf(_("your local %s support"),Config::$CONSORTIUM['name']);
130
-       $this->support_url_substitute = sprintf(_("your local %s support page"),Config::$CONSORTIUM['name']);
131
-       CAT::set_locale($olddomain);
132
-
133
-       if($this->signer && $this->options['sign'])
134
-         $this->sign = CAT::$root . '/signer/'. $this->signer;
135
-       $this->installerBasename = $this->getInstallerBasename();
91
+        debug(4,"module setup start\n");
92
+        if(! $profile instanceof Profile) {
93
+            debug(2,"No profile has been set\n");
94
+            error("No profile has been set");
95
+            exit;
96
+        }
97
+        $this->attributes = $this->getProfileAttributes($profile);
98
+        if(! $this->selected_eap) {
99
+            error("No EAP type specified.");
100
+            exit;
101
+        }
102
+        // create temporary directory, its full path will be saved in $this->FPATH;
103
+        $T = createTemporaryDirectory('installer');
104
+        $this->FPATH = $T['dir'];
105
+        mkdir($T['dir'].'/tmp');
106
+        chdir($T['dir'].'/tmp');
107
+        $CAs = [];
108
+        if(isset($this->attributes['eap:ca_file'])) {
109
+        foreach ($this->attributes['eap:ca_file'] as $ca) {
110
+            if($c = X509::processCertificate($ca))
111
+                $CAs[] = $c;
112
+            }
113
+            $this->attributes['internal:CAs'][0]=$CAs;
114
+        }
115
+        if(isset($this->attributes['support:info_file'])) {
116
+            $this->attributes['internal:info_file'][0] = 
117
+                $this->saveInfoFile($this->attributes['support:info_file'][0]);
118
+        }
119
+        if(isset($this->attributes['general:logo_file']))
120
+            $this->attributes['internal:logo_file'] = 
121
+                $this->saveLogoFile($this->attributes['general:logo_file']);
122
+        $this->attributes['internal:SSID'] = $this->getSSIDs()['add'];;
123
+        $this->attributes['internal:remove_SSID'] = $this->getSSIDs()['del'];;
124
+        $this->attributes['internal:consortia'] = $this->getConsortia();
125
+        $this->lang_index = CAT::get_lang();
126
+        // phpMD says the below is not needed. Wow.
127
+        // $idp = new IdP($profile->institution);
128
+        $olddomain = CAT::set_locale("core");
129
+        $this->support_email_substitute = sprintf(_("your local %s support"),Config::$CONSORTIUM['name']);
130
+        $this->support_url_substitute = sprintf(_("your local %s support page"),Config::$CONSORTIUM['name']);
131
+        CAT::set_locale($olddomain);
132
+
133
+        if($this->signer && $this->options['sign'])
134
+            $this->sign = CAT::$root . '/signer/'. $this->signer;
135
+        $this->installerBasename = $this->getInstallerBasename();
136 136
     }
137 137
 
138
-  /**
139
-    * Selects the preferred eap method based on profile EAP configuration and device EAP capabilities
140
-    *
141
-    * @param array eap_array an array of eap methods supported by a given device
142
-    * @return the best matching EAP type for the profile; or 0 if no match was found
143
-    */   
144
-   public function getPreferredEapType($eap_array) {
145
-     foreach ($eap_array as $eap) {
146
-         if(in_array($eap,$this->supportedEapMethods)) {
138
+    /**
139
+     * Selects the preferred eap method based on profile EAP configuration and device EAP capabilities
140
+     *
141
+     * @param array eap_array an array of eap methods supported by a given device
142
+     * @return the best matching EAP type for the profile; or 0 if no match was found
143
+     */   
144
+    public function getPreferredEapType($eap_array) {
145
+        foreach ($eap_array as $eap) {
146
+            if(in_array($eap,$this->supportedEapMethods)) {
147 147
             $this->selected_eap = $eap;
148 148
             debug(4,"Selected EAP:");
149 149
             debug(4,$eap);
150 150
             return($eap);
151
-         }
152
-     }
153
-     return(0);
154
-   }
155
-  /**
156
-    * prepare usage information for the installer
157
-    * every device module should override this method
158
-    *
159
-    * @return String HTML text to be displayed
160
-    */ 
161
-   public function writeDeviceInfo() {
162
-     return _("Sorry, this should not happen - no additional information is available");
163
-   }
164
-
165
-  /**
166
-    *  Copy a file from the module location to the temporary directory.
167
-    *
168
-    * If the second argument is provided then the file will be saved under the name 
169
-    * taken form this argument. If only one parameter is given, source and destination
170
-    * filenames are the same
171
-    * Source file can be located either in the Files subdirectory or in the sibdirectory of Files
172
-    * named the same as device_id. The second option takes precedence.
173
-    *
174
-    * @param string $source_name The source file name
175
-    * @param string $output_name The destination file name
176
-    *
177
-    * @return bool result of the copy operation
178
-    * @final not to be redefined
179
-    */
180
-   final protected function copyFile($source_name, $output_name = 0) {
181
-      if  ( $output_name === 0)
151
+            }
152
+        }
153
+        return(0);
154
+    }
155
+    /**
156
+     * prepare usage information for the installer
157
+     * every device module should override this method
158
+     *
159
+     * @return String HTML text to be displayed
160
+     */ 
161
+    public function writeDeviceInfo() {
162
+        return _("Sorry, this should not happen - no additional information is available");
163
+    }
164
+
165
+    /**
166
+     *  Copy a file from the module location to the temporary directory.
167
+     *
168
+     * If the second argument is provided then the file will be saved under the name 
169
+     * taken form this argument. If only one parameter is given, source and destination
170
+     * filenames are the same
171
+     * Source file can be located either in the Files subdirectory or in the sibdirectory of Files
172
+     * named the same as device_id. The second option takes precedence.
173
+     *
174
+     * @param string $source_name The source file name
175
+     * @param string $output_name The destination file name
176
+     *
177
+     * @return bool result of the copy operation
178
+     * @final not to be redefined
179
+     */
180
+    final protected function copyFile($source_name, $output_name = 0) {
181
+        if  ( $output_name === 0)
182 182
         $output_name = $source_name;
183 183
 
184
-      debug(4,"fileCopy($source_name, $output_name)\n");
185
-      if(is_file($this->module_path.'/Files/'.$this->device_id.'/'.$source_name))
186
-         $source = $this->module_path.'/Files/'.$this->device_id.'/'.$source_name;
187
-      elseif(is_file($this->module_path.'/Files/'.$source_name))
188
-         $source = $this->module_path.'/Files/'.$source_name;
189
-      else {
184
+        debug(4,"fileCopy($source_name, $output_name)\n");
185
+        if(is_file($this->module_path.'/Files/'.$this->device_id.'/'.$source_name))
186
+            $source = $this->module_path.'/Files/'.$this->device_id.'/'.$source_name;
187
+        elseif(is_file($this->module_path.'/Files/'.$source_name))
188
+            $source = $this->module_path.'/Files/'.$source_name;
189
+        else {
190 190
         debug(2,"fileCopy:reqested file $source_name does not exist\n");
191 191
         return(FALSE);
192
-      }
193
-      debug(4,"Copying $source to $output_name\n");
194
-      $result = copy($source,"$output_name");
195
-      if(! $result )
192
+        }
193
+        debug(4,"Copying $source to $output_name\n");
194
+        $result = copy($source,"$output_name");
195
+        if(! $result )
196 196
         debug(2,"fileCopy($source_name, $output_name) failed\n");
197
-      return($result); 
198
-   }
199
-
200
-
201
-  /**
202
-    *  Copy a file from the module location to the temporary directory aplying transcoding.
203
-    *
204
-    * Transcoding is only required for Windows installers, and no Unicode support
205
-    * in NSIS (NSIS version below 3)
206
-    * Trancoding is only applied if the third optional parameter is set and nonzero
207
-    * If Config::$NSIS_VERSION is set to 3 or more, no transcoding will be applied
208
-    * regardless of the third parameter value.
209
-    * If the second argument is provided and is not equal to 0, then the file will be
210
-    * saved under the name taken from this argument.
211
-    * If only one parameter is given or the second is equal to 0, source and destination
212
-    * filenames are the same.
213
-    * The third optional parameter, if nonzero, should be the character set understood by iconv
214
-    * This is required by the Windows installer and is expected to go away in the future.
215
-    * Source file can be located either in the Files subdirectory or in the sibdirectory of Files
216
-    * named the same as device_id. The second option takes precedence.
217
-    *
218
-    * @param string $source_name The source file name
219
-    * @param string $output_name The destination file name
220
-    * @param int $use_win_cp Set Windows charset if non-zero
221
-    *
222
-    * @final not to be redefined
223
-    */
224
-
225
-   final protected function translateFile($source_name, $output_name = 0, $encoding = 0) {
226
-      if(Config::$NSIS_VERSION >= 3)
197
+        return($result); 
198
+    }
199
+
200
+
201
+    /**
202
+     *  Copy a file from the module location to the temporary directory aplying transcoding.
203
+     *
204
+     * Transcoding is only required for Windows installers, and no Unicode support
205
+     * in NSIS (NSIS version below 3)
206
+     * Trancoding is only applied if the third optional parameter is set and nonzero
207
+     * If Config::$NSIS_VERSION is set to 3 or more, no transcoding will be applied
208
+     * regardless of the third parameter value.
209
+     * If the second argument is provided and is not equal to 0, then the file will be
210
+     * saved under the name taken from this argument.
211
+     * If only one parameter is given or the second is equal to 0, source and destination
212
+     * filenames are the same.
213
+     * The third optional parameter, if nonzero, should be the character set understood by iconv
214
+     * This is required by the Windows installer and is expected to go away in the future.
215
+     * Source file can be located either in the Files subdirectory or in the sibdirectory of Files
216
+     * named the same as device_id. The second option takes precedence.
217
+     *
218
+     * @param string $source_name The source file name
219
+     * @param string $output_name The destination file name
220
+     * @param int $use_win_cp Set Windows charset if non-zero
221
+     *
222
+     * @final not to be redefined
223
+     */
224
+
225
+    final protected function translateFile($source_name, $output_name = 0, $encoding = 0) {
226
+        if(Config::$NSIS_VERSION >= 3)
227 227
         $encoding = 0;
228
-      if  ( $output_name === 0)
228
+        if  ( $output_name === 0)
229 229
         $output_name = $source_name;
230 230
 
231
-      debug(4,"translateFile($source_name, $output_name, $encoding)\n");
232
-      ob_start();
233
-      debug(4,$this->module_path.'/Files/'.$this->device_id.'/'.$source_name."\n");
234
-      if(is_file($this->module_path.'/Files/'.$this->device_id.'/'.$source_name))
235
-         $source = $this->module_path.'/Files/'.$this->device_id.'/'.$source_name;
236
-      elseif(is_file($this->module_path.'/Files/'.$source_name))
237
-         $source = $this->module_path.'/Files/'.$source_name;
238
-      include($source);
239
-      $output = ob_get_clean();
240
-      if($encoding) {
231
+        debug(4,"translateFile($source_name, $output_name, $encoding)\n");
232
+        ob_start();
233
+        debug(4,$this->module_path.'/Files/'.$this->device_id.'/'.$source_name."\n");
234
+        if(is_file($this->module_path.'/Files/'.$this->device_id.'/'.$source_name))
235
+            $source = $this->module_path.'/Files/'.$this->device_id.'/'.$source_name;
236
+        elseif(is_file($this->module_path.'/Files/'.$source_name))
237
+            $source = $this->module_path.'/Files/'.$source_name;
238
+        include($source);
239
+        $output = ob_get_clean();
240
+        if($encoding) {
241 241
         $output_c = iconv('UTF-8',$encoding.'//TRANSLIT',$output);
242 242
         if($output_c)
243
-           $output = $output_c;
244
-      }
245
-      $f = fopen("$output_name","w");
246
-      if(! $f)
247
-         debug(2,"translateFile($source, $output_name, $encoding) failed\n");
248
-      fwrite($f,$output);
249
-      fclose($f);
250
-      debug(4,"translateFile($source, $output_name, $encoding) end\n");
251
-   }
252
-
253
-
254
-  /**
255
-    * Transcode a string adding double quotes escaping
256
-    *
257
-    * Transcoding is only required for Windows installers, and no Unicode support
258
-    * in NSIS (NSIS version below 3)
259
-    * Trancoding is only applied if the third optional parameter is set and nonzero
260
-    * If Config::$NSIS_VERSION is set to 3 or more, no transcoding will be applied
261
-    * regardless of the second parameter value.
262
-    * The second optional parameter, if nonzero, should be the character set understood by iconv
263
-    * This is required by the Windows installer and is expected to go away in the future.
264
-    *
265
-    * @param string $source_name The source file name
266
-    * @param int $use_win_cp Set Windows charset if non-zero
267
-    *
268
-    * @final not to be redefined
269
-    */
270
-
271
-   final protected function translateString($source_string,$encoding = 0) {
272
-      if(Config::$NSIS_VERSION >= 3)
243
+            $output = $output_c;
244
+        }
245
+        $f = fopen("$output_name","w");
246
+        if(! $f)
247
+            debug(2,"translateFile($source, $output_name, $encoding) failed\n");
248
+        fwrite($f,$output);
249
+        fclose($f);
250
+        debug(4,"translateFile($source, $output_name, $encoding) end\n");
251
+    }
252
+
253
+
254
+    /**
255
+     * Transcode a string adding double quotes escaping
256
+     *
257
+     * Transcoding is only required for Windows installers, and no Unicode support
258
+     * in NSIS (NSIS version below 3)
259
+     * Trancoding is only applied if the third optional parameter is set and nonzero
260
+     * If Config::$NSIS_VERSION is set to 3 or more, no transcoding will be applied
261
+     * regardless of the second parameter value.
262
+     * The second optional parameter, if nonzero, should be the character set understood by iconv
263
+     * This is required by the Windows installer and is expected to go away in the future.
264
+     *
265
+     * @param string $source_name The source file name
266
+     * @param int $use_win_cp Set Windows charset if non-zero
267
+     *
268
+     * @final not to be redefined
269
+     */
270
+
271
+    final protected function translateString($source_string,$encoding = 0) {
272
+        if(Config::$NSIS_VERSION >= 3)
273 273
         $encoding = 0;
274
-      if($encoding)
274
+        if($encoding)
275 275
         $output_c = iconv('UTF-8',$encoding.'//TRANSLIT',$source_string);
276
-      else
276
+        else
277 277
         $output_c = $source_string;
278
-      if($output_c) 
279
-         $source_string  = str_replace('"','$\\"',$output_c);
280
-      else
281
-         debug(2,"Failed to convert string $source_string\n");
282
-      return $source_string;
283
-   }
284
-
285
-
286
-  /**
287
-   * Save certificate files in either DER or PEM format
288
-   *
289
-   * Certificate files will be saved in the module working directory.
290
-   * @param string $format  only "der" and "pem" are currently allowed
291
-   * @return array an array of arrays or FALSE on error
292
-   * saved certificate file names are avalable under the 'file' index
293
-   * additional array entries are indexed as 'sha1', 'md5', and 'root'.
294
-   * sha1 and md5 are correcponding certificate hashes
295
-   * root is set to 1 for the CA roor certicicate and 0 otherwise
296
-  */ 
297
-   final protected function saveCertificateFiles($format) {
298
-     if($format == 'der' || $format == 'pam') {
299
-       $i = 0;
300
-       $CA_files = [];
301
-       $ca_array = $this->attributes['internal:CAs'][0];
302
-       if(! $ca_array)
303
-         return(FALSE);
304
-       foreach ($ca_array as $CA) {
305
-         $f = fopen("cert-$i.crt","w");
306
-         if(! $f) die("problem opening the file\n");
307
-         if($format == "pem")
278
+        if($output_c) 
279
+            $source_string  = str_replace('"','$\\"',$output_c);
280
+        else
281
+            debug(2,"Failed to convert string $source_string\n");
282
+        return $source_string;
283
+    }
284
+
285
+
286
+    /**
287
+     * Save certificate files in either DER or PEM format
288
+     *
289
+     * Certificate files will be saved in the module working directory.
290
+     * @param string $format  only "der" and "pem" are currently allowed
291
+     * @return array an array of arrays or FALSE on error
292
+     * saved certificate file names are avalable under the 'file' index
293
+     * additional array entries are indexed as 'sha1', 'md5', and 'root'.
294
+     * sha1 and md5 are correcponding certificate hashes
295
+     * root is set to 1 for the CA roor certicicate and 0 otherwise
296
+     */ 
297
+    final protected function saveCertificateFiles($format) {
298
+        if($format == 'der' || $format == 'pam') {
299
+        $i = 0;
300
+        $CA_files = [];
301
+        $ca_array = $this->attributes['internal:CAs'][0];
302
+        if(! $ca_array)
303
+            return(FALSE);
304
+        foreach ($ca_array as $CA) {
305
+            $f = fopen("cert-$i.crt","w");
306
+            if(! $f) die("problem opening the file\n");
307
+            if($format == "pem")
308 308
             fwrite($f,$CA['pem']);
309
-         else
309
+            else
310 310
             fwrite($f,$CA['der']);
311
-         fclose($f);
312
-         $C = [];
313
-         $C['file'] = "cert-$i.crt";
314
-         $C['sha1'] = $CA['sha1'];
315
-         $C['md5'] = $CA['md5'];
316
-         $C['root'] = $CA['root'];
317
-         $CA_files[] = $C;
318
-         $i++;
319
-       }
320
-       return($CA_files);
321
-     } else {
322
-       debug(2, 'incorrect format value specified');
323
-       return(FALSE);
324
-     }
311
+            fclose($f);
312
+            $C = [];
313
+            $C['file'] = "cert-$i.crt";
314
+            $C['sha1'] = $CA['sha1'];
315
+            $C['md5'] = $CA['md5'];
316
+            $C['root'] = $CA['root'];
317
+            $CA_files[] = $C;
318
+            $i++;
319
+        }
320
+        return($CA_files);
321
+        } else {
322
+        debug(2, 'incorrect format value specified');
323
+        return(FALSE);
324
+        }
325 325
       
326
-   }
327
-
328
-   /**
329
-    * Generate installer filename base.
330
-    * Device module should use this name adding an extension.
331
-    * Normally the device identifier follows the Consortium name.
332
-    * The sting taken for the device identifier equals (by default) to the index in the listDevices array,
333
-    * but can be overriden with the 'device_id' device option.
334
-    */
335
-   private function getInstallerBasename() {
336
-      $replace_pattern = '/[ ()\/\'"]+/';
337
-      $lang_pointer = Config::$LANGUAGES[$this->lang_index]['latin_based'] == TRUE ? 0 : 1;
338
-      debug(4,"getInstallerBasename1:".$this->attributes['general:instname'][$lang_pointer]."\n");
339
-      $inst = iconv("UTF-8", "US-ASCII//TRANSLIT", preg_replace($replace_pattern, '_', $this->attributes['general:instname'][$lang_pointer]));
340
-      debug(4,"getInstallerBasename2:$inst\n");
341
-      $Inst_a = explode('_',$inst);
342
-      if(count($Inst_a) > 2) {
343
-         $inst = '';
344
-         foreach($Inst_a as $i)
345
-           $inst .= $i[0];
346
-      }   
347
-      $c_name = iconv("UTF-8", "US-ASCII//TRANSLIT", preg_replace($replace_pattern, '_', Config::$CONSORTIUM['name']));
348
-      if($this->attributes['internal:profile_count'][0] > 1) {
349
-         if(!empty($this->attributes['profile:name']) && ! empty($this->attributes['profile:name'][$lang_pointer])) {
350
-             $prof = iconv("UTF-8", "US-ASCII//TRANSLIT", preg_replace($replace_pattern, '_', $this->attributes['profile:name'][$lang_pointer]));
351
-             $prof = preg_replace('/_+$/','',$prof);
352
-             return $c_name. '-'. $this->getDeviceId() . $inst .'-'. $prof;
353
-         }
354
-      }
355
-      return $c_name. '-'. $this->getDeviceId() . $inst;
356
-  }
357
-
358
-  private function getDeviceId() {
326
+    }
327
+
328
+    /**
329
+     * Generate installer filename base.
330
+     * Device module should use this name adding an extension.
331
+     * Normally the device identifier follows the Consortium name.
332
+     * The sting taken for the device identifier equals (by default) to the index in the listDevices array,
333
+     * but can be overriden with the 'device_id' device option.
334
+     */
335
+    private function getInstallerBasename() {
336
+        $replace_pattern = '/[ ()\/\'"]+/';
337
+        $lang_pointer = Config::$LANGUAGES[$this->lang_index]['latin_based'] == TRUE ? 0 : 1;
338
+        debug(4,"getInstallerBasename1:".$this->attributes['general:instname'][$lang_pointer]."\n");
339
+        $inst = iconv("UTF-8", "US-ASCII//TRANSLIT", preg_replace($replace_pattern, '_', $this->attributes['general:instname'][$lang_pointer]));
340
+        debug(4,"getInstallerBasename2:$inst\n");
341
+        $Inst_a = explode('_',$inst);
342
+        if(count($Inst_a) > 2) {
343
+            $inst = '';
344
+            foreach($Inst_a as $i)
345
+            $inst .= $i[0];
346
+        }   
347
+        $c_name = iconv("UTF-8", "US-ASCII//TRANSLIT", preg_replace($replace_pattern, '_', Config::$CONSORTIUM['name']));
348
+        if($this->attributes['internal:profile_count'][0] > 1) {
349
+            if(!empty($this->attributes['profile:name']) && ! empty($this->attributes['profile:name'][$lang_pointer])) {
350
+                $prof = iconv("UTF-8", "US-ASCII//TRANSLIT", preg_replace($replace_pattern, '_', $this->attributes['profile:name'][$lang_pointer]));
351
+                $prof = preg_replace('/_+$/','',$prof);
352
+                return $c_name. '-'. $this->getDeviceId() . $inst .'-'. $prof;
353
+            }
354
+        }
355
+        return $c_name. '-'. $this->getDeviceId() . $inst;
356
+    }
357
+
358
+    private function getDeviceId() {
359 359
     $d_id = $this->device_id;
360 360
     if(isset($this->options['device_id'])) 
361
-      $d_id = $this->options['device_id'];
361
+        $d_id = $this->options['device_id'];
362 362
     if($d_id !== '')
363
-      $d_id .= '-';
363
+        $d_id .= '-';
364 364
     return $d_id;
365
-  }
365
+    }
366 366
 
367 367
 
368
-  private function getSSIDs() {
368
+    private function getSSIDs() {
369 369
     $S['add']=[];
370 370
     $S['del']=[];
371 371
     if (isset(Config::$CONSORTIUM['ssid'])) {
372
-       foreach (Config::$CONSORTIUM['ssid'] as $ssid) {
372
+        foreach (Config::$CONSORTIUM['ssid'] as $ssid) {
373 373
         if(isset(Config::$CONSORTIUM['tkipsupport']) && Config::$CONSORTIUM['tkipsupport'] == TRUE)
374
-          $S['add'][$ssid] = 'TKIP';
374
+            $S['add'][$ssid] = 'TKIP';
375 375
         else {
376
-          $S['add'][$ssid] = 'AES';
377
-          $S['del'][$ssid] = 'TKIP';
376
+            $S['add'][$ssid] = 'AES';
377
+            $S['del'][$ssid] = 'TKIP';
378
+        }
378 379
         }
379
-       }
380 380
     }
381 381
     if(isset($this->attributes['media:SSID'])) {
382
-      $SSID = $this->attributes['media:SSID'];
382
+        $SSID = $this->attributes['media:SSID'];
383 383
 
384
-      foreach($SSID as $ssid)
385
-         $S['add'][$ssid] = 'AES';
386
-      }
384
+        foreach($SSID as $ssid)
385
+            $S['add'][$ssid] = 'AES';
386
+        }
387 387
     if(isset($this->attributes['media:SSID_with_legacy'])) {
388
-      $SSID = $this->attributes['media:SSID_with_legacy'];
389
-      foreach($SSID as $ssid)
390
-         $S['add'][$ssid] = 'TKIP';
388
+        $SSID = $this->attributes['media:SSID_with_legacy'];
389
+        foreach($SSID as $ssid)
390
+            $S['add'][$ssid] = 'TKIP';
391 391
     }
392 392
     if(isset($this->attributes['media:remove_SSID'])) {
393
-      $SSID = $this->attributes['media:remove_SSID'];
394
-      foreach($SSID as $ssid)
395
-         $S['del'][$ssid] = 'DEL';
393
+        $SSID = $this->attributes['media:remove_SSID'];
394
+        foreach($SSID as $ssid)
395
+            $S['del'][$ssid] = 'DEL';
396 396
     }
397 397
     return $S;
398
-  }
398
+    }
399 399
 
400
-  private function getConsortia() {
401
-      $OIs = [];
402
-      $OIs = array_merge($OIs, Config::$CONSORTIUM['interworking-consortium-oi']);
403
-      if (isset($this->attributes['media:consortium_OI']))
404
-          foreach ($this->attributes['media:consortium_OI'] as $new_oi)
400
+    private function getConsortia() {
401
+        $OIs = [];
402
+        $OIs = array_merge($OIs, Config::$CONSORTIUM['interworking-consortium-oi']);
403
+        if (isset($this->attributes['media:consortium_OI']))
404
+            foreach ($this->attributes['media:consortium_OI'] as $new_oi)
405 405
             $OIs[] = $new_oi;
406
-      return $OIs;
407
-  }
406
+        return $OIs;
407
+    }
408 408
   
409
-  /**
410
-   * An array with shorthand definitions for MIME types
411
-   * @var array
412
-   */
413
-  private $mime_extensions = [
414
-     'text/plain' => 'txt',
415
-     'text/rtf' => 'rtf',
416
-     'application/pdf' =>'pdf',
417
-  ];
418
-
419
-  private function saveLogoFile($Logos) {
409
+    /**
410
+     * An array with shorthand definitions for MIME types
411
+     * @var array
412
+     */
413
+    private $mime_extensions = [
414
+        'text/plain' => 'txt',
415
+        'text/rtf' => 'rtf',
416
+        'application/pdf' =>'pdf',
417
+    ];
418
+
419
+    private function saveLogoFile($Logos) {
420 420
     $i=0;
421 421
     $returnarray= [];
422 422
     foreach ($Logos as $blob) {
423
-      $finfo = new finfo(FILEINFO_MIME_TYPE);
424
-      $mime = $finfo->buffer($blob);
425
-      if(preg_match('/^image\/(.*)/',$mime,$m))
423
+        $finfo = new finfo(FILEINFO_MIME_TYPE);
424
+        $mime = $finfo->buffer($blob);
425
+        if(preg_match('/^image\/(.*)/',$mime,$m))
426 426
         $ext = $m[1];
427
-      else
427
+        else
428 428
         $ext = 'unsupported';
429
-      debug(4,"saveLogoFile: $mime : $ext\n");
430
-      $f_name = 'logo-'.$i.'.'.$ext;
431
-      $f = fopen($f_name,"w");
432
-      if(! $f) {
433
-          debug(2,"saveLogoFile failed for: $f_name\n");
434
-          die("problem opening the file\n");
435
-      }
436
-      fwrite($f,$blob);
437
-      fclose($f);
438
-      $returnarray[]= ['name'=>$f_name,'mime'=>$ext];
439
-      $i++;
429
+        debug(4,"saveLogoFile: $mime : $ext\n");
430
+        $f_name = 'logo-'.$i.'.'.$ext;
431
+        $f = fopen($f_name,"w");
432
+        if(! $f) {
433
+            debug(2,"saveLogoFile failed for: $f_name\n");
434
+            die("problem opening the file\n");
435
+        }
436
+        fwrite($f,$blob);
437
+        fclose($f);
438
+        $returnarray[]= ['name'=>$f_name,'mime'=>$ext];
439
+        $i++;
440 440
     }
441 441
     return($returnarray);
442
-  }
442
+    }
443 443
 
444 444
 
445
-  private function saveInfoFile($blob) {
445
+    private function saveInfoFile($blob) {
446 446
     $finfo = new finfo(FILEINFO_MIME_TYPE);
447 447
     $mime = $finfo->buffer($blob);
448 448
     $ext = isset($this->mime_extensions[$mime]) ? $this->mime_extensions[$mime] : 'usupported';
@@ -452,43 +452,43 @@  discard block
 block discarded – undo
452 452
     fwrite($f,$blob);
453 453
     fclose($f);
454 454
     return(['name'=>'local-info.'.$ext,'mime'=>$ext]);
455
-  }
456
-
457
-  private function getProfileAttributes(Profile $profile) {
458
-     $eaps = $profile->getEapMethodsinOrderOfPreference(1);
459
-     if($eap = $this->getPreferredEapType($eaps)) {
460
-          $a = $profile->getCollapsedAttributes($eap);
461
-          $a['eap'] = $eap;
462
-          $a['all_eaps'] = $eaps;
463
-          return($a);
464
-     } else {
465
-       error("No supported eap types found for this profile.");
466
-       return(FALSE);
467
-  }
468
-  }
455
+    }
456
+
457
+    private function getProfileAttributes(Profile $profile) {
458
+        $eaps = $profile->getEapMethodsinOrderOfPreference(1);
459
+        if($eap = $this->getPreferredEapType($eaps)) {
460
+            $a = $profile->getCollapsedAttributes($eap);
461
+            $a['eap'] = $eap;
462
+            $a['all_eaps'] = $eaps;
463
+            return($a);
464
+        } else {
465
+        error("No supported eap types found for this profile.");
466
+        return(FALSE);
467
+    }
468
+    }
469 469
 /**
470
-  * dumps attributes for debugging purposes
471
-  *
472
-  * dumpAttibutes method is supplied for debuging purposes, it simply dumps the attribute array
473
-  * to a file with name passed in the attribute.
474
-  * @param string $file the output file name
475
-  */
476
-  protected function dumpAttibutes($file) {
470
+     * dumps attributes for debugging purposes
471
+     *
472
+     * dumpAttibutes method is supplied for debuging purposes, it simply dumps the attribute array
473
+     * to a file with name passed in the attribute.
474
+     * @param string $file the output file name
475
+     */
476
+    protected function dumpAttibutes($file) {
477 477
         ob_start();
478 478
         print_r($this->attributes);
479 479
         $output = ob_get_clean();
480 480
         $f = fopen($file,"w");
481 481
         fwrite($f,$output);
482 482
         fclose($f);
483
-  }
483
+    }
484 484
 /** 
485
- * placeholder for the main device method
486
- *
487
- */
485
+     * placeholder for the main device method
486
+     *
487
+     */
488 488
 
489
-  protected function writeInstaller() {
490
-     return("download path");
491
-  }
489
+    protected function writeInstaller() {
490
+        return("download path");
491
+    }
492 492
 
493 493
 /**
494 494
  * Array passing all options to the device module.
@@ -522,75 +522,75 @@  discard block
 block discarded – undo
522 522
  * @see X509::processCertificate()
523 523
  * @var array $attributes
524 524
  */
525
-  public $attributes;
525
+    public $attributes;
526 526
 /**
527
-  * stores the path to the module source location and is used 
528
-  * by copyFile and translateFile
529
-  * the only reason for it to be a public variable ies that it is set by the DeviceFactory class
530
-  * module_path should not be used by module drivers.
531
-  * @var string 
532
-  */
533
-  public $module_path;
527
+     * stores the path to the module source location and is used 
528
+     * by copyFile and translateFile
529
+     * the only reason for it to be a public variable ies that it is set by the DeviceFactory class
530
+     * module_path should not be used by module drivers.
531
+     * @var string 
532
+     */
533
+    public $module_path;
534 534
 
535 535
 /**
536 536
  * The optimal EAP type
537 537
  *
538 538
  */ 
539 539
 /**
540
-  * optimal EAP method selected given profile and device
541
-  * @var EAP::constant
542
-  */
543
-  public $selected_eap;
540
+ * optimal EAP method selected given profile and device
541
+ * @var EAP::constant
542
+ */
543
+    public $selected_eap;
544 544
 /**
545
-  * the path to the profile signing program
546
-  * device modules which require signing should use this property to exec the signer
547
-  * the signer program must accept two arguments - input and output file names
548
-  * the signer program mus operate in the local directory and filenames are relative to this
549
-  * directory
550
-  *
551
-  *@var string
552
-  */
553
-  public $sign;
554
-  public $signer;
545
+     * the path to the profile signing program
546
+     * device modules which require signing should use this property to exec the signer
547
+     * the signer program must accept two arguments - input and output file names
548
+     * the signer program mus operate in the local directory and filenames are relative to this
549
+     * directory
550
+     *
551
+     *@var string
552
+     */
553
+    public $sign;
554
+    public $signer;
555 555
 /**
556
- * the string referencing the language (index ot the Config::$LANGUAGES array).
557
- * It is set to the current language and may be used by the device module to
558
- * set its language
559
- *
560
- *@var string
561
- */
562
-  public $lang_index;
563
-  /**
564
-   * The string identifier of the device (don't show this to users)
565
-   * @var string
566
-   */
567
-  public $device_id;
568
-
569
-  /**
570
-   * See devices-template.php for a list of available options
571
-   * @var array
572
-   */
573
-  public $options;
574
-
575
-  /**
576
-   * This string will be shown if no support email was configured by the admin
577
-   * 
578
-   * @var string 
579
-   */
580
-  public static $support_email_substitute;
581
-
582
-  /**
583
-   * This string will be shown if no support URL was configured by the admin
584
-   * 
585
-   * @var string 
586
-   */
587
-  public static $support_url_substitute;
588
-
589
-  /**
590
-   * This string should be used by all installer modules to set the 
591
-   * installer file basename.
592
-   *
593
-   * @var string 
594
-   */
595
-  public static $installerBasename;
556
+     * the string referencing the language (index ot the Config::$LANGUAGES array).
557
+     * It is set to the current language and may be used by the device module to
558
+     * set its language
559
+     *
560
+     *@var string
561
+     */
562
+    public $lang_index;
563
+    /**
564
+     * The string identifier of the device (don't show this to users)
565
+     * @var string
566
+     */
567
+    public $device_id;
568
+
569
+    /**
570
+     * See devices-template.php for a list of available options
571
+     * @var array
572
+     */
573
+    public $options;
574
+
575
+    /**
576
+     * This string will be shown if no support email was configured by the admin
577
+     * 
578
+     * @var string 
579
+     */
580
+    public static $support_email_substitute;
581
+
582
+    /**
583
+     * This string will be shown if no support URL was configured by the admin
584
+     * 
585
+     * @var string 
586
+     */
587
+    public static $support_url_substitute;
588
+
589
+    /**
590
+     * This string should be used by all installer modules to set the 
591
+     * installer file basename.
592
+     *
593
+     * @var string 
594
+     */
595
+    public static $installerBasename;
596 596
 }
Please login to merge, or discard this patch.
web/basic.php 1 patch
Indentation   +268 added lines, -268 removed lines patch added patch discarded remove patch
@@ -23,23 +23,23 @@  discard block
 block discarded – undo
23 23
 debug(4,$_POST);
24 24
 
25 25
 /**
26
-  * SimpleGUI defines extensions of the GUI class used only in the simple interface
27
-  * this class does not define its own constructor.
28
-  */
26
+ * SimpleGUI defines extensions of the GUI class used only in the simple interface
27
+ * this class does not define its own constructor.
28
+ */
29 29
 class SimpleGUI extends UserAPI {
30 30
 
31 31
 /**
32
-  *  create the SimpleGUI object calling CAT constructor first
33
-  *
34
-  *  sets up all public prperties of the object
35
-  */
32
+ *  create the SimpleGUI object calling CAT constructor first
33
+ *
34
+ *  sets up all public prperties of the object
35
+ */
36 36
 public function __construct() {
37
-  parent::__construct();
38
-  $this->Args = [];
39
-  $this->page =  0;
40
-  $this->set_locale('core');
41
-  $this->version = 2;
42
-  $this->Args['lang'] = CAT::get_lang();
37
+    parent::__construct();
38
+    $this->Args = [];
39
+    $this->page =  0;
40
+    $this->set_locale('core');
41
+    $this->version = 2;
42
+    $this->Args['lang'] = CAT::get_lang();
43 43
 //print "<pre>"; print_r($_REQUEST); print "</pre>";
44 44
 
45 45
 /*
@@ -50,24 +50,24 @@  discard block
 block discarded – undo
50 50
 
51 51
 
52 52
     if(isset($_REQUEST['reset_dev']) && $_REQUEST['reset_dev'] == 1)
53
-      unset($_REQUEST['device']);
53
+        unset($_REQUEST['device']);
54 54
 
55 55
 /* Start with checking if we have the country code if not then use geolocation..
56 56
 */
57 57
     $F = array_keys($this->printCountryList(1));
58 58
     if(isset($_REQUEST['country']) && $_REQUEST['country']) {
59
-       $c = strtoupper($_REQUEST['country']);
59
+        $c = strtoupper($_REQUEST['country']);
60 60
     } else {
61
-       $L = $this->locateUser();
62
-       if( $L['status'] == 'ok' ) {
63
-         $c = strtoupper($L['country']);
64
-       } else {
65
-         debug(2, "No coutry provided and unable to locate the address\n");
66
-         $c='NONE';
67
-       }
61
+        $L = $this->locateUser();
62
+        if( $L['status'] == 'ok' ) {
63
+            $c = strtoupper($L['country']);
64
+        } else {
65
+            debug(2, "No coutry provided and unable to locate the address\n");
66
+            $c='NONE';
67
+        }
68 68
     }
69 69
     if(!in_array($c,$F))
70
-      $c= array_shift($F);
70
+        $c= array_shift($F);
71 71
     $this->Country = new Federation($c);
72 72
     $this->Args['country'] = $this->Country->name;
73 73
     $this->page =  1;
@@ -79,287 +79,287 @@  discard block
 block discarded – undo
79 79
 // and they do not match then drop the profile code and just leave the IdP
80 80
 
81 81
     if(isset($_REQUEST['idp']) && $_REQUEST['idp']) {
82
-       $this->page =  2;
83
-       try {
84
-         $this->Idp = new IdP($_REQUEST['idp']);
85
-       }
86
-       catch (Exception $fail) {
87
-         $this->page =  1;
88
-         $this->set_locale("web_user");
89
-         return;
90
-       }
91
-       $country_tmp = new Federation($this->Idp->federation);
92
-       if(strtoupper($this->Country->name) !== strtoupper($country_tmp->name)) {
93
-         unset($this->Idp);
94
-         $this->page = 1;
95
-         $this->set_locale("web_user");
96
-         return;
97
-       } 
98
-       $this->Args['idp'] = $_REQUEST['idp'];
99
-       $this->profile_count = $this->Idp->profileCount();
100
-       if(!isset($_REQUEST['profile'])) {
101
-         $this->set_locale("web_user");
102
-         return;
103
-       }
104
-       $this->page =  3;
105
-       try {
106
-         $this->Profile = new Profile($_REQUEST['profile']);
107
-       }
108
-       catch (Exception $fail) {
109
-         $this->page =  2;
110
-         $this->set_locale("web_user");
111
-         return;
112
-       }
113
-       if($this->Profile->institution != $this->Idp->identifier)  {
114
-          unset($this->Profile);
115
-          $this->page = 2;
116
-          $this->set_locale("web_user");
117
-          return;
118
-       }
119
-       $this->Args['profile'] = $_REQUEST['profile'];
120
-       if(isset($_REQUEST['device'])) {
121
-             $this->Args['device'] = $_REQUEST['device'];
122
-       }
82
+        $this->page =  2;
83
+        try {
84
+            $this->Idp = new IdP($_REQUEST['idp']);
85
+        }
86
+        catch (Exception $fail) {
87
+            $this->page =  1;
88
+            $this->set_locale("web_user");
89
+            return;
90
+        }
91
+        $country_tmp = new Federation($this->Idp->federation);
92
+        if(strtoupper($this->Country->name) !== strtoupper($country_tmp->name)) {
93
+            unset($this->Idp);
94
+            $this->page = 1;
95
+            $this->set_locale("web_user");
96
+            return;
97
+        } 
98
+        $this->Args['idp'] = $_REQUEST['idp'];
99
+        $this->profile_count = $this->Idp->profileCount();
100
+        if(!isset($_REQUEST['profile'])) {
101
+            $this->set_locale("web_user");
102
+            return;
103
+        }
104
+        $this->page =  3;
105
+        try {
106
+            $this->Profile = new Profile($_REQUEST['profile']);
107
+        }
108
+        catch (Exception $fail) {
109
+            $this->page =  2;
110
+            $this->set_locale("web_user");
111
+            return;
112
+        }
113
+        if($this->Profile->institution != $this->Idp->identifier)  {
114
+            unset($this->Profile);
115
+            $this->page = 2;
116
+            $this->set_locale("web_user");
117
+            return;
118
+        }
119
+        $this->Args['profile'] = $_REQUEST['profile'];
120
+        if(isset($_REQUEST['device'])) {
121
+                $this->Args['device'] = $_REQUEST['device'];
122
+        }
123 123
 
124 124
     }
125 125
 //print "<pre>"; print_r($_REQUEST); print "</pre>";
126
-   $this->set_locale("web_user");
126
+    $this->set_locale("web_user");
127 127
 }
128 128
 
129 129
 // print coutry selection
130 130
 public function listCountries() {
131
-   $out = '';
132
-   $FED = $this->printCountryList(1);
133
-   $out .= _('Select your country').'<br>';
134
-   $out .= '<select name="country" onchange="submit_form(this)">'."\n";
135
-   foreach ($FED as $f => $F) {
136
-     $out .= '<option value="'.$f.'"';
137
-     if($f === $this->Country->name)
138
-         $out .= ' selected';
139
-     $out .= '>'.$F.'</option>'."\n";
140
-   }
141
-   $out .= '</select>';
142
-   return $out;
131
+    $out = '';
132
+    $FED = $this->printCountryList(1);
133
+    $out .= _('Select your country').'<br>';
134
+    $out .= '<select name="country" onchange="submit_form(this)">'."\n";
135
+    foreach ($FED as $f => $F) {
136
+        $out .= '<option value="'.$f.'"';
137
+        if($f === $this->Country->name)
138
+            $out .= ' selected';
139
+        $out .= '>'.$F.'</option>'."\n";
140
+    }
141
+    $out .= '</select>';
142
+    return $out;
143 143
 }
144 144
 
145 145
 public function listIdPs() {
146
-   $Inst = $this->orderIdentityProviders($this->Country->name);
147
-   if(! isset($this->Idp))
148
-     $this->Idp = new Idp ($Inst[0]['idp']);
149
-   $i_id = $this->Idp->identifier;
150
-   $out = '';
151
-   $out .= _("Select your institution");
152
-   $out .= '<select name="idp" onchange="submit_form(this)">';
153
-   foreach ($Inst as $I) {
154
-      $out .= '<option value="'.$I['idp'].'"';
155
-      if($I['idp'] == $i_id)
156
-         $out .= ' selected';
157
-      $out .= '>'.$I['title'].'</option>';
158
-   }
159
-   $out .= '</select>'; 
160
-   return $out;
146
+    $Inst = $this->orderIdentityProviders($this->Country->name);
147
+    if(! isset($this->Idp))
148
+        $this->Idp = new Idp ($Inst[0]['idp']);
149
+    $i_id = $this->Idp->identifier;
150
+    $out = '';
151
+    $out .= _("Select your institution");
152
+    $out .= '<select name="idp" onchange="submit_form(this)">';
153
+    foreach ($Inst as $I) {
154
+        $out .= '<option value="'.$I['idp'].'"';
155
+        if($I['idp'] == $i_id)
156
+            $out .= ' selected';
157
+        $out .= '>'.$I['title'].'</option>';
158
+    }
159
+    $out .= '</select>'; 
160
+    return $out;
161 161
 }
162 162
 
163 163
 public function listProfiles() {
164
-   $Prof = $this->Idp->listProfiles(1);
165
-   if(! isset($this->Profile))
166
-     $this->Profile = $Prof[0];
167
-   $p_id = $this->Profile->identifier;
168
-   $this->Args['profile'] = $p_id;
169
-   $out = '';
170
-   if (count($Prof) > 1) {
171
-     $out .=  _("Select the user group").'<br>';
172
-     $out .= '<select name="profile" onchange="submit_form(this)">';
173
-     foreach ($Prof as $P) {
174
-       $out .= '<option value="'.$P->identifier.'"';
175
-       if($P->identifier == $p_id)
176
-         $out .= ' selected';
177
-       $out .= '>'.$P->name.'</option>';
178
-     }
179
-     $out .= '</select>';
180
-   } else {
181
-     $out .= $this->passArgument('profile');
182
-   }
183
-   return $out;
164
+    $Prof = $this->Idp->listProfiles(1);
165
+    if(! isset($this->Profile))
166
+        $this->Profile = $Prof[0];
167
+    $p_id = $this->Profile->identifier;
168
+    $this->Args['profile'] = $p_id;
169
+    $out = '';
170
+    if (count($Prof) > 1) {
171
+        $out .=  _("Select the user group").'<br>';
172
+        $out .= '<select name="profile" onchange="submit_form(this)">';
173
+        foreach ($Prof as $P) {
174
+        $out .= '<option value="'.$P->identifier.'"';
175
+        if($P->identifier == $p_id)
176
+            $out .= ' selected';
177
+        $out .= '>'.$P->name.'</option>';
178
+        }
179
+        $out .= '</select>';
180
+    } else {
181
+        $out .= $this->passArgument('profile');
182
+    }
183
+    return $out;
184 184
 }
185 185
 
186 186
 
187 187
 
188 188
 public function listDevices() {
189
-   if(! isset($this->Profile))
190
-      return '';
191
-   $OS = $this->detectOS();
192
-   $os = $OS['device'];
193
-   $this->Args['device'] = $os;
194
-   $profile_redirect = 0;
195
-   $redirect_target = '';
196
-   $device_redirects = '';
197
-   $selected_os = 0;
198
-   $unsupported_message = '<div id="unsupported_os">'._("Your operating system was not properly detected, is not supported yet or cannot be configured with settings provided by your institution")."</div><br>";
189
+    if(! isset($this->Profile))
190
+        return '';
191
+    $OS = $this->detectOS();
192
+    $os = $OS['device'];
193
+    $this->Args['device'] = $os;
194
+    $profile_redirect = 0;
195
+    $redirect_target = '';
196
+    $device_redirects = '';
197
+    $selected_os = 0;
198
+    $unsupported_message = '<div id="unsupported_os">'._("Your operating system was not properly detected, is not supported yet or cannot be configured with settings provided by your institution")."</div><br>";
199 199
    
200
-   $a = $this->profileAttributes($this->Profile->identifier);
201
-   $thedevices = $a['devices'];
202
-   $message = '';
203
-   if(! $os)
204
-     $message = $unsupported_message;
205
-   $out = _("Choose an installer to download").'<br>';
206
-   $out .= '<select name="device" onchange="set_device(this)">';
207
-   $i= 0;
208
-   foreach ($thedevices as $D) {
209
-      if((isset($D['options']) && isset($D['options']['hidden']) &&  $D['options']['hidden']) || $D['status'] )
210
-         continue; 
211
-      if(! $os)
212
-         $os = $D['id'];
213
-      $disp = $D['display'];
214
-      if($D['id'] === '0') {
200
+    $a = $this->profileAttributes($this->Profile->identifier);
201
+    $thedevices = $a['devices'];
202
+    $message = '';
203
+    if(! $os)
204
+        $message = $unsupported_message;
205
+    $out = _("Choose an installer to download").'<br>';
206
+    $out .= '<select name="device" onchange="set_device(this)">';
207
+    $i= 0;
208
+    foreach ($thedevices as $D) {
209
+        if((isset($D['options']) && isset($D['options']['hidden']) &&  $D['options']['hidden']) || $D['status'] )
210
+            continue; 
211
+        if(! $os)
212
+            $os = $D['id'];
213
+        $disp = $D['display'];
214
+        if($D['id'] === '0') {
215 215
         $profile_redirect = 1;
216 216
         $redirect_target = $D['redirect'];
217
-      }
218
-      $out .= '<option value="'.$D['id'].'"';
219
-      if($D['id'] == $os) {
217
+        }
218
+        $out .= '<option value="'.$D['id'].'"';
219
+        if($D['id'] == $os) {
220 220
         $out .= ' selected';
221 221
         $selected_os = 1;
222 222
         if($D['redirect']) {
223
-           $redirect_target = $D['redirect'];
223
+            $redirect_target = $D['redirect'];
224
+        }
224 225
         }
225
-      }
226
-      $out .= '>'.$disp.'</option>';
227
-      $device_redirects .= 'redirects['.$i.'] = '.( $D['redirect'] ? 1 : 0 ).';';
228
-      $i++;
229
-   }
230
-   $out .= '</select>';
231
-   if( $selected_os == 0)
232
-      $message = $unsupported_message;
233
-   $out = $message . $out;
234
-   if($profile_redirect)
235
-      $out = '';
236
-   if($redirect_target) {
237
-      $device_redirects .= 'is_redirected = 1;';
238
-      $out .= _("Your local administrator has specified a redirect to a local support page.").'<br>'. _("When you click <b>CONTINUE</b> this support page will be opened.");
239
-      $action = 'window.location.href=\''.$redirect_target.'\'; return(false);';
240
-   $out .= "<p><button id='devices' name='devices' style='width:100%;' onclick=\"".$action.'">'._("CONTINUE to local support page")."</button>";
241
-   } else {
242
-      $device_redirects .= 'is_redirected = 0;';
243
-      $action = 'submit_form(this)';
244
-   $out .= "<p><button id='devices' name='devices' style='width:100%;' onclick=\"".$action.'">'._("Do you have an account at this institution?").'<br>'._("If so and if the other settings above are OK then click here to download...")."</button>";
245
-   }
246
-   $out .= '<script type="text/javascript">'.$device_redirects.'</script>';
247
-   return $out;
226
+        $out .= '>'.$disp.'</option>';
227
+        $device_redirects .= 'redirects['.$i.'] = '.( $D['redirect'] ? 1 : 0 ).';';
228
+        $i++;
229
+    }
230
+    $out .= '</select>';
231
+    if( $selected_os == 0)
232
+        $message = $unsupported_message;
233
+    $out = $message . $out;
234
+    if($profile_redirect)
235
+        $out = '';
236
+    if($redirect_target) {
237
+        $device_redirects .= 'is_redirected = 1;';
238
+        $out .= _("Your local administrator has specified a redirect to a local support page.").'<br>'. _("When you click <b>CONTINUE</b> this support page will be opened.");
239
+        $action = 'window.location.href=\''.$redirect_target.'\'; return(false);';
240
+    $out .= "<p><button id='devices' name='devices' style='width:100%;' onclick=\"".$action.'">'._("CONTINUE to local support page")."</button>";
241
+    } else {
242
+        $device_redirects .= 'is_redirected = 0;';
243
+        $action = 'submit_form(this)';
244
+    $out .= "<p><button id='devices' name='devices' style='width:100%;' onclick=\"".$action.'">'._("Do you have an account at this institution?").'<br>'._("If so and if the other settings above are OK then click here to download...")."</button>";
245
+    }
246
+    $out .= '<script type="text/javascript">'.$device_redirects.'</script>';
247
+    return $out;
248 248
 }
249 249
 
250 250
 public function displayDeviceDownload() {
251
-   $this->set_locale('devices');
252
-   $a = $this->profileAttributes($this->Profile->identifier);
253
-   $thedevices = $a['devices'];
254
-   $this->set_locale("web_user");
255
-   $out = '';
256
-   if(isset($a['description']) && $a['description'])
257
-     print '<div>'.$a['description'] . '</div>';
258
-   if (isset($a['local_email']) && $a['local_email'])
259
-     $out .= '<p>Email: <a href="mailto:' . $a['local_email'] . '">' . $a['local_email'] . '</a>';
260
-   if (isset($a['local_url']) && $a['local_url'])
261
-     $out .= '<p>WWW: <a href="' . $a['local_url'] . '">' . $a['local_url'] . '</a>';
262
-   if (isset($a['local_phone']) && $a['local_phone'])
263
-     $out .= '<p>Tel: <a href="' . $a['local_phone'] . '">' . $a['local_phone'] . '</a>';
264
-   if( $out !== '') {
265
-     print '<div class="user_info">';
266
-     print _("If you encounter problems you should ask for help at your home institution");
267
-     print $out;
268
-     print "</div>\n";
269
-   }
251
+    $this->set_locale('devices');
252
+    $a = $this->profileAttributes($this->Profile->identifier);
253
+    $thedevices = $a['devices'];
254
+    $this->set_locale("web_user");
255
+    $out = '';
256
+    if(isset($a['description']) && $a['description'])
257
+        print '<div>'.$a['description'] . '</div>';
258
+    if (isset($a['local_email']) && $a['local_email'])
259
+        $out .= '<p>Email: <a href="mailto:' . $a['local_email'] . '">' . $a['local_email'] . '</a>';
260
+    if (isset($a['local_url']) && $a['local_url'])
261
+        $out .= '<p>WWW: <a href="' . $a['local_url'] . '">' . $a['local_url'] . '</a>';
262
+    if (isset($a['local_phone']) && $a['local_phone'])
263
+        $out .= '<p>Tel: <a href="' . $a['local_phone'] . '">' . $a['local_phone'] . '</a>';
264
+    if( $out !== '') {
265
+        print '<div class="user_info">';
266
+        print _("If you encounter problems you should ask for help at your home institution");
267
+        print $out;
268
+        print "</div>\n";
269
+    }
270 270
                    
271
-   foreach ($thedevices as $D) {
272
-      if(isset($D['options']) && isset($D['options']['hidden']) &&  $D['options']['hidden'])
273
-          continue; 
274
-      $disp = $D['display'];
275
-      if($D['id'] === '0') {
276
-          print _("Your local administrator has specified a redirect to a local support page.").' '. _("Click on the link below to continue.");
277
-          print '<div style="width:100%; text-align:center"><a href ="'.$D['redirect'].'">'.$D['redirect'].'</a></div>';
278
-          exit;
279
-      }
280
-      if($D['id'] === $this->Args['device']) 
281
-          break;
282
-   }
283
-   $this->set_locale("web_user");
284
-
285
-   $o = $this->generateInstaller($this->Args['device'], $this->Profile->identifier);
286
-   if (!$o['link']) {
287
-      print _("This is embarrassing. Generation of your installer failed. System admins have been notified. We will try to take care of the problem as soon as possible.");
288
-      return;
289
-   }
290
-   $extra_text = '';
291
-   if(isset($D['message']) && $D['message']) 
292
-      $extra_text = $D['message']; 
293
-   if(isset($D['device_customtext']) && $D['device_customtext']) {
294
-      if($extra_text)
295
-           $extra_text .= '<p>';
296
-      $extra_text = $D['device_customtext']; 
271
+    foreach ($thedevices as $D) {
272
+        if(isset($D['options']) && isset($D['options']['hidden']) &&  $D['options']['hidden'])
273
+            continue; 
274
+        $disp = $D['display'];
275
+        if($D['id'] === '0') {
276
+            print _("Your local administrator has specified a redirect to a local support page.").' '. _("Click on the link below to continue.");
277
+            print '<div style="width:100%; text-align:center"><a href ="'.$D['redirect'].'">'.$D['redirect'].'</a></div>';
278
+            exit;
279
+        }
280
+        if($D['id'] === $this->Args['device']) 
281
+            break;
282
+    }
283
+    $this->set_locale("web_user");
284
+
285
+    $o = $this->generateInstaller($this->Args['device'], $this->Profile->identifier);
286
+    if (!$o['link']) {
287
+        print _("This is embarrassing. Generation of your installer failed. System admins have been notified. We will try to take care of the problem as soon as possible.");
288
+        return;
297 289
     }
298
-   if(isset($D['eap_customtext']) && $D['eap_customtext']) {
299
-      if($extra_text)
300
-          $extra_text .= '<p>';
301
-      $extra_text .= $D['eap_customtext']; 
290
+    $extra_text = '';
291
+    if(isset($D['message']) && $D['message']) 
292
+        $extra_text = $D['message']; 
293
+    if(isset($D['device_customtext']) && $D['device_customtext']) {
294
+        if($extra_text)
295
+            $extra_text .= '<p>';
296
+        $extra_text = $D['device_customtext']; 
302 297
     }
303
-   if($extra_text)
304
-      $extra_text .= '<p>';
305
-      print $extra_text;
298
+    if(isset($D['eap_customtext']) && $D['eap_customtext']) {
299
+        if($extra_text)
300
+            $extra_text .= '<p>';
301
+        $extra_text .= $D['eap_customtext']; 
302
+    }
303
+    if($extra_text)
304
+        $extra_text .= '<p>';
305
+        print $extra_text;
306 306
 
307
-      $download_link = 'user/API.php?action=downloadInstaller&api_version=2&generatedfor=user&lang='.CAT::get_lang().'&device='.$o['device'].'&profile='.$o['profile'];
307
+        $download_link = 'user/API.php?action=downloadInstaller&api_version=2&generatedfor=user&lang='.CAT::get_lang().'&device='.$o['device'].'&profile='.$o['profile'];
308 308
 
309
-      print '<p><button id="download_button" onclick="window.location.href=\'' . rtrim(dirname($_SERVER['SCRIPT_NAME']),'/'). '/' . $download_link . '\'; return(false)"><div>' . _("Download installer for") . '<br><span style="color:yellow; font-weight: bold">' . $D['display']. '</span></div></button>';
309
+        print '<p><button id="download_button" onclick="window.location.href=\'' . rtrim(dirname($_SERVER['SCRIPT_NAME']),'/'). '/' . $download_link . '\'; return(false)"><div>' . _("Download installer for") . '<br><span style="color:yellow; font-weight: bold">' . $D['display']. '</span></div></button>';
310 310
 
311
-      print '<p><button id="start_over" name="start_over" onclick="submit_form(this)">'._("Start over").'</button>';
312
-   print $this->passArgument('country');
313
-   print $this->passArgument('idp');
314
-   print $this->passArgument('profile');
315
-   print $this->passArgument('device');
311
+        print '<p><button id="start_over" name="start_over" onclick="submit_form(this)">'._("Start over").'</button>';
312
+    print $this->passArgument('country');
313
+    print $this->passArgument('idp');
314
+    print $this->passArgument('profile');
315
+    print $this->passArgument('device');
316 316
 }
317 317
 
318 318
 
319 319
 
320 320
 public function langSelection() {
321
-   $out = _("View this page in")." ";
322
-   $out .= '<select onchange="submit_form(this)" name="lang">';
323
-   foreach (Config::$LANGUAGES as $lng => $value) {
324
-       $out .= '<option value="'.$lng.'"';
325
-       if ($lng === CAT::get_lang())
326
-          $out .= ' selected';
327
-       $out .= '>'. $value['display'] . '</option>';
328
-   }
329
-   $out .= '</select>';
330
-   return $out;
321
+    $out = _("View this page in")." ";
322
+    $out .= '<select onchange="submit_form(this)" name="lang">';
323
+    foreach (Config::$LANGUAGES as $lng => $value) {
324
+        $out .= '<option value="'.$lng.'"';
325
+        if ($lng === CAT::get_lang())
326
+            $out .= ' selected';
327
+        $out .= '>'. $value['display'] . '</option>';
328
+    }
329
+    $out .= '</select>';
330
+    return $out;
331 331
 }
332 332
 
333 333
 /**
334
-  * displays the navigation bar showing the current location of the page
335
-  */
334
+ * displays the navigation bar showing the current location of the page
335
+ */
336 336
 
337 337
 public function yourChoice() {
338
-  $out = '';
339
-   $c = strtoupper($this->Country->name);
340
-   $name = isset(Federation::$federationList[$c]) ? Federation::$federationList[$c] : $c;
341
-   $name = preg_replace('/ +/','&nbsp;',$name);
342
-   $out .= "$name; ";
343
-   $name = $this->Idp->name;
344
-   $name = preg_replace('/ +/','&nbsp;',$name);
345
-   $out .= "$name";
346
-   if($this->profile_count > 1) {
347
-     $name = '; '.$this->Profile->name;
348
-     $name = preg_replace('/ +/','&nbsp;',$name);
349
-     $out .= "$name";
350
-   }
351
-  return $out;
338
+    $out = '';
339
+    $c = strtoupper($this->Country->name);
340
+    $name = isset(Federation::$federationList[$c]) ? Federation::$federationList[$c] : $c;
341
+    $name = preg_replace('/ +/','&nbsp;',$name);
342
+    $out .= "$name; ";
343
+    $name = $this->Idp->name;
344
+    $name = preg_replace('/ +/','&nbsp;',$name);
345
+    $out .= "$name";
346
+    if($this->profile_count > 1) {
347
+        $name = '; '.$this->Profile->name;
348
+        $name = preg_replace('/ +/','&nbsp;',$name);
349
+        $out .= "$name";
350
+    }
351
+    return $out;
352 352
 }
353 353
 
354 354
 /**
355
-  * returns the navigation link to a given GUI page
356
-  * @param int $new_page new page number
357
-  * @param string $text link text
358
-  * @return string
359
-  */
355
+ * returns the navigation link to a given GUI page
356
+ * @param int $new_page new page number
357
+ * @param string $text link text
358
+ * @return string
359
+ */
360 360
 
361 361
 public function passArgument($arg_name) {
362
-   return '<input type="hidden" name="'.$arg_name.'" value="'.$this->Args[$arg_name].'">';
362
+    return '<input type="hidden" name="'.$arg_name.'" value="'.$this->Args[$arg_name].'">';
363 363
 }
364 364
 
365 365
 public $Country;
@@ -422,24 +422,24 @@  discard block
 block discarded – undo
422 422
         print $Gui->langSelection();
423 423
         if(! isset($_REQUEST['devices_h']) || $_REQUEST['devices_h'] == 0 || isset($_REQUEST['start_over'])) {
424 424
         print "<p>\n";
425
-          print $Gui->listCountries();
426
-          if($Gui->page == 2 && ! isset($FED[strtoupper($Gui->Country->name)]))
427
-             $Gui->page = 1;
428
-          print "<p>".$Gui->listIdPs();
429
-          print "<p>".$Gui->listProfiles();
430
-          print "<p>".$Gui->listDevices();
431
-          print '<input type="hidden" name="devices_h" id="devices_h" value="0">';
425
+            print $Gui->listCountries();
426
+            if($Gui->page == 2 && ! isset($FED[strtoupper($Gui->Country->name)]))
427
+                $Gui->page = 1;
428
+            print "<p>".$Gui->listIdPs();
429
+            print "<p>".$Gui->listProfiles();
430
+            print "<p>".$Gui->listDevices();
431
+            print '<input type="hidden" name="devices_h" id="devices_h" value="0">';
432 432
 
433 433
         } else {
434
-          if($Gui->page != 3) {
435
-             print "Arguments missmatch error.";
436
-             exit;
437
-          }
434
+            if($Gui->page != 3) {
435
+                print "Arguments missmatch error.";
436
+                exit;
437
+            }
438 438
         print '<div id="user_choice">'.$Gui->yourChoice().'</div><p>';
439
-          $Gui->displayDeviceDownload();
439
+            $Gui->displayDeviceDownload();
440 440
         print '<input type="hidden" name="devices_h" id="devices_h" value="1">';
441 441
         }
442
-     ?>
442
+        ?>
443 443
       <input type="hidden" name="reset_dev" id="reset_dev" value="0">
444 444
         </form>
445 445
         <div class='footer'><hr />
Please login to merge, or discard this patch.
core/Profile.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -692,11 +692,11 @@
 block discarded – undo
692 692
                     $out[$name][0] = (isset($S[$this->langIndex])) ? $S[$this->langIndex] : $S['C'];
693 693
                 }
694 694
                 if (isset($S['en'])) {
695
-                   $out[$name][1] = $S['en'];
695
+                    $out[$name][1] = $S['en'];
696 696
                 } elseif(isset($S['C'])) {
697
-                   $out[$name][1] = $S['C'];
697
+                    $out[$name][1] = $S['C'];
698 698
                 } else {
699
-                   $out[$name][1] = $out[$name][0];
699
+                    $out[$name][1] = $out[$name][0];
700 700
                 }
701 701
             } else {
702 702
                 if (isset($temp[$name]['Method'])) {
Please login to merge, or discard this patch.