Code Duplication    Length = 51-51 lines in 2 locations

devices/ms/Device_W10.php 1 location

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

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"?>