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 function testCopyToExistingDir() { $orig = $this->getPath('orig2'); $copy = $this->getPath('copy2'); // dir1 only in /orig rex_dir::create($orig . '/dir1'); // dir2 only in /copy rex_dir::create($copy . '/dir2'); // file1 only in /orig rex_file::put($orig . '/file1.txt', ''); rex_file::put($orig . '/dir3/file1.txt', ''); // file2 with newest version in /orig rex_file::put($copy . '/file2.txt', 'file2_old'); touch($copy . '/file2.txt', 1); rex_file::put($copy . '/dir3/file2.txt', 'file2_old'); touch($copy . '/dir3/file2.txt', 1); rex_file::put($orig . '/file2.txt', 'file2_new'); rex_file::put($orig . '/dir3/file2.txt', 'file2_new'); $this->assertTrue(rex_dir::copy($orig, $copy), 'copy() returns true on success'); $this->assertTrue(is_dir($copy . '/dir1'), 'subdir of source dir exists in destination dir'); $this->assertTrue(is_dir($copy . '/dir2'), 'existsing subdir of destination dir still exists'); $this->assertTrue(is_file($copy . '/file1.txt'), 'file of source dir exists in destination dir'); $this->assertTrue(is_file($copy . '/dir3/file1.txt'), 'existing file of destination dir still exists'); $this->assertEquals('file2_new', rex_file::get($copy . '/file2.txt'), 'existing file in destination dir will be replaced'); $this->assertEquals('file2_new', rex_file::get($copy . '/dir3/file2.txt'), 'existing file in destination dir will be replaced'); }
public static function copyDirToArchive($dir, $archive, $basename = null, $excludeDirs = null) { $dir = rtrim($dir, '/\\'); $basename = $basename ?: basename($dir); rex_dir::create(dirname($archive)); $files = array(); $iterator = rex_finder::factory($dir)->recursive()->filesOnly(); if ($excludeDirs) { $iterator->ignoreDirs($excludeDirs, false); } foreach ($iterator as $path => $file) { $subpath = str_replace($dir, $basename, $path); $subpath = str_replace('\\', '/', $subpath); $files[$subpath] = $path; } if (class_exists('ZipArchive')) { $zip = new ZipArchive(); $zip->open($archive, ZipArchive::CREATE); foreach ($files as $path => $realpath) { $zip->addFile($realpath, $path); } $zip->close(); } else { $phar = new PharData($archive, 0, null, Phar::ZIP); $phar->buildFromIterator(new ArrayIterator($files)); $phar->compressFiles(Phar::GZ); foreach ($files as $path => $realpath) { if (filesize($realpath) == 0) { $phar[$path]->decompress(); } } } }
/** * Constructor. * * @param string $path File path * @param int|null $maxFileSize Maximum file size */ public function __construct($path, $maxFileSize = null) { $this->path = $path; rex_dir::create(dirname($path)); if ($maxFileSize && file_exists($path) && filesize($path) > $maxFileSize) { rename($path, $path . '.2'); } $this->file = fopen($path, 'a+b'); }
public function doAction() { $path = rex_path::addon($this->addonkey); $temppath = rex_path::addon('.new.' . $this->addonkey); if (($msg = $this->extractArchiveTo($temppath)) !== true) { return $msg; } if ($this->addon->isAvailable() && ($msg = $this->checkRequirements()) !== true) { return $msg; } // ---- include update.php if ($this->addon->isInstalled() && file_exists($temppath . rex_package::FILE_UPDATE)) { try { $this->addon->includeFile('../.new.' . $this->addonkey . '/' . rex_package::FILE_UPDATE); } catch (rex_functional_exception $e) { return $e->getMessage(); } catch (rex_sql_exception $e) { return 'SQL error: ' . $e->getMessage(); } if (($msg = $this->addon->getProperty('updatemsg', '')) != '') { return $msg; } if (!$this->addon->getProperty('update', true)) { return rex_i18n::msg('package_no_reason'); } } // ---- backup $assets = $this->addon->getAssetsPath(); if (rex_addon::get('install')->getConfig('backups')) { $archivePath = rex_path::addonData('install', $this->addonkey . '/'); rex_dir::create($archivePath); $archive = $archivePath . strtolower(preg_replace('/[^a-z0-9-_.]/i', '_', $this->addon->getVersion('0'))) . '.zip'; rex_install_archive::copyDirToArchive($path, $archive); if (is_dir($assets)) { rex_install_archive::copyDirToArchive($assets, $archive, 'assets'); } } // ---- copy plugins to new addon dir foreach ($this->addon->getRegisteredPlugins() as $plugin) { $pluginPath = $temppath . '/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()); } } // ---- update main addon dir rex_dir::delete($path); rename($temppath, $path); // ---- update assets $origAssets = $this->addon->getPath('assets'); if ($this->addon->isInstalled() && is_dir($origAssets)) { rex_dir::copy($origAssets, $assets); } $this->addon->setProperty('version', $this->file['version']); rex_install_packages::updatedPackage($this->addonkey, $this->fileId); }
public function testCopyToDir() { $orig = $this->getPath('file.txt'); $copyDir = $this->getPath('copy'); $copyFile = $this->getPath('copy/file.txt'); $content = 'test'; rex_file::put($orig, $content); rex_dir::create($copyDir); $this->assertTrue(rex_file::copy($orig, $copyDir), 'copy() returns true on success'); $this->assertEquals($content, rex_file::get($copyFile), 'content of new file is the same as of original file'); }
public function doAction() { global $I18N, $REX; // $REX is needed for update.inc.php $path = rex_path::addon($this->addonkey); $temppath = rex_path::addon('.new.' . $this->addonkey); if (($msg = $this->extractArchiveTo($temppath)) !== true) { return $msg; } // ---- include update.php if (file_exists($temppath . 'update.inc.php')) { try { require $temppath . 'update.inc.php'; } catch (rex_install_functional_exception $e) { return $e->getMessage(); } if (($msg = OOAddon::getProperty($this->addonkey, 'updatemsg', '')) != '') { return $msg; } if (!OOAddon::getProperty($this->addonkey, 'update', true)) { return $I18N->msg('package_no_reason'); } } // ---- backup $assets = rex_path::addonAssets($this->addonkey); if (OOAddon::getProperty('install', 'backups')) { $archivePath = rex_path::addonData('install', $this->addonkey . '/'); rex_dir::create($archivePath); $archive = $archivePath . strtolower(preg_replace('/[^a-z0-9-_.]/i', '_', OOAddon::getVersion($this->addonkey))) . '.zip'; rex_install_archive::copyDirToArchive($path, $archive); if (is_dir($assets)) { rex_install_archive::copyDirToArchive($assets, $archive, 'assets'); } } // ---- copy plugins to new addon dir foreach (OOPlugin::getRegisteredPlugins($this->addonkey) as $plugin) { $pluginPath = $temppath . '/plugins/' . $plugin; if (!is_dir($pluginPath)) { rex_dir::copy(rex_path::plugin($this->addonkey, $plugin), $pluginPath); } elseif (OOPlugin::isInstalled($this->addonkey, $plugin) && is_dir($pluginPath . '/files')) { rex_dir::copy($pluginPath . '/files', rex_path::pluginAssets($this->addonkey, $plugin)); } } // ---- update main addon dir rex_dir::delete($path); rename($temppath, $path); // ---- update assets $origAssets = rex_path::addon($this->addonkey, 'assets'); if (is_dir($origAssets)) { rex_dir::copy($origAssets, $assets); } OOAddon::setProperty($this->addonkey, 'version', $this->file['version']); rex_install_packages::updatedPackage($this->addonkey, $this->fileId); }
/** * Puts content in a file * * @param string $file Path to the file * @param string $content Content for the file * @return boolean TRUE on success, FALSE on failure */ public static function put($file, $content) { global $REX; if (!rex_dir::create(dirname($file)) || file_exists($file) && !is_writable($file)) { return false; } if (file_put_contents($file, $content) !== false) { @chmod($file, $REX['FILEPERM']); return true; } return false; }
public function setUp() { parent::setUp(); rex_file::put($this->getPath('file1.txt'), ''); rex_file::put($this->getPath('file2.yml'), ''); rex_file::put($this->getPath('dir1/file3.txt'), ''); rex_file::put($this->getPath('dir2/file4.yml'), ''); rex_file::put($this->getPath('dir2/dir/file5.yml'), ''); rex_dir::create($this->getPath('dir1/dir')); rex_dir::create($this->getPath('dir2/dir1')); rex_dir::create($this->getPath('dir')); rex_file::put($this->getPath('.DS_Store'), ''); rex_file::put($this->getPath('dir1/Thumbs.db'), ''); }
/** * Writes the body to the given resource. * * @param string|resource $resource File path or file pointer * * @return bool `true` on success, `false` on failure */ public function writeBodyTo($resource) { $close = false; if (is_string($resource) && rex_dir::create(dirname($resource))) { $resource = fopen($resource, 'wb'); $close = true; } if (!is_resource($resource)) { return false; } $success = true; while ($success && ($buf = $this->getBufferedBody()) !== false) { $success = (bool) fwrite($resource, $buf); } if ($close) { fclose($resource); } return $success; }
public function extractTar() { // kills: Warnung verhindern if (is_array($this->files)) { foreach ($this->files as $item) { // jan: wenn probleme mit der ordnergenerierung -> ordner manuell einstellen if (!file_exists(dirname($item['name']))) { rex_dir::create(dirname($item['name'])); } if ($h = @fopen($item['name'], 'w+')) { fwrite($h, $item['file'], $item['size']); fclose($h); } else { $this->message[] = dirname($item['name']); return false; } } } if (count($this->message) > 0) { return false; } else { return true; } }
function enterObject() { $error = array(); $rfile = 'file_' . md5($this->getFieldName('file')); $err_msgs = $this->getElement('messages'); // min_err,max_err,type_err,empty_err if (!is_array($err_msgs)) { $err_msgs = explode(',', $err_msgs); } $err_msgs['min_error'] = $err_msgs[0]; $err_msgs['max_error'] = isset($err_msgs[1]) ? rex_i18n::translate($err_msgs[1]) : 'max_error'; $err_msgs['type_error'] = isset($err_msgs[2]) ? rex_i18n::translate($err_msgs[2]) : 'type_error'; $err_msgs['empty_error'] = isset($err_msgs[3]) ? rex_i18n::translate($err_msgs[3]) : 'empty_error'; $err_msgs['delete_file'] = isset($err_msgs[4]) ? rex_i18n::translate($err_msgs[4]) : 'delete '; $this->tmp_messages = $err_msgs; $value = $this->getValue(); if ($value == "") { $value = $this->getElement('default_file'); } $this->setValue(''); $value_email = ''; $value_sql = ''; if (!is_string($value) && $value["delete"] == 1) { $value = ''; } // SIZE CHECK $sizes = explode(',', $this->getElement('max_size')); $minsize = count($sizes) > 1 ? (int) ($sizes[0] * 1024) : 0; $maxsize = count($sizes) > 1 ? (int) ($sizes[1] * 1024) : (int) ($sizes[0] * 1024); if ($this->params['send'] && isset($_FILES[$rfile]) && $_FILES[$rfile]['name'] != '' && ($_FILES[$rfile]['size'] > $maxsize || $_FILES[$rfile]['size'] < $minsize)) { if ($_FILES[$rfile]['size'] < $minsize) { $error[] = $err_msgs['min_error']; } if ($_FILES[$rfile]['size'] > $maxsize) { $error[] = $err_msgs['max_error']; } unset($_FILES[$rfile]); } $database_filename_field = $this->getElement('database_filename_field'); if ($database_filename_field != "") { $value = $this->params['value_pool']['sql'][$database_filename_field]; } $prefix = md5(mt_rand() . microtime(true)) . '_'; if ($this->getElement('file_prefix')) { $prefix .= $this->getElement('file_prefix') . '_'; } $upload_folder = $this->getElement('upload_folder'); if ($upload_folder == "") { $upload_folder = rex_path::addonData('yform', 'uploads'); rex_dir::create($upload_folder); } if ($value != "") { if ($REX["REDAXO"]) { $value = explode("_", $value, 2); $value = $value[0]; } $search_path = $upload_folder . '/' . $value . '_' . $this->getElement('file_prefix'); $files = glob(preg_replace('/(\\*|\\?|\\[)/', '[$1]', $search_path) . '*'); if (count($files) == 1) { $value = basename($files[0]); if (rex_request("rex_upload_downloadfile") == $value) { $file = $upload_folder . '/' . $value; if (file_exists($file)) { ob_end_clean(); $filename = explode("_", basename($file), 2); $filename = $filename[1]; header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . $filename); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); readfile($file); exit; } } } else { $value = ""; } } if ($this->params['send']) { if (isset($_FILES[$rfile]) && $_FILES[$rfile]['name'] != '') { $FILE['size'] = $_FILES[$rfile]['size']; $FILE['name'] = $_FILES[$rfile]['name']; $FILE['type'] = $_FILES[$rfile]['type']; $FILE['tmp_name'] = $_FILES[$rfile]['tmp_name']; $FILE['error'] = $_FILES[$rfile]['error']; $FILE['name_normed'] = strtolower(preg_replace('/[^a-zA-Z0-9.\\-\\$\\+]/', '_', $FILE['name'])); $extensions_array = explode(',', $this->getElement('types')); $ext = '.' . pathinfo($FILE['name'], PATHINFO_EXTENSION); if (!in_array(strtolower($ext), $extensions_array) && !in_array(strtoupper($ext), $extensions_array)) { $error[] = $err_msgs['type_error']; $value = ''; } else { $file_normed = $FILE['name_normed']; $file_normed_new = $prefix . $file_normed; if (file_exists($upload_folder . '/' . $file_normed_new)) { for ($cf = 1; $cf < 1000; $cf++) { $file_normed_new = $prefix . $cf . '_' . $file_normed; if (!file_exists($upload_folder . '/' . $file_normed_new)) { break; } } } $value = $file_normed_new; if (!@move_uploaded_file($FILE['tmp_name'], $upload_folder . '/' . $file_normed_new)) { if (!@copy($FILE['tmp_name'], $upload_folder . '/' . $file_normed_new)) { $error[] = 'upload failed: destination folder problem'; $value = ''; } else { @chmod($upload_folder . '/' . $file_normed_new, $REX['FILEPERM']); } } else { @chmod($upload_folder . '/' . $file_normed_new, $REX['FILEPERM']); } } } } if (count($error) == 0) { switch ($this->getElement('modus')) { case 'database': if ($database_filename_field != "") { $this->params['value_pool']['email'][$database_filename_field] = $value; // $FILE['name_normed']; $this->params['value_pool']['sql'][$database_filename_field] = $value; // $FILE['name_normed']; } $value_email = file_get_contents($upload_folder . '/' . $value); $value_sql = $value_email; break; case 'upload': default: $value_email = $value; $value_sql = $value_email; break; } } $this->setValue($value); $this->params['value_pool']['email'][$this->getName()] = $value_email; $this->params['value_pool']['sql'][$this->getName()] = $value_sql; ## check for required file if ($this->params['send'] && $this->getElement('required') == 1 && $this->getValue() == '') { $error[] = $err_msgs['empty_error']; } ## setting up error Message if ($this->params['send'] && count($error) > 0) { $this->params['warning'][$this->getId()] = $this->params['error_class']; $this->params['warning_messages'][$this->getId()] = implode(', ', $error); } $this->params['form_output'][$this->getId()] = $this->parse('value.upload.tpl.php'); }
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; }
<?php if (rex_string::versionCompare(rex::getVersion(), '5.0.0-beta1', '<=')) { rex_extension::register('RESPONSE_SHUTDOWN', function () { rex_file::delete(rex_path::assets('jquery.min.js')); rex_file::delete(rex_path::assets('jquery.min.map')); rex_file::delete(rex_path::assets('jquery-pjax.min.js')); rex_file::delete(rex_path::assets('jquery-ui.custom.min.js')); rex_file::delete(rex_path::assets('jquery-ui.custom.txt')); rex_file::delete(rex_path::assets('redaxo-logo.svg')); rex_file::delete(rex_path::assets('sha1.js')); rex_file::delete(rex_path::assets('standard.js')); }); rex_dir::copy(__DIR__ . '/assets', rex_path::assets('core')); rex_dir::create(rex_path::data('core')); rename(rex_path::data('config.yml'), rex_path::data('core/config.yml')); }
public static function getDir() { $dir = rex_path::addonData('backup'); rex_dir::create($dir); return $dir; }
/** * Copies a file. * * @param string $srcfile Path of the source file * @param string $dstfile Path of the destination file or directory * * @return bool TRUE on success, FALSE on failure */ public static function copy($srcfile, $dstfile) { if (is_file($srcfile)) { if (is_dir($dstfile)) { $dstdir = rtrim($dstfile, DIRECTORY_SEPARATOR); $dstfile = $dstdir . DIRECTORY_SEPARATOR . basename($srcfile); } else { $dstdir = dirname($dstfile); rex_dir::create($dstdir); } if (rex_dir::isWritable($dstdir) && (!file_exists($dstfile) || is_writable($dstfile)) && copy($srcfile, $dstfile)) { touch($dstfile, filemtime($srcfile)); @chmod($dstfile, rex::getFilePerm()); return true; } } return false; }
/** * initilizes the rex_config class. */ protected static function init() { if (self::$initialized) { return; } define('REX_CONFIG_FILE_CACHE', rex_path::coreCache('config.cache')); // take care, so we are able to write a cache file on shutdown // (check here, since exceptions in shutdown functions are not visible to the user) $dir = dirname(REX_CONFIG_FILE_CACHE); rex_dir::create($dir); if (!is_writable($dir)) { throw new rex_exception('rex-config: cache dir "' . dirname(REX_CONFIG_FILE_CACHE) . '" is not writable!'); } // save cache on shutdown register_shutdown_function([__CLASS__, 'save']); self::load(); self::$initialized = true; }