Note that there are some explanatory texts on larger screens.

plurals
  1. POIn YII Framework, the Captcha doesn't show(conflict with accessControl)
    primarykey
    data
    text
    <p>In my site, only when I remove the filters() method, the captcha can show up. other time the captcha doesn't work. and my php gd support is enable.</p> <p>now I am using a custome WebUser, if I remove it from config, the captcha also works well.</p> <p>by the way, if I access user/captcha directly, it only show a picture box, but not content, maybe can not load the picture..</p> <p>here are some code segments in my UserController:</p> <p>actions();</p> <pre><code>public function actions() { return array( // captcha action renders the CAPTCHA image displayed on the contact page 'captcha'=&gt;array( 'class'=&gt;'CCaptchaAction', 'backColor'=&gt;0xFFFFFF, 'minLength' =&gt; 4, 'maxLength' =&gt; 4, 'testLimit' =&gt; 99999 ) ); } </code></pre> <p>filters():</p> <pre><code>public function filters() { // return the filter configuration for this controller, e.g.: return array( "accessControl", ); } </code></pre> <p>accessRulse():</p> <pre><code>public function accessRules() { return array( array('allow', // allow all users to perform 'index' and 'view' actions 'actions'=&gt;array('captcha'), 'users'=&gt;array('*'), ), array('allow', // allow all users to perform 'index' and 'view' actions 'actions'=&gt;array('index','login','signup'), 'expression'=&gt;'Yii::app()-&gt;user-&gt;isGuest', ), array('allow', // allow authenticated user to perform 'create' and 'update' actions 'actions'=&gt;array('cpassword','info','logout'), 'expression'=&gt;'!Yii::app()-&gt;user-&gt;isGuest', ), array('allow', // allow admin user to perform 'admin' and 'delete' actions 'users'=&gt;array('admin@example.com'), ), array('deny', // deny all users 'users'=&gt;array('*'), 'message'=&gt;'Access Denied.', ), ); } </code></pre> <p>My WebUsers.php</p> <pre><code>&lt;?php // this file must be stored in: // protected/components/WebUser.php class WebUser extends CWebUser { // Store model to not repeat query. private $_model; // Return first name. // access it by Yii::app()-&gt;user-&gt;first_name public function getDisplayName(){ $user = $this-&gt;loadUser(Yii::app()-&gt;user-&gt;id); if($user) return $user-&gt;display_name; } public function getGroupId(){ $user = $this-&gt;loadUser(Yii::app()-&gt;user-&gt;id); return $user-&gt;group_id; } // This is a function that checks the field 'role' // in the User model to be equal to 1, that means it's admin // access it by Yii::app()-&gt;user-&gt;isAdmin() public function isAdmin(){ $user = $this-&gt;loadUser(Yii::app()-&gt;user-&gt;id); return intval($user-&gt;group_id) == 1; } public function isGroupAAS(){ $user = $this-&gt;loadUser(Yii::app()-&gt;user-&gt;id); return intval($user-&gt;group_id) == 1001; } // Load user model. protected function loadUser($id=null) { if($this-&gt;_model===null) { if($id!==null) $this-&gt;_model=User::model()-&gt;findByPk($id); } return $this-&gt;_model; } protected function afterLogin($fromCookie){ $user = $this-&gt;loadUser($this-&gt;id); $user-&gt;last_login_ip = Yii::app()-&gt;request-&gt;userHostAddress; $user-&gt;last_login_time = new CDbExpression('NOW()'); $user-&gt;save(); } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload