您的位置:首页 > 产品设计 > UI/UE

Requested scripts may not include parent directory

2015-10-27 13:33 302 查看

ZF中

<?php
/**
 * zend framework
 */
class IndexController extends Zend_Controller_Action {

    function indexAction() {     
    
    }
    
index.phtml
<?php echo $this->render('../../../common/header.phtml'); ?>
hello world
[/code]

整个异常如下:

Fatal error: Uncaught exception 'Zend_View_Exception' with message 'Requested scripts may not include parent directory traversal ("../", "..\" notation)' in D:\xyj\vancelle_beta\library\Zend\View\Abstract.php:966 Stack trace: #0 D:\xyj\vancelle_beta\library\Zend\View\Abstract.php(884): Zend_View_Abstract->_script('../../../common...') #1 D:\xyj\vancelle_beta\application\app4crm\default\views\scripts\index\index.phtml(1): Zend_View_Abstract->render('../../../common...') #2 D:\xyj\vancelle_beta\library\Zend\View.php(157): include('D:\xyj\vancelle...') #3 D:\xyj\vancelle_beta\library\Zend\View\Abstract.php(888): Zend_View->_run('D:/xyj/vancelle...') #4 D:\xyj\vancelle_beta\library\Zend\Controller\Action\Helper\ViewRenderer.php(912): Zend_View_Abstract->render('index/index.pht...') #5 D:\xyj\vancelle_beta\library\Zend\Controller\Action\Helper\ViewRenderer.php(933): Zend_Controller_Action_Helper_ViewRenderer->renderScript('index/index.pht...', NULL) #6 D:\xyj\vancelle_beta\library\Zend\Controller\Action\Helper\ViewRenderer.php in D:\xyj\vancelle_beta\library\Zend\View\Abstract.php on line 966
[/code]

经过百般google,发现原因是由于相对路径所对应的不止一个目录,肯定是为了安全,但是有时候又为了兼容性,我们需要禁用。

class IndexController extends Zend_Controller_Action {

    function indexAction() {
      $this->view->setLfiProtection(false);
    }
[/code]

这是第一种方式。

第二种方式 就是最常见的

class IndexController extends Zend_Controller_Action {

    function indexAction() {
       $this->view->addScroptPath(APPLICATION_ROOT.'/common/');
    }
index.phtml
<?php echo $this->render('header.phtml'); ?>
[/code]

转载于:https://my.oschina.net/u/1249595/blog/522576

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐