Skip to content

Commit 772c81c

Browse files
authored
Merge pull request #1 from CGT-Software/main
Add files via upload
2 parents 24ddf57 + c817bc7 commit 772c81c

17 files changed

+208
-0
lines changed

conf.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "reCAPTCHA",
3+
"brief": "Never gonna give you up",
4+
"version": "1.0",
5+
"bbs_version": "4.0",
6+
"installed": 1,
7+
"enable": 1,
8+
"hooks_rank": [],
9+
"dependencies": []
10+
}

hook/post_message_after.htm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
include_once APP_PATH.'plugin/xn_recaptcha/hook/recaptcha.php';
3+
$btn = $conf['user_create_email_on'] ? '#sendcode' : '#submit';
4+
$script = <<<SCRIPT
5+
SCRIPT;
6+
echo getRecaptchaScript('thread_create', $script);
7+
?>

hook/post_post_start.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include APP_PATH.'plugin/xn_recaptcha/util/validate.php';
2+
validate('quick_reply');

hook/recaptcha.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
include_once APP_PATH.'plugin/xn_recaptcha/util/validate.php';
3+
function getRecaptchaScript($moduleName, $script) {
4+
$config = getConfig();
5+
if (empty($config['enable'][$moduleName])) return ;
6+
$config = setting_get('xn_recaptcha');
7+
$config = $config ? json_decode($config, true) : $config = array(
8+
"sitekey" => "",
9+
"secret" => ""
10+
);
11+
include_once APP_PATH.'plugin/xn_recaptcha/hook/template.htm';
12+
?>
13+
14+
<script src="https://www.recaptcha.net/recaptcha/api.js" async defer></script>
15+
16+
17+
<?php }?>

hook/template.htm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div name="recaptcha-box" id="recaptcha" class="g-recaptcha" data-sitekey="data-sitekey" data-callback="captcha_onclick" data-expired-callback="captcha_onclick">
2+
</div>
3+
<script>
4+
document.getElementById("recaptcha").setAttribute('data-sitekey','<?php echo $config['sitekey'];?>');
5+
</script>
6+
<input type="hidden" name="recaptcha" id="recaptchaValidator" />
7+
<script>
8+
function captcha_onclick() {
9+
document.getElementById('recaptchaValidator').value = grecaptcha.getResponse();
10+
}
11+
</script>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include APP_PATH.'plugin/xn_recaptcha/util/validate.php';
2+
validate('thread_create');
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
include_once APP_PATH.'plugin/xn_recaptcha/hook/recaptcha.php';
3+
$btn = $conf['user_create_email_on'] ? '#sendcode' : '#submit';
4+
$script = <<<SCRIPT
5+
SCRIPT;
6+
echo getRecaptchaScript('quick_reply', $script);
7+
?>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
include_once APP_PATH.'plugin/xn_recaptcha/hook/recaptcha.php';
3+
$btn = $conf['user_create_email_on'] ? '#sendcode' : '#submit';
4+
$script = <<<SCRIPT
5+
SCRIPT;
6+
echo getRecaptchaScript( $conf['user_create_email_on'] ? 'email_code' : 'user_create', $script);
7+
?>

hook/user_create_post_start.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include_once APP_PATH.'plugin/xn_recaptcha/util/validate.php';
2+
validate('user_create');

hook/user_login_password_after.htm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
include_once APP_PATH.'plugin/xn_recaptcha/hook/recaptcha.php';
3+
$btn = $conf['user_create_email_on'] ? '#sendcode' : '#submit';
4+
$script = <<<SCRIPT
5+
SCRIPT;
6+
echo getRecaptchaScript('user_login', $script);
7+
?>

0 commit comments

Comments
 (0)