Changeset View
Changeset View
Standalone View
Standalone View
branches/5.3.x/core/install.php
Show First 20 Lines • Show All 601 Lines • ▼ Show 20 Line(s) | |||||
function Run() | function Run() | ||||
{ | { | ||||
if ($this->errorMessage) { | if ($this->errorMessage) { | ||||
// was error during data validation stage | // was error during data validation stage | ||||
return ; | return ; | ||||
} | } | ||||
switch ($this->currentStep) { | switch ($this->currentStep) { | ||||
case 'check_paths': | |||||
$this->generateSecurityKeys(); | |||||
break; | |||||
case 'db_config': | case 'db_config': | ||||
case 'db_reconfig': | case 'db_reconfig': | ||||
// store db configuration | // store db configuration | ||||
$sql = 'SHOW COLLATION | $sql = 'SHOW COLLATION | ||||
LIKE \''.$this->toolkit->systemConfig->get('DBCollation', 'Database').'\''; | LIKE \''.$this->toolkit->systemConfig->get('DBCollation', 'Database').'\''; | ||||
$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 432 Lines • ▼ Show 20 Line(s) | |||||
$user_helper = $this->Application->recallObject('UserHelper'); | $user_helper = $this->Application->recallObject('UserHelper'); | ||||
$user_helper->logoutUser(); | $user_helper->logoutUser(); | ||||
$this->Application->Redirect($user_helper->event->redirect, $user_helper->event->getRedirectParams(), '', 'index.php'); | $this->Application->Redirect($user_helper->event->redirect, $user_helper->event->getRedirectParams(), '', 'index.php'); | ||||
} | } | ||||
} | } | ||||
/** | |||||
* Generates a security keys. | |||||
* | |||||
* @return void | |||||
*/ | |||||
protected function generateSecurityKeys() | |||||
{ | |||||
if ( $this->toolkit->systemConfig->get('SecurityHmacKey', 'Misc') | |||||
&& $this->toolkit->systemConfig->get('SecurityEncryptionKey', 'Misc') | |||||
) { | |||||
return; | |||||
} | |||||
// 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(); | |||||
} | |||||
function getUpgradeDependencies($modules, &$upgrade_data) | function getUpgradeDependencies($modules, &$upgrade_data) | ||||
{ | { | ||||
$dependencies = Array (); | $dependencies = Array (); | ||||
foreach ($modules as $module_name) { | foreach ($modules as $module_name) { | ||||
$module_info = $upgrade_data[$module_name]; | $module_info = $upgrade_data[$module_name]; | ||||
$upgrade_object =& $this->getUpgradeObject($module_info['Path']); | $upgrade_object =& $this->getUpgradeObject($module_info['Path']); | ||||
▲ Show 20 Lines • Show All 688 Lines • Show Last 20 Lines |