Index: branches/5.1.x/core/install.php =================================================================== diff -u -N -r12127 -r12657 --- branches/5.1.x/core/install.php (.../install.php) (revision 12127) +++ branches/5.1.x/core/install.php (.../install.php) (revision 12657) @@ -1,6 +1,6 @@ Array ('check_paths', 'db_config', 'select_license', 'download_license', 'select_domain', 'root_password', 'choose_modules', 'post_config', 'select_theme', 'finish'), - 'clean_reinstall' => Array ('check_paths', 'clean_db', 'db_config', 'select_license', 'download_license', 'select_domain', 'root_password', 'choose_modules', 'post_config', 'select_theme', 'finish'), + 'fresh_install' => Array ('check_paths', 'db_config', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'select_theme', 'security', 'finish'), + 'clean_reinstall' => Array ('check_paths', 'clean_db', 'db_config', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'select_theme', 'security', 'finish'), 'already_installed' => Array ('check_paths', 'install_setup'), - 'upgrade' => Array ('check_paths', 'install_setup', 'upgrade_modules', 'finish'), - 'update_license' => Array ('check_paths', 'install_setup', 'select_license', 'download_license', 'select_domain', 'finish'), - 'db_reconfig' => Array ('check_paths', 'install_setup', 'db_reconfig', 'finish'), - 'fix_paths' => Array ('check_paths', 'install_setup', 'fix_paths', 'finish'), + 'upgrade' => Array ('check_paths', 'install_setup', 'upgrade_modules', 'security', 'finish'), + 'update_license' => Array ('check_paths', 'install_setup', 'select_license', /*'download_license',*/ 'select_domain', 'security', 'finish'), + 'db_reconfig' => Array ('check_paths', 'install_setup', 'db_reconfig', 'security', 'finish'), + 'fix_paths' => Array ('check_paths', 'install_setup', 'fix_paths', 'security', 'finish'), ); /** * Steps, that doesn't required admin to be logged-in to proceed * * @var Array */ - var $skipLoginSteps = Array ('check_paths', 'select_license', 'download_license', 'select_domain', 'root_password', 'choose_modules', 'post_config', 'select_theme', 'finish', -1); + var $skipLoginSteps = Array ('check_paths', 'select_license', /*'download_license',*/ 'select_domain', 'root_password', 'choose_modules', 'post_config', 'select_theme', 'security', 'finish', -1); /** * Steps, on which kApplication should not be initialized, because of missing correct db table structure @@ -106,6 +106,8 @@ '$1/images/emoticons', // for "In-Bulletin" '$1/images/manufacturers', // for "In-Commerce" '$1/images/manufacturers/resized', // for "In-Commerce" + '$1/images/polls', // for "In-Bulletin" + '$1/images/polls/resized', // for "In-Bulletin" '$1/backupdata', '$1/export', '$1/stylesheets', @@ -250,7 +252,7 @@ foreach ($this->writeableFolders as $folder_path) { $file_path = FULL_PATH . str_replace('$1', $writeable_base, $folder_path); if (file_exists($file_path) && !is_writable($file_path)) { - $this->errorMessage = 'Install cannot write to specified folder in the root directory of your installation'; + $this->errorMessage = '
Installation can not continue until all required permissions are set correctly'; break; } } @@ -387,6 +389,59 @@ $this->errorMessage = 'Please select action to perform'; } break; + + case 'security': + // perform write check + if ($this->Application->GetVar('skip_security_check')) { + // administrator intensionally skips security checks + break; + } + + $write_check = true; + $check_paths = Array ('/', '/index.php', '/config.php', ADMIN_DIRECTORY . '/index.php'); + foreach ($check_paths as $check_path) { + $path_check_status = $this->toolkit->checkWritePermissions(FULL_PATH . $check_path); + + if (is_bool($path_check_status) && $path_check_status) { + $write_check = false; + break; + } + } + + // script execute check + if (file_exists(WRITEABLE . '/install_check.php')) { + unlink(WRITEABLE . '/install_check.php'); + } + + $fp = fopen(WRITEABLE . '/install_check.php', 'w'); + fwrite($fp, "Application->recallObject('CurlHelper'); + /* @var $curl_helper kCurlHelper */ + + $output = $curl_helper->Send($this->Application->BaseURL(WRITEBALE_BASE) . 'install_check.php'); + unlink(WRITEABLE . '/install_check.php'); + $execute_check = ($output !== 'OK'); + + $directive_check = true; + $ini_vars = Array ('register_globals' => false, 'open_basedir' => true, 'allow_url_fopen' => false); + foreach ($ini_vars as $var_name => $var_value) { + $current_value = ini_get($var_name); + + if (($var_value && !$current_value) || (!$var_value && $current_value)) { + $directive_check = false; + break; + } + } + + if (!$write_check || !$execute_check || !$directive_check) { + $this->errorMessage = true; + } + /*else { + $this->currentStep = $this->GetNextStep(); + }*/ + break; } $this->PerformValidation(); // returns validation status (just in case) @@ -457,20 +512,20 @@ break; case 'choose_modules': + break; + case 'upgrade_modules': $modules = $this->Application->GetVar('modules'); if (!$modules) { $modules = Array (); $this->errorMessage = 'Please select module(-s) to ' . ($this->currentStep == 'choose_modules' ? 'install' : 'upgrade'); } - if ($this->currentStep == 'choose_modules') { - // don't check interface modules during install, only for during upgrade - break; - } - // check interface module - if (!in_array('core', $modules)) { + $upgrade_data = $this->GetUpgradableModules(); + + if (array_key_exists('core', $upgrade_data) && !in_array('core', $modules)) { + // core can be upgraded, but isn't selected $this->errorMessage = 'Please select "Core" as interface module'; } @@ -531,6 +586,9 @@ // set module "Core" version after install (based on upgrade scripts) $this->toolkit->SetModuleVersion('Core'); + + // for now we set "In-Portal" module version to "Core" module version (during clean install) + $this->toolkit->SetModuleVersion('In-Portal', $this->toolkit->GetMaxModuleVersion('Core')); } break; @@ -680,7 +738,7 @@ if ($domain != '') { if (strstr($domain, $license_domain) || $modules_helper->_IsLocalSite($domain)) { - $this->toolkit->setSystemConfig('Intechnic', 'Domain', $domain); + $this->toolkit->setSystemConfig('Misc', 'Domain', $domain); $this->toolkit->SaveConfig(); } else { @@ -700,11 +758,18 @@ 'RootPass' => $password, 'Site_Path' => BASE_PATH.'/', // set Site_Path (for SSL & old in-portal code) 'Backup_Path' => FULL_PATH . $this->toolkit->getSystemConfig('Misc', 'WriteablePath') . DIRECTORY_SEPARATOR . 'backupdata', - 'Smtp_AdminMailFrom' => 'portal@' . $this->toolkit->getSystemConfig('Intechnic', 'Domain') + 'Smtp_AdminMailFrom' => 'portal@' . $this->toolkit->getSystemConfig('Misc', 'Domain') ); $this->toolkit->saveConfigValues($config_values); + // login as "root", when no errors on password screen + $this->Application->SetVar('login', 'root'); + $this->Application->SetVar('password', $this->Application->GetVar('root_password')); + + $login_event = new kEvent('u.current:OnLogin'); + $this->Application->HandleEvent($login_event); + // import base language for core (english) $this->toolkit->ImportLanguage('/core/install/english'); @@ -824,6 +889,11 @@ // after upgrade sqls are executed update version and upgrade language pack $this->toolkit->SetModuleVersion($module_name, $module_info['ToVersion']); } + + // for now we set "In-Portal" module version to "Core" module version (during upgrade) + if (in_array('core', $modules)) { + $this->toolkit->SetModuleVersion('In-Portal', $upgrade_data['core']['ToVersion']); + } } break; @@ -1074,8 +1144,8 @@ if (!isset($modules)) { $modules = Array(); $fh = opendir(MODULES_PATH); - while (($sub_folder = readdir($fh))) { - $folder_path = MODULES_PATH.'/'.$sub_folder; + while ( ($sub_folder = readdir($fh)) ) { + $folder_path = MODULES_PATH . '/'.$sub_folder; if ($sub_folder != '.' && $sub_folder != '..' && is_dir($folder_path)) { if ($sub_folder == 'core') { // skip modules here @@ -1336,5 +1406,32 @@ $this->Done($errstr); } } + + /** + * Checks, that given button should be visible on current installation step + * + * @param string $name + * @return bool + */ + function buttonVisible($name) + { + $button_visibility = Array ( + 'continue' => $this->GetNextStep() != -1 || ($this->stepsPreset == 'already_installed'), + 'refresh' => in_array($this->currentStep, Array ('check_paths', 'security')), + 'back' => in_array($this->currentStep, Array (/*'select_license',*/ 'download_license', 'select_domain')), + ); + + if ($name == 'any') { + foreach ($button_visibility as $button_name => $button_visible) { + if ($button_visible) { + return true; + } + } + + return false; + } + + return array_key_exists($name, $button_visibility) ? $button_visibility[$name] : true; + } } ?> \ No newline at end of file