Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
recaptcha-3408409
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
recaptcha-3408409
Commits
8448563a
Commit
8448563a
authored
1 year ago
by
Liam Morland
Browse files
Options
Downloads
Patches
Plain Diff
Fix coding standards
parent
45bf6991
No related branches found
Branches containing commit
Tags
7.x-2.4-rc1
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
recaptcha-widget-noscript.tpl.php
+1
-1
1 addition, 1 deletion
recaptcha-widget-noscript.tpl.php
recaptcha.install
+6
-6
6 additions, 6 deletions
recaptcha.install
recaptcha.module
+33
-6
33 additions, 6 deletions
recaptcha.module
with
40 additions
and
13 deletions
recaptcha-widget-noscript.tpl.php
+
1
−
1
View file @
8448563a
<?php
/**
* @file
recaptcha-widget-noscript.tpl.php
* @file
* Default theme implementation to present the reCAPTCHA noscript code.
*
* Available variables:
...
...
This diff is collapsed.
Click to expand it.
recaptcha.install
+
6
−
6
View file @
8448563a
...
...
@@ -25,16 +25,16 @@ function recaptcha_uninstall() {
*/
function
recaptcha_update_7200
()
{
// Migrate the public key to site key.
// Upgrade from 6.x-2.x to 7.x-2.x
// Upgrade from 6.x-2.x to 7.x-2.x
.
$site_key
=
variable_get
(
'recaptcha_site_key'
,
''
);
// Upgrade from 7.x-1.x to 7.x-2.x
// Upgrade from 7.x-1.x to 7.x-2.x
.
$public_key
=
variable_get
(
'recaptcha_public_key'
,
$site_key
);
variable_set
(
'recaptcha_site_key'
,
$public_key
);
variable_del
(
'recaptcha_public_key'
);
// Upgrade from 6.x-2.x to 7.x-2.x
// Upgrade from 6.x-2.x to 7.x-2.x
.
$secret_key
=
variable_get
(
'recaptcha_secret_key'
,
''
);
// Upgrade from 7.x-1.x to 7.x-2.x
// Upgrade from 7.x-1.x to 7.x-2.x
.
$private_key
=
variable_get
(
'recaptcha_private_key'
,
$secret_key
);
variable_set
(
'recaptcha_secret_key'
,
$private_key
);
variable_del
(
'recaptcha_private_key'
);
...
...
@@ -47,7 +47,7 @@ function recaptcha_update_7200() {
'clean'
=>
'light'
,
'custom'
=>
'light'
,
);
// Upgrade from 6.x-2.x to 7.x-2.x
// Upgrade from 6.x-2.x to 7.x-2.x
.
$recaptcha_themes
+=
array
(
'light'
=>
'light'
,
'dark'
=>
'dark'
,
...
...
@@ -70,7 +70,7 @@ function recaptcha_update_7200() {
// - recaptcha_mailhide_public_key
// - recaptcha_mailhide_public_key_*
// - recaptcha_mailhide_private_key
// - recaptcha_mailhide_private_key_*
// - recaptcha_mailhide_private_key_*
.
db_delete
(
'variable'
)
->
condition
(
'name'
,
'recaptcha_mailhide_%'
,
'LIKE'
)
->
execute
();
...
...
This diff is collapsed.
Click to expand it.
recaptcha.module
+
33
−
6
View file @
8448563a
...
...
@@ -11,6 +11,9 @@ require_once dirname(__FILE__) . '/recaptcha-php/src/ReCaptcha/RequestParameters
require_once
dirname
(
__FILE__
)
.
'/recaptcha-php/src/ReCaptcha/Response.php'
;
require_once
dirname
(
__FILE__
)
.
'/src/ReCaptcha/RequestMethod/Drupal7Post.php'
;
use
ReCaptcha\ReCaptcha
;
use
ReCaptcha\RequestMethod\Drupal7Post
;
/**
* Implements hook_help().
*/
...
...
@@ -109,7 +112,7 @@ function recaptcha_captcha($op, $captcha_type = '') {
$variables
=
array
(
'sitekey'
=>
$recaptcha_site_key
,
'language'
=>
$language
->
language
,
'recaptcha_src_fallback'
=>
$recaptcha_src_fallback
'recaptcha_src_fallback'
=>
$recaptcha_src_fallback
,
);
$noscript
=
theme
(
'recaptcha_widget_noscript'
,
array
(
'widget'
=>
$variables
));
}
...
...
@@ -130,13 +133,30 @@ function recaptcha_captcha($op, $captcha_type = '') {
'#suffix'
=>
$noscript
,
);
// @todo: #1664602: D7 does not yet support "async" in drupal_add_js().
// drupal_add_js(url('https://www.google.com/recaptcha/api.js', array('query' => array('hl' => $language->language), 'absolute' => TRUE)), array('defer' => TRUE, 'async' => TRUE, 'type' => 'external'));
// @todo #1664602: D7 does not yet support "async" in drupal_add_js().
// drupal_add_js(
// url(
// 'https://www.google.com/recaptcha/api.js',
// array(
// 'query' => array(
// 'hl' => $language->language
// ),
// 'absolute' => TRUE),
// ),
// array('defer' => TRUE, 'async' => TRUE, 'type' => 'external')
// );
$data
=
array
(
'#tag'
=>
'script'
,
'#value'
=>
''
,
'#attributes'
=>
array
(
'src'
=>
url
(
$recaptcha_src
,
array
(
'query'
=>
array
(
'hl'
=>
$language
->
language
),
'absolute'
=>
TRUE
)),
'src'
=>
url
(
$recaptcha_src
,
array
(
'query'
=>
array
(
'hl'
=>
$language
->
language
,
),
'absolute'
=>
TRUE
),
),
'async'
=>
'async'
,
'defer'
=>
'defer'
,
),
...
...
@@ -162,7 +182,7 @@ function recaptcha_captcha_validation($solution, $response, $element, $form_stat
}
// Use drupal_http_request() to circumvent all issues with the Google library.
$recaptcha
=
new
\ReCaptcha\
ReCaptcha
(
$recaptcha_secret_key
,
new
\ReCaptcha\RequestMethod\
Drupal7Post
());
$recaptcha
=
new
ReCaptcha
(
$recaptcha_secret_key
,
new
Drupal7Post
());
// Ensures the hostname matches. Required if "Domain Name Validation" is
// disabled for credentials.
...
...
@@ -223,5 +243,12 @@ function recaptcha_captcha_validation($solution, $response, $element, $form_stat
function
template_preprocess_recaptcha_widget_noscript
(
&
$variables
)
{
$variables
[
'sitekey'
]
=
check_plain
(
$variables
[
'widget'
][
'sitekey'
]);
$variables
[
'language'
]
=
check_plain
(
$variables
[
'widget'
][
'language'
]);
$variables
[
'url'
]
=
check_url
(
url
(
$variables
[
'widget'
][
'recaptcha_src_fallback'
],
array
(
'query'
=>
array
(
'k'
=>
$variables
[
'widget'
][
'sitekey'
],
'hl'
=>
$variables
[
'widget'
][
'language'
]),
'absolute'
=>
TRUE
)));
$options
=
array
(
'query'
=>
array
(
'k'
=>
$variables
[
'widget'
][
'sitekey'
],
'hl'
=>
$variables
[
'widget'
][
'language'
],
),
'absolute'
=>
TRUE
,
);
$variables
[
'url'
]
=
check_url
(
url
(
$variables
[
'widget'
][
'recaptcha_src_fallback'
],
$options
));
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment