215 |
215 |
return $aRetval;
|
216 |
216 |
}
|
217 |
217 |
|
|
218 |
function WbErrorHandler($iErrorCode, $sErrorText, $sErrorFile, $iErrorLine)
|
|
219 |
{
|
|
220 |
if (!(error_reporting() & $iErrorCode)) {
|
|
221 |
return false;
|
|
222 |
}
|
|
223 |
$bRetval = false;
|
|
224 |
$aErrors = array(
|
|
225 |
E_USER_DEPRECATED => 'E_USER_DEPRECATED',
|
|
226 |
E_USER_NOTICE => 'E_USER_NOTICE',
|
|
227 |
E_USER_WARNING => 'E_USER_WARNING',
|
|
228 |
E_DEPRECATED => 'E_DEPRECATED',
|
|
229 |
E_NOTICE => 'E_NOTICE',
|
|
230 |
E_WARNING => 'E_WARNING',
|
|
231 |
E_CORE_WARNING => 'E_CORE_WARNING',
|
|
232 |
E_COMPILE_WARNING => 'E_COMPILE_WARNING',
|
|
233 |
E_STRICT => 'E_STRICT',
|
|
234 |
);
|
|
235 |
if (array_key_exists($iErrorCode, $aErrors)) {
|
|
236 |
$sErrorType = $aErrors[$iErrorCode];
|
|
237 |
$bRetval = true;
|
|
238 |
}
|
|
239 |
$aBt= debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
|
240 |
$sEntry = date('c').' '.'['.$sErrorType.'] '.str_replace(dirname(__DIR__), '', $sErrorFile).':['.$iErrorLine.'] '
|
|
241 |
. ' from '.str_replace(dirname(__DIR__), '', $aBt[2]['file']).':['.$aBt[2]['line'].'] '
|
|
242 |
. (@$aBt[2]['class'] ? $aBt[2]['class'].$aBt[2]['type'] : '').$aBt[2]['function'].' '
|
|
243 |
. '"'.$sErrorText.'"'.PHP_EOL;
|
|
244 |
file_put_contents(dirname(__DIR__).'/temp/ERROR.LOG', $sEntry, FILE_APPEND);
|
|
245 |
return $bRetval;
|
|
246 |
}
|
218 |
247 |
/* ***************************************************************************************
|
219 |
248 |
* Start initialization *
|
220 |
249 |
****************************************************************************************/
|
|
250 |
// activate errorhandler
|
|
251 |
set_error_handler('WbErrorHandler');
|
221 |
252 |
// reset global output buffering
|
222 |
253 |
while (ob_get_level()) { ob_end_clean(); }
|
223 |
254 |
// test for existing and active old config.php
|
... | ... | |
242 |
273 |
if (! defined('SYSTEM_RUN')) { define('SYSTEM_RUN', true); }
|
243 |
274 |
// load configuration ---
|
244 |
275 |
$aCfg = initReadSetupFile();
|
|
276 |
|
245 |
277 |
// sanitize $_SERVER['HTTP_REFERER'] ---
|
246 |
278 |
initSetInstallPathConstants();
|
247 |
279 |
initSanitizeHttpReferer(WB_URL);
|
... | ... | |
294 |
326 |
// load global settings from database and define global consts from ---
|
295 |
327 |
$sql = 'SELECT `name`, `value` FROM `'.$oDb->TablePrefix.'settings`';
|
296 |
328 |
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;
|
|
329 |
if (($aRecords = $oSettings->fetchAll(MYSQLI_NUM))) {
|
|
330 |
$iNum = sizeof($aRecords);
|
|
331 |
for ($i = 0; $i < $iNum; $i++) {
|
|
332 |
$aSetting = $aRecords[$i];
|
|
333 |
//sanitize true/false values
|
|
334 |
$aSetting['value'] = ($aSetting['value'] == 'true'
|
|
335 |
? true
|
|
336 |
: ($aSetting['value'] == 'false'
|
|
337 |
? false
|
|
338 |
: $aSetting['value'])
|
|
339 |
);
|
|
340 |
$sSettingName = strtoupper($aSetting['name']);
|
|
341 |
switch($sSettingName):
|
|
342 |
case 'STRING_FILE_MODE':
|
|
343 |
$iTmp = ((intval(octdec($aSetting['value'])) & ~0111)|0600);
|
|
344 |
if(!defined('OCTAL_FILE_MODE')) { define('OCTAL_FILE_MODE', $iTmp); } // deprecated
|
|
345 |
if(!defined('FILE_MODE_OCTAL')) { define('FILE_MODE_OCTAL', $iTmp); }
|
|
346 |
if(!defined('STRING_FILE_MODE')) { define('STRING_FILE_MODE', sprintf('0%03o', $iTmp)); } // deprecated
|
|
347 |
if(!defined('FILE_MODE_STRING')) { define('FILE_MODE_STRING', sprintf('0%03o', $iTmp)); }
|
|
348 |
break;
|
|
349 |
case 'STRING_DIR_MODE':
|
|
350 |
$iTmp = (intval(octdec($aSetting['value'])) |0711);
|
|
351 |
if(!defined('OCTAL_DIR_MODE')) { define('OCTAL_DIR_MODE', $iTmp); } // deprecated
|
|
352 |
if(!defined('DIR_MODE_OCTAL')) { define('DIR_MODE_OCTAL', $iTmp); }
|
|
353 |
if(!defined('STRING_DIR_MODE')) { define('STRING_DIR_MODE', sprintf('0%03o', $iTmp)); } // deprecated
|
|
354 |
if(!defined('DIR_MODE_STRING')) { define('DIR_MODE_STRING', sprintf('0%03o', $iTmp)); }
|
|
355 |
break;
|
|
356 |
case 'PAGES_DIRECTORY':
|
|
357 |
// sanitize pages_directory
|
|
358 |
$sTmp = trim($aSetting['value'], '/');
|
|
359 |
$sTmp = ($sTmp == '' ? '' : '/'.$sTmp);
|
|
360 |
if(!defined('PAGES_DIRECTORY')) { define('PAGES_DIRECTORY', $sTmp); }
|
|
361 |
break;
|
|
362 |
default: // make global const from setting
|
|
363 |
if(!defined($sSettingName)) { define($sSettingName, $aSetting['value']); }
|
|
364 |
break;
|
|
365 |
endswitch;
|
|
366 |
}
|
|
367 |
} else {
|
|
368 |
throw new AppException('no settings found');
|
332 |
369 |
}
|
333 |
|
}else { throw new AppException($database->get_error()); }
|
|
370 |
} else {
|
|
371 |
throw new AppException($oDb->getError());
|
|
372 |
}
|
|
373 |
$oReg->getWbConstants();
|
334 |
374 |
// 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 |
|
}
|
|
375 |
$iErrorLevel = intval(ER_LEVEL);
|
|
376 |
if ($iErrorLevel >= 0 && $iErrorLevel <= E_ALL) {
|
|
377 |
error_reporting($iErrorLevel);
|
|
378 |
} else {
|
|
379 |
// on invalid value in ER_LEVEL activate E_ALL
|
|
380 |
error_reporting(E_ALL);
|
340 |
381 |
}
|
|
382 |
// activate display_errors
|
|
383 |
if( intval(ini_get ( 'display_errors' )) == 0 ) {
|
|
384 |
ini_set('display_errors', 1);
|
|
385 |
}
|
341 |
386 |
// Start a session ---
|
342 |
387 |
if(!defined('SESSION_STARTED')) {
|
343 |
388 |
session_name(APP_NAME.'_session_id');
|
... | ... | |
367 |
412 |
// *** begin deprecated part *************************************************************
|
368 |
413 |
// load settings for use in Captch and ASP module
|
369 |
414 |
if (!defined('WB_INSTALL_PROCESS') && !defined('ENABLED_CAPTCHA')) {
|
370 |
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_captcha_control`';
|
|
415 |
$sql = 'SELECT * FROM `'.$oDb->TablePrefix.'mod_captcha_control`';
|
371 |
416 |
// request settings from database
|
372 |
|
if(($oSettings = $database->query($sql))) {
|
373 |
|
if(($aSetting = $oSettings->fetchRow(MYSQL_ASSOC))) {
|
|
417 |
if(($oSettings = $oDb->doQuery($sql))) {
|
|
418 |
if(($aSetting = $oSettings->fetchAssoc())) {
|
374 |
419 |
define('ENABLED_CAPTCHA', ($aSetting['enabled_captcha'] == '1'));
|
375 |
420 |
define('ENABLED_ASP', ($aSetting['enabled_asp'] == '1'));
|
376 |
421 |
define('CAPTCHA_TYPE', $aSetting['captcha_type']);
|
! framework/initialize.php added ErrorHandler and ERROR-LOG file