Exemple #1
0
    $database = $app->container->get('install.database');
    if (!$database->setDatabase()) {
        throw new \Exception($database->getError());
    }
    $pdo = $database->getDatabase();
    $license = new \Shopware\Recovery\Install\License($pdo);
    return $license;
});
$app->config('install.configuration', new \Shopware\Recovery\Install\Configuration());
$app->config('install.requirements', new \Shopware\Recovery\Install\Requirements(__DIR__ . '/../data/System.xml'));
$app->config('install.requirementsPath', new \Shopware\Recovery\Install\RequirementsPath(SW_PATH, __DIR__ . '/../data/Path.xml'));
$app->config('install.language', $selectedLanguage);
// Set global variables
$app->view()->setData("selectedLanguage", $selectedLanguage);
$app->view()->setData("language", $language);
$app->view()->setData("baseUrl", Utils::getBaseUrl($app));
$app->view()->setData("app", $app);
$app->view()->setData("error", false);
$app->view()->setData("parameters", $_SESSION["parameters"]);
$app->error(function (Exception $e) use($app) {
    if (!$app->request()->isAjax()) {
        throw $e;
    }
    $response = $app->response();
    $data = array('code' => $e->getCode(), 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => $e->getTraceAsString());
    $response['Content-Type'] = 'application/json';
    $response->body(json_encode($data));
});
// Step 1: Select language
$app->map('/', function () use($app) {
    $app->render("/step1.php", array());
 public function checkRequirements()
 {
     $paths = Utils::getPaths(SW_PATH . "/engine/Shopware/Components/Check/Data/Path.xml");
     clearstatcache();
     $systemCheckPathResults = Utils::checkPaths($paths, SW_PATH);
     foreach ($systemCheckPathResults as $value) {
         if (!$value['result']) {
             $fileName = SW_PATH . '/' . $value['name'];
             @mkdir($fileName, 0777, true);
             @chmod($fileName, 0777);
         }
     }
     clearstatcache();
     $systemCheckPathResults = Utils::checkPaths($paths, SW_PATH);
     $hasErrors = false;
     foreach ($systemCheckPathResults as $value) {
         if (!$value['result']) {
             $hasErrors = true;
         }
     }
     $directoriesToDelete = ['engine/Library/Mpdf/tmp' => false, 'engine/Library/Mpdf/ttfontdata' => false];
     CommonUtils::clearOpcodeCache();
     $results = [];
     foreach ($directoriesToDelete as $directory => $deleteDirecory) {
         $result = true;
         $filePath = SW_PATH . '/' . $directory;
         Utils::deleteDir($filePath, $deleteDirecory);
         if ($deleteDirecory && is_dir($filePath)) {
             $result = false;
             $hasErrors = true;
         }
         if ($deleteDirecory) {
             $results[$directory] = $result;
         }
     }
     if (!$hasErrors && $this->app->request()->get("force") !== "1") {
         // No errors, skip page except if force parameter is set
         $this->app->redirect($this->app->urlFor("dbmigration"));
     }
     $isSkippableCheck = $this->app->config('skippable.check');
     if ($isSkippableCheck && $this->app->request()->get("force") !== "1") {
         // No errors, skip page except if force parameter is set
         $this->app->redirect($this->app->urlFor("dbmigration"));
     }
     $this->app->render('checks.php', ['systemCheckResultsWritePermissions' => $systemCheckPathResults, 'filesToDelete' => $results, 'error' => $hasErrors]);
 }
Exemple #3
0
prefixSessionVars($app);
$selectedLanguage = selectLanguage();
$translations = (require __DIR__ . "/../data/lang/{$selectedLanguage}.php");
$container->offsetSet('translations', $translations);
/** @var $translationService TranslationService */
$translationService = $container->offsetGet('translation.service');
$container->offsetSet('install.language', $selectedLanguage);
/** @var $helper MenuHelper */
$menuHelper = $container->offsetGet('menu.helper');
// Set global variables
$app->view()->setData('version', $container->offsetGet('shopware.version'));
$app->view()->setData('t', $translationService);
$app->view()->setData('menuHelper', $menuHelper);
$app->view()->setData('selectedLanguage', $selectedLanguage);
$app->view()->setData('translations', $translations);
$app->view()->setData('baseUrl', Utils::getBaseUrl($app));
$app->view()->setData('app', $app);
$app->view()->setData('error', false);
$app->view()->setData('parameters', $_SESSION["parameters"]);
$app->error(function (\Exception $e) use($app) {
    if (!$app->request()->isAjax()) {
        throw $e;
    }
    $response = $app->response();
    $data = ['code' => $e->getCode(), 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => $e->getTraceAsString()];
    $response->header('Content-Type', 'application/json');
    $response->body(json_encode($data));
});
$app->map('/', function () use($app, $container, $menuHelper) {
    $menuHelper->setCurrent('language-selection');
    $app->view()->set('languages', ['de', 'en', 'nl']);
Exemple #4
0
 * "Shopware" is a registered trademark of shopware AG.
 * The licensing of the program under the AGPLv3 does not imply a
 * trademark license. Therefore any rights, title and interest in
 * our trademarks remain entirely with us.
 */
use Shopware\Recovery\Update\DependencyInjection\Container;
use Shopware\Recovery\Update\Utils;
date_default_timezone_set('Europe/Berlin');
ini_set('display_errors', 1);
error_reporting(-1);
$config = (require __DIR__ . '/../config/config.php');
$container = new Container(new Pimple(), $config);
/** @var \Slim\Slim $app */
$app = $container->get('app');
$app->hook('slim.before.dispatch', function () use($app, $container) {
    $baseUrl = \Shopware\Recovery\Common\Utils::getBaseUrl($app);
    $lang = null;
    if (!UPDATE_IS_MANUAL) {
        if (!is_file(UPDATE_META_FILE)) {
            $shopPath = str_replace('/recovery/update', '/', $app->request()->getRootUri());
            $app->response()->redirect($shopPath);
            $app->response()->status(302);
            $app->stop();
        }
        $file = file_get_contents(UPDATE_META_FILE);
        $updateConfig = json_decode($file, true);
        $container->setParameter('update.config', $updateConfig);
        $lang = substr($updateConfig['locale'], 0, 2);
    }
    session_set_cookie_params(7200, $baseUrl);
    //Silence errors during session start, Work around session_start(): ps_files_cleanup_dir: opendir(/var/lib/php5) failed: Permission denied (13)
 /**
  * @throws \RuntimeException
  */
 public function unpack()
 {
     // Manual updates do not contain files to overwrite
     if (UPDATE_IS_MANUAL) {
         Utils::clearOpcodeCache();
         $this->toJson(200, $this->resultMapper->toExtJs(new FinishResult(0, 0)));
         return;
     }
     $offset = $this->request->get('offset');
     $total = $this->request->get('total');
     /** @var FilesystemFactory $factory */
     $factory = $this->container->get('filesystem.factory');
     $localFilesystem = $factory->createLocalFilesystem();
     $remoteFilesystem = $factory->createRemoteFilesystem();
     if ($offset == 0) {
         $this->validateFilesytems($localFilesystem, $remoteFilesystem);
     }
     /** @var PathBuilder $pathBuilder */
     $pathBuilder = $this->container->get('path.builder');
     $debug = false;
     $step = new UnpackStep($localFilesystem, $remoteFilesystem, $pathBuilder, $debug);
     $result = $step->run($offset, $total);
     if ($result instanceof ValidResult) {
         Utils::clearOpcodeCache();
     }
     $this->toJson(200, $this->resultMapper->toExtJs($result));
 }