/**
     * Add a decimal hash in the banner path (to force browser cache expiry)
     * ONLY FOR BANNER !
     * ie: "/esibuild/banner/just-published/small/cluster_uk.png" => "/esibuild/banner/just-published/small/cluster_uk.15251848.png"
     * @param string $bannerPath
     * @return  string
     */
    public static function bannerDecHash( $bannerPath )
    {
        if ( !empty($bannerPath) )
        {
            $ini = eZINI::instance();
            if ( $ini->hasVariable('DesignSettings', 'DynamicImageSuffix') && ( $ini->variable('DesignSettings', 'DynamicImageSuffix') == 'enabled' ) )
            {
                $bannerPathArray = explode('/', $bannerPath);
                if ( isset($bannerPathArray[3]) && !empty($bannerPathArray[3]) && isset($bannerPathArray[4]) && !empty($bannerPathArray[4]) )
                {
                    $applicationIdentifier = $bannerPathArray[3];
                    $bannerType = $bannerPathArray[4];

                    $clusterIdentifier = ClusterTool::clusterIdentifier();
                    $staticFilePath = BannerPathTool::getStaticPath( $clusterIdentifier, $applicationIdentifier, $bannerType );

                    return self::addDecHash($bannerPath, $staticFilePath);
                }
            }
        }

        return $bannerPath;
    }
Example #2
0
$end                   = strrpos( $clusterAndExtension, '.png');
$clusterIdentifier     = $clusterAndExtension;

if ( !$end )
{
    $clusterIdentifier = substr($cluster, $start, $end - $start);
}
// make sure cluster identifier is correct.
if ( !in_array( $clusterIdentifier, $properClusters ) )
{
    $clusterIdentifier = ClusterTool::clusterIdentifier();
}

if( $applicationIdentifier && $bannerType )
{
    $filename = BannerPathTool::getStaticPath($clusterIdentifier, $applicationIdentifier, $bannerType);
    if( !empty($filename) && file_exists($filename) )
    {
        if (strrpos($filename, 'png', strlen($filename) - 3)) {
            header( 'Content-type: image/png' );
        }
        else {
            header( 'Content-type: image/jpeg' );
        }
        header( 'Content-Length: '.filesize($filename) );
        readfile( $filename );
        eZExecution::cleanExit();
    }
}

header( 'HTTP/1.0 404 Not Found' );