Project

General

Profile

1
<?php
2

    
3
/*
4
 * Copyright (C) 2017 Manuela v.d.Decken <manuela@isteam.de>
5
 *
6
 * DO NOT ALTER OR REMOVE COPYRIGHT OR THIS HEADER
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation, version 2 of the License.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License 2 for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License 2
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
/**
21
 * @package      Core
22
 * @copyright    Ryan Djurovich
23
 * @author       Ryan Djurovich
24
 * @author       Manuela v.d.Decken <manuela@isteam.de>
25
 * @license      GNU General Public License 2.0
26
 * @version      1.0.1
27
 * @revision     $Id: initialize.php 30 2017-11-25 01:35:18Z Manuela $
28
 * @deprecated   no / since 0000/00/00
29
 * @description  xxx
30
 */
31
// $aPhpFunctions = get_defined_functions();
32
/**
33
 * sanitize $_SERVER['HTTP_REFERER']
34
 * @param string $sWbUrl qualified startup URL of current application
35
 */
36
function SanitizeHttpReferer($sWbUrl = WB_URL)
37
{
38
    $sTmpReferer = '';
39
    if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != '') {
40
        define('ORG_REFERER', ($_SERVER['HTTP_REFERER'] ?: ''));
41
        $aRefUrl = parse_url($_SERVER['HTTP_REFERER']);
42
        if ($aRefUrl !== false) {
43
            $aRefUrl['host'] = isset($aRefUrl['host']) ? $aRefUrl['host'] : '';
44
            $aRefUrl['path'] = isset($aRefUrl['path']) ? $aRefUrl['path'] : '';
45
            $aRefUrl['fragment'] = isset($aRefUrl['fragment']) ? '#'.$aRefUrl['fragment'] : '';
46
            $aWbUrl = parse_url(WB_URL);
47
            if ($aWbUrl !== false) {
48
                $aWbUrl['host'] = isset($aWbUrl['host']) ? $aWbUrl['host'] : '';
49
                $aWbUrl['path'] = isset($aWbUrl['path']) ? $aWbUrl['path'] : '';
50
                if (strpos($aRefUrl['host'].$aRefUrl['path'], $aWbUrl['host'].$aWbUrl['path']) !== false) {
51
                    $aRefUrl['path'] = preg_replace('#^'.$aWbUrl['path'].'#i', '', $aRefUrl['path']);
52
                    $sTmpReferer = WB_URL.$aRefUrl['path'].$aRefUrl['fragment'];
53
                }
54
                unset($aWbUrl);
55
            }
56
            unset($aRefUrl);
57
        }
58
    }
59
    $_SERVER['HTTP_REFERER'] = $sTmpReferer;
60
}
61
/**
62
 * makePhExp
63
 * @param array list of names for placeholders
64
 * @return array reformatted list
65
 * @description makes an RegEx-Expression for preg_replace() of each item in $aList
66
 *              Example: from 'TEST_NAME' it mades '/\[TEST_NAME\]/s'
67
 */
68
function makePhExp($sList)
69
{
70
    $aList = func_get_args();
71
//    return preg_replace('/^(.*)$/', '/\[$1\]/s', $aList);
72
    return preg_replace('/^(.*)$/', '[$1]', $aList);
73
}
74

    
75
/**
76
 * Read DB settings from configuration file
77
 * @return array
78
 * @throws RuntimeException
79
 *
80
 */
81
function initReadSetupFile()
82
{
83
// check for valid file request. Becomes more stronger in next version
84
//    initCheckValidCaller(array('save.php','index.php','config.php','upgrade-script.php'));
85
    $aCfg = array();
86
    $sSetupFile = dirname(dirname(__FILE__)).'/setup.ini.php';
87
    if(is_readable($sSetupFile) && !defined('WB_URL')) {
88
        $aCfg = parse_ini_file($sSetupFile, true);
89
        if (!isset($aCfg['Constants']) || !isset($aCfg['DataBase'])) {
90
            throw new InvalidArgumentException('configuration missmatch in setup.ini.php');
91
        }
92
        foreach($aCfg['Constants'] as $key=>$value) {
93
            switch($key):
94
                case 'DEBUG':
95
                    $value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
96
                    if(!defined('DEBUG')) { define('DEBUG', $value); }
97
                    break;
98
                case 'WB_URL': // << case is set deprecated
99
                case 'AppUrl':
100
                    $value = trim(str_replace('\\', '/', $value), '/');
101
                    if(!defined('WB_URL')) { define('WB_URL', $value); }
102
                    break;
103
                case 'ADMIN_DIRECTORY': // << case is set deprecated
104
                case 'AcpDir':
105
                    $value = trim(str_replace('\\', '/', $value), '/');
106
                    if(!defined('ADMIN_DIRECTORY')) { define('ADMIN_DIRECTORY', $value); }
107
                    break;
108
                default:
109
                    if(!defined($key)) { define($key, $value); }
110
                    break;
111
            endswitch;
112
        }
113
    }
114
    return $aCfg;
115
//      throw new RuntimeException('unable to read setup.ini.php');
116
}
117
/**
118
 * Set constants for system/install values
119
 * @throws RuntimeException
120
 */
121
function initSetInstallWbConstants($aCfg)
122
{
123
    if (sizeof($aCfg)) {
124
        foreach($aCfg['Constants'] as $key=>$value) {
125
            switch($key):
126
                case 'DEBUG':
127
                    $value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
128
                    if(!defined('DEBUG')) { define('DEBUG', $value); }
129
                    break;
130
                case 'WB_URL': // << case is set deprecated
131
                case 'AppUrl':
132
                    $value = trim(str_replace('\\', '/', $value), '/');
133
                    if(!defined('WB_URL')) { define('WB_URL', $value); }
134
                    break;
135
                case 'ADMIN_DIRECTORY': // << case is set deprecated
136
                case 'AcpDir':
137
                    $value = trim(str_replace('\\', '/', $value), '/');
138
                    if(!defined('ADMIN_DIRECTORY')) { define('ADMIN_DIRECTORY', $value); }
139
                    if(!preg_match('/xx[a-z0-9_][a-z0-9_\-\.]+/i', 'xx'.ADMIN_DIRECTORY)) {
140
                        throw new RuntimeException('Invalid admin-directory: ' . ADMIN_DIRECTORY);
141
                    }
142
                    break;
143
                default:
144
                    if(!defined($key)) { define($key, $value); }
145
                    break;
146
            endswitch;
147
        }
148
    }
149
    if(!defined('WB_PATH')){ define('WB_PATH', dirname(__DIR__)); }
150
    if(!defined('ADMIN_URL')){ define('ADMIN_URL', rtrim(WB_URL, '/\\').'/'.ADMIN_DIRECTORY); }
151
    if(!defined('ADMIN_PATH')){ define('ADMIN_PATH', WB_PATH.'/'.ADMIN_DIRECTORY); }
152
    if(!defined('WB_REL')){
153
        $x1 = parse_url(WB_URL);
154
        define('WB_REL', (isset($x1['path']) ? $x1['path'] : ''));
155
    }
156
    if(!defined('ADMIN_REL')){ define('ADMIN_REL', WB_REL.'/'.ADMIN_DIRECTORY); }
157
    if(!defined('DOCUMENT_ROOT')) {
158
        define('DOCUMENT_ROOT', preg_replace('/'.preg_quote(str_replace('\\', '/', WB_REL), '/').'$/', '', str_replace('\\', '/', WB_PATH)));
159
        $_SERVER['DOCUMENT_ROOT'] = DOCUMENT_ROOT;
160
    }
161
    if(!defined('TMP_PATH')){ define('TMP_PATH', WB_PATH.'/temp'); }
162

    
163
    if (defined('DB_TYPE'))
164
    {
165
    // import constants for compatibility reasons
166
        $db = array();
167
        if (defined('DB_TYPE'))      { $db['type']         = DB_TYPE; }
168
        if (defined('DB_USERNAME'))  { $db['user']         = DB_USERNAME; }
169
        if (defined('DB_PASSWORD'))  { $db['pass']         = DB_PASSWORD; }
170
        if (defined('DB_HOST'))      { $db['host']         = DB_HOST; }
171
        if (defined('DB_PORT'))      { $db['port']         = DB_PORT; }
172
        if (defined('DB_NAME'))      { $db['name']         = DB_NAME; }
173
        if (defined('DB_CHARSET'))   { $db['charset']      = DB_CHARSET; }
174
        if (defined('TABLE_PREFIX')) { $db['table_prefix'] = TABLE_PREFIX; }
175
    } else {
176
        foreach($aCfg['DataBase'] as $key=>$value) {
177
            switch($key):
178
                case 'type':
179
                    if(!defined('DB_TYPE')) { define('DB_TYPE', $value); }
180
                    break;
181
                case 'user':
182
                    if(!defined('DB_USERNAME')) { define('DB_USERNAME', $value); }
183
                    break;
184
                case 'pass':
185
                    if(!defined('DB_PASSWORD')) { define('DB_PASSWORD', $value); }
186
                    break;
187
                case 'host':
188
                    if(!defined('DB_HOST')) { define('DB_HOST', $value); }
189
                    break;
190
                case 'port':
191
                    if(!defined('DB_PORT')) { define('DB_PORT', $value); }
192
                    break;
193
                case 'name':
194
                    if(!defined('DB_NAME')) { define('DB_NAME', $value); }
195
                    break;
196
                case 'charset':
197
                    if(!defined('DB_CHARSET')) { define('DB_CHARSET', $value); }
198
                    break;
199
                default:
200
                    $key = strtoupper($key);
201
                    if(!defined($key)) { define($key, $value); }
202
                    break;
203
            endswitch;
204
        }
205
    }
206
}
207

    
208
function WbErrorHandler($iErrorCode, $sErrorText, $sErrorFile, $iErrorLine)
209
{
210
     if (!(error_reporting() & $iErrorCode) || ini_get('log_errors') == 0) {
211
        return false;
212
    }
213
    $bRetval = false;
214
    $sErrorLogFile = ini_get ('error_log');
215
    if (!is_writeable($sErrorLogFile)){return false;}
216
    $sErrorType = E_NOTICE ;
217
    $aErrors = array(
218
        E_USER_DEPRECATED   => 'E_USER_DEPRECATED',
219
        E_USER_NOTICE       => 'E_USER_NOTICE',
220
        E_USER_WARNING      => 'E_USER_WARNING',
221
        E_DEPRECATED        => 'E_DEPRECATED',
222
        E_NOTICE            => 'E_NOTICE',
223
        E_WARNING           => 'E_WARNING',
224
        E_CORE_WARNING      => 'E_CORE_WARNING',
225
        E_COMPILE_WARNING   => 'E_COMPILE_WARNING',
226
        E_STRICT            => 'E_STRICT',
227
        E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
228
    );
229
    if (array_key_exists($iErrorCode, $aErrors)) {
230
        $sErrorType = $aErrors[$iErrorCode];
231
        $bRetval = true;
232
    }
233
    $aBt= debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
234
    $x = sizeof($aBt) -1;
235
    $iSize = $x < 0 ? 0 : ($x <= 2 ? $x : 2);
236
    $sEntry = date('c').' '.'['.$sErrorType.'] '.str_replace(dirname(__DIR__), '', $sErrorFile).':['.$iErrorLine.'] '
237
            . ' from '.str_replace(dirname(__DIR__), '', $aBt[$iSize]['file']).':['.$aBt[$iSize]['line'].'] '
238
            . (isset($aBt[$iSize]['class']) ? $aBt[$iSize]['class'].$aBt[$iSize]['type'] : '').$aBt[$iSize]['function'].' '
239
            . '"'.$sErrorText.'"'.PHP_EOL;
240
    file_put_contents($sErrorLogFile, $sEntry, FILE_APPEND);
241
    return $bRetval;
242
}
243
/**
244
 * create / recreate a admin object
245
 * @param string $section_name (default: '##skip##')
246
 * @param string $section_permission (default: 'start')
247
 * @param bool $auto_header (default: true)
248
 * @param bool $auto_auth (default: true)
249
 * @return \admin
250
 */
251
function newAdmin($section_name= '##skip##', $section_permission = 'start', $auto_header = true, $auto_auth = true)
252
{
253
    if (isset($GLOBALS['admin']) && $GLOBALS['admin'] instanceof admin) {
254
        unset($GLOBALS['admin']);
255
        usleep(10000);
256
    }
257
    return new admin($section_name, $section_permission, $auto_header, $auto_auth);
258
}
259

    
260
/* ***************************************************************************************
261
 * Start initialization                                                                  *
262
 ****************************************************************************************/
263
    // Stop execution if PHP version is too old
264
    // PHP less then 5.6.0 is prohibited ---
265
    if (version_compare(PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION.'.'.PHP_RELEASE_VERSION, '5.6.0', '<')) {
266
        $sMsg = '<p style="color: #ff0000;">WebsiteBaker is not able to run with PHP-Version less then 5.6.0!!<br />'
267
              . 'Please change your PHP-Version to any kind from 5.6.0 and up!<br />'
268
              . 'If you have problems to solve that, ask your hosting provider for it.<br  />'
269
              . 'The very best solution is the use of PHP-7.0 and up</p>';
270
        die($sMsg);
271
    }
272
    error_reporting(E_ALL);
273
    $sStarttime = array_sum(explode(" ", microtime()));
274
    if (!defined('MAX_DATETIME')) { define('MAX_DATETIME', ((2**31)-1)); }
275
    /* -------------------------------------------------------- */
276
    if ( !defined('WB_PATH')) { define('WB_PATH', dirname(__DIR__)); }
277
// activate Autoloader
278
    if (!class_exists('\bin\CoreAutoloader')) {
279
        include __DIR__.'/CoreAutoloader.php';
280
    }
281
    \bin\CoreAutoloader::doRegister(dirname(__DIR__));
282
    \bin\CoreAutoloader::addNamespace([ // add several needed namespaces
283
    //  Namespace               Directory
284
        'bin'                => 'framework',
285
        'addon'              => 'modules',
286
        'vendor'             => 'include',
287
        'vendor\\jscalendar' => 'include/jscalendar',
288
        'bin\\db'            => 'framework/db',
289
        'bin\\security'      => 'framework',
290
        'bin\\interfaces'    => 'framework',
291
        'api'                => 'framework/api',
292
    ]);
293

    
294
    // *** initialize Exception handling
295
    if(!function_exists('globalExceptionHandler')) {
296
        include(__DIR__.'/globalExceptionHandler.php');
297
    }
298
    // *** initialize Error handling
299
    $sErrorLogFile = dirname(__DIR__).'/var/logs/php_error.log.php';
300
    $sErrorLogPath = dirname($sErrorLogFile);
301

    
302
    if (!file_exists($sErrorLogFile)) {
303
        $sTmp = '<?php die(\'illegal file access\'); ?>'
304
              . 'created: ['.date('c').']'.PHP_EOL;
305
        if (false === file_put_contents($sErrorLogFile, $sTmp, FILE_APPEND)) {
306
            throw new Exception('unable to create logfile \'/var/logs/php_error.log.php\'');
307
        }
308
    }
309
    if (!is_writeable($sErrorLogFile)) {
310
        throw new Exception('not writeable logfile \'/var/logs/php_error.log.php\'');
311
    }
312
    ini_set('log_errors', 1);
313
    ini_set ('error_log', $sErrorLogFile);
314

    
315
// activate errorhandler -----------------------------------------------------------------
316
    set_error_handler('WbErrorHandler', -1 );
317
    defined('SYSTEM_RUN') ? '' : define('SYSTEM_RUN', true);
318
// load configuration ---
319
    $aCfg = initReadSetupFile();
320
    initSetInstallWbConstants($aCfg);
321
// activate requester --------------------------------------------------------------------
322
    $oRequest = \bin\HttpRequester();
323
// ---------------------------
324
// get Database connection data from configuration
325
    defined('ADMIN_DIRECTORY') ? '' : define('ADMIN_DIRECTORY', 'admin');
326
    if (
327
        !preg_match('/xx[a-z_][a-z0-9_\-\.]+/i', 'xx'.ADMIN_DIRECTORY) ||
328
        !is_dir(dirname(__DIR__).'/'.ADMIN_DIRECTORY)
329
    ) {
330
        throw new RuntimeException('Invalid admin-directory set: ' . ADMIN_DIRECTORY);
331
    }
332
// add Namespace 'acp' to Autoloader
333
    \bin\CoreAutoloader::addNamespace('acp', ADMIN_DIRECTORY);
334
    defined('ADMIN_URL') ? '' : define('ADMIN_URL', WB_URL.'/'.ADMIN_DIRECTORY);
335
    defined('ADMIN_PATH') ? '' : define('ADMIN_PATH', WB_PATH.'/'.ADMIN_DIRECTORY);
336
    if ( !defined('WB_REL')){
337
        $x1 = parse_url(WB_URL);
338
        define('WB_REL', (isset($x1['path']) ? $x1['path'] : ''));
339
    }
340
    if ( !defined('DOCUMENT_ROOT')) {
341
        define('DOCUMENT_ROOT', preg_replace('/'.preg_quote(str_replace('\\', '/', WB_REL), '/').'$/', '', str_replace('\\', '/', WB_PATH)));
342
        $_SERVER['DOCUMENT_ROOT'] = DOCUMENT_ROOT;
343
    }
344

    
345
    if (class_exists('database')) {
346
        // sanitize $_SERVER['HTTP_REFERER']
347
        SanitizeHttpReferer(WB_URL);
348
        date_default_timezone_set('UTC');
349
        // register TWIG autoloader ---
350
        $sTmp = dirname(dirname(__FILE__)).'/include/Sensio/Twig/lib/Twig/Autoloader.php';
351
        if (!class_exists('Twig_Autoloader') && is_readable($sTmp)){
352
            include $sTmp;
353
            Twig_Autoloader::register();
354
        }
355
    // register PHPMailer autoloader ---
356
        $sTmp = dirname(dirname(__FILE__)).'/include/phpmailer/PHPMailerAutoload.php';
357
        if (!function_exists('PHPMailerAutoload') && is_readable($sTmp)) {
358
            include $sTmp;
359
        }
360
        // Create database class
361
        $database = new database();
362

    
363
        // activate frontend OutputFilterApi (initialize.php)
364
        if (is_readable(WB_PATH .'/modules/output_filter/OutputFilterApi.php')) {
365
            if (!function_exists('OutputFilterApi')) {
366
                include WB_PATH .'/modules/output_filter/OutputFilterApi.php';
367
            }
368
        } else {
369
            throw new RuntimeException('missing mandatory global OutputFilterApi!');
370
        }
371
        // Get website settings (title, keywords, description, header, and footer)
372
        $sql = 'SELECT `name`, `value` FROM `'.TABLE_PREFIX.'settings`';
373
        if (($get_settings = $database->query($sql))) {
374
            $x = 0;
375
            while ($setting = $get_settings->fetchRow(MYSQLI_ASSOC)) {
376
                $setting_name  = strtoupper($setting['name']);
377
                $setting_value = $setting['value'];
378
                if ($setting_value == 'false') {
379
                    $setting_value = false;
380
                }
381
                if ($setting_value == 'true') {
382
                    $setting_value = true;
383
                }
384
                defined($setting_name) ? '' : define($setting_name, $setting_value);
385
                $x++;
386
            }
387
        } else {
388
            die($database->get_error());
389
        }
390
        if (!$x) {
391
            throw new RuntimeException('no settings found');
392
        }
393
        defined('DO_NOT_TRACK') ? '' : define('DO_NOT_TRACK', ($oRequest->issetHeader('DNT')));
394
        ini_set('display_errors', ((defined('DEBUG') && (DEBUG==true)) ? '1' : '0'));
395

    
396
        defined('DEBUG') ? '' : define('DEBUG', false);
397
        $string_file_mode = defined('STRING_FILE_MODE') ? STRING_FILE_MODE : '0644';
398
        defined('OCTAL_FILE_MODE') ? '' : define('OCTAL_FILE_MODE', (int) octdec($string_file_mode));
399
        $string_dir_mode = defined('STRING_DIR_MODE') ? STRING_DIR_MODE : '0755';
400
        defined('OCTAL_DIR_MODE')  ? '' : define('OCTAL_DIR_MODE',  (int) octdec($string_dir_mode));
401
        if (!defined('WB_INSTALL_PROCESS') && !defined('WB_UPGRADE_PROCESS')) {
402
        // get CAPTCHA and ASP settings
403
            $sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_captcha_control`';
404
            if (($get_settings = $database->query($sql)) &&
405
                ($setting = $get_settings->fetchRow(MYSQLI_ASSOC))
406
            ) {
407
                defined('ENABLED_CAPTCHA')     ? '' : define('ENABLED_CAPTCHA',     (bool) ($setting['enabled_captcha'] == '1'));
408
                defined('ENABLED_ASP')         ? '' : define('ENABLED_ASP',         (bool) ($setting['enabled_asp'] == '1'));
409
                defined('CAPTCHA_TYPE')        ? '' : define('CAPTCHA_TYPE',        $setting['captcha_type']);
410
                defined('ASP_SESSION_MIN_AGE') ? '' : define('ASP_SESSION_MIN_AGE', (int) $setting['asp_session_min_age']);
411
                defined('ASP_VIEW_MIN_AGE')    ? '' : define('ASP_VIEW_MIN_AGE',    (int) $setting['asp_view_min_age']);
412
                defined('ASP_INPUT_MIN_AGE')   ? '' : define('ASP_INPUT_MIN_AGE',   (int) $setting['asp_input_min_age']);
413
            } else {
414
                throw new RuntimeException('CAPTCHA-Settings not found');
415
            }
416
        }
417
        // Start a session
418
        if (!defined('SESSION_STARTED')) {
419
            session_name(APP_NAME.'-sid');
420
            @session_start();
421
            define('SESSION_STARTED', true);
422
        }
423
        if (defined('ENABLED_ASP') && ENABLED_ASP && !isset($_SESSION['session_started'])) {
424
            $_SESSION['session_started'] = time();
425
        }
426
        // Get users language
427
        if (
428
            ($sLang = $oRequest->issetParam('lang')) == null ||
429
            !preg_match('/^([a-z]{2})(?:[\-_]([a-z]{2})(?:[\-_]([a-z\-_]{2,8}))?)?$/i', $sLang, $aMatches)
430
        ) {
431
            if (isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') {
432
                define('LANGUAGE', $_SESSION['LANGUAGE']);
433
            } else {
434
                define('LANGUAGE', DEFAULT_LANGUAGE);
435
            }
436
        } else {
437
            $sLang = strtoupper($aMatches[1]);
438
            define('LANGUAGE', $slang);
439
            $_SESSION['LANGUAGE'] = $sLang;
440
        }
441
        $sCachePath = dirname(__DIR__).'/temp/cache/';
442
        if (!file_exists($sCachePath)) {
443
            if (!mkdir($sCachePath, 0777, true)) { $sCachePath = dirname(__DIR__).'/temp/'; }
444
        }
445
        // Load Language file(s)
446
        $sCurrLanguage = '';
447
        $slangFile = WB_PATH.'/languages/EN.php';
448
        if (is_readable($slangFile)) {
449
            require $slangFile;
450
            $sCurrLanguage ='EN';
451
        }
452
        if ($sCurrLanguage != DEFAULT_LANGUAGE) {
453
            $slangFile = WB_PATH.'/languages/'.DEFAULT_LANGUAGE.'.php';
454
            if (is_readable($slangFile)) {
455
                require $slangFile;
456
                $sCurrLanguage = DEFAULT_LANGUAGE;
457
            }
458
        }
459
        if ($sCurrLanguage != LANGUAGE) {
460
            $slangFile = WB_PATH.'/languages/'.LANGUAGE.'.php';
461
            if (is_readable($slangFile)) {
462
                require $slangFile;
463
            }
464
        }
465
// activate Translate --------------------------------------------------------------------
466
        $oTrans = Translate::getInstance();
467
        $oTrans->initialize(array('EN', DEFAULT_LANGUAGE, LANGUAGE), $sCachePath); // 'none'
468
// activate SecureTokens -----------------------------------------------------------------
469
        $oApp = (object) [
470
            'oRequester' => $oRequest,
471
            'oRegistry'  => (object) [
472
                'SecTokenFingerprint' => (bool) SEC_TOKEN_FINGERPRINT,
473
                'SecTokenNetmask4'    => SEC_TOKEN_NETMASK4,
474
                'SecTokenNetmask6'    => SEC_TOKEN_NETMASK6,
475
                'SecTokenLifeTime'    => SEC_TOKEN_LIFE_TIME
476
            ]
477
        ];
478
        \bin\SecureTokens::getInstance($oApp);
479
        \bin\SecureTokens::checkFTAN();
480
// ---------------------------------------------------------------------------------------
481
        // Get users timezone
482
        if (isset($_SESSION['TIMEZONE'])) {
483
            define('TIMEZONE', $_SESSION['TIMEZONE']);
484
        } else {
485
            define('TIMEZONE', DEFAULT_TIMEZONE);
486
        }
487
        // Get users date format
488
        if (isset($_SESSION['DATE_FORMAT'])) {
489
            define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
490
        } else {
491
            define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
492
        }
493
        // Get users time format
494
        if (isset($_SESSION['TIME_FORMAT'])) {
495
            define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
496
        } else {
497
            define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
498
        }
499
        // Set Theme dir
500
        define('THEME_URL', WB_URL.'/templates/'.DEFAULT_THEME);
501
        define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);
502
        // extended wb_settings
503
        define('EDIT_ONE_SECTION', false);
504
        define('EDITOR_WIDTH', 0);
505
    }
(29-29/30)