Recpatcha no carga config/recaptcha.php

14 views
Skip to first unread message

basi batusi

unread,
Sep 30, 2009, 3:45:01 AM9/30/09
to codeignit...@googlegroups.com
Buenos días,

continuando con el formulario que me trae de cabeza...
Le quiero poner el codigo de reCaptcha, segun la wiki de CI:

http://codeigniter.com/wiki/ReCAPTCHA/

Al cargarse el formulario no carga las variables que provienen del config/recaptacha.php, sin embargo, probando solo con el formulario recaptchademo, sin ningun campo mas funciona perfectamente. En cuanto intento integrar mas campos, ya no funciona.

Los codigos los pongo a continuacion.

controllers/contact.php:
[CODE]
public function index()
  {
    $arraycontact = '';

    $this -> form_validation -> set_message('required', '* Debe introducir "%s"');
    $this -> form_validation -> set_message('is_natural', '* El "%s" debe debe contener solo caracteres numéricos');
    $this -> form_validation -> set_message('exact_length', '* El "%s" debe contener 9 dígitos');
    $this -> form_validation -> set_message('valid_email', '* Debe escribir una "%s" correcta');
    $this -> form_validation -> set_message('check_captcha', $this -> lang -> line('recaptcha_incorrect_response'));

    if($this -> form_validation -> run() == FALSE)
    {
      $formmessages['errors'] = validation_errors();
    }
    else
    {
      $formmessages['success'] = 'Los datos que ha rellenado serán enviados por correo-e.';
[funcion para enviar mail]/[funcion para enviar mail]
function check_captcha($val)
  {
    if ($this -> recaptcha -> check_answer($this -> input -> ip_address(),$this->input->post('recaptcha_challenge_field'),$val))
    {
      return TRUE;
    }
    else
    {
      $this -> form_validation -> set_message('check_captcha', $this -> lang -> line('recaptcha_incorrect_response'));
      return FALSE;
    }
  }
[/CODE]

views/contactview.php:
[CODE]
<script type="text/javascript">
  var RecaptchaOptions =
  {
    theme:"<?php echo 'theme';?>",
    lang:"<?php echo 'lang';?>",
  };
</script>

          <div class = "errors"><?php if (isset($messages['success'])) echo $messages['success'];?></div>
          <div class = "errors"><?php if (isset($messages['emailmessage'])) echo $messages['emailmessage'];?></div>

          <label for = "contactname">Nombre:</label>
          <input id = "contactname" name = "contactname" type = "text" maxlength =" 100"  size = "35" value = "<?php echo set_value('contactname', '');?>" /><br />
          <?php echo form_error('contactname');?><br />

          <label for = "contactemail">Direcci&oacute;n de correo-e:</label>
          <input id = "contactemail" name = "contactemail" type = "text" maxlength = "100"  size = "25" value = "<?php echo set_value('contactemail', '');?>" />&nbsp;
          <label for = "contactphone">N&uacute;mero de telefono:</label>
          <input id = "contactphone" name = "contactphone" type = "text" maxlength = "9"  size = "9" value = "<?php echo set_value('contactphone', '');?>" /><br />
          <?php echo form_error('contactemail');?><br />
          <?php echo form_error('contactphone');?><br />

          <label for = "contactsubject">Asunto:</label>
          <input id = "contactsubject" name = "contactsubject" type = "text" maxlength = "100"  size = "35" value = "<?php echo set_value('contactsubject', '');?>" /><br />
          <?php echo form_error('contactsubject');?><br />

          <label for = "contacttext">Texto:</label><br />
          <textarea id = "contacttext" name = "contacttext" rows = "10" cols = "80"><?php echo set_value('contacttext', '');?></textarea><br />
          <?php echo form_error('contacttext');?><br />


<?php echo form_error('recaptcha_response_field') ;?>

<script type="text/javascript" src="<?php echo $server;?>/challenge?k=<?php echo $key.$errorpart;?>"></script>
<noscript>
    <iframe src="<?php echo $server;?>/noscript?lang=<?php echo $lang;?>&k=<?php echo $key.$errorpart;?>" height="300" width="500" frameborder="0"></iframe><br/>
    <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
    <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript>

          <div id = "buttons">
            <!--<input id = "formsubmit" name = "formsubmit" type = "submit" value = "Enviar" />-->
            <input id = "formsubmit" type="submit" name="formsubmit" value="Enviar" />
            <input id = "formreset" name = "formreset" type = "reset" value = "Restablecer" />
          </div><!--  buttons  -->

          <p>
            <div class ="errors">Atenci&oacute;n: Todos los campos son obligatorios.</div>
          </p>

        </fieldset>
      </form>

    </div><!-- main -->
[/CODE]

config/recaptcha.php:
[CODE]
$config['recaptcha'] = array
(
  'public' => 'XXXXXXX',
  'private' => 'XXXXXXX',
  'RECAPTCHA_API_SERVER' => 'http://api.recaptcha.net',
  'RECAPTCHA_API_SECURE_SERVER' => 'https://api-secure.recaptcha.net',
  'RECAPTCHA_VERIFY_SERVER' => 'api-verify.recaptcha.net',
  'theme' => 'clean',
  'lang' => 'es'
);
[/CODE]

Despues de darle muchas vueltas, no logro que se cargue el recaptcha, a no ser que escriba el script, con el valor directo de las variables, pero entonces no reconoce las demas, para la validacion del codigo en el servidor de recaptha, en la view del form.
[CODE]
<script type="text/javascript" src="http://api.recaptcha.net/challenge?k=xxxxxxxxxxxx&amp;error="></script>
[/CODE]
Muchas gracias, un saludo

basi batusi

unread,
Oct 1, 2009, 7:18:49 AM10/1/09
to codeignit...@googlegroups.com
Buenos días, reenvío correo que puse ayer a la lista, por que no me ha llegado, no se si se quedo por el camino. Perdón por las molestias si alguno ya lo recibió.
Reply all
Reply to author
Forward
0 new messages