Completed
Push — master ( cc9aa9...547d73 )
by
unknown
04:54
created
core/Profile.php 7 patches
Doc Comments   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -819,6 +819,4 @@
 block discarded – undo
819 819
      * boolean value: should anonymous outer IDs be used or not?
820 820
      * @var boolean
821 821
      */
822
-    public $use_anon_outer;
823
-
824
-}
822
+    public $use_anon_outer
825 823
\ No newline at end of file
Please login to merge, or discard this patch.
Unused Use Statements   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -819,6 +819,4 @@
 block discarded – undo
819 819
      * boolean value: should anonymous outer IDs be used or not?
820 820
      * @var boolean
821 821
      */
822
-    public $use_anon_outer;
823
-
824
-}
822
+    public $use_anon_outer
825 823
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -819,6 +819,4 @@
 block discarded – undo
819 819
      * boolean value: should anonymous outer IDs be used or not?
820 820
      * @var boolean
821 821
      */
822
-    public $use_anon_outer;
823
-
824
-}
822
+    public $use_anon_outer
825 823
\ No newline at end of file
Please login to merge, or discard this patch.
Switch Indentation   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -819,6 +819,4 @@
 block discarded – undo
819 819
      * boolean value: should anonymous outer IDs be used or not?
820 820
      * @var boolean
821 821
      */
822
-    public $use_anon_outer;
823
-
824
-}
822
+    public $use_anon_outer
825 823
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +10 added lines, -12 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         // add internal attributes
127 127
         // they share many attribute properties, so condense the generation
128 128
 
129
-        $localValueIfAny = (preg_match('/@/', $this->realm) ? substr($this->realm, 0, strpos($this->realm, '@')) : "anonymous" );
129
+        $localValueIfAny = (preg_match('/@/', $this->realm) ? substr($this->realm, 0, strpos($this->realm, '@')) : "anonymous");
130 130
 
131 131
         $internalAttributes = [
132 132
             "internal:profile_count" => $idp->profileCount(),
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 
252 252
                 $temparray[] = [
253 253
                     "name" => $attributeQuery->option_name,
254
-                    "value" => ( $decodedAttribute['lang'] == "" ? $decodedAttribute['content'] : serialize($decodedAttribute)),
254
+                    "value" => ($decodedAttribute['lang'] == "" ? $decodedAttribute['content'] : serialize($decodedAttribute)),
255 255
                     "level" => "Method",
256 256
                     "row" => $attributeQuery->row,
257 257
                     "flag" => $optinfo['flag'],
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
         $escapedAttrValue = DBConnection::escape_value($this->databaseType, $attrValue);
390 390
 
391 391
         DBConnection::exec($this->databaseType, "INSERT INTO $this->entityOptionTable ($this->entityIdColumn, option_name, option_value, eap_method_id" . ($device !== 0 ? ",device_id" : "") . ") 
392
-                          VALUES(" . $this->identifier . ", '$escapedAttrName', '$escapedAttrValue', $eapType" . ($device !== 0 ? ",'" . DBConnection::escape_value($this->databaseType, $device) . "'" : "" ) . ")");
392
+                          VALUES(" . $this->identifier . ", '$escapedAttrName', '$escapedAttrValue', $eapType" . ($device !== 0 ? ",'" . DBConnection::escape_value($this->databaseType, $device) . "'" : "") . ")");
393 393
         $this->updateFreshness();
394 394
     }
395 395
     
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
      */
457 457
     public function setRealmCheckUser($shallwe, $localpart = NULL) {
458 458
         DBConnection::exec($this->databaseType, "UPDATE profile SET checkuser_outer = " . ($shallwe == true ? "1" : "0") .
459
-                ( $localpart !== NULL ? ", checkuser_value = '$localpart' " : "") .
459
+                ($localpart !== NULL ? ", checkuser_value = '$localpart' " : "") .
460 460
                 " WHERE profile_id = $this->identifier");
461 461
     }
462 462
 
@@ -688,9 +688,9 @@  discard block
 block discarded – undo
688 688
                     }
689 689
                 }
690 690
                 $out[$name]['langs'] = $S;
691
-<<<<<<< HEAD
692
-                if (isset($S[$this->lang_index]) || isset($S['C']))
693
-                    $out[$name][0] = (isset($S[$this->lang_index])) ? $S[$this->lang_index] : $S['C'];
691
+<< << <<< HEAD
692
+                if (isset($S[$this - >lang_index]) || isset($S['C']))
693
+                    $out[$name][0] = (isset($S[$this - >lang_index])) ? $S[$this - >lang_index] : $S['C'];
694 694
                 if (isset($S['en']))
695 695
                    $out[$name][1] = $S['en'];
696 696
                 elseif(isset($S['C']))
@@ -698,8 +698,8 @@  discard block
 block discarded – undo
698 698
                 else
699 699
                    $out[$name][1] = $out[$name][0];
700 700
 =======
701
-                if (isset($S[$this->langIndex]) || isset($S['C'])) {
702
-                    $out[$name][0] = (isset($S[$this->langIndex])) ? $S[$this->langIndex] : $S['C'];
701
+                if (isset($S[$this - >langIndex]) || isset($S['C'])) {
702
+                    $out[$name][0] = (isset($S[$this - >langIndex])) ? $S[$this - >langIndex] : $S['C'];
703 703
                 }
704 704
 >>>>>>> cc9aa934406bee74d39aa1556cebec9586f485e6
705 705
             } else {
@@ -819,6 +819,4 @@  discard block
 block discarded – undo
819 819
      * boolean value: should anonymous outer IDs be used or not?
820 820
      * @var boolean
821 821
      */
822
-    public $use_anon_outer;
823
-
824
-}
822
+    public $use_anon_outer
825 823
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -819,6 +819,4 @@
 block discarded – undo
819 819
      * boolean value: should anonymous outer IDs be used or not?
820 820
      * @var boolean
821 821
      */
822
-    public $use_anon_outer;
823
-
824
-}
822
+    public $use_anon_outer
825 823
\ No newline at end of file
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -819,6 +819,4 @@
 block discarded – undo
819 819
      * boolean value: should anonymous outer IDs be used or not?
820 820
      * @var boolean
821 821
      */
822
-    public $use_anon_outer;
823
-
824
-}
822
+    public $use_anon_outer
825 823
\ No newline at end of file
Please login to merge, or discard this patch.
config/config-template.php 2 patches
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.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      * pass: password for the username
171 171
      * @var array
172 172
      */
173
-    public static $MAILSETTINGS = [ // we always use Submission
173
+    public static $MAILSETTINGS = [// we always use Submission
174 174
         'host' => 'submission.capable.mta',
175 175
         'user'=> 'mailuser',
176 176
         'pass' => 'mailpass',
@@ -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
@@ -350,9 +350,9 @@  discard block
 block discarded – undo
350 350
      * NSIS version - with version 3 UTF installers will be created
351 351
      * see also $PATHS['makensis']
352 352
      */
353
-    public static $NSIS_VERSION = 2 ;
353
+    public static $NSIS_VERSION = 2;
354 354
 
355
-    public static $SUPERADMINS =  [
355
+    public static $SUPERADMINS = [
356 356
         'eptid:someuser',
357 357
         'http://sommeopenid.example/anotheruser',
358 358
         'I do not care about security!',
Please login to merge, or discard this patch.
core/DeviceConfig.php 2 patches
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.
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
      */
64 64
 
65 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);
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
 
@@ -88,50 +88,50 @@  discard block
 block discarded – undo
88 88
     * @final not to be redefined
89 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");
91
+       debug(4, "module setup start\n");
92
+       if (!$profile instanceof Profile) {
93
+          debug(2, "No profile has been set\n");
94 94
           error("No profile has been set");
95 95
           exit;
96 96
        }
97 97
        $this->attributes = $this->getProfileAttributes($profile);
98
-       if(! $this->selected_eap) {
98
+       if (!$this->selected_eap) {
99 99
           error("No EAP type specified.");
100 100
           exit;
101 101
        }
102 102
        // create temporary directory, its full path will be saved in $this->FPATH;
103 103
        $T = createTemporaryDirectory('installer');
104 104
        $this->FPATH = $T['dir'];
105
-       mkdir($T['dir'].'/tmp');
106
-       chdir($T['dir'].'/tmp');
105
+       mkdir($T['dir'] . '/tmp');
106
+       chdir($T['dir'] . '/tmp');
107 107
        $CAs = [];
108
-       if(isset($this->attributes['eap:ca_file'])) {
108
+       if (isset($this->attributes['eap:ca_file'])) {
109 109
        foreach ($this->attributes['eap:ca_file'] as $ca) {
110
-          if($c = X509::processCertificate($ca))
110
+          if ($c = X509::processCertificate($ca))
111 111
              $CAs[] = $c;
112 112
           }
113
-          $this->attributes['internal:CAs'][0]=$CAs;
113
+          $this->attributes['internal:CAs'][0] = $CAs;
114 114
        }
115
-       if(isset($this->attributes['support:info_file'])) {
115
+       if (isset($this->attributes['support:info_file'])) {
116 116
           $this->attributes['internal:info_file'][0] = 
117 117
              $this->saveInfoFile($this->attributes['support:info_file'][0]);
118 118
        }
119
-       if(isset($this->attributes['general:logo_file']))
119
+       if (isset($this->attributes['general:logo_file']))
120 120
           $this->attributes['internal:logo_file'] = 
121 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'];;
122
+       $this->attributes['internal:SSID'] = $this->getSSIDs()['add']; ;
123
+       $this->attributes['internal:remove_SSID'] = $this->getSSIDs()['del']; ;
124 124
        $this->attributes['internal:consortia'] = $this->getConsortia();
125 125
        $this->lang_index = CAT::get_lang();
126 126
        // phpMD says the below is not needed. Wow.
127 127
        // $idp = new IdP($profile->institution);
128 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']);
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 131
        CAT::set_locale($olddomain);
132 132
 
133
-       if($this->signer && $this->options['sign'])
134
-         $this->sign = CAT::$root . '/signer/'. $this->signer;
133
+       if ($this->signer && $this->options['sign'])
134
+         $this->sign = CAT::$root . '/signer/' . $this->signer;
135 135
        $this->installerBasename = $this->getInstallerBasename();
136 136
     }
137 137
 
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
     */   
144 144
    public function getPreferredEapType($eap_array) {
145 145
      foreach ($eap_array as $eap) {
146
-         if(in_array($eap,$this->supportedEapMethods)) {
146
+         if (in_array($eap, $this->supportedEapMethods)) {
147 147
             $this->selected_eap = $eap;
148
-            debug(4,"Selected EAP:");
149
-            debug(4,$eap);
148
+            debug(4, "Selected EAP:");
149
+            debug(4, $eap);
150 150
             return($eap);
151 151
          }
152 152
      }
@@ -178,22 +178,22 @@  discard block
 block discarded – undo
178 178
     * @final not to be redefined
179 179
     */
180 180
    final protected function copyFile($source_name, $output_name = 0) {
181
-      if  ( $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;
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 189
       else {
190
-        debug(2,"fileCopy:reqested file $source_name does not exist\n");
190
+        debug(2, "fileCopy:reqested file $source_name does not exist\n");
191 191
         return(FALSE);
192 192
       }
193
-      debug(4,"Copying $source to $output_name\n");
194
-      $result = copy($source,"$output_name");
195
-      if(! $result )
196
-        debug(2,"fileCopy($source_name, $output_name) failed\n");
193
+      debug(4, "Copying $source to $output_name\n");
194
+      $result = copy($source, "$output_name");
195
+      if (!$result)
196
+        debug(2, "fileCopy($source_name, $output_name) failed\n");
197 197
       return($result); 
198 198
    }
199 199
 
@@ -223,31 +223,31 @@  discard block
 block discarded – undo
223 223
     */
224 224
 
225 225
    final protected function translateFile($source_name, $output_name = 0, $encoding = 0) {
226
-      if(Config::$NSIS_VERSION >= 3)
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");
231
+      debug(4, "translateFile($source_name, $output_name, $encoding)\n");
232 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;
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 238
       include($source);
239 239
       $output = ob_get_clean();
240
-      if($encoding) {
241
-        $output_c = iconv('UTF-8',$encoding.'//TRANSLIT',$output);
242
-        if($output_c)
240
+      if ($encoding) {
241
+        $output_c = iconv('UTF-8', $encoding . '//TRANSLIT', $output);
242
+        if ($output_c)
243 243
            $output = $output_c;
244 244
       }
245
-      $f = fopen("$output_name","w");
246
-      if(! $f)
247
-         debug(2,"translateFile($source, $output_name, $encoding) failed\n");
248
-      fwrite($f,$output);
245
+      $f = fopen("$output_name", "w");
246
+      if (!$f)
247
+         debug(2, "translateFile($source, $output_name, $encoding) failed\n");
248
+      fwrite($f, $output);
249 249
       fclose($f);
250
-      debug(4,"translateFile($source, $output_name, $encoding) end\n");
250
+      debug(4, "translateFile($source, $output_name, $encoding) end\n");
251 251
    }
252 252
 
253 253
 
@@ -268,17 +268,17 @@  discard block
 block discarded – undo
268 268
     * @final not to be redefined
269 269
     */
270 270
 
271
-   final protected function translateString($source_string,$encoding = 0) {
272
-      if(Config::$NSIS_VERSION >= 3)
271
+   final protected function translateString($source_string, $encoding = 0) {
272
+      if (Config::$NSIS_VERSION >= 3)
273 273
         $encoding = 0;
274
-      if($encoding)
275
-        $output_c = iconv('UTF-8',$encoding.'//TRANSLIT',$source_string);
274
+      if ($encoding)
275
+        $output_c = iconv('UTF-8', $encoding . '//TRANSLIT', $source_string);
276 276
       else
277 277
         $output_c = $source_string;
278
-      if($output_c) 
279
-         $source_string  = str_replace('"','$\\"',$output_c);
278
+      if ($output_c) 
279
+         $source_string = str_replace('"', '$\\"', $output_c);
280 280
       else
281
-         debug(2,"Failed to convert string $source_string\n");
281
+         debug(2, "Failed to convert string $source_string\n");
282 282
       return $source_string;
283 283
    }
284 284
 
@@ -295,19 +295,19 @@  discard block
 block discarded – undo
295 295
    * root is set to 1 for the CA roor certicicate and 0 otherwise
296 296
   */ 
297 297
    final protected function saveCertificateFiles($format) {
298
-     if($format == 'der' || $format == 'pam') {
298
+     if ($format == 'der' || $format == 'pam') {
299 299
        $i = 0;
300 300
        $CA_files = [];
301 301
        $ca_array = $this->attributes['internal:CAs'][0];
302
-       if(! $ca_array)
302
+       if (!$ca_array)
303 303
          return(FALSE);
304 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
-            fwrite($f,$CA['pem']);
305
+         $f = fopen("cert-$i.crt", "w");
306
+         if (!$f) die("problem opening the file\n");
307
+         if ($format == "pem")
308
+            fwrite($f, $CA['pem']);
309 309
          else
310
-            fwrite($f,$CA['der']);
310
+            fwrite($f, $CA['der']);
311 311
          fclose($f);
312 312
          $C = [];
313 313
          $C['file'] = "cert-$i.crt";
@@ -335,42 +335,42 @@  discard block
 block discarded – undo
335 335
    private function getInstallerBasename() {
336 336
       $replace_pattern = '/[ ()\/\'"]+/';
337 337
       $lang_pointer = Config::$LANGUAGES[$this->lang_index]['latin_based'] == TRUE ? 0 : 1;
338
-      debug(4,"getInstallerBasename1:".$this->attributes['general:instname'][$lang_pointer]."\n");
338
+      debug(4, "getInstallerBasename1:" . $this->attributes['general:instname'][$lang_pointer] . "\n");
339 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) {
340
+      debug(4, "getInstallerBasename2:$inst\n");
341
+      $Inst_a = explode('_', $inst);
342
+      if (count($Inst_a) > 2) {
343 343
          $inst = '';
344
-         foreach($Inst_a as $i)
344
+         foreach ($Inst_a as $i)
345 345
            $inst .= $i[0];
346 346
       }   
347 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])) {
348
+      if ($this->attributes['internal:profile_count'][0] > 1) {
349
+         if (!empty($this->attributes['profile:name']) && !empty($this->attributes['profile:name'][$lang_pointer])) {
350 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;
351
+             $prof = preg_replace('/_+$/', '', $prof);
352
+             return $c_name . '-' . $this->getDeviceId() . $inst . '-' . $prof;
353 353
          }
354 354
       }
355
-      return $c_name. '-'. $this->getDeviceId() . $inst;
355
+      return $c_name . '-' . $this->getDeviceId() . $inst;
356 356
   }
357 357
 
358 358
   private function getDeviceId() {
359 359
     $d_id = $this->device_id;
360
-    if(isset($this->options['device_id'])) 
360
+    if (isset($this->options['device_id'])) 
361 361
       $d_id = $this->options['device_id'];
362
-    if($d_id !== '')
362
+    if ($d_id !== '')
363 363
       $d_id .= '-';
364 364
     return $d_id;
365 365
   }
366 366
 
367 367
 
368 368
   private function getSSIDs() {
369
-    $S['add']=[];
370
-    $S['del']=[];
369
+    $S['add'] = [];
370
+    $S['del'] = [];
371 371
     if (isset(Config::$CONSORTIUM['ssid'])) {
372 372
        foreach (Config::$CONSORTIUM['ssid'] as $ssid) {
373
-        if(isset(Config::$CONSORTIUM['tkipsupport']) && Config::$CONSORTIUM['tkipsupport'] == TRUE)
373
+        if (isset(Config::$CONSORTIUM['tkipsupport']) && Config::$CONSORTIUM['tkipsupport'] == TRUE)
374 374
           $S['add'][$ssid] = 'TKIP';
375 375
         else {
376 376
           $S['add'][$ssid] = 'AES';
@@ -378,20 +378,20 @@  discard block
 block discarded – undo
378 378
         }
379 379
        }
380 380
     }
381
-    if(isset($this->attributes['media:SSID'])) {
381
+    if (isset($this->attributes['media:SSID'])) {
382 382
       $SSID = $this->attributes['media:SSID'];
383 383
 
384
-      foreach($SSID as $ssid)
384
+      foreach ($SSID as $ssid)
385 385
          $S['add'][$ssid] = 'AES';
386 386
       }
387
-    if(isset($this->attributes['media:SSID_with_legacy'])) {
387
+    if (isset($this->attributes['media:SSID_with_legacy'])) {
388 388
       $SSID = $this->attributes['media:SSID_with_legacy'];
389
-      foreach($SSID as $ssid)
389
+      foreach ($SSID as $ssid)
390 390
          $S['add'][$ssid] = 'TKIP';
391 391
     }
392
-    if(isset($this->attributes['media:remove_SSID'])) {
392
+    if (isset($this->attributes['media:remove_SSID'])) {
393 393
       $SSID = $this->attributes['media:remove_SSID'];
394
-      foreach($SSID as $ssid)
394
+      foreach ($SSID as $ssid)
395 395
          $S['del'][$ssid] = 'DEL';
396 396
     }
397 397
     return $S;
@@ -417,25 +417,25 @@  discard block
 block discarded – undo
417 417
   ];
418 418
 
419 419
   private function saveLogoFile($Logos) {
420
-    $i=0;
421
-    $returnarray= [];
420
+    $i = 0;
421
+    $returnarray = [];
422 422
     foreach ($Logos as $blob) {
423 423
       $finfo = new finfo(FILEINFO_MIME_TYPE);
424 424
       $mime = $finfo->buffer($blob);
425
-      if(preg_match('/^image\/(.*)/',$mime,$m))
425
+      if (preg_match('/^image\/(.*)/', $mime, $m))
426 426
         $ext = $m[1];
427 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");
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 434
           die("problem opening the file\n");
435 435
       }
436
-      fwrite($f,$blob);
436
+      fwrite($f, $blob);
437 437
       fclose($f);
438
-      $returnarray[]= ['name'=>$f_name,'mime'=>$ext];
438
+      $returnarray[] = ['name'=>$f_name, 'mime'=>$ext];
439 439
       $i++;
440 440
     }
441 441
     return($returnarray);
@@ -446,17 +446,17 @@  discard block
 block discarded – undo
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';
449
-    debug(4,"saveInfoFile: $mime : $ext\n");
450
-    $f = fopen('local-info.'.$ext,"w");
451
-    if(! $f) die("problem opening the file\n");
452
-    fwrite($f,$blob);
449
+    debug(4, "saveInfoFile: $mime : $ext\n");
450
+    $f = fopen('local-info.' . $ext, "w");
451
+    if (!$f) die("problem opening the file\n");
452
+    fwrite($f, $blob);
453 453
     fclose($f);
454
-    return(['name'=>'local-info.'.$ext,'mime'=>$ext]);
454
+    return(['name'=>'local-info.' . $ext, 'mime'=>$ext]);
455 455
   }
456 456
 
457 457
   private function getProfileAttributes(Profile $profile) {
458 458
      $eaps = $profile->getEapMethodsinOrderOfPreference(1);
459
-     if($eap = $this->getPreferredEapType($eaps)) {
459
+     if ($eap = $this->getPreferredEapType($eaps)) {
460 460
           $a = $profile->getCollapsedAttributes($eap);
461 461
           $a['eap'] = $eap;
462 462
           $a['all_eaps'] = $eaps;
@@ -477,8 +477,8 @@  discard block
 block discarded – undo
477 477
         ob_start();
478 478
         print_r($this->attributes);
479 479
         $output = ob_get_clean();
480
-        $f = fopen($file,"w");
481
-        fwrite($f,$output);
480
+        $f = fopen($file, "w");
481
+        fwrite($f, $output);
482 482
         fclose($f);
483 483
   }
484 484
 /** 
Please login to merge, or discard this patch.