assira captcha

I make an extension for the assira ’ CAPTCHA’.

I post the demo app.I use the contact form as a demo.

The class is the extensions/assira/assira.php- I put it at config/main.php


'assira'=>array('class'=>'application.extensions.assira.Assira'),

I use also 2 js files js/assira.js,asssiraphotos.js as you can see at contact view.

Also ant contactform.php there is the validation rule


public function rules()

	{

		return array(...

// verifyCode needs to be entered correctly

			array('verifyCode','assira'),....


 function assira() {

        if (Yii::app()->assira->ValidateAsirraChallenge()==false)

            $this->addError( 'verifyCode','Please select the right photos');

        else

            return true();


    }

I am waiting for suggestions or improvements

[Edit] I had to fix something,so I re-upload the file

Something more.

At form we must write the onsubmit function and the id


  <?php echo CHtml::beginForm('','post',array('id'=>'mainForm',

'onSubmit'=>'return Asirra_CheckIfHuman(HumanCheckComplete)')); ?>

.

Also we have to include the javascript files.


 $cs = Yii::app()->clientScript;

 $cs->registerScriptFile(Yii::app()->request->baseUrl.'/js/assira.js'); 

and


<div >

             <script type="text/javascript" src="//challenge.asirra.com/js/AsirraClientSide.js"></script>

            

<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/asssiraphotos.js" ></script>

        </div>

at the place of the cats div

You may look also at the php demo