Example #1
0
 /**
  * Performs PDF content generation and caching
  *
  * @param $url                 	 String    URL
  * @param $denisty               Integer   
  * @param $keys                  Mixed     Keys for Cache key(s) - either as a string or an array of strings
  * @param $subtree_expiry        Mixed     The parameter $subtreeExpiryParameter is expiry value is usually taken
  *                                         from the template operator and can be one of:
  *                                           - A numerical value which represents the node ID (the fastest approach)
  *                                           - A string containing 'content/view/full/xxx' where xx is the node ID number,
  *                                             the number will be extracted.
  *                                           - A string containing a nice url which will be decoded into a node ID using
  *                                             the database (slowest approach).
  * @param $expiry                Integer   The number of seconds that the pdf cache should be allowed to live.A value of
  *                                         zero will produce a cache block that will never expire
  * @param $ignore_content_expiry Boolean   Disables cache expiry when new content is published.
  * @return void
  */
 public function getObject($url = '', $density, $keys, $subtree_expiry, $expiry, $ignore_content_expiry = false)
 {
     $pngUrl = '';
     $obj = false;
     $mtime = eZDateTime::currentTimeStamp();
     $httpExpiry = $this->cacheTTL;
     if (strpos("://", $url) === false) {
         $url = eZSys::serverURL() . $url;
     }
     //eZDebug::writeError($url, 'sPdf2png::exportPng');
     if ($this->cacheEnabled) {
         $use_global_expiry = !$ignore_content_expiry;
         //$keys = self::getCacheKeysArray($keys);
         $expiry = is_numeric($expiry) ? $expiry : $this->cacheTTL;
         list($handler, $pngUrl) = eZTemplateCacheBlock::retrieve($keys, $subtree_expiry, $expiry, $use_global_expiry);
         if ($pngUrl instanceof eZClusterFileFailure || !file_get_contents($pngUrl)) {
             eZDebug::writeError("cache invalid", 'sPdf2png::exportPng');
             $obj = $this->generatePng($url, $density, $keys);
             $handler->storeCache(array('scope' => 'template-block', 'binarydata' => $obj['url']));
         }
         //eZDebug::writeError("cache", 'sPdf2png::exportPng');
     } else {
         $obj = $this->generatePng($url, $density, $keys);
     }
     if (!$obj) {
         $obj = $this->getPngData($pngUrl);
     }
     $obj['url'] = self::getWwwDir() . $obj['url'];
     return $obj;
 }
 /**
  * Returns part of the data for the attribute
  *
  * @param string $dataMember
  *
  * @return string
  */
 public function getDataMember($dataMember)
 {
     if ($dataMember === 'related_images') {
         $images = array();
         $relations = $this->ContentObjectAttribute->attribute('content');
         foreach ($relations['relation_list'] as $relation) {
             $object = eZContentObject::fetch($relation['contentobject_id']);
             if ($object instanceof eZContentObject) {
                 $dataMap = $object->attribute('data_map');
                 foreach ($dataMap as $attribute) {
                     /** @var eZContentObjectAttribute $attribute */
                     if ($attribute->attribute('data_type_string') !== eZImageType::DATA_TYPE_STRING) {
                         continue;
                     }
                     if ($attribute->hasContent()) {
                         $imageAliasHandler = $attribute->attribute('content');
                         $imageAlias = $imageAliasHandler->imageAlias('opengraph');
                         if ($imageAlias['is_valid'] == 1) {
                             $images[] = eZSys::serverURL() . '/' . $imageAlias['full_path'];
                         }
                     }
                 }
             }
         }
         if (empty($images)) {
             $images[] = eZSys::serverURL() . eZURLOperator::eZImage(null, 'opengraph_default_image.png', '');
         }
         return $images;
     }
     return $this->getData();
 }
Example #3
0
 /**
  * Returns data for the attribute
  *
  * @return string
  */
 public function getData()
 {
     if ($this->ContentObjectAttribute->hasContent()) {
         $imageAliasHandler = $this->ContentObjectAttribute->attribute('content');
         $imageAlias = $imageAliasHandler->imageAlias('opengraph');
         if ($imageAlias['is_valid'] == 1) {
             return eZSys::serverURL() . '/' . $imageAlias['full_path'];
         }
     }
     return eZSys::serverURL() . eZURLOperator::eZImage(null, 'opengraph_default_image.png', '');
 }
Example #4
0
 function createRedirectionUrl($process)
 {
     //__DEBUG__
     $this->logger->writeTimedString("createRedirectionUrl");
     //___end____
     $paypalINI = eZINI::instance('paypal.ini');
     $paypalServer = $paypalINI->variable('ServerSettings', 'ServerName');
     $requestURI = $paypalINI->variable('ServerSettings', 'RequestURI');
     $business = urlencode($paypalINI->variable('PaypalSettings', 'Business'));
     $processParams = $process->attribute('parameter_list');
     $orderID = $processParams['order_id'];
     $indexDir = eZSys::indexDir();
     $localHost = eZSys::serverURL();
     $localURI = eZSys::serverVariable('REQUEST_URI');
     $order = eZOrder::fetch($orderID);
     $amount = urlencode($order->attribute('total_inc_vat'));
     $currency = urlencode($order->currencyCode());
     //        include_once( 'lib/ezlocale/classes/ezlocale.php' );
     $locale = eZLocale::instance();
     $countryCode = urlencode($locale->countryCode());
     $maxDescLen = $paypalINI->variable('PaypalSettings', 'MaxDescriptionLength');
     $itemName = urlencode($this->createShortDescription($order, $maxDescLen));
     $accountInfo = $order->attribute('account_information');
     $first_name = urlencode($accountInfo['first_name']);
     $last_name = urlencode($accountInfo['last_name']);
     $street = urlencode($accountInfo['street2']);
     $zip = urlencode($accountInfo['zip']);
     $state = urlencode($accountInfo['state']);
     $place = urlencode($accountInfo['place']);
     $image_url = "{$localHost}" . urlencode($paypalINI->variable('PaypalSettings', 'LogoURI'));
     $background = urlencode($paypalINI->variable('PaypalSettings', 'BackgroundColor'));
     $pageStyle = urlencode($paypalINI->variable('PaypalSettings', 'PageStyle'));
     $noNote = urlencode($paypalINI->variable('PaypalSettings', 'NoNote'));
     $noteLabel = $noNote == 1 ? '' : urlencode($paypalINI->variable('PaypalSettings', 'NoteLabel'));
     $noShipping = 1;
     $url = $paypalServer . $requestURI . "?cmd=_ext-enter" . "&redirect_cmd=_xclick" . "&business={$business}" . "&item_name={$itemName}" . "&custom={$orderID}" . "&amount={$amount}" . "&currency_code={$currency}" . "&first_name={$first_name}" . "&last_name={$last_name}" . "&address1={$street}" . "&zip={$zip}" . "&state={$state}" . "&city={$place}" . "&image_url={$image_url}" . "&cs={$background}" . "&page_style={$pageStyle}" . "&no_shipping={$noShipping}" . "&cn={$noteLabel}" . "&no_note={$noNote}" . "&lc={$countryCode}" . "&notify_url={$localHost}" . $indexDir . "/paypal/notify_url/" . "&return={$localHost}" . $indexDir . "/shop/checkout/" . "&cancel_return={$localHost}" . $indexDir . "/shop/basket/";
     //__DEBUG__
     $this->logger->writeTimedString("business       = {$business}");
     $this->logger->writeTimedString("item_name      = {$itemName}");
     $this->logger->writeTimedString("custom         = {$orderID}");
     $this->logger->writeTimedString("no_shipping    = {$noShipping}");
     $this->logger->writeTimedString("localHost      = {$localHost}");
     $this->logger->writeTimedString("amount         = {$amount}");
     $this->logger->writeTimedString("currency_code  = {$currency}");
     $this->logger->writeTimedString("notify_url     = {$localHost}" . $indexDir . "/paypal/notify_url/");
     $this->logger->writeTimedString("return         = {$localHost}" . $indexDir . "/shop/checkout/");
     $this->logger->writeTimedString("cancel_return  = {$localHost}" . $indexDir . "/shop/basket/");
     //___end____
     return $url;
 }
<?php

/* @type $Params string[] */

$nodeID = $Params['nodeID'];
$node   = eZContentObjectTreeNode::fetch($nodeID);

header('Pragma: no-cache');
header('cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
//TODO add context to login
if(MMUsers::isAnonymous(MMUsers::getCurrentUserId()))
{
    $host = eZSys::serverURL();
    $siteIni = eZINI::instance( 'site.ini' );
    $loginUrl = preg_replace('#^https?//[^/]+#', '', $siteIni->variable('SiteSettings', 'LoginPage'));
    $context = $host . '/esibuild/download/' . $nodeID;
    header( 'Location: ' . $loginUrl . '?context='.urlencode($context) );
    eZExecution::cleanExit();
}

//test if application allow download
if(!SecurityTool::getFileApplicationCanRead($node))
{
    header('HTTP/1.1 403 Forbidden');
    echo "<h1>Forbidden access</h1>\n";
    eZExecution::cleanExit();
}

if($node)
{
 /**
  * Handles redirection to the mobile optimized interface
  *
  */
 public function redirect()
 {
     $http = eZHTTPTool::instance();
     $currentSiteAccess = eZSiteAccess::current();
     if ($http->hasGetVariable('notmobile')) {
         setcookie('eZMobileDeviceDetect', 1, time() + (int) eZINI::instance()->variable('SiteAccessSettings', 'MobileDeviceDetectCookieTimeout'), '/');
         $http->redirect(eZSys::indexDir());
         eZExecution::cleanExit();
     }
     if (!isset($_COOKIE['eZMobileDeviceDetect']) && !in_array($currentSiteAccess['name'], eZINI::instance()->variable('SiteAccessSettings', 'MobileSiteAccessList'))) {
         $currentUrl = eZSys::serverURL() . eZSys::requestURI();
         $redirectUrl = eZINI::instance()->variable('SiteAccessSettings', 'MobileSiteAccessURL');
         // Do not redirect if already on the redirect url
         if (strpos($currentUrl, $redirectUrl) !== 0) {
             // Default siteaccess name needs to be removed from the uri when redirecting
             $uri = explode('/', ltrim(eZSys::requestURI(), '/'));
             if (array_shift($uri) == $currentSiteAccess['name']) {
                 $http->redirect($redirectUrl . '/' . implode('/', $uri));
             } else {
                 $http->redirect($redirectUrl . eZSys::requestURI());
             }
         }
         eZExecution::cleanExit();
     }
 }
 /**
  *  Make image and css urls relative to ezpublish root directory
  *
  * @param $html String
  * @param $absolute Boolean Generate absolute urls
  * @return String html with fixed urls
  */
 private function fixURL($html, $relative = false)
 {
     $base_url = $relative ? '../..' : eZSys::serverURL();
     $htmlfixed = preg_replace('#(<\\s*(img|link)\\s+[^>]*(href|src)\\s*=\\s*["\'])/?([^:"\'>]*)(["\'])#i', '$1' . $base_url . '/$4$5', $html);
     #$htmlfixed = preg_replace('#(@import)?\s*(url)?\s*(\()?\s*["\']/?([^"\'\);]*)["\']?\s*(\))?\s*;#i','$1 $2 $3"'.$base_url.'/$4"$5',$htmlfixed);
     return $htmlfixed;
 }
    /**
     * @return string
     */
    public function domain()
    {
        $serverUrl = eZSys::serverURL();

        // we were redirected by varnish on the mobile version - we need to trick a little
        if( isset( $_SERVER['HTTP_X_REQ_HOST'] ) )
        {
            $serverUrl = 'http://'.$_SERVER['HTTP_X_REQ_HOST'];
        }

        return $serverUrl;
    }