Yii Framework Forum: Captcha Broken Image - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Captcha Broken Image called on module/controller/action Rate Topic: -----

#1 User is offline   Kostas Apazidis (KonApaz) 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,332
  • Joined: 21-February 11
  • Location:Greece

Posted 28 May 2013 - 09:14 AM

Hi Everyone

I use a lot of times the default captcha with Yii, almost without problem

Today I try to show the captcha on a module but the captcha image is broken (no image appearing). The other components of captcha (links, error matching code etc) seem to work correctly

My code in module Controller is

  public function actions() {
        return array(
            'captcha' => array(
                'class' => 'CCaptchaAction',
                'backColor' => 0xFFFFFF,
            ),
        );
}


In module view
 <?php if (CCaptcha::checkRequirements()): ?>
        <div class="row">
            <?php echo $form->labelEx($model, 'verifyCode'); ?>
            <div>
                <?php $this->widget('CCaptcha'); ?>
                <?php echo $form->textField($model, 'verifyCode'); ?>
            </div>
            <div class="hint">Please enter the letters as they are shown in the image above.
                <br/>Letters are not case-sensitive.</div>
            <?php echo $form->error($model, 'verifyCode'); ?>
        </div>
    <?php endif; ?>



And in model

  
public $verifyCode;
   ....
    public function rules() {
        return array(
            ....
            ....
            array('verifyCode', 'captcha', 'allowEmpty' => !CCaptcha::checkRequirements()),
        );
}


The Same code with Controller/action/model/view as we all know

Why I have this problem?
Thanks
Yii is the best php framework in the world!
It is also powerful and flexible for large scale websites
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

#2 User is offline   Kostas Apazidis (KonApaz) 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,332
  • Joined: 21-February 11
  • Location:Greece

Posted 28 May 2013 - 09:35 AM

Ok, I found the problem


I had assign accessRules permissions for other actions
But I missed to do that for captcha .. is an action itself!

So I had to add the captcha action like that

 public function accessRules() {
        return array(
            array('allow',
                'actions' => array('index', ... ... ,'captcha'),
                'users' => array('@'),
            ),
            array('deny', // deny all users
                'users' => array('*'),
            ),
        );
    }



Now all work fine!
Thanks for your time :)
Yii is the best php framework in the world!
It is also powerful and flexible for large scale websites
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

#3 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,670
  • Joined: 04-March 10
  • Location:UK

Posted 28 May 2013 - 09:36 AM

Check the source code to see if an image tag has been rendered. If so, post the URL that's been generated. That might help to determine the problem.

Edit: Sorted :lol:
0

#4 User is offline   waterloomatt 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 545
  • Joined: 09-April 10

Posted 28 May 2013 - 09:36 AM

Check out the first answer: http://stackoverflow...ng-no-image-yii

Matt
0

#5 User is offline   waterloomatt 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 545
  • Joined: 09-April 10

Posted 28 May 2013 - 09:38 AM

Same thing: http://shanidevelope...oesnt-show.html
0

#6 User is offline   Kostas Apazidis (KonApaz) 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,332
  • Joined: 21-February 11
  • Location:Greece

Posted 28 May 2013 - 09:44 AM

Thanks a lot @Keith and @waterloommat!

Keith the image tag was exist ( So that I said broken image :) )

Waterloommat your links describe and solve my problem on the last step (accessRules())


Thanks both of you for your time :)
Yii is the best php framework in the world!
It is also powerful and flexible for large scale websites
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users