lib/ezutils/classes/ezmodule.php
function redirectTo( $uri )
    {
        $originalURI = $uri;
        $uri = preg_replace( "#(^.*)(/+)$#", "\$1", $uri );
        if ( strlen( $originalURI ) != 0 and
             strlen( $uri ) == 0 )
            $uri = '/';

        $urlComponents = parse_url( $uri );
        // eZSys::hostname() can contain port if present.
        // So parsing it with parse_url() as well to only get host.
        $currentHostname = eZSys::hostname();
        $currentHostnameParsed = parse_url( $currentHostname, PHP_URL_HOST );
        $currentHostname = $currentHostnameParsed ? $currentHostnameParsed : $currentHostname;
        if ( isset( $urlComponents['host'] ) && $urlComponents['host'] !== $currentHostname )
        {
            $allowedHosts = $this->getAllowedRedirectHosts();
            if ( !isset( $allowedHosts[$urlComponents['host']] ) )
            {
                // Non-authorized host, return only the URI (without host) + query string and fragment if present.
                eZDebug::writeError( "Redirection requested on non-authorized host '{$urlComponents['host']}'" );
                header( $_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden' );
                echo "Redirection requested on non-authorized host";
                eZDB::checkTransactionCounter();
                eZExecution::cleanExit();
            }
        }

        $this->RedirectURI = $uri;
        $this->setExitStatus( self::STATUS_REDIRECT );
    }
function redirectTo( $uri )
    {
        $originalURI = $uri;
        $uri = preg_replace( "#(^.*)(/+)$#", "\$1", $uri );
        if ( strlen( $originalURI ) != 0 and
             strlen( $uri ) == 0 )
            $uri = '/';

        $urlComponents = parse_url( $uri );
        // eZSys::hostname() can contain port if present.
        // So parsing it with parse_url() as well to only get host.
        $currentHostname = eZSys::hostname();
        $currentHostnameParsed = parse_url( $currentHostname, PHP_URL_HOST );
        $currentHostname = $currentHostnameParsed ? $currentHostnameParsed : $currentHostname;
        if ( isset( $urlComponents['host'] ) && $urlComponents['host'] !== $currentHostname )
        {
            $allowedHosts = $this->getAllowedRedirectHosts();
            if ( !isset( $allowedHosts[$urlComponents['host']] ) )
            {
                // Non-authorized host, return only the URI (without host) + query string and fragment if present.
                eZDebug::writeError( "Redirection requested on non-authorized host '{$urlComponents['host']}'" );
                header( $_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden' );
                echo "Redirection requested on non-authorized host";
                eZDB::checkTransactionCounter();
                eZExecution::cleanExit();
            }
        }

        $this->RedirectURI = $uri;
        $this->setExitStatus( self::STATUS_REDIRECT );
    }
function redirectTo ( $ uri ) { $ originalURI = $ uri ; $ uri = preg_replace ( "#(^.*)(/+)$#" , "\$1" , $ uri ) ; if ( strlen ( $ originalURI ) != 0 and strlen ( $ uri ) == 0 ) $ uri = '/' ; $ urlComponents = parse_url ( $ uri ) ; // eZSys::hostname() can contain port if present. // So parsing it with parse_url() as well to only get host. $ currentHostname = eZSys :: hostname ( ) ; $ currentHostnameParsed = parse_url ( $ currentHostname , PHP_URL_HOST ) ; $ currentHostname = $ currentHostnameParsed ? $ currentHostnameParsed : $ currentHostname ; if ( isset ( $ urlComponents [ 'host' ] ) && $ urlComponents [ 'host' ] !== $ currentHostname ) { $ allowedHosts = $ this -> getAllowedRedirectHosts ( ) ; if ( ! isset ( $ allowedHosts [ $ urlComponents [ 'host' ] ] ) ) { // Non-authorized host, return only the URI (without host) + query string and fragment if present. eZDebug :: writeError ( "Redirection requested on non-authorized host '{$urlComponents['host']}'" ) ; header ( $ _SERVER [ 'SERVER_PROTOCOL' ] . ' 403 Forbidden' ) ; echo "Redirection requested on non-authorized host" ; eZDB :: checkTransactionCounter ( ) ; eZExecution :: cleanExit ( ) ; } } $ this -> RedirectURI = $ uri ; $ this -> setExitStatus ( self :: STATUS_REDIRECT ) ; }
Sets the module to redirect at the end of the execution

@param string $uri the URI to redirect to

@see setRedirectURI(), setExitStatus()

@return void
Sets the module to redirect at the end of the execution