Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-04-27 02:58:21

theturninggate
Member
Registered: 2004-11-07
Posts: 185
Website

pap_contact_cleaner for any form

I’d like to make use of the technique employed in pap_contact_cleaner in other forms, and not necessarily on TXP based sites. Unfortunately, I don’t know enough about PHP to duplicate the technique. Would it be possible for someone to provide a straight PHP, non-plugin-based version of this that could be dropped into any form?

Offline

#2 2007-04-27 08:43:52

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: pap_contact_cleaner for any form

create a hidden input text field:

<input type="text" name="telephone" value="" style="display:none">

In PHP, exit if something was entered in that field while submitting:

if (strlen($_REQUEST['telephone']))
{
  echo "go away!";
  exit;
}

Last edited by ruud (2007-04-27 08:44:17)

Offline

#3 2007-04-28 00:59:02

theturninggate
Member
Registered: 2004-11-07
Posts: 185
Website

Re: pap_contact_cleaner for any form

It’s working! Thanks!

One question, though:

Rather than include the style commands in the input tag, I wrapped it in a div and set the div’s display to none.

I did this so that I could also include (and hide) a label saying “Leave this field empty” for anyone browsing without stylesheets. A pointless inclusion, perhaps, but wanted to cover my bases.

The question: Spambots ought still to see it, correct? Hiding the div rather than the input shouldn’t hinder the effectiveness of the anti-spam measure?

Thanks again!

Last edited by theturninggate (2007-04-28 03:27:16)

Offline

#4 2007-04-28 08:03:09

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: pap_contact_cleaner for any form

I think pap_conctact_cleaner uses the “div” approach. It’s basically the same thing, since it assumes that the spammer doesn’t look at the styles whether that’s on the div or on the input element.

Offline

#5 2007-04-28 08:26:05

ragger
Member
From: Netherlands
Registered: 2005-04-10
Posts: 82
Website

Re: pap_contact_cleaner for any form

Hm, this should be implemented on sdr_guestbook as well.

Offline

#6 2007-04-28 12:12:31

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: pap_contact_cleaner for any form

ragger wrote:

Hm, this should be implemented on sdr_guestbook as well.

Still waiting for someone to take over…

Offline

#7 2007-04-28 15:43:10

ragger
Member
From: Netherlands
Registered: 2005-04-10
Posts: 82
Website

Re: pap_contact_cleaner for any form

It should probably be implemented in txp comments. That’s what sdr_guestbook is using, isn’t it?

Offline

#8 2007-04-28 16:00:30

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: pap_contact_cleaner for any form

In that case, it shouldn’t be too hard to go from pap_contact_cleaner to something that also working for comments, see textbook

Offline

#9 2008-04-23 09:11:18

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,596
Website

Re: pap_contact_cleaner for any form

Not sure if this is the right thread (can’t find one only for pap_contact_cleaner) but you can extend pap_contact_cleaner with the following functions to use it in conjunction with mem_form.

Edit the plugin code for pap_contact_cleaner and at the top after the other register_callbacks add:

// new callbacks for pap_cleaner honeypot fields for mem_form
register_callback('pap_zemcontact_form','mem_form.display');
register_callback('pap_memform_submit','mem_form.spam');

At the end add:

function pap_memform_submit() {

	$checking_mail_field = trim(ps('mail'));
	$checking_phone_field = trim(ps('phone'));

	$evaluation =& get_mem_form_evaluator();

	// If the hidden fields are filled out, the form won't be submitted!
	if ($checking_mail_field != '' || $checking_phone_field != ''){
		$evaluation -> add_status();
	}
	return;

}

Then it works with any form made using mem_form.

EDIT: this is for the current svn version (0.4) of mem_form.

Last edited by jakob (2008-04-23 09:12:59)


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB