For several reasons, I wanted to offer a contest for non-registered visitors. I soon found that my contest was filled with unwanted spam entries so I embedded reCAPTCHA into the template.
Here is how to do it if you are interested
If you haven't already, go to http://recaptcha.net/whyrecaptcha.html
- Sign up for an account.
- Register for your Public and Private Key
- Download the reCAPTCHA library and upload recaptchalib.php to your cart's root directory.
In /templates/your template/templates/tpl_contest_default.php
Find
Code:
} else { // Contest NOT Closed
// Retrieve Prize details
$sql_query = "select p.products_id, p.products_image, p.products_price, pd.products_name, pd.products_description from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and p.products_id ='" . (int)CONTEST_PRIZE_ID . "' and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' limit 1";
$contest_prize = $db->Execute($sql_query);
if (!$contest_prize->RecordCount() > 0) {
// Data base error display warning
echo '<center><br/><table width="80%" border="0" cellpadding="3" cellspacing="3" bgcolor="#FFFF00" >'.
'<tr> '.
'<td align="center"><strong>ADMIN ERROR:</strong> The selected Prize Could Not Be Found.</td>'.
'</tr>'.
'</table></center>';
}
if (isset($_GET['action']) && ($_GET['action'] == 'process')) {
Insert the following immediately thereafter
Code:
// Begin reCAPTCHA code
require_once('recaptchalib.php');
$privatekey = "enter the private key you received";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
}
// End reCAPTCHA code
Be sure to insert your private key where appropriate
Now find
Code:
<?php
if (CONTEST_QUALIFY == "true") {
echo FORM_FIELD_QUALIFING_QUESTION.'<br/>';
// Retrived from Data Base
echo CONTEST_QUESTION;
?>
<label class="inputLabel" for="entry_qualify_answer"><?php echo FORM_FIELD_QUALIFING_ANSWER; ?></label>
<?php echo zen_draw_input_field('entry_qualify_answer', $entry_qualify_answer, ' size="1" id="entry_qualify_answer"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />
<?php
} // End Qualify Question
Insert the following immediately thereafter
Code:
// Begin reCAPTCHA code
require_once('recaptchalib.php');
$publickey = "enter the public key you received";
echo recaptcha_get_html($publickey);
// End reCAPTCHA code
Remember to enter your public key where appropriate.
Save and test.
Works well for me.