Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add support for passing challenge/response manually #3

Merged
merged 2 commits into from

2 participants

@flack

This makes integrations into frameworks a bit easier. If no values are passed, then the values will be read from $_POST as before, so that there is no BC break.

Not sure if I got your coding style right, feel free to correct as needed.

@flack flack Add support for passing challenge/response manually
This makes integrations into frameworks a bit easier. If no values are passed, then the values will be read from $_POST as before, so that there is no BC break. 

Not sure if I got your coding style right, feel free to correct as needed.
7fbad0b
Package/Captcha/Captcha.php
((19 lines not shown))
// Skip processing of empty data
- if (isset($_POST['recaptcha_challenge_field']) && isset($_POST['recaptcha_response_field'])) {
+ if ((strlen($captcha_challenge) == 0 || strlen($captcha_response) == 0) && isset($_POST['recaptcha_challenge_field']) && isset($_POST['recaptcha_response_field'])) {
@AlekseyKorzun Owner

Can you please do:

if (!$captcha_challenge && !$captcha_response) {
    if (isset($_POST['recaptcha_challenge_field']) && isset($_POST['recaptcha_response_field']) {

    }
}

To follow line width limit of PSR compliance and avoid treating default method values (false) as a string.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@AlekseyKorzun

Thanks for the pull request, made a minor comment as soon as you update it I will merge it.

Cheers!

@flack

OK, I updated now as requested

@AlekseyKorzun

Approved, thank you.

@AlekseyKorzun AlekseyKorzun merged commit 6fc690f into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 14, 2013
  1. @flack

    Add support for passing challenge/response manually

    flack authored
    This makes integrations into frameworks a bit easier. If no values are passed, then the values will be read from $_POST as before, so that there is no BC break. 
    
    Not sure if I got your coding style right, feel free to correct as needed.
Commits on Mar 23, 2013
  1. @flack

    Fix coding style

    flack authored
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 8 deletions.
  1. +8 −8 Package/Captcha/Captcha.php
View
16 Package/Captcha/Captcha.php
@@ -208,22 +208,22 @@ public function html()
/**
* Checks and validates user's response
*
+ * @param string $captcha_challenge Optional challenge string. If empty, value from $_POST will be used
+ * @param string $captcha_response Optional response string. If empty, value from $_POST will be used
* @throws Exception
* @return Response
*/
- public function check()
+ public function check($captcha_challenge = false, $captcha_response = false)
{
if (!$this->getPrivateKey()) {
throw new Exception('You must set private key provided by reCaptcha');
}
-
- $captcha_challenge = false;
- $captcha_response = false;
-
// Skip processing of empty data
- if (isset($_POST['recaptcha_challenge_field']) && isset($_POST['recaptcha_response_field'])) {
- $captcha_challenge = $_POST['recaptcha_challenge_field'];
- $captcha_response = $_POST['recaptcha_response_field'];
+ if (!$captcha_challenge && !$captcha_response) {
+ if (isset($_POST['recaptcha_challenge_field']) && isset($_POST['recaptcha_response_field'])) {
+ $captcha_challenge = $_POST['recaptcha_challenge_field'];
+ $captcha_response = $_POST['recaptcha_response_field'];
+ }
}
// Instance of response object
Something went wrong with that request. Please try again.