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,009

Results 101 to 120 of 131
25 Sep 2012, 1:10 PM
#101
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Simple CSS/PHP AntiSpam solution for a contact form

lat9:

Would another obfuscation help here? What if there was a database setting that held the name of the "honeypot" field so that the name could be customized? That way, each store could have a unique input field name and, if the name was discovered and spam began arriving, it could be changed via the admin's console.
I think it may be the "hidden" css attribute on the field that they have programmed to ignore. They have no other way of knowing which is the trap in the rendered html page. I can't see any other way around the hidden attribute but the timer is a good idea.


Zen Cart and it's community are the best!!

25 Sep 2012, 4:32 PM
#102
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,018
Plugin Contributions:
2

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

Just thinking out loud for other Field display options:

White on white

Shrink field to 0.1%

25 Sep 2012, 6:04 PM
#103
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

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

dw08gm:

Just thinking out loud for other Field display options:

White on white

Shrink field to 0.1%
Wonder if the white on white would result in a Google penalty of some sort??

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

25 Sep 2012, 6:30 PM
#104
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

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

... and problematic from a usability perspective, such as screen readers and other assistive devices.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

26 Sep 2012, 10:30 PM
#105
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

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

This is how I added a timer to a form to try and filter out fast form-filling by robots....not to be taken as an example of good programming...I write code so I can still understand it the next year/day.
This works for me, no doubt someone will explain why its a bad idea/bad programming but hopefully suggest improvements or a relevant php tutorial.
I did this recently (in addition to a honeypot) for the Ask a Question form as that was getting spammed. As part of my 151 upgrade I am rationalising the antispams across all the forms I have.

The idea is record the server time when the form is generated and subtract it from the time when the form is submitted and if its too fast (you decide), don’t allow it to be processed.

  1. \includes\templates\YOUR_TEMPLATE\templates\tpl_contact_us_default.php

Add another field in the form

<input type="hidden" name="form_load_time" value="<?php echo $_SERVER['REQUEST_TIME']; //when was the form loaded? ?>" />
  1. add the processing in the header
    \includes\modules\pages\contact_us\header_php.php

This section
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
handles the form input fields.

Add these lines inside this “if” section:

$form_load_time = (int)zen_db_prepare_input($_POST['form_load_time']);// when was form loaded
$form_submit_time = $_SERVER['REQUEST_TIME'];//when was form submitted
$form_fill_time = $form_submit_time-$form_load_time;//how long did it take to fill in
define (CONTACT_US_MIN_TIME, '5');//seconds..(obviously should be in the admin)
$fast_form_filling = ($form_fill_time < (int)CONTACT_US_MIN_TIME) ? true : false;//true when form was filled in too fast

This should go in a new function if you want to use this across all the forms.

  1. Now add the check before the form is processed/email is generated, still in
    \includes\modules\pages\contact_us\header_php.php

Change

if ($zc_validate_email and !empty($enquiry) and !empty($name) && $error == FALSE)

to

if ($zc_validate_email and !empty($enquiry) and !empty($name) and $fast_form_filling && $error == FALSE)

If the form is submitted in less than 5 seconds the form is just redisplayed. You will need to play around with the value to suit a slow site.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

11 Dec 2012, 10:24 AM
#106
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

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

Great to see that this has been included in 1.5.1 Hats off to the devs :-)

My only question here is why the css is inline? Firstly, and not something that bothers me overly, it isn't great practice. Secondly, if the css is an external file it makes it that much harder for bots to recognise the file as a honeytrap. Parsing css is a whole different level of difficulty that looking at inline styles. Just thoughts.

My solution is to wrap the input in another element and then apply the css to that wrapper from an external css file. In the html the input looks like any other. It seems to have worked so far.

Nick
iszent.com

11 Dec 2012, 11:02 AM
#107
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

niccol:

Great to see that this has been included in 1.5.1 Hats off to the devs :-)

My only question here is why the css is inline? Firstly, and not something that bothers me overly, it isn't great practice. Secondly, if the css is an external file it makes it that much harder for bots to recognise the file as a honeytrap. Parsing css is a whole different level of difficulty that looking at inline styles. Just thoughts.

My solution is to wrap the input in another element and then apply the css to that wrapper from an external css file. In the html the input looks like any other. It seems to have worked so far.

Very simple answer.
When the code is in a seperate CSS it would not work when you select a different template.

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

11 Dec 2012, 4:44 PM
#108
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

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

eentje:

Very simple answer.
When the code is in a seperate CSS it would not work when you select a different template.
But there are ways to make the CSS file template agnostic..

My Site - Zen Cart & WordPress integration specialist
I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

11 Dec 2012, 5:03 PM
#109
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

True... but that wouldn't be the Zen Cart way :)

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

11 Dec 2012, 5:52 PM
#110
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

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

niccol:

My only question here is why the css is inline?
Simple: The majority of people doing upgrades end up skipping CSS files, or anything template-related.
Supporting existing installs is the biggest thing that slows progress, unfortunately.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

9 Feb 2013, 10:21 PM
#111
dharma avatar

dharma

Totally Zenned

Join Date:
Nov 2006
Posts:
505
Plugin Contributions:
0

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

I used the post on page 8 (post #72 summary of earlier posts) and it works, thanks everyone for contributing! :bigups:

Zencart 1.3.9h - PHP 5.2.13 - My SQL 5.0.84 - Apache 1.3.41

19 Apr 2013, 12:05 PM
#113
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

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

Did anyone tried the timer to the form pages alone?
I get so few spam I elect to receive it and see what they have done. Coincidentally I just got gibberish through my Ask a Question form and this robot waited 24 seconds before submitting the form! It filled in the honeypot so it would have been discarded by that.
Since a timer is invisible to the user, I don't see a problem in implementing it in parallel to other methods.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

22 Jul 2016, 5:25 PM
#114
monkeyjr47906 avatar

monkeyjr47906

New Zenner

Join Date:
Nov 2007
Posts:
72
Plugin Contributions:
0

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

Hello, I have a 1.5.1 site that has the CSS anti-spam integrated into it and I seem to be getting quite a few spammy emails. Is there any benefit to removing the inline css that hides the field and/or change "should be empty" to something else (in case the nots are looking for it)?

Also is there a way to test if the CSS anti-spam working as it should? It could be an implementation issue on my part.

22 Jul 2016, 5:37 PM
#115
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

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

You can rename it if you like. Doesn't seem to be necessary on hundreds of other sites I'm aware of. But if yours has been targeted then maybe you need to take other action.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

16 Jan 2017, 6:26 AM
#116
mario75 avatar

mario75

New Zenner

Join Date:
May 2012
Posts:
22
Plugin Contributions:
0

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

The solution in post 76 worked fine for about 3 years for me. But lately my online shop started again to receive spam from "contact us" page. I have already tried the timer solution but even for 10 seconds timer, I still get spam from contact us page. I'm thinking to disable this page entirely because clients have many ways to contact us beside the "contact us" page from online shop. Which is the proper way to do that? I mean to keep the file with the contact details, but not the contact form.
My Store: http://harmonyhandmade.ro/catalog/index.php?main_page=contact_us running Zen Cart 1.3.9h
(sorry but all the English language files are translated in Romanian language - sorry for that)

16 Jan 2017, 9:58 AM
#117
yaseent avatar

yaseent

Zen Follower

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

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

mario75:

The solution in post 76 worked fine for about 3 years for me..

Hi,

the contact us page generates more leads than anyone gives credit to. It's a lazy feel-good feature that many mainstream online stores don't actually use, but I find that it brings in a lot of rain. I would not disable it.

What I would do in your case is changed the name of the field, and the name of the function that tests for that field's input.

Change all instances of "leaveblank" to "Telephone". Use developer's toolkit to ensure you find them all for the Contact Us page.

Since it's only your Contact Us page, calling it Telephone won't be a problem.

Also, give it an ID or a class, and add this class to your Stylesheet, and apply "display:none;visibility:hidden" - and remove it from the inline styling for now.

What you should also do is remove thse SPAM tags you've got there:

<!--NO SPAM-->

Bots have become familiar with these techniques, and scan for these little details.

Just for an added measure, change the input type to "tel" rather than text.

And see how that goes for you.

16 Jan 2017, 2:13 PM
#118
mario75 avatar

mario75

New Zenner

Join Date:
May 2012
Posts:
22
Plugin Contributions:
0

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

Thank you! I will try.

16 Jan 2017, 9:18 PM
#119
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

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

yaseent:

Hi,

the contact us page generates more leads than anyone gives credit to. It's a lazy feel-good feature that many mainstream online stores don't actually use, but I find that it brings in a lot of rain. I would not disable it.

Agreed... I find that customers who wish to place really large orders prefer to do so "off-line" - and by talking to a person at some point. While the vast majority of our customers are general "household consumers" - buying 2 or 3 items at a time, companies, who often want several thousand items (we sell engraved tags) like to do this sort of business the "traditional" way.

By making ourselves accessible to such customers by email, online quote request forms and the "conventional telephone", we can sometimes "shut down" the website for conventional purchasing (switch to showcase with prices) while we gear up the workshop to handle two or three really big projects.

The point many people miss is that the website - while being an "easy" way to order goods - is just another sales channel. Many people put up their website and then "sit back" hoping that the orders will just roll in regardless. They hide their phone number, they don't provide an address...

At the end of the day, the objective is to get the order - and if that means it comes via some guy pulling up outside the workshop door on roller-skates it matters not a hoot to me... as long as we get the order, get paid, and satisfy the customer.

20 years a Zencart User

18 Jan 2017, 8:12 AM
#120
mario75 avatar

mario75

New Zenner

Join Date:
May 2012
Posts:
22
Plugin Contributions:
0

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

schoolboy:

The point many people miss is that the website - while being an "easy" way to order goods - is just another sales channel. Many people put up their website and then "sit back" hoping that the orders will just roll in regardless. They hide their phone number, they don't provide an address...
I don't get it! Not sure how it helps me. Didn't hide my phone number, and I didn't provide an address because I don't have a shop address. I have offered many ways that a customer can contact us and worked very well. Thanks for the help though! I understand your point and I will take it into account.

I also don't understand why somebody would bother to enter in an online shop to look for a "contact us" page then fill in the fields with nonsense to send to a store owner. What would they gain with this?
One example:

From:	Charleslouri
Email:	bae.tepaul######################

------------------------------------------------------

salir google play realistic racing games android best role playing games for
android  nintendo game watch emulator android 3110 mobile games free games
source code android  
trial bike game android  truck games download for mobile free download nba
basketball games for android download free naughty games for mobile  
multiplayer music game android best golf mobile games  game online team
mobile best olympic games android download mobile game software  
sky on google play  mobile cricket game free download sony ericsson  
cool sports games for android  my sims mobile game free download android
amiga emulator games  
divo games mobile android mobile games themes video  3d dragonball z mobile
game free download bubbles games for mobile chocolate shop frenzy mobile
game free download  
crime games free download for mobile mobile game download android  game
flash for android game cuc khung cho android google play store radar
detector  
download game iso psp untuk android mobile game player for pc download  how
to search music on google play dragon ball games android play flash games on
android chrome  
 gift card numbers for google play  
tmnt game download for android  free offline solitaire games for android new
mobile games for free samurai game free for android  
weed wars android game  gorillaz mobile game how to create a 2d game for
android smurf village game download for android  
samsung mobile java games download free  game hacking programs for android
download 3d war games for mobile free mobile games download for blackberry
8310  
play free games in google get the google play app  problema con google play
services motion sensing games android  
sally salon mobile game download  google play books online game foq mobile
squaresoft android games  
mobile game developer salary in india  02 games mobile management sim games
android download game mortal kombat 3 for android 

It's good that they are only 20 a day maximum.

I was thinking to cut from "contact us" page only the section with the contact us form, AND LEAVE there all the other means to contact us: the TELEPHONE, the Facebook fan page, FB messenger, email, Youtube channel, Twitter, but I will try Yaseent solution as soon as time will let me. Hopefully won't break anything.
Thank you for your help!
Have a nice day!