Project

General

Profile

wb-2_10_x / branches / main / framework / initialize.php @ 6

1
<?php
2
/**
3
 *
4
 * @category        framework
5
 * @package         initialize
6
 * @author          WebsiteBaker Project
7
 * @copyright       Ryan Djurovich
8
 * @copyright       WebsiteBaker Org. e.V.
9
 * @link            http://websitebaker.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.3
12
 * @requirements    PHP 5.3.6 and higher
13
 * @version         $Id: initialize.php 6 2017-08-28 00:03:54Z Manuela $
14
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/branches/main/framework/initialize.php $
15
 * @lastmodified    $Date: 2017-08-28 02:03:54 +0200 (Mon, 28 Aug 2017) $
16
 *
17
 */
18
// $aPhpFunctions = get_defined_functions();
19
/**
20
 * sanitize $_SERVER['HTTP_REFERER']
21
 * @param string $sWbUrl qualified startup URL of current application
22
 */
23
function SanitizeHttpReferer($sWbUrl = WB_URL)
24
{
25
    $sTmpReferer = '';
26
    if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != '') {
27
        define('ORG_REFERER', ($_SERVER['HTTP_REFERER'] ?: ''));
28
        $aRefUrl = parse_url($_SERVER['HTTP_REFERER']);
29
        if ($aRefUrl !== false) {
30
            $aRefUrl['host'] = isset($aRefUrl['host']) ? $aRefUrl['host'] : '';
31
            $aRefUrl['path'] = isset($aRefUrl['path']) ? $aRefUrl['path'] : '';
32
            $aRefUrl['fragment'] = isset($aRefUrl['fragment']) ? '#'.$aRefUrl['fragment'] : '';
33
            $aWbUrl = parse_url(WB_URL);
34
            if ($aWbUrl !== false) {
35
                $aWbUrl['host'] = isset($aWbUrl['host']) ? $aWbUrl['host'] : '';
36
                $aWbUrl['path'] = isset($aWbUrl['path']) ? $aWbUrl['path'] : '';
37
                if (strpos($aRefUrl['host'].$aRefUrl['path'], $aWbUrl['host'].$aWbUrl['path']) !== false) {
38
                    $aRefUrl['path'] = preg_replace('#^'.$aWbUrl['path'].'#i', '', $aRefUrl['path']);
39
                    $sTmpReferer = WB_URL.$aRefUrl['path'].$aRefUrl['fragment'];
40
                }
41
                unset($aWbUrl);
42
            }
43
            unset($aRefUrl);
44
        }
45
    }
46
    $_SERVER['HTTP_REFERER'] = $sTmpReferer;
47
}
48
/**
49
 * makePhExp
50
 * @param array list of names for placeholders
51
 * @return array reformatted list
52
 * @description makes an RegEx-Expression for preg_replace() of each item in $aList
53
 *              Example: from 'TEST_NAME' it mades '/\[TEST_NAME\]/s'
54
 */
55
function makePhExp($sList)
56
{
57
    $aList = func_get_args();
58
//    return preg_replace('/^(.*)$/', '/\[$1\]/s', $aList);
59
    return preg_replace('/^(.*)$/', '[$1]', $aList);
60
}
61

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

    
150
    if (defined('DB_TYPE'))
151
    {
152
    // import constants for compatibility reasons
153
        $db = array();
154
        if (defined('DB_TYPE'))      { $db['type']         = DB_TYPE; }
155
        if (defined('DB_USERNAME'))  { $db['user']         = DB_USERNAME; }
156
        if (defined('DB_PASSWORD'))  { $db['pass']         = DB_PASSWORD; }
157
        if (defined('DB_HOST'))      { $db['host']         = DB_HOST; }
158
        if (defined('DB_PORT'))      { $db['port']         = DB_PORT; }
159
        if (defined('DB_NAME'))      { $db['name']         = DB_NAME; }
160
        if (defined('DB_CHARSET'))   { $db['charset']      = DB_CHARSET; }
161
        if (defined('TABLE_PREFIX')) { $db['table_prefix'] = TABLE_PREFIX; }
162
    } else {
163
        foreach($aCfg['DataBase'] as $key=>$value) {
164
            switch($key):
165
                case 'type':
166
                    if(!defined('DB_TYPE')) { define('DB_TYPE', $value); }
167
                    break;
168
                case 'user':
169
                    if(!defined('DB_USERNAME')) { define('DB_USERNAME', $value); }
170
                    break;
171
                case 'pass':
172
                    if(!defined('DB_PASSWORD')) { define('DB_PASSWORD', $value); }
173
                    break;
174
                case 'host':
175
                    if(!defined('DB_HOST')) { define('DB_HOST', $value); }
176
                    break;
177
                case 'port':
178
                    if(!defined('DB_PORT')) { define('DB_PORT', $value); }
179
                    break;
180
                case 'name':
181
                    if(!defined('DB_NAME')) { define('DB_NAME', $value); }
182
                    break;
183
                case 'charset':
184
                    if(!defined('DB_CHARSET')) { define('DB_CHARSET', $value); }
185
                    break;
186
                default:
187
                    $key = strtoupper($key);
188
                    if(!defined($key)) { define($key, $value); }
189
                    break;
190
            endswitch;
191
        }
192
    }
193
}
194

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

    
256
/* ***************************************************************************************
257
 * Start initialization                                                                  *
258
 ****************************************************************************************/
259
    // Stop execution if PHP version is too old
260
    // PHP less then 5.6.0 is prohibited ---
261
    if (version_compare(PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION.'.'.PHP_RELEASE_VERSION, '5.6.0', '<')) {
262
        $sMsg = '<p style="color: #ff0000;">WebsiteBaker is not able to run with PHP-Version less then 5.6.0!!<br />'
263
              . 'Please change your PHP-Version to any kind from 5.6.0 and up!<br />'
264
              . 'If you have problems to solve that, ask your hosting provider for it.<br  />'
265
              . 'The very best solution is the use of PHP-7.0 and up</p>';
266
        die($sMsg);
267
    }
268
    error_reporting(E_ALL);
269
    $sStarttime = array_sum(explode(" ", microtime()));
270
    /* -------------------------------------------------------- */
271
    if ( !defined('WB_PATH')) { define('WB_PATH', dirname(__DIR__)); }
272
    // *** initialize Exception handling
273
    if(!function_exists('globalExceptionHandler')) {
274
        include(__DIR__.'/globalExceptionHandler.php');
275
    }
276
    // *** initialize Error handling
277
    $sErrorLogFile = dirname(__DIR__).'/var/logs/php_error.log.php';
278
    $sErrorLogPath = dirname($sErrorLogFile);
279

    
280
    if (!file_exists($sErrorLogFile)) {
281
        $sTmp = '<?php die(\'illegal file access\'); ?>'
282
              . 'created: ['.date('c').']'.PHP_EOL;
283
        if (false === file_put_contents($sErrorLogFile, $sTmp, FILE_APPEND)) {
284
            throw new Exception('unable to create logfile \'/var/logs/php_error.log.php\'');
285
        }
286
    }
287
    if (!is_writeable($sErrorLogFile)) {
288
        throw new Exception('not writeable logfile \'/var/logs/php_error.log.php\'');
289
    }
290
    ini_set('log_errors', 1);
291
    ini_set ('error_log', $sErrorLogFile);
292

    
293
// activate errorhandler *****************************************************************
294
    set_error_handler('WbErrorHandler', -1 );
295
    defined('SYSTEM_RUN') ? '' : define('SYSTEM_RUN', true);
296
// load configuration ---
297
    $aCfg = initReadSetupFile();
298
    initSetInstallWbConstants($aCfg);
299
// ---------------------------
300
// get Database connection data from configuration
301
    defined('ADMIN_DIRECTORY') ? '' : define('ADMIN_DIRECTORY', 'admin');
302
    if (!preg_match('/xx[a-z0-9_][a-z0-9_\-\.]+/i', 'xx'.ADMIN_DIRECTORY)) {
303
        throw new RuntimeException('Invalid admin-directory: ' . ADMIN_DIRECTORY);
304
    }
305
    defined('ADMIN_URL') ? '' : define('ADMIN_URL', WB_URL.'/'.ADMIN_DIRECTORY);
306
    defined('ADMIN_PATH') ? '' : define('ADMIN_PATH', WB_PATH.'/'.ADMIN_DIRECTORY);
307
    if ( !defined('WB_REL')){
308
        $x1 = parse_url(WB_URL);
309
        define('WB_REL', (isset($x1['path']) ? $x1['path'] : ''));
310
    }
311
    if ( !defined('DOCUMENT_ROOT')) {
312
        define('DOCUMENT_ROOT', preg_replace('/'.preg_quote(str_replace('\\', '/', WB_REL), '/').'$/', '', str_replace('\\', '/', WB_PATH)));
313
        $_SERVER['DOCUMENT_ROOT'] = DOCUMENT_ROOT;
314
    }
315
// activate Autoloader
316
    if (!class_exists('\bin\Autoloader')) {
317
        include __DIR__.'/Autoloader.php';
318
    }
319
    \bin\Autoloader::doRegister();
320

    
321
if (file_exists(WB_PATH.'/framework/class.database.php')) {
322
    // sanitize $_SERVER['HTTP_REFERER']
323
    SanitizeHttpReferer(WB_URL);
324
    date_default_timezone_set('UTC');
325
    // register TWIG autoloader ---
326
    $sTmp = dirname(dirname(__FILE__)).'/include/Sensio/Twig/lib/Twig/Autoloader.php';
327
    if (!class_exists('Twig_Autoloader') && is_readable($sTmp)){
328
        include $sTmp;
329
        Twig_Autoloader::register();
330
    }
331
// register PHPMailer autoloader ---
332
    $sTmp = dirname(dirname(__FILE__)).'/include/phpmailer/PHPMailerAutoload.php';
333
    if (!function_exists('PHPMailerAutoload') && is_readable($sTmp)) {
334
        include $sTmp;
335
    }
336

    
337
//    if (!class_exists('database', false)){
338
//      // load database class
339
//      require(__DIR__.'/class.database.php');
340
      // Create database class
341
      $database = new database();
342
//    }
343

    
344
    // activate frontend OutputFilterApi (initialize.php)
345
    if (is_readable(WB_PATH .'/modules/output_filter/OutputFilterApi.php')) {
346
        if (!function_exists('OutputFilterApi')) {
347
            include WB_PATH .'/modules/output_filter/OutputFilterApi.php';
348
        }
349
    } else {
350
        throw new RuntimeException('missing mandatory global OutputFilterApi!');
351
    }
352
    // Get website settings (title, keywords, description, header, and footer)
353
    $sql = 'SELECT `name`, `value` FROM `'.TABLE_PREFIX.'settings`';
354
    if (($get_settings = $database->query($sql))) {
355
        $x = 0;
356
        while ($setting = $get_settings->fetchRow(MYSQLI_ASSOC)) {
357
            $setting_name  = strtoupper($setting['name']);
358
            $setting_value = $setting['value'];
359
            if ($setting_value == 'false') {
360
                $setting_value = false;
361
            }
362
            if ($setting_value == 'true') {
363
                $setting_value = true;
364
            }
365
            defined($setting_name) ? '' : define($setting_name, $setting_value);
366
            $x++;
367
        }
368
    } else {
369
        die($database->get_error());
370
    }
371
    if (!$x) {
372
        throw new RuntimeException('no settings found');
373
    }
374
    defined('DO_NOT_TRACK') ? '' : define('DO_NOT_TRACK', (isset($_SERVER['HTTP_DNT'])));
375
    ini_set('display_errors', ((defined('DEBUG') && (DEBUG==true)) ?'1':'0'));
376

    
377
    defined('DEBUG') ? '' : define('DEBUG', false);
378
    $string_file_mode = defined('STRING_FILE_MODE') ? STRING_FILE_MODE : '0644';
379
    defined('OCTAL_FILE_MODE') ? '' : define('OCTAL_FILE_MODE', (int) octdec($string_file_mode));
380
    $string_dir_mode = defined('STRING_DIR_MODE') ? STRING_DIR_MODE : '0755';
381
    defined('OCTAL_DIR_MODE')  ? '' : define('OCTAL_DIR_MODE',  (int) octdec($string_dir_mode));
382
//    $sSecMod = (defined('SECURE_FORM_MODULE') && SECURE_FORM_MODULE != '') ? '.'.SECURE_FORM_MODULE : '';
383
//    $sSecMod = WB_PATH.'/framework/SecureForm'.$sSecMod.'.php';
384
//    require_once($sSecMod);
385
    if (!defined('WB_INSTALL_PROCESS')) {
386
    // get CAPTCHA and ASP settings
387
        $sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_captcha_control`';
388
        if (($get_settings = $database->query($sql)) &&
389
            ($setting = $get_settings->fetchRow(MYSQLI_ASSOC))
390
        ) {
391
            defined('ENABLED_CAPTCHA')     ? '' : define('ENABLED_CAPTCHA',     (bool) ($setting['enabled_captcha'] == '1'));
392
            defined('ENABLED_ASP')         ? '' : define('ENABLED_ASP',         (bool) ($setting['enabled_asp'] == '1'));
393
            defined('CAPTCHA_TYPE')        ? '' : define('CAPTCHA_TYPE',        $setting['captcha_type']);
394
            defined('ASP_SESSION_MIN_AGE') ? '' : define('ASP_SESSION_MIN_AGE', (int) $setting['asp_session_min_age']);
395
            defined('ASP_VIEW_MIN_AGE')    ? '' : define('ASP_VIEW_MIN_AGE',    (int) $setting['asp_view_min_age']);
396
            defined('ASP_INPUT_MIN_AGE')   ? '' : define('ASP_INPUT_MIN_AGE',   (int) $setting['asp_input_min_age']);
397
        } else {
398
            throw new RuntimeException('CAPTCHA-Settings not found');
399
        }
400
    }
401

    
402
    // Start a session
403
    if (!defined('SESSION_STARTED')) {
404
        session_name(APP_NAME.'-sid');
405
        @session_start();
406
        define('SESSION_STARTED', true);
407
    }
408
    if (defined('ENABLED_ASP') && ENABLED_ASP && !isset($_SESSION['session_started'])) {
409
        $_SESSION['session_started'] = time();
410
    }
411
    // Get users language
412
    if (
413
        isset($_GET['lang']) AND
414
        $_GET['lang'] != '' AND
415
        !is_numeric($_GET['lang']) AND
416
        strlen($_GET['lang']) == 2
417
    ) {
418
        define('LANGUAGE', strtoupper($_GET['lang']));
419
        $_SESSION['LANGUAGE']=LANGUAGE;
420
    } else {
421
        if (isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') {
422
            define('LANGUAGE', $_SESSION['LANGUAGE']);
423
        } else {
424
            define('LANGUAGE', DEFAULT_LANGUAGE);
425
        }
426
    }
427
    $sCachePath = dirname(__DIR__).'/temp/cache/';
428
    if (!file_exists($sCachePath)) {
429
        if (!mkdir($sCachePath)) { $sCachePath = dirname(__DIR__).'/temp/'; }
430
    }
431
    // Load Language file(s)
432
    $sCurrLanguage = '';
433
    $slangFile = WB_PATH.'/languages/EN.php';
434
    if (is_readable($slangFile)) {
435
        require $slangFile;
436
        $sCurrLanguage ='EN';
437
    }
438
    if ($sCurrLanguage != DEFAULT_LANGUAGE) {
439
        $slangFile = WB_PATH.'/languages/'.DEFAULT_LANGUAGE.'.php';
440
        if (is_readable($slangFile)) {
441
            require $slangFile;
442
            $sCurrLanguage = DEFAULT_LANGUAGE;
443
        }
444
    }
445
    if ($sCurrLanguage != LANGUAGE) {
446
        $slangFile = WB_PATH.'/languages/'.LANGUAGE.'.php';
447
        if (is_readable($slangFile)) {
448
            require $slangFile;
449
        }
450
    }
451
//    if (!class_exists('Translate', false)) {
452
//        include __DIR__.'/Translate.php';
453
//    }
454
    $oTrans = Translate::getInstance();
455
    $oTrans->initialize(array('EN', DEFAULT_LANGUAGE, LANGUAGE), $sCachePath); // 'none'
456
    // Get users timezone
457
    if (isset($_SESSION['TIMEZONE'])) {
458
        define('TIMEZONE', $_SESSION['TIMEZONE']);
459
    } else {
460
        define('TIMEZONE', DEFAULT_TIMEZONE);
461
    }
462
    // Get users date format
463
    if (isset($_SESSION['DATE_FORMAT'])) {
464
        define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
465
    } else {
466
        define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
467
    }
468
    // Get users time format
469
    if (isset($_SESSION['TIME_FORMAT'])) {
470
        define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
471
    } else {
472
        define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
473
    }
474
    // Set Theme dir
475
    define('THEME_URL', WB_URL.'/templates/'.DEFAULT_THEME);
476
    define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);
477
    // extended wb_settings
478
    define('EDIT_ONE_SECTION', false);
479
    define('EDITOR_WIDTH', 0);
480
}