Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/install.php
Show First 20 Lines • Show All 623 Lines • ▼ Show 20 Line(s) | |||||
$collation_info = $this->Conn->Query($sql); | $collation_info = $this->Conn->Query($sql); | ||||
if ($collation_info) { | if ($collation_info) { | ||||
$this->toolkit->systemConfig->set('DBCharset', 'Database', $collation_info[0]['Charset']); | $this->toolkit->systemConfig->set('DBCharset', 'Database', $collation_info[0]['Charset']); | ||||
// database is already connected, that's why set collation on the fly | // database is already connected, that's why set collation on the fly | ||||
$this->Conn->Query('SET NAMES \''.$this->toolkit->systemConfig->get('DBCharset', 'Database').'\' COLLATE \''.$this->toolkit->systemConfig->get('DBCollation', 'Database').'\''); | $this->Conn->Query('SET NAMES \''.$this->toolkit->systemConfig->get('DBCharset', 'Database').'\' COLLATE \''.$this->toolkit->systemConfig->get('DBCollation', 'Database').'\''); | ||||
} | } | ||||
if ( !$this->toolkit->systemConfig->get('SecurityHmacKey', 'Misc') | |||||
|| !$this->toolkit->systemConfig->get('SecurityEncryptionKey', 'Misc') | |||||
) { | |||||
// Include class declarations manually, because kApplication isn't available. | |||||
require_once FULL_PATH . '/core/kernel/security/SecurityEncrypter.php'; | |||||
require_once FULL_PATH . '/core/kernel/security/SecurityGenerator.php'; | |||||
require_once FULL_PATH . '/core/kernel/security/SecurityGeneratorPromise.php'; | |||||
// Include dependencies, to make "random_int" function available in earlier PHP versions. | |||||
require_once FULL_PATH . '/vendor/autoload.php'; | |||||
// Generate missing security-related settings. | |||||
$this->toolkit->systemConfig->set( | |||||
'SecurityHmacKey', | |||||
'Misc', | |||||
base64_encode(SecurityGenerator::generateString( | |||||
SecurityEncrypter::HASHING_KEY_LENGTH, | |||||
SecurityGenerator::CHAR_ALNUM | SecurityGenerator::CHAR_SYMBOLS | |||||
)) | |||||
); | |||||
$this->toolkit->systemConfig->set( | |||||
'SecurityEncryptionKey', | |||||
'Misc', | |||||
SecurityGenerator::generateBytes(SecurityEncrypter::ENCRYPTION_KEY_LENGTH) | |||||
); | |||||
} | |||||
$this->toolkit->systemConfig->save(); | $this->toolkit->systemConfig->save(); | ||||
if ($this->currentStep == 'db_config') { | if ($this->currentStep == 'db_config') { | ||||
if ($this->GetVar('UseExistingSetup')) { | if ($this->GetVar('UseExistingSetup')) { | ||||
// abort clean install and redirect to already_installed | // abort clean install and redirect to already_installed | ||||
$this->stepsPreset = 'already_installed'; | $this->stepsPreset = 'already_installed'; | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Line(s) | |||||
$config_data = $this->GetVar('system_config'); | $config_data = $this->GetVar('system_config'); | ||||
foreach ($config_data as $section => $section_vars) { | foreach ($config_data as $section => $section_vars) { | ||||
foreach ($section_vars as $var_name => $var_value) { | foreach ($section_vars as $var_name => $var_value) { | ||||
$this->toolkit->systemConfig->set($var_name, $section, $var_value); | $this->toolkit->systemConfig->set($var_name, $section, $var_value); | ||||
} | } | ||||
} | } | ||||
if ( !$this->toolkit->systemConfig->get('SecurityHmacKey', 'Misc') | |||||
|| !$this->toolkit->systemConfig->get('SecurityEncryptionKey', 'Misc') | |||||
) { | |||||
$this->toolkit->systemConfig->set( | |||||
'SecurityHmacKey', | |||||
'Misc', | |||||
base64_encode(SecurityGenerator::generateString( | |||||
SecurityEncrypter::HASHING_KEY_LENGTH, | |||||
SecurityGenerator::CHAR_ALNUM | SecurityGenerator::CHAR_SYMBOLS | |||||
)) | |||||
); | |||||
$this->toolkit->systemConfig->set( | |||||
'SecurityEncryptionKey', | |||||
'Misc', | |||||
SecurityGenerator::generateBytes(SecurityEncrypter::ENCRYPTION_KEY_LENGTH) | |||||
); | |||||
} | |||||
$this->toolkit->systemConfig->save(); | $this->toolkit->systemConfig->save(); | ||||
break; | break; | ||||
case 'root_password': | case 'root_password': | ||||
// update root password in database | // update root password in database | ||||
/** @var kPasswordFormatter $password_formatter */ | /** @var kPasswordFormatter $password_formatter */ | ||||
$password_formatter = $this->Application->recallObject('kPasswordFormatter'); | $password_formatter = $this->Application->recallObject('kPasswordFormatter'); | ||||
▲ Show 20 Lines • Show All 921 Lines • Show Last 20 Lines |