0

I just wondering how it is possible to copy exact code of Yii Framework demo-blog-contact , downloaded from Yii website to other yii application with same version library and it don't show captcha.

When i go to controller/action page ,it show broken link instead of captcha and when i open broken link image in new page it show another broken link.

I saw this link for common problem of CCaptcha and i checked gd library is up and running and i have function actions() with content of exact same as the link said and i don't define any access control filter in the application.

I saw this link and i don't have permission problem and this link and i don't ajax it.

I did exact same as this link said but no success. any help to show these captcha would be appreciated.

Controller :

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

public function accessRules()
{
    return array(
        array('allow', 
            'actions'=>array('create', 'captcha'),
            'users'=>array('*'),
        ));
} 

Model :

<?php
class ContactsM extends CFormModel {
    public $name;
    public $email;
    public $subject;
    public $body;
    public $verifyCode;

    /**
     * Declares the validation rules.
     */
    public function rules()
    {
        return array(
            // name, email, subject and body are required
            array('name, email, subject, body', 'required'),
            // email has to be a valid email address
            array('email', 'email'),
            // verifyCode needs to be entered correctly
            array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
        );
    }
    public function attributeLabels()
    {
        return array(
            'verifyCode'=>'Verification Code',
        );
    }
    }

View :

<?php $form=$this->beginWidget('CActiveForm'); ?>
    <?php echo $form->errorSummary($model); ?>

    <?php if(extension_loaded('gd')): ?>
    <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>
    </div>
    <?php endif; ?>

    <div class="row submit">
        <?php echo CHtml::submitButton('Submit'); ?>
    </div>

<?php $this->endWidget(); ?>
Community
  • 1
  • 1

2 Answers2

1

As i understand from your comment You should Extend your Controller class from CController.

  • 1
    It solve my problem but What should i do with my basecontroller class which i want to inherent from? –  Apr 14 '13 at 10:43
  • 3
    It should not cause any problem to inheriat fom another controller. check your controller for error,white space in php or other problems. –  Apr 14 '13 at 10:49
0

I want to share the fact i have understand :

My problem was :

I used inheritances and father class have some issue , the son class extend it but it do not show any error and i was thinking it works fine but in fact it didn't , i understand it till i used some of father function which in this case was CCaptcha.