Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
no-captcha
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
CENTER-TBI
no-captcha
Commits
f78e1a0c
Unverified
Commit
f78e1a0c
authored
Oct 31, 2017
by
Nguyen Van Anh
Committed by
GitHub
Oct 31, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #91 from mmghv/multiple-verify
Allow verifying multiple times.
parents
60aa7396
0f44e59e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
src/NoCaptcha.php
src/NoCaptcha.php
+21
-4
No files found.
src/NoCaptcha.php
View file @
f78e1a0c
...
@@ -9,8 +9,6 @@ class NoCaptcha
...
@@ -9,8 +9,6 @@ class NoCaptcha
{
{
const
CLIENT_API
=
'https://www.google.com/recaptcha/api.js'
;
const
CLIENT_API
=
'https://www.google.com/recaptcha/api.js'
;
const
VERIFY_URL
=
'https://www.google.com/recaptcha/api/siteverify'
;
const
VERIFY_URL
=
'https://www.google.com/recaptcha/api/siteverify'
;
const
ON_LOAD_CLASS
=
'onloadCallBack'
;
const
RENDER_TYPE
=
'explicit'
;
/**
/**
* The recaptcha secret key.
* The recaptcha secret key.
...
@@ -31,6 +29,13 @@ class NoCaptcha
...
@@ -31,6 +29,13 @@ class NoCaptcha
*/
*/
protected
$http
;
protected
$http
;
/**
* The cached verified responses.
*
* @var array
*/
protected
$verifiedResponses
=
[];
/**
/**
* NoCaptcha.
* NoCaptcha.
*
*
...
@@ -85,13 +90,25 @@ class NoCaptcha
...
@@ -85,13 +90,25 @@ class NoCaptcha
return
false
;
return
false
;
}
}
$response
=
$this
->
sendRequestVerify
([
// Return true if response already verfied before.
if
(
in_array
(
$response
,
$this
->
verifiedResponses
))
{
return
true
;
}
$verifyResponse
=
$this
->
sendRequestVerify
([
'secret'
=>
$this
->
secret
,
'secret'
=>
$this
->
secret
,
'response'
=>
$response
,
'response'
=>
$response
,
'remoteip'
=>
$clientIp
,
'remoteip'
=>
$clientIp
,
]);
]);
return
isset
(
$response
[
'success'
])
&&
$response
[
'success'
]
===
true
;
if
(
isset
(
$verifyResponse
[
'success'
])
&&
$verifyResponse
[
'success'
]
===
true
)
{
// A response can only be verified once from google, so we need to
// cache it to make it work in case we want to verify it multiple times.
$this
->
verifiedResponses
[]
=
$response
;
return
true
;
}
else
{
return
false
;
}
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment