Code Duplication    Length = 51-51 lines in 2 locations

devices/ms/Device_W8.php 1 location

@@ 293-343 (lines=51) @@
290
     * @param int $profileNumber counter, which profile number is this
291
     * @return string
292
     */
293
    private function writeWLANprofile($wlanProfileName, $ssid, $auth, $encryption, $eapConfig, $profileNumber) {
294
        $profileFileCont = '<?xml version="1.0"?>
295
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
296
<name>' . $wlanProfileName . '</name>
297
<SSIDConfig>
298
<SSID>
299
<name>' . $ssid . '</name>
300
</SSID>
301
<nonBroadcast>true</nonBroadcast>
302
</SSIDConfig>
303
<connectionType>ESS</connectionType>
304
<connectionMode>auto</connectionMode>
305
<autoSwitch>false</autoSwitch>
306
<MSM>
307
<security>
308
<authEncryption>
309
<authentication>' . $auth . '</authentication>
310
<encryption>' . $encryption . '</encryption>
311
<useOneX>true</useOneX>
312
</authEncryption>
313
';
314
        if ($auth == 'WPA2') {
315
            $profileFileCont .= '<PMKCacheMode>enabled</PMKCacheMode> 
316
<PMKCacheTTL>720</PMKCacheTTL> 
317
<PMKCacheSize>128</PMKCacheSize> 
318
<preAuthMode>disabled</preAuthMode> 
319
        ';
320
        }
321
        $profileFileCont .= '<OneX xmlns="http://www.microsoft.com/networking/OneX/v1">
322
<cacheUserData>true</cacheUserData>
323
<authMode>user</authMode>
324
';
325
326
        $closing = '
327
</OneX>
328
</security>
329
</MSM>
330
</WLANProfile>
331
';
332
333
        if (!is_dir('w8')) {
334
            mkdir('w8');
335
        }
336
        $xmlFname = "w8/wlan_prof-$profileNumber.xml";
337
        $xmlF = fopen($xmlFname, 'w');
338
        fwrite($xmlF, $profileFileCont . $eapConfig['w8'] . $closing);
339
        fclose($xmlF);
340
        $this->loggerInstance->debug(2, "Installer has been written into directory $this->FPATH\n");
341
        $this->loggerInstance->debug(4, "WWWWLAN_Profile:$wlanProfileName:$encryption\n");
342
        return("\"$wlanProfileName\" \"$encryption\"");
343
    }
344
345
    private function writeLANprofile($eapConfig) {
346
        $profileFileCont = '<?xml version="1.0"?>

devices/ms/Device_W10.php 1 location

@@ 353-403 (lines=51) @@
350
     * @param int $profileNumber counter, which profile number is this
351
     * @return string
352
     */
353
    private function writeWLANprofile($wlanProfileName, $ssid, $auth, $encryption, $eapConfig, $profileNumber) {
354
        $profileFileCont = '<?xml version="1.0"?>
355
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
356
<name>' . $wlanProfileName . '</name>
357
<SSIDConfig>
358
<SSID>
359
<name>' . $ssid . '</name>
360
</SSID>
361
<nonBroadcast>true</nonBroadcast>
362
</SSIDConfig>
363
<connectionType>ESS</connectionType>
364
<connectionMode>auto</connectionMode>
365
<autoSwitch>false</autoSwitch>
366
<MSM>
367
<security>
368
<authEncryption>
369
<authentication>' . $auth . '</authentication>
370
<encryption>' . $encryption . '</encryption>
371
<useOneX>true</useOneX>
372
</authEncryption>
373
';
374
        if ($auth == 'WPA2') {
375
            $profileFileCont .= '<PMKCacheMode>enabled</PMKCacheMode> 
376
<PMKCacheTTL>720</PMKCacheTTL> 
377
<PMKCacheSize>128</PMKCacheSize> 
378
<preAuthMode>disabled</preAuthMode> 
379
        ';
380
        }
381
        $profileFileCont .= '<OneX xmlns="http://www.microsoft.com/networking/OneX/v1">
382
<cacheUserData>true</cacheUserData>
383
<authMode>user</authMode>
384
';
385
386
        $closing = '
387
</OneX>
388
</security>
389
</MSM>
390
</WLANProfile>
391
';
392
393
        if (!is_dir('w8')) {
394
            mkdir('w8');
395
        }
396
        $xmlFname = "w8/wlan_prof-$profileNumber.xml";
397
        $xmlF = fopen($xmlFname, 'w');
398
        fwrite($xmlF, $profileFileCont . $eapConfig['w10'] . $closing);
399
        fclose($xmlF);
400
        $this->loggerInstance->debug(2, "Installer has been written into directory $this->FPATH\n");
401
        $this->loggerInstance->debug(4, "WWWWLAN_Profile:$wlanProfileName:$encryption\n");
402
        return("\"$wlanProfileName\" \"$encryption\"");
403
    }
404
405
    private function writeLANprofile($eapConfig) {
406
        $profileFileCont = '<?xml version="1.0"?>