protected function getOutput() { $id = $this->getArg('id', 0, true); if (!in_array($this->getContext(), ['module', 'action']) || !is_numeric($id) || $id < 1 || $id > 20) { return false; } $value = $this->getContextData()->getValue('value' . $id); if ($this->hasArg('isset') && $this->getArg('isset')) { return $value ? 'true' : 'false'; } $output = $this->getArg('output'); if ($output == 'php') { if ($this->environmentIs(self::ENV_BACKEND)) { $value = rex_string::highlight($value); } else { return 'rex_var::nothing(require rex_stream::factory(substr(__FILE__, 6) . \'/REX_VALUE/' . $id . '\', ' . self::quote($value) . '))'; } } elseif ($output == 'html') { $value = str_replace(['<?', '?>'], ['<?', '?>'], $value); } else { $value = htmlspecialchars($value); if (!$this->environmentIs(self::ENV_INPUT)) { $value = nl2br($value); } } return self::quote($value); }
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; }
/** * Gibt eine Url zu einem Artikel zurück. * * @param int|null $id * @param int|null $clang SprachId des Artikels * @param array $params Array von Parametern * @param string $separator * * @return string * * @package redaxo\structure */ function rex_getUrl($id = null, $clang = null, array $params = [], $separator = '&') { $id = (int) $id; $clang = (int) $clang; // ----- get id if ($id == 0) { $id = rex::getProperty('article_id'); } // ----- get clang // Wenn eine rexExtension vorhanden ist, immer die clang mitgeben! // Die rexExtension muss selbst entscheiden was sie damit macht if (!rex_clang::exists($clang) && (rex_clang::count() > 1 || rex_extension::isRegistered('URL_REWRITE'))) { $clang = rex_clang::getCurrentId(); } // ----- EXTENSION POINT $url = rex_extension::registerPoint(new rex_extension_point('URL_REWRITE', '', ['id' => $id, 'clang' => $clang, 'params' => $params, 'separator' => $separator])); if ($url == '') { if (rex_clang::count() > 1) { $clang = $separator . 'clang=' . $clang; } else { $clang = ''; } $params = rex_string::buildQuery($params, $separator); $params = $params ? $separator . $params : ''; $url = rex_url::frontendController() . '?article_id=' . $id . $clang . $params; } return $url; }
/** * Erstellt einen Filename der eindeutig ist für den Medienpool. * * @param string $FILENAME Dateiname * @param bool $doSubindexing * * @return string */ function rex_mediapool_filename($FILENAME, $doSubindexing = true) { // ----- neuer filename und extension holen $NFILENAME = rex_string::normalize($FILENAME, '_', '.-'); if (strrpos($NFILENAME, '.') != '') { $NFILE_NAME = substr($NFILENAME, 0, strlen($NFILENAME) - (strlen($NFILENAME) - strrpos($NFILENAME, '.'))); $NFILE_EXT = substr($NFILENAME, strrpos($NFILENAME, '.'), strlen($NFILENAME) - strrpos($NFILENAME, '.')); } else { $NFILE_NAME = $NFILENAME; $NFILE_EXT = ''; } // ---- ext checken - alle scriptendungen rausfiltern if (in_array(ltrim($NFILE_EXT, '.'), rex_addon::get('mediapool')->getProperty('blocked_extensions'))) { $NFILE_NAME .= $NFILE_EXT; $NFILE_EXT = '.txt'; } // ---- multiple extension check foreach (rex_addon::get('mediapool')->getProperty('blocked_extensions') as $ext) { $NFILE_NAME = str_replace($ext . '.', $ext . '_.', $NFILE_NAME); } $NFILENAME = $NFILE_NAME . $NFILE_EXT; if ($doSubindexing || $FILENAME != $NFILENAME) { // ----- datei schon vorhanden -> namen aendern -> _1 .. if (file_exists(rex_path::media($NFILENAME))) { $cnt = 1; while (file_exists(rex_path::media($NFILE_NAME . '_' . $cnt . $NFILE_EXT))) { ++$cnt; } $NFILENAME = $NFILE_NAME . '_' . $cnt . $NFILE_EXT; } } return $NFILENAME; }
public function formatElement() { $s = ''; $values = explode('|', trim($this->getValue(), '|')); $options = $this->getOptions(); $name = $this->getAttribute('name'); $id = $this->getAttribute('id'); $attr = ''; foreach ($this->getAttributes() as $attributeName => $attributeValue) { if ($attributeName == 'name' || $attributeName == 'id') { continue; } $attr .= ' ' . htmlspecialchars($attributeName) . '="' . htmlspecialchars($attributeValue) . '"'; } $formElements = []; foreach ($options as $opt_name => $opt_value) { $opt_id = $id; if ($opt_value != '') { $opt_id .= '-' . rex_string::normalize($opt_value, '-'); } $opt_attr = $attr . ' id="' . htmlspecialchars($opt_id) . '"'; $checked = in_array($opt_value, $values) ? ' checked="checked"' : ''; $n = []; $n['label'] = '<label class="control-label" for="' . htmlspecialchars($opt_id) . '">' . htmlspecialchars($opt_name) . '</label>'; $n['field'] = '<input type="checkbox" name="' . htmlspecialchars($name) . '[' . htmlspecialchars($opt_value) . ']" value="' . htmlspecialchars($opt_value) . '"' . $opt_attr . $checked . ' />'; $formElements[] = $n; } $fragment = new rex_fragment(); $fragment->setVar('elements', $formElements, false); $fragment->setVar('grouped', true); $s = $fragment->parse('core/form/checkbox.php'); return $s; }
public function formatElement() { $s = ''; $value = $this->getValue(); $options = $this->getOptions(); $id = $this->getAttribute('id'); $attr = ''; foreach ($this->getAttributes() as $attributeName => $attributeValue) { if ($attributeName == 'id') { continue; } $attr .= ' ' . htmlspecialchars($attributeName) . '="' . htmlspecialchars($attributeValue) . '"'; } $formElements = []; foreach ($options as $opt_name => $opt_value) { $checked = $opt_value == $value ? ' checked="checked"' : ''; $opt_id = $id . '-' . rex_string::normalize($opt_value, '-'); $opt_attr = $attr . ' id="' . $opt_id . '"'; $n = []; $n['label'] = '<label class="control-label" for="' . $opt_id . '">' . htmlspecialchars($opt_name) . '</label>'; $n['field'] = '<input type="radio" value="' . htmlspecialchars($opt_value) . '"' . $opt_attr . $checked . ' />'; $formElements[] = $n; } $fragment = new rex_fragment(); $fragment->setVar('elements', $formElements, false); $s = $fragment->parse('core/form/radio.php'); return $s; }
protected function checkPreConditions() { if (!OOAddon::isAvailable($this->addonkey)) { throw new rex_install_functional_exception(sprintf('AddOn "%s" is not available!', $this->addonkey)); } if (!rex_string::versionCompare($this->file['version'], OOAddon::getVersion($this->addonkey), '>')) { throw new rex_install_functional_exception(sprintf('Existing version of AddOn "%s" (%s) is newer than %s', $this->addonkey, OOAddon::getVersion($this->addonkey), $this->file['version'])); } }
protected function checkPreConditions() { if (!rex_addon::exists($this->addonkey)) { throw new rex_api_exception(sprintf('AddOn "%s" does not exist!', $this->addonkey)); } $this->addon = rex_addon::get($this->addonkey); if (!rex_string::versionCompare($this->file['version'], $this->addon->getVersion(), '>')) { throw new rex_api_exception(sprintf('Existing version of AddOn "%s" (%s) is newer than %s', $this->addonkey, $this->addon->getVersion(), $this->file['version'])); } }
private static function unsetOlderVersions($package, $version) { foreach (self::$updatePackages[$package]['files'] as $fileId => $file) { if (empty($version) || empty($file['version']) || rex_string::versionCompare($file['version'], $version, '<=')) { unset(self::$updatePackages[$package]['files'][$fileId]); } } if (empty(self::$updatePackages[$package]['files'])) { unset(self::$updatePackages[$package]); } }
protected function getOutput() { $id = $this->getArg('id', 0, true); if (!in_array($this->getContext(), ['module', 'action']) || !is_numeric($id) || $id < 1 || $id > 20) { return false; } $value = $this->getContextData()->getValue('value' . $id); if ($this->hasArg('isset') && $this->getArg('isset')) { return $value ? 'true' : 'false'; } $classes = []; if ($this->hasArg('class') && $this->getArg('class')) { $classes[] = $this->getArg('class'); } if ($this->hasArg('widget') && $this->getArg('widget')) { $value = htmlspecialchars($value); if (!$this->environmentIs(self::ENV_INPUT)) { $value = nl2br($value); } $classes[] = 'form-control'; $class = ' class="' . implode(' ', $classes) . '"'; $type = $this->getArg('type', 'text', true); switch ($type) { case 'textarea': $widget = '<textarea' . $class . ' name="REX_INPUT_VALUE[' . $id . ']" rows="10">' . $value . '</textarea>'; break; default: $widget = '<input' . $class . ' type="' . $type . '" name="REX_INPUT_VALUE[' . $id . ']" value="' . $value . '" />'; break; } if ($this->hasArg('output') && $this->getArg('output')) { $label = $this->hasArg('label') ? $this->getArg('label') : ''; $widget = Dao::getForm($widget, $label, $this->getArg('output')); } return self::quote($widget); } $output = $this->getArg('output'); if ($output == 'php') { if ($this->environmentIs(self::ENV_BACKEND)) { $value = rex_string::highlight($value); } else { return 'rex_var::nothing(require rex_stream::factory(substr(__FILE__, 6) . \'/REX_VALUE/' . $id . '\', ' . self::quote($value) . '))'; } } elseif ($output == 'html') { $value = str_replace(['<?', '?>'], ['<?', '?>'], $value); } else { $value = htmlspecialchars($value); if (!$this->environmentIs(self::ENV_INPUT)) { $value = nl2br($value); } } return self::quote($value); }
$fragment->setVar('class', 'info', false); $fragment->setVar('title', 'Prüfen ob der aktuelle Browser Chrome ist', false); //todo: translate $fragment->setVar('body', rex_string::highlight($code), false); echo $fragment->parse('core/page/section.php'); /// $code = ""; $code .= "<?php" . PHP_EOL; $code .= "\tif (useragent::isBrowserInternetExplorer()) {" . PHP_EOL; $code .= "\t\t//..." . PHP_EOL; $code .= "\t}" . PHP_EOL; $code .= "?>"; $fragment = new rex_fragment(); $fragment->setVar('class', 'info', false); $fragment->setVar('title', 'Prüfen ob der aktuelle Browser Internet Explorer ist', false); //todo: translate $fragment->setVar('body', rex_string::highlight($code), false); echo $fragment->parse('core/page/section.php'); /// $code = ""; $code .= "<?php" . PHP_EOL; $code .= "\tif (useragent::isBrowserEdge()) {" . PHP_EOL; $code .= "\t\t//..." . PHP_EOL; $code .= "\t}" . PHP_EOL; $code .= "?>"; $fragment = new rex_fragment(); $fragment->setVar('class', 'info', false); $fragment->setVar('title', 'Prüfen ob der aktuelle Browser Edge ist', false); //todo: translate $fragment->setVar('body', rex_string::highlight($code), false); echo $fragment->parse('core/page/section.php');
/** * Sends content to the client. * * @param string $content Content * @param string $contentType Content type * @param int $lastModified HTTP Last-Modified Timestamp * @param string $etag HTTP Cachekey to identify the cache */ public static function sendContent($content, $contentType = null, $lastModified = null, $etag = null) { if (!self::$sentContentType) { self::sendContentType($contentType); } if (!self::$sentCacheControl) { self::sendCacheControl(); } $environment = rex::isBackend() ? 'backend' : 'frontend'; if (self::$httpStatus == self::HTTP_OK && (false === strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') || false !== strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome'))) { // ----- Last-Modified if (!self::$sentLastModified && (rex::getProperty('use_last_modified') === true || rex::getProperty('use_last_modified') === $environment)) { self::sendLastModified($lastModified); } // ----- ETAG if (!self::$sentEtag && (rex::getProperty('use_etag') === true || rex::getProperty('use_etag') === $environment)) { self::sendEtag($etag ?: self::md5($content)); } } // ----- GZIP if (rex::getProperty('use_gzip') === true || rex::getProperty('use_gzip') === $environment) { $content = self::sendGzip($content); } self::cleanOutputBuffers(); header('HTTP/1.1 ' . self::$httpStatus); // content length schicken, damit der browser einen ladebalken anzeigen kann header('Content-Length: ' . rex_string::size($content)); echo $content; if (function_exists('fastcgi_finish_request')) { fastcgi_finish_request(); } }
/** * Checks the version of the connected database server. * * @param array $config of databaes configs * @param bool $createDb Should the database be created, if it not exists. * * @return string Error */ public static function checkDb($config, $createDb) { $err = rex_sql::checkDbConnection($config['db'][1]['host'], $config['db'][1]['login'], $config['db'][1]['password'], $config['db'][1]['name'], $createDb); if ($err !== true) { return $err; } $serverVersion = rex_sql::getServerVersion(); if (rex_string::versionCompare($serverVersion, self::MIN_MYSQL_VERSION, '<') == 1) { return rex_i18n::msg('setup_404', $serverVersion, self::MIN_MYSQL_VERSION); } return ''; }
/** * Formats a version string by `sprintf()`. * * @link http://www.php.net/manual/en/function.sprintf.php * * @param string $value Version * @param string $format Version format, e.g. "%s.%s" * * @return string */ public static function version($value, $format) { return vsprintf($format, rex_string::versionSplit($value)); }
/** * Übernimmt die gePOSTeten werte in ein rex_sql-Objekt. * * @param array $params * @param rex_sql $sqlSave rex_sql-objekt, in das die aktuellen Werte gespeichert werden sollen * @param rex_sql $sqlFields rex_sql-objekt, dass die zu verarbeitenden Felder enthält */ public static function fetchRequestValues(&$params, &$sqlSave, $sqlFields) { if (rex_request_method() != 'post') { return; } for ($i = 0; $i < $sqlFields->getRows(); $i++, $sqlFields->next()) { $fieldName = $sqlFields->getValue('name'); $fieldType = $sqlFields->getValue('type_id'); $fieldAttributes = $sqlFields->getValue('attributes'); // dont save restricted fields $attrArray = rex_string::split($fieldAttributes); if (isset($attrArray['perm'])) { if (!rex::getUser()->hasPerm($attrArray['perm'])) { continue; } unset($attrArray['perm']); } // Wert in SQL zum speichern $saveValue = self::getSaveValue($fieldName, $fieldType, $fieldAttributes); $sqlSave->setValue($fieldName, $saveValue); // Werte im aktuellen Objekt speichern, dass zur Anzeige verwendet wird if (isset($params['activeItem'])) { $params['activeItem']->setValue($fieldName, $saveValue); } } }
/** * Returns the url to the backend-controller (index.php from backend). * * @param array $params Params * @param bool $escape Flag whether the argument separator "&" should be escaped (&) * * @return string */ public static function backendController(array $params = [], $escape = true) { $query = rex_string::buildQuery($params, $escape ? '&' : '&'); $query = $query ? '?' . $query : ''; return self::backend('index.php' . $query); }
public function setAttribute($name, $value) { if ($name == 'value') { $this->setValue($value); } else { if ($name == 'id') { $value = rex_string::normalize($value, '-'); } elseif ($name == 'name') { $value = rex_string::normalize($value, '_', '[]'); } $this->attributes[$name] = $value; } }
"> <dt> <label class="control-label" for="<?php echo rex_string::normalize($name, ''); ?> "><?php echo $label; ?> </label> </dt> <dd> <?php $newSelect = new rex_select(); $newSelect->setMultiple($this->getVar('multiple')); $newSelect->setAttribute('class', 'form-control'); $newSelect->setId(rex_string::normalize($name, '')); $newSelect->setSize($size); $newSelect->setName($name); $newSelect->setSelected($this->getVar('selected')); if (count($options) > 0) { foreach ($options as $key => $module) { if (is_array($module)) { $newSelect->addOption($module['name'], $module['id']); } else { $newSelect->addOption($module, $key); } } } echo $newSelect->get(); ?> <br><span class="rex-form-notice"><?php
/** * Writes a request to the opened connection. * * @param string $method HTTP method, e.g. "GET" * @param string $path Path * @param array $headers Headers * @param string|callable $data Body data as string or a callback for writing the body * * @throws rex_socket_exception * * @return rex_socket_response Response */ protected function writeRequest($method, $path, array $headers = [], $data = '') { $eol = "\r\n"; $headerStrings = []; $headerStrings[] = strtoupper($method) . ' ' . $path . ' HTTP/1.1'; foreach ($headers as $key => $value) { $headerStrings[] = $key . ': ' . $value; } foreach ($headerStrings as $header) { fwrite($this->stream, str_replace(["\r", "\n"], '', $header) . $eol); } if (!is_callable($data)) { fwrite($this->stream, 'Content-Length: ' . rex_string::size($data) . $eol); fwrite($this->stream, $eol . $data); } else { call_user_func($data, $this->stream); } $meta = stream_get_meta_data($this->stream); if (isset($meta['timed_out']) && $meta['timed_out']) { throw new rex_socket_exception('Timeout!'); } return new rex_socket_response($this->stream); }
/** * Puts content in a config file. * * @param string $file Path to the file * @param mixed $content Content for the file * @param int $inline The level where you switch to inline YAML * * @return bool TRUE on success, FALSE on failure */ public static function putConfig($file, $content, $inline = 3) { return self::put($file, rex_string::yamlEncode($content, $inline)); }
} $icon = ''; if (isset($item['icon']) && $item['icon'] != '') { if (isset($item['itemAttr']['class'])) { if (is_array($item['itemAttr']['class'])) { $item['itemAttr']['class'] = array_merge($item['itemAttr']['class'], ['rex-has-icon']); } else { $item['itemAttr']['class'] = [$item['itemAttr']['class'], 'rex-has-icon']; } } else { $item['itemAttr']['class'] = ['rex-has-icon']; } $icon = '<i class="' . trim($item['icon']) . '"></i> '; } $itemAttr = isset($item['itemAttr']) ? rex_string::buildAttributes($item['itemAttr']) : ''; $linkAttr = isset($item['linkAttr']) ? rex_string::buildAttributes($item['linkAttr']) : ''; ?> <li<?php echo $itemAttr; ?> ><a href="<?php echo $item['href']; ?> "<?php echo $linkAttr; ?> ><?php echo $icon . $item['title']; ?> </a></li>
<?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')); }
/** * Checks the version of the requirement. * * @param string $version Version * @param string $constraints Constraint list, separated by comma * * @throws rex_exception * * @return bool */ private static function matchVersionConstraints($version, $constraints) { $rawConstraints = array_filter(array_map('trim', explode(',', $constraints))); $constraints = []; foreach ($rawConstraints as $constraint) { if ($constraint === '*') { continue; } if (!preg_match('/^(?<op>==?|<=?|>=?|!=|~|\\^|) ?(?<version>\\d+(?:\\.\\d+)*)(?<wildcard>\\.\\*)?(?<prerelease>[ -.]?[a-z]+(?:[ -.]?\\d+)?)?$/i', $constraint, $match) || isset($match['wildcard']) && $match['wildcard'] && ($match['op'] != '' || isset($match['prerelease']) && $match['prerelease'])) { throw new rex_exception('Unknown version constraint "' . $constraint . '"!'); } if (isset($match['wildcard']) && $match['wildcard']) { $constraints[] = ['>=', $match['version']]; $pos = strrpos($match['version'], '.') + 1; $sub = substr($match['version'], $pos); $constraints[] = ['<', substr_replace($match['version'], $sub + 1, $pos)]; } elseif (in_array($match['op'], ['~', '^'])) { $constraints[] = ['>=', $match['version'] . (isset($match['prerelease']) ? $match['prerelease'] : '')]; if ('^' === $match['op'] || false === ($pos = strrpos($match['version'], '.'))) { $constraints[] = ['<', (int) $match['version'] + 1]; } else { $main = ''; $sub = substr($match['version'], 0, $pos); if (($pos = strrpos($sub, '.')) !== false) { $main = substr($sub, 0, $pos + 1); $sub = substr($sub, $pos + 1); } $constraints[] = ['<', $main . ($sub + 1)]; } } else { $constraints[] = [$match['op'] ?: '=', $match['version'] . (isset($match['prerelease']) ? $match['prerelease'] : '')]; } } foreach ($constraints as $constraint) { if (!rex_string::versionCompare($version, $constraint[1], $constraint[0])) { return false; } } return true; }
public function sendMedia($sourceCacheFilename, $headerCacheFilename, $save = false) { if ($this->asImage) { $src = $this->getImageSource(); } else { $src = rex_file::get($this->getMediapath()); } $this->setHeader('Content-Length', rex_string::size($src)); $header = $this->getHeader(); if (!array_key_exists('Content-Type', $header)) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $content_type = finfo_file($finfo, $this->getMediapath()); if ($content_type != '') { $this->setHeader('Content-Type', $content_type); } } if (!array_key_exists('Content-Disposition', $header)) { $this->setHeader('Content-Disposition', 'inline; filename="' . $this->getMediaFilename() . '";'); } if (!array_key_exists('Last-Modified', $header)) { $this->setHeader('Last-Modified', gmdate('D, d M Y H:i:s T')); } rex_response::cleanOutputBuffers(); foreach ($this->header as $t => $c) { header($t . ': ' . $c); } echo $src; if ($save) { rex_file::putCache($headerCacheFilename, $this->header); rex_file::put($sourceCacheFilename, $src); } }
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; }
/** * @param string $name * * @return string * * @package redaxo\structure */ function rex_parse_article_name($name) { return str_replace('+', '-', urlencode(preg_replace('/ {2,}/', ' ', rex_string::normalize($name, '', ' _')))); }
// HTML body $body = "Hello <font size=\\"4\\">" . $row->getValue("full_name") . "</font>, <p>"; $body .= "<i>Your</i> personal photograph to this message.<p>"; $body .= "Sincerely, <br />"; $body .= "phpmailer List manager"; // Plain text body (for mail clients that cannot read HTML) $text_body = "Hello " . $row->getValue("full_name") . ", \\n\\n"; $text_body .= "Your personal photograph to this message.\\n\\n"; $text_body .= "Sincerely, \\n"; $text_body .= "phpmailer List manager"; $mail->Body = $body; $mail->AltBody = $text_body; $mail->AddAddress($row->getValue("email"), $row->getValue("full_name")); $mail->AddStringAttachment($sql->getValue("photo"), "YourPhoto.jpg"); if(!$mail->Send()) echo "There has been a mail error sending to " . $row->getValue("email") . "<br>"; // Clear all addresses and attachments for next loop $mail->ClearAddresses(); $mail->ClearAttachments(); } ?>'; $fragment = new rex_fragment(); $fragment->setVar('title', $this->i18n('example_headline')); $fragment->setVar('body', rex_string::highlight($mdl_ex), false); $content = $fragment->parse('core/page/section.php'); echo $content;
$body_attr['id'] = ['rex-page-' . $body_id]; $body_attr['onunload'] = ['closeAll();']; $body_attr['class'] = ['rex-is-logged-out']; if (rex::getUser()) { $body_attr['class'] = ['rex-is-logged-in']; } if ($curPage->isPopup()) { $body_attr['class'][] = 'rex-is-popup'; } // ----- EXTENSION POINT $body_attr = rex_extension::registerPoint(new rex_extension_point('PAGE_BODY_ATTR', $body_attr)); $body = ''; foreach ($body_attr as $k => $v) { $body .= ' ' . $k . '="'; if (is_array($v)) { $body .= rex_string::normalize(implode(' ', $v), '-', ' '); } $body .= '"'; } $hasNavigation = $curPage->hasNavigation(); $meta_items = []; if (rex::getUser() && $hasNavigation) { if (rex::isSafeMode()) { $item = []; $item['title'] = rex_i18n::msg('safemode_deactivate'); $item['href'] = rex_url::backendController(['safemode' => 0]); $meta_items[] = $item; unset($item); } $user_name = rex::getUser()->getValue('name') != '' ? rex::getUser()->getValue('name') : rex::getUser()->getValue('login'); $item = [];
/** * @param string $fieldsetName * * @return array */ public function fieldsetPostValues($fieldsetName) { // Name normalisieren, da der gepostete Name auch zuvor normalisiert wurde $normalizedFieldsetName = rex_string::normalize($fieldsetName, '_', '[]'); return rex_post($normalizedFieldsetName, 'array'); }
} $li_a .= '<li' . rex_string::buildAttributes($attributes) . '>'; if (isset($navi['href']) && $navi['href'] != '') { $attributes = []; $attributes['href'] = $navi['href']; if (isset($navi['linkClasses']) && is_array($navi['linkClasses']) && count($navi['linkClasses']) > 0 && isset($navi['linkClasses'][0]) && $navi['linkClasses'][0] != '') { $attributes['class'] = implode(' ', $navi['linkClasses']); } if (isset($navi['linkAttr']) && is_array($navi['linkAttr']) && count($navi['linkAttr']) > 0) { foreach ($navi['linkAttr'] as $key => $value) { if ($value != '') { $attributes[$key] = $value; } } } $li_a .= '<a' . rex_string::buildAttributes($attributes) . '>'; } if (isset($navi['icon']) && $navi['icon'] != '') { $li_a .= '<i class="' . $navi['icon'] . '"></i> '; } $li_a .= $navi['title']; if (isset($navi['href']) && $navi['href'] != '') { $li_a .= '</a>'; } $li_a .= '</li>'; $li[] = $li_a; } $navigations[$nav_key] = implode($li); } $out = ''; $tabs = '';