Welcome Guest, Not a member yet? Register   Sign In
ReCAPTCHA library - ignited
#41

[eluser]dinaco[/eluser]
Are you ever going to make this library support custom themes?

I tried making some changes without changing the library but it seems not to be possible!
#42

[eluser]kaluzhanin[/eluser]
This is a great library. But is it server-configuration dependent?

The problem is, I had to move to another platform (from ubuntu-LAMP to windows-XAMPP), and recaptcha never validates now.

Here's the excerpt from debug log:

Code:
DEBUG - 2010-04-16 21:20:23 --> Recaptcha::_qsencode(
Array
(
    [privatekey] => <valid value>
    [remoteip] => 127.0.0.1
    [challenge] => <long and obviously valid sequence of characters>
    [response] => height polecats
)

)
DEBUG - 2010-04-16 21:20:23 --&gt; Recaptcha::_http_post response:Array
(
    [0] => HTTP/1.0 200 OK
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Date: Fri, 16 Apr 2010 17:20:28 GMT
Content-Type: text/plain
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
    [1] => false
'Input error: response: Required field must not be blank\nchallenge: Required field must not be blank\n'
)

So, as far as I understand, user response doesn't get to recaptcha.net. Why is that?

Any advice would be much appreciated.
#43

[eluser]kaluzhanin[/eluser]
I've solved the problem described above. The trick was to change the body of _qsendcode($data) function of the library. I've replaced call for http_build_query($data) with the code from general recaptchalib.php file from recaptcha.net:

Code:
function _qsencode($data) {
        log_message('debug',"Recaptcha::_qsencode(\n".print_r($data,TRUE)."\n)");
        //http_build_query() = PHP 5 ONLY!
        //return http_build_query($data);

        //from recaptchalib.php:
        $req = "";
        foreach ( $data as $key => $value )
                $req .= $key . '=' . urlencode( stripslashes($value) ) . '&';

        // Cut the last '&'
        $req=substr($req,0,strlen($req)-1);
        return $req;
    }

Now it works as charm. If this is the only thing that enforces usage of PHP 5, the restriction is lifted.

P.S. Still, it is very strange that the problem arose. I use PHP 5.1.3 in my development environment. Obviously, the problem is in http_build_query function(), but we can do without it.
#44

[eluser]Benedikt[/eluser]
@kaluzhanin: Thanks, this helped me!!
#45

[eluser]theseamusjames[/eluser]
So this is a fun one.

The library works perfectly on my local MAMP host, but when I upload it to our live site, I get the following CI error: "Non-existent class: Recaptcha".

To make matters worse, I noticed that I'd named the library on the live site "recaptcha.php" so I changed it to "Recaptcha.php" (capitalized the R) and noticed that it changed in the error message too.

This is driving me crazy - it works locally! AHHHHH!
#46

[eluser]steelaz[/eluser]
Open your Recaptcha.php and check the name of the class. Also, check if there are any weird characters above class definition. I had similar problem once and it turned out to be some weirdly encoded character in the comments above class definition that was braking the whole script.
#47

[eluser]theseamusjames[/eluser]
Nope. I took out all the comments, and it didn't make a difference.

It's just so weird that it runs locally but not on the live site. I downloaded the entire live version of our site and set it up on our local MAMP host - works fine here, not at all on the live version.

My Recaptcha.php begins:

&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Recaptcha
{

Which looks perfect to me. I've tried it in both the system/libraries folder, and the system/application/libraries folder. Neither worked.

So. Frustrating!
#48

[eluser]theseamusjames[/eluser]
Got it! Server permissions were screwed up on all the reCaptcha files - I just had to allow group and user access to them and it's all better!

And that's why I don't do admin...
#49

[eluser]Unknown[/eluser]
Hi

Got problem implementing this. I am using a template to display my views, when I use this library, It did not display if I input the correct captcha or not. see below for the code on my controller:

function index()
{
$this->load->library('recaptcha');
$this->load->library('form_validation');
$this->load->helper('form');
$this->lang->load('recaptcha');

$this->template->set('nav', 'Home');


if ($this->form_validation->run()) {

$this->template->load('template','home_view',array('recaptcha'=>'Yay! You got it right!'));

} else {

$this->template->load('template', 'home_view',array('recaptcha'=>$this->recaptcha->get_html()));

}
}


On my view :

&lt;?php echo form_open('Home'); ?&gt;
&lt;?php echo form_error('recaptcha_response_field'); ?&gt;
&lt;?php echo $recaptcha; ?&gt;
&lt;?php echo form_submit('recaptchasubmit','Check Recaptcha'); ?&gt;
&lt;?php echo form_close(); ?&gt;

Any Ideas? I'm wondering if this would work on CI template library. Please advise.

Thanks
#50

[eluser]mighty_falcon[/eluser]
I could not update the wiki since it complained in might be spam, but it needs to be updated to add the following function for the callback in the validation to run:

Quote: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;
}
}




Theme © iAndrew 2016 - Forum software by © MyBB