Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Product review fixed when error message is returned. Also added check…
… to only attempt recapcha call if no other errors are set first which stops invalidating the saved token.

Close #2843 #2839
  • Loading branch information
jamesallsup committed Apr 2, 2015
1 parent 7d26b0c commit fc95639
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog.md
Expand Up @@ -5,6 +5,7 @@
* Mail config hostname variable (https://github.com/opencart/opencart/issues/2840)
* Order status id INT size in install.sql (https://github.com/opencart/opencart/issues/2820)
* Fix admin alert email for new customer.
* Product review fixed when error message is returned.

#### Changes
* Added pre & post triggers for customer log in
Expand Down
12 changes: 8 additions & 4 deletions upload/catalog/controller/product/product.php
Expand Up @@ -624,12 +624,16 @@ public function write() {
$json['error'] = $this->language->get('error_rating');
}

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']);
if ($this->config->get('config_google_captcha_status') && empty($json['error'])) {
if (isset($this->request->post['g-recaptcha-response'])) {
$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);
$recaptcha = json_decode($recaptcha, true);

if (!$recaptcha['success']) {
if (!$recaptcha['success']) {
$json['error'] = $this->language->get('error_captcha');
}
} else {
$json['error'] = $this->language->get('error_captcha');
}
}
Expand Down
Expand Up @@ -69,7 +69,7 @@
<?php } ?>
<?php if ($review_status) { ?>
<div class="tab-pane" id="tab-review">
<form class="form-horizontal">
<form class="form-horizontal" id="form-review">
<div id="review"></div>
<h2><?php echo $text_write; ?></h2>
<?php if ($review_guest) { ?>
Expand Down Expand Up @@ -570,7 +570,7 @@ $('#button-review').on('click', function() {
url: 'index.php?route=product/product/write&product_id=<?php echo $product_id; ?>',
type: 'post',
dataType: 'json',
data: 'name=' + encodeURIComponent($('input[name=\'name\']').val()) + '&text=' + encodeURIComponent($('textarea[name=\'text\']').val()) + '&rating=' + encodeURIComponent($('input[name=\'rating\']:checked').val() ? $('input[name=\'rating\']:checked').val() : ''),
data: $("#form-review").serialize(),
beforeSend: function() {
$('#button-review').button('loading');
},
Expand Down

0 comments on commit fc95639

Please sign in to comment.