Register | Log in | RSS channel for codegravity.com homepage Bookmark!

232/2NEW projects | 71 services | 212 websites | 712/6NEW freelancers | 1994 topics | advertise



Login:



Forgot your password?
Forgot your username?
Create an account


Countries

17.9%United States United States
17.5%India India
7.9%Germany Germany
6.2%United Kingdom United Kingdom
5.1%France France

Visitors

Today: 2543
Yesterday: 3250
This Week: 20602
Last Week: 23907
This Month: 44509
Last Month: 37156
Total: 117493


Users

Most active users today from total of 89:
niksakl, gjcode, reucoulsolf, brurleldeds, Choakster, mrkx1, hirano, thepassenger, jpramirezp, theochambers24, gmwasaru, shanepowys, faisal.vaipur, lisagirl, deboeck, 1testme1, Tmphil, Turdin, himself78, kaldov
JoomlaWatch Stats 1.2.10_04 by Matej Koval
Partners:

Freelance ColdFusion, Flex, PHP

Olejomalby, abstraktne obrazy

Camping Europe

WinAsm Studio

Vyšné Ružbachy

Sochy, Reštaurovanie

R.E.M.

Valid XHTML 1.0 Transitional

RSS feed:
rss feed

Statistics:
Search Engine Genie Promotion Widget
Home

MathGuard PHP form anti-spam protection

If you are looking for the MathGuard anti-spam patch for AkoComment TSE 1.4.6, please see: MathGuard anti-spam patch for Joomla's Akocomment component

 

Creating this website made with PHP, I attracted lots of spambots to flood my forum, my programming resources, freelance database and other forms, but you probably know this situation very well.  So I decided to create a simple anti-spam PHP Class which could help me and probably other people to deal with the spam.

MathGuard is free PHP class that everyone can use as anti-spam protection for the website forms. It's also a suitable solution when there is no PHP GD support from the webhosting company. 

UPDATE: MathGuard version 3.0

 

Here's an example how to use MathGuard to protect your forms  (Adobe Flash player required)

 

 

New version features a better way of rendering the expression that user has to evaluate. The numbers consist of 3x5 random character matrix.


featuring more complex anti-spam security question rendering - these numbers consist of the random letters

Download UPDATED version MathGuard

Go to the download section on this website and find there mathguard-v3.0.zip

Installation process is the same as in the version 2.0, so please install it the way it is described below. 

 

The older version - MathGuard 2.0

 You can still install the older version:  


 

You have probably seen this solution before on some other websites, it's nothing new,
but I did it by myself and the way I wanted and I am using this anti-spam everywhere it's needed. The good thing is, that it works.

 

The principle of this PHP anti-spam class 

The principle of this PHP anti-spam class is very simple - The class inserts a small piece of HTML code into your PHP form -
an expression consisting of two random numbers, one text input field for user's answer,
and one hidden field with the hashcode.

When user submits the form with the answer, the answer is being hashed and compared to
the security code that has been submitted as well.

 

How to set up this PHP anti-spam class and use it on your website?

1. Download the code of MathGuard

Current version is 2.0

Go to the download section on this website and find there mathguard-v0.2.zip 

2. Unzip the archive

and copy the file ClassMathGuard.php into the folder with forms and action handlers you want to use.

3. Open the code with the PHP or HTML form you want to protect

 

4. Add the following PHP code snippet (the one in the ellipse)



5. Protect the form handler

 

		/* first we need to require our MathGuard class */
require ("ClassMathGuard.php");
/* this condition checks the user input. Don't change the condition,
just the body within the curly braces */
if (MathGuard :: checkResult($_REQUEST['mathguard_answer'],
$_REQUEST['mathguard_code'])) {
echo ("Great !");
//insert your code that will be executed when user enters the correct answer
} else {
echo ("Bad answer, go back to school !");
//insert your code which tells the user he is spamming your website
}

6. Open the form in your browser and you should see the mathguard's anti-spam security question there 

 

7. Example - watch the flash demo above


 There is also an example in the downloaded archive. It features a simple form and one simple form
handler which displays the data. I recommend you also to watch the flash demo on this website that shows a real example how to integrate mathguard.

 

8. Enjoy ! 

 If you'd have any questions regarding my PHP anti-spam class, feel free to write to the comments or directly to my email

Comments
Add New Search RSS
Site doesn't display well in FireFox
Mike (24.22.195.xxx) 2007-05-03 15:57:56

This site displays very poorly in Firefox, I'm sorry to say.
Very poorly?
matto (193.141.180.xxx) 2007-05-03 16:06:45

Could you please specify what's wrong that I can make the corrections? Are there also some other people experiencing the same problems? Thank you
MathGuard on Joomla installation trouble
Mitch (209.176.198.xxx) 2007-05-09 21:54:50

I'm having a lot of trouble with spam from the contact form on one of my Joomla sites. MathGuard looks like a good solution. I have been trying to install it but I can't get it to work. Where does the form handler code go? I'm not sure which page handles the form.
Re: MathGuard on Joomla installation tro
Matej Koval (88.212.22.xxx) 2007-05-09 22:38:22

Hello Mitch,

First you have to find out what code handles your form on submit.
It's usually the one which contains the SQL insert command or some other action.
(eg. with the joomlaboard forum component it's the /components/com_joomlaboard/post.php
line 186).

When you find this piece of code, you have to wrap it in one IF block with the mathguard condition:


.
.
some code
.
.
// we need to tell PHP to require our class

require ("ClassMathGuard.php");

if (MathGuard :: checkResult($_REQUEST['mathguard_answer'],
$_REQUEST['mathguard_code'] ) ) {

// original code with the
database insert wrapped by the IF condition

} else {
// code that handles the wrong answer
}
.
.
some code
.
.


I hope I explained it well. If you'll have some questions, feel free to ask !

Regards,

Matej Koval
Re: MathGuard on Joomla installation
Mitch Vars (88.212.22.xxx) 2007-05-16 21:26:28

Matej,
I managed to get this to work by putting the IF condition in the switch on line 30 of contact.php - it should look something like this:


switch( $op ) {
case 'sendmail':
/* first we need to require our MathGuard class */
require ("ClassMathGuard.php");
/* this condition checks the user input. Don't change the condition,
just the body within the curly braces */
if (MathGuard :: checkResult($_REQUEST['mathguard_answer'],
$_REQUEST['mathguard_code']))
sendmail( $con_id, $option );
} else {
//insert your code which tells the user he is spamming your website
echo ("Sorry - Your email has not been sent. Please help us to combat spam by correctly answering the math problem before sending your email.");

}
break;

Thank you for this very useful piece of work. Feel free to share this on your site.

Mitch Vars
MathGuard not working
Petar (89.215.10.xxx) 2007-05-19 17:33:07

I've just downloaded and installed MathGuard example on my web server and every time I try to submit the form it tels me the phrase "Bad answer, go back to school". I don't know what's wrong since it is the authors example? Please, help! It looks fine antispam method protection for me.
Error corrected
Matej Koval (193.141.180.xxx) 2007-05-21 14:59:03

Hello Petar,
I'm sorry, there was an error in the example code, you were right.
In the formhandler.php, there has to be $_REQUEST instead of $request.

The error is now corrected and it's bundled in the mathguard-v0.2.zip that you can download from codegravity.com.
Impressed
Rob Hope (196.25.255.xxx) 2007-05-27 10:46:46

Thanks for a great spam filter! Took roughly 45 minutes to code the script into my contact form and css all the styles etc to make it look part of the website.

Maybe the documentation could be a little better, but overall I would give this script 4/5.
kumz (85.115.108.xxx) 2007-05-30 12:51:47

hei, great job! can i use this class for my site without referencing to this site?
I can't download the scipt
TITA STEFAN (86.120.17.xxx) 2007-05-30 13:03:14

On the download section I receive a "forbidden access"
message for Mathguard script
Re: kumz
matto3c (193.141.180.xxx) 2007-05-30 13:23:20

Kumz,
you can keep or remove the link, it's up to you.
But I think it would be nice to keep it there.
How to make this work on Joomla 1.0.12
Peter (62.195.213.xxx) 2007-06-20 00:45:20

Just wondering wich steps to take to make it work in joomla version 1.0.12
MathGuard and Frontpage
Philip (196.207.40.xxx) 2007-07-12 16:59:16

Will MathGuard work with a form that was created and published with Frontpage?
Re: MathGuard and Frontpage
Matej Koval (88.212.22.xxx) 2007-07-12 18:06:56

MathGuard needs PHP to work, so you can't just include it into a plain HTML with no PHP support.

You can do so, if the .html extension is interpreted by PHP and the piece of code that mathguard generates is inserted there.
The form handler has to be also a PHP-interpreted page that uses MathGuard's function to check the right answer.

I hope I explained it well, if you'll have any further questions, feel free to ask me.
Thanks
Djay (82.232.6.xxx) 2007-07-24 14:48:23

Thanks for this script really easy to use and I hope efficient ! Well, I'll tell you in few days... :)
Works well!
Cambo (124.190.59.xxx) 2007-07-29 03:13:54

It took me about 5 minutes to incorporate mathguard into my existing contact form. It worked straight out of the box. Very impressed. I give it 4/5. It would rate a 5 but it doesn't display well in Opera. Thanks for a very simple way to protect from spammers.
Thanks...
Luca (82.52.19.xxx) 2007-08-08 03:50:34

I'm using it on my site that has more than one form and I must say it seems to work pretty well. I wanna thank you for the script.
I also moved the the link to your site to a less visible place without taking it away. A person can still find it easily.

I hope it's fine for you :)
Thank you so much
FlorinP (77.81.23.xxx) 2007-08-14 16:47:04

It really works! I set it up in a snap, fitted in perfectly :)
Thanks!
Where to paste the code in post.php?
Winnie (219.95.208.xxx) 2007-08-16 19:51:59

Hi, I really hope mathguard can help me with those spammers. Where to paste the code in post.php? I'm not a good programmer. Shall I paste the whole block of If-then-else into 1 block or have to find the code that insert the database and then break your if-then-else apart? Can anyone help me to paste the snippet into joomlaboard/post.php? Thanks very much in advance.
Firefox and poor display
norton (130.209.6.xxx) 2007-08-20 16:31:10

Mathguard didn't display well for me in Firefox. I did some investigating, using the CSS with no luck. Finally I checked my Firefox font display settings:
Tools > Options... > Content > Font & Colours > Advanced > Minimum font size - set it to "none".
Reload page.
Mathguard now displays well.

This is a per user fix, obviously, and I have no idea how to ensure that my site visitors have their Minimum font size set to "none".

Hope this helps.
MathGuard is wonderful
The Pearls Master (62.94.144.xxx) 2007-09-25 11:42:40

Thank you very much for this simple and powerful class! I incorporated MathGuard in my site in a few minutes.

Are you planning to release a new version soon?
Well done
Dragon (84.222.95.xxx) 2007-11-08 14:46:12

Nice spam protection and very easy to implement. If I can suggest one more option to implement with the random image because many people get use to it. Anyway the counting filter is very effective.
Thank you
matto (SAdministrator) 2007-11-08 14:49:33

I'm working on the new improved version. So if you have some more suggestions, please post them here.
matto (SAdministrator) 2008-02-05 15:04:02

Yes, you are unfortunatelly right. Please re-download and re-install the .zip archive. The error has been corrected.
matto (SAdministrator) 2008-02-05 15:05:07

... Or, you can just replace the ClassMathGuard.php that comes in this new archive in your root Joomla directory.
Gman (130.14.254.xxx) 2008-02-05 15:15:45

Thats great! I didn't realize I was running an old version, my apologies.
which download?
Gman (130.14.254.xxx) 2008-02-05 15:18:32

Hi Matto,

Which one to download? The v3.0? I am having problems finding the proper download file.
matto (SAdministrator) 2008-02-05 15:27:09

So... You downloaded the akocomment-TSE1.4.6-with-MathGuard-anti-spam.zip

(the screenshot you posted comes from this component)

But.. this .zip archive had MathGuard class in it, which had this minor bug (see on a screenshot)

After your post I realized that, and put the corrected version of MathGuard (3.0) into this akocomment-TSE1.4.6-with-MathGuard-anti-spam.zip

So, you can re-download it, and replace the ClassMathGuard.php to get rid of this stupid bug.

From this time in akocomment-TSE1.4.6-with-MathGuard-anti-spam.zip is this minor bug fixed.

Or, second option : you can download MathGuard 3.0 (http://www.codegravity.com/component/
option,com_remository/
Itemid,26/func,fileinfo/id,13/)
separatelly and replace it in your root joomla folder.

Cheers,

Matto
Gman (130.14.254.xxx) 2008-02-05 15:29:10

Hi Matto,

That clarifies things for me. Thanks so much for this wonderful spam protection add on!
Could you please finish step #2?????????
joeweareidiotbastards (24.18.143.xxx) 2008-07-11 01:35:32

You could save everyone alot of time by just doing that. Also, what files are we supposed to edit in steps 4 & 5? It would take you 5 minutes to update this info and save your customers hours.
Done
matto (SAdministrator) 2008-07-11 08:47:15

It's done now.
Well done
iskandar88 (60.50.145.xxx) 2008-08-10 17:16:50

The best antispam protection. keep up the good work
mattimc (212.50.147.xxx) 2008-08-29 19:16:08

For some reason I can't get the characters in the Mathguard question for Akocomment to display in red, or in a small-sized font. I've checked the php file but the parameters are correct: they just don't display on the page.

If you'd any thoughts as to why and how to correct it, would be very grateful?
Best of best
Renan (119.95.119.xxx) 2008-08-31 06:16:02

This was the best antispam protection I ever seen. I will try it and if this is really good, i will spread the words to everyone.

love it!
Nice one
Naeem (116.71.179.xxx) 2008-09-02 06:58:35

Great article for php web programming
can robot read it?
iva (88.2.19.xxx) 2008-10-09 17:35:36

hi,
i've been using this code for several months and till today everything was ok, but i just received email snet from the form on the site with spam massege inside of the body.

can robots read it? and is there a session limit, because i heerd that robot can like with captcha to use the same code for many submits.

i will give you more info if you need.

thanks
Javascript validation
hotchilidamo (86.156.174.xxx) 2009-01-27 17:38:30

My forms use Javascript validation, is there any way to impliment Math Guard validation in Javascript?
Nice security class
Frodon (62.147.185.xxx) 2009-03-12 09:18:24

Thanks a lot for this class. Works well !
How to make it work in J1.5
pcnw (79.166.85.xxx) 2009-03-16 19:24:23

It looks very elegant and everybody would love to have it in Joomla1.5 contact form. How can this happen? Can somebody write what code, where (exact files e.g. /components/contact/xxxx.php)?
Thank you in advance
solylluvia (74.101.232.xxx) 2009-08-10 02:47:27

Hi I a trying this out, the version 3.. But I a a bit dense... I am not sure where to put what... My form is an HTML email form handled by PHP.
thanks
Laptop Battery (58.247.134.xxx) 2009-11-23 01:56:20

thanks
Buy RapidSSL Certificate, 128 Bit WildCard GeoTrus
Martin Lawrence (122.169.85.xxx) 2010-02-12 13:51:04

hi..
great job!
can i use this class for my site?
Thanks for sharing.
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
:D:):(:0:shock::confused:8):lol::x:P:oops::cry:
:evil::twisted::roll::wink::!::?::idea::arrow:
MathGuard security question, please solve:

MGH         T        
S      P    K C   YYK
3LX   ORR   ISY      
  T    Y      S   GPY
PK8           X      
Please input the anti-spam code that you can read in the image.
 
Add URL of a programming website
register as a freelancer
submit your project
open freelance projects you can work on
webmaster resources
write for us tips, articles

Recommended: (advertise)
Advertise Here -
Promote your services and get the new customers from the community of webmasters / programmers visiting CodeGravity.com

Add URL of your website -
Submit your programming or software development website to webmaster resouces directory and share it with everyone.

Web hosting -
Rioserver Web Hosting provide ultra-reliable. We offer a range of packages which we believe are better than any other web host simply a cost-by-cost basis.

Outsource your project -
Submit your project description with all the requirements to more than 600 freelancers from around the world for FREE.

Register as a Freelancer -
Submit your project experiences, programming languages and your other skills


Download Joomlawatch 1.2.9

Download the NEW* JoomlaWatch 1.2.9 official from 20.04.2009 available for Joomla 1.5 and Joomla 1.0

RSS Feeds:new

rss Freelance
rss Projects
rss Forum
rss Resources

Popular:
MathGuard
download mathguard
Random screenshot:

linoopz15.jpg


Poll
I've installed JoomlaWatch 1.2.9 and:
 

News:

Registration required
I know that people don't like registering on websites, but I had to do it. From this moment you have to register first, before you download any file. This is better, because this way I can give you quick info about new version of downloadable files (eg. MathGuard) or some necessary security fixes. Thanks for understanding. (26.08.2007)

Books about investing and finance
I'd like to recommend you to read a book by Robert T. Kiyosaki - "Rich Dad, Poor Dad". However many people say it's quite a controversial book, it gave me a good motivation to improve my financial intelligence. (23.08.2007)

Fighting with the spam
All of the forms were protected with my own PHP antispam class - MathGuard, including the forms in the joomla modules I use. (02.05.2007)

Forum
Converted posts from the old punbb forum to the new joomlaboard (25.02.2007)

Improvement
Fixed some issues with the freelance registration, added a possibility to add a new programming resource, reorganized the structure of the programming resources. (24.02.2007)

New content management system
Codegravity.com is now running on joomla cms :) Added features like comments, forum etc. I hope you'll like it. Today I fixed the problem with the comment module which was not showing the correct images. There is also a new URL structure. For the old urls there is a 301 (Moved permanently) http redirect. (10.02.2007)

Moved to another hosting
Codegravity.com has been moved to another web hosting - CustomHosting.sk, from the previous pipni.cz, mainly because of the mod_rewrite problems and slow loading of the website. Sorry for some problems that lasted for about an hour. (19.01.2007)

Bookmark feed
The new feed from the del.icio.us has been added to the homepage codegravity.com. You 'll always have the latest information about the sites I like and you should visit as well! (21.11.2006)

News improved
Today I improved the news feeds. They are sorted into categories and I also added some other feeds that may be interested for you. (31.03.2006)

The Antispam verification
My email form was hijacked by the spam bots and I was recieving a lots of junk into my mailbox everyday. So, I decided to put a simple verification in the end of the form. You have to answer the result of addition of two numbers. Thank you for your understanding. (07.03.2006)

Java SE 6 Beta Mustang is out !
This beta release is a major milestone in the development of Mustang. It provides a complete stable snapshot of the final release functionality. http://mustang.dev.java.net (20.02.2006)

Google analytics, apply online
Apply online to google-analytics.com. They offer the new way of analysis of your website visitors. It is very promising, and when you will recieve the invitation code, you can send me one :) Thank you :) (13.02.2006)

Money Manager 2 - software for mobile accounting

FaceRSS - simple JavaServer Facer (JSF) component
I registered my new project - FaceRSS on freshmeat.net, here is the description: FaceRSS is a simple JavaServer Faces (JSF) component that allows you to display news from a specified URL source in one configurable JSP tag. This allows you to place news feeds on a Web site in a very simple way. It uses rsslib4j and therefore supports RSS version 0.9x, 1.0, and 2.0 with Dublin Core and Syndication namespaces. (06.01.2006)

My new blog :)
Check out my new [jroller.com/page/matto3c] blog on jroller.com website. Here is the RSS feed [http://jroller.com/rss/matto3c] if you'd like to add it into your news reader. (14.12.2005)

Optimizations
Thanks to the SEO company SeoVisions, for the basic optimization of this website. (11.12.2005)

ERM-II and Slovakia
SLOVAKIA, my home country, is now one step closer to adopting the common European currency - EURO. At midnight between November 25 and November 26, the country joined the Exchange Rate Mechanism 2 (ERM-II) (30.11.2005)

www.jground.com
I established a new website - http://www.jground.com, it's all based on JSF and it should be all about Java and all other related things. Enjoy! (25.11.2005)

Swing text antialiasing

Java webhosting
I'm trying a new http://www.move.cz java webhosting on www.move.cz, but it seems they don't respond to my questions about JSF ;( (16.11.2005)

Migration from Weblogic to JBoss
Currently I am working on a task: Migration of one J2EE application from Weblogic to JBoss application server. So, if you have any suggestions or resources, I would be glad if you'll send me some. Thanks (15.11.2005)

Increased Java performance
Java increased its performance on desktop by 58% : [http://www.javalobby.org/java/forums/t54006.html] Java Performance
Improvement (15.11.2005)

Exadel Studio Pro
At this time I'm playing with JSF (Java Server Faces). I want to recommend you a great IDE - Exadel JSF Studio Pro. It costs about $99, and there is 15 days trial available. You can also try MyEclipse which has also like Exadel - WYSIWYG editor for editing JSP, JSF pages. It can save you a lot of time. For more info, visit www.exadel.com (27.09.2005)

Programming directory
added a new programming resources directory, where you can submit your own programming website (14.09.2005)

Programming forum
Now the Programming forum is included in website design. I put there some topics from previous version of this forum. (19.08.2005)

Ubytovanie, podnajom Poprad
Ponuka na podnajom, ubytovanie: Zrekonštruované podkrovie - rodinny dom Poprad-Matejovce - 2 izby + pracovna + kúpelna s kuchynou, strešné a plastové okná, samostatné plynové kúrenie, drevené plávajúce podlahy, garáž, velká záhrada a samostatný vchod. . . Cena: dohodou
Kontakt: 0908 190 372 (18.02.2008)

Stavebny pozemok
Predám stavebný pozemok v prijemnom prostredí kúpelov Vyšné Ružbachy v blízkosti lyžiarskych vlekov. Inžinierske siete v blízkosti. Vhodný na relax ale aj podnikanie. 1767+27m2. 0908 190 372
Privacy policy | Advertise | Donate

Locations of visitors to this page


©2003-2009 Codegravity.com - Home