Revision 2130
Added by darkviper over 9 years ago
initialize.php | ||
---|---|---|
121 | 121 |
// check for valid file request. Becomes more stronger in next version |
122 | 122 |
initCheckValidCaller(array('save.php','index.php','config.php','upgrade-script.php')); |
123 | 123 |
$aCfg = array(); |
124 |
|
|
125 | 124 |
$sSetupFile = dirname(__DIR__).'/setup.ini.php'; |
126 | 125 |
if(is_readable($sSetupFile)) { |
127 | 126 |
$aCfg = parse_ini_file($sSetupFile, true); |
... | ... | |
326 | 325 |
// load global settings from database and define global consts from --- |
327 | 326 |
$sql = 'SELECT `name`, `value` FROM `'.$oDb->TablePrefix.'settings`'; |
328 | 327 |
if(($oSettings = $oDb->doQuery($sql))) { |
329 |
if (($aRecords = $oSettings->fetchAll(MYSQLI_NUM))) { |
|
330 |
$iNum = sizeof($aRecords); |
|
331 |
for ($i = 0; $i < $iNum; $i++) { |
|
332 |
$aSetting = $aRecords[$i]; |
|
328 |
if (($aRecords = $oSettings->fetchAll(MYSQLI_ASSOC))) { |
|
329 |
for ($i = 0, $iNum = sizeof($aRecords); $i < $iNum; $i++) { |
|
333 | 330 |
//sanitize true/false values |
334 |
$aSetting['value'] = ($aSetting['value'] == 'true'
|
|
331 |
$aRecords[$i]['value'] = ($aRecords[$i]['value'] == 'true'
|
|
335 | 332 |
? true |
336 |
: ($aSetting['value'] == 'false'
|
|
333 |
: ($aRecords[$i]['value'] == 'false'
|
|
337 | 334 |
? false |
338 |
: $aSetting['value'])
|
|
335 |
: $aRecords[$i]['value'])
|
|
339 | 336 |
); |
340 |
$sSettingName = strtoupper($aSetting['name']);
|
|
337 |
$sSettingName = strtoupper($aRecords[$i]['name']);
|
|
341 | 338 |
switch($sSettingName): |
342 | 339 |
case 'STRING_FILE_MODE': |
343 |
$iTmp = ((intval(octdec($aSetting['value'])) & ~0111)|0600);
|
|
340 |
$iTmp = ((intval(octdec($aRecords[$i]['value'])) & ~0111)|0600);
|
|
344 | 341 |
if(!defined('OCTAL_FILE_MODE')) { define('OCTAL_FILE_MODE', $iTmp); } // deprecated |
345 | 342 |
if(!defined('FILE_MODE_OCTAL')) { define('FILE_MODE_OCTAL', $iTmp); } |
346 | 343 |
if(!defined('STRING_FILE_MODE')) { define('STRING_FILE_MODE', sprintf('0%03o', $iTmp)); } // deprecated |
347 | 344 |
if(!defined('FILE_MODE_STRING')) { define('FILE_MODE_STRING', sprintf('0%03o', $iTmp)); } |
348 | 345 |
break; |
349 | 346 |
case 'STRING_DIR_MODE': |
350 |
$iTmp = (intval(octdec($aSetting['value'])) |0711);
|
|
347 |
$iTmp = (intval(octdec($aRecords[$i]['value'])) |0711);
|
|
351 | 348 |
if(!defined('OCTAL_DIR_MODE')) { define('OCTAL_DIR_MODE', $iTmp); } // deprecated |
352 | 349 |
if(!defined('DIR_MODE_OCTAL')) { define('DIR_MODE_OCTAL', $iTmp); } |
353 | 350 |
if(!defined('STRING_DIR_MODE')) { define('STRING_DIR_MODE', sprintf('0%03o', $iTmp)); } // deprecated |
... | ... | |
355 | 352 |
break; |
356 | 353 |
case 'PAGES_DIRECTORY': |
357 | 354 |
// sanitize pages_directory |
358 |
$sTmp = trim($aSetting['value'], '/');
|
|
355 |
$sTmp = trim($aRecords[$i]['value'], '/');
|
|
359 | 356 |
$sTmp = ($sTmp == '' ? '' : '/'.$sTmp); |
360 | 357 |
if(!defined('PAGES_DIRECTORY')) { define('PAGES_DIRECTORY', $sTmp); } |
361 | 358 |
break; |
362 | 359 |
default: // make global const from setting |
363 |
if(!defined($sSettingName)) { define($sSettingName, $aSetting['value']); }
|
|
360 |
if(!defined($sSettingName)) { define($sSettingName, $aRecords[$i]['value']); }
|
|
364 | 361 |
break; |
365 | 362 |
endswitch; |
366 | 363 |
} |
364 |
unset($aRecords); |
|
367 | 365 |
} else { |
368 | 366 |
throw new AppException('no settings found'); |
369 | 367 |
} |
Also available in: Unified diff
! framework/initialize.php optimised read-settings routine for speed and memory consumption.