예제 #1
0
파일: rex_test.php 프로젝트: staabm/redaxo
 public function testGetServer()
 {
     $origServer = rex::getProperty('server');
     rex::setProperty('server', 'http://www.redaxo.org');
     $this->assertEquals('http://www.redaxo.org/', rex::getServer());
     $this->assertEquals('https://www.redaxo.org/', rex::getServer('https'));
     $this->assertEquals('www.redaxo.org/', rex::getServer(''));
     rex::setProperty('server', $origServer);
 }
예제 #2
0
파일: import.php 프로젝트: DECAF/redaxo
 public static function updateFromPrevious()
 {
     // ----- vorhandenen seite updaten
     $err_msg = '';
     if ($err_msg == '') {
         $version = rex::getVersion();
         rex::setProperty('version', rex::getConfig('version'));
         try {
             include rex_path::core('update.php');
         } catch (rex_functional_exception $e) {
             $err_msg .= $e->getMessage();
         } catch (rex_sql_exception $e) {
             $err_msg .= 'SQL error: ' . $e->getMessage();
         }
         rex::setProperty('version', $version);
     }
     if ($err_msg == '') {
         $err_msg .= self::installAddons();
     }
     return $err_msg;
 }
예제 #3
0
 public function testFactoryUrlProxy()
 {
     rex::setProperty('socket_proxy', 'proxy.example.com:8888');
     $socket = rex_socket::factoryUrl('www.example.com');
     $this->assertEquals('rex_socket_proxy', get_class($socket));
 }
예제 #4
0
    $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']);
    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();
예제 #5
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));
     }
 }
예제 #6
0
파일: backend.php 프로젝트: VIEWSION/redaxo
        $rex_user_loginmessage = $login->getMessage();
        // Fehlermeldung von der Datenbank
        if (is_string($loginCheck)) {
            $rex_user_loginmessage = $loginCheck;
        }
        $pages['login'] = rex_be_controller::getLoginPage();
        $page = 'login';
        rex_be_controller::setCurrentPage('login');
    } else {
        // Userspezifische Sprache einstellen
        $user = $login->getUser();
        $lang = $user->getLanguage();
        if ($lang && $lang != 'default' && $lang != rex::getProperty('lang')) {
            rex_i18n::setLocale($lang);
        }
        rex::setProperty('user', $user);
    }
    // Safe Mode
    if (($safeMode = rex_get('safemode', 'boolean', null)) !== null) {
        if ($safeMode) {
            rex_set_session('safemode', true);
        } else {
            rex_unset_session('safemode');
        }
    }
}
rex_be_controller::setPages($pages);
// ----- Prepare Core Pages
if (rex::getUser()) {
    rex_be_controller::appendLoggedInPages();
    rex_be_controller::setCurrentPage(trim(rex_request('page', 'string')));
예제 #7
0
파일: setup.php 프로젝트: alsahh/redaxo
         continue;
     }
     try {
         rex::setProperty($key, $config[$key]);
     } catch (InvalidArgumentException $e) {
         $error_array[] = rex_view::error(rex_i18n::msg($key . '_invalid'));
     }
 }
 foreach ($config as $key => $value) {
     if (in_array($key, $check)) {
         continue;
     }
     if (in_array($key, ['fileperm', 'dirperm'])) {
         $value = octdec($value);
     }
     rex::setProperty($key, $value);
 }
 if (count($error_array) == 0) {
     if (!rex_file::putConfig($configFile, $config)) {
         $error_array[] = rex_view::error(rex_i18n::msg('setup_401'));
     }
 }
 if (count($error_array) == 0) {
     try {
         $err = rex_setup::checkDb($config, $redaxo_db_create);
     } catch (PDOException $e) {
         $err = rex_i18n::msg('setup_415', $e->getMessage());
     }
     if ($err != '') {
         $error_array[] = rex_view::error($err);
     }
예제 #8
0
 public function setUp()
 {
     rex::setProperty('myCoreProperty', 'myCorePropertyValue');
     rex_addon::get('tests')->setProperty('myPackageProperty', 'myPackagePropertyValue');
 }
예제 #9
0
 /**
  * Creates the user object if it does not already exist.
  *
  * Helpful if you want to check permissions of the backend user in frontend.
  * If you only want to know if there is any backend session, use {@link rex_backend_login::hasSession()}.
  *
  * @return rex_user
  */
 public static function createUser()
 {
     if (!self::hasSession()) {
         return null;
     }
     if ($user = rex::getUser()) {
         return $user;
     }
     $login = new self();
     rex::setProperty('login', $login);
     if ($login->checkLogin()) {
         $user = $login->getUser();
         rex::setProperty('user', $user);
         return $user;
     }
     return null;
 }
예제 #10
0
파일: boot.php 프로젝트: skerbis/redaxo
rex_perm::register('moveArticle[]', null, rex_perm::OPTIONS);
rex_perm::register('moveCategory[]', null, rex_perm::OPTIONS);
rex_perm::register('copyArticle[]', null, rex_perm::OPTIONS);
rex_perm::register('copyContent[]', null, rex_perm::OPTIONS);
rex_perm::register('publishArticle[]', null, rex_perm::OPTIONS);
rex_perm::register('publishCategory[]', null, rex_perm::OPTIONS);
rex_perm::register('article2startarticle[]', null, rex_perm::OPTIONS);
rex_perm::register('article2category[]', null, rex_perm::OPTIONS);
rex_complex_perm::register('structure', 'rex_structure_perm');
require_once __DIR__ . '/functions/function_rex_url.php';
if (rex_request('article_id', 'int') == 0) {
    rex::setProperty('article_id', rex::getProperty('start_article_id'));
} else {
    $article_id = rex_request('article_id', 'int');
    $article_id = rex_article::get($article_id) ? $article_id : rex::getProperty('notfound_article_id');
    rex::setProperty('article_id', $article_id);
}
if (rex::isBackend() && rex::getUser()) {
    rex_view::addJsFile($this->getAssetsUrl('linkmap.js'));
    rex_extension::register('PAGE_SIDEBAR', function () {
        $category_id = rex_request('category_id', 'int');
        $article_id = rex_request('article_id', 'int');
        $clang = rex_request('clang', 'int');
        $ctype = rex_request('ctype', 'int');
        $category_id = rex_category::get($category_id) ? $category_id : 0;
        $article_id = rex_article::get($article_id) ? $article_id : 0;
        $clang = rex_clang::exists($clang) ? $clang : rex_clang::getStartId();
        // TODO - CHECK PERM
        $context = new rex_context(['page' => 'structure', 'category_id' => $category_id, 'article_id' => $article_id, 'clang' => $clang, 'ctype' => $ctype]);
        // check if a new category was folded
        $category_id = rex_request('toggle_category_id', 'int', -1);
예제 #11
0
 public static function prepare()
 {
     $clang = rex_clang::getCurrentId();
     // call_by_article allowed
     if (self::$call_by_article_id == 'allowed' && rex_request('article_id', 'int') > 0) {
         $url = rex_getUrl(rex_request('article_id', 'int'));
     } else {
         if (!isset($_SERVER['REQUEST_URI'])) {
             $_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'], 1);
             if (isset($_SERVER['QUERY_STRING'])) {
                 $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
             }
         }
         $url = urldecode($_SERVER['REQUEST_URI']);
     }
     // because of server differences
     if (substr($url, 0, 1) == '/') {
         $url = substr($url, 1);
     }
     // delete params
     if (($pos = strpos($url, '?')) !== false) {
         $url = substr($url, 0, $pos);
     }
     // delete anker
     if (($pos = strpos($url, '#')) !== false) {
         $url = substr($url, 0, $pos);
     }
     $host = self::getHost();
     $http = 'http://';
     if (self::isHttps()) {
         $http = 'https://';
     }
     if (isset(self::$paths['paths'][$host])) {
         $domain = self::$domainsByName[$host];
     } else {
         // check for aliases
         if (isset(self::$aliasDomains[$host])) {
             /** @var rex_yrewrite_domain $domain */
             $domain = self::$aliasDomains[$host]['domain'];
             if (!$url && isset(self::$paths['paths'][$domain->getName()][$domain->getStartId()][self::$aliasDomains[$host]['clang_start']])) {
                 $url = self::$paths['paths'][$domain->getName()][$domain->getStartId()][self::$aliasDomains[$host]['clang_start']];
             }
             // forward to original domain permanent move 301
             header('HTTP/1.1 301 Moved Permanently');
             header('Location: ' . $http . $domain->getName() . '/' . $url);
             exit;
             // no domain, no alias, domain with root mountpoint ?
         } elseif (isset(self::$domainsByMountId[0][$clang])) {
             $domain = self::$domainsByMountId[0][$clang];
             // no root domain -> undefined
         } else {
             $domain = self::$domainsByName['undefined'];
         }
     }
     rex::setProperty('domain_article_id', $domain->getMountId());
     rex::setProperty('start_article_id', $domain->getStartId());
     rex::setProperty('notfound_article_id', $domain->getNotfoundId());
     rex::setProperty('server', $http . $domain->getName());
     // if no path -> startarticle
     if ($url == '') {
         rex_addon::get('structure')->setProperty('article_id', $domain->getStartId());
         rex_clang::setCurrentId($domain->getStartClang());
         return true;
     }
     // normal exact check
     foreach (self::$paths['paths'][$domain->getName()] as $i_id => $i_cls) {
         foreach (rex_clang::getAllIds() as $clang_id) {
             if (isset($i_cls[$clang_id]) && ($i_cls[$clang_id] == $url || $i_cls[$clang_id] . '/' == $url)) {
                 rex_addon::get('structure')->setProperty('article_id', $i_id);
                 rex_clang::setCurrentId($clang_id);
                 return true;
             }
         }
     }
     $params = rex_extension::registerPoint(new rex_extension_point('YREWRITE_PREPARE', '', ['url' => $url, 'domain' => $domain, 'http' => $http]));
     if (isset($params['article_id']) && $params['article_id'] > 0) {
         if (isset($params['clang']) && $params['clang'] > -1) {
             $clang = $params['clang'];
         }
         if ($article = rex_article::get($params['article_id'], $clang)) {
             rex_addon::get('structure')->setProperty('article_id', $params['article_id']);
             rex_clang::setCurrentId($clang);
             return true;
         }
     }
     // no article found -> domain not found article
     rex_addon::get('structure')->setProperty('article_id', $domain->getNotfoundId());
     rex_clang::setCurrentId($domain->getStartClang());
     foreach (self::$paths['paths'][$domain->getName()][$domain->getStartId()] as $clang => $clangUrl) {
         if ($clang != $domain->getStartClang() && 0 === strpos($url, $clangUrl)) {
             rex_clang::setCurrentId($clang);
             break;
         }
     }
     return true;
 }
예제 #12
0
 protected function tearDown()
 {
     rex::setProperty('socket_proxy', $this->proxy);
 }