Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » Archives
  3. » Plug-in: zem_contact_reborn

#529 2006-07-24 14:25:19

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,911
Website

Re: Plug-in: zem_contact_reborn

Thanks marios. * <small>_goes to add to archives_</small> *

Offline

#530 2006-07-24 15:56:51

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

Re: Plug-in: zem_contact_reborn

Destry wrote:

I don’t see Tranquillo’s pap_contact_cleaner plugin anywhere, or at his Web site. Is it needed for this version of reborn?

pap_contact_cleaner is at thebombsite. I don’t think it is needed for zem_contact_reborn to work. But for safety, why not install it?

Stuart also has some articles on his site.

Offline

#531 2006-07-24 18:04:06

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,911
Website

Re: Plug-in: zem_contact_reborn

Thanks Els. Yeah, Stuart’s done a nice job with those docs. I’m still using the original zem_contact, works fine, but mainly because I haven’t needed to switch yet. Some day. Mainly just wanted to get the archive reflecting properly, and now it does.

I’m still looking for the day when a solid, secure, customizable contact form is part of the core, but that’s probably 4.5. ;)

Offline

#532 2006-07-25 03:43:24

cbeyls
Archived Plugin Author
From: Brussels, Belgium
Registered: 2005-09-12
Posts: 136
Website

Re: Plug-in: zem_contact_reborn

I tryed the original zem_contact and this one.

I have noticed that antispam is broken in this one but works in the original one. I can send the same message again and again by pressing the “refresh” button of my browser. Is it normal?


My plugins : cbs_live_search (improved) – cbs_category_list – cbs_navigation_menu – cbs_gravatar (updated) – cbs_article_index – cbs_maintenance_mode (new) – cbs_section_language (new)

Offline

#533 2006-07-25 18:06:37

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

Re: Plug-in: zem_contact_reborn

@cbeyls, this fixes the antispam feature (works for me):
<notextile><pre><code>safe_delete(‘txp_discuss_nonce’, ‘issue_time < date_sub(now(), interval 10 minute)’);
$nonce = mysql_real_escape_string(ps(‘zem_contact_nonce’));
if ($rs = safe_row(‘used’, ‘txp_discuss_nonce’, “nonce = ‘$nonce’”)) { if ($rs[‘used’]) { $zem_contact_error[] = zem_contact_gTxt(‘form_used’); $_POST = array(); } else { safe_update(‘txp_discuss_nonce’, “used = ‘1’, issue_time = now()”, “nonce = ‘$nonce’”); }
}
elseif (ps(‘zem_contact_submit’)) { $zem_contact_error[] = zem_contact_gTxt(‘form_expired’);
}</code></pre></notextile>

You can add it in the plugin just below this line:
<notextile><pre><code>safe_insert(‘txp_discuss_nonce’, “issue_time = now(), nonce = ‘$zem_contact_nonce’”);</code></pre></notextile>

This also introduces a new error message ‘form_used’ which requires one extra line to be added in an appropriate place in the zem_contact_lang plugin (below ‘form_expired’ makes sense). You may want to customize this a bit:

<notextile><pre><code>‘form_used’ => ‘Ouch, stop poking me. I am an experienced form and I know how to do my job. Submitting me once is enough.’,</code></pre></notextile>

<del>I’m not sure what the ‘used’ column in ‘txp_discuss_nonce’ is for. Seems to me that if you have used the nonce, it’s just as easy to delete it as it is to change ‘used’ from ‘0’ to ‘1’, but perhaps I’m overlooking something.</del>

Further down in the plugin code (in the zem_contact function) there is a block of code that starts with <code>if (ps(‘zem_contact_submit’))</code> and ends just before <code>return …</code>. It looks like that’s where the antispam checks are originally done, but it’s too late, because at that point the mail has already been sent.

<i><b>edit:</b> I’ve made some changes inspired by the comments of ‘cbeyls’ below this posting:
  • if a form is submitted more than once, the ‘form_used’ error is shown and the form fields are emptied (by clearing $_POST) to force the user to fill out the form from scratch.
  • if someone takes more than 10 minutes to fill out the form, the ‘form_expired’ error is shown but the form field contents are preserved.
  • when a form is succesfully submitted (email sent), ‘used’ is set to ‘1’ for this nonce and at the same time the ‘issue_time’ is reset. This makes sure that we check for 10 minutes after the submit if a duplicate submission takes place (in the old situation the 10 minutes start when you load the form, but if you take 9:59 minutes to fill out the form and submit, then the check for duplicate submissions would not trigger, because already 1 second later the nonce would be deleted… before the duplicate submit takes place)
    </i>

Last edited by ruud (2006-07-26 21:27:56)

Offline

#534 2006-07-25 18:34:23

cbeyls
Archived Plugin Author
From: Brussels, Belgium
Registered: 2005-09-12
Posts: 136
Website

Re: Plug-in: zem_contact_reborn

Thank you. I hope they will fix that.

The “use” column is set to “1” when a mail has been sent using this nonce, then it cannot be used again but it is still kept in the database for 10 minutes. That way you can detect when someone tries to submit the same form twice in a short amount of time (probably a spam attempt), which is different than using an outdated or unexisting nonce.

For the moment, I prefeir to use a home-made version of the original zem_contact.


My plugins : cbs_live_search (improved) – cbs_category_list – cbs_navigation_menu – cbs_gravatar (updated) – cbs_article_index – cbs_maintenance_mode (new) – cbs_section_language (new)

Offline

#535 2006-07-27 10:58:21

DaveR
Member
From: Dunedin, New Zealand
Registered: 2004-04-20
Posts: 13

Re: Plug-in: zem_contact_reborn

benbruce wrote:

I wanted to second DaveR’s comment about keeping the auxiliary plugin API.

How’s your work coming on a plugin to post the data into mysql tables? I’m interested in perhaps repurposing your efforts for use with the Email-on-Post and Newsletter Manager plugins.

Ben,

The plugin is not ready to post publically – it needs to be made more user friendly but here is the code if you want to use it as is. You’ll need to modify the php a little, and you’ll need to manually create a new database table but if you’re comfortable with that then you shouldn’t have too much trouble.

You will need to have:
zem_contact_reborn plugin installed and enabled
rss_admin_db_manager will make the mysql table creation easier and is useful to see whats in your table
ign_password_protect and mem_self_register are both used in my system. If you are not using these you can edit the plugin to remove the references.

Thisis plugin to a plugin which adds a function to zem_contact_reborn to save the form data into a database table (in addition to emailing the data).

Note: You must edit the php code to map your zem_contact_reborn field names to your database columns.

The easiest way to install this is to enale the plugin cache directory (under Textpattern’s Advanced preferences tab) and put this code as a plain textfile into that directory. Then there’s no need to base64 encode the plugin and its easy to edit and test. See the notes at http://forum.textpattern.com/viewtopic.php?id=10330

<notextile><pre><code>

<?php

// This is a PLUGIN TEMPLATE.

// Copy this file to a new name like abc_myplugin.php. Edit the code, then
// run this file at the command line to produce a plugin for distribution:
// $ php abc_myplugin.php > abc_myplugin-0.1.txt

// Plugin name is optional. If unset, it will be extracted from the current
// file name. Uncomment and edit this line to override:
$plugin[‘name’] = ‘djr_contact_db’;

$plugin[‘version’] = ‘0.1’;
$plugin[‘author’] = ‘DaveR’;
$plugin[‘author_uri’] = ‘’;
$plugin[‘description’] = ‘zem_contact_reborn plugin to save field data into a db’;
$plugin[‘type’] = 0; // 0 for regular plugin; 1 if it includes admin-side code

@include_once(‘zem_tpl.php’);

if (0) { ?>
  1. —- BEGIN PLUGIN HELP —-
h1. Textile-formatted help goes here
  1. —- END PLUGIN HELP —-
    <?php
    }
  1. —- BEGIN PLUGIN CODE —-

register_callback(‘djr_register_submit’,‘zemcontact.submit’);

// Add all the fields into a database tables.
function djr_register_submit() {

global $zem_contact_form;
global $ign_user,$txp_user,$sitename,$mem_profile;
global $txpcfg;

/* Set some defaults for non-required fields to keep mysql happy */
$Address_2 = ‘ ‘;
$Address_3 = ‘ ‘;
$Notes = ‘ ‘;
$Organisation = ‘ ‘;

/* extract will override the defaults if the variables are set. */
extract( $zem_contact_form );

if (isset($ign_user)) { $txp_user = $ign_user; }

$this_user_id = fetch(‘user_id’,‘ign_users’,‘name’, $txp_user);

/********* Edit the following to map your zem_contact_reborn field names to your database columns */

if (!safe_row(“*”, ‘djr_user_details’, “user_id=’$this_user_id’”) ) { $myresult = safe_insert( ‘djr_user_details’, “user_id = ‘$this_user_id’, firstName = ‘$Name’ , lastName = ‘$Surname’ , address1 = ‘$Address_1’ , address2 = ‘$Address_2’ , address3 = ‘$Address_3’ , phone = ‘$Phone’ , affiliation = ‘$Organisation’ , notes = ‘$Notes’ “); } else { $myresult = safe_update( ‘djr_user_details’, “firstName = ‘$Name’ , lastName = ‘$Surname’ , address1 = ‘$Address_1’ , address2 = ‘$Address_2’ , address3 = ‘$Address_3’ , phone = ‘$Phone’ , affiliation = ‘$Organisation’ , notes = ‘$Notes’ “, “user_id = ‘$this_user_id’” ); } }

/* Uncomment these two lines if you need some debugging output */ // dmp( $myresult) ; // dmp($zem_contact_form);

}

  1. —- END PLUGIN CODE —-

?>

</notextile></pre></code>

Edit: Thanks for the hint Ruud!

Last edited by DaveR (2006-07-27 21:58:44)

Offline

#536 2006-07-27 11:13:29

DaveR
Member
From: Dunedin, New Zealand
Registered: 2004-04-20
Posts: 13

Re: Plug-in: zem_contact_reborn

Ben,

The forum won’t play nicely with whitespace in the code above, so I’m emailing you a file as well.

Regards,
Dave

Offline

#537 2006-07-27 12:29:14

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

Re: Plug-in: zem_contact_reborn

Dave, if you enclose the code like this, whitespace is preserved on the forum:
<notextile><pre>&lt;notextile&gt;&lt;pre&gt;&lt;code&gt;
your code here
&lt;/code&gt;&lt;/pre&gt;&lt;/notextile&gt;</pre></notextile>

Offline

#538 2006-08-15 04:05:47

moslib
Member
Registered: 2005-08-11
Posts: 39

Re: Plug-in: zem_contact_reborn

I want to add some text to the email that is sent (but not have it visible to the user filling out the form).

That is, I’d like to add some words to the form result to make it clearer to the people who will need to respond to these emails.

It’ll be breaking up the responses … e.g. “Question 1: Local Issues”, “Question 2: State Issues”, etc

How do you go about doing that?

Offline

#539 2006-08-16 12:03:19

dog_biscuits
Member
Registered: 2005-10-14
Posts: 10

Re: Plug-in: zem_contact_reborn

Sorry if the answer to this is already in the thread, but a search didn’t give any relevant results…

Any ideas why I get two copies of the mail, sent from this plugin, when I specify a from address in the zem_contact tag?

Thanks.

Offline

  1. Index
  2. » Archives
  3. » Plug-in: zem_contact_reborn

Board footer

Powered by FluxBB