Code Duplication    Length = 49-51 lines in 2 locations

devices/ms/Device_W10.php 1 location

@@ 353-401 (lines=49) @@
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
        file_put_contents($xmlFname, $profileFileCont . $eapConfig['w10'] . $closing);
398
        $this->loggerInstance->debug(2, "Installer has been written into directory $this->FPATH\n");
399
        $this->loggerInstance->debug(4, "WWWWLAN_Profile:$wlanProfileName:$encryption\n");
400
        return("\"$wlanProfileName\" \"$encryption\"");
401
    }
402
403
    private function writeLANprofile($eapConfig) {
404
        $profileFileCont = '<?xml version="1.0"?>

devices/ms/Device_W8.php 1 location

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