You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I fully understand that we don't want any more features for the project. I am simply creating this to give people a concept of how to add ReCaptcha to their own pages.
Composer command (official google lib) composer require google/recaptcha "~1.1"
Code to add to any pages you want a captcha (will use built in if recaptcha not enabled)
Would indeed be great to see as a standard feature, ESPECIALLY if the present, server-side generated code is left in the code base as an alternative, similar to the option regarding the use of a locally hosted avatar vs. the use of gravatar.com.
FYI this script uses the most simple and native image creation possible in PHP, and rendering a captcha takes 1/1000sec on a standard CPU on a standard $5 server, so this should not be a big problem. @mcanatalay Can I ask you if you are using this in a very high-traffic scenario ?
No. Simply pressing reload captcha gives me %10 of cpu level. It is only captcha related problem. First, I was tought it is about my "autoload.php" since I cannot use composer, but it is only happens when I press reload captcha.
Currently Refactoring this system (Hopefully bring the entire system into one well bundled system that doesn't require a bunch of extra code in the HTML)
Hi, I'm using the code above. However, I get the error "Fatal error: Call to undefined method Request::server()" that probably if because of Request::server('REMOTE_ADDR') in chechRecaptcha function. Does anyone knows how to get the client IP? I'm not so experienced in php
EDIT: I fixed it by adding the function public static function server($key) in request.php. There should be another if in RegistrationModel.php to ask for Request::post('g-recaptcha-response') instead of 'captcha' when ReCaptcha is active.
Hi, I'm using the code above. However, I get the error "Fatal error: Call
to undefined method Request::server()" that probably if because of
Request::server('REMOTE_ADDR') in chechRecaptcha function. Does anyone
knows how to get the client IP? I'm not so experienced in php
—
Reply to this email directly or view it on GitHub #665 (comment).
Or you can add this function after cookie function in Request class.
/** * gets/returns the value of a specific key of the SERVER super-global * @param mixed $key key * @return mixed the key's value or nothing */publicstaticfunctionserver($key){
if (isset($_SERVER[$key])) {
return$_SERVER[$key];
}
}
First off... I am a HUGE fan! I just tried to implement the reCaptcha and
I get it to display and also get the green check mark but when submitting
the form it always says the feedback error "The entered captcha security
characters were wrong". I have added the $_SERVER['REMOTE_ADDR'] In the
CaptchaModel.php and was wondering if there was anything else that needed
to be updated.
—
Reply to this email directly or view it on GitHub #665 (comment).
Love the idea here...I keep getting an error when submiting Fatal error: Class 'ReCaptcha\ReCaptcha' not found in....
I do not have a ReCaptchaController so not sure what do :/
@videsignz Please read the very fist post very clearly. The Controller I used was the CaptchaController you will need to add the function from the first post yourself. The code needed has been clearly laid out and should be simple to follow. So again please read the very first post in this issue.
Well, after everything is installed...I am receiving the error missing-input-response and that's it...keys are right...in the docs it is looking for $_POST['g-recaptcha-response'] yet in the registration model it gets Request::post('captcha') so there needs to be another if statement here I think...I'll test it and post back here
Ok, so one last thing to make this work if anyone else is having issues....
Go to RegistrationModel.php and look at the first function registerNewUser(){}
It looks like this
// TODO this could be written simpler and cleaner// clean the input$user_name = strip_tags(Request::post('user_name'));
$user_email = strip_tags(Request::post('user_email'));
$user_password_new = Request::post('user_password_new');
$user_password_repeat = Request::post('user_password_repeat');
// stop registration flow if registrationInputValidation() returns false (= anything breaks the input check rules)$validation_result = self::registrationInputValidation(Request::post('captcha'), $user_name, $user_password_new, $user_password_repeat, $user_email);
if (!$validation_result) {
returnfalse;
}
We need it to be like this to determine the proper post name which depends on which captcha type you are using.
// TODO this could be written simpler and cleaner// clean the input$user_name = strip_tags(Request::post('user_name'));
$user_email = strip_tags(Request::post('user_email'));
$user_password_new = Request::post('user_password_new');
$user_password_repeat = Request::post('user_password_repeat');
// THIS IS THE SWITCH! :)if (Config::get('RECAPTCHA_ENABLED')) {
$captcha = Request::post('g-recaptcha-response');
}else{
$captcha = Request::post('captcha');
}
// stop registration flow if registrationInputValidation() returns false (= anything breaks the input check rules)$validation_result = self::registrationInputValidation($captcha, $user_name, $user_password_new, $user_password_repeat, $user_email);
if (!$validation_result) {
returnfalse;
}
Don't overlook this minor change in the above code
from
Hey, this is linked from the readme now, but I think it's better to simply leave this as a ticket instead of implementing it by default (as this would become tricky with the additional composer-dependency that wouldn't be needed by 90% of the users)... hmm... hard decision...
Anyway, users who read the readme will find this :)
Looks like the code base got a bit changed? Would you be so friendly to explain exactly how i can add recaptcha to the register page? :) (So what exactly i have to replace) Thank you very much.
I created the values on config changed the registration page added the captcha model but when i try to register and click the captcha it tells me its wrong if i let the captcha empty i can register without it .. :(
Activity
panique commentedon Jun 3, 2015
AWWESOMEEE !! Thank you so much, this should definitly go into the project by default! I'll do this in the next weeks when there's some time! :)
tankerkiller125 commentedon Jun 3, 2015
Your welcome. I might add that the
Language::getTextshould be changed to the correctText::get(I forgot to change it from my implemention)[-]ReCaptcha Support[/-][+][feature] ReCaptcha Support[/+][-][feature] ReCaptcha Support[/-][+][STICKY][Optional feature] ReCaptcha Support[/+]JFJanssen commentedon Jul 17, 2015
Thanks tankerkiller125!
Would indeed be great to see as a standard feature, ESPECIALLY if the present, server-side generated code is left in the code base as an alternative, similar to the option regarding the use of a locally hosted avatar vs. the use of gravatar.com.
mcanatalay commentedon Jul 20, 2015
Thank you tankerkiller125 there was a cpu issue in my server side. I think this would help me much.
tankerkiller125 commentedon Jul 23, 2015
@mcanatalay Not sure if it will help with CPU however it does reduce bandwidth (since verification and images come from google and not your server)
mcanatalay commentedon Jul 24, 2015
Well, what does use cpu is image creating process and maybe key creating. Taking them externally surely help.
panique commentedon Jul 24, 2015
FYI this script uses the most simple and native image creation possible in PHP, and rendering a captcha takes 1/1000sec on a standard CPU on a standard $5 server, so this should not be a big problem. @mcanatalay Can I ask you if you are using this in a very high-traffic scenario ?
mcanatalay commentedon Jul 24, 2015
No. Simply pressing reload captcha gives me %10 of cpu level. It is only captcha related problem. First, I was tought it is about my "autoload.php" since I cannot use composer, but it is only happens when I press reload captcha.
tankerkiller125 commentedon Jul 24, 2015
Currently Refactoring this system (Hopefully bring the entire system into one well bundled system that doesn't require a bunch of extra code in the HTML)
afermon commentedon Jul 26, 2015
Hi, I'm using the code above. However, I get the error "Fatal error: Call to undefined method Request::server()" that probably if because of Request::server('REMOTE_ADDR') in chechRecaptcha function. Does anyone knows how to get the client IP? I'm not so experienced in php
EDIT: I fixed it by adding the function public static function server($key) in request.php. There should be another if in RegistrationModel.php to ask for Request::post('g-recaptcha-response') instead of 'captcha' when ReCaptcha is active.
Thanks
tankerkiller125 commentedon Jul 26, 2015
Sorry about that I think I made the server function. Replace it with
$_SERVER['REMOTE_ADDR']
On Sat, Jul 25, 2015, 23:45 Alex Fermon notifications@github.com wrote:
mcanatalay commentedon Jul 26, 2015
Or you can add this function after cookie function in Request class.
tankerkiller125 commentedon Jul 30, 2015
The google lib should do most of the work. Make sure you have your keys
right?
On Thu, Jul 30, 2015, 11:23 Lester MacDonald notifications@github.com
wrote:
videsignz commentedon Aug 21, 2015
Love the idea here...I keep getting an error when submiting
Fatal error: Class 'ReCaptcha\ReCaptcha' not found in....I do not have a ReCaptchaController so not sure what do :/
tankerkiller125 commentedon Aug 21, 2015
@videsignz Please read the very fist post very clearly. The Controller I used was the CaptchaController you will need to add the function from the first post yourself. The code needed has been clearly laid out and should be simple to follow. So again please read the very first post in this issue.
videsignz commentedon Aug 21, 2015
Yeah, I did everything else, then looked back and saw
composer require google/recaptcha "~1.1"What a dummy...
I did assume on some level that all the pieces were here though....my bad
tankerkiller125 commentedon Aug 21, 2015
@videsignz I've done that a couple times 😆
videsignz commentedon Aug 22, 2015
Well, after everything is installed...I am receiving the error
missing-input-responseand that's it...keys are right...in the docs it is looking for$_POST['g-recaptcha-response']yet in the registration model it getsRequest::post('captcha')so there needs to be another if statement here I think...I'll test it and post back herevidesignz commentedon Aug 22, 2015
Ok, so one last thing to make this work if anyone else is having issues....
Go to
RegistrationModel.phpand look at the first functionregisterNewUser(){}It looks like this
We need it to be like this to determine the proper post name which depends on which captcha type you are using.
Don't overlook this minor change in the above code
from
to
Hope this helps :)
panique commentedon Oct 11, 2015
Hey, this is linked from the readme now, but I think it's better to simply leave this as a ticket instead of implementing it by default (as this would become tricky with the additional composer-dependency that wouldn't be needed by 90% of the users)... hmm... hard decision...
Anyway, users who read the readme will find this :)
christiangrieger commentedon Jan 10, 2016
Looks like the code base got a bit changed? Would you be so friendly to explain exactly how i can add recaptcha to the register page? :) (So what exactly i have to replace) Thank you very much.
I created the values on config changed the registration page added the captcha model but when i try to register and click the captcha it tells me its wrong if i let the captcha empty i can register without it .. :(
DonSYS91 commentedon Nov 6, 2017
Along with those changes I have fork a copy and implemented reCAPTCHA:
https://github.com/donmccoy/huge