ICQ:53-755-182 RSS channel for codegravity.com homepage Bookmark!

117/1NEW projects | 43 services | 257 resources | 332/3NEW freelancers | 1414 topics | advertise


JoomlaWatch
JoomlaWatch Stats 1.2.8_04-dev by Matej Koval

Countries

18.2%UNITED STATES UNITED STATES
12.5%INDIA INDIA
7.9%GERMANY GERMANY
5.4%SLOVAKIA SLOVAKIA
4.2%UNITED KINGDOM UNITED KINGDOM

Visitors

Today: 1634
Yesterday: 1685
This Week: 6615
Last Week: 8038
This Month: 10878
Last Month: 8616
Total: 49057


We have 6 guests and 5 members online


Login form:





Lost Password?
Register
Partners:

My CV / Zivotopis

CV / Zivotopis - SAP PM

Freelance ColdFusion, Flex, PHP

Olejomalby, abstraktne obrazy

Camping Europe

WinAsm Studio

Vyšné Ružbachy

Reštaurovanie, kameň, bronz, drevo

R.E.M.

Valid XHTML 1.0 Transitional

RSS feed:
rss feed
Home
Latest freelance programmers:

Enterprise skillsWeb skills
i work as software developer in reputation telecommunication company in Egypt. I'm professional in using j2se, struts, hibernate,jsf and spring. ...
add/register freelance programmerNew freelancer
Work on projects

Latest freelance projects:
raksha reddy
i need a code to implement tic tac toe game
New project request
Work on projects

Latest programming resources:
Php Ajax Related Useful codes, tips and article
This website contains useful code, tips and aritcle related to php and ajax programming.
add/submit programming urlAdd a new programming resource

Latest forum topics:
JoomlaWatch Date format in 1.2.7
Great module and component. Is there a way to change date format to MM/DD/YYYY?
add forum topicPost a new forum topic


MathGuard PHP form anti-spam protection

Sponsored links:

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





Sponsored links:

Comments (37)
RSS comments
1. 03-05-2007 13:57
Site doesn't display well in FireFox
This site displays very poorly in Firefox, I'm sorry to say.
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
2. 03-05-2007 14:06
Very poorly?
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
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
3. 09-05-2007 19:54
MathGuard on Joomla installation trouble
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.
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
4. 09-05-2007 20:38
Re: MathGuard on Joomla installation tro
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
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
5. 16-05-2007 19:26
Re: MathGuard on Joomla installation
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
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
6. 19-05-2007 15:33
MathGuard not working
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.
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
7. 21-05-2007 12:59
Error corrected
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.
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
8. 27-05-2007 08:46
Impressed
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.
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
9. 30-05-2007 10:51
Impressed
hei, great job! can i use this class for my site without referencing to this site?
Written by kumz (Guest)
10. 30-05-2007 11:03
I can't download the scipt
On the download section I receive a "forbidden access" 
message for Mathguard script
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
11. 30-05-2007 11:23
Re: kumz
Kumz, 
you can keep or remove the link, it's up to you.  
But I think it would be nice to keep it there.
Written by matto3c (Guest)
12. 30-05-2007 11:26
RE: I can't download the scipt
I'm sorry, this usually happens when the pegas-bekd.com where is the download hosted runs out of traffic quota per month. 
 
I hope it will be functioning soon, if not, please use the alternative download: 
http://www.immaculata.sk/download/mathguard-v0.2.zip
Written by matto3c (Guest)
13. 19-06-2007 22:45
How to make this work on Joomla 1.0.12
Just wondering wich steps to take to make it work in joomla version 1.0.12
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
14. 12-07-2007 14:59
MathGuard and Frontpage
Will MathGuard work with a form that was created and published with Frontpage?
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
15. 12-07-2007 16:06
Re: MathGuard and Frontpage
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.
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
16. 24-07-2007 12:48
Thanks
Thanks for this script really easy to use and I hope efficient ! Well, I'll tell you in few days... :)
Written by Djay (Guest)
17. 29-07-2007 01:13
Works well!
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.
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
18. 08-08-2007 01:50
Thanks...
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 :)
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
19. 14-08-2007 14:47
Thank you so much
It really works! I set it up in a snap, fitted in perfectly :) 
Thanks!
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
20. 16-08-2007 17:51
Where to paste the code in post.php?
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.
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
21. 20-08-2007 14:31
Firefox and poor display
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.
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
22. 25-09-2007 09:42
MathGuard is wonderful
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?
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
23. 08-11-2007 12:46
Well done
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.
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
24. 08-11-2007 12:49
Thank you
I'm working on the new improved version. So if you have some more suggestions, please post them here.
Written by matto (Registered)
25. 05-02-2008 13:04
Thank you
Yes, you are unfortunatelly right. Please re-download and re-install the .zip archive. The error has been corrected.
Written by matto (Registered)
26. 05-02-2008 13:05
Thank you
... Or, you can just replace the ClassMathGuard.php that comes in this new archive in your root Joomla directory.
Written by matto (Registered)
27. 05-02-2008 13:15
Thank you
Thats great! I didn't realize I was running an old version, my apologies.
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
28. 05-02-2008 13:18
which download?
Hi Matto, 
 
Which one to download? The v3.0? I am having problems finding the proper download file.
Written by Gman (Guest)
29. 05-02-2008 13:27
which download?
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
Written by matto (Registered)
30. 05-02-2008 13:29
which download?
Hi Matto, 
 
That clarifies things for me. Thanks so much for this wonderful spam protection add on!
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
31. 10-07-2008 23:35
Could you please finish step #2?????????
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.
Written by Joe (Registered)
32. 11-07-2008 06:47
Done
It's done now.
Written by matto (Registered)
33. 10-08-2008 15:16
Well done
The best antispam protection. keep up the good work
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Registered)
34. 29-08-2008 17:16
Well done
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?
Written by Matti (Registered)
35. 31-08-2008 04:16
Best of best
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!
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
36. 02-09-2008 04:58
Nice one
Great article for php web programming
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
37. 09-10-2008 15:35
can robot read it?
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
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)

Write Comment
Name:
E-mail
Homepage
Title:
BBCode:Web AddressEmail AddressBold TextItalic TextUnderlined TextQuoteCodeOpen ListList ItemClose List
Comment:



I wish to be contacted by email regarding additional comments
MathGuard security question, please solve:

1L4         1U6      
  K    O      P   318
TD8   DCC     U      
3      P      K   1WX
1TP           Q      

Powered by AkoComment Tweaked Special Edition v.1.4.6
AkoComment © Copyright 2004 by Arthur Konze - www.mamboportal.com
All right reserved

<MathGuard anti-spam patch for Joomla's Akocomment component FaceRSS - The JavaServer Faces (JSF) RSS component>
 









Recommended: (advertise)
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.

Website Design - The people at Hosterio are experts at Website design, Ecommerce and Hosting services. You can get complete website for as low as $249 only.

Web Hosting

Answering Service - The service that manages your phone calls so you can concentrate on coding. 24 hour live person availability, appointments, customer requests management, help desk, order processing and more.




Download the NEW* JoomlaWatch 1.2.7 official from 09.09.2008 that works with Joomla 1.5 and Joomla 1.0

Popular:
MathGuard
Random screenshot:

3morphsm.jpg


Poll
What do you think about this domain's name - CodeGravity.com ?
 

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 | IT services directory | Advertise | Sulik.sk | Donate
| My CV/Zivotopis - Java, J2EE, Web programming
Locations of visitors to this page


©2003-2008 Codegravity.com - MathGuard PHP form anti-spam protection