1
|
<?php
|
2
|
/**
|
3
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
4
|
*
|
5
|
* This program is free software: you can redistribute it and/or modify
|
6
|
* it under the terms of the GNU General Public License as published by
|
7
|
* the Free Software Foundation, either version 3 of the License, or
|
8
|
* (at your option) any later version.
|
9
|
*
|
10
|
* This program is distributed in the hope that it will be useful,
|
11
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
* GNU General Public License for more details.
|
14
|
*
|
15
|
* You should have received a copy of the GNU General Public License
|
16
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
*/
|
18
|
|
19
|
/**
|
20
|
* initialize.php
|
21
|
*
|
22
|
* @category Core
|
23
|
* @package Core_Environment
|
24
|
* @author Werner v.d.Decken <wkl@isteam.de>
|
25
|
* @copyright Werner v.d.Decken <wkl@isteam.de>
|
26
|
* @license http://www.gnu.org/licenses/gpl.html GPL License
|
27
|
* @version 0.0.1
|
28
|
* @revision $Revision: 2124 $
|
29
|
* @link $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/framework/initialize.php $
|
30
|
* @lastmodified $Date: 2015-05-16 15:44:25 +0200 (Sat, 16 May 2015) $
|
31
|
* @since File replaced since 05.02.2013
|
32
|
* @description set the basic environment to run WebsiteBaker
|
33
|
*/
|
34
|
|
35
|
/* *** define some helper functions *** */
|
36
|
/**
|
37
|
* sanitize $_SERVER['HTTP_REFERER']
|
38
|
* @param string $sWbUrl qualified startup URL of current application
|
39
|
*/
|
40
|
function initSanitizeHttpReferer($sWbUrl) {
|
41
|
$sTmpReferer = '';
|
42
|
if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != '') {
|
43
|
define('ORG_REFERER', ($_SERVER['HTTP_REFERER'] ?: ''));
|
44
|
$sTmpReferer = $_SERVER['HTTP_REFERER'];
|
45
|
$aRefUrl = parse_url($_SERVER['HTTP_REFERER']);
|
46
|
if ($aRefUrl !== false) {
|
47
|
$aRefUrl['host'] = isset($aRefUrl['host']) ? $aRefUrl['host'] : '';
|
48
|
$aRefUrl['path'] = isset($aRefUrl['path']) ? $aRefUrl['path'] : '';
|
49
|
$aRefUrl['fragment'] = isset($aRefUrl['fragment']) ? '#'.$aRefUrl['fragment'] : '';
|
50
|
$aWbUrl = parse_url($sWbUrl);
|
51
|
if ($aWbUrl !== false) {
|
52
|
$aWbUrl['host'] = isset($aWbUrl['host']) ? $aWbUrl['host'] : '';
|
53
|
$aWbUrl['path'] = isset($aWbUrl['path']) ? $aWbUrl['path'] : '';
|
54
|
if (strpos($aRefUrl['host'].$aRefUrl['path'],
|
55
|
$aWbUrl['host'].$aWbUrl['path']) !== false) {
|
56
|
$aRefUrl['path'] = preg_replace('#^'.$aWbUrl['path'].'#i', '', $aRefUrl['path']);
|
57
|
$sTmpReferer = $sWbUrl.$aRefUrl['path'].$aRefUrl['fragment'];
|
58
|
}
|
59
|
unset($aWbUrl);
|
60
|
}
|
61
|
unset($aRefUrl);
|
62
|
}
|
63
|
}
|
64
|
$_SERVER['HTTP_REFERER'] = $sTmpReferer;
|
65
|
}
|
66
|
/**
|
67
|
* Set constants for system/install values
|
68
|
* @throws RuntimeException
|
69
|
*/
|
70
|
function initSetInstallPathConstants() {
|
71
|
if(!defined('DEBUG')){ define('DEBUG', false); } // normaly set in config file
|
72
|
if(!defined('ADMIN_DIRECTORY')){ define('ADMIN_DIRECTORY', 'admin'); }
|
73
|
if(!preg_match('/xx[a-z0-9_][a-z0-9_\-\.]+/i', 'xx'.ADMIN_DIRECTORY)) {
|
74
|
throw new RuntimeException('Invalid admin-directory: ' . ADMIN_DIRECTORY);
|
75
|
}
|
76
|
if(!defined('WB_PATH')){ define('WB_PATH', dirname(__DIR__)); }
|
77
|
if(!defined('ADMIN_URL')){ define('ADMIN_URL', rtrim(WB_URL, '/\\').'/'.ADMIN_DIRECTORY); }
|
78
|
if(!defined('ADMIN_PATH')){ define('ADMIN_PATH', WB_PATH.'/'.ADMIN_DIRECTORY); }
|
79
|
if(!defined('WB_REL')){
|
80
|
$x1 = parse_url(WB_URL);
|
81
|
define('WB_REL', (isset($x1['path']) ? $x1['path'] : ''));
|
82
|
}
|
83
|
if(!defined('ADMIN_REL')){ define('ADMIN_REL', WB_REL.'/'.ADMIN_DIRECTORY); }
|
84
|
if(!defined('DOCUMENT_ROOT')) {
|
85
|
define('DOCUMENT_ROOT', preg_replace('/'.preg_quote(str_replace('\\', '/', WB_REL), '/').'$/', '', str_replace('\\', '/', WB_PATH)));
|
86
|
$_SERVER['DOCUMENT_ROOT'] = DOCUMENT_ROOT;
|
87
|
}
|
88
|
if(!defined('TMP_PATH')){ define('TMP_PATH', WB_PATH.'/temp'); }
|
89
|
}
|
90
|
/**
|
91
|
* checkValidCaller
|
92
|
* @param array $aCaller list of allowed scripts
|
93
|
* @return true || Exception
|
94
|
* @throws RuntimeException
|
95
|
* @description test if acctual file is called from one of the given list
|
96
|
*/
|
97
|
function initCheckValidCaller(array $aCaller)
|
98
|
{
|
99
|
return true;
|
100
|
$x = debug_backtrace();
|
101
|
if(sizeof($x) == 0) {
|
102
|
return true;
|
103
|
}
|
104
|
$sPattern = '/('.str_replace('#', '|', preg_quote(implode('#', $aCaller), '/')).')$/si';
|
105
|
foreach($x as $aStep) {
|
106
|
// define the scripts which can read the configuration
|
107
|
if(preg_match($sPattern, $aStep['file'])) {
|
108
|
return true;
|
109
|
}
|
110
|
}
|
111
|
throw new RuntimeException('illegal file request!');
|
112
|
}
|
113
|
/**
|
114
|
* Read DB settings from configuration file
|
115
|
* @return array
|
116
|
* @throws RuntimeException
|
117
|
*
|
118
|
*/
|
119
|
function initReadSetupFile()
|
120
|
{
|
121
|
// check for valid file request. Becomes more stronger in next version
|
122
|
initCheckValidCaller(array('save.php','index.php','config.php','upgrade-script.php'));
|
123
|
$aCfg = array();
|
124
|
|
125
|
$sSetupFile = dirname(__DIR__).'/setup.ini.php';
|
126
|
if(is_readable($sSetupFile)) {
|
127
|
$aCfg = parse_ini_file($sSetupFile, true);
|
128
|
if (!isset($aCfg['Constants']) || !isset($aCfg['DataBase'])) {
|
129
|
throw new InvalidArgumentException('configuration missmatch in setup.ini.php');
|
130
|
}
|
131
|
foreach($aCfg['Constants'] as $key=>$value) {
|
132
|
switch($key):
|
133
|
case 'DEBUG':
|
134
|
$value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
|
135
|
if(!defined('DEBUG')) { define('DEBUG', $value); }
|
136
|
break;
|
137
|
case 'WB_URL': // << case is set deprecated
|
138
|
case 'AppUrl':
|
139
|
$value = trim(str_replace('\\', '/', $value), '/');
|
140
|
if(!defined('WB_URL')) { define('WB_URL', $value); }
|
141
|
break;
|
142
|
case 'ADMIN_DIRECTORY': // << case is set deprecated
|
143
|
case 'AcpDir':
|
144
|
$value = trim(str_replace('\\', '/', $value), '/');
|
145
|
if(!defined('ADMIN_DIRECTORY')) { define('ADMIN_DIRECTORY', $value); }
|
146
|
break;
|
147
|
default:
|
148
|
if(!defined($key)) { define($key, $value); }
|
149
|
break;
|
150
|
endswitch;
|
151
|
}
|
152
|
}
|
153
|
return $aCfg;
|
154
|
// throw new RuntimeException('unable to read setup.ini.php');
|
155
|
}
|
156
|
/**
|
157
|
* GetDbConnectData
|
158
|
* @param array $aCfg
|
159
|
* @param string $sDbConnectType can be 'url' or 'dsn'
|
160
|
* @return array
|
161
|
*
|
162
|
*/
|
163
|
function initGetDbConnectData(array $aCfg, $sDbConnectType = 'url')
|
164
|
{
|
165
|
if(defined('DB_TYPE'))
|
166
|
{
|
167
|
// import constants for compatibility reasons
|
168
|
$db = array();
|
169
|
if(defined('DB_TYPE')) { $db['type'] = DB_TYPE; }
|
170
|
if(defined('DB_USERNAME')) { $db['user'] = DB_USERNAME; }
|
171
|
if(defined('DB_PASSWORD')) { $db['pass'] = DB_PASSWORD; }
|
172
|
if(defined('DB_HOST')) { $db['host'] = DB_HOST; }
|
173
|
if(defined('DB_PORT')) { $db['port'] = DB_PORT; }
|
174
|
if(defined('DB_NAME')) { $db['name'] = DB_NAME; }
|
175
|
if(defined('DB_CHARSET')) { $db['charset'] = DB_CHARSET; }
|
176
|
if(defined('TABLE_PREFIX')) { $db['table_prefix'] = TABLE_PREFIX; }
|
177
|
$aCfg['DataBase'] = $db;
|
178
|
}
|
179
|
// sanitize values
|
180
|
$db = $aCfg['DataBase'];
|
181
|
$db['type'] = isset($db['type']) ? $db['type'] : 'mysql';
|
182
|
$db['user'] = isset($db['user']) ? $db['user'] : 'foo';
|
183
|
$db['pass'] = isset($db['pass']) ? $db['pass'] : 'bar';
|
184
|
$db['host'] = isset($db['host']) ? $db['host'] : 'localhost';
|
185
|
$db['port'] = isset($db['port']) ? $db['port'] : '3306';
|
186
|
$db['port'] = ($db['port'] != '3306') ? $db['port'] : '';
|
187
|
$db['socket'] = isset($db['socket']) ? $db['socket'] : '';
|
188
|
$db['name'] = isset($db['name']) ? $db['name'] : 'dummy';
|
189
|
$db['charset'] = isset($db['charset']) ? trim($db['charset']) : 'utf8';
|
190
|
$db['table_prefix'] = (isset($db['table_prefix']) ? $db['table_prefix'] : '');
|
191
|
if (isset($db['options']) && is_array($db['options'])) {
|
192
|
foreach ($db['options'] as $key=>$value) {
|
193
|
$aRetval['options'][constant($key)] = $value;
|
194
|
}
|
195
|
}
|
196
|
if(!defined('TABLE_PREFIX')) { define('TABLE_PREFIX', $db['table_prefix']); }
|
197
|
if($sDbConnectType == 'dsn') {
|
198
|
// build dsn to connect
|
199
|
$aRetval['dsn'] = $db['type'].':dbname='.$db['name'].';host='.$db['host']
|
200
|
. ($db['port'] != '' ? ';port='.(int)$db['port'] : '');
|
201
|
if ($db['charset'] == 'utf8') {
|
202
|
$aRetval['dsn'] .= ';charset=UTF8';
|
203
|
$aRetval['options'][constant('PDO::MYSQL_ATTR_INIT_COMMAND')] = 'SET NAMES \'UTF8\'';
|
204
|
}
|
205
|
$aRetval['options'] = '';
|
206
|
$aRetval['user'] = $db['user'];
|
207
|
$aRetval['password'] = $db['pass'];
|
208
|
$aRetval['addons'] = array('CHARSET' => $db['charset'], 'TABLE_PREFIX' => $db['table_prefix']);
|
209
|
}else {
|
210
|
// build url to connect
|
211
|
$aRetval['url'] = $db['type'].'://'.$db['user'].':'.$db['pass'].'@'
|
212
|
. $db['host'].($db['port'] != '' ? ':'.$db['port'] : '').'/'.$db['name']
|
213
|
. '?Charset='.$db['charset'].'&TablePrefix='.$db['table_prefix'];
|
214
|
}
|
215
|
return $aRetval;
|
216
|
}
|
217
|
|
218
|
/* ***************************************************************************************
|
219
|
* Start initialization *
|
220
|
****************************************************************************************/
|
221
|
// reset global output buffering
|
222
|
while (ob_get_level()) { ob_end_clean(); }
|
223
|
// test for existing and active old config.php
|
224
|
if (defined('TABLE_PREFIX')) { /** TODO */ }
|
225
|
// set system defaults
|
226
|
date_default_timezone_set('UTC');
|
227
|
|
228
|
// initialize debug evaluation values ---
|
229
|
$starttime = array_sum(explode(" ",microtime()));
|
230
|
$iPhpDeclaredClasses = sizeof(get_declared_classes());
|
231
|
$sDbConnectType = 'url'; // depending from class WbDatabase it can be 'url' or 'dsn'
|
232
|
// calculate maximum timestamp
|
233
|
if (!defined('MAX_TIMESTAMP')) { define('MAX_TIMESTAMP', pow(2, 31)-1); } // 2038-01-19 04:14:07
|
234
|
// PHP less then 5.4.0 is prohibited ---
|
235
|
if (version_compare(PHP_VERSION, '5.4.0', '<')) {
|
236
|
$sMsg = '<p style="color: #ff0000;">WebsiteBaker is not able to run with PHP-Version less then 5.4.0!!<br />'
|
237
|
. 'Please change your PHP-Version to any kind from 5.4.0 and up!<br />'
|
238
|
. 'If you have problems to solve that, ask your hosting provider for it.<br />'
|
239
|
. 'The very best solution is the use of PHP-5.5 and up</p>';
|
240
|
die($sMsg);
|
241
|
}
|
242
|
if (! defined('SYSTEM_RUN')) { define('SYSTEM_RUN', true); }
|
243
|
// load configuration ---
|
244
|
$aCfg = initReadSetupFile();
|
245
|
// sanitize $_SERVER['HTTP_REFERER'] ---
|
246
|
initSetInstallPathConstants();
|
247
|
initSanitizeHttpReferer(WB_URL);
|
248
|
// register WB basic autoloader ---
|
249
|
$sTmp = __DIR__.'/WbAutoloader.php';
|
250
|
if(!class_exists('WbAutoloader')){
|
251
|
include($sTmp);
|
252
|
}
|
253
|
WbAutoloader::doRegister( array(
|
254
|
'a' => trim(str_replace('\\', '/',ADMIN_DIRECTORY), '/'),
|
255
|
'm' => 'modules',
|
256
|
't' => 'templates',
|
257
|
'i' => 'include',
|
258
|
'v' => 'vendor'
|
259
|
));
|
260
|
// WbAutoloader::doRegister(array(ADMIN_DIRECTORY=>'a', 'modules'=>'m', 'templates'=>'t', 'include'=>'i'));
|
261
|
// instantiate and initialize adaptor for temporary registry replacement ---
|
262
|
$oReg = WbAdaptor::getInstance();
|
263
|
$oReg->getWbConstants();
|
264
|
// register TWIG autoloader ---
|
265
|
$sTmp = dirname(__DIR__).'/include/Sensio/Twig/lib/Twig/Autoloader.php';
|
266
|
if(!class_exists('Twig_Autoloader') && is_readable($sTmp)) {
|
267
|
include($sTmp);
|
268
|
Twig_Autoloader::register();
|
269
|
}
|
270
|
// register PHPMailer autoloader ---
|
271
|
$sTmp = dirname(__DIR__).'include/phpmailer/PHPMailerAutoload.php';
|
272
|
if (!function_exists('PHPMailerAutoload') && is_readable($sTmp)) {
|
273
|
require($sTmp);
|
274
|
}
|
275
|
// aktivate exceptionhandler ---
|
276
|
if(!function_exists('globalExceptionHandler')) {
|
277
|
include(__DIR__.'/globalExceptionHandler.php');
|
278
|
}
|
279
|
// ---------------------------
|
280
|
// get Database connection data from configuration
|
281
|
$aSqlData = initGetDbConnectData($aCfg, $sDbConnectType);
|
282
|
// Create global database instance ---
|
283
|
$oDb = $database = WbDatabase::getInstance();
|
284
|
if($sDbConnectType == 'dsn') {
|
285
|
$bTmp = $oDb->doConnect($aSqlData['dsn'], $aSqlData['user'], $aSqlData['password'], null, $aSqlData['addons']);
|
286
|
}else {
|
287
|
$bTmp = $oDb->doConnect($aSqlData['url']);
|
288
|
}
|
289
|
// remove critical data from memory
|
290
|
unset($aSqlData, $aCfg);
|
291
|
|
292
|
if(!defined('TABLE_PREFIX')) { define('TABLE_PREFIX', $oDb->TablePrefix); }
|
293
|
|
294
|
// load global settings from database and define global consts from ---
|
295
|
$sql = 'SELECT `name`, `value` FROM `'.$oDb->TablePrefix.'settings`';
|
296
|
if(($oSettings = $oDb->doQuery($sql))) {
|
297
|
if(!$oSettings->numRows()) { throw new AppException('no settings found'); }
|
298
|
while($aSetting = $oSettings->fetchRow(MYSQL_ASSOC)) {
|
299
|
//sanitize true/false values
|
300
|
$aSetting['value'] = ($aSetting['value'] == 'true'
|
301
|
? true
|
302
|
: ($aSetting['value'] == 'false'
|
303
|
? false
|
304
|
: $aSetting['value'])
|
305
|
);
|
306
|
$sSettingName = strtoupper($aSetting['name']);
|
307
|
switch($sSettingName):
|
308
|
case 'STRING_FILE_MODE':
|
309
|
$iTmp = ((intval(octdec($aSetting['value'])) & ~0111)|0600);
|
310
|
if(!defined('OCTAL_FILE_MODE')) { define('OCTAL_FILE_MODE', $iTmp); } // deprecated
|
311
|
if(!defined('FILE_MODE_OCTAL')) { define('FILE_MODE_OCTAL', $iTmp); }
|
312
|
if(!defined('STRING_FILE_MODE')) { define('STRING_FILE_MODE', sprintf('0%03o', $iTmp)); } // deprecated
|
313
|
if(!defined('FILE_MODE_STRING')) { define('FILE_MODE_STRING', sprintf('0%03o', $iTmp)); }
|
314
|
break;
|
315
|
case 'STRING_DIR_MODE':
|
316
|
$iTmp = (intval(octdec($aSetting['value'])) |0711);
|
317
|
if(!defined('OCTAL_DIR_MODE')) { define('OCTAL_DIR_MODE', $iTmp); } // deprecated
|
318
|
if(!defined('DIR_MODE_OCTAL')) { define('DIR_MODE_OCTAL', $iTmp); }
|
319
|
if(!defined('STRING_DIR_MODE')) { define('STRING_DIR_MODE', sprintf('0%03o', $iTmp)); } // deprecated
|
320
|
if(!defined('DIR_MODE_STRING')) { define('DIR_MODE_STRING', sprintf('0%03o', $iTmp)); }
|
321
|
break;
|
322
|
case 'PAGES_DIRECTORY':
|
323
|
// sanitize pages_directory
|
324
|
$sTmp = trim($aSetting['value'], '/');
|
325
|
$sTmp = ($sTmp == '' ? '' : '/'.$sTmp);
|
326
|
if(!defined('PAGES_DIRECTORY')) { define('PAGES_DIRECTORY', $sTmp); }
|
327
|
break;
|
328
|
default: // make global const from setting
|
329
|
if(!defined($sSettingName)) { define($sSettingName, $aSetting['value']); }
|
330
|
break;
|
331
|
endswitch;
|
332
|
}
|
333
|
}else { throw new AppException($database->get_error()); }
|
334
|
// set error-reporting from loaded settings ---
|
335
|
if(intval(ER_LEVEL) > 0 ) {
|
336
|
error_reporting(ER_LEVEL);
|
337
|
if( intval(ini_get ( 'display_errors' )) == 0 ) {
|
338
|
ini_set('display_errors', 1);
|
339
|
}
|
340
|
}
|
341
|
// Start a session ---
|
342
|
if(!defined('SESSION_STARTED')) {
|
343
|
session_name(APP_NAME.'_session_id');
|
344
|
@session_start();
|
345
|
define('SESSION_STARTED', true);
|
346
|
}
|
347
|
// get/set server timezone ---
|
348
|
if(!defined('SERVER_TIMEZONE')) { define('SERVER_TIMEZONE', "UTC"); }
|
349
|
if(!defined('MAX_TIME')) { define('MAX_TIME', (pow(2, 31)-1)); } // 32-Bit Timestamp of 19 Jan 2038 03:14:07 GMT
|
350
|
$sTmp = (isset($_SERVER['HTTP_DNT']) && $_SERVER['HTTP_DNT'] != '') ? $_SERVER['HTTP_DNT'] : '0';
|
351
|
if(!defined('DO_NOT_TRACK')) { define('DO_NOT_TRACK', ($sTmp[0] == '1')); }
|
352
|
// get/set users timezone ---
|
353
|
if(!defined('TIMEZONE')) { define('TIMEZONE', (isset($_SESSION['TIMEZONE']) ? $_SESSION['TIMEZONE'] : DEFAULT_TIMEZONE)); }
|
354
|
if(!defined('DATE_FORMAT')) { define('DATE_FORMAT', (isset($_SESSION['DATE_FORMAT']) ? $_SESSION['DATE_FORMAT'] : DEFAULT_DATE_FORMAT)); }
|
355
|
if(!defined('TIME_FORMAT')) { define('TIME_FORMAT', (isset($_SESSION['TIME_FORMAT']) ? $_SESSION['TIME_FORMAT'] : DEFAULT_TIME_FORMAT)); }
|
356
|
// set Theme directory ---
|
357
|
if(!defined('THEME_URL')) { define('THEME_URL', WB_URL.'/templates/'.DEFAULT_THEME); }
|
358
|
if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME); }
|
359
|
if(!defined('THEME_REL')) { define('THEME_REL', WB_REL.'/templates/'.DEFAULT_THEME); }
|
360
|
// extended wb editor settings
|
361
|
if(!defined('EDIT_ONE_SECTION')) { define('EDIT_ONE_SECTION', false); }
|
362
|
if(!defined('EDITOR_WIDTH')) { define('EDITOR_WIDTH', 0); }
|
363
|
// define form security class and preload it ---
|
364
|
$sSecMod = (defined('SECURE_FORM_MODULE') && SECURE_FORM_MODULE != '') ? '.'.SECURE_FORM_MODULE : '';
|
365
|
$sSecMod = WB_PATH.'/framework/SecureForm'.$sSecMod.'.php';
|
366
|
require_once($sSecMod);
|
367
|
// *** begin deprecated part *************************************************************
|
368
|
// load settings for use in Captch and ASP module
|
369
|
if (!defined('WB_INSTALL_PROCESS') && !defined('ENABLED_CAPTCHA')) {
|
370
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_captcha_control`';
|
371
|
// request settings from database
|
372
|
if(($oSettings = $database->query($sql))) {
|
373
|
if(($aSetting = $oSettings->fetchRow(MYSQL_ASSOC))) {
|
374
|
define('ENABLED_CAPTCHA', ($aSetting['enabled_captcha'] == '1'));
|
375
|
define('ENABLED_ASP', ($aSetting['enabled_asp'] == '1'));
|
376
|
define('CAPTCHA_TYPE', $aSetting['captcha_type']);
|
377
|
define('ASP_SESSION_MIN_AGE', (int)$aSetting['asp_session_min_age']);
|
378
|
define('ASP_VIEW_MIN_AGE', (int)$aSetting['asp_view_min_age']);
|
379
|
define('ASP_INPUT_MIN_AGE', (int)$aSetting['asp_input_min_age']);
|
380
|
}
|
381
|
}
|
382
|
}
|
383
|
if(defined('ENABLED_ASP') && ENABLED_ASP && !isset($_SESSION['session_started'])) {
|
384
|
$_SESSION['session_started'] = time();
|
385
|
}
|
386
|
// *** end of deprecated part ************************************************************
|
387
|
// get user language ---
|
388
|
$sRequestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
|
389
|
// check if get/post value is available
|
390
|
$sTempLanguage = (isset(${$sRequestMethod}['lang']) ? ${$sRequestMethod}['lang'] : '');
|
391
|
// validate language code
|
392
|
if (preg_match('/^[a-z]{2}$/si', $sTempLanguage)) {
|
393
|
// if there's valid get/post
|
394
|
define('LANGUAGE', strtoupper($sTempLanguage));
|
395
|
} else {
|
396
|
if (!defined('LANGUAGE')) {
|
397
|
if(isset($_SESSION['LANGUAGE']) && $_SESSION['LANGUAGE']) {
|
398
|
// if there's valid session value
|
399
|
define('LANGUAGE', $_SESSION['LANGUAGE']);
|
400
|
} else {
|
401
|
// otherwise set to default
|
402
|
define('LANGUAGE', DEFAULT_LANGUAGE);
|
403
|
}
|
404
|
}
|
405
|
}
|
406
|
$_SESSION['LANGUAGE'] = LANGUAGE;
|
407
|
// activate translations / load language definitions
|
408
|
/** begin of deprecated part || will be replaced by class Translate **/
|
409
|
// Load Language file
|
410
|
if(!file_exists(WB_PATH.'/languages/'.LANGUAGE.'.php')) {
|
411
|
$sMsg = 'Error loading language file '.LANGUAGE.', please check configuration';
|
412
|
throw new AppException($sMsg);
|
413
|
} else {
|
414
|
// include language file
|
415
|
require_once(WB_PATH.'/languages/'.LANGUAGE.'.php');
|
416
|
}
|
417
|
/** end of deprecated part **/
|
418
|
// instantiate and initialize adaptor for temporary registry replacement ---
|
419
|
$oReg->getWbConstants();
|
420
|
// load and activate new global translation table
|
421
|
$oTrans = Translate::getInstance();
|
422
|
/* initializise Translate old style *************************************************** */
|
423
|
$oTrans->initialize(
|
424
|
'en',
|
425
|
(defined('DEFAULT_LANGUAGE') ? DEFAULT_LANGUAGE : ''),
|
426
|
(defined('LANGUAGE') ? LANGUAGE : ''),
|
427
|
'WbOldStyle',
|
428
|
// (Translate::CACHE_DISABLED|Translate::KEEP_MISSING),
|
429
|
(DEBUG ? Translate::CACHE_DISABLED|Translate::KEEP_MISSING : 0)
|
430
|
);
|
431
|
/* initializise Translate new style *************************************************** */
|
432
|
/*
|
433
|
$oTrans->initialize(
|
434
|
new TranslateAdaptorWbOldStyle,
|
435
|
'en',
|
436
|
(defined('DEFAULT_LANGUAGE') ? DEFAULT_LANGUAGE : ''),
|
437
|
(defined('LANGUAGE') ? LANGUAGE : ''),
|
438
|
// (Translate::CACHE_DISABLED|Translate::KEEP_MISSING),
|
439
|
(DEBUG ? Translate::CACHE_DISABLED|Translate::KEEP_MISSING : 0),
|
440
|
$oReg->DirModeOctal,
|
441
|
$oReg->TempPath
|
442
|
);
|
443
|
*/
|
444
|
/* ****** */
|
445
|
$oReg->setDatabase(WbDatabase::getInstance());
|
446
|
$oReg->setTranslate(Translate::getInstance());
|
447
|
if(!class_exists('PasswordHash', false)) { include(WB_PATH.'/include/phpass/PasswordHash.php'); }
|
448
|
$oPass = Password::getInstance(new PasswordHash(Password::CRYPT_LOOPS_DEFAULT, Password::HASH_TYPE_AUTO));
|
449
|
if(defined('PASSWORD_CRYPT_LOOPS')) { $oPass->setIteration(PASSWORD_CRYPT_LOOPS); }
|
450
|
if(defined('PASSWORD_HASH_TYPES')) { $oPass->setHashType(PASSWORD_HASH_TYPES); }
|
451
|
/* *** END OF FILE ******************************************************************** */
|