Yeah, finally I got it working...http://espc.altervista.org/index.php?ro ... on/contact
if you want to install recaptcha follow this sample instructions:
First Step
go to http://recaptcha.net/whyrecaptcha.html and sign up for the keys

if you have multiple domains ex. .com .net. org check the box circled in red.
Now you got two keys one for public side and one for private side.
copy and save them on your pc.
go to http://api.recaptcha.net/js/recaptcha_ajax.js
select all text, copy and past it on an new text document on your desktop
rename it to: recaptcha_ajax.js if pc asks "change file extension?" click "yes"
now upload it to catalog/view/javascript
then go http://code.google.com/p/recaptcha/down ... lib-Latest
and download the latest recaptcha library.
Second Step
now we edit this library (recaptchalib.php)
go to line 108 and find and insert your public key
Code: Select all
function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
{
if ($pubkey == null || $pubkey == 'HERE INSERT YOUR PUBLIC KEY') {
die ("To use reCAPTCHA you must get an API key from <a href='http://recaptcha.net/api/getkey'>http://recaptcha.net/api/getkey</a>");
}
Code: Select all
return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>
Code: Select all
return '<script type="text/javascript" src="catalog/view/javascript/recaptcha_ajax.js'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>
find and insert your private key
Code: Select all
function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array())
{
if ($privkey == null || $privkey == 'HERE INSERT YOUR PRIVATE KEY') {
die ("To use reCAPTCHA you must get an API key from <a href='http://recaptcha.net/api/getkey'>http://recaptcha.net/api/getkey</a>");
}
if ($remoteip == null || $remoteip == '') {
die ("For security reasons, you must pass the remote ip to reCAPTCHA");
}
Third Step
Now we are going to edit these files:
-catalog/controller/information/contact.php
-catalog/view/theme/YOURTHEME/template/information/contact.tpl
-catalog/controller/product/product.php
-catalog/view/theme/YOURTHEME/template/product/product.tpl
you better backup them before editing.
we start with: catalog/controller/information/contact.php
on line 65
find
Code: Select all
if (isset($this->error['captcha'])) {
$this->data['error_captcha'] = $this->error['captcha'];
} else {
$this->data['error_captcha'] = '';
}
then on line 97
find
Code: Select all
if (isset($this->request->post['captcha'])) {
$this->data['captcha'] = $this->request->post['captcha'];
} else {
$this->data['captcha'] = '';
}
then on line 162
find
Code: Select all
public function captcha() {
$this->load->library('captcha');
$captcha = new Captcha();
$this->session->data['captcha'] = $captcha->getCode();
$captcha->showImage();
}
}
Code: Select all
public function recaptcha() {
require_once('/system/library/recaptchalib.php');
$privatekey = "HERE INSERT YOUR PRIVATE KEY";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
// Your code here to handle a successful verification
}
}
find
Code: Select all
if (!isset($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {
$this->error['captcha'] = $this->language->get('error_captcha');
}
now we edit -catalog/view/theme/YOURTHEME/template/information/contact.tpl
on line 55
find
Code: Select all
<input type="text" name="captcha" value="<?php echo $captcha; ?>" />
<?php if ($error_captcha) { ?>
<span class="error"><?php echo $error_captcha; ?></span>
<?php } ?>
<br />
<img src="index.php?route=information/contact/captcha" /></td>
Code: Select all
<div id="recaptcha_div"></div><nowiki><br>
<input type="button" value="Show reCAPTCHA" onclick="showRecaptcha('recaptcha_div');"></input>
<br><nowiki></td>
then at the end of file BEFORE
Code: Select all
<?php echo $footer; ?>
Code: Select all
<script type="text/javascript" src="catalog/view/javascript/recaptcha_ajax.js"></script>
<!-- Wrapping the Recaptcha create method in a javascript function -->
<script type="text/javascript">
function showRecaptcha(element) {
Recaptcha.create("HERE INSERT YOUR PUBLIC KEY", element, {
theme: "red",
callback: Recaptcha.focus_response_field});
}
</script>
now we edit catalog/controller/product/product.php
on line 443
find
Code: Select all
public function captcha() {
$this->load->library('captcha');
$captcha = new Captcha();
$this->session->data['captcha'] = $captcha->getCode();
$captcha->showImage();
}
}
Code: Select all
public function recaptcha() {
require_once('/system/library/recaptchalib.php');
$privatekey = "YOUR PRIVATE KEY HERE";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
// Your code here to handle a successful verification
}
}
find
Code: Select all
if ($this->session->data['captcha'] != $this->request->post['captcha']) {
$this->error['message'] = $this->language->get('error_captcha');
}
now we edit catalog/view/theme/YOURTHEME/template/product/product.tpl
on line 129
find
Code: Select all
<input type="text" name="captcha" value="" />
<br />
<img src="index.php?route=product/product/captcha" id="captcha" /></div>
Code: Select all
<div id="recaptcha_div"></div><nowiki><br>
<input type="button" value="Show reCAPTCHA" onclick="showRecaptcha('recaptcha_div');"></input>
<br><nowiki>
<br />
</div>
Code: Select all
<?php echo $footer; ?>
Code: Select all
<script type="text/javascript" src="catalog/view/javascript/recaptcha_ajax.js"></script>
<!-- Wrapping the Recaptcha create method in a javascript function -->
<script type="text/javascript">
function showRecaptcha(element) {
Recaptcha.create("HERE INSERT YOUR PUBLIC KEY", element, {
theme: "red",
callback: Recaptcha.focus_response_field});
}
</script>
if you want to customize your recaptcha
just change theme color in this code
(located in:
catalog/view/theme/YOURTHEME/template/information/contact.tpl
catalog/view/theme/YOURTHEME/template/product/ product.tpl)
Code: Select all
<script type="text/javascript" src="catalog/view/javascript/recaptcha_ajax.js"></script>
<!-- Wrapping the Recaptcha create method in a javascript function -->
<script type="text/javascript">
function showRecaptcha(element) {
Recaptcha.create("", element, {
theme: "HERE INSERT YOUR COLOUR",
callback: Recaptcha.focus_response_field});
}
</script>
THAT'S ALL FOLKS!!
GOOD WORK

