recaptcha验证码可以有效防止发帖机发帖
下面是我测试很久找到的添加recaptcha验证码的方法
添加前,请替换你自己的KEY
第一步,模板添加客户端代码
文件路径 template\default\forum\post.htm
目标定位到 $seccodecheck ,选择添加下面部分代码
<div id="seccheck"> <!--{if $secqaacheck || $seccodecheck}--> <!--{subtemplate forum/seccheck_post}--> <!--{/if}--> <!--{if $_GET[action] == 'newthread'}--> <div class="g-recaptcha" data-sitekey="XXfjCXXXAAAAAMzCuvDbuGoekD3P0nGwTQ3MVlXI"></div> <script src='https://www.recaptcha.net/recaptcha/api.js' async defer></script> <!--{/if}--> </div>
第二步,添加服务端代码
文件路径 source\include\post\post_newthread.php
目标定位到 Access Denied 下面
$secret = 'XXXjCXXXAAAAADPK1p_3R87YEGBkxmYKy4D8sXXX' ; $pass = $subject ; if( $pass && !empty($_POST['g-recaptcha-response'])) { $verifyResponse = file_get_contents('https://www.recaptcha.net/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response']); $responseData = json_decode($verifyResponse); if (!$responseData->success) { showmessage('验证码输入不正确!' ); } } elseif( $_G['groupid'] == 10 && $pass && !$_POST["recaptcha_response_field"]) { showmessage('请输入验证码!'); }
此处评论已关闭