1 |
1349
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
1864
|
darkviper
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
4 |
1349
|
Luisehahne
|
*
|
5 |
1864
|
darkviper
|
* 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 |
1349
|
Luisehahne
|
*
|
10 |
1864
|
darkviper
|
* 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 |
1349
|
Luisehahne
|
*/
|
18 |
|
|
|
19 |
1617
|
darkviper
|
/**
|
20 |
1864
|
darkviper
|
* 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$
|
29 |
|
|
* @link $HeadURL$
|
30 |
|
|
* @lastmodified $Date$
|
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 |
1617
|
darkviper
|
* sanitize $_SERVER['HTTP_REFERER']
|
38 |
|
|
* @param string $sWbUrl qualified startup URL of current application
|
39 |
|
|
*/
|
40 |
2015
|
darkviper
|
function initSanitizeHttpReferer($sWbUrl) {
|
41 |
1617
|
darkviper
|
$sTmpReferer = '';
|
42 |
|
|
if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != '') {
|
43 |
2015
|
darkviper
|
$sTmpReferer = $_SERVER['HTTP_REFERER'];
|
44 |
1617
|
darkviper
|
$aRefUrl = parse_url($_SERVER['HTTP_REFERER']);
|
45 |
|
|
if ($aRefUrl !== false) {
|
46 |
|
|
$aRefUrl['host'] = isset($aRefUrl['host']) ? $aRefUrl['host'] : '';
|
47 |
|
|
$aRefUrl['path'] = isset($aRefUrl['path']) ? $aRefUrl['path'] : '';
|
48 |
|
|
$aRefUrl['fragment'] = isset($aRefUrl['fragment']) ? '#'.$aRefUrl['fragment'] : '';
|
49 |
2015
|
darkviper
|
$aWbUrl = parse_url($sWbUrl);
|
50 |
1617
|
darkviper
|
if ($aWbUrl !== false) {
|
51 |
|
|
$aWbUrl['host'] = isset($aWbUrl['host']) ? $aWbUrl['host'] : '';
|
52 |
|
|
$aWbUrl['path'] = isset($aWbUrl['path']) ? $aWbUrl['path'] : '';
|
53 |
|
|
if (strpos($aRefUrl['host'].$aRefUrl['path'],
|
54 |
|
|
$aWbUrl['host'].$aWbUrl['path']) !== false) {
|
55 |
|
|
$aRefUrl['path'] = preg_replace('#^'.$aWbUrl['path'].'#i', '', $aRefUrl['path']);
|
56 |
2015
|
darkviper
|
$sTmpReferer = $sWbUrl.$aRefUrl['path'].$aRefUrl['fragment'];
|
57 |
1617
|
darkviper
|
}
|
58 |
|
|
unset($aWbUrl);
|
59 |
|
|
}
|
60 |
|
|
unset($aRefUrl);
|
61 |
|
|
}
|
62 |
|
|
}
|
63 |
|
|
$_SERVER['HTTP_REFERER'] = $sTmpReferer;
|
64 |
|
|
}
|
65 |
1864
|
darkviper
|
/**
|
66 |
|
|
* Set constants for system/install values
|
67 |
|
|
* @throws RuntimeException
|
68 |
|
|
*/
|
69 |
2015
|
darkviper
|
function initSetInstallPathConstants() {
|
70 |
1864
|
darkviper
|
if(!defined('DEBUG')){ define('DEBUG', false); } // normaly set in config file
|
71 |
1680
|
darkviper
|
if(!defined('ADMIN_DIRECTORY')){ define('ADMIN_DIRECTORY', 'admin'); }
|
72 |
|
|
if(!preg_match('/xx[a-z0-9_][a-z0-9_\-\.]+/i', 'xx'.ADMIN_DIRECTORY)) {
|
73 |
|
|
throw new RuntimeException('Invalid admin-directory: ' . ADMIN_DIRECTORY);
|
74 |
|
|
}
|
75 |
|
|
if(!defined('WB_PATH')){ define('WB_PATH', dirname(dirname(__FILE__))); }
|
76 |
2015
|
darkviper
|
if(!defined('ADMIN_URL')){ define('ADMIN_URL', rtrim(WB_URL, '/\\').'/'.ADMIN_DIRECTORY); }
|
77 |
1680
|
darkviper
|
if(!defined('ADMIN_PATH')){ define('ADMIN_PATH', WB_PATH.'/'.ADMIN_DIRECTORY); }
|
78 |
|
|
if(!defined('WB_REL')){
|
79 |
|
|
$x1 = parse_url(WB_URL);
|
80 |
|
|
define('WB_REL', (isset($x1['path']) ? $x1['path'] : ''));
|
81 |
|
|
}
|
82 |
1887
|
Luisehahne
|
if(!defined('ADMIN_REL')){ define('ADMIN_REL', WB_REL.'/'.ADMIN_DIRECTORY); }
|
83 |
1680
|
darkviper
|
if(!defined('DOCUMENT_ROOT')) {
|
84 |
2015
|
darkviper
|
define('DOCUMENT_ROOT', preg_replace('/'.preg_quote(str_replace('\\', '/', WB_REL), '/').'$/', '', str_replace('\\', '/', WB_PATH)));
|
85 |
|
|
$_SERVER['DOCUMENT_ROOT'] = DOCUMENT_ROOT;
|
86 |
1680
|
darkviper
|
}
|
87 |
1887
|
Luisehahne
|
if(!defined('TMP_PATH')){ define('TMP_PATH', WB_PATH.'/temp'); }
|
88 |
1680
|
darkviper
|
}
|
89 |
1864
|
darkviper
|
/**
|
90 |
2015
|
darkviper
|
* checkValidCaller
|
91 |
|
|
* @param array $aCaller list of allowed scripts
|
92 |
|
|
* @return true || Exception
|
93 |
1864
|
darkviper
|
* @throws RuntimeException
|
94 |
2015
|
darkviper
|
* @description test if acctual file is called from one of the given list
|
95 |
1864
|
darkviper
|
*/
|
96 |
2015
|
darkviper
|
function initCheckValidCaller(array $aCaller)
|
97 |
|
|
{
|
98 |
1864
|
darkviper
|
$x = debug_backtrace();
|
99 |
2015
|
darkviper
|
if(sizeof($x) == 0) {
|
100 |
|
|
return true;
|
101 |
|
|
}
|
102 |
|
|
$sPattern = '/('.str_replace('#', '|', preg_quote(implode('#', $aCaller), '/')).')$/si';
|
103 |
|
|
foreach($x as $aStep) {
|
104 |
|
|
// define the scripts which can read the configuration
|
105 |
|
|
if(preg_match($sPattern, $aStep['file'])) {
|
106 |
|
|
return true;
|
107 |
1874
|
darkviper
|
}
|
108 |
|
|
}
|
109 |
2015
|
darkviper
|
throw new RuntimeException('illegal file request!');
|
110 |
|
|
}
|
111 |
|
|
/**
|
112 |
|
|
* Read DB settings from configuration file
|
113 |
|
|
* @return array
|
114 |
|
|
* @throws RuntimeException
|
115 |
|
|
*
|
116 |
|
|
*/
|
117 |
|
|
function initReadSetupFile()
|
118 |
|
|
{
|
119 |
|
|
// check for valid file request. Becomes more stronger in next version
|
120 |
|
|
initCheckValidCaller(array('save.php','index.php','config.php','upgrade-script.php'));
|
121 |
|
|
$aCfg = array();
|
122 |
|
|
|
123 |
1864
|
darkviper
|
$sSetupFile = dirname(dirname(__FILE__)).'/setup.ini.php';
|
124 |
|
|
if(is_readable($sSetupFile)) {
|
125 |
|
|
$aCfg = parse_ini_file($sSetupFile, true);
|
126 |
|
|
foreach($aCfg['Constants'] as $key=>$value) {
|
127 |
2001
|
Luisehahne
|
switch($key):
|
128 |
1885
|
Luisehahne
|
case 'DEBUG':
|
129 |
|
|
$value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
|
130 |
1887
|
Luisehahne
|
if(!defined('DEBUG')) { define('DEBUG', $value); }
|
131 |
1885
|
Luisehahne
|
break;
|
132 |
2015
|
darkviper
|
case 'WB_URL': // << case is set deprecated
|
133 |
1885
|
Luisehahne
|
case 'AppUrl':
|
134 |
|
|
$value = trim(str_replace('\\', '/', $value), '/');
|
135 |
|
|
if(!defined('WB_URL')) { define('WB_URL', $value); }
|
136 |
|
|
break;
|
137 |
2015
|
darkviper
|
case 'ADMIN_DIRECTORY': // << case is set deprecated
|
138 |
1885
|
Luisehahne
|
case 'AcpDir':
|
139 |
|
|
$value = trim(str_replace('\\', '/', $value), '/');
|
140 |
|
|
if(!defined('ADMIN_DIRECTORY')) { define('ADMIN_DIRECTORY', $value); }
|
141 |
|
|
break;
|
142 |
|
|
default:
|
143 |
|
|
if(!defined($key)) { define($key, $value); }
|
144 |
|
|
break;
|
145 |
|
|
endswitch;
|
146 |
1864
|
darkviper
|
}
|
147 |
|
|
}
|
148 |
2015
|
darkviper
|
return $aCfg;
|
149 |
|
|
// throw new RuntimeException('unable to read setup.ini.php');
|
150 |
1864
|
darkviper
|
}
|
151 |
2015
|
darkviper
|
/**
|
152 |
|
|
* GetDbConnectData
|
153 |
|
|
* @param array $aCfg
|
154 |
|
|
* @param string $sDbConnectType can be 'url' or 'dsn'
|
155 |
|
|
* @return array
|
156 |
|
|
*
|
157 |
|
|
*/
|
158 |
|
|
function initGetDbConnectData(array $aCfg, $sDbConnectType = 'url')
|
159 |
|
|
{
|
160 |
|
|
if(defined('DB_TYPE'))
|
161 |
|
|
{
|
162 |
|
|
// import constants for compatibility reasons
|
163 |
|
|
$db = array();
|
164 |
|
|
if(defined('DB_TYPE')) { $db['type'] = DB_TYPE; }
|
165 |
|
|
if(defined('DB_USERNAME')) { $db['user'] = DB_USERNAME; }
|
166 |
|
|
if(defined('DB_PASSWORD')) { $db['pass'] = DB_PASSWORD; }
|
167 |
|
|
if(defined('DB_HOST')) { $db['host'] = DB_HOST; }
|
168 |
|
|
if(defined('DB_PORT')) { $db['port'] = DB_PORT; }
|
169 |
|
|
if(defined('DB_NAME')) { $db['name'] = DB_NAME; }
|
170 |
|
|
if(defined('DB_CHARSET')) { $db['charset'] = DB_CHARSET; }
|
171 |
|
|
if(defined('TABLE_PREFIX')) { $db['table_prefix'] = TABLE_PREFIX; }
|
172 |
|
|
$aCfg['DataBase'] = $db;
|
173 |
|
|
}
|
174 |
|
|
// sanitize values
|
175 |
|
|
$db = $aCfg['DataBase'];
|
176 |
|
|
$db['type'] = isset($db['type']) ? $db['type'] : 'mysql';
|
177 |
|
|
$db['user'] = isset($db['user']) ? $db['user'] : 'foo';
|
178 |
|
|
$db['pass'] = isset($db['pass']) ? $db['pass'] : 'bar';
|
179 |
|
|
$db['host'] = isset($db['host']) ? $db['host'] : 'localhost';
|
180 |
|
|
$db['port'] = isset($db['port']) ? $db['port'] : '3306';
|
181 |
|
|
$db['port'] = ($db['port'] != '3306') ? $db['port'] : '';
|
182 |
|
|
$db['name'] = isset($db['name']) ? $db['name'] : 'dummy';
|
183 |
|
|
$db['charset'] = isset($db['charset']) ? trim($db['charset']) : 'utf8';
|
184 |
|
|
$db['table_prefix'] = (isset($db['table_prefix']) ? $db['table_prefix'] : '');
|
185 |
|
|
if(!defined('TABLE_PREFIX')) { define('TABLE_PREFIX', $db['table_prefix']); }
|
186 |
|
|
if($sDbConnectType == 'dsn') {
|
187 |
|
|
// build dsn to connect
|
188 |
|
|
$aRetval[0] = $db['type'].':dbname='.$db['name'].';host='.$db['host'].';'
|
189 |
|
|
. ($db['port'] != '' ? 'port='.(int)$db['port'].';' : '');
|
190 |
|
|
$aRetval[1] = array('CHARSET' => $db['charset'], 'TABLE_PREFIX' => $db['table_prefix']);
|
191 |
|
|
$aRetval[2] = array( 'user' => $db['user'], 'pass' => $db['pass']);
|
192 |
|
|
}else {
|
193 |
|
|
// build url to connect
|
194 |
|
|
$aRetval[0] = $db['type'].'://'.$db['user'].':'.$db['pass'].'@'
|
195 |
|
|
. $db['host'].($db['port'] != '' ? ':'.$db['port'] : '').'/'.$db['name']
|
196 |
|
|
. '?Charset='.$db['charset'].'&TablePrefix='.$db['table_prefix'];
|
197 |
|
|
}
|
198 |
|
|
return $aRetval;
|
199 |
|
|
}
|
200 |
|
|
|
201 |
1864
|
darkviper
|
/* ***************************************************************************************
|
202 |
|
|
* Start initialization *
|
203 |
|
|
****************************************************************************************/
|
204 |
|
|
// initialize debug evaluation values ---
|
205 |
1680
|
darkviper
|
$starttime = array_sum(explode(" ",microtime()));
|
206 |
1864
|
darkviper
|
$iPhpDeclaredClasses = sizeof(get_declared_classes());
|
207 |
2015
|
darkviper
|
$sDbConnectType = 'url'; // depending from class WbDatabase it can be 'url' or 'dsn'
|
208 |
1864
|
darkviper
|
// disable all kind of magic_quotes in PHP versions before 5.4 ---
|
209 |
2022
|
darkviper
|
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
|
210 |
|
|
$sMsg = '<p style="color: #ff0000;">WebsiteBaker is not able to run with magic_quotes=on!!<br />'
|
211 |
|
|
. 'Please change your PHP-ini or add a _htaccess file to switch this setting to off!<br />'
|
212 |
|
|
. 'If you have problems to solve that, ask your hosting provider for it.<br />'
|
213 |
|
|
. 'The very best solution is the use of PHP-5.4 and up</p>';
|
214 |
|
|
die($sMsg);
|
215 |
1864
|
darkviper
|
}
|
216 |
2015
|
darkviper
|
// load configuration ---
|
217 |
|
|
$aCfg = initReadSetupFile();
|
218 |
1865
|
darkviper
|
// sanitize $_SERVER['HTTP_REFERER'] ---
|
219 |
2015
|
darkviper
|
initSetInstallPathConstants();
|
220 |
|
|
initSanitizeHttpReferer(WB_URL);
|
221 |
1864
|
darkviper
|
// register WB basic autoloader ---
|
222 |
|
|
$sTmp = dirname(__FILE__).'/WbAutoloader.php';
|
223 |
1873
|
darkviper
|
if(!class_exists('WbAutoloader')){
|
224 |
|
|
include($sTmp);
|
225 |
|
|
}
|
226 |
1687
|
darkviper
|
WbAutoloader::doRegister(array(ADMIN_DIRECTORY=>'a', 'modules'=>'m'));
|
227 |
2015
|
darkviper
|
// instantiate and initialize adaptor for temporary registry replacement ---
|
228 |
|
|
WbAdaptor::getInstance()->getWbConstants();
|
229 |
1864
|
darkviper
|
// register TWIG autoloader ---
|
230 |
1865
|
darkviper
|
$sTmp = dirname(dirname(__FILE__)).'/include/Sensio/Twig/lib/Twig/Autoloader.php';
|
231 |
1873
|
darkviper
|
if(!class_exists('Twig_Autoloader')) {
|
232 |
|
|
include($sTmp);
|
233 |
|
|
}
|
234 |
1687
|
darkviper
|
Twig_Autoloader::register();
|
235 |
1864
|
darkviper
|
// aktivate exceptionhandler ---
|
236 |
|
|
if(!function_exists('globalExceptionHandler')) {
|
237 |
|
|
include(dirname(__FILE__).'/globalExceptionHandler.php');
|
238 |
|
|
}
|
239 |
|
|
// ---------------------------
|
240 |
2015
|
darkviper
|
// get Database connection data from configuration
|
241 |
|
|
$aSqlData = initGetDbConnectData($aCfg, $sDbConnectType);
|
242 |
1864
|
darkviper
|
// Create global database instance ---
|
243 |
2015
|
darkviper
|
$oDb = $database = WbDatabase::getInstance();
|
244 |
1864
|
darkviper
|
if($sDbConnectType == 'dsn') {
|
245 |
2015
|
darkviper
|
$bTmp = $oDb->doConnect($aSqlData[0], $aSqlData[1]['user'], $aSqlData[1]['pass'], $aSqlData[2]);
|
246 |
1864
|
darkviper
|
}else {
|
247 |
2015
|
darkviper
|
$bTmp = $oDb->doConnect($aSqlData[0]);
|
248 |
1680
|
darkviper
|
}
|
249 |
2015
|
darkviper
|
// remove critical data from memory
|
250 |
|
|
unset($aSqlData, $aCfg);
|
251 |
|
|
|
252 |
|
|
if(!defined('TABLE_PREFIX')) { define('TABLE_PREFIX', $oDb->TablePrefix); }
|
253 |
|
|
|
254 |
1864
|
darkviper
|
// load global settings from database and define global consts from ---
|
255 |
|
|
$sql = 'SELECT `name`, `value` FROM `'.TABLE_PREFIX.'settings`';
|
256 |
|
|
if(($oSettings = $database->query($sql))) {
|
257 |
|
|
if(!$oSettings->numRows()) { throw new AppException('no settings found'); }
|
258 |
|
|
while($aSetting = $oSettings->fetchRow(MYSQL_ASSOC)) {
|
259 |
|
|
//sanitize true/false values
|
260 |
|
|
$aSetting['value'] = ($aSetting['value'] == 'true'
|
261 |
|
|
? true
|
262 |
|
|
: ($aSetting['value'] == 'false'
|
263 |
|
|
? false
|
264 |
|
|
: $aSetting['value'])
|
265 |
|
|
);
|
266 |
1873
|
darkviper
|
$sSettingName = strtoupper($aSetting['name']);
|
267 |
|
|
switch($sSettingName):
|
268 |
|
|
case 'STRING_FILE_MODE':
|
269 |
|
|
$iTmp = ((intval(octdec($aSetting['value'])) & ~0111)|0600);
|
270 |
1887
|
Luisehahne
|
if(!defined('OCTAL_FILE_MODE')) { define('OCTAL_FILE_MODE', $iTmp); }
|
271 |
|
|
if(!defined('STRING_FILE_MODE')) { define('STRING_FILE_MODE', sprintf('0%03o', $iTmp)); }
|
272 |
1873
|
darkviper
|
break;
|
273 |
|
|
case 'STRING_DIR_MODE':
|
274 |
|
|
$iTmp = (intval(octdec($aSetting['value'])) |0711);
|
275 |
1887
|
Luisehahne
|
if(!defined('OCTAL_DIR_MODE')) { define('OCTAL_DIR_MODE', $iTmp); }
|
276 |
|
|
if(!defined('STRING_DIR_MODE')) { define('STRING_DIR_MODE', sprintf('0%03o', $iTmp)); }
|
277 |
1874
|
darkviper
|
break;
|
278 |
1873
|
darkviper
|
case 'PAGES_DIRECTORY':
|
279 |
|
|
// sanitize pages_directory
|
280 |
|
|
$sTmp = trim($aSetting['value'], '/');
|
281 |
|
|
$sTmp = ($sTmp == '' ? '' : '/'.$sTmp);
|
282 |
1887
|
Luisehahne
|
if(!defined('PAGES_DIRECTORY')) { define('PAGES_DIRECTORY', $sTmp); }
|
283 |
1873
|
darkviper
|
break;
|
284 |
|
|
default: // make global const from setting
|
285 |
1887
|
Luisehahne
|
if(!defined($sSettingName)) { define($sSettingName, $aSetting['value']); }
|
286 |
1873
|
darkviper
|
break;
|
287 |
|
|
endswitch;
|
288 |
1864
|
darkviper
|
}
|
289 |
|
|
}else { throw new AppException($database->get_error()); }
|
290 |
1872
|
Luisehahne
|
// set error-reporting from loaded settings ---
|
291 |
|
|
if(intval(ER_LEVEL) > 0 ) {
|
292 |
|
|
error_reporting(ER_LEVEL);
|
293 |
|
|
if( intval(ini_get ( 'display_errors' )) == 0 ) {
|
294 |
|
|
ini_set('display_errors', 1);
|
295 |
|
|
}
|
296 |
|
|
}
|
297 |
|
|
// Start a session ---
|
298 |
|
|
if(!defined('SESSION_STARTED')) {
|
299 |
|
|
session_name(APP_NAME.'_session_id');
|
300 |
|
|
@session_start();
|
301 |
|
|
define('SESSION_STARTED', true);
|
302 |
|
|
}
|
303 |
1963
|
darkviper
|
// get/set server timezone ---
|
304 |
|
|
if(!defined('SERVER_TIMEZONE')) { define('SERVER_TIMEZONE', "UTC"); }
|
305 |
|
|
date_default_timezone_set( SERVER_TIMEZONE );
|
306 |
|
|
if(!defined('MAX_TIME')) { define('MAX_TIME', (pow(2, 31)-1)); } // 32-Bit Timestamp of 19 Jan 2038 03:14:07 GMT
|
307 |
|
|
$sTmp = (isset($_SERVER['HTTP_DNT']) && $_SERVER['HTTP_DNT'] != '') ? $_SERVER['HTTP_DNT'] : '0';
|
308 |
|
|
if(!defined('DO_NOT_TRACK')) { define('DO_NOT_TRACK', ($sTmp[0] == '1')); }
|
309 |
1864
|
darkviper
|
// get/set users timezone ---
|
310 |
1887
|
Luisehahne
|
if(!defined('TIMEZONE')) { define('TIMEZONE', (isset($_SESSION['TIMEZONE']) ? $_SESSION['TIMEZONE'] : DEFAULT_TIMEZONE)); }
|
311 |
|
|
if(!defined('DATE_FORMAT')) { define('DATE_FORMAT', (isset($_SESSION['DATE_FORMAT']) ? $_SESSION['DATE_FORMAT'] : DEFAULT_DATE_FORMAT)); }
|
312 |
|
|
if(!defined('TIME_FORMAT')) { define('TIME_FORMAT', (isset($_SESSION['TIME_FORMAT']) ? $_SESSION['TIME_FORMAT'] : DEFAULT_TIME_FORMAT)); }
|
313 |
1864
|
darkviper
|
// set Theme directory ---
|
314 |
1887
|
Luisehahne
|
if(!defined('THEMA_URL')) { define('THEME_URL', WB_URL.'/templates/'.DEFAULT_THEME); }
|
315 |
|
|
if(!defined('THEME_PATH')) { define('THEME_PATH', WB_PATH.'/templates/'.DEFAULT_THEME); }
|
316 |
|
|
if(!defined('THEME_REL')) { define('THEME_REL', WB_REL.'/templates/'.DEFAULT_THEME); }
|
317 |
1864
|
darkviper
|
// extended wb editor settings
|
318 |
1887
|
Luisehahne
|
if(!defined('EDIT_ONE_SECTION')) { define('EDIT_ONE_SECTION', false); }
|
319 |
|
|
if(!defined('EDITOR_WIDTH')) { define('EDITOR_WIDTH', 0); }
|
320 |
1864
|
darkviper
|
// define form security class and preload it ---
|
321 |
1465
|
Luisehahne
|
$sSecMod = (defined('SECURE_FORM_MODULE') && SECURE_FORM_MODULE != '') ? '.'.SECURE_FORM_MODULE : '';
|
322 |
1462
|
DarkViper
|
$sSecMod = WB_PATH.'/framework/SecureForm'.$sSecMod.'.php';
|
323 |
|
|
require_once($sSecMod);
|
324 |
1864
|
darkviper
|
// *** begin deprecated part *************************************************************
|
325 |
|
|
// load settings for use in Captch and ASP module
|
326 |
1887
|
Luisehahne
|
if (!defined('WB_INSTALL_PROCESS') && !defined('ENABLED_CAPTCHA')) {
|
327 |
1864
|
darkviper
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_captcha_control`';
|
328 |
|
|
// request settings from database
|
329 |
|
|
if(($oSettings = $database->query($sql))) {
|
330 |
|
|
if(($aSetting = $oSettings->fetchRow(MYSQL_ASSOC))) {
|
331 |
|
|
define('ENABLED_CAPTCHA', ($aSetting['enabled_captcha'] == '1'));
|
332 |
|
|
define('ENABLED_ASP', ($aSetting['enabled_asp'] == '1'));
|
333 |
|
|
define('CAPTCHA_TYPE', $aSetting['captcha_type']);
|
334 |
|
|
define('ASP_SESSION_MIN_AGE', (int)$aSetting['asp_session_min_age']);
|
335 |
|
|
define('ASP_VIEW_MIN_AGE', (int)$aSetting['asp_view_min_age']);
|
336 |
|
|
define('ASP_INPUT_MIN_AGE', (int)$aSetting['asp_input_min_age']);
|
337 |
|
|
}
|
338 |
|
|
}
|
339 |
|
|
}
|
340 |
|
|
if(defined('ENABLED_ASP') && ENABLED_ASP && !isset($_SESSION['session_started'])) {
|
341 |
1349
|
Luisehahne
|
$_SESSION['session_started'] = time();
|
342 |
1864
|
darkviper
|
}
|
343 |
|
|
// *** end of deprecated part ************************************************************
|
344 |
|
|
// get user language ---
|
345 |
|
|
$sRequestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
|
346 |
|
|
// check if get/post value is available
|
347 |
|
|
$sTempLanguage = (isset(${$sRequestMethod}['lang']) ? ${$sRequestMethod}['lang'] : '');
|
348 |
|
|
// validate language code
|
349 |
|
|
if(preg_match('/^[a-z]{2}$/si', $sTempLanguage)) {
|
350 |
|
|
// if there's valid get/post
|
351 |
|
|
define('LANGUAGE', strtoupper($sTempLanguage));
|
352 |
1349
|
Luisehahne
|
$_SESSION['LANGUAGE']=LANGUAGE;
|
353 |
1864
|
darkviper
|
}else {
|
354 |
|
|
if(isset($_SESSION['LANGUAGE']) && $_SESSION['LANGUAGE']) {
|
355 |
|
|
// if there's valid session value
|
356 |
1349
|
Luisehahne
|
define('LANGUAGE', $_SESSION['LANGUAGE']);
|
357 |
1864
|
darkviper
|
}else {
|
358 |
|
|
// otherwise set to default
|
359 |
1349
|
Luisehahne
|
define('LANGUAGE', DEFAULT_LANGUAGE);
|
360 |
|
|
}
|
361 |
|
|
}
|
362 |
1864
|
darkviper
|
// activate translations / load language definitions
|
363 |
|
|
/** begin of deprecated part || will be replaced by class Translate **/
|
364 |
|
|
// Load Language file
|
365 |
|
|
if(!file_exists(WB_PATH.'/languages/'.LANGUAGE.'.php')) {
|
366 |
|
|
$sMsg = 'Error loading language file '.LANGUAGE.', please check configuration';
|
367 |
|
|
throw new AppException($sMsg);
|
368 |
1349
|
Luisehahne
|
} else {
|
369 |
1864
|
darkviper
|
// include language file
|
370 |
|
|
require_once(WB_PATH.'/languages/'.LANGUAGE.'.php');
|
371 |
1349
|
Luisehahne
|
}
|
372 |
1864
|
darkviper
|
/** end of deprecated part **/
|
373 |
|
|
// instantiate and initialize adaptor for temporary registry replacement ---
|
374 |
2015
|
darkviper
|
WbAdaptor::getInstance()->getWbConstants();
|
375 |
1864
|
darkviper
|
// load and activate new global translation table
|
376 |
|
|
Translate::getInstance()->initialize('en',
|
377 |
1873
|
darkviper
|
(defined('DEFAULT_LANGUAGE') ? DEFAULT_LANGUAGE : ''),
|
378 |
1885
|
Luisehahne
|
(defined('LANGUAGE') ? LANGUAGE : ''),
|
379 |
|
|
'WbOldStyle',
|
380 |
2015
|
darkviper
|
(Translate::CACHE_DISABLED|Translate::KEEP_MISSING)
|
381 |
|
|
// (DEBUG ? Translate::CACHE_DISABLED|Translate::KEEP_MISSING : 0)
|
382 |
1873
|
darkviper
|
);
|
383 |
1963
|
darkviper
|
if(!class_exists('PasswordHash', false)) { include(WB_PATH.'/include/phpass/PasswordHash.php'); }
|
384 |
1932
|
darkviper
|
$oPass = Password::getInstance(new PasswordHash(Password::CRYPT_LOOPS_DEFAULT, Password::HASH_TYPE_AUTO));
|
385 |
1930
|
darkviper
|
if(defined('PASSWORD_CRYPT_LOOPS')) { $oPass->setIteration(PASSWORD_CRYPT_LOOPS); }
|
386 |
1932
|
darkviper
|
if(defined('PASSWORD_HASH_TYPES')) { $oPass->setHashType(PASSWORD_HASH_TYPES); }
|
387 |
1864
|
darkviper
|
// *** END OF FILE ***********************************************************************
|