2014-12-04 52 views
2

我已更改 中的magento代码C:\ xampp \ htdocs \ magento \ app \ design \ frontend \ mypackage \ mytheme \ template \ catalog \ product \ list.phtml C:\ xampp \ htdocs \ magento \ app \ design \ frontend \ mypackage \ mytheme \ template \ catalog \ product \ price.phtmlMagento隐藏购物篮和价格注入

仅在用户登录时才显示价格并且隐藏购物篮按钮和价格当一个产品0.00价格 我的问题是,我不希望用户使用注入方法绕过这个,所以我的问题是我的代码vurnerable到SQL注入?

<!-- To hide price if price is 0 if not display the details --> 
       <?php if($_product->price==0): ?> 
    <?php echo ''; ?> 
    <?php else: ?> 
    <?php echo $this->getPriceHtml($_product, true) ?> 
    <?php endif; ?> 

       <div class="actions"> 
       <!-- To hide the shopping basket --> 
    <?php if (Mage::getSingleton('customer/session')->isLoggedIn()): ?> 
        <?php if($_product->isSaleable() && ($_product->price>0)): ?> 
         <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button> 
        <?php else: ?> 
         <p class="availability out-of-stock"><span><?php echo $this->__('Auf anfrage') ?></span></p> 
        <?php endif; ?> 
    <!-- if they are not logged in then -->    
<?php else: ?> 
<p class="nurfuer"><span><?php echo 'only for registered users'?></span></p> 
<p class="nurfuer"><span><?php echo 'please register'?></span></p> 
<?php endif; ?> 

,并在price.phtml文件我添加

<?php if (Mage::getSingleton('customer/session')->isLoggedIn()) { ?> 
and at the end of the file 
<?php } ?> 

回答

0

有一个在你的方法没有SQL,所以按理说,这个代码是不可行的SQL注入。

回答潜在的问题;

用户尚未登录,仍然可以将产品添加到购物篮或 查看价格?

你没有做任何事情来阻止用户使用直接url来实现某个目标。当您将商品添加到购物篮时,您会调用某个网址。用户仍然可以调用这样的URL来添加一些东西到他们的篮子里。当人们想要查看他们的购物篮时,他们会调用一个url,但仍然可以调用...

要真正确定,您还必须对控制器/操作进行“登录”检查。