oWizard); $sRootUrl = utils::GetAbsoluteUrlAppRoot(true); $aSelectedModules = json_decode($this->oWizard->GetParameter('selected_modules'), true); foreach ($aSelectedModules as $sModuleId) { if (!empty($aAvailableModules[$sModuleId]['doc.manual_setup'])) { $sUrl = $aAvailableModules[$sModuleId]['doc.manual_setup']; $sManualStepUrl = utils::IsURL($sUrl) ? $sUrl : $sRootUrl.$sUrl; $aManualSteps[$aAvailableModules[$sModuleId]['label']] = $sManualStepUrl; } } $oPage->add('
'); if (count($aManualSteps) > 0) { $oPage->add("

Manual operations required

"); $oPage->p("In order to complete the installation, the following manual operations are required:"); foreach ($aManualSteps as $sModuleLabel => $sUrl) { $oPage->p("Manual instructions for $sModuleLabel"); } $oPage->add("

Congratulations for installing ".ITOP_APPLICATION."

"); } else { $oPage->add("

Congratulations for installing ".ITOP_APPLICATION."

"); $oPage->ok("The installation completed successfully."); } $bHasBackup = false; if (($this->oWizard->GetParameter('mode', '') == 'upgrade') && $this->oWizard->GetParameter('db_backup', false) && $this->oWizard->GetParameter('authent', false)) { $sBackupDestination = $this->oWizard->GetParameter('db_backup_path', ''); if (file_exists($sBackupDestination.'.tar.gz')) { $bHasBackup = true; // To mitigate security risks: pass only the filename without the extension, the download will add the extension itself $oPage->p('Your backup is ready'); $oPage->p(' Download '.basename($sBackupDestination).''); } else { $oPage->p(' Warning: Backup creation failed !'); } } // Form goes here.. No back button since the job is done ! $oPage->add('
'); $oPage->add("
".file_get_contents(APPROOT.'images/illustrations/undraw_newsletter.svg')." Register now
"); $oPage->add("
".file_get_contents(APPROOT.'images/illustrations/undraw_active_support.svg')."Get professional support
"); $oPage->add("
".file_get_contents(APPROOT.'images/illustrations/undraw_education.svg')."Get professional training
"); $oPage->add('
'); $oPage->add('
'); $oConfig = new Config(utils::GetConfigFilePath()); $aParamValues = $this->oWizard->GetParamForConfigArray(); $oConfig->UpdateFromParams($aParamValues); // Load the data model only, in order to load env-production/core/main.php to get the XML parameters (needed by GetModuleSettings below) // But main.php may also contain classes (defined without any module), and thus requiring the full data model // to be loaded to prevent "class not found" errors... $oProductionEnv = new RunTimeEnvironment('production'); $oProductionEnv->InitDataModel($oConfig, true); $sIframeUrl = $oConfig->GetModuleSetting('itop-hub-connector', 'setup_url', ''); $sSetupTokenFile = APPROOT.'data/.setup'; $sSetupToken = bin2hex(random_bytes(12)); file_put_contents($sSetupTokenFile, $sSetupToken); $sIframeUrl .= "&setup_token=$sSetupToken"; if ($sIframeUrl != '') { $oPage->add(''); $oPage->add_script(" window.addEventListener('message', function(event) { if (event.data === 'itophub_load_completed') { $('#placeholder').hide(); $('#fresh_content').show(); } }, false); "); } $sForm = '
'; $sForm .= ''; $sForm .= ''; $sForm .= "
"; $sForm .= ''; $sForm = addslashes($sForm); $oPage->add_ready_script("$('#wiz_form').append('$sForm');"); // avoid leaving in a dirty state SetupUtils::ExitMaintenanceMode(false); SetupUtils::ExitReadOnlyMode(false); if (false === $bHasBackup) { SetupUtils::EraseSetupToken(); } } public function CanMoveForward() { return false; } public function CanMoveBackward() { return false; } /** * Tells whether this step of the wizard requires that the configuration file be writable * @return bool True if the wizard will possibly need to modify the configuration at some point */ public function RequiresWritableConfig() { return false; //This step executes once the config was written and secured } public function AsyncAction(WebPage $oPage, $sCode, $aParameters) { SetupUtils::EraseSetupToken(); // For security reasons: add the extension now so that this action can be used to read *only* .tar.gz files from the disk... $sBackupFile = $aParameters['backup'].'.tar.gz'; if (file_exists($sBackupFile)) { // Make sure there is NO output at all before our content, otherwise the document will be corrupted $sPreviousContent = ob_get_clean(); $oPage->SetContentType('application/gzip'); $oPage->SetContentDisposition('attachment', basename($sBackupFile)); $oPage->add(file_get_contents($sBackupFile)); } } }