Passed
Push — release_2_0 ( eda638...54acd9 )
by Stefan
07:59
created

WindowsCommon::translateFile()   B

Complexity

Conditions 7
Paths 48

Size

Total Lines 38
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 26
c 1
b 0
f 0
dl 0
loc 38
rs 8.5706
cc 7
nc 48
nop 3
1
<?php
2
3
/*
4
 * *****************************************************************************
5
 * Contributions to this work were made on behalf of the GÉANT project, a 
6
 * project that has received funding from the European Union’s Framework 
7
 * Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus),
8
 * Horizon 2020 research and innovation programme under Grant Agreements No. 
9
 * 691567 (GN4-1) and No. 731122 (GN4-2).
10
 * On behalf of the aforementioned projects, GEANT Association is the sole owner
11
 * of the copyright in all material which was developed by a member of the GÉANT
12
 * project. GÉANT Vereniging (Association) is registered with the Chamber of 
13
 * Commerce in Amsterdam with registration number 40535155 and operates in the 
14
 * UK as a branch of GÉANT Vereniging.
15
 * 
16
 * Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. 
17
 * UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK
18
 *
19
 * License: see the web/copyright.inc.php file in the file structure or
20
 *          <base_url>/copyright.php after deploying the software
21
 */
22
23
/**
24
 * This file contains common functions needed by all Windows installers
25
 * @author Tomasz Wolniewicz <[email protected]>
26
 *
27
 * @package ModuleWriting
28
 */
29
30
namespace devices\ms;
31
32
use \Exception;
33
34
/**
35
 * This class defines common functions needed by all Windows installers
36
 * @author Tomasz Wolniewicz <[email protected]>
37
 *
38
 * @package ModuleWriting
39
 */
40
abstract class WindowsCommon extends \core\DeviceConfig {
41
42
    /**
43
     * copies various common files into temp dir for inclusion into installers
44
     * 
45
     * @return void
46
     * @throws Exception
47
     */
48
    public function copyBasicFiles() {
49
        if (!($this->copyFile('wlan_test.exe') &&
50
                $this->copyFile('check_wired.cmd') &&
51
                $this->copyFile('install_wired.cmd') &&
52
                $this->copyFile('cat_bg.bmp') &&
53
                $this->copyFile('base64.nsh'))) {
54
            throw new Exception("Copying needed files (part 1) failed for at least one file!");
55
        }
56
57
        if (!($this->copyFile('cat32.ico') &&
58
                $this->copyFile('cat_150.bmp') &&
59
                $this->copyFile('WLANSetEAPUserData/WLANSetEAPUserData32.exe', 'WLANSetEAPUserDatax86.exe') &&
60
                $this->copyFile('WLANSetEAPUserData/WLANSetEAPUserData64.exe', 'WLANSetEAPUserDatax64.exe'))) {
61
            throw new Exception("Copying needed files (part 2) failed for at least one file!");
62
        }
63
        if (!$this->translateFile('common.inc', 'common.nsh', $this->codePage)) {
64
            throw new Exception("Translating needed file common.inc failed!");
65
        }
66
        return;
67
    }
68
69
    /**
70
     *  Copy a file from the module location to the temporary directory aplying transcoding.
71
     *
72
     * Transcoding is only required for Windows installers, and no Unicode support
73
     * in NSIS (NSIS version below 3)
74
     * Trancoding is only applied if the third optional parameter is set and nonzero
75
     * If CONFIG['NSIS']_VERSION is set to 3 or more, no transcoding will be applied
76
     * regardless of the third parameter value.
77
     * If the second argument is provided and is not equal to 0, then the file will be
78
     * saved under the name taken from this argument.
79
     * If only one parameter is given or the second is equal to 0, source and destination
80
     * filenames are the same.
81
     * The third optional parameter, if nonzero, should be the character set understood by iconv
82
     * This is required by the Windows installer and is expected to go away in the future.
83
     * Source file can be located either in the Files subdirectory or in the sibdirectory of Files
84
     * named the same as device_id. The second option takes precedence.
85
     *
86
     * @param string $source_name The source file name
87
     * @param string $output_name The destination file name
88
     * @param int    $encoding    Set Windows charset if non-zero
89
     * @return boolean
90
     * @final not to be redefined
91
     */
92
    final protected function translateFile($source_name, $output_name = NULL, $encoding = 0) {
93
        // there is no explicit gettext() call in this function, but catalogues
94
        // and translations occur in the varios ".inc" files - so make sure we
95
        // operate in the correct catalogue
96
        \core\common\Entity::intoThePotatoes();
97
        if (CONFIG_CONFASSISTANT['NSIS_VERSION'] >= 3) {
98
            $encoding = 0;
99
        }
100
        if ($output_name === NULL) {
101
            $output_name = $source_name;
102
        }
103
104
        $this->loggerInstance->debug(5, "translateFile($source_name, $output_name, $encoding)\n");
105
        ob_start();
106
        $this->loggerInstance->debug(5, $this->module_path . '/Files/' . $this->device_id . '/' . $source_name . "\n");
107
        $source = $this->findSourceFile($source_name);
108
109
        if ($source !== FALSE) { // if there is no file found, don't attempt to include an uninitialised variable
110
            include $source;
111
        }
112
        $output = ob_get_clean();
113
        if ($encoding) {
114
            $outputClean = iconv('UTF-8', $encoding . '//TRANSLIT', $output);
115
            if ($outputClean) {
116
                $output = $outputClean;
117
            }
118
        }
119
        $fileHandle = fopen("$output_name", "w");
120
        if ($fileHandle === FALSE) {
121
            $this->loggerInstance->debug(2, "translateFile($source, $output_name, $encoding) failed\n");
122
            \core\common\Entity::outOfThePotatoes();
123
            return FALSE;
124
        }
125
        fwrite($fileHandle, $output);
126
        fclose($fileHandle);
127
        $this->loggerInstance->debug(5, "translateFile($source, $output_name, $encoding) end\n");
128
        \core\common\Entity::outOfThePotatoes();
129
        return TRUE;
130
    }
131
132
        /**
133
     * Transcode a string adding double quotes escaping
134
     *
135
     * Transcoding is only required for Windows installers, and no Unicode support
136
     * in NSIS (NSIS version below 3)
137
     * Trancoding is only applied if the third optional parameter is set and nonzero
138
     * If CONFIG['NSIS']_VERSION is set to 3 or more, no transcoding will be applied
139
     * regardless of the second parameter value.
140
     * The second optional parameter, if nonzero, should be the character set understood by iconv
141
     * This is required by the Windows installer and is expected to go away in the future.
142
     *
143
     * @param string $source_string The source string
144
     * @param int    $encoding      Set Windows charset if non-zero
145
     * @return string
146
     * @final not to be redefined
147
     */
148
    final protected function translateString($source_string, $encoding = 0) {
149
        $this->loggerInstance->debug(5, "translateString input: \"$source_string\"\n");
150
        if (empty($source_string)) {
151
            return $source_string;
152
        }
153
        if (CONFIG_CONFASSISTANT['NSIS_VERSION'] >= 3) {
154
            $encoding = 0;
155
        }
156
        if ($encoding) {
157
            $output_c = iconv('UTF-8', $encoding . '//TRANSLIT', $source_string);
158
        } else {
159
            $output_c = $source_string;
160
        }
161
        if ($output_c) {
162
            $source_string = str_replace('"', '$\\"', $output_c);
163
        } else {
164
            $this->loggerInstance->debug(2, "Failed to convert string \"$source_string\"\n");
165
        }
166
        return $source_string;
167
    }
168
169
    /**
170
     * copies files relevant for EAP-pwd into installer temp directory for later inclusion into installers
171
     * 
172
     * @return void
173
     * @throws Exception
174
     */
175
    public function copyPwdFiles() {
176
        if (!($this->copyFile('Aruba_Networks_EAP-pwd_x32.msi') &&
177
                $this->copyFile('Aruba_Networks_EAP-pwd_x64.msi'))) {
178
            throw new Exception("Copying needed files (EAP-pwd) failed for at least one file!");
179
        }
180
        if (!$this->translateFile('pwd.inc', 'cat.NSI', $this->codePage)) {
181
            throw new Exception("Translating needed file pwd.inc failed!");
182
        }
183
    }
184
185
    /**
186
     * copies GEANTlink files into temp dir for later inclusion into installers
187
     * 
188
     * @return void
189
     * @throws Exception
190
     */
191
    public function copyGeantLinkFiles() {
192
        if (!($this->copyFile('GEANTLink/GEANTLink-x86.msi', 'GEANTLink-x86.msi') &&
193
                $this->copyFile('GEANTLink/GEANTLink-x64.msi', 'GEANTLink-x64.msi') &&
194
                $this->copyFile('GEANTLink/GEANTLink-ARM64.msi', 'GEANTLink-ARM64.msi') &&
195
                $this->copyFile('GEANTLink/CredWrite.exe', 'CredWrite.exe') &&
196
                $this->copyFile('GEANTLink/MsiUseFeature.exe', 'MsiUseFeature.exe'))) {
197
            throw new Exception("Copying needed files (GEANTLink) failed for at least one file!");
198
        }
199
        if (!$this->translateFile('geant_link.inc', 'cat.NSI', $this->codePage)) {
200
            throw new Exception("Translating needed file geant_link.inc failed!");
201
        }
202
    }
203
204
    /**
205
     * function to escape double quotes in a special NSI-compatible way
206
     * 
207
     * @param string $in input string
208
     * @return string
209
     */
210
    public static function echo_nsi($in) {
0 ignored issues
show
Coding Style introduced by
Method name "WindowsCommon::echo_nsi" is not in camel caps format
Loading history...
211
        echo preg_replace('/"/', '$\"', $in);
212
    }
213
214
    /**
215
     * @param string $input input string
216
     * @return string
217
     */
218
    public static function sprint_nsi($input) {
0 ignored issues
show
Coding Style introduced by
Method name "WindowsCommon::sprint_nsi" is not in camel caps format
Loading history...
219
        return preg_replace('/"/', '$\"', $input);
220
    }
221
222
    /**
223
     * constructor. Figures out if GEANTlink is needed/wanted
224
     */
225
    public function __construct() {
226
        parent::__construct();
227
        $this->useGeantLink = (isset($this->options['args']) && $this->options['args'] == 'gl') ? 1 : 0;
228
    }
229
230
    /**
231
     * determine Windows codepage and language settings based on requested installer language
232
     * 
233
     * @return void
234
     */
235
    protected function prepareInstallerLang() {
236
        if (isset($this->LANGS[$this->languageInstance->getLang()])) {
237
            $language = $this->LANGS[$this->languageInstance->getLang()];
238
            $this->lang = $language['nsis'];
239
            $this->codePage = 'cp' . $language['cp'];
240
        } else {
241
            $this->lang = 'English';
242
            $this->codePage = 'cp1252';
243
        }
244
    }
245
246
    /**
247
     * creates HTML code which will be displayed when the "info" button is pressed
248
     * 
249
     * @return string the HTML code
250
     */
251
    public function writeDeviceInfo() {
252
        $ssids = $this->getAttribute('internal:SSID') ?? [];
253
        $ssidCount = count($ssids);
254
        $configList = CONFIG_CONFASSISTANT['CONSORTIUM']['ssid'] ?? [];
255
        $configCount = count($configList);
256
        $out = "<p>";
257
        $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_CONFASSISTANT['CONSORTIUM']['display_name'], CONFIG_CONFASSISTANT['CONSORTIUM']['display_name']);
258
        $out .= "<p>";
259
        if ($ssidCount > $configCount) {
260
            $out .= sprintf(ngettext("In addition to <strong>%s</strong> the installer will also configure access to:", "In addition to <strong>%s</strong> the installer will also configure access to the following networks:", $ssidCount - $configCount), implode(', ', $configList)) . " ";
261
            $out .= '<strong>' . join('</strong>, <strong>', array_diff(array_keys($ssids), $configList)) . '</strong>';
262
            $out .= "<p>";
263
        }
264
// TODO - change this below
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
265
        if ($this->selectedEapObject->isClientCertRequired()) {
266
            $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 organisation. 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.");
267
            return $out;
268
        }
269
        // not EAP-TLS
270
        $out .= _("In order to connect to the network you will need an account from your organisation. 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.");
271
272
        if (!$this->useGeantLink && $this->selectedEap['OUTER'] == \core\common\EAP::TTLS) {
273
            $out .= "<p>";
274
            $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.");
275
            if ($ssidCount > 1) {
276
                $out .= "<p>";
277
                $out .= _("You will be required to enter the same credentials for each of the configured networks:") . " ";
278
                $out .= '<strong>' . join('</strong>, <strong>', array_keys($ssids)) . '</strong>';
279
            }
280
        }
281
        return $out;
282
    }
283
284
    /**
285
     * scales a logo to the desired size
286
     * @param string $imagePath path to the image
287
     * @param int    $maxSize   maximum size of output image (larger axis counts)
288
     * @return \IMagick IMagick image object
289
     */
290
    private function scaleLogo($imagePath, $maxSize) {
291
        $imageObject = new \Imagick($imagePath);
292
        $imageSize = $imageObject->getImageGeometry();
293
        $imageMax = max($imageSize);
294
        $this->loggerInstance->debug(5, "Logo size: ");
295
        $this->loggerInstance->debug(5, $imageSize);
296
        $this->loggerInstance->debug(5, "max=$imageMax\n");
297
// resize logo if necessary
298
        if ($imageMax > $maxSize) {
299
            if ($imageMax == $imageSize['width']) {
300
                $imageObject->scaleImage($maxSize, 0);
301
            } else {
302
                $imageObject->scaleImage(0, $maxSize);
303
            }
304
        }
305
        $imageSize = $imageObject->getImageGeometry();
306
        $this->background['freeHeight'] -= $imageSize['height'];
307
        return($imageObject);
308
    }
309
310
    /**
311
     * combines the inst and federation logo into one image and writes to file
312
     * 
313
     * @param array $logos   inst logo meta info
314
     * @param array $fedLogo fed logo meta info
315
     * @return void
316
     */
317
    protected function combineLogo($logos = NULL, $fedLogo = NULL) {
318
        // maximum size to which we want to resize the logos
319
320
        $maxSize = 120;
321
        // $freeTop is set to how much vertical space we need to leave at the top
322
        // this will depend on the design of the background
323
        $freeTop = 70;
324
        // $freeBottom is set to how much vertical space we need to leave at the bottom
325
        // this will depend on the design of the background
326
        $freeBottom = 30;
327
328
        $bgImage = new \Imagick('cat_bg.bmp');
329
        $bgImage->setFormat('BMP3');
330
        $bgImageSize = $bgImage->getImageGeometry();
331
        $logosToPlace = [];
332
        $this->background = [];
333
        $this->background['freeHeight'] = $bgImageSize['height'] - $freeTop - $freeBottom;
334
335
        if ($this->getAttribute('fed:include_logo_installers') === NULL) {
336
            $fedLogo = NULL;
337
        }
338
        if ($fedLogo != NULL) {
339
            $logosToPlace[] = $this->scaleLogo($fedLogo[0]['name'], $maxSize);
340
        }
341
        if ($logos != NULL) {
342
            $logosToPlace[] = $this->scaleLogo($logos[0]['name'], $maxSize);
343
        }
344
345
        $logoCount = count($logosToPlace);
346
        if ($logoCount > 0) {
347
            $voffset = $freeTop;
348
            $freeSpace = (int) round($this->background['freeHeight'] / ($logoCount + 1));
349
            foreach ($logosToPlace as $logo) {
350
                $voffset += $freeSpace;
351
                $logoSize = $logo->getImageGeometry();
352
                $hoffset = (int) round(($bgImageSize['width'] - $logoSize['width']) / 2);
353
                $bgImage->compositeImage($logo, $logo->getImageCompose(), $hoffset, $voffset);
354
                $voffset += $logoSize['height'];
355
            }
356
        }
357
//new image is saved as the background
358
        $bgImage->writeImage('BMP3:cat_bg.bmp');
359
    }
360
361
    /**
362
     * adds a digital signature to the installer, and returns path to file
363
     * 
364
     * @return string path to signed installer
365
     */
366
    protected function signInstaller() {
367
        $fileName = $this->installerBasename . '.exe';
368
        if (!$this->sign) {
369
            rename("installer.exe", $fileName);
370
            return $fileName;
371
        }
372
        // are actually signing
373
        $outputFromSigning = system($this->sign . " installer.exe '$fileName' > /dev/null");
374
        if ($outputFromSigning === FALSE) {
375
            $this->loggerInstance->debug(2, "Signing the WindowsCommon installer $fileName FAILED!\n");
376
        }
377
        return $fileName;
378
    }
379
380
    /**
381
     * creates one single installer .exe out of the NSH inputs and other files
382
     * 
383
     * @return void
384
     */
385
    protected function compileNSIS() {
386
        if (CONFIG_CONFASSISTANT['NSIS_VERSION'] >= 3) {
387
            $makensis = CONFIG_CONFASSISTANT['PATHS']['makensis'] . " -INPUTCHARSET UTF8";
388
        } else {
389
            $makensis = CONFIG_CONFASSISTANT['PATHS']['makensis'];
390
        }
391
        $lcAll = getenv("LC_ALL");
392
        putenv("LC_ALL=en_US.UTF-8");
393
        $command = $makensis . ' -V4 cat.NSI > nsis.log 2>&1';
394
        system($command);
395
        putenv("LC_ALL=" . $lcAll);
396
        $this->loggerInstance->debug(4, "compileNSIS:$command\n");
397
    }
398
399
    /**
400
     * find out where the user can get support
401
     * 
402
     * @param array  $attr list of profile attributes
403
     * @param string $type which type of support resource to we want
404
     * @return string NSH line with the resulting !define
405
     */
406
    private function getSupport($attr, $type) {
407
        $supportString = [
408
            'email' => 'SUPPORT',
409
            'url' => 'URL',
410
        ];
411
        $s = "support_" . $type . "_substitute";
412
        $substitute = $this->translateString($this->$s, $this->codePage);
413
        $returnValue = !empty($attr['support:' . $type][0]) ? $attr['support:' . $type][0] : $substitute;
414
        return '!define ' . $supportString[$type] . ' "' . $returnValue . '"' . "\n";
415
    }
416
417
    /**
418
     * returns various NSH !define statements for later inclusion into master file
419
     * 
420
     * @param array $attr profile attributes
421
     * @return string
422
     */
423
    protected function writeNsisDefines($attr) {
424
        $fcontents = "\n" . '!define NSIS_MAJOR_VERSION ' . CONFIG_CONFASSISTANT['NSIS_VERSION'];
425
        if ($attr['internal:profile_count'][0] > 1) {
426
            $fcontents .= "\n" . '!define USER_GROUP "' . $this->translateString(str_replace('"', '$\\"', $attr['profile:name'][0]), $this->codePage) . '"
427
';
428
        }
429
        $fcontents .= '
430
Caption "' . $this->translateString(sprintf(WindowsCommon::sprint_nsi(_("%s installer for %s")), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name'], $attr['general:instname'][0]), $this->codePage) . '"
431
!define APPLICATION "' . $this->translateString(sprintf(WindowsCommon::sprint_nsi(_("%s installer for %s")), CONFIG_CONFASSISTANT['CONSORTIUM']['display_name'], $attr['general:instname'][0]), $this->codePage) . '"
432
!define VERSION "' . \core\CAT::VERSION_MAJOR . '.' . \core\CAT::VERSION_MINOR . '"
433
!define INSTALLER_NAME "installer.exe"
434
!define LANG "' . $this->lang . '"
435
!define LOCALE "' . preg_replace('/\..*$/', '', CONFIG['LANGUAGES'][$this->languageInstance->getLang()]['locale']) . '"
436
;--------------------------------
437
!define ORGANISATION "' . $this->translateString($attr['general:instname'][0], $this->codePage) . '"
438
';
439
        $fcontents .= $this->getSupport($attr, 'email');
440
        $fcontents .= $this->getSupport($attr, 'url');
441
        if (\core\common\Entity::getAttributeValue($attr, 'media:wired', 0) == 'on') {
442
            $fcontents .= '!define WIRED
443
        ';
444
        }
445
        $fcontents .= '!define PROVIDERID "urn:UUID:' . $this->deviceUUID . '"
446
';
447
        if (!empty($attr['internal:realm'][0])) {
448
            $fcontents .= '!define REALM "' . $attr['internal:realm'][0] . '"
449
';
450
        }
451
        if (!empty($attr['internal:hint_userinput_suffix'][0]) && $attr['internal:hint_userinput_suffix'][0] == 1) {
452
            $fcontents .= '!define HINT_USER_INPUT "' . $attr['internal:hint_userinput_suffix'][0] . '"
453
';
454
        }
455
        if (!empty($attr['internal:verify_userinput_suffix'][0]) && $attr['internal:verify_userinput_suffix'][0] == 1) {
456
            $fcontents .= '!define VERIFY_USER_REALM_INPUT "' . $attr['internal:verify_userinput_suffix'][0] . '"
457
';
458
        }
459
        $fcontents .= $this->msInfoFile($attr);
460
        return $fcontents;
461
    }
462
463
    /**
464
     * includes NSH commands displaying terms of use file into installer, if any
465
     * 
466
     * @param array $attr profile attributes
467
     * @return string NSH commands
468
     * @throws Exception
469
     */
470
    protected function msInfoFile($attr) {
471
        $out = '';
472
        if (isset($attr['support:info_file'])) {
473
            $out .= '!define EXTERNAL_INFO "';
474
//  $this->loggerInstance->debug(4,"Info file type ".$attr['support:info_file'][0]['mime']."\n");
475
            if ($attr['internal:info_file'][0]['mime'] == 'rtf') {
476
                $out = '!define LICENSE_FILE "' . $attr['internal:info_file'][0]['name'];
477
            } elseif ($attr['internal:info_file'][0]['mime'] == 'txt') {
478
                $infoFile = file_get_contents($attr['internal:info_file'][0]['name']);
479
                if ($infoFile === FALSE) {
480
                    throw new Exception("We were told this file exists. Failing to read it is not really possible.");
481
                }
482
                if (CONFIG_CONFASSISTANT['NSIS_VERSION'] >= 3) {
483
                    $infoFileConverted = $infoFile;
484
                } else {
485
                    $infoFileConverted = iconv('UTF-8', $this->codePage . '//TRANSLIT', $infoFile);
486
                }
487
                if ($infoFileConverted !== FALSE && strlen($infoFileConverted) > 0) {
488
                    file_put_contents('info_f.txt', $infoFileConverted);
489
                    $out = '!define LICENSE_FILE " info_f.txt';
490
                }
491
            } else {
492
                $out = '!define EXTERNAL_INFO "' . $attr['internal:info_file'][0]['name'];
493
            }
494
495
            $out .= "\"\n";
496
        }
497
        $this->loggerInstance->debug(4, "Info file returned: $out");
498
        return $out;
499
    }
500
501
    /**
502
     * writes commands to delete SSIDs, if any, into a file
503
     * 
504
     * @param array $profiles WLAN profiles to delete
505
     * @return void
506
     * @throws Exception
507
     */
508
    protected function writeAdditionalDeletes($profiles) {
509
        if (count($profiles) == 0) {
510
            return;
511
        }
512
        $fileHandle = fopen('profiles.nsh', 'a');
513
        if ($fileHandle === FALSE) {
514
            throw new Exception("Unable to open possibly pre-existing profiles.nsh to append additional deletes.");
515
        }
516
        fwrite($fileHandle, "!define AdditionalDeletes\n");
517
        foreach ($profiles as $profile) {
518
            fwrite($fileHandle, "!insertmacro define_delete_profile \"$profile\"\n");
519
        }
520
        fclose($fileHandle);
521
    }
522
523
    /**
524
     * writes client certificate into file
525
     * 
526
     * @return void
527
     * @throws Exception
528
     */
529
    protected function writeClientP12File() {
530
        if (!is_array($this->clientCert)) {
531
            throw new Exception("the client block was called but there is no client certificate!");
532
        }
533
        file_put_contents('SB_cert.p12', $this->clientCert["certdata"]);
534
    }
535
536
    /**
537
     * nothing special to be done here
538
     * 
539
     * @return void
540
     */
541
    protected function writeTlsUserProfile() {
542
        
543
    }
544
545
    public $LANGS = [
0 ignored issues
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
546
        'fr' => ['nsis' => "French", 'cp' => '1252'],
547
        'de' => ['nsis' => "German", 'cp' => '1252'],
548
        'es' => ['nsis' => "SpanishInternational", 'cp' => '1252'],
549
        'it' => ['nsis' => "Italian", 'cp' => '1252'],
550
        'nl' => ['nsis' => "Dutch", 'cp' => '1252'],
551
        'sv' => ['nsis' => "Swedish", 'cp' => '1252'],
552
        'fi' => ['nsis' => "Finnish", 'cp' => '1252'],
553
        'pl' => ['nsis' => "Polish", 'cp' => '1250'],
554
        'ca' => ['nsis' => "Catalan", 'cp' => '1252'],
555
        'sr' => ['nsis' => "SerbianLatin", 'cp' => '1250'],
556
        'hr' => ['nsis' => "Croatian", 'cp' => '1250'],
557
        'sl' => ['nsis' => "Slovenian", 'cp' => '1250'],
558
        'da' => ['nsis' => "Danish", 'cp' => '1252'],
559
        'nb' => ['nsis' => "Norwegian", 'cp' => '1252'],
560
        'nn' => ['nsis' => "NorwegianNynorsk", 'cp' => '1252'],
561
        'el' => ['nsis' => "Greek", 'cp' => '1253'],
562
        'ru' => ['nsis' => "Russian", 'cp' => '1251'],
563
        'pt' => ['nsis' => "Portuguese", 'cp' => '1252'],
564
        'uk' => ['nsis' => "Ukrainian", 'cp' => '1251'],
565
        'cs' => ['nsis' => "Czech", 'cp' => '1250'],
566
        'sk' => ['nsis' => "Slovak", 'cp' => '1250'],
567
        'bg' => ['nsis' => "Bulgarian", 'cp' => '1251'],
568
        'hu' => ['nsis' => "Hungarian", 'cp' => '1250'],
569
        'ro' => ['nsis' => "Romanian", 'cp' => '1250'],
570
        'lv' => ['nsis' => "Latvian", 'cp' => '1257'],
571
        'mk' => ['nsis' => "Macedonian", 'cp' => '1251'],
572
        'et' => ['nsis' => "Estonian", 'cp' => '1257'],
573
        'tr' => ['nsis' => "Turkish", 'cp' => '1254'],
574
        'lt' => ['nsis' => "Lithuanian", 'cp' => '1257'],
575
        'ar' => ['nsis' => "Arabic", 'cp' => '1256'],
576
        'he' => ['nsis' => "Hebrew", 'cp' => '1255'],
577
        'id' => ['nsis' => "Indonesian", 'cp' => '1252'],
578
        'mn' => ['nsis' => "Mongolian", 'cp' => '1251'],
579
        'sq' => ['nsis' => "Albanian", 'cp' => '1252'],
580
        'br' => ['nsis' => "Breton", 'cp' => '1252'],
581
        'be' => ['nsis' => "Belarusian", 'cp' => '1251'],
582
        'is' => ['nsis' => "Icelandic", 'cp' => '1252'],
583
        'ms' => ['nsis' => "Malay", 'cp' => '1252'],
584
        'bs' => ['nsis' => "Bosnian", 'cp' => '1250'],
585
        'ga' => ['nsis' => "Irish", 'cp' => '1250'],
586
        'uz' => ['nsis' => "Uzbek", 'cp' => '1251'],
587
        'gl' => ['nsis' => "Galician", 'cp' => '1252'],
588
        'af' => ['nsis' => "Afrikaans", 'cp' => '1252'],
589
        'ast' => ['nsis' => "Asturian", 'cp' => '1252'],
590
    ];
591
    public $codePage;
0 ignored issues
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
592
    public $lang;
0 ignored issues
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
593
    public $useGeantLink;
0 ignored issues
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
594
    private $background;
0 ignored issues
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
595
596
}
597