Forums / All Other Contributions/Addons / Simple CSS/PHP AntiSpam solution for a contact form

Simple CSS/PHP AntiSpam solution for a contact form

Views: 49,007

Results 41 to 60 of 131
16 Sep 2011, 9:32 AM
#41
devolutio avatar

devolutio

New Zenner

Join Date:
May 2011
Posts:
10
Plugin Contributions:
0

Simple CSS/PHP AntiSpam solution for a contact form

I've been getting around 2-4 fake signups a day.
Here is a simple interpretation of the contact us version on the first page.

NOTE: your_template should be replaced with the name of your template

Step 1:
open:
/public_html/includes/templates/template_default/templates/tpl_modules_create_account.php

insert:
<input style="visibility:hidden; display:none;" name="leaveblank" type="text">
(mine went to line 78)

save to:
/public_html/includes/templates/your_template/templates/tpl_modules_create_account.php

Step 2:
open
/public_html/includes/modules/create_account.php

insert:
$leaveblank = zen_db_prepare_input($_POST["leaveblank"]);
(mine went to line 93)

insert:
// hidden anti-spam field
if(empty($leaveblank)) {
$error = true;
}
(mine went to 493)

save to:
/public_html/includes/modules/your_template/create_account.php

I guess I'll find out tomorrow if it works against bots.

23 Sep 2011, 3:02 PM
#42
feznizzle avatar

feznizzle

Totally Zenned

Join Date:
Apr 2010
Posts:
900
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

devolutio:

I've been getting around 2-4 fake signups a day.
.......
.......
.......
I guess I'll find out tomorrow if it works against bots.

Hi devolutio,

Did it work?

Thanks,
Mike

27 Sep 2011, 1:28 AM
#43
onlyseadoo avatar

onlyseadoo

New Zenner

Join Date:
Feb 2011
Posts:
43
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

devolutio:

Here is a simple interpretation of the contact us version on the first page....
I guess I'll find out tomorrow if it works against bots.

X2 on that question. Did that work? Also when you inserted the code in the two files does it need to go any certain place (beginning/end)? Since I'm not an expert at programming any further simple instruction on making this work for the Registration page would be appreciated. Thanks!

29 Sep 2011, 4:46 AM
#44
devolutio avatar

devolutio

New Zenner

Join Date:
May 2011
Posts:
10
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

OnlySeaDoo:

X2 on that question. Did that work? Also when you inserted the code in the two files does it need to go any certain place (beginning/end)? Since I'm not an expert at programming any further simple instruction on making this work for the Registration page would be appreciated. Thanks!

Almost 2 weeks and not a single fake signup.

As for where to insert the code, I put in brackets what line I inserted my code... ie (mine went to line 78).

Be sure to make a backup of any files you are about to edit (if not your entire site), and try to insert the code as close to where I inserted it. Have a look at the line I've specified and you should get the idea.

3 Oct 2011, 6:50 AM
#45
louis323 avatar

louis323

New Zenner

Join Date:
Jan 2011
Posts:
6
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

can someone upload the php files? so i can see where you have put the lines ?

3 Oct 2011, 7:10 AM
#46
devolutio avatar

devolutio

New Zenner

Join Date:
May 2011
Posts:
10
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

don't take this the wrong way, but if you can't work out what to do with what i've given, I dare say you shouldn't be editing files that WILL STOP customers from shopping at your store if you get it wrong...

good luck!

3 Oct 2011, 3:31 PM
#47
eentje avatar

eentje

Zen Follower

Join Date:
Jan 2009
Location:
The Netherlands/Germany
Posts:
144
Plugin Contributions:
4

Re: Simple CSS/PHP AntiSpam solution for a contact form

Iǘe prepared the files with this CSS trick for login... see attachment.

Use at own risk off course .

I came, I saw, I got zenned... :)

4 Oct 2011, 9:34 PM
#48
northfork avatar

northfork

New Zenner

Join Date:
Oct 2004
Location:
Montana
Posts:
43
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

Just a note: Eentje's files are from 2007. You might want to merge into the current 1.39h files before using them.

4 Oct 2011, 10:06 PM
#49
eentje avatar

eentje

Zen Follower

Join Date:
Jan 2009
Location:
The Netherlands/Germany
Posts:
144
Plugin Contributions:
4

Re: Simple CSS/PHP AntiSpam solution for a contact form

You are right these are the files from 1.3.8a i forgot to mention.

But the 1.3.9 files are not that much different and when you open the files in an editor you'll see the additions clearly marked.

As it is past midnight here i'll make the files for 1.3.9 in the morning.

I came, I saw, I got zenned... :)

4 Oct 2011, 11:07 PM
#50
northfork avatar

northfork

New Zenner

Join Date:
Oct 2004
Location:
Montana
Posts:
43
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

if (!empty($leaveblank)) {
zen_redirect(zen_href_link(FILENAME_DEFAULT));

I wish we could send the bots somewhere good. I'd like to send them off the site, at least.

5 Oct 2011, 4:42 AM
#51
makenoiz avatar

makenoiz

Zen Follower

Join Date:
Mar 2006
Posts:
284
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

Thanks for all who have contributed to this thread. This is much much lighter and more customer friendly than a captcha!

Remember the bots fill in the hidden form because they read the code and think its a valid input field. We test to see if the hidden field IS filled in. If it is, then its a bot, if it is not filled in then its a human and is A-OK. Some folks are having a hard time with the logic

filled in hidden form = bot > fail/redirect
empty hidden form = human > pass

...........

Just implemented on 1.3.9h create an account and Seems to work. I disabled the inline css, Filled out all the fields - including the one that should be hidden -as a bot would, and no new customer. I have mine redirecting like this:

// FOOL-A-ROBOT-HACK ZC POST 1069448 vf
if (!empty($leaveblank)) {
zen_redirect(zen_href_link(FILENAME_TIME_OUT, 'action=success'));
}

On to add to Contact Us now ........

22 stores and counting! Ive been zenned.

14 Oct 2011, 11:56 PM
#52
elarya avatar

elarya

New Zenner

Join Date:
Mar 2008
Posts:
55
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

devolutio:

don't take this the wrong way, but if you can't work out what to do with what i've given, I dare say you shouldn't be editing files that WILL STOP customers from shopping at your store if you get it wrong...

good luck!

I don't think anyone will take it wrong. Everyone appreciates anyone who takes the time to help out. However, I will say (and speaking for myself only) it helps to understand "the why" of things to further our knowledge. For example, I cannot work out what to do with your instructions with what you have given but I do not feel I shouldn't be editing those files, especially when I have a backup.

I think if I understood for example why yours when on "line 78" then I could figure out where mine should go (in case our 78s are different). I tend to learn by example and I think that may be why many people are asking for an example.

I am going to go again slowly through this entire thread. I am still a novice but I am determined to figure this out as these signups are becoming a mini nightmare on my site.

10 Nov 2011, 11:29 PM
#53
shartlesville avatar

shartlesville

New Zenner

Join Date:
Jul 2009
Location:
Roswell, NM, USA
Posts:
103
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

I've been adding mods, updating, and generally mucking around in the zen code for the past two years and I have to say, "Wow, this was the most confusing change I have ever had to make!" :frusty:

That said, I worked it out for both the Contact Us and the Report A Price mod. (I have not figured out the Create Account yet b/c the header file looks NOTHING like the ones in the examples, lol).

Here is what I did on the contact us form:

in **/includes/templates/template_default/tpl_contact_us_default.php **find:

<label class="inputLabel" for="email-address"><?php echo ENTRY_EMAIL; ?></label>
<?php echo zen_draw_input_field('email', ($email_address), ' size="40" id="email-address"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?>
<br class="clearBoth" />

directly under it put this:

<!-- NOSPAM -->
<input style="visibility:hidden; display:none;" name="leaveblank" type="text">
<br class="clearBoth" />
<!-- NO SPAM -->

:eek:*** You probably should save this and upload it to YOURTEMPLATE folder as well so it won't be over-ridden with an update. ***:Flush:

Then in includes/modules/pages/contact_us/header.php make the following changes:

Highlight this (around line 14): ```
$error = false;
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
$name = zen_db_prepare_input($_POST['contactname']);
$email_address = zen_db_prepare_input($_POST['email']);
$subject = zen_db_prepare_input($_POST['subject']);
$enquiry = zen_db_prepare_input(strip_tags($_POST['enquiry']));

$zc_validate_email = zen_validate_email($email_address);
if ($zc_validate_email and !empty($enquiry) and !empty($name)) {

and replace it with this: 

$error = false;
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
$name = zen_db_prepare_input($_POST['contactname']);
$email_address = zen_db_prepare_input($_POST['email']);
$subject = zen_db_prepare_input($_POST['subject']);
// NO SPAM
$leaveblank = zen_db_prepare_input($_POST["leaveblank"]);
// NO SPAM
$enquiry = zen_db_prepare_input(strip_tags($_POST['enquiry']));

//edited for NO SPAM
$zc_validate_email = zen_validate_email($email_address);

if ($zc_validate_email and !empty($enquiry) and !empty($name) and !empty($subject) and empty($leaveblank)) {


Then find (around line 93): ```
    if (empty($enquiry)) {
      $messageStack->add('contact', ENTRY_EMAIL_CONTENT_CHECK_ERROR);
    }

Directly under it add: ```
//NO SPAM
if (!empty($leaveblank)) {
zen_redirect(zen_href_link(FILENAME_TIME_OUT, 'action=success'));
}
//NO SPAM


**Test the form** normally to make sure you DO get mail from customers.  Then using firefox, disable the inline CSS styles filling out all the lines including the one that should be blank.  When you hit send, you should be redirected to the session timed out page.  If you get blank pages or the email goes through when it shouldn't, verify all the changes for missing punctuation and check the CACHE file for errors.

**For the Report A Cheaper Price mod** in **includes/templates/template_default/tpl_report_a_price_default.php** find (about line 74): 

<label class="inputLabel" for="email-address"><?php echo ENTRY_EMAIL; ?></label>

<?php echo zen_draw_input_field('email', ($error ? $_POST['email'] : $email), ' size="40" id="email-address"') . '<span class="alert">' . ENTRY_REQUIRED_SYMBOL . '</span>'; ?> <br class="clearBoth" /> ``` directly under it add: ``` <!-- NOSPAM --> <input style="visibility:hidden; display:none;" name="leaveblank" type="text"> <br class="clearBoth" /> <!-- NO SPAM --> ```

Then in includes/modules/pages/report_a_price/header.php find (about line 35):

$error = false;
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
  $name = zen_db_prepare_input($_POST['contactname']);
  $email_address = zen_db_prepare_input($_POST['email']);
  $other_store = zen_db_prepare_input(strip_tags($_POST['other_store']));
  $other_store_location = zen_db_prepare_input(strip_tags($_POST['other_store_location']));
  $other_price = zen_db_prepare_input(strip_tags($_POST['other_price']));

  $zc_validate_email = zen_validate_email($email_address);

  if ($zc_validate_email and !empty($other_store) and !empty($other_store_location) and !empty($other_price) and !empty($name)) {

Replace with

$error = false;
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
  $name = zen_db_prepare_input($_POST['contactname']);
  $email_address = zen_db_prepare_input($_POST['email']);
  // NO SPAM
  $leaveblank = zen_db_prepare_input($_POST['leaveblank']);
  // NO SPAM
  $other_store = zen_db_prepare_input(strip_tags($_POST['other_store']));
  $other_store_location = zen_db_prepare_input(strip_tags($_POST['other_store_location']));
  $other_price = zen_db_prepare_input(strip_tags($_POST['other_price']));

  $zc_validate_email = zen_validate_email($email_address);

  if ($zc_validate_email and !empty($other_store) and !empty($other_store_location) and !empty($other_price) and !empty($name) and empty($leaveblank)) {

Test the form normally to make sure you DO get mail from customers. Then using firefox, disable the inline CSS styles filling out all the lines including the one that should be blank. When you hit send, you should be redirected to the session timed out page. If you get blank pages or the email goes through when it shouldn't, verify all the changes for missing punctuation and check the CACHE file for errors.

If you get a blank page after this, check for syntax errors - I had an extra } on line 128 next to ```
} // end action==send


If anyone knows the edits for the Create Account pages, please let me know.  :wacko:

Thank you!
Blessings,
K

I donate to the Zen Team do you?
My current project: BestSewingDeals.com;

10 Dec 2011, 3:49 PM
#54
windsurfer avatar

windsurfer

Zen Follower

Join Date:
Jun 2011
Posts:
185
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

Is there a mod available for version 1.5 or will the above work ?

If you wait to do everything until you're sure it's right, you'll probably never do much of anything !!!

28 Dec 2011, 5:18 PM
#55
decostyle avatar

decostyle

Zen Follower

Join Date:
Mar 2008
Posts:
336
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

Worked!!! Thank you!

eentje:

Iǘe prepared the files with this CSS trick for login... see attachment.

Use at own risk off course .

28 Dec 2011, 10:23 PM
#56
paperthreads avatar

paperthreads

Zen Follower

Join Date:
Sep 2006
Posts:
142
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

adem.i:

I found the solution to the problem I had previously discussed.

for some reason, I didn't have a subject box and in the code in this thread , the line '!empty($name) and !empty($subject) and empty($leaveblank)) {' can't be used because when a real person submits enter, zen cart will be waiting for an entry in a subject box that doesn't exist, so just modify the line by

!empty($name) and empty($leaveblank)) {

alone

Thanks, I too don't have a subject line, so edited per your suggestion, and got this to work finally!

5 Jan 2012, 10:46 AM
#57
yaseent avatar

yaseent

Zen Follower

Join Date:
Mar 2009
Posts:
169
Plugin Contributions:
1

Re: Simple CSS/PHP AntiSpam solution for a contact form

dlg_ie:

Hi Everyone,

here is a very simple and modest contribution for all those who get spams sent with their contact forms.

You're a damn champion Denis.

Hate to have to use the word "stupid" but some customers...well...Let's just say they're CAPTCHA-CHALLENGED.

12 Jan 2012, 9:18 PM
#58
windsurfer avatar

windsurfer

Zen Follower

Join Date:
Jun 2011
Posts:
185
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

Just installed shartlesville spam modification this in V1.5 and works like a charm. Thank you so much :)

If you wait to do everything until you're sure it's right, you'll probably never do much of anything !!!

12 Jan 2012, 11:02 PM
#59
windsurfer avatar

windsurfer

Zen Follower

Join Date:
Jun 2011
Posts:
185
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

Hey eentje your anti spam create account mod works like a bute in V1.5 :clap::clap::clap:

If you wait to do everything until you're sure it's right, you'll probably never do much of anything !!!

15 Mar 2012, 1:47 PM
#60
micmed avatar

micmed

Zen Follower

Join Date:
Mar 2008
Location:
The Free South
Posts:
165
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

I have this working in 1.3.9h on the Create Account and Contact Us forms thanks to the work of shartlesville and eentje. 1.5 is next.

www.theCableStation.com
"If we restrict liberty to attain security we will lose them both."