如何在Opencart 2x中启用reCAPTCHA v3?

问题描述 投票:0回答:1

我想在Opencart 2x中使用reCAPTCHA v3。

由于Opencart 2默认支持reCAPTCHA,我需要修改一些文件,但我不是那么编码的人。

我在/controller/captcha/google_captcha.php中找到了此代码

class ControllerCaptchaGoogleCaptcha extends Controller {
    public function index($error = array()) {
        $this->load->language('captcha/google_captcha');

        $data['heading_title'] = $this->language->get('heading_title');

        $data['entry_captcha'] = $this->language->get('entry_captcha');

        $this->document->addScript('https://www.google.com/recaptcha/api.js');

        if (isset($error['captcha'])) {
            $data['error_captcha'] = $error['captcha'];
        } else {
            $data['error_captcha'] = '';
        }

        $data['site_key'] = $this->config->get('google_captcha_key');

        $data['route'] = $this->request->get['route']; 

        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/captcha/google_captcha.tpl')) {
            return $this->load->view($this->config->get('config_template') . '/template/captcha/google_captcha.tpl', $data);
        } else {
            return $this->load->view('default/template/captcha/google_captcha.tpl', $data);
        }
    }

    public function validate() {
        $this->load->language('captcha/google_captcha');

        $recaptcha = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($this->config->get('google_captcha_secret')) . '&response=' . $this->request->post['g-recaptcha-response'] . '&remoteip=' . $this->request->server['REMOTE_ADDR']);

        $recaptcha = json_decode($recaptcha, true);

        if (!$recaptcha['success']) {
            return $this->language->get('error_captcha');
        }
    }
}

有任何想法如何修改此文件?

recaptcha opencart2.x recaptcha-v3
1个回答
0
投票

答:不要。 Google的reCAPTCHA令人讨厌。而是阅读此内容并使用提供100%垃圾邮件保护的评论中发布的扩展名并且不可见:https://www.antropy.co.uk/blog/why-enable-captcha-what-is-advanced-captcha-and-how-does-it-prev/

© www.soinside.com 2019 - 2024. All rights reserved.