Completed
Branch master (03ec64)
by Brook
14:43
created
core/UserAPI.php 1 patch
Indentation   +391 added lines, -391 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
  *  link - the path name of the resulting installer
53 53
  *  mime - the mimetype of the installer
54 54
  */
55
-  public function generateInstaller($device,$prof_id, $generated_for = "user") {
55
+    public function generateInstaller($device,$prof_id, $generated_for = "user") {
56 56
     $this->set_locale("devices");
57 57
     $Dev = Devices::listDevices();
58 58
     $Config = $Dev[$device];
@@ -61,93 +61,93 @@  discard block
 block discarded – undo
61 61
     $attribs = $profile->getCollapsedAttributes();
62 62
     // test if the profile is production-ready and if not if the authenticated user is an owner
63 63
     if (!isset($attribs['profile:production']) || (isset($attribs['profile:production']) && $attribs['profile:production'][0] != "on")) {
64
-       debug(4,"Attempt to download a non-production ready installer fir profile: $prof_id\n");
65
-       require_once(Config::$AUTHENTICATION['ssp-path-to-autoloader']);
66
-       $as = new SimpleSAML_Auth_Simple(Config::$AUTHENTICATION['ssp-authsource']);
67
-       if($as->isAuthenticated()) {
68
-          $user_object = new User($_SESSION['user']);
69
-          if($user_object->isIdPOwner($profile->institution)) {
70
-              debug(4, "User is the owner - allowing access\n");
71
-          } else {
72
-             debug(2, "User not an owner of a non-production profile - access forbidden\n");
73
-       header("HTTP/1.0 403 Not Authorized");
74
-             return;
75
-          }
76
-       } else {
77
-          debug(2, "User NOT authenticated, rejecting request for a non-production installer\n");
78
-          header("HTTP/1.0 403 Not Authorized");
79
-          return;
80
-       }
64
+        debug(4,"Attempt to download a non-production ready installer fir profile: $prof_id\n");
65
+        require_once(Config::$AUTHENTICATION['ssp-path-to-autoloader']);
66
+        $as = new SimpleSAML_Auth_Simple(Config::$AUTHENTICATION['ssp-authsource']);
67
+        if($as->isAuthenticated()) {
68
+            $user_object = new User($_SESSION['user']);
69
+            if($user_object->isIdPOwner($profile->institution)) {
70
+                debug(4, "User is the owner - allowing access\n");
71
+            } else {
72
+                debug(2, "User not an owner of a non-production profile - access forbidden\n");
73
+        header("HTTP/1.0 403 Not Authorized");
74
+                return;
75
+            }
76
+        } else {
77
+            debug(2, "User NOT authenticated, rejecting request for a non-production installer\n");
78
+            header("HTTP/1.0 403 Not Authorized");
79
+            return;
80
+        }
81 81
     }
82 82
     $a = [];
83 83
     $a['profile'] = $prof_id;
84 84
     $a['device'] = $device;
85 85
     if( (isset(Devices::$Options['no_cache']) && Devices::$Options['no_cache'] ) || ( isset($Config['options']['no_cache']) && $Config['options']['no_cache'] ))
86
-      $this->i_path = FALSE;
86
+        $this->i_path = FALSE;
87 87
     else {
88
-      $cache = $profile->testCache($device);
89
-      $this->i_path = $cache['cache'];
88
+        $cache = $profile->testCache($device);
89
+        $this->i_path = $cache['cache'];
90 90
     }
91 91
     if($this->i_path && is_file($this->i_path)) { 
92
-      debug(4,"Using cached installer for: $device\n");
93
-      $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for";
94
-      $a['mime'] = $cache['mime'];
92
+        debug(4,"Using cached installer for: $device\n");
93
+        $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for";
94
+        $a['mime'] = $cache['mime'];
95 95
     } else {
96
-      $factory = new DeviceFactory($device);
97
-      $dev = $factory->device;
98
-      if(isset($dev)) {
99
-         $dev->setup($profile);
100
-         $installer = $dev->writeInstaller();
101
-         $i_path = $dev->FPATH.'/tmp/'.$installer;
102
-         if($i_path && is_file($i_path)) {
103
-         if(isset($dev->options['mime']))
104
-               $a['mime'] = $dev->options['mime'];
105
-         else {
106
-           $info = new finfo();
107
-           $a['mime'] = $info->file($i_path, FILEINFO_MIME_TYPE);
108
-         }
109
-         $this->i_path = $dev->FPATH.'/'.$installer;
110
-         rename($i_path, $this->i_path);
111
-         $profile->updateCache($device,$this->i_path,$a['mime']);
96
+        $factory = new DeviceFactory($device);
97
+        $dev = $factory->device;
98
+        if(isset($dev)) {
99
+            $dev->setup($profile);
100
+            $installer = $dev->writeInstaller();
101
+            $i_path = $dev->FPATH.'/tmp/'.$installer;
102
+            if($i_path && is_file($i_path)) {
103
+            if(isset($dev->options['mime']))
104
+                $a['mime'] = $dev->options['mime'];
105
+            else {
106
+            $info = new finfo();
107
+            $a['mime'] = $info->file($i_path, FILEINFO_MIME_TYPE);
108
+            }
109
+            $this->i_path = $dev->FPATH.'/'.$installer;
110
+            rename($i_path, $this->i_path);
111
+            $profile->updateCache($device,$this->i_path,$a['mime']);
112 112
 //         rrmdir($dev->FPATH.'/tmp');
113
-         debug(4,"Generated installer: ".$this->i_path.": for: $device\n");
114
-         $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for";
115
-         } else {
116
-         debug(2,"Installer generation failed for: $prof_id:$device:".CAT::get_lang()."\n");
117
-         $a['link'] = 0;
118
-         }
119
-      } 
113
+            debug(4,"Generated installer: ".$this->i_path.": for: $device\n");
114
+            $a['link'] = "API.php?api_version=$version&action=downloadInstaller&lang=".CAT::get_lang()."&profile=$prof_id&device=$device&generatedfor=$generated_for";
115
+            } else {
116
+            debug(2,"Installer generation failed for: $prof_id:$device:".CAT::get_lang()."\n");
117
+            $a['link'] = 0;
118
+            }
119
+        } 
120 120
     }
121 121
     $this->set_locale("web_user");
122 122
     return($a);
123
- }
123
+    }
124 124
 
125
- /**
126
-  * interface to Devices::listDevices() 
127
-  */
128
- public function listDevices($show_hidden = 0) {
125
+    /**
126
+     * interface to Devices::listDevices() 
127
+     */
128
+    public function listDevices($show_hidden = 0) {
129 129
     $Dev = Devices::listDevices();
130 130
     $R = [];
131 131
     $ct = 0;
132 132
     if($show_hidden !== 0 && $show_hidden != 1)
133
-      return;
133
+        return;
134 134
     foreach ($Dev as $device => $D) {
135
-      if(isset($D['options']['hidden']) && $D['options']['hidden'] && $show_hidden == 0)
136
-         continue;
137
-      $ct ++;
138
-      if($this->version == 1)
139
-         $D['device'] = $device;
140
-      else
141
-         $D['device'] = $device;
142
-      $group = isset($D['group']) ? $D['group'] : 'other';
143
-      if (! isset($R[$group]))
144
-         $R[$group] = [];
145
-      $R[$group][$device] = $D;
146
-    }
147
-   return $R;
148
- }
149
-
150
- public function deviceInfo($device,$prof_id) {
135
+        if(isset($D['options']['hidden']) && $D['options']['hidden'] && $show_hidden == 0)
136
+            continue;
137
+        $ct ++;
138
+        if($this->version == 1)
139
+            $D['device'] = $device;
140
+        else
141
+            $D['device'] = $device;
142
+        $group = isset($D['group']) ? $D['group'] : 'other';
143
+        if (! isset($R[$group]))
144
+            $R[$group] = [];
145
+        $R[$group][$device] = $D;
146
+    }
147
+    return $R;
148
+    }
149
+
150
+    public function deviceInfo($device,$prof_id) {
151 151
     $this->set_locale("devices");
152 152
     $out = 0;
153 153
     $profile = new Profile($prof_id);
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
     $dev = $factory->device;
156 156
     if(isset($dev)) {
157 157
 //       $dev->setup($profile);
158
-       $out = $dev->writeDeviceInfo();
159
-   }
158
+        $out = $dev->writeDeviceInfo();
159
+    }
160 160
     $this->set_locale("web_user");
161 161
     echo $out;
162
- }
162
+    }
163 163
 
164 164
 /**
165 165
  * Prepare the support data for a given profile
@@ -173,23 +173,23 @@  discard block
 block discarded – undo
173 173
  * - description
174 174
  * - devices - an array of device names and their statuses (for a given profile)
175 175
  */
176
- public function profileAttributes($prof_id) {
176
+    public function profileAttributes($prof_id) {
177 177
     $this->set_locale("devices");
178
-      $profile = new Profile($prof_id);
179
-      $attr = $profile->getCollapsedAttributes();
180
-      $a = [];
181
-      if(isset($attr['support:email']))
182
-         $a['local_email'] = $attr['support:email'][0];
183
-      if(isset($attr['support:phone']))
184
-         $a['local_phone'] = $attr['support:phone'][0];
185
-      if(isset($attr['support:url']))
186
-         $a['local_url'] = $attr['support:url'][0];
187
-      if(isset($attr['profile:description']))
188
-         $a['description'] = $attr['profile:description'][0];
189
-      $a['devices'] = $profile->listDevices();
190
-      $this->set_locale("web_user");
191
-      return($a);
192
- }
178
+        $profile = new Profile($prof_id);
179
+        $attr = $profile->getCollapsedAttributes();
180
+        $a = [];
181
+        if(isset($attr['support:email']))
182
+            $a['local_email'] = $attr['support:email'][0];
183
+        if(isset($attr['support:phone']))
184
+            $a['local_phone'] = $attr['support:phone'][0];
185
+        if(isset($attr['support:url']))
186
+            $a['local_url'] = $attr['support:url'][0];
187
+        if(isset($attr['profile:description']))
188
+            $a['description'] = $attr['profile:description'][0];
189
+        $a['devices'] = $profile->listDevices();
190
+        $this->set_locale("web_user");
191
+        return($a);
192
+    }
193 193
 
194 194
 /*
195 195
    this method needs to be used with care, it could give wrong results in some
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
     $file= $F['file'];
202 202
     $file = substr($file,strlen(dirname(__DIR__)));
203 203
     while(substr($file,0,1) == '/')
204
-       $file = substr($file,1);
204
+        $file = substr($file,1);
205 205
     $n = count(explode('/',$file));
206 206
     $out = $_SERVER['SCRIPT_NAME'];
207 207
     for ($i= 0; $i < $n; $i++)
208
-      $out = dirname($out);
208
+        $out = dirname($out);
209 209
     if ($out == '/')
210
-      $out = '';
210
+        $out = '';
211 211
     $s = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http';
212 212
     $s .= '://'.$_SERVER['HTTP_HOST'] . $out;
213 213
     return $s;
@@ -215,29 +215,29 @@  discard block
 block discarded – undo
215 215
 
216 216
 /* JSON functions */
217 217
 
218
-  public function return_json($data,$status=1) {
219
-     $return_array = [];
220
-     $return_array['status'] = $status;
221
-     $return_array['data'] = $data;
222
-     $return_array['tou'] =  "Please consult Terms of Use at: ".$this->GetRootURL()."/tou.php";
223
-     return(json_encode($return_array));
224
-  }
218
+    public function return_json($data,$status=1) {
219
+        $return_array = [];
220
+        $return_array['status'] = $status;
221
+        $return_array['data'] = $data;
222
+        $return_array['tou'] =  "Please consult Terms of Use at: ".$this->GetRootURL()."/tou.php";
223
+        return(json_encode($return_array));
224
+    }
225 225
 
226 226
 /**
227
-  * Return the list of supported languages.
228
-  *
229
-  * 
230
-  */
231
-  public function JSON_listLanguages() {
232
-     $return_array = [];
233
-     foreach(Config::$LANGUAGES as $id => $val){
234
-       if($this->version == 1)
235
-          $return_array[] = ['id'=>$id,'display'=>$val['display'],'locale'=>$val['locale']];
236
-       else
237
-          $return_array[] = ['lang'=>$id,'display'=>$val['display'],'locale'=>$val['locale']];
238
-     }
239
-     echo $this->return_json($return_array);
240
-  }
227
+ * Return the list of supported languages.
228
+ *
229
+ * 
230
+ */
231
+    public function JSON_listLanguages() {
232
+        $return_array = [];
233
+        foreach(Config::$LANGUAGES as $id => $val){
234
+        if($this->version == 1)
235
+            $return_array[] = ['id'=>$id,'display'=>$val['display'],'locale'=>$val['locale']];
236
+        else
237
+            $return_array[] = ['lang'=>$id,'display'=>$val['display'],'locale'=>$val['locale']];
238
+        }
239
+        echo $this->return_json($return_array);
240
+    }
241 241
 
242 242
 /**
243 243
  * Return the list of countiers with configured IdPs
@@ -245,17 +245,17 @@  discard block
 block discarded – undo
245 245
  * @return string JSON encoded data
246 246
  */
247 247
 
248
-  public function JSON_listCountries() {
249
-     $FED = $this->printCountryList(1);
250
-     $return_array = [];
251
-     foreach ($FED as $id => $val) {
252
-       if($this->version == 1)
253
-          $return_array[] = ['id'=>$id,'display'=>$val];
254
-       else
255
-          $return_array[] = ['federation'=>$id,'display'=>$val];
256
-     }
257
-     echo $this->return_json($return_array);
258
-  }
248
+    public function JSON_listCountries() {
249
+        $FED = $this->printCountryList(1);
250
+        $return_array = [];
251
+        foreach ($FED as $id => $val) {
252
+        if($this->version == 1)
253
+            $return_array[] = ['id'=>$id,'display'=>$val];
254
+        else
255
+            $return_array[] = ['federation'=>$id,'display'=>$val];
256
+        }
257
+        echo $this->return_json($return_array);
258
+    }
259 259
 
260 260
 /**
261 261
  * Return the list of IdPs in a given country
@@ -264,17 +264,17 @@  discard block
 block discarded – undo
264 264
  * @return string JSON encoded data
265 265
  */
266 266
 
267
-  public function JSON_listIdentityProviders($country) {
268
-     $idps = Federation::listAllIdentityProviders(1,$country);
269
-     $return_array = [];
270
-     foreach ($idps as $idp) {
267
+    public function JSON_listIdentityProviders($country) {
268
+        $idps = Federation::listAllIdentityProviders(1,$country);
269
+        $return_array = [];
270
+        foreach ($idps as $idp) {
271 271
         if($this->version == 1)
272
-           $return_array[] = ['id'=>$idp['entityID'],'display'=>$idp['title']];
272
+            $return_array[] = ['id'=>$idp['entityID'],'display'=>$idp['title']];
273 273
         else
274
-           $return_array[] = ['idp'=>$idp['entityID'],'display'=>$idp['title']];
275
-     }
276
-     echo $this->return_json($return_array);
277
-  }
274
+            $return_array[] = ['idp'=>$idp['entityID'],'display'=>$idp['title']];
275
+        }
276
+        echo $this->return_json($return_array);
277
+    }
278 278
 
279 279
 /**
280 280
  * return the list of all active IdPs
@@ -283,18 +283,18 @@  discard block
 block discarded – undo
283 283
  * @return string JSON encoded data
284 284
  */
285 285
 
286
-  public function JSON_listIdentityProvidersForDisco() {
287
-     $idps = Federation::listAllIdentityProviders(1);
288
-     $return_array = [];
289
-     foreach ($idps as $idp) {
286
+    public function JSON_listIdentityProvidersForDisco() {
287
+        $idps = Federation::listAllIdentityProviders(1);
288
+        $return_array = [];
289
+        foreach ($idps as $idp) {
290 290
         if($this->version == 1)
291
-           $idp['id'] = $idp['entityID'];
292
-         else
293
-           $idp['idp'] = $idp['entityID'];
291
+            $idp['id'] = $idp['entityID'];
292
+            else
293
+            $idp['idp'] = $idp['entityID'];
294 294
         $return_array[] = $idp;
295
-      }
296
-     echo json_encode($return_array);
297
-  }
295
+        }
296
+        echo json_encode($return_array);
297
+    }
298 298
 
299 299
 
300 300
 
@@ -306,17 +306,17 @@  discard block
 block discarded – undo
306 306
  */
307 307
 
308 308
 
309
-  public function JSON_orderIdentityProviders($country,$L=NULL) {
310
-     $idps = $this->orderIdentityProviders($country,$L);
311
-     $return_array = [];
312
-     foreach ($idps as $idp) {
309
+    public function JSON_orderIdentityProviders($country,$L=NULL) {
310
+        $idps = $this->orderIdentityProviders($country,$L);
311
+        $return_array = [];
312
+        foreach ($idps as $idp) {
313 313
         if($this->version == 1)
314
-           $return_array[] = ['id'=>$idp['id'],'display'=>$idp['title']];
314
+            $return_array[] = ['id'=>$idp['id'],'display'=>$idp['title']];
315 315
         else
316
-           $return_array[] = ['idp'=>$idp['id'],'display'=>$idp['title']];
317
-     }
318
-     echo $this->return_json($return_array);
319
-  }
316
+            $return_array[] = ['idp'=>$idp['id'],'display'=>$idp['title']];
317
+        }
318
+        echo $this->return_json($return_array);
319
+    }
320 320
 
321 321
 /**
322 322
  * Produce a list of profiles available for a given IdP
@@ -324,31 +324,31 @@  discard block
 block discarded – undo
324 324
  * @param int $idp_id the IdP identifier
325 325
  * @return string JSON encoded data
326 326
  */
327
-  public function JSON_listProfiles($idp_id,$sort = 0) {
328
-     $this->set_locale("web_user");
329
-     $return_array = [];
330
-     try {     
331
-         $idp = new IdP($idp_id);
332
-     }
333
-     catch (Exception $fail) {
327
+    public function JSON_listProfiles($idp_id,$sort = 0) {
328
+        $this->set_locale("web_user");
329
+        $return_array = [];
330
+        try {     
331
+            $idp = new IdP($idp_id);
332
+        }
333
+        catch (Exception $fail) {
334 334
         echo $this->return_json($return_array,0);
335 335
         return;
336
-     }
337
-     $l = 0;
338
-     $logo = $idp->getAttributes('general:logo_file');
339
-     if($logo)
340
-       $l = 1;
341
-     $profiles = $idp->listProfiles(1);
342
-     if($sort == 1)
336
+        }
337
+        $l = 0;
338
+        $logo = $idp->getAttributes('general:logo_file');
339
+        if($logo)
340
+        $l = 1;
341
+        $profiles = $idp->listProfiles(1);
342
+        if($sort == 1)
343 343
         usort($profiles,"profile_sort");
344
-     foreach ($profiles as $P) {
345
-       if($this->version == 1)
346
-          $return_array[] = ['id'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; 
347
-       else
348
-          $return_array[] = ['profile'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; 
349
-     }
350
-     echo $this->return_json($return_array);
351
-  }
344
+        foreach ($profiles as $P) {
345
+        if($this->version == 1)
346
+            $return_array[] = ['id'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; 
347
+        else
348
+            $return_array[] = ['profile'=>$P->identifier,'display'=>$P->name, 'idp_name'=>$P->inst_name,'logo'=>$l]; 
349
+        }
350
+        echo $this->return_json($return_array);
351
+    }
352 352
 
353 353
 /**
354 354
  * Return the list of devices available for the given profile
@@ -356,34 +356,34 @@  discard block
 block discarded – undo
356 356
  * @param int $profile_id the Profile identifier
357 357
  * @return string JSON encoded data
358 358
  */
359
-  public function JSON_listDevices($profile_id) {
360
-     $this->set_locale("web_user");
361
-     $return_array = [];
362
-     $a = $this->profileAttributes($profile_id);
363
-     $thedevices = $a['devices'];
364
-     if(!isset($profile_redirect) || ! $profile_redirect) {
365
-         $profile_redirect = 0;
366
-         foreach ($thedevices as $D) {
367
-              if(isset($D['options']) && isset($D['options']['hidden']) &&  $D['options']['hidden'])
368
-                   continue;
369
-              $disp = $D['display'];
370
-              if($this->version == 1) {
371
-                 if($D['id'] === '0') {
372
-                     $profile_redirect = 1;
373
-                     $disp = $c;
374
-                 }
359
+    public function JSON_listDevices($profile_id) {
360
+        $this->set_locale("web_user");
361
+        $return_array = [];
362
+        $a = $this->profileAttributes($profile_id);
363
+        $thedevices = $a['devices'];
364
+        if(!isset($profile_redirect) || ! $profile_redirect) {
365
+            $profile_redirect = 0;
366
+            foreach ($thedevices as $D) {
367
+                if(isset($D['options']) && isset($D['options']['hidden']) &&  $D['options']['hidden'])
368
+                    continue;
369
+                $disp = $D['display'];
370
+                if($this->version == 1) {
371
+                    if($D['id'] === '0') {
372
+                        $profile_redirect = 1;
373
+                        $disp = $c;
374
+                    }
375 375
                 $return_array[] = ['id'=>$D['id'], 'display'=>$disp, 'status'=>$D['status'], 'redirect'=>$D['redirect']];
376
-             } else {
377
-                 if($D['device'] === '0') {
378
-                     $profile_redirect = 1;
379
-                     $disp = $c;
380
-                 }
376
+                } else {
377
+                    if($D['device'] === '0') {
378
+                        $profile_redirect = 1;
379
+                        $disp = $c;
380
+                    }
381 381
                 $return_array[] = ['device'=>$D['id'], 'display'=>$disp, 'status'=>$D['status'], 'redirect'=>$D['redirect']];
382
-             }
383
-         }
382
+                }
383
+            }
384 384
 
385
-  }
386
-  echo $this->return_json($return_array);
385
+    }
386
+    echo $this->return_json($return_array);
387 387
 }
388 388
   
389 389
 /**
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
  * @param int $prof_id profile identifier
394 394
  * @return string JSON encoded data
395 395
  */
396
-  public function JSON_generateInstaller($device,$prof_id) {
396
+    public function JSON_generateInstaller($device,$prof_id) {
397 397
     debug(4,"JSON::generateInstaller arguments: $device,$prof_id\n");
398 398
     $o = $this->generateInstaller($device,$prof_id);
399 399
     debug(4,"output from GUI::generateInstaller:");
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
     debug(4,json_encode($o));
402 402
 //    header('Content-type: application/json; utf-8');
403 403
     echo $this->return_json($o);
404
- }
404
+    }
405 405
 
406 406
 /**
407 407
  * Generate and send the installer
@@ -411,14 +411,14 @@  discard block
 block discarded – undo
411 411
  * @return binary installerFile
412 412
  */
413 413
 
414
- public function downloadInstaller($device,$prof_id,$generated_for='user') {
414
+    public function downloadInstaller($device,$prof_id,$generated_for='user') {
415 415
     debug(4,"downloadInstaller arguments: $device,$prof_id,$generated_for\n");
416 416
     $o = $this->generateInstaller($device,$prof_id);
417 417
     debug(4,"output from GUI::generateInstaller:");
418 418
     debug(4,$o);
419 419
     if(! $o['link']) {
420
-       header("HTTP/1.0 404 Not Found");
421
-       return;
420
+        header("HTTP/1.0 404 Not Found");
421
+        return;
422 422
     }
423 423
     $profile = new Profile($prof_id);
424 424
     $profile->incrementDownloadStats($device, $generated_for);
@@ -431,242 +431,242 @@  discard block
 block discarded – undo
431 431
     ob_clean();
432 432
     flush();
433 433
     readfile($file);
434
- }
434
+    }
435 435
 /**
436
- * Get and prepare logo file 
437
- *
438
- * When called for DiscoJuice, first check if file cache exists
439
- * If not then generate the file and save it in the cache
440
- * @param int $idp_id IdP identifier
441
- * @param int $disco flag turning on image generation for DiscoJuice
442
- * @param int $width, $height  maximum width and height of the generated image 
443
- * if one of these is 0 then it is treated as no upper bound
444
- *
445
- */
436
+     * Get and prepare logo file 
437
+     *
438
+     * When called for DiscoJuice, first check if file cache exists
439
+     * If not then generate the file and save it in the cache
440
+     * @param int $idp_id IdP identifier
441
+     * @param int $disco flag turning on image generation for DiscoJuice
442
+     * @param int $width, $height  maximum width and height of the generated image 
443
+     * if one of these is 0 then it is treated as no upper bound
444
+     *
445
+     */
446
+
447
+    public function sendLogo($idp_id, $disco=FALSE, $width=0, $height=0) {
448
+    $ExpStr = '';
449
+    $resize = 0;
450
+    if(($width || $height) && is_numeric($width) && is_numeric($height)) {
451
+        $resize = 1;
452
+        if($height == 0)
453
+            $height = 10000;
454
+        if($width == 0)
455
+            $width = 10000;
456
+        $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png';
457
+    } elseif($disco == 1) {
458
+        $width = 120;
459
+        $height = 40;
460
+        $resize = 1;
461
+        $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png';
462
+    }
446 463
 
447
- public function sendLogo($idp_id, $disco=FALSE, $width=0, $height=0) {
448
-   $ExpStr = '';
449
-   $resize = 0;
450
-   if(($width || $height) && is_numeric($width) && is_numeric($height)) {
451
-       $resize = 1;
452
-       if($height == 0)
453
-          $height = 10000;
454
-       if($width == 0)
455
-          $width = 10000;
456
-       $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png';
457
-   } elseif($disco == 1) {
458
-       $width = 120;
459
-       $height = 40;
460
-       $resize = 1;
461
-       $logo_file = CAT::$root.'/web/downloads/logos/'.$idp_id.'_'.$width.'_'.$height.'.png';
462
-   }
463
-
464
-   if($resize && is_file($logo_file)){
465
-      debug(4,"Using cached logo $logo_file for: $idp_id\n");
466
-      $blob = file_get_contents($logo_file);
467
-      $filetype = 'image/png';
468
-   }
469
-   else {
470
-      $idp = new IdP($idp_id);
471
-      $at = $idp->getAttributes('general:logo_file');
472
-      $blob =  $at[0]['value'];
473
-      $info = new finfo();
474
-      $filetype = $info->buffer($blob, FILEINFO_MIME_TYPE);
475
-      $offset = 60 * 60 * 24 * 30;
476
-      $ExpStr = "Expires: " . gmdate( "D, d M Y H:i:s", time() + $offset ) . " GMT";
477
-      if($resize) {
478
-         $filetype = 'image/png';
479
-         $image = new Imagick();
480
-         $image->readImageBlob($blob);
481
-         if( $image->setImageFormat('PNG')) {
482
-           $image->thumbnailImage($width,$height,1);
483
-           $blob = $image->getImageBlob();
484
-           debug(4,"Writing cached logo $logo_file for: $idp_id\n");
485
-           file_put_contents($logo_file,$blob);
486
-         }
487
-         else
488
-           $blob = "XXXXXX";
489
-      }
490
-   }
491
-   header( "Content-type: ".$filetype );
492
-   header( "Cache-Control:max-age=36000, must-revalidate" );
493
-   header( $ExpStr );
494
-   echo $blob;
495
- }
496
-
497
- public function locateUser() {
498
-   $host = $_SERVER['REMOTE_ADDR'];
499
-   $record = geoip_record_by_name($host);
500
-   if($record) {
501
-     $result = ['status' => 'ok'];
502
-     $result['country'] = $record['country_code'];
464
+    if($resize && is_file($logo_file)){
465
+        debug(4,"Using cached logo $logo_file for: $idp_id\n");
466
+        $blob = file_get_contents($logo_file);
467
+        $filetype = 'image/png';
468
+    }
469
+    else {
470
+        $idp = new IdP($idp_id);
471
+        $at = $idp->getAttributes('general:logo_file');
472
+        $blob =  $at[0]['value'];
473
+        $info = new finfo();
474
+        $filetype = $info->buffer($blob, FILEINFO_MIME_TYPE);
475
+        $offset = 60 * 60 * 24 * 30;
476
+        $ExpStr = "Expires: " . gmdate( "D, d M Y H:i:s", time() + $offset ) . " GMT";
477
+        if($resize) {
478
+            $filetype = 'image/png';
479
+            $image = new Imagick();
480
+            $image->readImageBlob($blob);
481
+            if( $image->setImageFormat('PNG')) {
482
+            $image->thumbnailImage($width,$height,1);
483
+            $blob = $image->getImageBlob();
484
+            debug(4,"Writing cached logo $logo_file for: $idp_id\n");
485
+            file_put_contents($logo_file,$blob);
486
+            }
487
+            else
488
+            $blob = "XXXXXX";
489
+        }
490
+    }
491
+    header( "Content-type: ".$filetype );
492
+    header( "Cache-Control:max-age=36000, must-revalidate" );
493
+    header( $ExpStr );
494
+    echo $blob;
495
+    }
496
+
497
+    public function locateUser() {
498
+    $host = $_SERVER['REMOTE_ADDR'];
499
+    $record = geoip_record_by_name($host);
500
+    if($record) {
501
+        $result = ['status' => 'ok'];
502
+        $result['country'] = $record['country_code'];
503 503
 //  the two lines below are a dirty hack to take of the error in naming the UK federation
504
-     if($result['country'] == 'GB')
505
-         $result['country'] = 'UK';
506
-     $result['region'] = $record['region'];
507
-     $result['geo'] = ['lat' => (float)$record['latitude'] , 'lon' => (float)$record['longitude']];
508
-   } else {
509
-     $result = ['status' => 'error', 'error' =>'Problem listing countries']; 
510
-   }
511
-   return($result);
512
- }
513
-
514
-
515
- public function locateUser2() {
516
-   require_once Config::$GEOIP['geoip2-path-to-autoloader'];
517
-   $reader = new Reader(Config::$GEOIP['geoip2-path-to-db']);
518
-   $host = $_SERVER['REMOTE_ADDR'];
519
-   try {
520
-      $record = $reader->city($host);
521
-   } catch (Exception $e) {
522
-      $result = ['status' => 'error', 'error' =>'Problem listing countries']; 
523
-      return($result);
524
-   }
525
-   $result = ['status' => 'ok'];
526
-   $result['country'] = $record->country->isoCode;
504
+        if($result['country'] == 'GB')
505
+            $result['country'] = 'UK';
506
+        $result['region'] = $record['region'];
507
+        $result['geo'] = ['lat' => (float)$record['latitude'] , 'lon' => (float)$record['longitude']];
508
+    } else {
509
+        $result = ['status' => 'error', 'error' =>'Problem listing countries']; 
510
+    }
511
+    return($result);
512
+    }
513
+
514
+
515
+    public function locateUser2() {
516
+    require_once Config::$GEOIP['geoip2-path-to-autoloader'];
517
+    $reader = new Reader(Config::$GEOIP['geoip2-path-to-db']);
518
+    $host = $_SERVER['REMOTE_ADDR'];
519
+    try {
520
+        $record = $reader->city($host);
521
+    } catch (Exception $e) {
522
+        $result = ['status' => 'error', 'error' =>'Problem listing countries']; 
523
+        return($result);
524
+    }
525
+    $result = ['status' => 'ok'];
526
+    $result['country'] = $record->country->isoCode;
527 527
 //  the two lines below are a dirty hack to take of the error in naming the UK federation
528
-   if($result['country'] == 'GB')
529
-       $result['country'] = 'UK';
530
-   $result['region'] = $record->continent->name;
528
+    if($result['country'] == 'GB')
529
+        $result['country'] = 'UK';
530
+    $result['region'] = $record->continent->name;
531 531
 
532
-   $result['geo'] = ['lat' => (float)$record->location->latitude , 'lon' => (float)$record->location->longitude];
533
-   return($result);
534
- }
532
+    $result['geo'] = ['lat' => (float)$record->location->latitude , 'lon' => (float)$record->location->longitude];
533
+    return($result);
534
+    }
535 535
 
536 536
 public function JSON_locateUser() {
537 537
     header('Content-type: application/json; utf-8');
538 538
    
539 539
     if(empty(Config::$GEOIP['version']) || Config::$GEOIP['version'] == 0)
540
-      echo json_encode(['status' => 'error', 'error' =>'Geolocation not supported']);
540
+        echo json_encode(['status' => 'error', 'error' =>'Geolocation not supported']);
541 541
     if(Config::$GEOIP['version'] == 1)
542
-      echo json_encode($this->locateUser());
542
+        echo json_encode($this->locateUser());
543 543
     if(Config::$GEOIP['version'] == 2)
544
-      echo json_encode($this->locateUser2());
544
+        echo json_encode($this->locateUser2());
545 545
 }
546 546
 
547 547
 /**
548 548
  * Produce support data prepared within {@link GUI::profileAttributes()}
549 549
  * @return string JSON encoded data
550 550
  */
551
-  public function JSON_profileAttributes($prof_id) {
551
+    public function JSON_profileAttributes($prof_id) {
552 552
 //    header('Content-type: application/json; utf-8');
553 553
     echo $this->return_json($this->profileAttributes($prof_id));
554
-  }
554
+    }
555 555
 
556 556
 /**
557
-  * Calculate the distence in km between two points given their
558
-  * geo coordinates.
559
-  * @param array $P1 - first point as an 'lat', 'lon' array 
560
-  * @param array $P2 - second point as an 'lat', 'lon' array 
561
-  * @return float distance in km
562
-  */
557
+ * Calculate the distence in km between two points given their
558
+ * geo coordinates.
559
+ * @param array $P1 - first point as an 'lat', 'lon' array 
560
+ * @param array $P2 - second point as an 'lat', 'lon' array 
561
+ * @return float distance in km
562
+ */
563 563
 private function geoDistance($P1,$P2) {
564 564
 
565
-  $dist = sin(deg2rad($P1['lat'])) * sin(deg2rad($P2['lat'])) +  
565
+    $dist = sin(deg2rad($P1['lat'])) * sin(deg2rad($P2['lat'])) +  
566 566
          cos(deg2rad($P1['lat'])) * cos(deg2rad($P2['lat'])) * cos(deg2rad($P1['lon'] - $P2['lon']));
567
-  $dist = rad2deg(acos($dist)) * 60 * 1.1852 ;
568
-  return(round($dist));
567
+    $dist = rad2deg(acos($dist)) * 60 * 1.1852 ;
568
+    return(round($dist));
569 569
 }
570 570
 
571 571
 /**
572
-  * Order active identity providers according to their distance and name
573
-  * @param array $L - current location
574
-  * @return array $IdPs -  list of arrays ('id', 'name');
575
-  */
572
+ * Order active identity providers according to their distance and name
573
+ * @param array $L - current location
574
+ * @return array $IdPs -  list of arrays ('id', 'name');
575
+ */
576 576
 
577 577
 public function orderIdentityProviders($country,$L=NULL) {
578
-     $idps = Federation::listAllIdentityProviders(1,$country);
579
-
580
-  if(is_null($L)) {
581
-     $U = $this->locateUser();
582
-     if($U['status'] == 'ok') {
583
-     $L = $U['geo'];
584
-     } else {
585
-       $L = ['lat'=>"90",'lon'=>"0"];
586
-     }
587
-  }
588
-  $T=[];
589
-  $R=[];
590
-     foreach ($idps as $idp) {
578
+        $idps = Federation::listAllIdentityProviders(1,$country);
579
+
580
+    if(is_null($L)) {
581
+        $U = $this->locateUser();
582
+        if($U['status'] == 'ok') {
583
+        $L = $U['geo'];
584
+        } else {
585
+        $L = ['lat'=>"90",'lon'=>"0"];
586
+        }
587
+    }
588
+    $T=[];
589
+    $R=[];
590
+        foreach ($idps as $idp) {
591 591
         $T[$idp['entityID']] = $idp['title'];
592 592
         $dist = 10000;
593 593
         if(isset($idp['geo'])) {
594
-          $G=$idp['geo'];
595
-          if(isset($G['lon'])) {
596
-             $d1 = $this->geoDistance($L,$G); 
597
-             if( $d1 < $dist)
594
+            $G=$idp['geo'];
595
+            if(isset($G['lon'])) {
596
+                $d1 = $this->geoDistance($L,$G); 
597
+                if( $d1 < $dist)
598 598
                 $dist = $d1;
599
-          } else {
599
+            } else {
600 600
             foreach ($G as $g) {
601
-             $d1 = $this->geoDistance($L,$g); 
602
-             if( $d1 < $dist)
601
+                $d1 = $this->geoDistance($L,$g); 
602
+                if( $d1 < $dist)
603 603
                 $dist = $d1;
604 604
             }
605
-          }
605
+            }
606 606
         }
607
-       if($dist > 100)
608
-         $dist=10000;
609
-      $d = sprintf("%06d",$dist);
610
-      $R[$idp['entityID']] = $d." ".$idp['title'];
611
-     }
612
-     asort($R);
613
-     foreach (array_keys($R) as $r) {
614
-      if($this->version == 1)
615
-         $outarray[] = ['id'=>$r, 'title'=>$T[$r]];
616
-      else
617
-         $outarray[] = ['idp'=>$r, 'title'=>$T[$r]];
618
-      }
619
-     return($outarray);
607
+        if($dist > 100)
608
+            $dist=10000;
609
+        $d = sprintf("%06d",$dist);
610
+        $R[$idp['entityID']] = $d." ".$idp['title'];
611
+        }
612
+        asort($R);
613
+        foreach (array_keys($R) as $r) {
614
+        if($this->version == 1)
615
+            $outarray[] = ['id'=>$r, 'title'=>$T[$r]];
616
+        else
617
+            $outarray[] = ['idp'=>$r, 'title'=>$T[$r]];
618
+        }
619
+        return($outarray);
620 620
 }
621 621
 
622 622
 /**
623
-  * Detect the best device driver form the browser
624
-  *
625
-  * Detects the operating system and returns its id 
626
-  * display name and group membership (as in devices.php)
627
-  * @return array indexed by 'id', 'display', 'group'
628
-  */
623
+ * Detect the best device driver form the browser
624
+ *
625
+ * Detects the operating system and returns its id 
626
+ * display name and group membership (as in devices.php)
627
+ * @return array indexed by 'id', 'display', 'group'
628
+ */
629 629
 
630 630
 public function detectOS() {
631
-   $Dev = Devices::listDevices();
632
-   if( isset($_REQUEST['device']) && isset($Dev[$_REQUEST['device']]) && (!isset($device['options']['hidden']) || $device['options']['hidden'] == 0)) {
633
-      $dev_id = $_REQUEST['device'];
634
-      $device = $Dev[$dev_id];
635
-      if($this->version == 1)
636
-         return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]);
637
-      else
638
-         return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]);
639
-   }
640
-   $browser = $_SERVER['HTTP_USER_AGENT'];
641
-   debug(4,"HTTP_USER_AGENT=$browser\n");
642
-   foreach ($Dev as $dev_id => $device) {
643
-     if(!isset($device['match']))
631
+    $Dev = Devices::listDevices();
632
+    if( isset($_REQUEST['device']) && isset($Dev[$_REQUEST['device']]) && (!isset($device['options']['hidden']) || $device['options']['hidden'] == 0)) {
633
+        $dev_id = $_REQUEST['device'];
634
+        $device = $Dev[$dev_id];
635
+        if($this->version == 1)
636
+            return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]);
637
+        else
638
+            return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]);
639
+    }
640
+    $browser = $_SERVER['HTTP_USER_AGENT'];
641
+    debug(4,"HTTP_USER_AGENT=$browser\n");
642
+    foreach ($Dev as $dev_id => $device) {
643
+        if(!isset($device['match']))
644 644
         continue;
645
-     if(preg_match('/'.$device['match'].'/',$browser)) {
646
-       if(!isset($device['options']['hidden']) || $device['options']['hidden'] == 0) {
647
-          debug(4,"Browser_id: $dev_id\n");
648
-          if($this->version == 1)
649
-             return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]);
650
-          else
651
-             return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]);
652
-       }
653
-       else {
654
-         debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n");
655
-         return(false);
656
-       }
657
-     }
658
-   }
659
-   debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n");
660
-   return(false);
645
+        if(preg_match('/'.$device['match'].'/',$browser)) {
646
+        if(!isset($device['options']['hidden']) || $device['options']['hidden'] == 0) {
647
+            debug(4,"Browser_id: $dev_id\n");
648
+            if($this->version == 1)
649
+                return(['id'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]);
650
+            else
651
+                return(['device'=>$dev_id,'display'=>$device['display'], 'group'=>$device['group']]);
652
+        }
653
+        else {
654
+            debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n");
655
+            return(false);
656
+        }
657
+        }
658
+    }
659
+    debug(2, "Unrecognised system: ".$_SERVER['HTTP_USER_AGENT']."\n");
660
+    return(false);
661 661
 }
662 662
 
663 663
 public function JSON_detectOS() {
664
-     $return_array=$this->detectOS();
665
-     if($return_array)
664
+        $return_array=$this->detectOS();
665
+        if($return_array)
666 666
         $status = 1;
667
-     else
667
+        else
668 668
         $status = 0;
669
-     echo $this->return_json($return_array,$status);
669
+        echo $this->return_json($return_array,$status);
670 670
 }
671 671
 
672 672
 
@@ -676,6 +676,6 @@  discard block
 block discarded – undo
676 676
   
677 677
 }
678 678
 function profile_sort($P1,$P2) {
679
-   return strcasecmp($P1->name, $P2->name);
679
+    return strcasecmp($P1->name, $P2->name);
680 680
 } 
681 681
 ?>
Please login to merge, or discard this patch.
core/User.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -213,27 +213,27 @@
 block discarded – undo
213 213
         }
214 214
     }
215 215
 
216
-   /**
217
-    * This function tests if the current user has been configured as the system superadmin, i.e. if the user is allowed
218
-    * to execute the 112365365321.php script
219
-    *
220
-    * @return boolean TRUE if the user is a superadmin, FALSE if not 
221
-    */
216
+    /**
217
+     * This function tests if the current user has been configured as the system superadmin, i.e. if the user is allowed
218
+     * to execute the 112365365321.php script
219
+     *
220
+     * @return boolean TRUE if the user is a superadmin, FALSE if not 
221
+     */
222 222
     public function isSuperadmin() {
223
-       return in_array($this->identifier, Config::$SUPERADMINS);
223
+        return in_array($this->identifier, Config::$SUPERADMINS);
224 224
     }
225 225
 
226
-   /**
227
-    *  This function tests if the current user is an ovner of a given IdP
228
-    *
229
-    * @return boolean TRUE if the user is an owner, FALSE if not 
230
-    */
226
+    /**
227
+     *  This function tests if the current user is an ovner of a given IdP
228
+     *
229
+     * @return boolean TRUE if the user is an owner, FALSE if not 
230
+     */
231 231
     public function isIdPOwner($idp) {
232
-       $temp = new IdP($idp);
233
-       foreach ($temp->owner() as $oneowner)
232
+        $temp = new IdP($idp);
233
+        foreach ($temp->owner() as $oneowner)
234 234
             if ($oneowner['ID'] == $this->identifier)
235 235
                 return TRUE;
236
-       return FALSE;
236
+        return FALSE;
237 237
     }
238 238
 
239 239
     public function sendMailToUser($subject, $content) {
Please login to merge, or discard this patch.
devices/redirect_dev/RedirectDev.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -2,20 +2,20 @@
 block discarded – undo
2 2
 require_once('DeviceConfig.php');
3 3
 
4 4
 class Device_RedirectDev extends DeviceConfig {
5
-   /**
6
-    * Constructs a Device object.
7
-    *
8
-    * It is CRUTCIAL that the constructor sets $this->supportedEapMethods to an array of methods
9
-    * available for the particular device.
10
-    * {@source}
11
-    * @param string $device a pointer to a device module, which must
12
-    * be an index of one of the devices defined in the {@link Devices}
13
-    * array in {@link devices.php}.
14
-    * @final not to be redefined
15
-    */
5
+    /**
6
+     * Constructs a Device object.
7
+     *
8
+     * It is CRUTCIAL that the constructor sets $this->supportedEapMethods to an array of methods
9
+     * available for the particular device.
10
+     * {@source}
11
+     * @param string $device a pointer to a device module, which must
12
+     * be an index of one of the devices defined in the {@link Devices}
13
+     * array in {@link devices.php}.
14
+     * @final not to be redefined
15
+     */
16 16
     final public function __construct() {
17
-      $this->supportedEapMethods  = [EAP::$EAP_NONE];
18
-      debug(4,"RedirectEx called");
17
+        $this->supportedEapMethods  = [EAP::$EAP_NONE];
18
+        debug(4,"RedirectEx called");
19 19
     }
20 20
     public function writeDeviceInfo() {
21 21
         $out = "<p>";
Please login to merge, or discard this patch.
devices/linux/Linux.php 1 patch
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -30,17 +30,17 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class Device_Linux extends DeviceConfig {
32 32
 
33
-      final public function __construct() {
33
+        final public function __construct() {
34 34
 //      $this->supportedEapMethods  = array(EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP);
35
-      $this->supportedEapMethods  = [ EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$TTLS_MSCHAP2, EAP::$TLS ];
36
-      $this->local_dir = '.cat_installer';
37
-      $this->conf_file = '$HOME/'.$this->local_dir.'/cat_installer.conf';
38
-      debug(4,"LINUX: This device supports the following EAP methods: ");
39
-      debug(4,$this->supportedEapMethods);
35
+        $this->supportedEapMethods  = [ EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$TTLS_MSCHAP2, EAP::$TLS ];
36
+        $this->local_dir = '.cat_installer';
37
+        $this->conf_file = '$HOME/'.$this->local_dir.'/cat_installer.conf';
38
+        debug(4,"LINUX: This device supports the following EAP methods: ");
39
+        debug(4,$this->supportedEapMethods);
40 40
     }
41 41
 
42
-   public function writeInstaller() {
43
-      $out_string = '#!/usr/bin/env bash
42
+    public function writeInstaller() {
43
+        $out_string = '#!/usr/bin/env bash
44 44
 if [ -z "$BASH" ] ; then
45 45
    bash  $0
46 46
    exit
@@ -48,42 +48,42 @@  discard block
 block discarded – undo
48 48
 
49 49
 
50 50
 ';
51
-      $out_string .= $this->printFunctions();
52
-      $out_string .= $this->printStart();
53
-      $out_string .= $this->printProfileConfirmation();
54
-      $out_string .= $this->printUserConsent();
55
-      $out_string .= $this->printCheckDirectory();
56
-      $CAs = $this->attributes['internal:CAs'][0];
57
-      $this->server_name = $this->glueServerNames($this->attributes['eap:server_name']);
58
-      $this->server_alt_subject_name_list = $this->mkSubjectAltNameList($this->attributes['eap:server_name']);
59
-      $out_string .= "# save certificates\n";
60
-      $out_string .= 'echo "';
61
-      foreach ($CAs as $ca) {
51
+        $out_string .= $this->printFunctions();
52
+        $out_string .= $this->printStart();
53
+        $out_string .= $this->printProfileConfirmation();
54
+        $out_string .= $this->printUserConsent();
55
+        $out_string .= $this->printCheckDirectory();
56
+        $CAs = $this->attributes['internal:CAs'][0];
57
+        $this->server_name = $this->glueServerNames($this->attributes['eap:server_name']);
58
+        $this->server_alt_subject_name_list = $this->mkSubjectAltNameList($this->attributes['eap:server_name']);
59
+        $out_string .= "# save certificates\n";
60
+        $out_string .= 'echo "';
61
+        foreach ($CAs as $ca) {
62 62
         $out_string .= $ca['pem']."\n";
63
-      }
64
-      $out_string .= '"'." > \$HOME/$this->local_dir/ca.pem\n";
63
+        }
64
+        $out_string .= '"'." > \$HOME/$this->local_dir/ca.pem\n";
65 65
 
66
-     $SSIDs = $this->attributes['internal:SSID'];
67
-     $delSSIDs = $this->attributes['internal:remove_SSID'];
66
+        $SSIDs = $this->attributes['internal:SSID'];
67
+        $delSSIDs = $this->attributes['internal:remove_SSID'];
68 68
 
69
-     $out_string .= $this->printNMScript($SSIDs,$delSSIDs);
70
-     $out_string .= $this->writeWpaConf($SSIDs);
71
-     if($this->selected_eap == EAP::$TLS) 
72
-       $out_string .= $this->printP12Dialog();
73
-     else
74
-       $out_string .= $this->printPasswordDialog();
75
-     $out_string .= $this->checkNMResultAndCont();
76
-     $installer_path = $this->installerBasename.'.sh';
77
-      file_put_contents($installer_path, $out_string);
78
-      return($installer_path);
79
-   }
69
+        $out_string .= $this->printNMScript($SSIDs,$delSSIDs);
70
+        $out_string .= $this->writeWpaConf($SSIDs);
71
+        if($this->selected_eap == EAP::$TLS) 
72
+        $out_string .= $this->printP12Dialog();
73
+        else
74
+        $out_string .= $this->printPasswordDialog();
75
+        $out_string .= $this->checkNMResultAndCont();
76
+        $installer_path = $this->installerBasename.'.sh';
77
+        file_put_contents($installer_path, $out_string);
78
+        return($installer_path);
79
+    }
80 80
 
81 81
     public function writeDeviceInfo() {
82 82
     $ssid_ct=count($this->attributes['internal:SSID']);
83 83
     $out = '';
84 84
 
85
-   $out .= _("The installer is in the form of a bash script. It will try to configure eduroam under Network Manager and if this is either not appropriate for your system or your version of Network Manager is too old, a wpa_supplicant config file will be created instead.");
86
-   $out .= "<p>";
85
+    $out .= _("The installer is in the form of a bash script. It will try to configure eduroam under Network Manager and if this is either not appropriate for your system or your version of Network Manager is too old, a wpa_supplicant config file will be created instead.");
86
+    $out .= "<p>";
87 87
     if($ssid_ct > 1) {
88 88
         if($ssid_ct > 2) {
89 89
             $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to the following networks:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
@@ -91,39 +91,39 @@  discard block
 block discarded – undo
91 91
             $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
92 92
         $i = 0;
93 93
         foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
94
-           if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) {
95
-             if($i > 0)
96
-           $out .= ", ";
97
-         $i++;
98
-         $out .= "<strong>$ssid</strong>";
99
-       }
94
+            if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) {
95
+                if($i > 0)
96
+            $out .= ", ";
97
+            $i++;
98
+            $out .= "<strong>$ssid</strong>";
99
+        }
100 100
     }
101 101
     $out .= "<p>";
102 102
     }
103
-   $out .= _("The installer will create .cat_installer sub-directory in your home directory and will copy your server certificates there.");
103
+    $out .= _("The installer will create .cat_installer sub-directory in your home directory and will copy your server certificates there.");
104 104
 if($this->eap == EAP::$TLS)
105
-   $out .= _("In order to connect to the network you will need a personal certificate in the form of a p12 file. You should obtain this certificate from your home institution. Consult the support page to find out how this certificate can be obtained. Such certificate files are password protected. You should have both the file and the password available during the installation process. Your p12 file will also be copied to the .cat_installer directory.");
105
+    $out .= _("In order to connect to the network you will need a personal certificate in the form of a p12 file. You should obtain this certificate from your home institution. Consult the support page to find out how this certificate can be obtained. Such certificate files are password protected. You should have both the file and the password available during the installation process. Your p12 file will also be copied to the .cat_installer directory.");
106 106
 else {
107
-   $out .= _("In order to connect to the network you will need an account from your home institution. You should consult the support page to find out how this account can be obtained. It is very likely that your account is already activated.");
108
-   $out .= "<p>";
109
-   $out .= _("You will be requested to enter your account credentials during the installation. This information will be saved so that you will reconnect to the network automatically each time you are in the range.");
107
+    $out .= _("In order to connect to the network you will need an account from your home institution. You should consult the support page to find out how this account can be obtained. It is very likely that your account is already activated.");
108
+    $out .= "<p>";
109
+    $out .= _("You will be requested to enter your account credentials during the installation. This information will be saved so that you will reconnect to the network automatically each time you are in the range.");
110 110
 }
111 111
     $out .= "<p>";
112 112
     return $out;
113
-  }
113
+    }
114 114
 
115 115
 
116
-  private function printCheckDirectory() {
116
+    private function printCheckDirectory() {
117 117
 $out = 'if [ -d $HOME/'.$this->local_dir.' ] ; then
118 118
    if ! ask "'.sprintf(_("Directory %s exists; some of its files may be overwritten."),'$HOME/'.$this->local_dir).'" "'._("Continue").'" 1 ; then exit; fi
119 119
 else
120 120
   mkdir $HOME/'.$this->local_dir.'
121 121
 fi
122 122
 ';
123
- return $out;
124
-  }
123
+    return $out;
124
+    }
125 125
 
126
-  private function checkNMResultAndCont() {
126
+    private function checkNMResultAndCont() {
127 127
     $out = 'if run_python_script ; then
128 128
    show_info "'._("Installation successful").'"
129 129
 else
@@ -138,50 +138,50 @@  discard block
 block discarded – undo
138 138
    show_info "'.sprintf(_("Output written to %s"),$this->conf_file).'"
139 139
 fi
140 140
 ';
141
-  return $out;
142
-  }
141
+    return $out;
142
+    }
143 143
 
144 144
 private function printStart() {
145
-     $out = "setup_environment\n";
146
-     $out .= 'show_info "'._("This installer has been prepared for \${ORGANISATION}").'\n\n'._("More information and comments:").'\n\nEMAIL: ${SUPPORT}\nWWW: ${URL}\n\n'.
145
+        $out = "setup_environment\n";
146
+        $out .= 'show_info "'._("This installer has been prepared for \${ORGANISATION}").'\n\n'._("More information and comments:").'\n\nEMAIL: ${SUPPORT}\nWWW: ${URL}\n\n'.
147 147
 _("Installer created with software from the GEANT project.").'"
148 148
 ';
149
-  return $out;
149
+    return $out;
150 150
 }
151 151
 
152 152
 
153 153
 private function printProfileConfirmation() {
154
- if($this->attributes['internal:profile_count'][0] > 1)
155
-       $out = 'if ! ask "'.sprintf(_("This installer will only work properly if you are a member of %s and the user group: %s."),'${bf}'.$this->attributes['general:instname'][0].'${n}','${bf}'.$this->attributes['profile:name'][0]).'${n}"';
154
+    if($this->attributes['internal:profile_count'][0] > 1)
155
+        $out = 'if ! ask "'.sprintf(_("This installer will only work properly if you are a member of %s and the user group: %s."),'${bf}'.$this->attributes['general:instname'][0].'${n}','${bf}'.$this->attributes['profile:name'][0]).'${n}"';
156 156
     else
157
-       $out = 'if ! ask "'.sprintf(_("This installer will only work properly if you are a member of %s."),'${bf}'.$this->attributes['general:instname'][0]).'${n}"';
157
+        $out = 'if ! ask "'.sprintf(_("This installer will only work properly if you are a member of %s."),'${bf}'.$this->attributes['general:instname'][0]).'${n}"';
158 158
     $out .= ' "'._("Continue").'" 1 ; then exit; fi
159 159
 ';
160
-  return $out;
160
+    return $out;
161 161
 
162 162
 }
163 163
 
164 164
 
165
-  private function printUserConsent() {
165
+    private function printUserConsent() {
166 166
     $out = '';
167 167
     if(isset($this->attributes['support:info_file'])) {
168
-      if( $this->attributes['internal:info_file'][0]['mime'] == 'txt') {
169
-         $handle = fopen($this->attributes['internal:info_file'][0]['name'],"r");
170
-         $consent = '';
171
-         while (($buffer = fgets($handle, 4096)) !== false) {
172
-           $consent .= rtrim($buffer) . '\n';
173
-         }
174
-         $out = 'if ! ask "'.$consent.'${n}" "'._("Continue").'" 1 ; then exit; fi
168
+        if( $this->attributes['internal:info_file'][0]['mime'] == 'txt') {
169
+            $handle = fopen($this->attributes['internal:info_file'][0]['name'],"r");
170
+            $consent = '';
171
+            while (($buffer = fgets($handle, 4096)) !== false) {
172
+            $consent .= rtrim($buffer) . '\n';
173
+            }
174
+            $out = 'if ! ask "'.$consent.'${n}" "'._("Continue").'" 1 ; then exit; fi
175 175
 ';
176
-      }
176
+        }
177 177
     }
178 178
     return $out;
179
-  }
179
+    }
180 180
 # ask user for confirmation
181 181
 # the first argument is the user prompt
182 182
 # if the second argument is 0 then the first element of yes_no array
183 183
 # will be the default value prompted to the user
184
-  private function printFunctions() {
184
+    private function printFunctions() {
185 185
 $url = (isset($this->attributes['support:url'][0]) && $this->attributes['support:url'][0] ) ? $this->attributes['support:url'][0] : $this->support_url_substitute;
186 186
 $support=(isset($this->attributes['support:email'][0]) && $this->attributes['support:email'][0] ) ? $this->attributes['support:email'][0] : $this->support_email_substitute;
187 187
 $out ='
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
 }
392 392
 
393 393
 
394
-  private function writeWpaConf($SSIDs) {
395
-     $e = EAP::eapDisplayName($this->selected_eap);
394
+    private function writeWpaConf($SSIDs) {
395
+        $e = EAP::eapDisplayName($this->selected_eap);
396 396
 $out = 'function create_wpa_conf {
397 397
 cat << EOFW >> '.$this->conf_file."\n";
398
-     foreach (array_keys($SSIDs) as $ssid) {
398
+        foreach (array_keys($SSIDs) as $ssid) {
399 399
     $out .= '
400 400
 network={
401 401
   ssid="'.$ssid.'"
@@ -405,42 +405,42 @@  discard block
 block discarded – undo
405 405
   eap='.$e['OUTER'].'
406 406
   ca_cert="${HOME}/'.$this->local_dir.'/ca.pem"
407 407
   identity="${USER_NAME}"';
408
-  if($this->server_name)
408
+    if($this->server_name)
409 409
     $out .= '
410 410
   domain_suffix_match="'.$this->server_name.'"';
411
-  if($this->selected_eap == EAP::$TLS) {
411
+    if($this->selected_eap == EAP::$TLS) {
412 412
     $out .= '
413 413
   private_key="${HOME}/'.$this->local_dir.'/user.p12"
414 414
   private_key_passwd="${PASSWORD}"';
415
-  } else {
415
+    } else {
416 416
     $out .= '
417 417
   phase2="auth='.$e['INNER'].'"
418 418
   password="${PASSWORD}"';
419
-  if($this->attributes['internal:use_anon_outer'][0] == 1) 
419
+    if($this->attributes['internal:use_anon_outer'][0] == 1) 
420 420
     $out .= '
421 421
   anonymous_identity="'.$this->attributes['internal:anon_local_value'][0].'@'.$this->attributes['internal:realm'][0].'"';
422
-  }
422
+    }
423 423
     $out .= '
424 424
 }';
425 425
 }
426
-  $out .= '
426
+    $out .= '
427 427
 EOFW
428 428
 chmod 600 '.$this->conf_file.'
429 429
 }
430 430
 ';
431
-  return $out;
431
+    return $out;
432 432
 }
433 433
 
434 434
 
435 435
 
436
-  private function printPasswordDialog() {
437
-  $out = '#prompt user for credentials
436
+    private function printPasswordDialog() {
437
+    $out = '#prompt user for credentials
438 438
   user_cred
439 439
   ';
440
-  return $out;
440
+    return $out;
441 441
 }
442
-  private function printP12Dialog() {
443
-  $out ='function p12dialog {
442
+    private function printP12Dialog() {
443
+    $out ='function p12dialog {
444 444
   if [ ! -z $ZENITY ] ; then
445 445
     if ! cert=`$ZENITY --file-selection --file-filter="'._("personal certificate file (p12 or pfx)").' | *.p12 *.P12 *.pfx *.PFX" --file-filter="All files | *" --title="'._("personal certificate file (p12 or pfx)").'" 2>/dev/null` ; then
446 446
        exit
@@ -499,37 +499,37 @@  discard block
 block discarded – undo
499 499
 }  
500 500
 p12dialog
501 501
 ';
502
- return $out;
502
+    return $out;
503 503
 }
504 504
 
505 505
 
506 506
 private function glueServerNames($server_list) {
507
-  if(! $server_list)
507
+    if(! $server_list)
508 508
     return '';
509
-  $A0 =  array_reverse(explode('.',array_shift($server_list)));
510
-  $B = $A0;
511
-  foreach($server_list as $a) {
512
-     $A= array_reverse(explode('.',$a));
513
-     $B = array_intersect_assoc($A0,$A);
514
-     $A0 = $B;
515
-   }
516
-  return(implode('.',array_reverse($B)));
509
+    $A0 =  array_reverse(explode('.',array_shift($server_list)));
510
+    $B = $A0;
511
+    foreach($server_list as $a) {
512
+        $A= array_reverse(explode('.',$a));
513
+        $B = array_intersect_assoc($A0,$A);
514
+        $A0 = $B;
515
+    }
516
+    return(implode('.',array_reverse($B)));
517 517
 }
518 518
 
519 519
 private function mkSubjectAltNameList($server_list) {
520
-  if(! $server_list)
520
+    if(! $server_list)
521 521
     return '';
522
-  $out = '';
523
-  foreach($server_list as $a) {
524
-     if($out)
525
-       $out .= ','; 
526
-     $out .= "'DNS:$a'";
527
-  }
528
-  return $out;
522
+    $out = '';
523
+    foreach($server_list as $a) {
524
+        if($out)
525
+        $out .= ','; 
526
+        $out .= "'DNS:$a'";
527
+    }
528
+    return $out;
529 529
 }
530 530
 
531 531
 private function printNMScript($SSIDs,$delSSIDs) {
532
-   $e = EAP::eapDisplayName($this->selected_eap);
532
+    $e = EAP::eapDisplayName($this->selected_eap);
533 533
 $out = 'function run_python_script {
534 534
 PASSWORD=$( echo "$PASSWORD" | sed "s/\'/\\\\\\\'/g" )
535 535
 if python << EEE1 > /dev/null 2>&1
@@ -668,20 +668,20 @@  discard block
 block discarded – undo
668 668
             \'identity\': \'$USER_NAME\',
669 669
             \'ca-cert\': dbus.ByteArray("file://{0}\0".format(self.cacert_file).encode(\'utf8\')),';
670 670
     if($this->server_name) {
671
-             $out .= '
671
+                $out .= '
672 672
              match_key: match_value,';
673 673
     }
674 674
     if($this->selected_eap == EAP::$TLS) {
675
-       $out .= '
675
+        $out .= '
676 676
             \'client-cert\':  dbus.ByteArray("file://{0}\0".format(self.pfx_file).encode(\'utf8\')),
677 677
             \'private-key\':  dbus.ByteArray("file://{0}\0".format(self.pfx_file).encode(\'utf8\')),
678 678
             \'private-key-password\':  \'$PASSWORD\',';
679 679
     } else {
680
-       $out .= '
680
+        $out .= '
681 681
             \'password\': \'$PASSWORD\',
682 682
             \'phase2-auth\': \''.strtolower($e['INNER']).'\',';
683
-         if($this->attributes['internal:use_anon_outer'][0] == 1) 
684
-              $out .= '
683
+            if($this->attributes['internal:use_anon_outer'][0] == 1) 
684
+                $out .= '
685 685
             \'anonymous-identity\': \''.$this->attributes['internal:anon_local_value'][0].'@'.$this->attributes['internal:realm'][0].'\',';
686 686
     }
687 687
     $out .= '
@@ -701,17 +701,17 @@  discard block
 block discarded – undo
701 701
     def main(self):
702 702
         self.check_opts()
703 703
         ver = self.connect_to_NM()';
704
-     foreach (array_keys($SSIDs) as $ssid) {
705
-           $out .='
704
+        foreach (array_keys($SSIDs) as $ssid) {
705
+            $out .='
706 706
         self.delete_existing_connections(\''.$ssid.'\')
707 707
         self.add_connection(\''.$ssid.'\')';
708
-     }
708
+        }
709 709
 //   create a list of profiles to be deleted after installation
710
-     foreach ($delSSIDs as $ssid => $cipher) {
711
-         if($cipher == 'DEL')
710
+        foreach ($delSSIDs as $ssid => $cipher) {
711
+            if($cipher == 'DEL')
712 712
             $out .='
713 713
         self.delete_existing_connections(\''.$ssid.'\')';
714
-     }
714
+        }
715 715
 
716 716
 $out .='
717 717
 
Please login to merge, or discard this patch.
devices/devices-template.php 1 patch
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
  */
56 56
 
57 57
 public static $Options=[
58
-  'sign'=>0,
59
-  'no_cache'=>0,
60
-  'hidden'=>0,
61
-  'redirect'=>0,
58
+    'sign'=>0,
59
+    'no_cache'=>0,
60
+    'hidden'=>0,
61
+    'redirect'=>0,
62 62
 ];
63 63
 
64 64
 /**
@@ -96,75 +96,75 @@  discard block
 block discarded – undo
96 96
 
97 97
 public static function listDevices() {
98 98
     return [
99
- 'w10'=>[
100
-   'group' => "microsoft",
101
-   'display'=>_("MS Windows 10"),
102
-   'match'=>'Windows NT 10',
103
-   'directory'=>'ms',
104
-   'module'=>'W8',
105
-   'signer'=>'ms_windows_sign',
99
+    'w10'=>[
100
+    'group' => "microsoft",
101
+    'display'=>_("MS Windows 10"),
102
+    'match'=>'Windows NT 10',
103
+    'directory'=>'ms',
104
+    'module'=>'W8',
105
+    'signer'=>'ms_windows_sign',
106 106
     'options'=>[
107
-       'sign'=>1,
108
-       'device_id'=>'W10',
109
-       'mime'=>'application/x-dosexec',
110
-      ],
111
-   ],
107
+        'sign'=>1,
108
+        'device_id'=>'W10',
109
+        'mime'=>'application/x-dosexec',
110
+        ],
111
+    ],
112 112
 	
113
- 'w8'=>[
114
-   'group' => "microsoft",
115
-   'display'=>_("MS Windows 8, 8.1"),
116
-   'match'=>'Windows NT 6[._][23]',
117
-   'directory'=>'ms',
118
-   'module'=>'W8',
119
-   'signer'=>'ms_windows_sign',
113
+    'w8'=>[
114
+    'group' => "microsoft",
115
+    'display'=>_("MS Windows 8, 8.1"),
116
+    'match'=>'Windows NT 6[._][23]',
117
+    'directory'=>'ms',
118
+    'module'=>'W8',
119
+    'signer'=>'ms_windows_sign',
120 120
     'options'=>[
121
-       'sign'=>1,
122
-       'device_id'=>'W8',
123
-       'mime'=>'application/x-dosexec',
124
-      ],
125
-   ],
121
+        'sign'=>1,
122
+        'device_id'=>'W8',
123
+        'mime'=>'application/x-dosexec',
124
+        ],
125
+    ],
126 126
 	
127
- 'w7'=>[
128
-   'group' => "microsoft",
129
-   'display'=>_("MS Windows 7"),
130
-   'match'=>'Windows NT 6[._]1',
131
-   'directory'=>'ms',
132
-   'module'=>'Vista7',
133
-   'signer'=>'ms_windows_sign',
127
+    'w7'=>[
128
+    'group' => "microsoft",
129
+    'display'=>_("MS Windows 7"),
130
+    'match'=>'Windows NT 6[._]1',
131
+    'directory'=>'ms',
132
+    'module'=>'Vista7',
133
+    'signer'=>'ms_windows_sign',
134 134
     'options'=>[
135
-       'sign'=>1,
136
-       'device_id'=>'W7',
137
-       'mime'=>'application/x-dosexec',
138
-      ],
139
-   ],
135
+        'sign'=>1,
136
+        'device_id'=>'W7',
137
+        'mime'=>'application/x-dosexec',
138
+        ],
139
+    ],
140 140
 	
141
- 'vista'=>[
142
-   'group' => "microsoft",
143
-   'display'=>_("MS Windows Vista"),
144
-   'match'=>'Windows NT 6[._]0',
145
-   'directory'=>'ms',
146
-   'module'=>'Vista7',
147
-   'signer'=>'ms_windows_sign',
141
+    'vista'=>[
142
+    'group' => "microsoft",
143
+    'display'=>_("MS Windows Vista"),
144
+    'match'=>'Windows NT 6[._]0',
145
+    'directory'=>'ms',
146
+    'module'=>'Vista7',
147
+    'signer'=>'ms_windows_sign',
148 148
     'options'=>[
149
-       'sign'=>1,
150
-       'device_id'=>'Vista',
151
-       'mime'=>'application/x-dosexec',
152
-      ],
153
-   ],
149
+        'sign'=>1,
150
+        'device_id'=>'Vista',
151
+        'mime'=>'application/x-dosexec',
152
+        ],
153
+    ],
154 154
 	
155
- 'win-rt'=>[
155
+    'win-rt'=>[
156 156
     'group' => "microsoft",
157 157
     'display'=>_("Windows RT"),
158 158
     'directory'=>'redirect_dev',
159 159
     'module'=>'RedirectDev',
160 160
     'options'=>[
161
-      'hidden'=>0,
162
-      'redirect'=>1,
163
-      ],
164
-   ],
161
+        'hidden'=>0,
162
+        'redirect'=>1,
163
+        ],
164
+    ],
165 165
     
166 166
 
167
- 'apple_el_cap'=>[
167
+    'apple_el_cap'=>[
168 168
     'group' => "apple",
169 169
     'display'=>_("Apple OS X El Capitan"),
170 170
     'match'=>'Mac OS X 10[._]11',
@@ -172,13 +172,13 @@  discard block
 block discarded – undo
172 172
     'module'=>'mobileconfig_os_x',
173 173
     'signer'=>'mobileconfig_sign',
174 174
     'options'=>array(
175
-       'sign'=>1,
176
-       'device_id'=>'OS_X',
177
-       'mime'=>'application/x-apple-aspen-config',
178
-      ),
175
+        'sign'=>1,
176
+        'device_id'=>'OS_X',
177
+        'mime'=>'application/x-apple-aspen-config',
178
+        ),
179 179
     ],
180 180
 
181
- 'apple_yos'=>[
181
+    'apple_yos'=>[
182 182
     'group' => "apple",
183 183
     'display'=>_("Apple OS X Yosemite"),
184 184
     'match'=>'Mac OS X 10[._]10',
@@ -186,13 +186,13 @@  discard block
 block discarded – undo
186 186
     'module'=>'mobileconfig_os_x',
187 187
     'signer'=>'mobileconfig_sign',
188 188
     'options'=>[
189
-       'sign'=>1,
190
-       'device_id'=>'OS_X',
191
-       'mime'=>'application/x-apple-aspen-config',
192
-      ],
189
+        'sign'=>1,
190
+        'device_id'=>'OS_X',
191
+        'mime'=>'application/x-apple-aspen-config',
192
+        ],
193 193
     ],
194 194
 
195
- 'apple_mav'=>[
195
+    'apple_mav'=>[
196 196
     'group' => "apple",
197 197
     'display'=>_("Apple OS X Mavericks"),
198 198
     'match'=>'Mac OS X 10[._]9',
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
     'module'=>'mobileconfig_os_x',
201 201
     'signer'=>'mobileconfig_sign',
202 202
     'options'=>[
203
-       'sign'=>1,
204
-       'device_id'=>'OS_X',
205
-       'mime'=>'application/x-apple-aspen-config',
206
-      ],
203
+        'sign'=>1,
204
+        'device_id'=>'OS_X',
205
+        'mime'=>'application/x-apple-aspen-config',
206
+        ],
207 207
     ],
208 208
 
209
- 'apple_m_lion'=>[
209
+    'apple_m_lion'=>[
210 210
     'group' => "apple",
211 211
     'display'=>_("Apple OS X Mountain Lion"),
212 212
     'match'=>'Mac OS X 10[._]8',
@@ -214,13 +214,13 @@  discard block
 block discarded – undo
214 214
     'module'=>'mobileconfig_os_x',
215 215
     'signer'=>'mobileconfig_sign',
216 216
     'options'=>[
217
-       'sign'=>1,
218
-       'device_id'=>'OS_X',
219
-       'mime'=>'application/x-apple-aspen-config',
220
-      ],
217
+        'sign'=>1,
218
+        'device_id'=>'OS_X',
219
+        'mime'=>'application/x-apple-aspen-config',
220
+        ],
221 221
     ],
222 222
 	
223
- 'apple_lion'=>[
223
+    'apple_lion'=>[
224 224
     'group' => "apple",
225 225
     'display'=>_("Apple OS X Lion"),
226 226
     'match'=>'Mac OS X 10[._]7',
@@ -228,13 +228,13 @@  discard block
 block discarded – undo
228 228
     'module'=>'mobileconfig_os_x',
229 229
     'signer'=>'mobileconfig_sign',
230 230
     'options'=>[
231
-       'sign'=>1,
232
-       'device_id'=>'OS_X',
233
-       'mime'=>'application/x-apple-aspen-config',
234
-      ],
231
+        'sign'=>1,
232
+        'device_id'=>'OS_X',
233
+        'mime'=>'application/x-apple-aspen-config',
234
+        ],
235 235
     ],
236 236
         
237
- 'mobileconfig'=>[
237
+    'mobileconfig'=>[
238 238
     'group' => "apple",     
239 239
     'display'=>_("Apple iOS mobile devices"),
240 240
     'match'=>'(iPad|iPhone|iPod);.*OS [7-9]_',
@@ -242,13 +242,13 @@  discard block
 block discarded – undo
242 242
     'module'=>'mobileconfig_ios',
243 243
     'signer'=>'mobileconfig_sign',
244 244
     'options'=>[
245
-       'sign'=>1,
246
-       'device_id'=>'iOS',
247
-       'mime'=>'application/x-apple-aspen-config',
248
-      ],
245
+        'sign'=>1,
246
+        'device_id'=>'iOS',
247
+        'mime'=>'application/x-apple-aspen-config',
248
+        ],
249 249
     ],
250 250
 
251
- 'mobileconfig-56'=>[
251
+    'mobileconfig-56'=>[
252 252
     'group' => "apple",
253 253
     'display'=>_("Apple iOS mobile devices (iOS 5 and 6)"),
254 254
     'match'=>'(iPad|iPhone|iPod);.*OS [56]_',
@@ -256,132 +256,132 @@  discard block
 block discarded – undo
256 256
     'module'=>'mobileconfig_ios_56',
257 257
     'signer'=>'mobileconfig_sign',
258 258
     'options'=>[
259
-       'sign'=>1,
260
-       'device_id'=>'iOS',
261
-       'mime'=>'application/x-apple-aspen-config',
262
-      ],
259
+        'sign'=>1,
260
+        'device_id'=>'iOS',
261
+        'mime'=>'application/x-apple-aspen-config',
262
+        ],
263 263
     ],
264 264
 
265 265
         
266
- 'linux'=>[
267
-     'group' => "linux",
268
-     'display'=>_("Linux"),
269
-     'match'=>'Linux(?!.*Android)',
270
-     'directory'=>'linux',
271
-     'module' => 'Linux',
272
-     'options'=>[
273
-       'mime'=>'application/x-sh',
274
-      ],
275
-   ],
266
+    'linux'=>[
267
+        'group' => "linux",
268
+        'display'=>_("Linux"),
269
+        'match'=>'Linux(?!.*Android)',
270
+        'directory'=>'linux',
271
+        'module' => 'Linux',
272
+        'options'=>[
273
+        'mime'=>'application/x-sh',
274
+        ],
275
+    ],
276 276
 
277
- 'chromeos'=>[
277
+    'chromeos'=>[
278 278
     'group' => "chrome",
279 279
     'display'=>_("Chrome OS"),
280 280
     'match'=>'CrOS',
281 281
     'directory'=>'chromebook',
282 282
     'module'=>'chromebook',
283 283
     'options'=>[
284
-       'mime'=>'application/x-onc',
285
-       'message'=>sprintf(_("After downloading the file, open the Chrome browser and browse to this URL: <a href='chrome://net-internals/#chromeos'>chrome://net-internals/#chromeos</a>. Then, use the 'Import ONC file' button. The import is silent; the new network definitions will be added to the preferred networks.")),
286
-      ],
287
-   ],
284
+        'mime'=>'application/x-onc',
285
+        'message'=>sprintf(_("After downloading the file, open the Chrome browser and browse to this URL: <a href='chrome://net-internals/#chromeos'>chrome://net-internals/#chromeos</a>. Then, use the 'Import ONC file' button. The import is silent; the new network definitions will be added to the preferred networks.")),
286
+        ],
287
+    ],
288 288
         
289
- 'android_marshmallow'=>[
289
+    'android_marshmallow'=>[
290 290
     'group' => "android",
291 291
     'display'=>_("Android 6.0 Marshmallow"),
292
-     'match'=>'Android 6\.[0-9]',
292
+        'match'=>'Android 6\.[0-9]',
293 293
     'directory'=>'xml',
294 294
     'module'=>'Lollipop',
295 295
     'options'=>[
296
-       'mime'=>'application/eap-config',
297
-       'message'=>sprintf(_("Before you proceed with installation on Android systems, please make sure that you have installed the %s application. This application is available from %s, %s and %s, and will use the configuration file downloaded from CAT to create all necessary settings."),
296
+        'mime'=>'application/eap-config',
297
+        'message'=>sprintf(_("Before you proceed with installation on Android systems, please make sure that you have installed the %s application. This application is available from %s, %s and %s, and will use the configuration file downloaded from CAT to create all necessary settings."),
298 298
                             "eduroamCAT",
299 299
                             "<a target='_blank' href='https://play.google.com/store/apps/details?id=uk.ac.swansea.eduroamcat'>Google Play</a>",
300 300
                             "<a target='_blank' href='unbeknownst'>Amazon Appstore</a>",
301 301
                             "<a target='_blank' href='eduroamCAT-stable.apk'>"._("as local download")."</a>"),
302
-      ],
303
-   ],
302
+        ],
303
+    ],
304 304
 
305
- 'android_lollipop'=>[
305
+    'android_lollipop'=>[
306 306
     'group' => "android",
307 307
     'display'=>_("Android 5.0 Lollipop"),
308
-     'match'=>'Android 5\.[0-9]',
308
+        'match'=>'Android 5\.[0-9]',
309 309
     'directory'=>'xml',
310 310
     'module'=>'Lollipop',
311 311
     'options'=>[
312
-       'mime'=>'application/eap-config',
313
-       'message'=>sprintf(_("Before you proceed with installation on Android systems, please make sure that you have installed the %s application. This application is available from %s, %s and %s, and will use the configuration file downloaded from CAT to create all necessary settings."),
312
+        'mime'=>'application/eap-config',
313
+        'message'=>sprintf(_("Before you proceed with installation on Android systems, please make sure that you have installed the %s application. This application is available from %s, %s and %s, and will use the configuration file downloaded from CAT to create all necessary settings."),
314 314
                             "eduroamCAT",
315 315
                             "<a target='_blank' href='https://play.google.com/store/apps/details?id=uk.ac.swansea.eduroamcat'>Google Play</a>",
316 316
                             "<a target='_blank' href='unbeknownst'>Amazon Appstore</a>",
317 317
                             "<a target='_blank' href='eduroamCAT-stable.apk'>"._("as local download")."</a>"),
318
-      ],
319
-   ],
318
+        ],
319
+    ],
320 320
 
321
- 'android_kitkat'=>[
321
+    'android_kitkat'=>[
322 322
     'group' => "android",
323 323
     'display'=>_("Android 4.4 KitKat"),
324
-     'match'=>'Android 4\.[4-9]',
324
+        'match'=>'Android 4\.[4-9]',
325 325
     'directory'=>'xml',
326 326
     'module'=>'KitKat',
327 327
     'options'=>[
328
-       'mime'=>'application/eap-config',
329
-       'message'=>sprintf(_("Before you proceed with installation on Android systems, please make sure that you have installed the %s application. This application is available from %s, %s and %s, and will use the configuration file downloaded from CAT to create all necessary settings."),
328
+        'mime'=>'application/eap-config',
329
+        'message'=>sprintf(_("Before you proceed with installation on Android systems, please make sure that you have installed the %s application. This application is available from %s, %s and %s, and will use the configuration file downloaded from CAT to create all necessary settings."),
330 330
                             "eduroamCAT",
331 331
                             "<a target='_blank' href='https://play.google.com/store/apps/details?id=uk.ac.swansea.eduroamcat'>Google Play</a>",
332 332
                             "<a target='_blank' href='unbeknownst'>Amazon Appstore</a>",
333 333
                             "<a target='_blank' href='eduroamCAT-stable.apk'>"._("as local download")."</a>"),
334
-      ],
335
-   ],
334
+        ],
335
+    ],
336 336
 
337 337
 
338
- 'android_43'=>[
338
+    'android_43'=>[
339 339
     'group' => "android",
340 340
     'display'=>_("Android 4.3"),
341
-     'match'=>'Android 4\.3',
341
+        'match'=>'Android 4\.3',
342 342
     'directory'=>'xml',
343 343
     'module'=>'KitKat',
344 344
     'options'=>[
345
-       'mime'=>'application/eap-config',
346
-       'message'=>sprintf(_("Before you proceed with installation on Android systems, please make sure that you have installed the %s application. This application is available from %s, %s and %s, and will use the configuration file downloaded from CAT to create all necessary settings."),
345
+        'mime'=>'application/eap-config',
346
+        'message'=>sprintf(_("Before you proceed with installation on Android systems, please make sure that you have installed the %s application. This application is available from %s, %s and %s, and will use the configuration file downloaded from CAT to create all necessary settings."),
347 347
                             "eduroamCAT",
348 348
                             "<a target='_blank' href='https://play.google.com/store/apps/details?id=uk.ac.swansea.eduroamcat'>Google Play</a>",
349 349
                             "<a target='_blank' href='unbeknownst'>Amazon Appstore</a>",
350 350
                             "<a target='_blank' href='eduroamCAT-stable.apk'>"._("as local download")."</a>"),
351
-      ],
352
-   ],
351
+        ],
352
+    ],
353 353
 
354
- 'android_legacy'=>[
355
-     'group' => "android",
356
-     'display'=>_("Android"),
357
-     'match'=>'Android',
358
-     'directory'=>'redirect_dev',
359
-     'module'=>'RedirectDev',
360
-     'options'=>[
361
-       'redirect'=>1,
362
-      ],
363
-   ],
354
+    'android_legacy'=>[
355
+        'group' => "android",
356
+        'display'=>_("Android"),
357
+        'match'=>'Android',
358
+        'directory'=>'redirect_dev',
359
+        'module'=>'RedirectDev',
360
+        'options'=>[
361
+        'redirect'=>1,
362
+        ],
363
+    ],
364 364
 
365
- 'eap-config'=>[
365
+    'eap-config'=>[
366 366
     'group' => "eap-config",
367 367
     'display'=>_("EAP config"),
368 368
     'directory'=>'xml',
369 369
     'module'=>'XML_ALL',
370 370
     'options'=>[
371
-       'mime'=>'application/eap-config',
372
-       'message'=>sprintf(_("This option provides a generic EAP config XML file, which can be consumed by dedicated applications like eduroamCAT for Android and Linux platforms. This is still an experimental feature.")),
373
-      ],
371
+        'mime'=>'application/eap-config',
372
+        'message'=>sprintf(_("This option provides a generic EAP config XML file, which can be consumed by dedicated applications like eduroamCAT for Android and Linux platforms. This is still an experimental feature.")),
373
+        ],
374 374
     ],
375 375
 
376
- 'test'=>[
376
+    'test'=>[
377 377
     'group' => "other",
378 378
     'display'=>_("Test"),
379 379
     'directory'=>'test_module',
380 380
     'module'=>'TestModule',
381 381
     'options'=>[
382
-       'hidden'=>1,
383
-      ],
384
-   ],
382
+        'hidden'=>1,
383
+        ],
384
+    ],
385 385
 
386 386
 
387 387
 /*    
Please login to merge, or discard this patch.
devices/test_module/TestModule.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -70,51 +70,51 @@  discard block
 block discarded – undo
70 70
  * @package ModuleWriting
71 71
  */
72 72
 class Device_TestModule extends DeviceConfig {
73
-   /**
74
-    * Constructs a Device object.
75
-    *
76
-    * It is CRUTCIAL that the constructor sets $this->supportedEapMethods to an array of methods
77
-    * available for the particular device.
78
-    * {@source}
79
-    * @param string $device a pointer to a device module, which must
80
-    * be an index of one of the devices defined in the {@link Devices}
81
-    * array in {@link devices.php}.
82
-    * @final not to be redefined
83
-    */
73
+    /**
74
+     * Constructs a Device object.
75
+     *
76
+     * It is CRUTCIAL that the constructor sets $this->supportedEapMethods to an array of methods
77
+     * available for the particular device.
78
+     * {@source}
79
+     * @param string $device a pointer to a device module, which must
80
+     * be an index of one of the devices defined in the {@link Devices}
81
+     * array in {@link devices.php}.
82
+     * @final not to be redefined
83
+     */
84 84
     final public function __construct() {
85
-      $this->supportedEapMethods  = EAP::listKnownEAPTypes();
86
-      debug(4,"This device supports the following EAP methods: ");
87
-      debug(4,$this->supportedEapMethods);
85
+        $this->supportedEapMethods  = EAP::listKnownEAPTypes();
86
+        debug(4,"This device supports the following EAP methods: ");
87
+        debug(4,$this->supportedEapMethods);
88 88
     }
89 89
 
90
-  /**
91
-   * prepare a zip archive containing files and settings which normally would be used inside the module to produce an installer
92
-   *
93
-   * {@source}
94
-   * @return string installer path name
95
-   */
96
-   public function writeInstaller() {
90
+    /**
91
+     * prepare a zip archive containing files and settings which normally would be used inside the module to produce an installer
92
+     *
93
+     * {@source}
94
+     * @return string installer path name
95
+     */
96
+    public function writeInstaller() {
97 97
 debug(4,"Test Module Installer start\n");
98
-   // create certificate files and save their names in $CA_files arrary
99
-     $CA_files = $this->saveCertificateFiles('der');
98
+    // create certificate files and save their names in $CA_files arrary
99
+        $CA_files = $this->saveCertificateFiles('der');
100 100
   
101 101
     // copy a fixed file from the module Files directory
102
-       if(! $this->copyFile('Module.howto'))
103
-          debug(2, "copying of Module.howto failed\n");
102
+        if(! $this->copyFile('Module.howto'))
103
+            debug(2, "copying of Module.howto failed\n");
104 104
 
105 105
     // copy a fixed file from the module Files directory and saveunde a different name
106
-       if( ! $this->copyFile('test_file','copied_test_file'))
107
-          debug(2, "copying of Module.howto to copied_test_file failed\n");
108
-       $this->dumpAttibutes('profile_attributes');
109
-       $installer_path =  $this->zipInstaller($this->attributes);
110
-       return($installer_path);
111
-   }
106
+        if( ! $this->copyFile('test_file','copied_test_file'))
107
+            debug(2, "copying of Module.howto to copied_test_file failed\n");
108
+        $this->dumpAttibutes('profile_attributes');
109
+        $installer_path =  $this->zipInstaller($this->attributes);
110
+        return($installer_path);
111
+    }
112 112
 
113
-  /**
114
-    * prepare module desctiption and usage information
115
-    * {@source}
116
-    * @return string HTML text to be displayed in the information window
117
-    */
113
+    /**
114
+     * prepare module desctiption and usage information
115
+     * {@source}
116
+     * @return string HTML text to be displayed in the information window
117
+     */
118 118
     public function writeDeviceInfo() {
119 119
     $ssid_ct=count($this->attributes['internal:SSID']);
120 120
     $out = "<p>";
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
 
125 125
 
126 126
 /**
127
-  * zip files and return the archive name
128
-  *
129
-  * inline{@source}
130
-  * return string
131
-  */
132
-  private function zipInstaller($attr) {
127
+ * zip files and return the archive name
128
+ *
129
+ * inline{@source}
130
+ * return string
131
+ */
132
+    private function zipInstaller($attr) {
133 133
     $e = $this->installerBasename.'.zip';
134 134
     $o = system('zip -q '.$e.' *');
135 135
     return $e;
136
-  }
136
+    }
137 137
 
138 138
 }
Please login to merge, or discard this patch.
devices/ms/W8.php 1 patch
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -26,74 +26,74 @@  discard block
 block discarded – undo
26 26
  */
27 27
 class Device_W8 extends WindowsCommon {
28 28
     final public function __construct() {
29
-      $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$TTLS_MSCHAP2, EAP::$PWD];
29
+        $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$TTLS_MSCHAP2, EAP::$PWD];
30 30
 #      $this->supportedEapMethods = array(EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$TTLS_PAP, EAP::$PWD);
31
-      debug(4,"This device supports the following EAP methods: ");
32
-      debug(4,$this->supportedEapMethods);
33
-      $this->specialities['anon_id'][serialize(EAP::$PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead.");
31
+        debug(4,"This device supports the following EAP methods: ");
32
+        debug(4,$this->supportedEapMethods);
33
+        $this->specialities['anon_id'][serialize(EAP::$PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead.");
34 34
     }
35 35
 
36
-  public function writeInstaller() {
37
-      $dom = textdomain(NULL);
38
-      textdomain("devices");
39
-   // create certificate files and save their names in $CA_files arrary
40
-     $CA_files = $this->saveCertificateFiles('der');
36
+    public function writeInstaller() {
37
+        $dom = textdomain(NULL);
38
+        textdomain("devices");
39
+    // create certificate files and save their names in $CA_files arrary
40
+        $CA_files = $this->saveCertificateFiles('der');
41 41
 
42
-     $SSIDs = $this->attributes['internal:SSID'];
43
-     $delSSIDs = $this->attributes['internal:remove_SSID'];
44
-     $this->prepareInstallerLang();
45
-     $set_wired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0;
42
+        $SSIDs = $this->attributes['internal:SSID'];
43
+        $delSSIDs = $this->attributes['internal:remove_SSID'];
44
+        $this->prepareInstallerLang();
45
+        $set_wired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0;
46 46
 //   create a list of profiles to be deleted after installation
47
-     $delProfiles = [];
48
-     foreach ($delSSIDs as $ssid => $cipher) {
49
-         if($cipher == 'DEL')
50
-          $delProfiles[] = $ssid;
51
-         if($cipher == 'TKIP')
52
-          $delProfiles[] = $ssid.' (TKIP)';
53
-     }
54
-
55
-
56
-     if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap ==  EAP::$TTLS_PAP || $this->selected_eap == EAP::$TTLS_MSCHAP2 || $this->selected_eap == EAP::$PWD) {
57
-       $WindowsProfile = [];
58
-       $eap_config = $this->prepareEapConfig($this->attributes);
59
-       $i = 0;
60
-       foreach ($SSIDs as $ssid => $cipher) {
61
-          if($cipher == 'TKIP') {
62
-             $WindowsProfile[$i] = $this->writeWLANprofile ($ssid.' (TKIP)',$ssid,'WPA','TKIP',$eap_config,$i);
63
-             $i++;
64
-          }
65
-          $WindowsProfile[$i] = $this->writeWLANprofile ($ssid,$ssid,'WPA2','AES',$eap_config,$i);
66
-          $i++;
67
-       }
68
-       if($set_wired) {
69
-         $this->writeLANprofile($eap_config);
70
-       }
71
-     } else {
72
-       error("  this EAP type is not handled yet");
73
-       return;
74
-     }
47
+        $delProfiles = [];
48
+        foreach ($delSSIDs as $ssid => $cipher) {
49
+            if($cipher == 'DEL')
50
+            $delProfiles[] = $ssid;
51
+            if($cipher == 'TKIP')
52
+            $delProfiles[] = $ssid.' (TKIP)';
53
+        }
54
+
55
+
56
+        if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap ==  EAP::$TTLS_PAP || $this->selected_eap == EAP::$TTLS_MSCHAP2 || $this->selected_eap == EAP::$PWD) {
57
+        $WindowsProfile = [];
58
+        $eap_config = $this->prepareEapConfig($this->attributes);
59
+        $i = 0;
60
+        foreach ($SSIDs as $ssid => $cipher) {
61
+            if($cipher == 'TKIP') {
62
+                $WindowsProfile[$i] = $this->writeWLANprofile ($ssid.' (TKIP)',$ssid,'WPA','TKIP',$eap_config,$i);
63
+                $i++;
64
+            }
65
+            $WindowsProfile[$i] = $this->writeWLANprofile ($ssid,$ssid,'WPA2','AES',$eap_config,$i);
66
+            $i++;
67
+        }
68
+        if($set_wired) {
69
+            $this->writeLANprofile($eap_config);
70
+        }
71
+        } else {
72
+        error("  this EAP type is not handled yet");
73
+        return;
74
+        }
75 75
     debug(4,"WindowsProfile"); debug(4,$WindowsProfile);
76 76
     
77 77
     $this->writeProfilesNSH($WindowsProfile, $CA_files,$set_wired);
78 78
     $this->writeAdditionalDeletes($delProfiles);
79 79
     if(isset($additional_deletes) && count($additional_deletes))
80
-       $this->writeAdditionalDeletes($additional_deletes);
80
+        $this->writeAdditionalDeletes($additional_deletes);
81 81
     $this->copyFiles($this->selected_eap);
82 82
     if(isset($this->attributes['internal:logo_file']))
83
-       $this->combineLogo($this->attributes['internal:logo_file']);
83
+        $this->combineLogo($this->attributes['internal:logo_file']);
84 84
     $this->writeMainNSH($this->selected_eap,$this->attributes);
85 85
     $this->compileNSIS();
86 86
     $installer_path = $this->signInstaller($this->attributes); 
87 87
 
88 88
     textdomain($dom);
89 89
     return($installer_path);  
90
-  }
90
+    }
91 91
 
92
-  public function writeDeviceInfo() {
92
+    public function writeDeviceInfo() {
93 93
     $ssid_ct=count($this->attributes['internal:SSID']);
94
-   $out = "<p>";
95
-   $out .= sprintf(_("%s installer will be in the form of an EXE file. It will configure %s on your device, by creating wireless network profiles.<p>When you click the download button, the installer will be saved by your browser. Copy it to the machine you want to configure and execute."),Config::$CONSORTIUM['name'],Config::$CONSORTIUM['name']);
96
-   $out .= "<p>";
94
+    $out = "<p>";
95
+    $out .= sprintf(_("%s installer will be in the form of an EXE file. It will configure %s on your device, by creating wireless network profiles.<p>When you click the download button, the installer will be saved by your browser. Copy it to the machine you want to configure and execute."),Config::$CONSORTIUM['name'],Config::$CONSORTIUM['name']);
96
+    $out .= "<p>";
97 97
     if($ssid_ct > 1) {
98 98
         if($ssid_ct > 2) {
99 99
             $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to the following networks:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
@@ -101,52 +101,52 @@  discard block
 block discarded – undo
101 101
             $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
102 102
         $i = 0;
103 103
         foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
104
-           if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) {
105
-             if($i > 0)
106
-           $out .= ", ";
107
-         $i++;
108
-         $out .= "<strong>$ssid</strong>";
109
-       }
104
+            if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) {
105
+                if($i > 0)
106
+            $out .= ", ";
107
+            $i++;
108
+            $out .= "<strong>$ssid</strong>";
109
+        }
110 110
     }
111 111
     $out .= "<p>";
112 112
     }
113 113
 
114 114
 if($this->eap == EAP::$TLS)
115
-   $out .= _("In order to connect to the network you will need an a personal certificate in the form of a p12 file. You should obtain this certificate from your home institution. Consult the support page to find out how this certificate can be obtained. Such certificate files are password protected. You should have both the file and the password available during the installation process.");
115
+    $out .= _("In order to connect to the network you will need an a personal certificate in the form of a p12 file. You should obtain this certificate from your home institution. Consult the support page to find out how this certificate can be obtained. Such certificate files are password protected. You should have both the file and the password available during the installation process.");
116 116
 else {
117
-   $out .= _("In order to connect to the network you will need an account from your home institution. You should consult the support page to find out how this account can be obtained. It is very likely that your account is already activated.");
118
-   $out .= "<p>";
119
-   $out .= _("When you are connecting to the network for the first time, Windows will pop up a login box, where you should enter your user name and password. This information will be saved so that you will reconnect to the network automatically each time you are in the range.");
117
+    $out .= _("In order to connect to the network you will need an account from your home institution. You should consult the support page to find out how this account can be obtained. It is very likely that your account is already activated.");
118
+    $out .= "<p>";
119
+    $out .= _("When you are connecting to the network for the first time, Windows will pop up a login box, where you should enter your user name and password. This information will be saved so that you will reconnect to the network automatically each time you are in the range.");
120 120
         if($ssid_ct > 1) {
121
-             $out .= "<p>";
122
-             $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." ";
123
-             $i = 0;
121
+                $out .= "<p>";
122
+                $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." ";
123
+                $i = 0;
124 124
             foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
125
-                 if($i > 0)
126
-                   $out .= ", ";
127
-                 $i++;
128
-                 $out .= "<strong>$ssid</strong>";
125
+                    if($i > 0)
126
+                    $out .= ", ";
127
+                    $i++;
128
+                    $out .= "<strong>$ssid</strong>";
129 129
             }
130 130
     }
131 131
 
132 132
 
133 133
 }
134 134
     return $out;
135
-  }
135
+    }
136 136
 
137 137
 
138 138
 private function prepareEapConfig($attr) {
139
-   $eap = $this->selected_eap;
140
-   $w8_ext = '';
141
-   $use_anon = $attr['internal:use_anon_outer'] [0];
142
-   if ($use_anon) {
143
-     $outer_user = $attr['internal:anon_local_value'][0];
144
-     $outer_id = $outer_user.'@'.$attr['internal:realm'][0];
145
-   }
139
+    $eap = $this->selected_eap;
140
+    $w8_ext = '';
141
+    $use_anon = $attr['internal:use_anon_outer'] [0];
142
+    if ($use_anon) {
143
+        $outer_user = $attr['internal:anon_local_value'][0];
144
+        $outer_id = $outer_user.'@'.$attr['internal:realm'][0];
145
+    }
146 146
 //   $servers = preg_quote(implode(';',$attr['eap:server_name']));
147
-   $servers = implode(';',$attr['eap:server_name']);
147
+    $servers = implode(';',$attr['eap:server_name']);
148 148
    
149
-   $ca_array = $attr['internal:CAs'][0];
149
+    $ca_array = $attr['internal:CAs'][0];
150 150
 
151 151
 
152 152
 $profile_file_contents = '<EAPConfig><EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 $profile_file_contents .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId>
163 163
 </EapMethod>
164 164
 ';
165
-  $profile_file_contents .= '
165
+    $profile_file_contents .= '
166 166
 
167 167
 <Config xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" 
168 168
   xmlns:eapTls="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV1">
@@ -178,14 +178,14 @@  discard block
 block discarded – undo
178 178
 if($ca_array) {
179 179
 foreach ($ca_array as $CA)
180 180
     if($CA['root'])
181
-       $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n";
181
+        $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n";
182 182
 }
183 183
 $profile_file_contents .= '</eapTls:ServerValidation>
184 184
 ';
185 185
 if(isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on')
186
-   $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>';
186
+    $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>';
187 187
 else
188
-   $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>';
188
+    $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>';
189 189
 $profile_file_contents .= '
190 190
 </eapTls:EapType>
191 191
 </baseEap:Eap>
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 ';
194 194
 } elseif ( $eap == EAP::$PEAP_MSCHAP2) {
195 195
 if(isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on')
196
-   $nea = 'true';
196
+    $nea = 'true';
197 197
 else
198
-   $nea = 'false';
198
+    $nea = 'false';
199 199
 $profile_file_contents .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId>
200 200
 </EapMethod>
201 201
 ';
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 <Phase2Authentication>
261 261
 ';
262 262
 if ( $eap == EAP::$TTLS_PAP) {
263
-   $w8_ext .='<PAPAuthentication /> ';
263
+    $w8_ext .='<PAPAuthentication /> ';
264 264
 }
265 265
 if ( $eap == EAP::$TTLS_MSCHAP2)  {
266
-   $w8_ext .='<MSCHAPv2Authentication>
266
+    $w8_ext .='<MSCHAPv2Authentication>
267 267
 <UseWinlogonCredentials>false</UseWinlogonCredentials>
268 268
 </MSCHAPv2Authentication>
269 269
 ';
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
 <Phase1Identity>
273 273
 ';
274 274
 if($use_anon == 1) {
275
-  $w8_ext .= '<IdentityPrivacy>true</IdentityPrivacy> 
275
+    $w8_ext .= '<IdentityPrivacy>true</IdentityPrivacy> 
276 276
 ';
277
-  if(isset($outer_id) && $outer_id) 
277
+    if(isset($outer_id) && $outer_id) 
278 278
     $w8_ext .='<AnonymousIdentity>'.$outer_id.'</AnonymousIdentity>
279 279
 ';
280
-  else
280
+    else
281 281
     $w8_ext .='<AnonymousIdentity/>
282 282
 ';
283 283
 } else {
284
-  $w8_ext .= '<IdentityPrivacy>false</IdentityPrivacy>
284
+    $w8_ext .= '<IdentityPrivacy>false</IdentityPrivacy>
285 285
 ';
286 286
 }
287 287
 $w8_ext .='</Phase1Identity>
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 $profile_file_contents .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId>
293 293
 </EapMethod>
294 294
 ';
295
-   $profile_file_contents .= '<ConfigBlob></ConfigBlob>';
295
+    $profile_file_contents .= '<ConfigBlob></ConfigBlob>';
296 296
 }
297 297
 
298 298
 $profile_file_contents_end = '</EapHostConfig></EAPConfig>';
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 /**
310 310
  * produce PEAP, TLS and TTLS configuration files for Windows 8
311 311
  */
312
-  private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) {
312
+    private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) {
313 313
 $profile_file_contents = '<?xml version="1.0"?>
314 314
 <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
315 315
 <name>'.$wlan_profile_name.'</name>
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 ';
350 350
 
351 351
 if(! is_dir('w8'))
352
-  mkdir('w8');
352
+    mkdir('w8');
353 353
 $xml_f_name = "w8/wlan_prof-$i.xml";
354 354
 $xml_f = fopen($xml_f_name,'w');
355 355
 fwrite($xml_f,$profile_file_contents. $eap_config['w8']. $closing) ;
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 ';
377 377
 
378 378
 if(! is_dir('w8'))
379
-  mkdir('w8');
379
+    mkdir('w8');
380 380
 $xml_f_name = "w8/lan_prof.xml";
381 381
 $xml_f = fopen($xml_f_name,'w');
382 382
 fwrite($xml_f,$profile_file_contents. $eap_config['w8']. $closing) ;
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 ';
436 436
 
437 437
 if(isset($this->attributes['media:wired'][0]) && $attr['media:wired'][0] == 'on')
438
-  $fcontents .= '!define WIRED
438
+    $fcontents .= '!define WIRED
439 439
 ';
440 440
 
441 441
 $f = fopen('main.nsh','w');
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 debug(4,"writeProfilesNSH");
449 449
 debug(4,$P);
450 450
 $fcontents = '';
451
-  foreach($P as $p) 
451
+    foreach($P as $p) 
452 452
     $fcontents .= "!insertmacro define_wlan_profile $p\n";
453 453
 
454 454
 $f = fopen('profiles.nsh','w');
@@ -459,8 +459,8 @@  discard block
 block discarded – undo
459 459
 $f = fopen('certs.nsh','w');
460 460
 if($ca_array) {
461 461
 foreach ($ca_array as $CA) {
462
-      $store = $CA['root'] ? "root" : "ca";
463
-      $fcontents .= '!insertmacro install_ca_cert "'.$CA['file'].'" "'.$CA['sha1'].'" "'.$store."\"\n";
462
+        $store = $CA['root'] ? "root" : "ca";
463
+        $fcontents .= '!insertmacro install_ca_cert "'.$CA['file'].'" "'.$CA['sha1'].'" "'.$store."\"\n";
464 464
     }
465 465
 fwrite($f, $fcontents);
466 466
 }
@@ -471,26 +471,26 @@  discard block
 block discarded – undo
471 471
 
472 472
 private function copyFiles ($eap) {
473 473
 debug(4,"copyFiles start\n");
474
-   $result;
475
-   $result = $this->copyFile('wlan_test.exe');
476
-   $result = $this->copyFile('check_wired.cmd');
477
-   $result = $this->copyFile('install_wired.cmd');
478
-   $result = $this->copyFile('setEAPCred.exe');
479
-   $result = $this->copyFile('cat_bg.bmp');
480
-   $result = $this->copyFile('base64.nsh');
481
-   $result = $result && $this->copyFile('cat32.ico');
482
-   $result = $result && $this->copyFile('cat_150.bmp');
483
-   $this->translateFile('common.inc','common.nsh',$this->code_page);
484
-   if($eap["OUTER"] == PWD) {
485
-     $this->translateFile('pwd.inc','cat.NSI',$this->code_page);
486
-     $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x32.msi');
487
-     $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi');
488
-   } else {
489
-   $this->translateFile('eap_w8.inc','cat.NSI',$this->code_page);
490
-   $result = 1;
491
-   }
474
+    $result;
475
+    $result = $this->copyFile('wlan_test.exe');
476
+    $result = $this->copyFile('check_wired.cmd');
477
+    $result = $this->copyFile('install_wired.cmd');
478
+    $result = $this->copyFile('setEAPCred.exe');
479
+    $result = $this->copyFile('cat_bg.bmp');
480
+    $result = $this->copyFile('base64.nsh');
481
+    $result = $result && $this->copyFile('cat32.ico');
482
+    $result = $result && $this->copyFile('cat_150.bmp');
483
+    $this->translateFile('common.inc','common.nsh',$this->code_page);
484
+    if($eap["OUTER"] == PWD) {
485
+        $this->translateFile('pwd.inc','cat.NSI',$this->code_page);
486
+        $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x32.msi');
487
+        $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi');
488
+    } else {
489
+    $this->translateFile('eap_w8.inc','cat.NSI',$this->code_page);
490
+    $result = 1;
491
+    }
492 492
 debug(4,"copyFiles end\n");
493
-   return($result);
493
+    return($result);
494 494
 }
495 495
 
496 496
 }
Please login to merge, or discard this patch.
devices/ms/Vista7.php 1 patch
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -26,66 +26,66 @@  discard block
 block discarded – undo
26 26
  */
27 27
 class Device_Vista7 extends WindowsCommon {
28 28
     final public function __construct() {
29
-      $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$PWD];
30
-      debug(4,"This device supports the following EAP methods: ");
31
-      debug(4,$this->supportedEapMethods);
32
-      $this->specialities['anon_id'][serialize(EAP::$PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead.");
29
+        $this->supportedEapMethods = [EAP::$TLS, EAP::$PEAP_MSCHAP2, EAP::$PWD];
30
+        debug(4,"This device supports the following EAP methods: ");
31
+        debug(4,$this->supportedEapMethods);
32
+        $this->specialities['anon_id'][serialize(EAP::$PEAP_MSCHAP2)] = _("Anonymous identities do not use the realm as specified in the profile - it is derived from the suffix of the user's username input instead.");
33 33
     }
34 34
 
35
-  public function writeInstaller() {
36
-      $dom = textdomain(NULL);
37
-      textdomain("devices");
38
-   // create certificate files and save their names in $CA_files arrary
39
-     $CA_files = $this->saveCertificateFiles('der');
35
+    public function writeInstaller() {
36
+        $dom = textdomain(NULL);
37
+        textdomain("devices");
38
+    // create certificate files and save their names in $CA_files arrary
39
+        $CA_files = $this->saveCertificateFiles('der');
40 40
 
41
-     $SSIDs = $this->attributes['internal:SSID'];
42
-     $delSSIDs = $this->attributes['internal:remove_SSID'];
43
-     $this->prepareInstallerLang();
44
-     $set_wired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0;
41
+        $SSIDs = $this->attributes['internal:SSID'];
42
+        $delSSIDs = $this->attributes['internal:remove_SSID'];
43
+        $this->prepareInstallerLang();
44
+        $set_wired = isset($this->attributes['media:wired'][0]) && $this->attributes['media:wired'][0] == 'on' ? 1 : 0;
45 45
 //   create a list of profiles to be deleted after installation
46
-     $delProfiles = [];
47
-     foreach ($delSSIDs as $ssid => $cipher) {
48
-         if($cipher == 'DEL') 
49
-          $delProfiles[] = $ssid;
50
-         if($cipher == 'TKIP') 
51
-          $delProfiles[] = $ssid.' (TKIP)';
52
-     }
53
-
54
-     if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap == EAP::$PWD || $this->selected_eap == EAP::$TTLS_PAP) {
55
-       $WindowsProfile = [];
56
-       $eap_config = $this->prepareEapConfig($this->attributes);
57
-       $i = 0;
58
-       foreach ($SSIDs as $ssid => $cipher) {
59
-          if($cipher == 'TKIP') {
60
-             $WindowsProfile[$i] = $this->writeWLANprofile ($ssid.' (TKIP)',$ssid,'WPA','TKIP',$eap_config,$i);
61
-             $i++;
62
-          }
63
-          $WindowsProfile[$i] = $this->writeWLANprofile ($ssid,$ssid,'WPA2','AES',$eap_config,$i);
64
-          $i++;
65
-       }
66
-       if($set_wired) {
67
-         $this->writeLANprofile($eap_config);
68
-       }
69
-     } else {
70
-       error("  this EAP type is not handled yet");
71
-       return;
72
-     }
46
+        $delProfiles = [];
47
+        foreach ($delSSIDs as $ssid => $cipher) {
48
+            if($cipher == 'DEL') 
49
+            $delProfiles[] = $ssid;
50
+            if($cipher == 'TKIP') 
51
+            $delProfiles[] = $ssid.' (TKIP)';
52
+        }
53
+
54
+        if ($this->selected_eap == EAP::$TLS || $this->selected_eap == EAP::$PEAP_MSCHAP2 || $this->selected_eap == EAP::$PWD || $this->selected_eap == EAP::$TTLS_PAP) {
55
+        $WindowsProfile = [];
56
+        $eap_config = $this->prepareEapConfig($this->attributes);
57
+        $i = 0;
58
+        foreach ($SSIDs as $ssid => $cipher) {
59
+            if($cipher == 'TKIP') {
60
+                $WindowsProfile[$i] = $this->writeWLANprofile ($ssid.' (TKIP)',$ssid,'WPA','TKIP',$eap_config,$i);
61
+                $i++;
62
+            }
63
+            $WindowsProfile[$i] = $this->writeWLANprofile ($ssid,$ssid,'WPA2','AES',$eap_config,$i);
64
+            $i++;
65
+        }
66
+        if($set_wired) {
67
+            $this->writeLANprofile($eap_config);
68
+        }
69
+        } else {
70
+        error("  this EAP type is not handled yet");
71
+        return;
72
+        }
73 73
     debug(4,"WindowsProfile"); debug(4,$WindowsProfile);
74 74
     
75 75
     $this->writeProfilesNSH($WindowsProfile, $CA_files,$set_wired);
76 76
     $this->writeAdditionalDeletes($delProfiles);
77 77
     $this->copyFiles($this->selected_eap);
78 78
     if(isset($this->attributes['internal:logo_file']))
79
-       $this->combineLogo($this->attributes['internal:logo_file']);
79
+        $this->combineLogo($this->attributes['internal:logo_file']);
80 80
     $this->writeMainNSH($this->selected_eap,$this->attributes);
81 81
     $this->compileNSIS();
82 82
     $installer_path = $this->signInstaller($this->attributes); 
83 83
 
84 84
     textdomain($dom);
85 85
     return($installer_path);  
86
-  }
86
+    }
87 87
 
88
-  public function writeDeviceInfo() {
88
+    public function writeDeviceInfo() {
89 89
     $ssid_ct=count($this->attributes['internal:SSID']);
90 90
     $out = "<p>";
91 91
     $out .= sprintf(_("%s installer will be in the form of an EXE file. It will configure %s on your device, by creating wireless network profiles.<p>When you click the download button, the installer will be saved by your browser. Copy it to the machine you want to configure and execute."),Config::$CONSORTIUM['name'],Config::$CONSORTIUM['name']);
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
             $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',Config::$CONSORTIUM['ssid']))." ";
98 98
         $i = 0;
99 99
         foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
100
-           if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) {
101
-             if($i > 0)
102
-           $out .= ", ";
103
-         $i++;
104
-         $out .= "<strong>$ssid</strong>";
105
-       }
100
+            if(! in_array($ssid, Config::$CONSORTIUM['ssid'])) {
101
+                if($i > 0)
102
+            $out .= ", ";
103
+            $i++;
104
+            $out .= "<strong>$ssid</strong>";
105
+        }
106 106
     }
107 107
     $out .= "<p>";
108 108
     }
@@ -115,21 +115,21 @@  discard block
 block discarded – undo
115 115
         $out .= "<p>";
116 116
         $out .= _("When you are connecting to the network for the first time, Windows will pop up a login box, where you should enter your user name and password. This information will be saved so that you will reconnect to the network automatically each time you are in the range.");
117 117
         if($ssid_ct > 1) {
118
-             $out .= "<p>";
119
-             $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." ";
120
-             $i = 0;
118
+                $out .= "<p>";
119
+                $out .= _("You will be required to enter the same credentials for each of the configured notworks:")." ";
120
+                $i = 0;
121 121
             foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
122
-                 if($i > 0)
123
-                   $out .= ", ";
124
-                 $i++;
125
-                 $out .= "<strong>$ssid</strong>";
122
+                    if($i > 0)
123
+                    $out .= ", ";
124
+                    $i++;
125
+                    $out .= "<strong>$ssid</strong>";
126 126
             }
127 127
     }
128 128
 
129
-   }
129
+    }
130 130
 
131
-   }
132
-  return($out);
131
+    }
132
+    return($out);
133 133
 }
134 134
 
135 135
 private function prepareEapConfig($attr) {
@@ -137,25 +137,25 @@  discard block
 block discarded – undo
137 137
     $w7_ext = '';
138 138
     $eap = $this->selected_eap;
139 139
     if ($eap != EAP::$TLS && $eap != EAP::$PEAP_MSCHAP2 && $eap != EAP::$PWD && $eap != EAP::$TTLS_PAP) {
140
-      debug(2,"this method only allows TLS, PEAP, TTLS-PAP or EAP-pwd");
141
-      error("this method only allows TLS, PEAP, TTLS-PAP or EAP-pwd");
142
-     return;
140
+        debug(2,"this method only allows TLS, PEAP, TTLS-PAP or EAP-pwd");
141
+        error("this method only allows TLS, PEAP, TTLS-PAP or EAP-pwd");
142
+        return;
143
+    }
144
+    $use_anon = $attr['internal:use_anon_outer'] [0];
145
+    $realm = $attr['internal:realm'] [0];
146
+    if ($use_anon) {
147
+        $outer_user = $attr['internal:anon_local_value'][0];
143 148
     }
144
-   $use_anon = $attr['internal:use_anon_outer'] [0];
145
-   $realm = $attr['internal:realm'] [0];
146
-   if ($use_anon) {
147
-     $outer_user = $attr['internal:anon_local_value'][0];
148
-   }
149 149
 //   $servers = preg_quote(implode(';',$attr['eap:server_name']));
150
-   $servers = implode(';',$attr['eap:server_name']);
151
-   $ca_array = $attr['internal:CAs'][0];
152
-   $author_id = "0";
153
-   if( $eap == EAP::$TTLS_PAP) {
154
-      $author_id = "17236";
155
-      $servers = implode('</ServerName><ServerName>',$attr['eap:server_name']);
156
-   }
157
-
158
-  $profile_file_contents = '<EAPConfig><EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
150
+    $servers = implode(';',$attr['eap:server_name']);
151
+    $ca_array = $attr['internal:CAs'][0];
152
+    $author_id = "0";
153
+    if( $eap == EAP::$TTLS_PAP) {
154
+        $author_id = "17236";
155
+        $servers = implode('</ServerName><ServerName>',$attr['eap:server_name']);
156
+    }
157
+
158
+    $profile_file_contents = '<EAPConfig><EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
159 159
 <EapMethod>
160 160
 <Type xmlns="http://www.microsoft.com/provisioning/EapCommon">'.
161 161
     $this->selected_eap["OUTER"] .'</Type>
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 ';
167 167
 
168 168
 
169
-   if( $eap == EAP::$TTLS_PAP) {
169
+    if( $eap == EAP::$TTLS_PAP) {
170 170
 $profile_file_contents .= '
171 171
 <Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
172 172
 <EAPIdentityProviderList xmlns="urn:ietf:params:xml:ns:yang:ietf-eap-metadata">
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
 $profile_file_contents .= '<ServerSideCredential>
202 202
 ';
203 203
 
204
-   foreach ($ca_array as $ca) {
204
+    foreach ($ca_array as $ca) {
205 205
       
206
-      $profile_file_contents .= '<CA><format>PEM</format><cert-data>';
207
-      $profile_file_contents .= base64_encode($ca['der']);
208
-      $profile_file_contents .= '</cert-data></CA>
206
+        $profile_file_contents .= '<CA><format>PEM</format><cert-data>';
207
+        $profile_file_contents .= base64_encode($ca['der']);
208
+        $profile_file_contents .= '</cert-data></CA>
209 209
 ';
210
-   }
211
-   $profile_file_contents .= "<ServerName>$servers</ServerName>\n";
210
+    }
211
+    $profile_file_contents .= "<ServerName>$servers</ServerName>\n";
212 212
 
213 213
 $profile_file_contents .= '
214 214
 </ServerSideCredential>
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 }
229 229
 
230 230
 elseif( $eap == EAP::$TLS) {
231
-  $profile_file_contents .= '
231
+    $profile_file_contents .= '
232 232
 
233 233
 <Config xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" 
234 234
   xmlns:eapTls="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV1">
@@ -244,14 +244,14 @@  discard block
 block discarded – undo
244 244
 if($ca_array) {
245 245
 foreach ($ca_array as $CA)
246 246
     if($CA['root'])
247
-       $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n";
247
+        $profile_file_contents .= "<eapTls:TrustedRootCA>".$CA['sha1']."</eapTls:TrustedRootCA>\n";
248 248
 }
249 249
 $profile_file_contents .= '</eapTls:ServerValidation>
250 250
 ';
251 251
 if(isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on')
252
-   $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>';
252
+    $profile_file_contents .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>';
253 253
 else
254
-   $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>';
254
+    $profile_file_contents .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>';
255 255
 $profile_file_contents .= '
256 256
 </eapTls:EapType>
257 257
 </baseEap:Eap>
@@ -259,9 +259,9 @@  discard block
 block discarded – undo
259 259
 ';
260 260
 } elseif ( $eap == EAP::$PEAP_MSCHAP2) {
261 261
 if(isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on')
262
-   $nea = 'true';
262
+    $nea = 'true';
263 263
 else
264
-   $nea = 'false';
264
+    $nea = 'false';
265 265
 $vista_ext = '<Config xmlns:eapUser="http://www.microsoft.com/provisioning/EapUserPropertiesV1" 
266 266
 xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" 
267 267
   xmlns:msPeap="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV1" 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 if($ca_array) {
276 276
 foreach ($ca_array as $CA)
277 277
     if($CA['root'])
278
-       $vista_ext .= "<msPeap:TrustedRootCA>".$CA['sha1']."</msPeap:TrustedRootCA>\n";
278
+        $vista_ext .= "<msPeap:TrustedRootCA>".$CA['sha1']."</msPeap:TrustedRootCA>\n";
279 279
 }
280 280
 $vista_ext .= '</msPeap:ServerValidation>
281 281
 <msPeap:FastReconnect>true</msPeap:FastReconnect> 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 </Config>
330 330
 ';
331 331
 } elseif ( $eap == EAP::$PWD) {
332
-   $profile_file_contents .= '<ConfigBlob></ConfigBlob>';
332
+    $profile_file_contents .= '<ConfigBlob></ConfigBlob>';
333 333
 } 
334 334
 
335 335
 
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 /**
352 352
  * produce PEAP and TLS configuration files for Vista and Windows 7
353 353
  */
354
-  private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) {
354
+    private function writeWLANprofile($wlan_profile_name,$ssid,$auth,$encryption,$eap_config,$i) {
355 355
 $profile_file_contents = '<?xml version="1.0"?>
356 356
 <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
357 357
 <name>'.$wlan_profile_name.'</name>
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
 ';
392 392
 
393 393
 if(! is_dir('w7'))
394
-  mkdir('w7');
394
+    mkdir('w7');
395 395
 if(! is_dir('vista'))
396
-  mkdir('vista');
396
+    mkdir('vista');
397 397
 $xml_f_name = "vista/wlan_prof-$i.xml";
398 398
 $xml_f = fopen($xml_f_name,'w');
399 399
 fwrite($xml_f,$profile_file_contents. $eap_config['vista']. $closing) ;
@@ -423,9 +423,9 @@  discard block
 block discarded – undo
423 423
 </LANProfile>
424 424
 ';
425 425
 if(! is_dir('w7'))
426
-  mkdir('w7');
426
+    mkdir('w7');
427 427
 if(! is_dir('vista'))
428
-  mkdir('vista');
428
+    mkdir('vista');
429 429
 $xml_f_name = "vista/lan_prof.xml";
430 430
 $xml_f = fopen($xml_f_name,'w');
431 431
 fwrite($xml_f,$profile_file_contents. $eap_config['vista']. $closing) ;
@@ -438,16 +438,16 @@  discard block
 block discarded – undo
438 438
 
439 439
 private function glueServerNames($server_list) {
440 440
 //print_r($server_list);
441
- $A0 =  array_reverse(explode('.',array_shift($server_list)));
442
- $B = $A0;
443
- if($server_list) {
444
-   foreach($server_list as $a) {
445
-   $A= array_reverse(explode('.',$a));
446
-   $B = array_intersect_assoc($A0,$A);
447
-   $A0 = $B;
448
-   }
449
-  }
450
-  return(implode('.',array_reverse($B)));
441
+    $A0 =  array_reverse(explode('.',array_shift($server_list)));
442
+    $B = $A0;
443
+    if($server_list) {
444
+    foreach($server_list as $a) {
445
+    $A= array_reverse(explode('.',$a));
446
+    $B = array_intersect_assoc($A0,$A);
447
+    $A0 = $B;
448
+    }
449
+    }
450
+    return(implode('.',array_reverse($B)));
451 451
 }
452 452
 
453 453
 
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 ';
503 503
 
504 504
 if(isset($this->attributes['media:wired'][0]) && $attr['media:wired'][0] == 'on')
505
-  $fcontents .= '!define WIRED
505
+    $fcontents .= '!define WIRED
506 506
 ';
507 507
 
508 508
 $f = fopen('main.nsh','w');
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
 private function writeProfilesNSH($P,$ca_array,$wired=0) {
515 515
 debug(4,"writeProfilesNSH");
516 516
 debug(4,$P);
517
-  $fcontents = '';
518
-  foreach($P as $p) 
517
+    $fcontents = '';
518
+    foreach($P as $p) 
519 519
     $fcontents .= "!insertmacro define_wlan_profile $p\n";
520 520
   
521 521
 $f = fopen('profiles.nsh','w');
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
 $f = fopen('certs.nsh','w');
527 527
 if($ca_array) {
528 528
 foreach ($ca_array as $CA) {
529
-      $store = $CA['root'] ? "root" : "ca";
530
-      $fcontents .= '!insertmacro install_ca_cert "'.$CA['file'].'" "'.$CA['sha1'].'" "'.$store."\"\n";
529
+        $store = $CA['root'] ? "root" : "ca";
530
+        $fcontents .= '!insertmacro install_ca_cert "'.$CA['file'].'" "'.$CA['sha1'].'" "'.$store."\"\n";
531 531
     }
532 532
 fwrite($f, $fcontents);
533 533
 }
@@ -537,33 +537,33 @@  discard block
 block discarded – undo
537 537
 private function copyFiles ($eap) {
538 538
 debug(4,"copyFiles start\n");
539 539
 debug(4,"code_page=".$this->code_page."\n");
540
-   $result;
541
-   $result = $this->copyFile('wlan_test.exe');
542
-   $result = $this->copyFile('check_wired.cmd');
543
-   $result = $this->copyFile('install_wired.cmd');
544
-   $result = $this->copyFile('setEAPCred.exe');
545
-   $result = $this->copyFile('base64.nsh');
546
-   $result = $this->copyFile('cat_bg.bmp');
547
-   $result = $result && $this->copyFile('cat32.ico');
548
-   $result = $result && $this->copyFile('cat_150.bmp');
549
-   $this->translateFile('common.inc','common.nsh',$this->code_page);
550
-   if( $eap["OUTER"] == TTLS)  {
551
-     $result = $this->copyFile('GPL3.rtf');
552
-     $result = $result && $this->copyFile('ArnesLinkEn32.msi');
553
-     $result = $result && $this->copyFile('ArnesLinkEn64.msi');
554
-     $result = $result && $this->copyFile('dump_arneslink_profile.cmd');
555
-     $result = $result && $this->copyFile('install_arneslink_profile.cmd');
556
-     $this->translateFile('arnes_link.inc','cat.NSI',$this->code_page);
557
-   } elseif($eap["OUTER"] == PWD) {
558
-     $this->translateFile('pwd.inc','cat.NSI',$this->code_page);
559
-     $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x32.msi');
560
-     $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi');
540
+    $result;
541
+    $result = $this->copyFile('wlan_test.exe');
542
+    $result = $this->copyFile('check_wired.cmd');
543
+    $result = $this->copyFile('install_wired.cmd');
544
+    $result = $this->copyFile('setEAPCred.exe');
545
+    $result = $this->copyFile('base64.nsh');
546
+    $result = $this->copyFile('cat_bg.bmp');
547
+    $result = $result && $this->copyFile('cat32.ico');
548
+    $result = $result && $this->copyFile('cat_150.bmp');
549
+    $this->translateFile('common.inc','common.nsh',$this->code_page);
550
+    if( $eap["OUTER"] == TTLS)  {
551
+        $result = $this->copyFile('GPL3.rtf');
552
+        $result = $result && $this->copyFile('ArnesLinkEn32.msi');
553
+        $result = $result && $this->copyFile('ArnesLinkEn64.msi');
554
+        $result = $result && $this->copyFile('dump_arneslink_profile.cmd');
555
+        $result = $result && $this->copyFile('install_arneslink_profile.cmd');
556
+        $this->translateFile('arnes_link.inc','cat.NSI',$this->code_page);
557
+    } elseif($eap["OUTER"] == PWD) {
558
+        $this->translateFile('pwd.inc','cat.NSI',$this->code_page);
559
+        $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x32.msi');
560
+        $result = $result && $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi');
561 561
     } else {
562
-     $this->translateFile('peap_tls.inc','cat.NSI',$this->code_page);
563
-     $result = 1;
562
+        $this->translateFile('peap_tls.inc','cat.NSI',$this->code_page);
563
+        $result = 1;
564 564
     }
565 565
 debug(4,"copyFiles end\n");
566
-   return($result);
566
+    return($result);
567 567
 }
568 568
 
569 569
 }
Please login to merge, or discard this patch.
devices/ms/WindowsCommon.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
  * @param string $in input string
19 19
  */
20 20
 function echo_nsi($in) {
21
-  echo preg_replace('/"/','$\"',$in);
21
+    echo preg_replace('/"/','$\"',$in);
22 22
 }
23 23
 
24 24
 function sprint_nsi($in) {
25
-  return preg_replace('/"/','$\"',$in);
25
+    return preg_replace('/"/','$\"',$in);
26 26
 }
27 27
 
28 28
 /**
@@ -35,39 +35,39 @@  discard block
 block discarded – undo
35 35
 
36 36
 protected function prepareInstallerLang() {
37 37
     if(isset($this->LANGS[$this->lang_index])) {
38
-      $L = $this->LANGS[$this->lang_index];
39
-      $this->lang = $L['nsis'];
40
-      $this->code_page = 'cp'.$L['cp'];
38
+        $L = $this->LANGS[$this->lang_index];
39
+        $this->lang = $L['nsis'];
40
+        $this->code_page = 'cp'.$L['cp'];
41 41
     } else {
42
-      $this->lang = 'English';
43
-      $this->code_page = 'cp1252';
42
+        $this->lang = 'English';
43
+        $this->code_page = 'cp1252';
44 44
     }
45 45
 }
46 46
 
47 47
 protected function combineLogo($Logos) {
48 48
     // maximum size to which we want to resize
49
- $max_size= 120;
49
+    $max_size= 120;
50 50
 // logo wull be shited up by this much
51
- $vshift = 20;
52
- $bg_image = new Imagick('cat_bg.bmp');
53
- $bg_image->setFormat('BMP3');
54
- $bg_image_size = $bg_image->getImageGeometry();
55
- $logo = new Imagick($Logos[0]['name']);
56
- $logo_size = $logo->getImageGeometry();
57
- $max = max($logo_size);
58
- debug(4,"Logo size: "); debug(4,$logo_size); debug(4,"max=$max\n");
51
+    $vshift = 20;
52
+    $bg_image = new Imagick('cat_bg.bmp');
53
+    $bg_image->setFormat('BMP3');
54
+    $bg_image_size = $bg_image->getImageGeometry();
55
+    $logo = new Imagick($Logos[0]['name']);
56
+    $logo_size = $logo->getImageGeometry();
57
+    $max = max($logo_size);
58
+    debug(4,"Logo size: "); debug(4,$logo_size); debug(4,"max=$max\n");
59 59
 // resize logo if necessary
60
- if($max > $max_size) {
61
-   if($max == $logo_size['width'])
62
-      $logo->scaleImage($max_size,0);
63
-   else
64
-      $logo->scaleImage(0,$max_size);
65
- }
66
- $logo_size = $logo->getImageGeometry();
67
- debug(4,"New logo size: "); debug(4,$logo_size);
60
+    if($max > $max_size) {
61
+    if($max == $logo_size['width'])
62
+        $logo->scaleImage($max_size,0);
63
+    else
64
+        $logo->scaleImage(0,$max_size);
65
+    }
66
+    $logo_size = $logo->getImageGeometry();
67
+    debug(4,"New logo size: "); debug(4,$logo_size);
68 68
 // calculate logo offsets for composition with the background
69
- $hoffset = round(($bg_image_size['width'] - $logo_size['width'])/2);
70
- $voffset = round(($bg_image_size['height'] - $logo_size['height'])/2) - $vshift;
69
+    $hoffset = round(($bg_image_size['width'] - $logo_size['width'])/2);
70
+    $voffset = round(($bg_image_size['height'] - $logo_size['height'])/2) - $vshift;
71 71
 
72 72
 //logo image is put on top of the background
73 73
 $bg_image->compositeImage($logo, $logo->getImageCompose(), $hoffset, $voffset);
@@ -77,61 +77,61 @@  discard block
 block discarded – undo
77 77
 }
78 78
 
79 79
 protected function signInstaller($attr) {
80
-   $e = $this->installerBasename.'.exe';
81
-   if($this->sign) {
82
-      $o = system($this->sign." installer.exe '$e' > /dev/null");
83
-   }
84
-   else
85
-      rename("installer.exe",$e);
86
-   return $e;
80
+    $e = $this->installerBasename.'.exe';
81
+    if($this->sign) {
82
+        $o = system($this->sign." installer.exe '$e' > /dev/null");
83
+    }
84
+    else
85
+        rename("installer.exe",$e);
86
+    return $e;
87 87
 }
88 88
 
89 89
 protected function compileNSIS() {
90
-   if(Config::$NSIS_VERSION >= 3)
91
-      $makensis = Config::$PATHS['makensis'] . " -INPUTCHARSET UTF8";
92
-   else
93
-      $makensis = Config::$PATHS['makensis']; 
94
-   $o = $makensis.' -V4 cat.NSI > nsis.log';
95
-   system($o);
96
-   debug(4,"compileNSIS:$o\n");
90
+    if(Config::$NSIS_VERSION >= 3)
91
+        $makensis = Config::$PATHS['makensis'] . " -INPUTCHARSET UTF8";
92
+    else
93
+        $makensis = Config::$PATHS['makensis']; 
94
+    $o = $makensis.' -V4 cat.NSI > nsis.log';
95
+    system($o);
96
+    debug(4,"compileNSIS:$o\n");
97 97
 }
98 98
 
99 99
 protected function msInfoFile($attr) {
100
- $out = '';
100
+    $out = '';
101 101
 if(isset($attr['support:info_file'])) {
102 102
     $out .= '!define EXTERNAL_INFO "';
103 103
 //  debug(4,"Info file type ".$attr['support:info_file'][0]['mime']."\n");
104
-  if ($attr['internal:info_file'][0]['mime'] == 'rtf')
105
-     $out = '!define LICENSE_FILE "'. $attr['internal:info_file'][0]['name'];
106
-  elseif( $attr['internal:info_file'][0]['mime'] == 'txt') {
107
-     $in_txt = file_get_contents($attr['internal:info_file'][0]['name']);
108
-     if(Config::$NSIS_VERSION >= 3)
104
+    if ($attr['internal:info_file'][0]['mime'] == 'rtf')
105
+        $out = '!define LICENSE_FILE "'. $attr['internal:info_file'][0]['name'];
106
+    elseif( $attr['internal:info_file'][0]['mime'] == 'txt') {
107
+        $in_txt = file_get_contents($attr['internal:info_file'][0]['name']);
108
+        if(Config::$NSIS_VERSION >= 3)
109 109
         $out_txt = $in_txt;
110
-     else
110
+        else
111 111
         $out_txt = iconv('UTF-8',$this->code_page.'//TRANSLIT',$in_txt);
112
-     if($out_txt) {
112
+        if($out_txt) {
113 113
         file_put_contents('info_f.txt',$out_txt);
114 114
         $out = '!define LICENSE_FILE " info_f.txt';
115
-     }
116
-  }
117
-  else
118
-     $out = '!define EXTERNAL_INFO "'. $attr['internal:info_file'][0]['name'];
115
+        }
116
+    }
117
+    else
118
+        $out = '!define EXTERNAL_INFO "'. $attr['internal:info_file'][0]['name'];
119 119
 
120
-  $out .= "\"\n";
120
+    $out .= "\"\n";
121 121
 }
122
- debug(4,"Info file returned: $out");
123
-  return $out;
122
+    debug(4,"Info file returned: $out");
123
+    return $out;
124 124
 }
125 125
 
126 126
 
127 127
 protected function writeAdditionalDeletes($P) {
128
-  if(count($P) == 0 )
128
+    if(count($P) == 0 )
129 129
     return;
130
-  $f = fopen('profiles.nsh','a');
131
-  fwrite($f,"!define AdditionalDeletes\n");
132
-  foreach ($P as $p)
130
+    $f = fopen('profiles.nsh','a');
131
+    fwrite($f,"!define AdditionalDeletes\n");
132
+    foreach ($P as $p)
133 133
     fwrite($f,"!insertmacro define_delete_profile \"$p\"\n");
134
-  fclose($f);
134
+    fclose($f);
135 135
 }
136 136
 
137 137
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 'af'=>['nsis'=>"Afrikaans",'cp'=>'1252'],
182 182
 'ast'=>['nsis'=>"Asturian",'cp'=>'1252'],
183 183
 
184
-  ];
184
+    ];
185 185
 
186 186
 public $code_page;
187 187
 public $lang;
Please login to merge, or discard this patch.