private function createArchives() { $path = rex_path::base('releases/' . $this->version . '/'); if (file_exists($path)) { rex_dir::deleteFiles($path); } rex_dir::create($path); $complete = new ZipArchive(); $update = new ZipArchive(); $complete->open($path . 'redaxo_' . $this->version . '.zip', ZipArchive::CREATE); $update->open($path . 'redaxo_update_' . $this->version . '.zip', ZipArchive::CREATE); $files = ['assets/.redaxo', 'media/.redaxo', 'redaxo/cache/.htaccess', 'redaxo/cache/.redaxo', 'redaxo/data/.htaccess', 'redaxo/data/.redaxo', 'redaxo/src/.htaccess', 'redaxo/index.php', 'index.php', 'LICENSE.md', 'README.md']; foreach ($files as $file) { $complete->addFile(rex_path::base($file), $file); } $this->addDir($complete, rex_path::core(), 'redaxo/src/core'); $this->addDir($update, rex_path::core(), 'core'); foreach (self::$addons as $addon) { $this->addDir($complete, rex_path::addon($addon), 'redaxo/src/addons/' . $addon); $this->addDir($update, rex_path::addon($addon), 'addons/' . $addon); } $this->addDir($complete, rex_path::core('assets'), 'assets'); $addon = rex_addon::get('be_style'); $this->addDir($complete, $addon->getPath('assets'), 'assets/addons/be_style'); $this->addDir($complete, $addon->getPlugin('redaxo')->getPath('assets'), 'assets/addons/be_style/plugins/redaxo'); $files = (require $addon->getPath('vendor_files.php')); foreach ($files as $source => $destination) { $complete->addFile($addon->getPath($source), 'assets/addons/be_style/' . $destination); } $complete->close(); $update->close(); }
public static function defaultLocator() { $locator = new self(); $locator->addTestFolder(rex_path::core(self::TESTS_FOLDER)); foreach (rex_package::getAvailablePackages() as $package) { $locator->addTestFolder($package->getPath(self::TESTS_FOLDER)); } return $locator; }
public static function prepareEmptyDb() { // ----- leere Datenbank neu einrichten $err_msg = ''; $import_sql = rex_path::core('install.sql'); if ($err_msg == '') { $err_msg .= self::import($import_sql); } $err_msg .= self::installAddons(); return $err_msg; }
/** * very basic setup steps, so everything is in place for our browser-based setup wizard. * * @param string $skinAddon * @param string $skinPlugin */ public static function init($skinAddon = 'be_style', $skinPlugin = 'redaxo') { // initial purge all generated files rex_delete_cache(); // delete backend session rex_backend_login::deleteSession(); // copy alle media files of the current rex-version into redaxo_media rex_dir::copy(rex_path::core('assets'), rex_path::assets()); // copy skins files/assets rex_dir::copy(rex_path::addon($skinAddon, 'assets'), rex_path::addonAssets($skinAddon)); rex_dir::copy(rex_path::plugin($skinAddon, $skinPlugin, 'assets'), rex_path::pluginAssets($skinAddon, $skinPlugin)); }
/** * Register rex_autoload in spl autoloader. */ public static function register() { if (self::$registered) { return; } ini_set('unserialize_callback_func', 'spl_autoload_call'); if (!self::$composerLoader) { self::$composerLoader = (require rex_path::core('vendor/autoload.php')); // Unregister Composer Autoloader because we call self::$composerLoader->loadClass() manually self::$composerLoader->unregister(); } if (false === spl_autoload_register([__CLASS__, 'autoload'])) { throw new Exception(sprintf('Unable to register %s::autoload as an autoloading method.', __CLASS__)); } self::$cacheFile = rex_path::cache('autoload.cache'); self::loadCache(); register_shutdown_function([__CLASS__, 'saveCache']); self::$registered = true; }
/** * very basic setup steps, so everything is in place for our browser-based setup wizard. * * @param string $skinAddon * @param string $skinPlugin */ public static function init($skinAddon = 'be_style', $skinPlugin = 'redaxo') { // initial purge all generated files rex_delete_cache(); // delete backend session rex_backend_login::deleteSession(); // copy alle media files of the current rex-version into redaxo_media rex_dir::copy(rex_path::core('assets'), rex_path::coreAssets()); // copy skins files/assets $skinAddon = rex_addon::get($skinAddon); $skinPlugin = $skinAddon->getPlugin($skinPlugin); rex_dir::copy($skinAddon->getPath('assets'), $skinAddon->getAssetsPath()); rex_dir::copy($skinPlugin->getPath('assets'), $skinPlugin->getAssetsPath()); if (is_file($skinAddon->getPath('install.php'))) { $skinAddon->includeFile('install.php'); } if (is_file($skinPlugin->getPath('install.php'))) { $skinPlugin->includeFile('install.php'); } }
if (rex_file::putConfig($configFile, $config) !== false) { $info = rex_i18n::msg('setup_error1', '<a href="' . rex_url::backendController() . '">', '</a>'); header('Location:' . rex_url::backendController()); exit; } else { $error[] = rex_i18n::msg('setup_error2'); } } elseif ($func == 'generate') { // generate all articles,cats,templates,caches $success = rex_delete_cache(); } elseif ($func == 'updateassets') { rex_dir::copy(rex_path::core('assets'), rex_path::assets()); $success = 'Updated assets'; } elseif ($func == 'updateinfos') { $configFile = rex_path::data('config.yml'); $config = array_merge(rex_file::getConfig(rex_path::core('default.config.yml')), rex_file::getConfig($configFile)); $settings = rex_post('settings', 'array', []); foreach (['server', 'servername', 'error_email', 'lang'] as $key) { if (!isset($settings[$key]) || !$settings[$key]) { $error[] = rex_i18n::msg($key . '_required'); continue; } $config[$key] = $settings[$key]; try { rex::setProperty($key, $settings[$key]); } catch (InvalidArgumentException $e) { $error[] = rex_i18n::msg($key . '_invalid'); } } $config['debug'] = isset($settings['debug']) && $settings['debug']; rex::setProperty('debug', $config['debug']);
public function execute() { if (!rex::getUser()->isAdmin()) { throw new rex_api_exception('You do not have the permission!'); } $installAddon = rex_addon::get('install'); $versions = self::getVersions(); $versionId = rex_request('version_id', 'int'); if (!isset($versions[$versionId])) { return null; } $version = $versions[$versionId]; if (!rex_string::versionCompare($version['version'], rex::getVersion(), '>')) { throw new rex_api_exception(sprintf('Existing version of Core (%s) is newer than %s', rex::getVersion(), $version['version'])); } try { $archivefile = rex_install_webservice::getArchive($version['path']); } catch (rex_functional_exception $e) { throw new rex_api_exception($e->getMessage()); } $message = ''; $temppath = rex_path::coreCache('.new.core/'); try { if ($version['checksum'] != md5_file($archivefile)) { throw new rex_functional_exception($installAddon->i18n('warning_zip_wrong_checksum')); } if (!rex_install_archive::extract($archivefile, $temppath)) { throw new rex_functional_exception($installAddon->i18n('warning_core_zip_not_extracted')); } if (!is_dir($temppath . 'core')) { throw new rex_functional_exception($installAddon->i18n('warning_zip_wrong_format')); } $coreAddons = []; /** @var rex_addon[] $updateAddons */ $updateAddons = []; if (is_dir($temppath . 'addons')) { foreach (rex_finder::factory($temppath . 'addons')->dirsOnly() as $dir) { $addonkey = $dir->getBasename(); $addonPath = $dir->getRealPath() . '/'; if (!file_exists($addonPath . rex_package::FILE_PACKAGE)) { continue; } $config = rex_file::getConfig($addonPath . rex_package::FILE_PACKAGE); if (!isset($config['version']) || rex_addon::exists($addonkey) && rex_string::versionCompare($config['version'], rex_addon::get($addonkey)->getVersion(), '<')) { continue; } $coreAddons[$addonkey] = $addonkey; if (rex_addon::exists($addonkey)) { $updateAddons[$addonkey] = rex_addon::get($addonkey); $updateAddonsConfig[$addonkey] = $config; } } } //$config = rex_file::getConfig($temppath . 'core/default.config.yml'); //foreach ($config['system_addons'] as $addonkey) { // if (is_dir($temppath . 'addons/' . $addonkey) && rex_addon::exists($addonkey)) { // $updateAddons[$addonkey] = rex_addon::get($addonkey); // } //} $this->checkRequirements($temppath, $version['version'], $updateAddonsConfig); if (file_exists($temppath . 'core/update.php')) { include $temppath . 'core/update.php'; } foreach ($updateAddons as $addonkey => $addon) { if ($addon->isInstalled() && file_exists($file = $temppath . 'addons/' . $addonkey . '/' . rex_package::FILE_UPDATE)) { try { $addon->includeFile($file); if ($msg = $addon->getProperty('updatemsg', '')) { throw new rex_functional_exception($msg); } if (!$addon->getProperty('update', true)) { throw new rex_functional_exception(rex_i18n::msg('package_no_reason')); } } catch (rex_functional_exception $e) { throw new rex_functional_exception($addonkey . ': ' . $e->getMessage(), $e); } catch (rex_sql_exception $e) { throw new rex_functional_exception($addonkey . ': SQL error: ' . $e->getMessage(), $e); } } } // create backup $installConfig = rex_file::getCache($installAddon->getDataPath('config.json')); if (isset($installConfig['backups']) && $installConfig['backups']) { rex_dir::create($installAddon->getDataPath()); $archive = $installAddon->getDataPath(strtolower(preg_replace('/[^a-z0-9-_.]/i', '_', rex::getVersion())) . '.zip'); rex_install_archive::copyDirToArchive(rex_path::core(), $archive); foreach ($updateAddons as $addonkey => $addon) { rex_install_archive::copyDirToArchive($addon->getPath(), $archive, 'addons/' . $addonkey); } } // copy plugins to new addon dirs foreach ($updateAddons as $addonkey => $addon) { foreach ($addon->getRegisteredPlugins() as $plugin) { $pluginPath = $temppath . 'addons/' . $addonkey . '/plugins/' . $plugin->getName(); if (!is_dir($pluginPath)) { rex_dir::copy($plugin->getPath(), $pluginPath); } elseif ($plugin->isInstalled() && is_dir($pluginPath . '/assets')) { rex_dir::copy($pluginPath . '/assets', $plugin->getAssetsPath()); } } } // move temp dirs to permanent destination rex_dir::delete(rex_path::core()); rename($temppath . 'core', rex_path::core()); if (is_dir(rex_path::core('assets'))) { rex_dir::copy(rex_path::core('assets'), rex_path::coreAssets()); } foreach ($coreAddons as $addonkey) { if (isset($updateAddons[$addonkey])) { rex_dir::delete(rex_path::addon($addonkey)); } rename($temppath . 'addons/' . $addonkey, rex_path::addon($addonkey)); if (is_dir(rex_path::addon($addonkey, 'assets'))) { rex_dir::copy(rex_path::addon($addonkey, 'assets'), rex_path::addonAssets($addonkey)); } } } catch (rex_functional_exception $e) { $message = $e->getMessage(); } catch (rex_sql_exception $e) { $message = 'SQL error: ' . $e->getMessage(); } rex_file::delete($archivefile); rex_dir::delete($temppath); if ($message) { $message = $installAddon->i18n('warning_core_not_updated') . '<br />' . $message; $success = false; } else { $message = $installAddon->i18n('info_core_updated'); $success = true; rex_delete_cache(); rex_install_webservice::deleteCache('core'); } $result = new rex_api_result($success, $message); if ($success) { $result->setRequiresReboot(true); } return $result; }
} rex_be_controller::setPages($pages); // ----- Prepare Core Pages if (rex::getUser()) { rex_be_controller::appendLoggedInPages(); rex_be_controller::setCurrentPage(trim(rex_request('page', 'string'))); } rex_view::addJsFile(rex_url::coreAssets('jquery.min.js')); rex_view::addJsFile(rex_url::coreAssets('jquery-ui.custom.min.js')); rex_view::addJsFile(rex_url::coreAssets('jquery-pjax.min.js')); rex_view::addJsFile(rex_url::coreAssets('standard.js')); rex_view::addJsFile(rex_url::coreAssets('sha1.js')); rex_view::setJsProperty('backend', true); rex_view::setJsProperty('accesskeys', rex::getProperty('use_accesskeys')); // ----- INCLUDE ADDONS include_once rex_path::core('packages.php'); // ----- Prepare AddOn Pages if (rex::getUser()) { rex_be_controller::appendPackagePages(); } $pages = rex_extension::registerPoint(new rex_extension_point('PAGES_PREPARED', rex_be_controller::getPages())); rex_be_controller::setPages($pages); // Set Startpage if ($user = rex::getUser()) { // --- page pruefen und benoetigte rechte checken rex_be_controller::checkPagePermissions($user); } $page = rex_be_controller::getCurrentPage(); rex_view::setJsProperty('page', $page); // ----- EXTENSION POINT // page variable validated
/** * Includes the current page. A page may be provided by the core, an addon or plugin. */ public static function includeCurrentPage() { $currentPage = self::getCurrentPageObject(); if (rex_request::isPJAXRequest() && !rex_request::isPJAXContainer('#rex-page')) { // non-core pjax containers should not have a layout. // they render their whole response on their own $currentPage->setHasLayout(false); } require rex_path::core('layout/top.php'); $path = $currentPage->getPath(); $pattern = '@' . preg_quote(rex_path::src('addons/'), '@') . '([^/\\\\]+)(?:[/\\\\]plugins[/\\\\]([^/\\\\]+))?@'; if (preg_match($pattern, $path, $matches)) { $package = rex_addon::get($matches[1]); if (isset($matches[2])) { $package = $package->getPlugin($matches[2]); } $package->includeFile(str_replace($package->getPath(), '', $path)); } else { include $path; } require rex_path::core('layout/bottom.php'); }
/** * @package redaxo5 */ // -------------- Defaults $subpage = rex_be_controller::getCurrentPagePart(2); $func = rex_request('func', 'string'); // -------------- Header if ($subpage != 'phpinfo') { echo rex_view::title(rex_i18n::msg('system')); } $file = null; switch ($subpage) { case 'lang': $file = 'system.clangs.php'; break; case 'log': $file = 'system.log.php'; break; case 'phpinfo': $file = 'system.phpinfo.php'; break; case 'settings': $file = 'system.settings.php'; break; } if ($file) { $file = rex_path::core('pages/' . $file); } else { $file = rex_be_controller::getCurrentPageObject()->getSubPath(); } require $file;
require_once rex_path::core('functions/function_rex_other.php'); // ----------------- VERSION rex::setProperty('version', '5.0.0-alpha7'); $cacheFile = rex_path::cache('config.yml.cache'); $configFile = rex_path::data('config.yml'); if (file_exists($cacheFile) && file_exists($configFile) && filemtime($cacheFile) >= filemtime($configFile)) { $config = rex_file::getCache($cacheFile); } else { $config = array_merge(rex_file::getConfig(rex_path::core('default.config.yml')), rex_file::getConfig($configFile)); rex_file::putCache($cacheFile, $config); } foreach ($config as $key => $value) { if (in_array($key, ['fileperm', 'dirperm'])) { $value = octdec($value); } rex::setProperty($key, $value); } date_default_timezone_set(rex::getProperty('timezone', 'Europe/Berlin')); if (!rex::isSetup()) { rex_error_handler::register(); } // ----------------- REX PERMS rex_complex_perm::register('clang', 'rex_clang_perm'); // ----- SET CLANG if (!rex::isSetup()) { rex_clang::setCurrentId(rex_request('clang', 'int', rex_clang::getStartId())); } if (isset($REX['LOAD_PAGE']) && $REX['LOAD_PAGE']) { unset($REX); require rex_path::core(rex::isBackend() ? 'backend.php' : 'frontend.php'); }
<?php /** * @package redaxo5 */ // -------------- Defaults $subpage = rex_be_controller::getCurrentPagePart(2); $func = rex_request('func', 'string'); // -------------- Header if ($subpage != 'phpinfo') { echo rex_view::title(rex_i18n::msg('system')); } switch ($subpage) { case 'lang': $file = 'system.clangs.php'; break; case 'log': $file = 'system.log.php'; break; case 'phpinfo': $file = 'system.phpinfo.php'; break; default: $file = 'system.settings.php'; break; } require rex_path::core('pages/' . $file);
/** * Includes the current page. A page may be provided by the core, an addon or plugin. */ public static function includeCurrentPage() { $currentPage = self::getCurrentPageObject(); if (rex_request::isPJAXRequest() && !rex_request::isPJAXContainer('#rex-js-page-container')) { // non-core pjax containers should not have a layout. // they render their whole response on their own $currentPage->setHasLayout(false); } require rex_path::core('layout/top.php'); self::includePath($currentPage->getPath()); require rex_path::core('layout/bottom.php'); }