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;
        }
    }
Example #2
0
     $oP->p(Dict::S('bkp-status-backups-none'));
 }
 $oP->add("</fieldset>");
 // 2nd table: list the backups made manually
 //
 $aDetails = array();
 foreach ($oBackup->ListFiles($sBackupDirManual) as $sBackupFile) {
     $sFileName = basename($sBackupFile);
     $sFilePath = 'manual/' . $sFileName;
     if (MetaModel::GetConfig()->Get('demo_mode')) {
         $sName = $sFileName;
     } else {
         $sAjax = utils::GetAbsoluteUrlModulePage('itop-backup', 'ajax.backup.php', array('operation' => 'download', 'file' => $sFilePath));
         $sName = "<a href=\"{$sAjax}\">" . $sFileName . '</a>';
     }
     $sSize = SetupUtils::HumanReadableSize(filesize($sBackupFile));
     $sConfirmRestore = addslashes(Dict::Format('bkp-confirm-restore', $sFileName));
     $sFileEscaped = addslashes($sFilePath);
     $sRestoreBtn = '<button class="restore" onclick="LaunchRestoreNow(\'' . $sFileEscaped . '\', \'' . $sConfirmRestore . '\');" ' . $sDisableRestore . '>' . Dict::S('bkp-button-restore-now') . '</button>';
     $aDetails[] = array('file' => $sName, 'size' => $sSize, 'actions' => $sRestoreBtn);
 }
 $aConfig = array('file' => array('label' => Dict::S('bkp-table-file'), 'description' => Dict::S('bkp-table-file+')), 'size' => array('label' => Dict::S('bkp-table-size'), 'description' => Dict::S('bkp-table-size+')), 'actions' => array('label' => Dict::S('bkp-table-actions'), 'description' => Dict::S('bkp-table-actions+')));
 $oP->add("<fieldset>");
 $oP->add("<legend>" . Dict::S('bkp-status-backups-manual') . "</legend>");
 if (count($aDetails) > 0) {
     $oP->add('<div style="max-height:400px; overflow: auto;">');
     $oP->table($aConfig, array_reverse($aDetails));
     $oP->add('</div>');
 } else {
     $oP->p(Dict::S('bkp-status-backups-none'));
 }