Ejemplo n.º 1
0
require_once rex_path::core('functions/function_rex_other.php');
// ----------------- VERSION
rex::setProperty('version', '5.0.0-alpha7');
$cacheFile = rex_path::cache('config.yml.cache');
$configFile = rex_path::data('config.yml');
if (file_exists($cacheFile) && file_exists($configFile) && filemtime($cacheFile) >= filemtime($configFile)) {
    $config = rex_file::getCache($cacheFile);
} else {
    $config = array_merge(rex_file::getConfig(rex_path::core('default.config.yml')), rex_file::getConfig($configFile));
    rex_file::putCache($cacheFile, $config);
}
foreach ($config as $key => $value) {
    if (in_array($key, ['fileperm', 'dirperm'])) {
        $value = octdec($value);
    }
    rex::setProperty($key, $value);
}
date_default_timezone_set(rex::getProperty('timezone', 'Europe/Berlin'));
if (!rex::isSetup()) {
    rex_error_handler::register();
}
// ----------------- REX PERMS
rex_complex_perm::register('clang', 'rex_clang_perm');
// ----- SET CLANG
if (!rex::isSetup()) {
    rex_clang::setCurrentId(rex_request('clang', 'int', rex_clang::getStartId()));
}
if (isset($REX['LOAD_PAGE']) && $REX['LOAD_PAGE']) {
    unset($REX);
    require rex_path::core(rex::isBackend() ? 'backend.php' : 'frontend.php');
}
Ejemplo n.º 2
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;
 }