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 10 2017-09-04 08:08:45Z Manuela $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/branches/main/framework/initialize.php $
|
15
|
* @lastmodified $Date: 2017-09-04 10:08:45 +0200 (Mon, 04 Sep 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\CoreAutoloader')) {
|
317
|
include __DIR__.'/CoreAutoloader.php';
|
318
|
}
|
319
|
\bin\CoreAutoloader::doRegister(['acp' => ADMIN_DIRECTORY]);
|
320
|
|
321
|
if (class_exists('database')) {
|
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
|
// Create database class
|
337
|
$database = new database();
|
338
|
|
339
|
// activate frontend OutputFilterApi (initialize.php)
|
340
|
if (is_readable(WB_PATH .'/modules/output_filter/OutputFilterApi.php')) {
|
341
|
if (!function_exists('OutputFilterApi')) {
|
342
|
include WB_PATH .'/modules/output_filter/OutputFilterApi.php';
|
343
|
}
|
344
|
} else {
|
345
|
throw new RuntimeException('missing mandatory global OutputFilterApi!');
|
346
|
}
|
347
|
// Get website settings (title, keywords, description, header, and footer)
|
348
|
$sql = 'SELECT `name`, `value` FROM `'.TABLE_PREFIX.'settings`';
|
349
|
if (($get_settings = $database->query($sql))) {
|
350
|
$x = 0;
|
351
|
while ($setting = $get_settings->fetchRow(MYSQLI_ASSOC)) {
|
352
|
$setting_name = strtoupper($setting['name']);
|
353
|
$setting_value = $setting['value'];
|
354
|
if ($setting_value == 'false') {
|
355
|
$setting_value = false;
|
356
|
}
|
357
|
if ($setting_value == 'true') {
|
358
|
$setting_value = true;
|
359
|
}
|
360
|
defined($setting_name) ? '' : define($setting_name, $setting_value);
|
361
|
$x++;
|
362
|
}
|
363
|
} else {
|
364
|
die($database->get_error());
|
365
|
}
|
366
|
if (!$x) {
|
367
|
throw new RuntimeException('no settings found');
|
368
|
}
|
369
|
defined('DO_NOT_TRACK') ? '' : define('DO_NOT_TRACK', (isset($_SERVER['HTTP_DNT'])));
|
370
|
ini_set('display_errors', ((defined('DEBUG') && (DEBUG==true)) ?'1':'0'));
|
371
|
|
372
|
defined('DEBUG') ? '' : define('DEBUG', false);
|
373
|
$string_file_mode = defined('STRING_FILE_MODE') ? STRING_FILE_MODE : '0644';
|
374
|
defined('OCTAL_FILE_MODE') ? '' : define('OCTAL_FILE_MODE', (int) octdec($string_file_mode));
|
375
|
$string_dir_mode = defined('STRING_DIR_MODE') ? STRING_DIR_MODE : '0755';
|
376
|
defined('OCTAL_DIR_MODE') ? '' : define('OCTAL_DIR_MODE', (int) octdec($string_dir_mode));
|
377
|
// $sSecMod = (defined('SECURE_FORM_MODULE') && SECURE_FORM_MODULE != '') ? '.'.SECURE_FORM_MODULE : '';
|
378
|
// $sSecMod = WB_PATH.'/framework/SecureForm'.$sSecMod.'.php';
|
379
|
// require_once($sSecMod);
|
380
|
if (!defined('WB_INSTALL_PROCESS')) {
|
381
|
// get CAPTCHA and ASP settings
|
382
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_captcha_control`';
|
383
|
if (($get_settings = $database->query($sql)) &&
|
384
|
($setting = $get_settings->fetchRow(MYSQLI_ASSOC))
|
385
|
) {
|
386
|
defined('ENABLED_CAPTCHA') ? '' : define('ENABLED_CAPTCHA', (bool) ($setting['enabled_captcha'] == '1'));
|
387
|
defined('ENABLED_ASP') ? '' : define('ENABLED_ASP', (bool) ($setting['enabled_asp'] == '1'));
|
388
|
defined('CAPTCHA_TYPE') ? '' : define('CAPTCHA_TYPE', $setting['captcha_type']);
|
389
|
defined('ASP_SESSION_MIN_AGE') ? '' : define('ASP_SESSION_MIN_AGE', (int) $setting['asp_session_min_age']);
|
390
|
defined('ASP_VIEW_MIN_AGE') ? '' : define('ASP_VIEW_MIN_AGE', (int) $setting['asp_view_min_age']);
|
391
|
defined('ASP_INPUT_MIN_AGE') ? '' : define('ASP_INPUT_MIN_AGE', (int) $setting['asp_input_min_age']);
|
392
|
} else {
|
393
|
throw new RuntimeException('CAPTCHA-Settings not found');
|
394
|
}
|
395
|
}
|
396
|
|
397
|
// Start a session
|
398
|
if (!defined('SESSION_STARTED')) {
|
399
|
session_name(APP_NAME.'-sid');
|
400
|
@session_start();
|
401
|
define('SESSION_STARTED', true);
|
402
|
}
|
403
|
if (defined('ENABLED_ASP') && ENABLED_ASP && !isset($_SESSION['session_started'])) {
|
404
|
$_SESSION['session_started'] = time();
|
405
|
}
|
406
|
// Get users language
|
407
|
if (
|
408
|
isset($_GET['lang']) AND
|
409
|
$_GET['lang'] != '' AND
|
410
|
!is_numeric($_GET['lang']) AND
|
411
|
strlen($_GET['lang']) == 2
|
412
|
) {
|
413
|
define('LANGUAGE', strtoupper($_GET['lang']));
|
414
|
$_SESSION['LANGUAGE']=LANGUAGE;
|
415
|
} else {
|
416
|
if (isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') {
|
417
|
define('LANGUAGE', $_SESSION['LANGUAGE']);
|
418
|
} else {
|
419
|
define('LANGUAGE', DEFAULT_LANGUAGE);
|
420
|
}
|
421
|
}
|
422
|
$sCachePath = dirname(__DIR__).'/temp/cache/';
|
423
|
if (!file_exists($sCachePath)) {
|
424
|
if (!mkdir($sCachePath, 0777, true)) { $sCachePath = dirname(__DIR__).'/temp/'; }
|
425
|
}
|
426
|
// Load Language file(s)
|
427
|
$sCurrLanguage = '';
|
428
|
$slangFile = WB_PATH.'/languages/EN.php';
|
429
|
if (is_readable($slangFile)) {
|
430
|
require $slangFile;
|
431
|
$sCurrLanguage ='EN';
|
432
|
}
|
433
|
if ($sCurrLanguage != DEFAULT_LANGUAGE) {
|
434
|
$slangFile = WB_PATH.'/languages/'.DEFAULT_LANGUAGE.'.php';
|
435
|
if (is_readable($slangFile)) {
|
436
|
require $slangFile;
|
437
|
$sCurrLanguage = DEFAULT_LANGUAGE;
|
438
|
}
|
439
|
}
|
440
|
if ($sCurrLanguage != LANGUAGE) {
|
441
|
$slangFile = WB_PATH.'/languages/'.LANGUAGE.'.php';
|
442
|
if (is_readable($slangFile)) {
|
443
|
require $slangFile;
|
444
|
}
|
445
|
}
|
446
|
$oTrans = Translate::getInstance();
|
447
|
$oTrans->initialize(array('EN', DEFAULT_LANGUAGE, LANGUAGE), $sCachePath); // 'none'
|
448
|
// Get users timezone
|
449
|
if (isset($_SESSION['TIMEZONE'])) {
|
450
|
define('TIMEZONE', $_SESSION['TIMEZONE']);
|
451
|
} else {
|
452
|
define('TIMEZONE', DEFAULT_TIMEZONE);
|
453
|
}
|
454
|
// Get users date format
|
455
|
if (isset($_SESSION['DATE_FORMAT'])) {
|
456
|
define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
|
457
|
} else {
|
458
|
define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
|
459
|
}
|
460
|
// Get users time format
|
461
|
if (isset($_SESSION['TIME_FORMAT'])) {
|
462
|
define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
|
463
|
} else {
|
464
|
define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
|
465
|
}
|
466
|
// Set Theme dir
|
467
|
define('THEME_URL', WB_URL.'/templates/'.DEFAULT_THEME);
|
468
|
define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);
|
469
|
// extended wb_settings
|
470
|
define('EDIT_ONE_SECTION', false);
|
471
|
define('EDITOR_WIDTH', 0);
|
472
|
}
|