/**
  * Performs a redirection
  */
 protected function redirect()
 {
     $GLOBALS['eZRedirection'] = true;
     $ini = eZINI::instance();
     $automaticRedirect = true;
     if ($GLOBALS['eZDebugAllowed'] && ($redirUri = $ini->variable('DebugSettings', 'DebugRedirection')) !== 'disabled') {
         if ($redirUri == "enabled") {
             $automaticRedirect = false;
         } else {
             $uri = eZURI::instance(eZSys::requestURI());
             $uri->toBeginning();
             foreach ($ini->variableArray("DebugSettings", "DebugRedirection") as $redirUri) {
                 $redirUri = new eZURI($redirUri);
                 if ($redirUri->matchBase($uri)) {
                     $automaticRedirect = false;
                     break;
                 }
             }
         }
     }
     $redirectURI = eZSys::indexDir();
     $moduleRedirectUri = $this->module->redirectURI();
     if ($ini->variable('URLTranslator', 'Translation') === 'enabled' && eZURLAliasML::urlTranslationEnabledByUri(new eZURI($moduleRedirectUri))) {
         $translatedModuleRedirectUri = $moduleRedirectUri;
         if (eZURLAliasML::translate($translatedModuleRedirectUri, true)) {
             $moduleRedirectUri = $translatedModuleRedirectUri;
             if (strlen($moduleRedirectUri) > 0 && $moduleRedirectUri[0] !== '/') {
                 $moduleRedirectUri = '/' . $moduleRedirectUri;
             }
         }
     }
     if (preg_match('#^(\\w+:)|^//#', $moduleRedirectUri)) {
         $redirectURI = $moduleRedirectUri;
     } else {
         $leftSlash = strlen($redirectURI) > 0 && $redirectURI[strlen($redirectURI) - 1] === '/';
         $rightSlash = strlen($moduleRedirectUri) > 0 && $moduleRedirectUri[0] === '/';
         if (!$leftSlash && !$rightSlash) {
             // Both are without a slash, so add one
             $moduleRedirectUri = '/' . $moduleRedirectUri;
         } else {
             if ($leftSlash && $rightSlash) {
                 // Both are with a slash, so we remove one
                 $moduleRedirectUri = substr($moduleRedirectUri, 1);
             }
         }
         $redirectURI .= $moduleRedirectUri;
     }
     eZStaticCache::executeActions();
     eZDB::checkTransactionCounter();
     if ($automaticRedirect) {
         eZHTTPTool::redirect($redirectURI, array(), $this->module->redirectStatus());
     } else {
         // Make sure any errors or warnings are reported
         if ($ini->variable('DebugSettings', 'DisplayDebugWarnings') === 'enabled') {
             if (isset($GLOBALS['eZDebugError']) && $GLOBALS['eZDebugError']) {
                 eZAppendWarningItem(array('error' => array('type' => 'error', 'number' => 1, 'count' => $GLOBALS['eZDebugErrorCount']), 'identifier' => 'ezdebug-first-error', 'text' => ezpI18n::tr('index.php', 'Some errors occurred, see debug for more information.')));
             }
             if (isset($GLOBALS['eZDebugWarning']) && $GLOBALS['eZDebugWarning']) {
                 eZAppendWarningItem(array('error' => array('type' => 'warning', 'number' => 1, 'count' => $GLOBALS['eZDebugWarningCount']), 'identifier' => 'ezdebug-first-warning', 'text' => ezpI18n::tr('index.php', 'Some general warnings occured, see debug for more information.')));
             }
         }
         $tpl = eZTemplate::factory();
         $tpl->setVariable('site', $this->site);
         $tpl->setVariable('warning_list', !empty($this->warningList) ? $this->warningList : false);
         $tpl->setVariable('redirect_uri', eZURI::encodeURL($redirectURI));
         $templateResult = $tpl->fetch('design:redirect.tpl');
         eZDebug::addTimingPoint("Script end");
         eZDisplayResult($templateResult);
     }
     eZExecution::cleanExit();
 }
Beispiel #2
0
    }
}
if ($module->exitStatus() == eZModule::STATUS_REDIRECT) {
    $GLOBALS['eZRedirection'] = true;
    $ini = eZINI::instance();
    $automatic_redir = true;
    if ($GLOBALS['eZDebugAllowed'] && ($redirUri = $ini->variable('DebugSettings', 'DebugRedirection')) != 'disabled') {
        if ($redirUri == "enabled") {
            $automatic_redir = false;
        } else {
            $redirUris = $ini->variableArray("DebugSettings", "DebugRedirection");
            $uri = eZURI::instance(eZSys::requestURI());
            $uri->toBeginning();
            foreach ($redirUris as $redirUri) {
                $redirUri = new eZURI($redirUri);
                if ($redirUri->matchBase($uri)) {
                    $automatic_redir = false;
                    break;
                }
            }
        }
    }
    $redirectURI = eZSys::indexDir();
    $moduleRedirectUri = $module->redirectURI();
    $redirectStatus = $module->redirectStatus();
    $translatedModuleRedirectUri = $moduleRedirectUri;
    if ($ini->variable('URLTranslator', 'Translation') == 'enabled' && eZURLAliasML::urlTranslationEnabledByUri(new eZURI($moduleRedirectUri))) {
        if (eZURLAliasML::translate($translatedModuleRedirectUri, true)) {
            $moduleRedirectUri = $translatedModuleRedirectUri;
            if (strlen($moduleRedirectUri) > 0 and $moduleRedirectUri[0] != '/') {
                $moduleRedirectUri = '/' . $moduleRedirectUri;