OpenCart 2.0.3.1
I wanted Google reCaptcha on the registration page, I found one someone was selling, but you needed VqMod well I dont like mod integration as its not good for other reasons.
So What I have done and seems to work fine.
Enabled and got reCaptcha working on site first.
Edited register.tpl
added this code where I wanted recaptcha to be
Code: Select all
<?php if ($site_key) { ?>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="g-recaptcha" data-sitekey="<?php echo $site_key; ?>"></div>
<?php if ($error_captcha) { ?>
<div class="text-danger"><?php echo $error_captcha; ?></div>
<?php } ?>
</div>
</div>
<?php } ?>
Code: Select all
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/contact')
);
Code: Select all
if (isset($this->error['captcha'])) {
$data['error_captcha'] = $this->error['captcha'];
} else {
$data['error_captcha'] = '';
}
Code: Select all
if ($this->config->get('config_google_captcha_status')) {
$this->document->addScript('https://www.google.com/recaptcha/api.js');
$data['site_key'] = $this->config->get('config_google_captcha_public');
} else {
$data['site_key'] = '';
}
Code: Select all
if ($this->config->get('config_google_captcha_status')) {
$recaptcha = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($this->config->get('config_google_captcha_secret')) . '&response=' . $this->request->post['g-recaptcha-response'] . '&remoteip=' . $this->request->server['REMOTE_ADDR']);
$recaptcha = json_decode($recaptcha, true);
if (!$recaptcha['success']) {
$this->error['captcha'] = $this->language->get('error_captcha');
}
}
I'm no coder, but copy & Paste works for me..
I'm after feed back on security with this method and if it will break OpenCart..
site where i have the code is http://speedlogger.net/online/index.php ... t/register check it out working..
Thanks for reading
Tony....