Jump to content



Photo
- - - - -

osC reCaptcha


  • Please log in to reply
113 replies to this topic

#1   olsonsp4c

olsonsp4c
  • Members
  • 548 posts
  • Real Name:Scott Olson
  • Gender:Male
  • Location:Colorado Springs, CO

Posted 16 October 2008 - 21:07

This is the support form for the addon osC reCaptcha: http://addons.oscommerce.com/info/6306

This places a reCaptcha validation code box at the bottom of your form pages to eliminate SPAM and bot submissions from your website.

Currently works on:
Create Account
Contact Us
Tell a Friend

Addon Support:
Wholesale Inquiries
Customer Testimonials (in progress)

Edited by olsonsp4c, 16 October 2008 - 21:14.


#2   carryG

carryG
  • Members
  • 125 posts
  • Real Name:Carry G
  • Gender:Female
  • Location:USA

Posted 18 October 2008 - 04:06

Installed this on a perfectly new contact_us.php file (after doing all the other steps). Everything appears to work fine, enter code, etc and click send. It goes to a blank screen. If i remove the oscid number after it and hit enter, it responds with:

our E-Mail Address does not appear to be valid - please make any necessary corrections.
Error The Security Code was not entered correctly. (reCAPTCHA output: incorrect-captcha-sol)

I have tried everything on this, its a vanilla install of the cart, no mods - setup this way to have a pure test. Yet it won't work.

Any suggestions?

--------------------------------------------------------
on further testing....just a blank contact_us.php (untouched) yields this blank screen after you click send - seems like it craps when it adds oscid.

Edited by carryG, 18 October 2008 - 04:19.


#3   carryG

carryG
  • Members
  • 125 posts
  • Real Name:Carry G
  • Gender:Female
  • Location:USA

Posted 18 October 2008 - 05:43

disregard, got it working.

Had to change tld.txt and add gmail, etc.

#4   olsonsp4c

olsonsp4c
  • Members
  • 548 posts
  • Real Name:Scott Olson
  • Gender:Male
  • Location:Colorado Springs, CO

Posted 18 October 2008 - 14:14

disregard, got it working.

Had to change tld.txt and add gmail, etc.


I apologize, but could you elaborate a little bit on this and explain a little more on this so that others could understand what you did, in case they have the same problem? Thanks!

Scott

#5   rexx

rexx
  • Members
  • 16 posts
  • Real Name:Rexx

Posted 19 October 2008 - 02:30

Hello Scott,
Great contribution! Installation was flawless with my heavily modded site.
Just one simple issue that has me puzzled. I have a dark background, almost black, for the store.
The problem is that the user can not see what is entered, as it is black on black. I have searched many places and found a few similar questions on other forums over the past year. Most had no replies, but the ones that did have a reply, was the link to the recaptcha documentation on the development website.
I even created a new tad in my .CSS called {main2}. Was similar to my original {main} .CSS tag, but changed it to the color to FFFFFF. It changed the cell where the recaptcha box located on the CONTACT US form, but still was 'black on black'.

Hope you might some input on this issue.

'Rexx

#6   Coopco

Coopco
  • Members
  • 9,557 posts
  • Real Name:Leslie Cooper
  • Gender:Male
  • Location:Sea Lake, Victoria, Australia

Posted 19 October 2008 - 04:01

I apologize, but could you elaborate a little bit on this and explain a little more on this so that others could understand what you did, in case they have the same problem? Thanks!

Scott

The tld.txt file is in the includes directory and lists the com net org etc but I don't know how gmail could be added.


The Coopco Underwear Shop



If you live to be 100 years of age, that means you have lived for 36,525 days. Don't waste another, there aren't many left.

#7   Robbogeordie

Robbogeordie
  • Members
  • 55 posts
  • Real Name:Chris

Posted 19 October 2008 - 17:46

The tld.txt file is in the includes directory and lists the com net org etc but I don't know how gmail could be added.

It would be great with "Ask a (product) question" as well.

#8   rexx

rexx
  • Members
  • 16 posts
  • Real Name:Rexx

Posted 19 October 2008 - 19:48

It would be great with "Ask a (product) question" as well.


The instructions for ASK A QUESTION would be the same as TELL A FRIEND, as it was cloned from that.

In catalog/ask_a_question.php

Find this:

require('includes/application_top.php');

Insert this AFTER:

// start modification for reCaptcha
require_once('includes/classes/recaptchalib.php');
require_once('includes/recaptchakeys.php');
// end modification for reCaptcha


Find this:

if ($error == false) {
$email_subject = sprintf(TEXT_EMAIL_SUBJECT, $from_name, STORE_NAME);
$email_body = sprintf(TEXT_EMAIL_INTRO, $to_name, $from_name, $product_info['products_name'], STORE_NAME) . "\n\n";

Insert this BEFORE:

// start modification for reCaptcha
// the response from reCAPTCHA
$resp = null;

// was there a reCAPTCHA response?
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
$error = true;

$messageStack->add('friend', ENTRY_SECURITY_CHECK_ERROR . " (reCAPTCHA output: " . $resp->error . ")");
}
// end modification for reCaptcha


Find this:

<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
</tr>
<tr>
<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
<tr class="infoBoxContents">
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
<td><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
<td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></form></td>
<!-- body_text_eof //-->
<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->

Insert this BEFORE:

<!-- start modification for reCaptcha -->
<tr>
<td class="main"><?php echo ENTRY_SECURITY_CHECK; ?></td>
</tr>
<tr>
<script>
var RecaptchaOptions = {
theme : 'white',
tabindex : 3
};
</script>
<td class="main"><?php echo recaptcha_get_html($publickey); ?></td>
</tr>
<!-- end modification for reCaptcha -->


**********
* Step 6 *
**********

In catalog/includes/languages/xxxxxxx/ask_a_question.php

Find the ENDING:

?>

Insert this BEFORE:

define('ENTRY_SECURITY_CHECK', 'Security Code:');
define('ENTRY_SECURITY_CHECK_ERROR', 'The Security Code was not entered correctly.');

========
** END **
========

Remember to backup first.

'Rexx

#9   Coopco

Coopco
  • Members
  • 9,557 posts
  • Real Name:Leslie Cooper
  • Gender:Male
  • Location:Sea Lake, Victoria, Australia

Posted 19 October 2008 - 19:49

Ooops.

Edited by Coopco, 19 October 2008 - 19:49.



The Coopco Underwear Shop



If you live to be 100 years of age, that means you have lived for 36,525 days. Don't waste another, there aren't many left.

#10   olsonsp4c

olsonsp4c
  • Members
  • 548 posts
  • Real Name:Scott Olson
  • Gender:Male
  • Location:Colorado Springs, CO

Posted 20 October 2008 - 05:44

Rex

I think that there is not a way to change this as the recaptcha images and such is pulled dynamically from their servers... you might checkout the reCaptcha forums on this one...

Scott

#11   olsonsp4c

olsonsp4c
  • Members
  • 548 posts
  • Real Name:Scott Olson
  • Gender:Male
  • Location:Colorado Springs, CO

Posted 20 October 2008 - 23:54

osC reCaptcha v1.1 is out: http://addons.oscommerce.com/info/6306

Added full support for Customer Testimonials v3.6+: http://addons.oscommerce.com/info/5477

Scott

#12   PetterK

PetterK
  • Members
  • 124 posts
  • Real Name:Petter Kvalsvik
  • Location:Norway

Posted 26 October 2008 - 20:27

Nice contrib, thanks!
I'm trying to implement it on a "sligtly" older (but otherwise fully working) version of osC.
This line in contact_us.php is completely missing:
$messageStack->add('contact', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
...and the result is that the e-mail address is rendered not valid.

To be hones I'm not sure if it is possible to implement at all, but if someone can see how/where to insert reCaptcha-code in this segment it would be much appreiciated:

require('includes/application_top.php');

$enquiry = $HTTP_POST_VARS['enquiry'];
$name = $HTTP_POST_VARS['name'];
$email = $HTTP_POST_VARS['email'];
$enquiry = '';
$name = '';
$email = '';

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CONTACT_US);

  $error = false;
  if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send')) { 
	if (tep_validate_email(trim($HTTP_POST_VARS['email']))) { 
	  tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, 'Sent from IP: ' . $REMOTE_ADDR . "\n\n" . $HTTP_POST_VARS['enquiry'], $HTTP_POST_VARS['name'], $HTTP_POST_VARS['email']); 
	  tep_redirect(tep_href_link(FILENAME_CONTACT_US, 'action=success', 'NONSSL')); 
	} else { 
	  $error = true; 
	} 
  }

  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CONTACT_US));

Petter - Arktisk Pudder

#13   PetterK

PetterK
  • Members
  • 124 posts
  • Real Name:Petter Kvalsvik
  • Location:Norway

Posted 27 October 2008 - 10:44

I upgraded the contact_us.php, added message_stack.php to includes/classes and edited my application_top.php /rolleyes.gif' class='bbc_emoticon' alt=':rolleyes:' />

It works now, but it seems that some typing-errors slip through; anyone else noted this?
Petter - Arktisk Pudder

#14   olsonsp4c

olsonsp4c
  • Members
  • 548 posts
  • Real Name:Scott Olson
  • Gender:Male
  • Location:Colorado Springs, CO

Posted 27 October 2008 - 15:12

I upgraded the contact_us.php, added message_stack.php to includes/classes and edited my application_top.php /rolleyes.gif' class='bbc_emoticon' alt=':rolleyes:' />

It works now, but it seems that some typing-errors slip through; anyone else noted this?


glad to know it works now - if you could post any code changes you did and mention what version of osC you are using (MS2? rc1? rc2a?) then your changes might help a bunch of people add this to their older versions of osC... thanks! I have noticed that reCaptcha has an allowance for 1 or so typing errors occasionally and I don't know why...

Scott

#15   PetterK

PetterK
  • Members
  • 124 posts
  • Real Name:Petter Kvalsvik
  • Location:Norway

Posted 27 October 2008 - 16:34

My store is running a (fine-tuned to my needs) version of Loaded v.5 (based on osc snapshot 16th Febrauary 2003 (MS1 Releases).

As message_stack.php does not exist in Loaded v.5 I descided to try to drop it in includes/classes and it worked right out of the box with the contact_us.php from v2.2 RC2.
Id: contact_us.php 1739 2007-12-20 00:52:16Z hpdl
Id: message_stack.php 1740 2007-12-20 14:57:13Z hpdl

Apart from that I just modifyed my application_top.php by adding this at the end:

// initialize the message stack for output messages
  require(DIR_WS_CLASSES . 'message_stack.php');
  $messageStack = new messageStack;
?>

Petter - Arktisk Pudder

#16   olsonsp4c

olsonsp4c
  • Members
  • 548 posts
  • Real Name:Scott Olson
  • Gender:Male
  • Location:Colorado Springs, CO

Posted 27 October 2008 - 16:36

Thank you Petter...

#17   olsonsp4c

olsonsp4c
  • Members
  • 548 posts
  • Real Name:Scott Olson
  • Gender:Male
  • Location:Colorado Springs, CO

Posted 28 October 2008 - 06:08

I am working through the process of making all my forms encrypted using SSL - if you plan on doing this as well (and it would be a good idea), reCaptcha provides a SSL API so that your customers don't get the dreaded "insecure items on the page" popup or a little security lock with an alert! Here's what to change.

In every file you installed reCaptcha on (You must have an SSL certificate installed to use this) -

Find this:

<td class="main"><?php echo recaptcha_get_html($publickey); ?></td>

REPLACE with this:

<td class="main"><?php echo recaptcha_get_html($publickey, null, true); ?></td>

That's it - now you have a secured reCaptcha.

Scott

#18   olsonsp4c

olsonsp4c
  • Members
  • 548 posts
  • Real Name:Scott Olson
  • Gender:Male
  • Location:Colorado Springs, CO

Posted 18 November 2008 - 19:58

osC reCaptcha 1.3 is out: http://addons.oscommerce.com/info/6306

Since v1.2
----------
* Added reCaptcha support for Store Mode Addon (1.2+): http://addons.oscommerce.com/info/6332

Scott

#19   SteveDallas

SteveDallas
  • Members
  • 725 posts
  • Real Name:Glen
  • Gender:Male
  • Location:Alabama, US

Posted 21 November 2008 - 16:00

I am working through the process of making all my forms encrypted using SSL - if you plan on doing this as well (and it would be a good idea), reCaptcha provides a SSL API so that your customers don't get the dreaded "insecure items on the page" popup or a little security lock with an alert! Here's what to change.

In every file you installed reCaptcha on (You must have an SSL certificate installed to use this) -

Find this:

<td class="main"><?php echo recaptcha_get_html($publickey); ?></td>

REPLACE with this:

<td class="main"><?php echo recaptcha_get_html($publickey, null, true); ?></td>

That's it - now you have a secured reCaptcha.

Scott


Scott,
A better solution is to use the following:

<td class="main"><?php echo recaptcha_get_html($publickey, null, ($request_type == 'SSL')); ?></td>

This version works for both secured and non-secured pages. includes/application_top.php sets the $request_type variable to either SSL or NONSSL, depending on how the page was called.

--Glen

#20   SteveDallas

SteveDallas
  • Members
  • 725 posts
  • Real Name:Glen
  • Gender:Male
  • Location:Alabama, US

Posted 21 November 2008 - 18:48

Hello Scott,
Great contribution! Installation was flawless with my heavily modded site.
Just one simple issue that has me puzzled. I have a dark background, almost black, for the store.
The problem is that the user can not see what is entered, as it is black on black. I have searched many places and found a few similar questions on other forums over the past year. Most had no replies, but the ones that did have a reply, was the link to the recaptcha documentation on the development website.
I even created a new tad in my .CSS called {main2}. Was similar to my original {main} .CSS tag, but changed it to the color to FFFFFF. It changed the cell where the recaptcha box located on the CONTACT US form, but still was 'black on black'.

Hope you might some input on this issue.

'Rexx


The reCAPTCHA Wiki has instructions for doing this. You can set the theme to "clean" as below, then override the CSS styles to match your site.

<script>
		var RecaptchaOptions = {
		   theme : 'clean',
		   tabindex : 4
		};
		</script>

The Wiki notes that the method is unsupported and may fail in a future release.

I have added the following to my stylesheet.css to set the colors to create a borderless infoBox. I put the reCAPTCHA box on my Contact Us page, but moved it right below the "Enquiry" textarea, so that it looks better.

/* BOF osC reCAPTCHA */
 .recaptchatable .recaptcha_image_cell, #recaptcha_table {
   background-color: #f8f8f9 !important; /* reCaptcha widget background color */
 }
 
 #recaptcha_table {
   border-color: #f8f8f9 !important;	 /* reCaptcha widget border color */
 }
 
 #recaptcha_response_field {
   border-color: #b6b7cb !important;	 /* Text input field border color */
   background-color:#ffffff !important;  /* Text input field background color */
   color: #000000						/* Text input field font color */
 }
/* EOF osC reCAPTCHA */

Below is an image showing where I put the box. This shows the default osC color scheme, but you should be able to set it to any color, as long as there is sufficient contrast on the buttons and the "reCAPTCHA" logo. This shows a white background and black text, but I have tested white text on black background by setting the appropriate colors in #recaptcha_response_field.

[img]http://www.glensgarage.com/images/contact_us.jpg[/img]
--Glen