YII:访问规则不适用于Chrome但不适用于Firefox

时间:2014-07-11 16:50:30

标签: php google-chrome firefox yii

我使用最新版本的YII v1.1.14: 我使用以下代码创建控制器:

class MyController extends CController
{

    public $layout='//layouts/column1';


    public $menu=array();

    public $breadcrumbs=array();
    public $resourceUrl = '';
    public $pageTitle = '' ;
    public $pageSubTitle = '';
    public $baseUrl = '' ;
    public $themeUrl ='';
    public $additionalJS = '' ;
    public $currentMenu = '' ; // for menu highlighting (use small case)


    public function init(){
        $this->themeUrl = YII::app()->theme->baseUrl;
        $this->resourceUrl = YII::app()->theme->baseUrl.'/resources/';
        $this->pageTitle = strtoupper(Yii::app()->controller->id) ;
        $this->baseUrl = YII::app()->baseUrl;
        $this->currentMenu = 'home';
    }

    public function isCurrentMenu($topic){
        if($this->currentMenu == $topic)
            return 'current-menu-item';
    }
}


class DashboardController extends MyController
{
    public $active = 'dashboard';
    public $pageTitle = 'Dashboard';
    public $pageSubTitle = 'manage your inventory and all stuff';
    public $layout = '//layouts/dashboard';

    public function filters()
    {
        return array( 'accessControl' ); // perform access control for CRUD operations
    }

    public function accessRules()
    {
        return array(
            array('allow', // allow authenticated user to perform 'create' and 'update' actions
                'actions'=>array('index','createStuff'),
                'roles'=>array('user'),
                //'expression'=>'Yii::app()->user->roles== "admin"',
                //'users'=>array('@'),
            ),
            array('allow', // allow admin user to perform 'admin' and 'delete' actions
                'actions'=>array('delete'),
                'roles'=>array('admin'),
            ),
            array('allow', // allow admin user to perform 'admin' and 'delete' actions
                'actions'=>array('indxex'),
                'users'=>array('@'),
            ),
            array('deny',  // deny all users
                'users'=>array('*'),
            ),
        );
    }

    public function actionCreateStuff()
    {
        $this->render('createStuff');
    }

    public function actionIndex()
    {
        //echo Yii::app()->user->checkAccess('user');exit;
        $this->render('index',array());
    }

....

}

在main.php中

'user'=>array(
            // enable cookie-based authentication
            'class'=>'WebUser',
            'allowAutoLogin'=>true,
            'loginUrl'=>array('site/login'),
            'returnUrl'=>array('dashboard/index'),
        ),

当我尝试使用谷歌浏览器访问该页面时,访问规则不起作用,它只允许访问该页面...但是使用Mozilla Firefox,它通过首先登录到登录页面做了​​正确的事情。

如何在chrome上调试此错误?

错误页面:(为了更好地查看https://www.dropbox.com/s/ceg1o06n8bj4vk5/PHP%20notice.pdf

PHP notice

Trying to get property of non-object

D:\xampp\htdocs\buntelangame\themes\initializr\views\layouts\dashboard.php(75)

63 <a href="javascript:;" class="menu-toggler responsive-toggler" data-toggle="collapse" data-target=".navbar-collapse">
64 </a>
65 <!-- END RESPONSIVE MENU TOGGLER -->
66 <!-- BEGIN TOP NAVIGATION MENU -->
67 <div class="top-menu">
68 <ul class="nav navbar-nav pull-right">
69 
70 <!-- BEGIN USER LOGIN DROPDOWN -->
71 <li class="dropdown dropdown-user">
72     <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
73         <img alt="" class="img-circle" src="<?php echo $this->themeUrl; ?>/assets/admin/layout/img/avatar3_small.jpg"/>
74                     <span class="username">
75                     <?php echo Yii::app()->session['user']->nama_lengkap;?> </span>
76         <i class="fa fa-angle-down"></i>
77     </a>
78     <ul class="dropdown-menu">
79         <li>
80             <a href="extra_profile.html">
81                 <i class="icon-user"></i> My Profile </a>
82         </li>
83         <li>
84             <a href="inbox.html">
85                 <i class="icon-envelope-open"></i> My Inbox <span class="badge badge-danger">
86                             3 </span>
87             </a>
Stack Trace
#0    
+  D:\yii\bin\framework\web\CBaseController.php(126): require("D:\xampp\htdocs\buntelangame\themes\initializr\views\layouts\das...")
#1    
+  D:\yii\bin\framework\web\CBaseController.php(95): CBaseController->renderInternal("D:\xampp\htdocs\buntelangame\themes\initializr\views//layouts/da...",
     

array(“content”=&gt;“

dashboard / index

此页面将是   包含,st ...“),true)       #2
      + D:\ yii \ bin \ framework \ web \ CController.php(784):CBaseController-&gt; renderFile(“D:\ xampp \ htdocs \ buntelangame \ themes \ initializr \ views // layouts / da ...”,   array(“content”=&gt;“

dashboard / index

此页面将是   包含,st ...“),true)       #3
       - D:\ xampp \ htdocs \ buntelangame \ protected \ controllers \ DashboardController.php(46):   CController-&gt; render(“index”,array())       41}       42       43公共功能actionIndex()       44 {       45 // echo Yii :: app() - &gt; user-&gt; checkAccess('user');退出;       46 $ this-&gt; render('index',array());       47}       48       49公共函数actionListStuff()       50 {       51 $ this-&gt; render('listStuff');       #4
      + D:\ yii \ bin \ framework \ web \ actions \ CInlineAction.php(49):DashboardController-&gt; actionIndex()       #5
      + D:\ yii \ bin \ framework \ web \ CController.php(308):CInlineAction-&gt; runWithParams(array(“/ dashboard / index”=&gt;“”))       #6
      + D:\ yii \ bin \ framework \ web \ filters \ CFilterChain.php(133):CController-&gt; runAction(CInlineAction)       #7
      + D:\ yii \ bin \ framework \ web \ filters \ CFilter.php(40):CFilterChain-&gt; run()       #8
      + D:\ yii \ bin \ framework \ web \ CController.php(1145):CFilter-&gt; filter(CFilterChain)       #9
      + D:\ yii \ bin \ framework \ web \ filters \ CInlineFilter.php(58):CController-&gt; filterAccessControl(CFilterChain)       #10
      + D:\ yii \ bin \ framework \ web \ filters \ CFilterChain.php(130):CInlineFilter-&gt; filter(CFilterChain)       #11
      + D:\ yii \ bin \ framework \ web \ CController.php(291):CFilterChain-&gt; run()       #12
      + D:\ yii \ bin \ framework \ web \ CController.php(265):CController-&gt; runActionWithFilters(CInlineAction,   阵列( “AccessControl的”))       #13
      + D:\ yii \ bin \ framework \ web \ CWebApplication.php(282):CController-&gt; run(“index”)       #14
      + D:\ yii \ bin \ framework \ web \ CWebApplication.php(141):CWebApplication-&gt; runController(“dashboard / index”)       #15
      + D:\ yii \ bin \ framework \ base \ CApplication.php(180):CWebApplication-&gt; processRequest()       #16
       - D:\ xampp \ htdocs \ buntelangame \ index.php(13):CApplication-&gt; run()       08定义('YII_DEBUG')或定义('YII_DEBUG',真);       09 //指定每条日志消息中应显示多少级别的调用堆栈       10定义('YII_TRACE_LEVEL')或定义('YII_TRACE_LEVEL',3);       11       12 require_once($ yii);       13 Yii :: createWebApplication($ config) - &gt; run();       2014-07-11 18:43:39 Apache / 2.4.9(Win32)OpenSSL / 1.0.1g PHP / 5.5.11 Yii Framework / 1.1.14

编辑: 它在icognito模式下工作。 我的谷歌浏览器版本:版本35.0.1916.153米

0 个答案:

没有答案