Completed
Push — master ( cc9aa9...547d73 )
by
unknown
04:54
created
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.
core/Profile.php 1 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.