PDA

View Full Version : Sample filters



russellr
16-Oct-2005, 06:56 PM
Attached to this post you'll find a ZIP package containing two sample filters for use with FormMail.

These filters are written in PHP, so it's easy to modify them for your own use. These samples merely convert all the characters in the form submission to upper case.

FormMail has two filtering mechanisms:
It executes a program on the server to filter the data.
It accesses a web URL that filters the data.The sample PHP filter for mechanism #1 is called "upperfiltercmd.php".
The sample PHP filter for mechanism #2 is called "upperfilter.php".

To use "upperfiltercmd.php", you would add this to your FormMail $FILTERS configuration:


"toupper"=>"php upperfiltercmd.php"
Like this:


$FILTERS = array("encode"=>"$REAL_DOCUMENT_ROOT/cgi-bin/fmencoder -kpubkey.txt",
"null"=>"null",
"toupper"=>"php upperfiltercmd.php");
However, some servers won't run PHP scripts from the command line. If this is the case for you, then you'll need to use "upperfilter.php", which is designed to run on your web server.

Add this to your FormMail's $SOCKET_FILTERS configuration:


"uppercase"=>array("site"=>"YourSiteHere",
"port"=>80,
"path"=>"/upperfilter.php",
"params"=>array()),
The above assumes you put "upperfilter.php" in your webserver's DOCUMENT ROOT. If you put it elsewhere, change "path" accordingly.

Adding to the existing $SOCKET_FILTERS configuration looks like this:


$SOCKET_FILTERS = array(
"httpencode"=>array("site"=>"YourSiteHere",
"port"=>80,
"path"=>"/cgi-bin/fmencoder",
"params"=>array(array("name"=>"key",
"file"=>"$REAL_DOCUMENT_ROOT/cgi-bin/pubkey.txt"))),

"sslencode"=>array("site"=>"ssl://YourSecureSiteHere",
"port"=>443,
"path"=>"/cgi-bin/fmencoder",
"params"=>array(array("name"=>"key",
"file"=>"$REAL_DOCUMENT_ROOT/cgi-bin/pubkey.txt"))),

"uppercase"=>array("site"=>"YourSiteHere",
"port"=>80,
"path"=>"/upperfilter.php",
"params"=>array()),
);
Make sure you replace YourSiteHere with your site's domain name.

To get your form to use a filter, simply add this hidden field to your form:


<input type="hidden" name="filter" value="uppercase" />
replacing "uppercase" with whatever filter you want to call.

For more information about filter: http://www.tectite.com/fmhowto/filters.php

Download Problems?

If you can't download the attachment, it might be because of a bug in Microsoft Internet Explorer 7.

In any case, you can use this alternate download location:
www.tectite.com/public_downloads (http://www.tectite.com/vbforums/../public_downloads)