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 2 2017-07-02 15:14:29Z Manuela $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/framework/initialize.php $
|
15
|
* @lastmodified $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
|
16
|
*
|
17
|
*/
|
18
|
error_reporting( -1 );
|
19
|
$sStarttime = array_sum(explode(" ", microtime()));
|
20
|
$aPhpFunctions = get_defined_functions();
|
21
|
/**
|
22
|
* sanitize $_SERVER['HTTP_REFERER']
|
23
|
* @param string $sWbUrl qualified startup URL of current application
|
24
|
*/
|
25
|
function SanitizeHttpReferer($sWbUrl = WB_URL) {
|
26
|
$sTmpReferer = '';
|
27
|
if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != '') {
|
28
|
define('ORG_REFERER', ($_SERVER['HTTP_REFERER'] ?: ''));
|
29
|
$aRefUrl = parse_url($_SERVER['HTTP_REFERER']);
|
30
|
if ($aRefUrl !== false) {
|
31
|
$aRefUrl['host'] = isset($aRefUrl['host']) ? $aRefUrl['host'] : '';
|
32
|
$aRefUrl['path'] = isset($aRefUrl['path']) ? $aRefUrl['path'] : '';
|
33
|
$aRefUrl['fragment'] = isset($aRefUrl['fragment']) ? '#'.$aRefUrl['fragment'] : '';
|
34
|
$aWbUrl = parse_url(WB_URL);
|
35
|
if ($aWbUrl !== false) {
|
36
|
$aWbUrl['host'] = isset($aWbUrl['host']) ? $aWbUrl['host'] : '';
|
37
|
$aWbUrl['path'] = isset($aWbUrl['path']) ? $aWbUrl['path'] : '';
|
38
|
if (strpos($aRefUrl['host'].$aRefUrl['path'], $aWbUrl['host'].$aWbUrl['path']) !== false) {
|
39
|
$aRefUrl['path'] = preg_replace('#^'.$aWbUrl['path'].'#i', '', $aRefUrl['path']);
|
40
|
$sTmpReferer = WB_URL.$aRefUrl['path'].$aRefUrl['fragment'];
|
41
|
}
|
42
|
unset($aWbUrl);
|
43
|
}
|
44
|
unset($aRefUrl);
|
45
|
}
|
46
|
}
|
47
|
$_SERVER['HTTP_REFERER'] = $sTmpReferer;
|
48
|
}
|
49
|
/**
|
50
|
* makePhExp
|
51
|
* @param array list of names for placeholders
|
52
|
* @return array reformatted list
|
53
|
* @description makes an RegEx-Expression for preg_replace() of each item in $aList
|
54
|
* Example: from 'TEST_NAME' it mades '/\[TEST_NAME\]/s'
|
55
|
*/
|
56
|
function makePhExp($sList)
|
57
|
{
|
58
|
$aList = func_get_args();
|
59
|
// return preg_replace('/^(.*)$/', '/\[$1\]/s', $aList);
|
60
|
return preg_replace('/^(.*)$/', '[$1]', $aList);
|
61
|
}
|
62
|
|
63
|
/* ***************************************************************************************
|
64
|
* Start initialization *
|
65
|
****************************************************************************************/// aktivate exceptionhandler ---
|
66
|
// throw new Exception('PHP-'.PHP_VERSION.' found, but at last PHP-5.3.6 required !!');
|
67
|
// Stop execution if PHP version is too old
|
68
|
// PHP less then 5.6.0 is prohibited ---
|
69
|
if (version_compare(PHP_VERSION, '5.6.0', '<')) {
|
70
|
$sMsg = '<p style="color: #ff0000;">WebsiteBaker is not able to run with PHP-Version less then 5.6.0!!<br />'
|
71
|
. 'Please change your PHP-Version to any kind from 5.6.0 and up!<br />'
|
72
|
. 'If you have problems to solve that, ask your hosting provider for it.<br />'
|
73
|
. 'The very best solution is the use of PHP-7.0 and up</p>';
|
74
|
die($sMsg);
|
75
|
}
|
76
|
|
77
|
/* -------------------------------------------------------- */
|
78
|
if ( !defined('WB_PATH')) { define('WB_PATH', dirname(__DIR__)); }
|
79
|
// *** initialize Exception handling
|
80
|
if(!function_exists('globalExceptionHandler')) {
|
81
|
include(__DIR__.'/globalExceptionHandler.php');
|
82
|
}
|
83
|
// *** initialize Error handling
|
84
|
$sErrorLogFile = dirname(__DIR__).'/var/logs/php_error.log.php';
|
85
|
$sErrorLogPath = dirname($sErrorLogFile);
|
86
|
|
87
|
if (!file_exists($sErrorLogFile)) {
|
88
|
$sTmp = '<?php die(\'illegal file access\'); ?>'
|
89
|
. 'created: ['.date('c').']'.PHP_EOL;
|
90
|
if (false === file_put_contents($sErrorLogFile, $sTmp, FILE_APPEND)) {
|
91
|
throw new Exception('unable to create logfile \'/var/logs/php_error.log.php\'');
|
92
|
}
|
93
|
}
|
94
|
if (!is_writeable($sErrorLogFile)) {
|
95
|
throw new Exception('not writeable logfile \'/var/logs/php_error.log.php\'');
|
96
|
}
|
97
|
ini_set('log_errors', 1);
|
98
|
ini_set ('error_log', $sErrorLogFile);
|
99
|
|
100
|
/**
|
101
|
* Read DB settings from configuration file
|
102
|
* @return array
|
103
|
* @throws RuntimeException
|
104
|
*
|
105
|
*/
|
106
|
function initReadSetupFile()
|
107
|
{
|
108
|
// check for valid file request. Becomes more stronger in next version
|
109
|
// initCheckValidCaller(array('save.php','index.php','config.php','upgrade-script.php'));
|
110
|
$aCfg = array();
|
111
|
$sSetupFile = dirname(dirname(__FILE__)).'/setup.ini.php';
|
112
|
if(is_readable($sSetupFile) && !defined('WB_URL')) {
|
113
|
$aCfg = parse_ini_file($sSetupFile, true);
|
114
|
if (!isset($aCfg['Constants']) || !isset($aCfg['DataBase'])) {
|
115
|
throw new InvalidArgumentException('configuration missmatch in setup.ini.php');
|
116
|
}
|
117
|
foreach($aCfg['Constants'] as $key=>$value) {
|
118
|
switch($key):
|
119
|
case 'DEBUG':
|
120
|
$value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
|
121
|
if(!defined('DEBUG')) { define('DEBUG', $value); }
|
122
|
break;
|
123
|
case 'WB_URL': // << case is set deprecated
|
124
|
case 'AppUrl':
|
125
|
$value = trim(str_replace('\\', '/', $value), '/');
|
126
|
if(!defined('WB_URL')) { define('WB_URL', $value); }
|
127
|
break;
|
128
|
case 'ADMIN_DIRECTORY': // << case is set deprecated
|
129
|
case 'AcpDir':
|
130
|
$value = trim(str_replace('\\', '/', $value), '/');
|
131
|
if(!defined('ADMIN_DIRECTORY')) { define('ADMIN_DIRECTORY', $value); }
|
132
|
break;
|
133
|
default:
|
134
|
if(!defined($key)) { define($key, $value); }
|
135
|
break;
|
136
|
endswitch;
|
137
|
}
|
138
|
}
|
139
|
return $aCfg;
|
140
|
// throw new RuntimeException('unable to read setup.ini.php');
|
141
|
}
|
142
|
/**
|
143
|
* Set constants for system/install values
|
144
|
* @throws RuntimeException
|
145
|
*/
|
146
|
function initSetInstallWbConstants($aCfg) {
|
147
|
if (sizeof($aCfg)) {
|
148
|
foreach($aCfg['Constants'] as $key=>$value) {
|
149
|
switch($key):
|
150
|
case 'DEBUG':
|
151
|
$value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
|
152
|
if(!defined('DEBUG')) { define('DEBUG', $value); }
|
153
|
break;
|
154
|
case 'WB_URL': // << case is set deprecated
|
155
|
case 'AppUrl':
|
156
|
$value = trim(str_replace('\\', '/', $value), '/');
|
157
|
if(!defined('WB_URL')) { define('WB_URL', $value); }
|
158
|
break;
|
159
|
case 'ADMIN_DIRECTORY': // << case is set deprecated
|
160
|
case 'AcpDir':
|
161
|
$value = trim(str_replace('\\', '/', $value), '/');
|
162
|
if(!defined('ADMIN_DIRECTORY')) { define('ADMIN_DIRECTORY', $value); }
|
163
|
if(!preg_match('/xx[a-z0-9_][a-z0-9_\-\.]+/i', 'xx'.ADMIN_DIRECTORY)) {
|
164
|
throw new RuntimeException('Invalid admin-directory: ' . ADMIN_DIRECTORY);
|
165
|
}
|
166
|
break;
|
167
|
default:
|
168
|
if(!defined($key)) { define($key, $value); }
|
169
|
break;
|
170
|
endswitch;
|
171
|
}
|
172
|
}
|
173
|
if(!defined('WB_PATH')){ define('WB_PATH', dirname(__DIR__)); }
|
174
|
if(!defined('ADMIN_URL')){ define('ADMIN_URL', rtrim(WB_URL, '/\\').'/'.ADMIN_DIRECTORY); }
|
175
|
if(!defined('ADMIN_PATH')){ define('ADMIN_PATH', WB_PATH.'/'.ADMIN_DIRECTORY); }
|
176
|
if(!defined('WB_REL')){
|
177
|
$x1 = parse_url(WB_URL);
|
178
|
define('WB_REL', (isset($x1['path']) ? $x1['path'] : ''));
|
179
|
}
|
180
|
if(!defined('ADMIN_REL')){ define('ADMIN_REL', WB_REL.'/'.ADMIN_DIRECTORY); }
|
181
|
if(!defined('DOCUMENT_ROOT')) {
|
182
|
define('DOCUMENT_ROOT', preg_replace('/'.preg_quote(str_replace('\\', '/', WB_REL), '/').'$/', '', str_replace('\\', '/', WB_PATH)));
|
183
|
$_SERVER['DOCUMENT_ROOT'] = DOCUMENT_ROOT;
|
184
|
}
|
185
|
if(!defined('TMP_PATH')){ define('TMP_PATH', WB_PATH.'/temp'); }
|
186
|
|
187
|
if (defined('DB_TYPE'))
|
188
|
{
|
189
|
// import constants for compatibility reasons
|
190
|
$db = array();
|
191
|
if (defined('DB_TYPE')) { $db['type'] = DB_TYPE; }
|
192
|
if (defined('DB_USERNAME')) { $db['user'] = DB_USERNAME; }
|
193
|
if (defined('DB_PASSWORD')) { $db['pass'] = DB_PASSWORD; }
|
194
|
if (defined('DB_HOST')) { $db['host'] = DB_HOST; }
|
195
|
if (defined('DB_PORT')) { $db['port'] = DB_PORT; }
|
196
|
if (defined('DB_NAME')) { $db['name'] = DB_NAME; }
|
197
|
if (defined('DB_CHARSET')) { $db['charset'] = DB_CHARSET; }
|
198
|
if (defined('TABLE_PREFIX')) { $db['table_prefix'] = TABLE_PREFIX; }
|
199
|
} else {
|
200
|
foreach($aCfg['DataBase'] as $key=>$value) {
|
201
|
switch($key):
|
202
|
case 'type':
|
203
|
if(!defined('DB_TYPE')) { define('DB_TYPE', $value); }
|
204
|
break;
|
205
|
case 'user':
|
206
|
if(!defined('DB_USERNAME')) { define('DB_USERNAME', $value); }
|
207
|
break;
|
208
|
case 'pass':
|
209
|
if(!defined('DB_PASSWORD')) { define('DB_PASSWORD', $value); }
|
210
|
break;
|
211
|
case 'host':
|
212
|
if(!defined('DB_HOST')) { define('DB_HOST', $value); }
|
213
|
break;
|
214
|
case 'port':
|
215
|
if(!defined('DB_PORT')) { define('DB_PORT', $value); }
|
216
|
break;
|
217
|
case 'name':
|
218
|
if(!defined('DB_NAME')) { define('DB_NAME', $value); }
|
219
|
break;
|
220
|
case 'charset':
|
221
|
if(!defined('DB_CHARSET')) { define('DB_CHARSET', $value); }
|
222
|
break;
|
223
|
default:
|
224
|
$key = strtoupper($key);
|
225
|
if(!defined($key)) { define($key, $value); }
|
226
|
break;
|
227
|
endswitch;
|
228
|
}
|
229
|
}
|
230
|
}
|
231
|
|
232
|
/**
|
233
|
* WbErrorHandler()
|
234
|
*
|
235
|
* @param mixed $iErrorCode
|
236
|
* @param mixed $sErrorText
|
237
|
* @param mixed $sErrorFile
|
238
|
* @param mixed $iErrorLine
|
239
|
* @return
|
240
|
*/
|
241
|
function WbErrorHandler($iErrorCode, $sErrorText, $sErrorFile, $iErrorLine)
|
242
|
{
|
243
|
if (!(error_reporting() & $iErrorCode) || ini_get('log_errors') == 0) {
|
244
|
return false;
|
245
|
}
|
246
|
$bRetval = false;
|
247
|
$sErrorLogFile = ini_get ('error_log');
|
248
|
if (!is_writeable($sErrorLogFile)){return false;}
|
249
|
$sErrorType = E_NOTICE ;
|
250
|
$aErrors = array(
|
251
|
E_USER_DEPRECATED => 'E_USER_DEPRECATED',
|
252
|
E_USER_NOTICE => 'E_USER_NOTICE',
|
253
|
E_USER_WARNING => 'E_USER_WARNING',
|
254
|
E_DEPRECATED => 'E_DEPRECATED',
|
255
|
E_NOTICE => 'E_NOTICE',
|
256
|
E_WARNING => 'E_WARNING',
|
257
|
E_CORE_WARNING => 'E_CORE_WARNING',
|
258
|
E_COMPILE_WARNING => 'E_COMPILE_WARNING',
|
259
|
E_STRICT => 'E_STRICT',
|
260
|
E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
|
261
|
);
|
262
|
if (array_key_exists($iErrorCode, $aErrors)) {
|
263
|
$sErrorType = $aErrors[$iErrorCode];
|
264
|
$bRetval = true;
|
265
|
}
|
266
|
$aBt= debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
267
|
$x = sizeof($aBt) -1;
|
268
|
$x = $x < 0 ? 0 : ($x <= 2 ? $x : 2);
|
269
|
$sEntry = date('c').' '.'['.$sErrorType.'] '.str_replace(dirname(__DIR__), '', $sErrorFile).':['.$iErrorLine.'] '
|
270
|
. ' from '.str_replace(dirname(__DIR__), '', $aBt[$x]['file']).':['.$aBt[$x]['line'].'] '
|
271
|
. (@$aBt[$x]['class'] ? $aBt[$x]['class'].$aBt[$x]['type'] : '').$aBt[$x]['function'].' '
|
272
|
. '"'.$sErrorText.'"'.PHP_EOL;
|
273
|
file_put_contents($sErrorLogFile, $sEntry, FILE_APPEND);
|
274
|
return $bRetval;
|
275
|
}
|
276
|
/* ***************************************************************************************
|
277
|
* Start initialization *
|
278
|
****************************************************************************************/
|
279
|
// activate errorhandler
|
280
|
set_error_handler('WbErrorHandler', -1 );
|
281
|
if (! defined('SYSTEM_RUN')) { define('SYSTEM_RUN', true); }
|
282
|
// load configuration ---
|
283
|
$aCfg = initReadSetupFile();
|
284
|
initSetInstallWbConstants($aCfg);
|
285
|
// ---------------------------
|
286
|
// get Database connection data from configuration
|
287
|
if (!defined('ADMIN_DIRECTORY')) { define('ADMIN_DIRECTORY', 'admin'); }
|
288
|
if (!preg_match('/xx[a-z0-9_][a-z0-9_\-\.]+/i', 'xx'.ADMIN_DIRECTORY)) {
|
289
|
throw new RuntimeException('Invalid admin-directory: ' . ADMIN_DIRECTORY);
|
290
|
}
|
291
|
if ( !defined('ADMIN_URL')) { define('ADMIN_URL', WB_URL.'/'.ADMIN_DIRECTORY); }
|
292
|
if ( !defined('ADMIN_PATH')) { define('ADMIN_PATH', WB_PATH.'/'.ADMIN_DIRECTORY); }
|
293
|
if ( !defined('WB_REL')){
|
294
|
$x1 = parse_url(WB_URL);
|
295
|
define('WB_REL', (isset($x1['path']) ? $x1['path'] : ''));
|
296
|
}
|
297
|
if ( !defined('DOCUMENT_ROOT')) {
|
298
|
define('DOCUMENT_ROOT', preg_replace('/'.preg_quote(str_replace('\\', '/', WB_REL), '/').'$/', '', str_replace('\\', '/', WB_PATH)));
|
299
|
$_SERVER['DOCUMENT_ROOT'] = DOCUMENT_ROOT;
|
300
|
}
|
301
|
if (file_exists(WB_PATH.'/framework/class.database.php')) {
|
302
|
// sanitize $_SERVER['HTTP_REFERER']
|
303
|
SanitizeHttpReferer(WB_URL);
|
304
|
date_default_timezone_set('UTC');
|
305
|
// register TWIG autoloader ---
|
306
|
$sTmp = dirname(dirname(__FILE__)).'/include/Sensio/Twig/lib/Twig/Autoloader.php';
|
307
|
if (!class_exists('Twig_Autoloader') && is_readable($sTmp)){
|
308
|
include $sTmp;
|
309
|
Twig_Autoloader::register();
|
310
|
}
|
311
|
// register PHPMailer autoloader ---
|
312
|
$sTmp = dirname(dirname(__FILE__)).'/include/phpmailer/PHPMailerAutoload.php';
|
313
|
if (!function_exists('PHPMailerAutoload') && is_readable($sTmp)) {
|
314
|
require($sTmp);
|
315
|
}
|
316
|
|
317
|
if (!class_exists('database', false)){
|
318
|
// load database class
|
319
|
require(__DIR__.'/class.database.php');
|
320
|
// Create database class
|
321
|
$database = new database();
|
322
|
$database->sTablePrefix = TABLE_PREFIX;
|
323
|
}
|
324
|
|
325
|
// activate frontend OutputFilterApi (initialize.php)
|
326
|
if (is_readable(WB_PATH .'/modules/output_filter/OutputFilterApi.php')) {
|
327
|
if (!function_exists('OutputFilterApi')) {
|
328
|
include WB_PATH .'/modules/output_filter/OutputFilterApi.php';
|
329
|
}
|
330
|
} else {
|
331
|
throw new RuntimeException('missing mandatory global OutputFilterApi!');
|
332
|
}
|
333
|
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
|
334
|
@ini_set("magic_quotes_runtime", 0); // Disable magic_quotes_runtime
|
335
|
@ini_set("magic_quotes_gpc", 0); // Disable magic_quotes_gpc
|
336
|
}
|
337
|
if (get_magic_quotes_gpc()) {
|
338
|
$unescape = function(&$value, $key) {
|
339
|
$value = stripslashes($value);
|
340
|
};
|
341
|
array_walk_recursive($_POST, $unescape);
|
342
|
array_walk_recursive($_GET, $unescape);
|
343
|
array_walk_recursive($_REQUEST, $unescape);
|
344
|
array_walk_recursive($_COOKIE, $unescape);
|
345
|
}
|
346
|
// Get website settings (title, keywords, description, header, and footer)
|
347
|
$sql = 'SELECT `name`, `value` FROM `'.TABLE_PREFIX.'settings`';
|
348
|
if (($get_settings = $database->query($sql))) {
|
349
|
$x = 0;
|
350
|
while ($setting = $get_settings->fetchRow(MYSQLI_ASSOC)) {
|
351
|
$setting_name = strtoupper($setting['name']);
|
352
|
$setting_value = $setting['value'];
|
353
|
if ($setting_value == 'false') {
|
354
|
$setting_value = false;
|
355
|
}
|
356
|
if ($setting_value == 'true') {
|
357
|
$setting_value = true;
|
358
|
}
|
359
|
@define($setting_name, $setting_value);
|
360
|
$x++;
|
361
|
}
|
362
|
} else {
|
363
|
die($database->get_error());
|
364
|
}
|
365
|
if (!$x) {
|
366
|
throw new RuntimeException('no settings found');
|
367
|
}
|
368
|
@define('DO_NOT_TRACK', (isset($_SERVER['HTTP_DNT'])));
|
369
|
ini_set('display_errors', ((defined('DEBUG')&& (DEBUG==true)) ?'1':'0'));
|
370
|
|
371
|
if (!defined('DEBUG')){ define('DEBUG', false); }
|
372
|
$string_file_mode = defined('STRING_FILE_MODE')?STRING_FILE_MODE:'0644';
|
373
|
@define('OCTAL_FILE_MODE',(int) octdec($string_file_mode));
|
374
|
$string_dir_mode = defined('STRING_DIR_MODE')?STRING_DIR_MODE:'0755';
|
375
|
@define('OCTAL_DIR_MODE',(int) octdec($string_dir_mode));
|
376
|
// $sSecMod = (defined('SECURE_FORM_MODULE') && SECURE_FORM_MODULE != '') ? '.'.SECURE_FORM_MODULE : '';
|
377
|
// $sSecMod = WB_PATH.'/framework/SecureForm'.$sSecMod.'.php';
|
378
|
// require_once($sSecMod);
|
379
|
if (!defined("WB_INSTALL_PROCESS")) {
|
380
|
// get CAPTCHA and ASP settings
|
381
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_captcha_control`';
|
382
|
if (($get_settings = $database->query($sql)) &&
|
383
|
($setting = $get_settings->fetchRow(MYSQLI_ASSOC))
|
384
|
) {
|
385
|
@define('ENABLED_CAPTCHA', (($setting['enabled_captcha'] == '1') ? true : false));
|
386
|
@define('ENABLED_ASP', (($setting['enabled_asp'] == '1') ? true : false));
|
387
|
@define('CAPTCHA_TYPE', $setting['captcha_type']);
|
388
|
@define('ASP_SESSION_MIN_AGE', (int)$setting['asp_session_min_age']);
|
389
|
@define('ASP_VIEW_MIN_AGE', (int)$setting['asp_view_min_age']);
|
390
|
@define('ASP_INPUT_MIN_AGE', (int)$setting['asp_input_min_age']);
|
391
|
} else {
|
392
|
throw new RuntimeException('CAPTCHA-Settings not found');
|
393
|
}
|
394
|
}
|
395
|
|
396
|
// Start a session
|
397
|
if (!defined('SESSION_STARTED')) {
|
398
|
session_name(APP_NAME.'-sid');
|
399
|
@session_start();
|
400
|
define('SESSION_STARTED', true);
|
401
|
}
|
402
|
if (defined('ENABLED_ASP') && ENABLED_ASP && !isset($_SESSION['session_started'])) {
|
403
|
$_SESSION['session_started'] = time();
|
404
|
}
|
405
|
// Get users language
|
406
|
if (
|
407
|
isset($_GET['lang']) AND
|
408
|
$_GET['lang'] != '' AND
|
409
|
!is_numeric($_GET['lang']) AND
|
410
|
strlen($_GET['lang']) == 2
|
411
|
) {
|
412
|
define('LANGUAGE', strtoupper($_GET['lang']));
|
413
|
$_SESSION['LANGUAGE']=LANGUAGE;
|
414
|
} else {
|
415
|
if (isset($_SESSION['LANGUAGE']) AND $_SESSION['LANGUAGE'] != '') {
|
416
|
define('LANGUAGE', $_SESSION['LANGUAGE']);
|
417
|
} else {
|
418
|
define('LANGUAGE', DEFAULT_LANGUAGE);
|
419
|
}
|
420
|
}
|
421
|
$sCachePath = dirname(__DIR__).'/temp/cache/';
|
422
|
if (!file_exists($sCachePath)) {
|
423
|
if (!mkdir($sCachePath)) { $sCachePath = dirname(__DIR__).'/temp/'; }
|
424
|
}
|
425
|
// Load Language file(s)
|
426
|
$sCurrLanguage = '';
|
427
|
$slangFile = WB_PATH.'/languages/EN.php';
|
428
|
if (is_readable($slangFile)) {
|
429
|
require $slangFile;
|
430
|
$sCurrLanguage ='EN';
|
431
|
}
|
432
|
if ($sCurrLanguage != DEFAULT_LANGUAGE) {
|
433
|
$slangFile = WB_PATH.'/languages/'.DEFAULT_LANGUAGE.'.php';
|
434
|
if (is_readable($slangFile)) {
|
435
|
require $slangFile;
|
436
|
$sCurrLanguage = DEFAULT_LANGUAGE;
|
437
|
}
|
438
|
}
|
439
|
if ($sCurrLanguage != LANGUAGE) {
|
440
|
$slangFile = WB_PATH.'/languages/'.LANGUAGE.'.php';
|
441
|
if (is_readable($slangFile)) {
|
442
|
require $slangFile;
|
443
|
}
|
444
|
}
|
445
|
if (!class_exists('Translate', false)) {
|
446
|
include __DIR__.'/Translate.php';
|
447
|
}
|
448
|
$oTrans = Translate::getInstance();
|
449
|
$oTrans->initialize(array('EN', DEFAULT_LANGUAGE, LANGUAGE), $sCachePath); // 'none'
|
450
|
// Get users timezone
|
451
|
if (isset($_SESSION['TIMEZONE'])) {
|
452
|
define('TIMEZONE', $_SESSION['TIMEZONE']);
|
453
|
} else {
|
454
|
define('TIMEZONE', DEFAULT_TIMEZONE);
|
455
|
}
|
456
|
// Get users date format
|
457
|
if (isset($_SESSION['DATE_FORMAT'])) {
|
458
|
define('DATE_FORMAT', $_SESSION['DATE_FORMAT']);
|
459
|
} else {
|
460
|
define('DATE_FORMAT', DEFAULT_DATE_FORMAT);
|
461
|
}
|
462
|
// Get users time format
|
463
|
if (isset($_SESSION['TIME_FORMAT'])) {
|
464
|
define('TIME_FORMAT', $_SESSION['TIME_FORMAT']);
|
465
|
} else {
|
466
|
define('TIME_FORMAT', DEFAULT_TIME_FORMAT);
|
467
|
}
|
468
|
// Set Theme dir
|
469
|
define('THEME_URL', WB_URL.'/templates/'.DEFAULT_THEME);
|
470
|
define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME);
|
471
|
// extended wb_settings
|
472
|
define('EDIT_ONE_SECTION', false);
|
473
|
define('EDITOR_WIDTH', 0);
|
474
|
}
|
475
|
|
476
|
function newAdmin($section_name= '##skip##', $section_permission = 'start', $auto_header = true, $auto_auth = true)
|
477
|
{
|
478
|
if (isset($GLOBALS['admin']) && $GLOBALS['admin'] instanceof admin) {
|
479
|
unset($GLOBALS['admin']);
|
480
|
usleep(10000);
|
481
|
}
|
482
|
return new admin($section_name, $section_permission, $auto_header, $auto_auth);
|
483
|
}
|