public function AsyncAction(WebPage $oPage, $sCode, $aParameters) { switch ($sCode) { case 'check_path': $sPreviousVersionDir = $aParameters['previous_version_dir']; $aPreviousInstance = SetupUtils::GetPreviousInstance($sPreviousVersionDir); if ($aPreviousInstance['found']) { $sDBServer = htmlentities($aPreviousInstance['db_server'], ENT_QUOTES, 'UTF-8'); $sDBUser = htmlentities($aPreviousInstance['db_user'], ENT_QUOTES, 'UTF-8'); $sDBPwd = htmlentities($aPreviousInstance['db_pwd'], ENT_QUOTES, 'UTF-8'); $sDBName = htmlentities($aPreviousInstance['db_name'], ENT_QUOTES, 'UTF-8'); $sDBPrefix = htmlentities($aPreviousInstance['db_prefix'], ENT_QUOTES, 'UTF-8'); $oPage->add_ready_script(<<<EOF \t\$("#db_server").val('{$sDBServer}'); \t\$("#db_user").val('{$sDBUser}'); \t\$("#db_pwd").val('{$sDBPwd}'); \t\$("#db_name").val('{$sDBName}'); \t\$("#db_prefix").val('{$sDBPrefix}'); \t\$("#db_pwd").trigger('change'); // Forces check of the DB connection EOF ); } break; case 'check_db': SetupUtils::AsyncCheckDB($oPage, $aParameters); break; case 'check_backup': $sDBBackupPath = $aParameters['db_backup_path']; $fFreeSpace = SetupUtils::CheckDiskSpace($sDBBackupPath); if ($fFreeSpace !== false) { $sMessage = htmlentities(SetupUtils::HumanReadableSize($fFreeSpace) . ' free in ' . dirname($sDBBackupPath), ENT_QUOTES, 'UTF-8'); $oPage->add_ready_script(<<<EOF \t\$("#backup_info").html('{$sMessage}'); EOF ); } else { $oPage->add_ready_script(<<<EOF \t\$("#backup_info").html(''); EOF ); } break; } }
} else { $sMySqlDump = $sImgError . Dict::Format("bkp-mysqldump-issue", $iRetCode); } foreach ($aOutput as $sLine) { //echo 'Info - mysqldump -V said: '.$sLine; } $oP->p($sMySqlDump); // Destination directory // // Make sure the target directory exists and is writeable $sBackupDir = APPROOT . 'data/backups/'; SetupUtils::builddir($sBackupDir); if (!is_dir($sBackupDir)) { $oP->p($sImgError . Dict::Format('bkp-missing-dir', $sBackupDir)); } else { $oP->p(Dict::Format('bkp-free-disk-space', SetupUtils::HumanReadableSize(SetupUtils::CheckDiskSpace($sBackupDir)), $sBackupDir)); if (!is_writable($sBackupDir)) { $oP->p($sImgError . Dict::Format('bkp-dir-not-writeable', $sBackupDir)); } } $sBackupDirAuto = $sBackupDir . 'auto/'; SetupUtils::builddir($sBackupDirAuto); $sBackupDirManual = $sBackupDir . 'manual/'; SetupUtils::builddir($sBackupDirManual); // Wrong format // $sBackupFile = MetaModel::GetConfig()->GetModuleSetting('itop-backup', 'file_name_format', BACKUP_DEFAULT_FORMAT); $oBackup = new DBBackupScheduled(); $sZipName = $oBackup->MakeName($sBackupFile); if ($sZipName == '') { $oP->p($sImgError . Dict::Format('bkp-wrong-format-spec', $sBackupFile, BACKUP_DEFAULT_FORMAT));