// Blocklayered Fix bug with SSL

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12926 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
mDeflotte
2012-02-02 10:48:48 +00:00
parent cca93f2c6d
commit 9136bc5ddb
4 changed files with 26 additions and 15 deletions
@@ -1,7 +1,6 @@
<?php <?php
include(dirname(__FILE__).'/../../config/config.inc.php'); include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
include(dirname(__FILE__).'/blocklayered.php'); include(dirname(__FILE__).'/blocklayered.php');
if (substr(Tools::encrypt('blocklayered/index'),0,10) != Tools::getValue('token') || !Module::isInstalled('blocklayered')) if (substr(Tools::encrypt('blocklayered/index'),0,10) != Tools::getValue('token') || !Module::isInstalled('blocklayered'))
@@ -1,13 +1,11 @@
<?php <?php
include(dirname(__FILE__).'/../../config/config.inc.php'); include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
include(dirname(__FILE__).'/blocklayered.php'); include(dirname(__FILE__).'/blocklayered.php');
if (substr(Tools::encrypt('blocklayered/index'),0,10) != Tools::getValue('token') || !Module::isInstalled('blocklayered')) if (substr(Tools::encrypt('blocklayered/index'),0,10) != Tools::getValue('token') || !Module::isInstalled('blocklayered'))
die('Bad token'); die('Bad token');
if (!Tools::getValue('ajax')) if (!Tools::getValue('ajax'))
{ {
// Case of nothing to do but showing a message (1) // Case of nothing to do but showing a message (1)
@@ -17,10 +15,15 @@ if (!Tools::getValue('ajax'))
die(); die();
} }
if (Tools::usingSecureMode())
$domain = Tools::getShopDomainSsl(true);
else
$domain = Tools::getShopDomain(true);
// Return a content without waiting the end of index execution // Return a content without waiting the end of index execution
header('Location: '.Tools::getProtocol().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-price-indexer.php?token='.Tools::getValue('token') .'&return_message='.(int)Tools::getValue('cursor')); header('Location: '.$domain.__PS_BASE_URI__.'modules/blocklayered/blocklayered-price-indexer.php?token='.Tools::getValue('token') .'&return_message='.(int)Tools::getValue('cursor'));
flush(); flush();
} }
if(Tools::getValue('full')) if(Tools::getValue('full'))
{ {
echo BlockLayered::fullPricesIndexProcess((int)Tools::getValue('cursor'), (int)Tools::getValue('ajax'), true); echo BlockLayered::fullPricesIndexProcess((int)Tools::getValue('cursor'), (int)Tools::getValue('ajax'), true);
@@ -1,7 +1,6 @@
<?php <?php
include(dirname(__FILE__).'/../../config/config.inc.php'); include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
include(dirname(__FILE__).'/blocklayered.php'); include(dirname(__FILE__).'/blocklayered.php');
if (substr(Tools::encrypt('blocklayered/index'),0,10) != Tools::getValue('token') || !Module::isInstalled('blocklayered')) if (substr(Tools::encrypt('blocklayered/index'),0,10) != Tools::getValue('token') || !Module::isInstalled('blocklayered'))
+19 -9
View File
@@ -930,7 +930,12 @@ class BlockLayered extends Module
if (($nbProducts > 0 && !$full || $cursor < $nbProducts && $full) && !$ajax) if (($nbProducts > 0 && !$full || $cursor < $nbProducts && $full) && !$ajax)
{ {
$token = substr(Tools::encrypt('blocklayered/index'), 0, 10); $token = substr(Tools::encrypt('blocklayered/index'), 0, 10);
if (!Tools::file_get_contents(Tools::getCurrentUrlProtocolPrefix().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-price-indexer.php?token='.$token.'&cursor='.(int)$cursor.'&full='.(int)$full)) if (Tools::usingSecureMode())
$domain = Tools::getShopDomainSsl(true);
else
$domain = Tools::getShopDomain(true);
if (!Tools::file_get_contents($domain.__PS_BASE_URI__.'modules/blocklayered/blocklayered-price-indexer.php?token='.$token.'&cursor='.(int)$cursor.'&full='.(int)$full))
self::indexPrices((int)$cursor, (int)$full); self::indexPrices((int)$cursor, (int)$full);
return $cursor; return $cursor;
} }
@@ -1396,7 +1401,7 @@ class BlockLayered extends Module
'.(version_compare(_PS_VERSION_,'1.5','>') ? '' : '<img src="../img/admin/ok2.png" alt="" />').'<span class="message"></span> '.(version_compare(_PS_VERSION_,'1.5','>') ? '' : '<img src="../img/admin/ok2.png" alt="" />').'<span class="message"></span>
</div> </div>
<div id="ajax-message-ko" class="error ajax-message" style="display: none"> <div id="ajax-message-ko" class="error ajax-message" style="display: none">
'.(version_compare(_PS_VERSION_,'1.5','>') ? '' : '<img src="../img/admin/ok2.png" alt="" />').'<span class="message"></span> '.(version_compare(_PS_VERSION_,'1.5','>') ? '' : '<img src="../img/admin/errors.png" alt="" />').'<span class="message"></span>
</div> </div>
<h2>'.$this->l('Layered navigation').'</h2> <h2>'.$this->l('Layered navigation').'</h2>
<fieldset class="width4"> <fieldset class="width4">
@@ -1418,36 +1423,41 @@ class BlockLayered extends Module
if ($category['id_category'] != 1) if ($category['id_category'] != 1)
$categoryList[] = $category['id_category']; $categoryList[] = $category['id_category'];
if (Tools::usingSecureMode())
$domain = Tools::getShopDomainSsl(true);
else
$domain = Tools::getShopDomain(true);
$html .= ' $html .= '
<a class="bold ajaxcall-recurcive" <a class="bold ajaxcall-recurcive"
style="width: 250px; text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px" style="width: 250px; text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px"
href="'.Tools::getCurrentUrlProtocolPrefix().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-price-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'">'. href="'.$domain.__PS_BASE_URI__.'modules/blocklayered/blocklayered-price-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'">'.
$this->l('Index all missing prices').'</a> $this->l('Index all missing prices').'</a>
<br /> <br />
<a class="bold ajaxcall-recurcive" <a class="bold ajaxcall-recurcive"
style="width: 250px; text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px" id="full-index" style="width: 250px; text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px" id="full-index"
href="'.Tools::getCurrentUrlProtocolPrefix().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-price-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&full=1">'. href="'.$domain.__PS_BASE_URI__.'modules/blocklayered/blocklayered-price-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&full=1">'.
$this->l('Re-build entire price index').'</a> $this->l('Re-build entire price index').'</a>
<br /> <br />
<a class="bold ajaxcall" id="attribute-indexer" <a class="bold ajaxcall" id="attribute-indexer"
style="width: 250px; text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px" id="full-index" style="width: 250px; text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px" id="full-index"
href="'.Tools::getCurrentUrlProtocolPrefix().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-attribute-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'">'. href="'.$domain.__PS_BASE_URI__.'modules/blocklayered/blocklayered-attribute-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'">'.
$this->l('Build attribute index').'</a> $this->l('Build attribute index').'</a>
<br /> <br />
<a class="bold ajaxcall" id="url-indexer" <a class="bold ajaxcall" id="url-indexer"
style="width: 250px; text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px" id="full-index" style="width: 250px; text-align:center;display:block;border:1px solid #aaa;text-decoration:none;background-color:#fafafa;color:#123456;margin:2px;padding:2px" id="full-index"
href="'.Tools::getCurrentUrlProtocolPrefix().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-url-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&truncate=1">'. href="'.$domain.__PS_BASE_URI__.'modules/blocklayered/blocklayered-url-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&truncate=1">'.
$this->l('Build url index').'</a> $this->l('Build url index').'</a>
<br /> <br />
<br /> <br />
'.$this->l('You can set a cron job that will re-build price index using the following URL:').'<br /><b>'. '.$this->l('You can set a cron job that will re-build price index using the following URL:').'<br /><b>'.
Tools::getCurrentUrlProtocolPrefix().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-price-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&full=1</b> $domain.__PS_BASE_URI__.'modules/blocklayered/blocklayered-price-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&full=1</b>
<br /> <br />
'.$this->l('You can set a cron job that will re-build url index using the following URL:').'<br /><b>'. '.$this->l('You can set a cron job that will re-build url index using the following URL:').'<br /><b>'.
Tools::getCurrentUrlProtocolPrefix().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-url-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&truncate=1</b> $domain.__PS_BASE_URI__.'modules/blocklayered/blocklayered-url-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&truncate=1</b>
<br /> <br />
'.$this->l('You can set a cron job that will re-build attribute index using the following URL:').'<br /><b>'. '.$this->l('You can set a cron job that will re-build attribute index using the following URL:').'<br /><b>'.
Tools::getCurrentUrlProtocolPrefix().Tools::getHttpHost().__PS_BASE_URI__.'modules/blocklayered/blocklayered-attribute-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'</b> $domain.__PS_BASE_URI__.'modules/blocklayered/blocklayered-attribute-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'</b>
<br /><br /> <br /><br />
'.$this->l('A nightly rebuild is recommended.').' '.$this->l('A nightly rebuild is recommended.').'
<script type="text/javascript"> <script type="text/javascript">