Access denied'; dcPage::close(); exit; } $updater = new dcUpdate(DC_UPDATE_URL, 'dotclear', DC_UPDATE_VERSION, DC_TPL_CACHE . '/versions'); $new_v = $updater->check(DC_VERSION, !empty($_GET['nocache'])); $zip_file = $new_v ? DC_BACKUP_PATH . '/' . basename($updater->getFileURL()) : ''; $version_info = $new_v ? $updater->getInfoURL() : ''; # Hide "update me" message if (!empty($_GET['hide_msg'])) { $updater->setNotify(false); http::redirect('index.php'); } $p_url = 'update.php'; $step = isset($_GET['step']) ? $_GET['step'] : ''; $step = in_array($step, array('check', 'download', 'backup', 'unzip')) ? $step : ''; $default_tab = !empty($_GET['tab']) ? html::escapeHTML($_GET['tab']) : 'update'; if (!empty($_POST['backup_file'])) { $default_tab = 'files'; } $archives = array(); foreach (files::scanDir(DC_BACKUP_PATH) as $v) { if (preg_match('/backup-([0-9A-Za-z\.-]+).zip/', $v)) { $archives[] = $v; } } if (!empty($archives)) { usort($archives, "version_compare"); } else { $default_tab = 'update'; } # Revert or delete backup file if (!empty($_POST['backup_file']) && in_array($_POST['backup_file'], $archives)) { $b_file = $_POST['backup_file']; try { if (!empty($_POST['b_del'])) { if (!@unlink(DC_BACKUP_PATH . '/' . $b_file)) { throw new Exception(sprintf(__('Unable to delete file %s'), html::escapeHTML($b_file))); } http::redirect($p_url . '?tab=files'); } if (!empty($_POST['b_revert'])) { $zip = new fileUnzip(DC_BACKUP_PATH . '/' . $b_file); $zip->unzipAll(DC_BACKUP_PATH . '/'); @unlink(DC_BACKUP_PATH . '/' . $b_file); http::redirect($p_url . '?tab=files'); } } catch (Exception $e) { $core->error->add($e->getMessage()); } } # Upgrade process if ($new_v && $step) { try { $updater->setForcedFiles('inc/digests'); switch ($step) { case 'check': $updater->checkIntegrity(DC_ROOT . '/inc/digests', DC_ROOT); http::redirect($p_url . '?step=download'); break; case 'download': $updater->download($zip_file); if (!$updater->checkDownload($zip_file)) { throw new Exception( sprintf(__('Downloaded Dotclear archive seems to be corrupted. ' . 'Try download it again.'), 'href="' . $p_url . '?step=download"') . ' ' . __('If this problem persists try to ' . 'update manually.') ); } http::redirect($p_url . '?step=backup'); break; case 'backup': $updater->backup( $zip_file, 'dotclear/inc/digests', DC_ROOT, DC_ROOT . '/inc/digests', DC_BACKUP_PATH . '/backup-' . DC_VERSION . '.zip' ); http::redirect($p_url . '?step=unzip'); break; case 'unzip': $updater->performUpgrade( $zip_file, 'dotclear/inc/digests', 'dotclear', DC_ROOT, DC_ROOT . '/inc/digests' ); break; } } catch (Exception $e) { $msg = $e->getMessage(); if ($e->getCode() == dcUpdate::ERR_FILES_CHANGED) { $msg = __('The following files of your Dotclear installation ' . 'have been modified so we won\'t try to update your installation. ' . 'Please try to update manually.'); } elseif ($e->getCode() == dcUpdate::ERR_FILES_UNREADABLE) { $msg = sprintf(__('The following files of your Dotclear installation are not readable. ' . 'Please fix this or try to make a backup file named %s manually.'), 'backup-' . DC_VERSION . '.zip'); } elseif ($e->getCode() == dcUpdate::ERR_FILES_UNWRITALBE) { $msg = __('The following files of your Dotclear installation cannot be written. ' . 'Please fix this or try to update manually.'); } if (isset($e->bad_files)) { $msg .= '
' . __('No newer Dotclear version available.') . '
' . ''; } else { echo '' . sprintf(__('Dotclear %s is available.'), $new_v) .
($version_info ? ' (' .
__('Information about this version') . ') ' : '') .
'
' . sprintf(__('PHP version is %s (%s or earlier needed).'), phpversion(), $updater->getPHPVersion()) . '
'; } else { echo '' . __('To upgrade your Dotclear installation simply click on the following button. ' . 'A backup file of your current installation will be created in your root directory.') . '
' . ''; } } echo '' . __('The following files are backups of previously updates. ' . 'You can revert your previous installation or delete theses files.') . '
'; echo ''; echo '