From fe1ac74994e7f2b63d44aed00edc477bb7b2e9fb Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Thu, 27 Aug 2015 22:49:44 +0200 Subject: [PATCH] ESI Decoder: Button to show block content. Added button to the ESI Decoder tool to show the content of the ESI block. Added auto-detect for Magento root. --- contrib/tools/esi-decoder.php | 36 ++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/contrib/tools/esi-decoder.php b/contrib/tools/esi-decoder.php index da6d093cb..7e066ac20 100644 --- a/contrib/tools/esi-decoder.php +++ b/contrib/tools/esi-decoder.php @@ -7,13 +7,21 @@ * * Make sure you place this utility on a protected spot on your web server where only authorized users can use it. * - * If the URLs you see in "varnishlog" or "varnishncsa", read this FAQ item: + * If the URLs you see in "varnishlog" or "varnishncsa" are not working because they are cut off, read this FAQ item: * https://github.com/nexcess/magento-turpentine/wiki/FAQ#im-using-varnishncsa-to-generate-logs-and-the-esi-urls-are-cut-off-how-do-i-get-the-full-url-in-the-logs * */ -// You might need to fix the path to your app/Mage.php on the line below. -require_once dirname(__FILE__).'/../../app/Mage.php'; +$tries = 5; +$dir = dirname(__FILE__); +while( $tries-- && ! file_exists( $dir . '/app/Mage.php' ) ) { + $dir = dirname($dir); // go one dir up +} +if ( file_exists( $dir . '/app/Mage.php' ) ) { + require_once $dir . '/app/Mage.php'; +} else { + die( "Could not find 'app/Mage.php'. Please edit esi-decoder.php and 'require' it manually." ); +} Mage::app(); $data = ( empty($_REQUEST['data']) ) ? '' : $_REQUEST['data']; @@ -69,7 +77,12 @@ } $dataHelper = Mage::helper( 'turpentine/data' ); $esiDataArray = $dataHelper->thaw( $processData ); -?> + $showContentUrl = Mage::getUrl( 'turpentine/esi/getBlock', + array( 'method' => 'esi', + 'ttl' => 0, + 'hmac' => $dataHelper->getHmac( $processData ), + 'data' => $processData ) ); + ?>
=  DATA  =
@@ -78,14 +91,19 @@ $refPreg = preg_quote( $esiHelper->getEsiReferrerParam(), '|' ); if ( preg_match('|'.$refPreg.'/([\w\.\-]+),*|', $data, $matches) ): $processData = $matches[1]; + ?> +
=  REFERRER  =
+
+
urlBase64Decode( $processData ) ); ?>
+
+ -
=  REFERRER  =
-
-
urlBase64Decode( $processData ) ); ?>
+
+