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

59/1NEW projects | 4 businesses NEW! | 258 web resources | 175/3NEW freelancers | 484 topics


JoomlaWatch
JoomlaWatch Stats 1.2.6 by Matej Koval
We have 11 guests and 1 member online


Login form:





Lost Password?
Register
Partners:

Google Page Rank Checker

My CV / resume

WinAsm Studio

Prehliadac Opera

ColdFusion, Flex, PHP Web development worldwide

View a profile on proagora.com
view my profile

CodeGravity.com is
looking for the
link partnership
with related websites.

Relax, oddych, zabava, ubytovanie

Ubytovani, volny cas, zabava

Vyšné Ružbachy

Reštaurovanie, kameň, bronz, drevo

Slobodne forum

R.E.M.

Valid XHTML 1.0 Transitional

RSS feed:
rss feed
Home
Latest freelance programmers:
Ashish Shah
Game skillsWeb skills
Asp.net,Java,PHP,JSP,J2ME,JSF,Seam,Struts,c#,J2EE
add/register freelance programmerNew freelancer
Work on projects

Latest freelance projects:
aditya lohiya
i need a running project of internet banking which has a front end of java and a back end of My SQL
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:
Re:guests online adding up instead of real time
Hi, the first number is a visit counter. And then follows the message about guest and visitors. (We have guest online means you have ONE guest online). Regards, Matto...
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 

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


 There is also an example in the downloaded archive. It features a simple form and one simple form
handler which displays the data.

 

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 (31)
RSS comments
1. 03-05-2007 14: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 15: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 20: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 21: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 20: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 16: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 13: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 09: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 11: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 12: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 12: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 12: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 23: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 15: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 17: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 13: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 02: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 02: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 15: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 18: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 15: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 10: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 13: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 13: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:52
Bugs in mathguard for akocomment
Quite often the letters get pushed around as in this Image I have CLICK TO SEE BUG - that was in FF 
 
Second bug - If someone gives a bad answer it forgets everything the user typed, which is NOT good!!
Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it (Guest)
26. 05-02-2008 14:04
Bugs in mathguard for akocomment
Yes, you are unfortunatelly right. Please re-download and re-install the .zip archive. The error has been corrected.
Written by matto (Registered)
27. 05-02-2008 14:05
Bugs in mathguard for akocomment
... Or, you can just replace the ClassMathGuard.php that comes in this new archive in your root Joomla directory.
Written by matto (Registered)
28. 05-02-2008 14:15
Bugs in mathguard for akocomment
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)
29. 05-02-2008 14: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)
30. 05-02-2008 14: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)
31. 05-02-2008 14: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)

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:

84K         KY8      
  P    S    L     TBT
W4H   24P   OE6      
  R    F    8 I   HTW
HAT         PLF      

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>
 











Download the NEW JoomlaWatch 1.2.5 from 24.3.2008 that works with Joomla 1.5 and Joomla 1.0

Sponsored:



Popular:
MathGuard
Random screenshot:

l3d04.jpg


Poll
JoomlaWatch 1.2.5 installation was for me
 

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)

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: 0949 401 409 (18.02.2008)
Privacy policy | freelance programmers | webmaster resources | business directory | advertise with codegravity.com

Locations of visitors to this page


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