Пример #1
0
 private function updateVersion()
 {
     $file = rex_path::core('boot.php');
     $content = rex_file::get($file);
     $content = preg_replace('/(?<=^rex::setProperty\\(\'version\', \').*?(?=\')/m', $this->version, $content);
     rex_file::put($file, $content);
 }
Пример #2
0
function focus_setup_metainfo()
{
    global $REX;
    if (!isset($REX['USER'])) {
        return;
    }
    $install_metas = array('med_focuspoint_data' => array('Focuspoint Data', 'med_focuspoint_data', 200, '', 1, '', '', '', ''), 'med_focuspoint_css' => array('Focuspoint CSS', 'med_focuspoint_css', 201, '', 1, '', '', '', ''));
    $db = new rex_sql();
    foreach ($db->getDbArray('SHOW COLUMNS FROM `rex_file` LIKE \'med_focuspoint_%\';') as $column) {
        unset($install_metas[$column['Field']]);
    }
    foreach ($install_metas as $k => $v) {
        $db->setQuery('SELECT `name` FROM `rex_62_params` WHERE `name`=\'' . $k . '\';');
        if ($db->getRows() > 0) {
            // FIELD KNOWN TO METAINFO BUT MISSING IN ARTICLE..
            $db->setQuery('ALTER TABLE `rex_file` ADD `' . $k . '` TEXT NOT NULL;');
            if ($REX['REDAXO']) {
                echo rex_info('Metainfo Feld ' . $k . ' wurde repariert.');
            }
        } else {
            if (!function_exists('a62_add_field')) {
                require_once $REX['INCLUDE_PATH'] . '/addons/metainfo/functions/function_metainfo.inc.php';
            }
            a62_add_field($v[0], $v[1], $v[2], $v[3], $v[4], $v[5], $v[6], $v[7], $v[8]);
            if ($REX['REDAXO']) {
                echo rex_info('Metainfo Feld ' . $k . ' wurde angelegt.');
            }
        }
    }
    rex_file::copy(rex_path::addon("focuspoint", "classes/class.rex_effect_focuspoint_resize.inc.php"), rex_path::addon("image_manager", "classes/effects/class.rex_effect_focuspoint_resize.inc.php"));
}
Пример #3
0
 /**
  * Prepares a new stream.
  *
  * @param string $path    Virtual path which should describe the content (e.g. "template/1"), only relevant for error messages
  * @param string $content Content which will be included
  *
  * @throws InvalidArgumentException
  *
  * @return string Full path with protocol (e.g. "rex:///template/1")
  */
 public static function factory($path, $content)
 {
     if (!is_string($path) || empty($path)) {
         throw new InvalidArgumentException('Expecting $path to be a string and not empty!');
     }
     if (!is_string($content)) {
         throw new InvalidArgumentException('Expecting $content to be a string!');
     }
     if (null === self::$useRealFiles) {
         self::$useRealFiles = extension_loaded('suhosin') && !preg_match('/(?:^|,)rex(?::|,|$)/', ini_get('suhosin.executor.include.whitelist'));
     }
     if (self::$useRealFiles) {
         $hash = substr(sha1($content), 0, 7);
         $path = rex_path::coreCache('stream/' . $path . '/' . $hash);
         if (!file_exists($path)) {
             rex_file::put($path, $content);
         }
         return $path;
     }
     if (!self::$registered) {
         stream_wrapper_register('rex', __CLASS__);
         self::$registered = true;
     }
     // 3 slashes needed to sidestep some server url include protections
     // example: https://www.strato.de/faq/article/622/Warum-erhalte-ich-über-PHP-die-Fehlermeldung-%22Warning:-main()-…:-include(….).html
     $path = 'rex:///' . $path;
     self::$nextContent[$path] = $content;
     return $path;
 }
Пример #4
0
 public function execute()
 {
     global $I18N;
     $addonkey = rex_request('addonkey', 'string');
     $upload = rex_request('upload', array(array('upload_file', 'bool'), array('oldversion', 'string'), array('redaxo', 'array[string]'), array('description', 'string'), array('status', 'int'), array('replace_assets', 'bool'), array('ignore_tests', 'bool')));
     $file = array();
     $archive = null;
     $file['version'] = $upload['upload_file'] ? OOAddon::getVersion($addonkey) : $upload['oldversion'];
     $file['redaxo_versions'] = $upload['redaxo'];
     $file['description'] = stripslashes($upload['description']);
     $file['status'] = $upload['status'];
     if ($upload['upload_file']) {
         $archive = rex_path::addonCache('install', md5($addonkey . time()) . '.zip');
         $exclude = array();
         if ($upload['replace_assets']) {
             $exclude[] = 'files';
         }
         if ($upload['ignore_tests']) {
             $exclude[] = 'tests';
         }
         rex_install_archive::copyDirToArchive(rex_path::addon($addonkey), $archive, null, $exclude);
         if ($upload['replace_assets']) {
             rex_install_archive::copyDirToArchive(rex_path::addonAssets($addonkey), $archive, $addonkey . '/files');
         }
         $file['checksum'] = md5_file($archive);
     }
     rex_install_webservice::post(rex_install_packages::getPath('?package=' . $addonkey . '&file_id=' . rex_request('file', 'int', 0)), array('file' => $file), $archive);
     if ($archive) {
         rex_file::delete($archive);
     }
     unset($_REQUEST['addonkey']);
     unset($_REQUEST['file']);
     rex_install_packages::deleteCache();
     return $I18N->msg('install_info_addon_uploaded', $addonkey);
 }
Пример #5
0
 /**
  * Prepares a new stream.
  *
  * @param string $path    Virtual path which should describe the content (e.g. "template/1"), only relevant for error messages
  * @param string $content Content which will be included
  *
  * @throws InvalidArgumentException
  *
  * @return string Full path with protocol (e.g. "rex://template/1")
  */
 public static function factory($path, $content)
 {
     if (!is_string($path) || empty($path)) {
         throw new InvalidArgumentException('Expecting $path to be a string and not empty!');
     }
     if (!is_string($content)) {
         throw new InvalidArgumentException('Expecting $content to be a string!');
     }
     if (null === self::$useRealFiles) {
         self::$useRealFiles = extension_loaded('suhosin') && !preg_match('/(?:^|,)rex(?::|,|$)/', ini_get('suhosin.executor.include.whitelist'));
     }
     if (self::$useRealFiles) {
         $hash = substr(sha1($content), 0, 7);
         $path = rex_path::coreCache('stream/' . $path . '/' . $hash);
         if (!file_exists($path)) {
             rex_file::put($path, $content);
         }
         return $path;
     }
     if (!self::$registered) {
         stream_wrapper_register('rex', __CLASS__);
         self::$registered = true;
     }
     $path = 'rex://' . $path;
     self::$nextContent[$path] = $content;
     return $path;
 }
 static function replaceVars($template, $er = array())
 {
     $r = rex_extension::registerPoint(new rex_extension_point('YFORM_EMAIL_BEFORE_REPLACEVARS', ['template' => $template, 'search_replace' => $er, 'status' => false]));
     $template = $r['template'];
     $er = $r['search_replace'];
     $status = $r['status'];
     if ($status) {
         return true;
     }
     $er['REX_SERVER'] = rex::getServer();
     $er['REX_ERROR_EMAIL'] = rex::getErrorEmail();
     $er['REX_SERVERNAME'] = rex::getServerName();
     $er['REX_NOTFOUND_ARTICLE_ID'] = rex_article::getNotfoundArticleId();
     $er['REX_ARTICLE_ID'] = rex_article::getCurrentId();
     $template['body'] = rex_var::parse($template['body'], '', 'yform_email_template', $er);
     $template['body_html'] = rex_var::parse($template['body_html'], '', 'yform_email_template', $er);
     // rex_vars bug: sonst wird der Zeilenumbruch entfernt - wenn DATA_VAR am Ende einer Zeile
     if (rex_string::versionCompare(rex::getVersion(), '5.0.1', '<')) {
         $template['body'] = str_replace("?>\r", "?>\r\n\r", $template['body']);
         $template['body'] = str_replace("?>\n", "?>\n\r\n", $template['body']);
         $template['body_html'] = str_replace("?>\r", "?>\r\n\r", $template['body_html']);
         $template['body_html'] = str_replace("?>\n", "?>\n\r\n", $template['body_html']);
     }
     $template['body'] = rex_file::getOutput(rex_stream::factory('yform/email/template/' . $template['name'] . '/body', $template['body']));
     $template['body_html'] = rex_file::getOutput(rex_stream::factory('yform/email/template/' . $template['name'] . '/body_html', $template['body_html']));
     return $template;
 }
Пример #7
0
 public function deleteCache()
 {
     if ($this->id < 1) {
         return false;
     }
     $file = $this->getFilePath($this->getId());
     rex_file::delete($file);
     return true;
 }
Пример #8
0
 /**
  * Compile a fragment.
  *
  * @param string $value
  */
 public function compile($file)
 {
     if ($this->isExpired($file)) {
         $content = rex_file::get($file);
         if (rex_file::put($this->getCompiledFile($file), $this->compileString($content)) === false) {
             throw new rex_exception('Unable to generate fragment ' . $file . '!');
         }
     }
     return $this->getCompiledFile($file);
 }
Пример #9
0
 public function testDelete()
 {
     $path = $this->getPath('delete.log');
     $path2 = $path . '.2';
     rex_file::put($path, '');
     rex_file::put($path2, '');
     rex_log_file::delete($path);
     $this->assertFileNotExists($path);
     $this->assertFileNotExists($path2);
 }
Пример #10
0
 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'), '');
 }
Пример #11
0
 private function backup()
 {
     $content = '<!-- ' . PHP_EOL . date('d.m.Y H:i:s') . PHP_EOL;
     $content .= 'From : ' . $this->From . PHP_EOL;
     $content .= 'To : ' . implode(', ', array_column($this->getToAddresses(), 0)) . PHP_EOL;
     $content .= 'Subject : ' . $this->Subject . PHP_EOL;
     $content .= ' -->' . PHP_EOL;
     $content .= $this->Body;
     $dir = rex_path::addonData('phpmailer', 'mail_backup/' . date('Y') . '/' . date('m'));
     $count = 1;
     $backupFile = $dir . '/' . date('Y-m-d_H_i_s') . '.html';
     while (file_exists($backupFile)) {
         $backupFile = $dir . '/' . date('Y-m-d_H_i_s') . '_' . ++$count . '.html';
     }
     rex_file::put($backupFile, $content);
 }
Пример #12
0
 public function execute()
 {
     // error_reporting(E_ALL);ini_set("display_errors",1);
     if (!isset(self::$convert_to[$this->params['convert_to']])) {
         $convert_to = self::$convert_to[self::$convert_to_default];
     } else {
         $convert_to = self::$convert_to[$this->params['convert_to']];
     }
     $density = (int) $this->params['density'];
     if (!in_array($density, self::$densities)) {
         $density = self::$density_default;
     }
     $from_path = realpath($this->media->getMediapath());
     $ext = rex_file::extension($from_path);
     if (!$ext) {
         return;
     }
     if (!in_array(strtolower($ext), self::$convert_types)) {
         return;
     }
     $convert_path = self::getConvertPath();
     if ($convert_path == '') {
         return;
     }
     $filename = $this->media->getMediaFilename();
     $filename_wo_ext = substr($filename, 0, strlen($filename) - strlen($ext));
     $to_path = rex_path::addonCache('media_manager', 'media_manager__convert2img_' . md5($this->media->getMediapath()) . '_' . $filename_wo_ext . $convert_to['ext']);
     $cmd = $convert_path . ' -density ' . $density . ' "' . $from_path . '[0]" -colorspace RGB "' . $to_path . '"';
     exec($cmd, $out, $ret);
     if ($ret != 0) {
         return false;
     }
     $image_src = call_user_func($convert_to['createfunc'], $to_path);
     if (!$image_src) {
         return;
     }
     $this->media->setImage($image_src);
     $this->media->refreshImageDimensions();
     $this->media->setFormat($convert_to['ext']);
     $this->media->setMediaFilename($filename);
     $this->media->setHeader('Content-Type', $convert_to['content-type']);
     unlink($to_path);
 }
Пример #13
0
 public function execute()
 {
     if (!rex::getUser()->isAdmin()) {
         throw new rex_api_exception('You do not have the permission!');
     }
     $addonkey = rex_request('addonkey', 'string');
     $upload = rex_request('upload', [['upload_file', 'bool'], ['oldversion', 'string'], ['redaxo', 'array[string]'], ['description', 'string'], ['status', 'int'], ['replace_assets', 'bool'], ['ignore_tests', 'bool']]);
     $file = [];
     $archive = null;
     $file['version'] = $upload['upload_file'] ? rex_addon::get($addonkey)->getVersion() : $upload['oldversion'];
     $file['redaxo_versions'] = $upload['redaxo'];
     $file['description'] = $upload['description'];
     $file['status'] = $upload['status'];
     try {
         if ($upload['upload_file']) {
             $archive = rex_path::addonCache('install', md5($addonkey . time()) . '.zip');
             $exclude = [];
             if ($upload['replace_assets']) {
                 $exclude[] = 'assets';
             }
             if ($upload['ignore_tests']) {
                 $exclude[] = 'tests';
             }
             rex_install_archive::copyDirToArchive(rex_path::addon($addonkey), $archive, null, $exclude);
             if ($upload['replace_assets']) {
                 rex_install_archive::copyDirToArchive(rex_url::addonAssets($addonkey), $archive, $addonkey . '/assets');
             }
             $file['checksum'] = md5_file($archive);
         }
         rex_install_webservice::post(rex_install_packages::getPath('?package=' . $addonkey . '&file_id=' . rex_request('file', 'int', 0)), ['file' => $file], $archive);
     } catch (rex_functional_exception $e) {
         throw new rex_api_exception($e->getMessage());
     }
     if ($archive) {
         rex_file::delete($archive);
     }
     unset($_REQUEST['addonkey']);
     unset($_REQUEST['file']);
     rex_install_packages::deleteCache();
     return new rex_api_result(true, rex_i18n::msg('install_info_addon_uploaded', $addonkey));
 }
Пример #14
0
 public function execute()
 {
     if (!rex::getUser()->isAdmin()) {
         throw new rex_api_exception('You do not have the permission!');
     }
     $this->addonkey = rex_request('addonkey', 'string');
     $function = static::GET_PACKAGES_FUNCTION;
     $packages = rex_install_packages::$function();
     $this->fileId = rex_request('file', 'int');
     if (!isset($packages[$this->addonkey]['files'][$this->fileId])) {
         return null;
     }
     $this->file = $packages[$this->addonkey]['files'][$this->fileId];
     $this->checkPreConditions();
     try {
         $archivefile = rex_install_webservice::getArchive($this->file['path']);
     } catch (rex_functional_exception $e) {
         throw new rex_api_exception($e->getMessage());
     }
     $message = '';
     $this->archive = $archivefile;
     if ($this->file['checksum'] != md5_file($archivefile)) {
         $message = rex_i18n::msg('install_warning_zip_wrong_checksum');
     } elseif (!$this->isCorrectFormat($archivefile)) {
         $message = rex_i18n::msg('install_warning_zip_wrong_format');
     } elseif (is_string($msg = $this->doAction())) {
         $message = $msg;
     }
     rex_file::delete($archivefile);
     if ($message) {
         $message = rex_i18n::msg('install_warning_addon_not_' . static::VERB, $this->addonkey) . '<br />' . $message;
         $success = false;
     } else {
         $message = rex_i18n::msg('install_info_addon_' . static::VERB, $this->addonkey) . (static::SHOW_LINK ? ' <a href="' . rex_url::backendPage('packages') . '">' . rex_i18n::msg('install_to_addon_page') . '</a>' : '');
         $success = true;
         unset($_REQUEST['addonkey']);
     }
     return new rex_api_result($success, $message);
 }
Пример #15
0
 public function execute()
 {
     global $I18N;
     $this->addonkey = rex_request('addonkey', 'string');
     $function = static::GET_PACKAGES_FUNCTION;
     $packages = rex_install_packages::$function();
     $this->fileId = rex_request('file', 'int');
     if (!isset($packages[$this->addonkey]['files'][$this->fileId])) {
         return null;
     }
     $this->file = $packages[$this->addonkey]['files'][$this->fileId];
     $this->checkPreConditions();
     $archivefile = rex_install_webservice::getArchive($this->file['path']);
     $message = '';
     $this->archive = $archivefile;
     if ($this->file['checksum'] != md5_file($archivefile)) {
         $message = $I18N->msg('install_warning_zip_wrong_checksum');
     } elseif (!file_exists("phar://{$archivefile}/" . $this->addonkey)) {
         $message = $I18N->msg('install_warning_zip_wrong_format');
     } elseif (is_string($msg = $this->doAction())) {
         $message = $msg;
     }
     rex_file::delete($archivefile);
     if ($message) {
         $message = $I18N->msg('install_warning_addon_not_' . static::VERB, $this->addonkey) . '<br />' . $message;
         $success = false;
     } else {
         $message = $I18N->msg('install_info_addon_' . static::VERB, $this->addonkey) . (static::SHOW_LINK ? ' <a href="index.php?page=addon">' . $I18N->msg('install_to_addon_page') . '</a>' : '');
         $success = true;
         unset($_REQUEST['addonkey']);
     }
     if ($success) {
         return $message;
     } else {
         throw new rex_install_functional_exception($message);
     }
 }
Пример #16
0
        } catch (InvalidArgumentException $e) {
            $error[] = rex_i18n::msg($key . '_invalid');
        }
    }
    $config['debug'] = isset($settings['debug']) && $settings['debug'];
    rex::setProperty('debug', $config['debug']);
    foreach (rex_system_setting::getAll() as $setting) {
        $key = $setting->getKey();
        if (isset($settings[$key])) {
            if (($msg = $setting->setValue($settings[$key])) !== true) {
                $error[] = $msg;
            }
        }
    }
    if (empty($error)) {
        if (rex_file::putConfig($configFile, $config) > 0) {
            $success = rex_i18n::msg('info_updated');
        }
    }
}
$sel_lang = new rex_select();
$sel_lang->setStyle('class="form-control"');
$sel_lang->setName('settings[lang]');
$sel_lang->setId('rex-id-lang');
$sel_lang->setSize(1);
$sel_lang->setSelected(rex::getProperty('lang'));
foreach (rex_i18n::getLocales() as $l) {
    $sel_lang->addOption($l, $l);
}
if (!empty($error)) {
    echo rex_view::error(implode('<br />', $error));
Пример #17
0
 /**
  * {@inheritdoc}
  */
 public function getSystemPlugins()
 {
     if (rex::isSetup() || rex::isSafeMode()) {
         // in setup and safemode this method is called before the package .lang files are added to rex_i18n
         // so don't use getProperty(), to avoid loading all properties without translations
         $properties = rex_file::getConfig($this->getPath(parent::FILE_PACKAGE));
         $systemPlugins = isset($properties['system_plugins']) ? (array) $properties['system_plugins'] : [];
     } else {
         $systemPlugins = (array) $this->getProperty('system_plugins', []);
     }
     $plugins = [];
     foreach ($systemPlugins as $plugin) {
         if ($this->pluginExists($plugin)) {
             $plugins[$plugin] = $this->getPlugin($plugin);
         }
     }
     return $plugins;
 }
Пример #18
0
     $subject = $ep->getSubject();
     $file = rex_plugin::get('be_style', $mypage)->getPath('scss/default.scss');
     array_unshift($subject, $file);
     return $subject;
 }, rex_extension::EARLY);
 if (rex::getUser() && $this->getProperty('compile')) {
     rex_addon::get('be_style')->setProperty('compile', true);
     rex_extension::register('PACKAGES_INCLUDED', function () {
         $compiler = new rex_scss_compiler();
         $compiler->setRootDir($this->getPath('scss/'));
         $compiler->setScssFile($this->getPath('scss/master.scss'));
         // Compile in backend assets dir
         $compiler->setCssFile($this->getPath('assets/css/styles.css'));
         $compiler->compile();
         // Compiled file to copy in frontend assets dir
         rex_file::copy($this->getPath('assets/css/styles.css'), $this->getAssetsPath('css/styles.css'));
     });
 }
 rex_view::addCssFile($this->getAssetsUrl('css/styles.css'));
 rex_view::addJsFile($this->getAssetsUrl('javascripts/redaxo.js'));
 rex_extension::register('PAGE_HEADER', function (rex_extension_point $ep) {
     $icons = [];
     foreach (['57', '60', '72', '76', '114', '120', '144', '152'] as $size) {
         $size = $size . 'x' . $size;
         $icons[] = '<link rel="apple-touch-icon-precomposed" sizes="' . $size . '" href="' . $this->getAssetsUrl('images/apple-touch-icon-' . $size . '.png') . '" />';
     }
     foreach (['16', '32', '96', '128', '196'] as $size) {
         $size = $size . 'x' . $size;
         $icons[] = '<link rel="icon" type="image/png" href="' . $this->getAssetsUrl('images/favicon-' . $size . '.png') . '" sizes="' . $size . '" />';
     }
     $icons[] = '<meta name="msapplication-TileColor" content="#FFFFFF" />';
Пример #19
0
 /**
  * Loads the properties of package.yml.
  */
 private function loadProperties()
 {
     static $cache = null;
     if (is_null($cache)) {
         $cache = rex_file::getCache(rex_path::cache('packages.cache'));
     }
     $id = $this->getPackageId();
     $file = $this->getPath(self::FILE_PACKAGE);
     if (!file_exists($file)) {
         $this->propertiesLoaded = true;
         return;
     }
     if (isset($cache[$id]) && (!rex::isBackend() || !($user = rex::getUser()) || !$user->isAdmin() || $cache[$id]['timestamp'] >= filemtime($file))) {
         $properties = $cache[$id]['data'];
     } else {
         $properties = rex_file::getConfig($file);
         $cache[$id]['timestamp'] = filemtime($file);
         $cache[$id]['data'] = $properties;
         static $registeredShutdown = false;
         if (!$registeredShutdown) {
             $registeredShutdown = true;
             register_shutdown_function(function () use(&$cache) {
                 foreach ($cache as $package => $_) {
                     if (!rex_package::exists($package)) {
                         unset($cache[$package]);
                     }
                 }
                 rex_file::putCache(rex_path::cache('packages.cache'), $cache);
             });
         }
     }
     foreach ($properties as $key => $value) {
         if (!isset($this->properties[$key])) {
             $this->properties[$key] = rex_i18n::translateArray($value, false, [$this, 'i18n']);
         }
     }
     $this->propertiesLoaded = true;
 }
Пример #20
0
 public function toTar($filename, $useGzip)
 {
     // Encode processed files into TAR file format
     $this->__generateTar();
     // GZ Compress the data if we need to
     if ($useGzip) {
         // Make sure we have gzip support
         if (!function_exists('gzencode')) {
             return false;
         }
         $file = gzencode($this->tar_file);
     } else {
         $file = $this->tar_file;
     }
     // Write the TAR file
     //    $fp = fopen($filename,"wb");
     //    fwrite($fp,$file);
     //    fclose($fp);
     // kein Filename gegeben => Inhalt zurueckgeben
     if (!$filename) {
         return $file;
     }
     // STM: hier mit put_file_contents ist viel schneller
     return rex_file::put($filename, $file) !== false;
 }
Пример #21
0
         if ($media_manager) {
             $thumbnail = '<img class="thumbnail" src="' . rex_url::backendController(['rex_media_type' => 'rex_mediapool_preview', 'rex_media_file' => $encoded_file_name]) . '" alt="' . $alt . '" title="' . $alt . '" />';
         }
     }
 }
 // ----- get file size
 $size = $file_size;
 $file_size = rex_formatter::bytes($size);
 if ($file_title == '') {
     $file_title = '[' . rex_i18n::msg('pool_file_notitle') . ']';
 }
 $file_title .= ' [' . $file_id . ']';
 // ----- opener
 $opener_link = '';
 if ($opener_input_field == 'TINYIMG') {
     if (rex_media::isImageType(rex_file::extension($file_name))) {
         $opener_link .= '<a class="btn btn-select" href="javascript:insertImage(\'$file_name\',\'' . $files->getValue('title') . '\')">' . rex_i18n::msg('pool_image_get') . '</a>';
     }
 } elseif ($opener_input_field == 'TINY') {
     $opener_link .= '<a class="btn btn-select" href="javascript:insertLink(\'' . $file_name . '\');"">' . rex_i18n::msg('pool_link_get') . '</a>';
 } elseif ($opener_input_field != '') {
     $opener_link = '<a class="btn btn-xs btn-select" href="javascript:selectMedia(\'' . $file_name . '\', \'' . addslashes(htmlspecialchars($files->getValue('title'))) . '\');">' . rex_i18n::msg('pool_file_get') . '</a>';
     if (substr($opener_input_field, 0, 14) == 'REX_MEDIALIST_') {
         $opener_link = '<a class="btn btn-xs btn-select" href="javascript:selectMedialist(\'' . $file_name . '\');">' . rex_i18n::msg('pool_file_get') . '</a>';
     }
 }
 $ilink = rex_url::currentBackendPage(array_merge(['file_id' => $file_id, 'rex_file_category' => $rex_file_category], $arg_url));
 $add_td = '<td></td>';
 if ($PERMALL) {
     $add_td = '<td><input type="checkbox" name="selectedmedia[]" value="' . $file_name . '" /></td>';
 }
Пример #22
0
 /**
  * @param string      $temppath
  * @param string      $version
  * @param rex_addon[] $addons
  *
  * @throws rex_functional_exception
  */
 private function checkRequirements($temppath, $version, array $addons)
 {
     // ---- update "version", "requires" and "conflicts" properties
     $coreVersion = rex::getVersion();
     rex::setProperty('version', $version);
     $versions = new SplObjectStorage();
     $requirements = new SplObjectStorage();
     $conflicts = new SplObjectStorage();
     foreach ($addons as $addonkey => $config) {
         $addon = rex_addon::get($addonkey);
         $addonPath = $temppath . 'addons/' . $addonkey . '/';
         if (isset($config['requires'])) {
             $requirements[$addon] = $addon->getProperty('requires');
             $addon->setProperty('requires', $config['requires']);
         }
         if (isset($config['conflicts'])) {
             $conflicts[$addon] = $addon->getProperty('conflicts');
             $addon->setProperty('conflicts', $config['conflicts']);
         }
         $versions[$addon] = $addon->getVersion();
         $addon->setProperty('version', $config['version']);
         foreach ($addon->getAvailablePlugins() as $plugin) {
             if (is_dir($addonPath . 'plugins/' . $plugin->getName())) {
                 $config = rex_file::getConfig($addonPath . 'plugins/' . $plugin->getName() . '/' . rex_package::FILE_PACKAGE);
                 if (isset($config['requires'])) {
                     $requirements[$plugin] = $plugin->getProperty('requires');
                     $plugin->setProperty('requires', $config['requires']);
                 }
                 if (isset($config['conflicts'])) {
                     $conflicts[$plugin] = $plugin->getProperty('conflicts');
                     $plugin->setProperty('conflicts', $config['conflicts']);
                 }
                 if (isset($config['version'])) {
                     $versions[$plugin] = $plugin->getProperty('version');
                     $plugin->setProperty('requires', $config['version']);
                 }
             }
         }
     }
     // ---- check requirements
     $messages = [];
     foreach (rex_package::getAvailablePackages() as $package) {
         $manager = rex_package_manager::factory($package);
         if (!$manager->checkRequirements()) {
             $messages[] = $package->getPackageId() . ': ' . $manager->getMessage();
         } elseif (!$manager->checkConflicts()) {
             $messages[] = $package->getPackageId() . ': ' . $manager->getMessage();
         }
     }
     // ---- reset "version", "requires" and "conflicts" properties
     rex::setProperty('version', $coreVersion);
     foreach ($versions as $package) {
         $package->setProperty('version', $versions[$package]);
     }
     foreach ($requirements as $package) {
         $package->setProperty('requires', $requirements[$package]);
     }
     foreach ($conflicts as $package) {
         $package->setProperty('conflicts', $conflicts[$package]);
     }
     if (!empty($messages)) {
         throw new rex_functional_exception(implode('<br />', $messages));
     }
 }
Пример #23
0
/**
 * check if mediatpye(extension) is allowed for upload.
 *
 * @param string $filename
 * @param array  $args
 *
 * @return bool
 */
function rex_mediapool_isAllowedMediaType($filename, array $args = [])
{
    $file_ext = rex_file::extension($filename);
    if ($filename === '' || strpos($file_ext, ' ') !== false || $file_ext === '') {
        return false;
    }
    $blacklist = rex_mediapool_getMediaTypeBlacklist();
    $whitelist = rex_mediapool_getMediaTypeWhitelist($args);
    if (in_array($file_ext, $blacklist)) {
        return false;
    }
    if (count($whitelist) > 0 && !in_array($file_ext, $whitelist)) {
        return false;
    }
    return true;
}
Пример #24
0
 /**
  * @param int    $parentId
  * @param string $listType
  * @param bool   $ignoreOfflines
  * @param int    $clang
  *
  * @return static[]
  */
 protected static function getChildElements($parentId, $listType, $ignoreOfflines = false, $clang = null)
 {
     $parentId = (int) $parentId;
     // for $parentId=0 root elements will be returned, so abort here for $parentId<0 only
     if (0 > $parentId) {
         return [];
     }
     if (!$clang) {
         $clang = rex_clang::getCurrentId();
     }
     $class = get_called_class();
     return static::getInstanceList([$parentId, $listType], function ($id) use($class, $ignoreOfflines, $clang) {
         if ($instance = $class::get($id, $clang)) {
             return !$ignoreOfflines || $instance->isOnline() ? $instance : null;
         }
         return null;
     }, function ($parentId, $listType) {
         $listFile = rex_path::addonCache('structure', $parentId . '.' . $listType);
         if (!file_exists($listFile)) {
             rex_article_cache::generateLists($parentId);
         }
         return rex_file::getCache($listFile);
     });
 }
Пример #25
0
 function saveNextTime($nexttime = null)
 {
     global $REX;
     if ($nexttime === null) {
         $sql_manager = rex_cronjob_manager_sql::factory($this);
         $nexttime = $sql_manager->getMinNextTime();
     }
     if ($nexttime === null) {
         $nexttime = 0;
     } else {
         $nexttime = max(1, $nexttime);
     }
     if ($nexttime != $REX['ADDON']['nexttime']['cronjob'] && rex_file::put(REX_CRONJOB_NEXTTIME_FILE, $nexttime)) {
         $REX['ADDON']['nexttime']['cronjob'] = $nexttime;
         return true;
     }
     return false;
 }
Пример #26
0
 /**
  * @return string
  */
 public function getExtension()
 {
     return rex_file::extension($this->name);
 }
/**
 * Generiert den TemplateCache im Filesystem
 *
 * @param $template_id Id des zu generierenden Templates
 *
 * @return TRUE bei Erfolg, sonst FALSE
 */
function rex_generateTemplate($template_id)
{
    global $REX;
    $sql = rex_sql::factory();
    $qry = 'SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'template WHERE id = ' . $template_id;
    $sql->setQuery($qry);
    if ($sql->getRows() == 1) {
        $templatesDir = rex_template::getTemplatesDir();
        $templateFile = rex_template::getFilePath($template_id);
        $content = $sql->getValue('content');
        foreach ($REX['VARIABLES'] as $var) {
            $content = $var->getTemplate($content);
        }
        if (rex_file::put($templateFile, $content) !== false) {
            return true;
        } else {
            trigger_error('Unable to generate template ' . $template_id . '!', E_USER_ERROR);
            if (!is_writable()) {
                trigger_error('directory "' . $templatesDir . '" is not writable!', E_USER_ERROR);
            }
        }
    } else {
        trigger_error('Template with id "' . $template_id . '" does not exist!', E_USER_ERROR);
    }
    return false;
}
Пример #28
0
 /**
  * Schreibt Spracheigenschaften in die Datei include/clang.php.
  *
  * @throws rex_exception
  */
 public static function generateCache()
 {
     $lg = rex_sql::factory();
     $lg->setQuery('select * from ' . rex::getTablePrefix() . 'clang order by priority');
     $clangs = [];
     foreach ($lg as $lang) {
         $id = $lang->getValue('id');
         foreach ($lg->getFieldnames() as $field) {
             $clangs[$id][$field] = $lang->getValue($field);
         }
     }
     $file = rex_path::coreCache('clang.cache');
     if (rex_file::putCache($file, $clangs) === false) {
         throw new rex_exception('Clang cache file could not be generated');
     }
 }
Пример #29
0
                <thead>
                    <tr>
                        <th class="rex-table-icon"></th>
                        <th>' . rex_i18n::msg('backup_filename') . '</th>
                        <th class="rex-table-width-5">' . rex_i18n::msg('backup_filesize') . '</th>
                        <th class="rex-table-width-5">' . rex_i18n::msg('backup_createdate') . '</th>
                        <th class="rex-table-action" colspan="3">' . rex_i18n::msg('backup_function') . '</th>
                    </tr>
                </thead>
                <tbody>';
$dir = rex_backup::getDir();
$folder = rex_backup::getBackupFiles('.tar.gz');
foreach ($folder as $file) {
    $filepath = $dir . '/' . $file;
    $filec = date('d.m.Y H:i', filemtime($filepath));
    $filesize = rex_file::formattedSize($filepath);
    $content .= '<tr>
                    <td class="rex-table-icon"><i class="rex-icon rex-icon-file-archive"></i></td>
                    <td data-title="' . rex_i18n::msg('backup_filename') . '">' . $file . '</td>
                    <td data-title="' . rex_i18n::msg('backup_filesize') . '">' . $filesize . '</td>
                    <td data-title="' . rex_i18n::msg('backup_createdate') . '">' . $filec . '</td>
                    <td class="rex-table-action"><a href="' . rex_url::currentBackendPage(['function' => 'fileimport', 'impname' => $file]) . '" title="' . rex_i18n::msg('backup_import_file') . '" data-confirm="' . rex_i18n::msg('backup_proceed_file_import') . '"><i class="rex-icon rex-icon-import"></i> ' . rex_i18n::msg('backup_to_import') . '</a></td>
                    <td class="rex-table-action"><a href="' . rex_url::currentBackendPage(['function' => 'download', 'impname' => $file]) . '" title="' . rex_i18n::msg('backup_download_file') . '"><i class="rex-icon rex-icon-download"></i> ' . rex_i18n::msg('backup_download') . '</a></td>
                    <td class="rex-table-action"><a href="' . rex_url::currentBackendPage(['function' => 'delete', 'impname' => $file]) . '" title="' . rex_i18n::msg('backup_delete_file') . '" data-confirm="' . rex_i18n::msg('backup_delete') . ' ?"><i class="rex-icon rex-icon-delete"></i> ' . rex_i18n::msg('backup_delete') . '</a></td>
                </tr>';
}
$content .= '
               </tbody>
            </table>
        ';
$fragment = new rex_fragment();
Пример #30
0
 /**
  * Loads the translation definitions of the given file.
  *
  * @param string $file Path to the file
  *
  * @return bool TRUE on success, FALSE on failure
  */
 private static function loadFile($file)
 {
     if (($content = rex_file::get($file)) && preg_match_all("/^([^\\s]*)\\s*=\\s*(.*\\S)?\\s*\$/m", $content, $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             self::addMsg($match[1], $match[2]);
         }
     }
 }