重复的网址发布参数问题

时间:2019-04-29 11:15:36

标签: php url magento-1.9

您好,有人可以帮忙为什么一次又一次发布URL字符串参数吗?

HTTP://127.0.0.1/ab/1936.html?cart=yes?cart=yes

当我们将产品添加到Magnetico 1.9的购物车中时,我会使用此参数打开迷你购物车

请帮助我如何保护它? 我正在使用此代码-

<?php
if ($_GET['cart']=='yes') {
    echo "<script type='text/javascript'>
          jQuery('.minicart_open').show();
    </script>";
}
?>

cartController.php

protected function _goBack()
{
    $returnUrl = $this->getRequest()->getParam('return_url');
   // print_r($returnUrl);exit;
    if ($returnUrl) {

        if (!$this->_isUrlInternal($returnUrl)) {
            throw new Mage_Exception('External urls redirect to "' . $returnUrl . '" denied!');
        }

        $this->_getSession()->getMessages(true);
        $this->getResponse()->setRedirect($returnUrl);
    } elseif (!Mage::getStoreConfig('checkout/cart/redirect_to_cart')
        && !$this->getRequest()->getParam('in_cart')
        && $backUrl = $this->_getRefererUrl()
    ) {
        $this->getResponse()->setRedirect($backUrl.'?cart=yes');
    } else {
        if (
            (strtolower($this->getRequest()->getActionName()) == 'add')
            && !$this->getRequest()->getParam('in_cart')
        ) {
            $this->_getSession()->setContinueShoppingUrl($this->_getRefererUrl());
        }
        $this->_redirect('checkout/cart');
    }
    return $this;
}

1 个答案:

答案 0 :(得分:0)

我得到了答案

  

只需替换下面的行

$this->getResponse()->setRedirect($backUrl.'?cart=yes');

收件人

$url = $backUrl; 
        // Search substring  
            if (strpos($url, $key) == false) { 
                 $this->getResponse()->setRedirect($backUrl.'?cart=yes');
            } 
            else { 
                 $this->getResponse()->setRedirect($backUrl);
            } 
            //exit;

它为我工作...希望对您有帮助...