Recapchalib

Actualmente he modificado el condigo para eliminar el captcha y que solamente aparezca el recaptcha

He seguido los pasos que se indican en http://www.yiiframework.com/wiki/94/using-recaptchlib-in-your-projects/

  1. Yii::import(‘ext.recaptchalib’,true);

    $publickey = "my key public";

    echo recaptcha_get_html($publickey); ?>

Con esto consigo que se muestre el recaptcha

Modifique la parte de la vista :

<?php

/* @var $this SiteController */

/* @var $model ContactForm */

/* @var $form CActiveForm */

$this->pageTitle=Yii::app()->name . ’ - Contact Us’;

$this->breadcrumbs=array(

'Contact',

);

?>

<?php Yii::import(‘ext.recaptchalib’,true);

$publickey = "mi publico key ";?>

<h1>Contact Us</h1>

<?php if(Yii::app()->user->hasFlash(‘contact’)): ?>

<div class="flash-success">

&lt;?php echo Yii::app()-&gt;user-&gt;getFlash('contact'); ?&gt;

</div>

<?php else: ?>

<p>

If you have business inquiries or other questions, please fill out the following form to contact us. Thank you.

</p>

<div class="form">

<?php $form=$this->beginWidget(‘CActiveForm’, array(

'id'=&gt;'contact-form',


'enableClientValidation'=&gt;true,


'clientOptions'=&gt;array(


	'validateOnSubmit'=&gt;true,


),

)); ?>

&lt;p class=&quot;note&quot;&gt;Campos con &lt;span class=&quot;required&quot;&gt;*&lt;/span&gt; son obligatorios.&lt;/p&gt;





&lt;?php echo &#036;form-&gt;errorSummary(&#036;model); ?&gt;





&lt;div class=&quot;row&quot;&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'name'); ?&gt;


	&lt;?php echo &#036;form-&gt;textField(&#036;model,'name'); ?&gt;


	&lt;?php echo &#036;form-&gt;error(&#036;model,'name'); ?&gt;


&lt;/div&gt;





&lt;div class=&quot;row&quot;&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'email'); ?&gt;


	&lt;?php echo &#036;form-&gt;textField(&#036;model,'email'); ?&gt;


	&lt;?php echo &#036;form-&gt;error(&#036;model,'email'); ?&gt;


&lt;/div&gt;





&lt;div class=&quot;row&quot;&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'subject'); ?&gt;


	&lt;?php echo &#036;form-&gt;textField(&#036;model,'subject',array('size'=&gt;60,'maxlength'=&gt;128)); ?&gt;


	&lt;?php echo &#036;form-&gt;error(&#036;model,'subject'); ?&gt;


&lt;/div&gt;





&lt;div class=&quot;row&quot;&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'body'); ?&gt;


	&lt;?php echo &#036;form-&gt;textArea(&#036;model,'body',array('rows'=&gt;6, 'cols'=&gt;50)); ?&gt;


	&lt;?php echo &#036;form-&gt;error(&#036;model,'body'); ?&gt;


&lt;/div&gt;








&lt;?php endif; ?&gt;--&#62;


&lt;?php echo recaptcha_get_html(&#036;publickey); ?&gt;





&lt;div class=&quot;row buttons&quot;&gt;


	&lt;?php echo CHtml::submitButton('Submit'); ?&gt;


&lt;/div&gt;

<?php $this->endWidget(); ?>

</div><!-- form -->

<?php endif; ?>

Asimismo he cambiado en SiteController.php la función:

public function actionContact()

{   





  //----- Declaración del Recaptcha


  Yii::import('ext.recaptchalib',true);


  &#036;privatekey = 'my private key';


  &#036;resp = recaptcha_check_answer(&#036;privatekey, &#036;_SERVER['REMOTE_ADDR'],


  Yii::app()-&gt;request-&gt;getParam('recaptcha_challenge_field'), 


  Yii::app()-&gt;request-&gt;getParam( 'recaptcha_response_field' ) );


 // ---------------------------------------------------------------------------------------


	&#036;model=new ContactForm;


	if(isset(&#036;_POST['ContactForm']))


	{


		&#036;model-&gt;attributes=&#036;_POST['ContactForm'];


		if(&#036;model-&gt;validate())


		{


			&#036;name='=?UTF-8?B?'.base64_encode(&#036;model-&gt;name).'?=';


			&#036;subject='=?UTF-8?B?'.base64_encode(&#036;model-&gt;subject).'?=';


			&#036;headers=&quot;From: &#036;name &lt;{&#036;model-&gt;email}&gt;&#092;r&#092;n&quot;.


				&quot;Reply-To: {&#036;model-&gt;email}&#092;r&#092;n&quot;.


				&quot;MIME-Version: 1.0&#092;r&#092;n&quot;.


				&quot;Content-type: text/plain; charset=UTF-8&quot;;


             // recaptcha_check_answer returns a ReCaptchaResponse object 


             // which has two properties: is_valid and error.


            // I dont think I need to explain that


               if(&#036;resp-&gt;is_valid)


                  {


                mail(Yii::app()-&gt;params['adminEmail'],&#036;subject,&#036;model-&gt;body,&#036;headers);


			    Yii::app()-&gt;user-&gt;setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');


                     }


                else


                 {


                 Yii::app()-&gt;user-&gt;setFlash('contact','Introduce un correcto codigo recaptcha');


				 &#036;this-&gt;render('contact',array('model'=&gt;&#036;model));


                   }


			


			


			


			&#036;this-&gt;refresh();


		}


	}


	&#036;this-&gt;render('contact',array('model'=&gt;&#036;model));


}

Pero no me manda el email es decir no validad el captcha, alguien me puede ayudar. Un saludo.