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

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

    
301
    // *** initialize Exception handling
302
    if(!function_exists('globalExceptionHandler')) {
303
        include(__DIR__.'/globalExceptionHandler.php');
304
    }
305
    // *** initialize Error handling
306
    $sErrorLogFile = dirname(__DIR__).'/var/logs/php_error.log.php';
307
    $sErrorLogPath = dirname($sErrorLogFile);
308

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

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

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

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

    
401
        defined('DEBUG') ? '' : define('DEBUG', false);
402
        $string_file_mode = defined('STRING_FILE_MODE') ? STRING_FILE_MODE : '0644';
403
        defined('OCTAL_FILE_MODE') ? '' : define('OCTAL_FILE_MODE', (int) octdec($string_file_mode));
404
        $string_dir_mode = defined('STRING_DIR_MODE') ? STRING_DIR_MODE : '0755';
405
        defined('OCTAL_DIR_MODE')  ? '' : define('OCTAL_DIR_MODE',  (int) octdec($string_dir_mode));
406
    //    $sSecMod = (defined('SECURE_FORM_MODULE') && SECURE_FORM_MODULE != '') ? '.'.SECURE_FORM_MODULE : '';
407
    //    $sSecMod = WB_PATH.'/framework/SecureForm'.$sSecMod.'.php';
408
    //    require_once($sSecMod);
409
        if (!defined('WB_INSTALL_PROCESS')) {
410
        // get CAPTCHA and ASP settings
411
            $sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_captcha_control`';
412
            if (($get_settings = $database->query($sql)) &&
413
                ($setting = $get_settings->fetchRow(MYSQLI_ASSOC))
414
            ) {
415
                defined('ENABLED_CAPTCHA')     ? '' : define('ENABLED_CAPTCHA',     (bool) ($setting['enabled_captcha'] == '1'));
416
                defined('ENABLED_ASP')         ? '' : define('ENABLED_ASP',         (bool) ($setting['enabled_asp'] == '1'));
417
                defined('CAPTCHA_TYPE')        ? '' : define('CAPTCHA_TYPE',        $setting['captcha_type']);
418
                defined('ASP_SESSION_MIN_AGE') ? '' : define('ASP_SESSION_MIN_AGE', (int) $setting['asp_session_min_age']);
419
                defined('ASP_VIEW_MIN_AGE')    ? '' : define('ASP_VIEW_MIN_AGE',    (int) $setting['asp_view_min_age']);
420
                defined('ASP_INPUT_MIN_AGE')   ? '' : define('ASP_INPUT_MIN_AGE',   (int) $setting['asp_input_min_age']);
421
            } else {
422
                throw new RuntimeException('CAPTCHA-Settings not found');
423
            }
424
        }
425

    
426
        // Start a session
427
        if (!defined('SESSION_STARTED')) {
428
            session_name(APP_NAME.'-sid');
429
            @session_start();
430
            define('SESSION_STARTED', true);
431
        }
432
        if (defined('ENABLED_ASP') && ENABLED_ASP && !isset($_SESSION['session_started'])) {
433
            $_SESSION['session_started'] = time();
434
        }
435
        // Get users language
436
        if (
437
            isset($_GET['lang']) AND
438
            $_GET['lang'] != '' AND
439
            !is_numeric($_GET['lang']) AND
440
            strlen($_GET['lang']) == 2
441
        ) {
442
            define('LANGUAGE', strtoupper($_GET['lang']));
443
            $_SESSION['LANGUAGE']=LANGUAGE;
444
        } else {
445
            if (isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') {
446
                define('LANGUAGE', $_SESSION['LANGUAGE']);
447
            } else {
448
                define('LANGUAGE', DEFAULT_LANGUAGE);
449
            }
450
        }
451
        $sCachePath = dirname(__DIR__).'/temp/cache/';
452
        if (!file_exists($sCachePath)) {
453
            if (!mkdir($sCachePath, 0777, true)) { $sCachePath = dirname(__DIR__).'/temp/'; }
454
        }
455
        // Load Language file(s)
456
        $sCurrLanguage = '';
457
        $slangFile = WB_PATH.'/languages/EN.php';
458
        if (is_readable($slangFile)) {
459
            require $slangFile;
460
            $sCurrLanguage ='EN';
461
        }
462
        if ($sCurrLanguage != DEFAULT_LANGUAGE) {
463
            $slangFile = WB_PATH.'/languages/'.DEFAULT_LANGUAGE.'.php';
464
            if (is_readable($slangFile)) {
465
                require $slangFile;
466
                $sCurrLanguage = DEFAULT_LANGUAGE;
467
            }
468
        }
469
        if ($sCurrLanguage != LANGUAGE) {
470
            $slangFile = WB_PATH.'/languages/'.LANGUAGE.'.php';
471
            if (is_readable($slangFile)) {
472
                require $slangFile;
473
            }
474
        }
475
        $oTrans = Translate::getInstance();
476
        $oTrans->initialize(array('EN', DEFAULT_LANGUAGE, LANGUAGE), $sCachePath); // 'none'
477
        // Get users timezone
478
        if (isset($_SESSION['TIMEZONE'])) {
479
            define('TIMEZONE', $_SESSION['TIMEZONE']);
480
        } else {
481
            define('TIMEZONE', DEFAULT_TIMEZONE);
482
        }
483
        // Get users date format
484
        if (isset($_SESSION['DATE_FORMAT'])) {
485
            define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
486
        } else {
487
            define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
488
        }
489
        // Get users time format
490
        if (isset($_SESSION['TIME_FORMAT'])) {
491
            define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
492
        } else {
493
            define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
494
        }
495
        // Set Theme dir
496
        define('THEME_URL', WB_URL.'/templates/'.DEFAULT_THEME);
497
        define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);
498
        // extended wb_settings
499
        define('EDIT_ONE_SECTION', false);
500
        define('EDITOR_WIDTH', 0);
501
    }
(27-27/28)