Forum Moderators: coopster

Message Too Old, No Replies

Preventing guestbook spam

         

jackvull

9:54 am on Jul 18, 2005 (gmt 0)

10+ Year Member



Hi
I have a guestbook on my site, which is occasionally spammed and random html links are inserted. DO you know of a way to remove any HTML markup and also all the text following it with PHP?

I don't want to include any catchpa solutions if I can help it...

Thanks

maxi million

10:09 am on Jul 18, 2005 (gmt 0)

10+ Year Member



try strip_tags. that should do the trick. removes all html and php from the input unless you specifically allow some tags.
here: [php.net...]

mcibor

3:42 pm on Jul 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A good solution is to validate the guestbook by yourself.
The easiest method is to send yourself an email when someone writes to your guestbook. Email should contain the text and three links - one link "Approve", one "Don't allow", and "Ban". The links point to php which will validate the text.

Hope this helps.
Of course the method suggested by maxi will work, but is not fool proof.

Michal Cibor

jackvull

8:40 am on Jul 19, 2005 (gmt 0)

10+ Year Member



Thanks for the options. I can see how strip_tags works but it only takes out the actual HTML commands and nothing in between. For example a line like:
<a href = 'http://www.somewhere.com'>Somewhere website</a>
This would leave in the text: Somewhere website.
SO ideally I'd like to remove that as well.

I understand the approving posts method but I'd like the site to be as real time as possible and hti smethod would introduce delays so not sure if its needed at present.

Any ideas on a function that would strip the tags and remove text in between the tags?

Thanks.

jackvull

8:43 am on Jul 19, 2005 (gmt 0)

10+ Year Member



It seems like the spammers leave a little bit of text and then all their links, e.g.:
Greate site! <a href = , etc.
So would it be possible to trim off everything after the first instance of the html starter tag < is found?

mcibor

9:22 am on Jul 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$text_trimmed = strip_tags [php.net](substr [php.net]($text_untrimmed, 0, strpos [php.net]($text_untrimmed, "<a")));

This will cut the text up to the link. cutting everything what's after the link as well.
Michal