<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dagon Design &#187; PHP Scripts</title>
	<atom:link href="http://www.dagondesign.com/topics/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dagondesign.com</link>
	<description>WordPress Plugins, PHP Scripts, Tools, and Tutorials</description>
	<lastBuildDate>Tue, 23 Feb 2010 22:49:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Secure PHP Form Mailer Script</title>
		<link>http://www.dagondesign.com/articles/secure-php-form-mailer-script/</link>
		<comments>http://www.dagondesign.com/articles/secure-php-form-mailer-script/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 01:55:00 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[PHP Scripts]]></category>

		<guid isPermaLink="false">http://www.dagondesign.com/?p=35</guid>
		<description><![CDATA[This is the PHP version of my secure form mailer script. This script has a wide range of features including: an easy to use dynamic form generation system (any number of fields, in any order), multiple recipients, multiple file attachments, optional auto reply feature, an image verification system, numerous security features (including protection against email [...]]]></description>
			<content:encoded><![CDATA[<p>This is the PHP version of my secure form mailer script. This script has a wide range of features including: an easy to use dynamic form generation system (any number of fields, in any order), multiple recipients, multiple file attachments, optional auto reply feature, an image verification system, numerous security features (including protection against email header injection), a message template system, multiple languages, and too many other things to list. This script was designed to be easy to use, while still being extremely flexible. If you just want a simple contact form, you can set one up with just a few clicks. For those of you who need something a bit more advanced, you can completely customize script plugin to fit your needs &#8211; whether it is 5 fields or 500. A WordPress plugin version is also available. ReCaptcha support has also been added, as well as support for storing the data in a delimited file.<span id="more-35"></span></p>
<p>You can see a <strong>very basic</strong> implementation of the WordPress plugin version of this script on this site&#8217;s <a href="http://www.dagondesign.com/contact/">contact page</a>.</p>
<h3>Notice: WordPress Users</h3>
<p><a href="http://www.dagondesign.com/articles/secure-form-mailer-plugin-for-wordpress/">Information on the WordPress plugin version of this script</a></p>
<h3>Languages</h3>
<p>As of the latest release, this script contains language files for:</p>
<blockquote><p>English, Belarussian, Brazilian Portuguese, Catalan, Czech, Danish, Dutch, Estonian, Finnish, French, German, Greek, Italian, Japanese, Norwegian Bokmaal, Polish, Portuguese, Romanian, Russian, Slovak, Slovene, Spanish, Swedish, Turkish, Vietnamese</p></blockquote>
<p>If you would like to submit a language file please <a href="/contact/">contact me</a>.</p>
<h3>WordPress vs PHP Versions</h3>
<p>To make things easier to find, the two versions of this script share much of the same documentation. While the basic features are the same, there are several differences, so be sure to reference the proper page.</p>
<h3>Table of Contents</h3>
<p>Due to the size of this page, I have split everything up into sections:</p>
<ul>
<li><a href="#download">Download</a></li>
<li><a href="#changelog">Changelog</a></li>
<li><a href="#installation">Installation</a></li>
<li><a href="#required">Required Configuration</a></li>
<li><a href="#otherconfig">Other Configuration Options</a></li>
<li><a href="#customize">Other Customizations</a></li>
<li><a href="#usage">Usage</a></li>
<li><a href="#advancedrecip">Advanced Recipient Options</a></li>
<li><a href="#advancedform">Advanced Form Structure</a></li>
<li><a href="#manualcode">Manual Form Code</a></li>
<li><a href="#autoreply">Auto Reply Feature</a></li>
<li><a href="#csv">Saving Data to a File</a></li>
<li><a href="#othermods">Other Modifications</a></li>
<li><a href="#troubleshooting">Troubleshooting</a></li>
<li><a href="#comments">Comments</a></li>
</ul>
<hr /><a name="download"><br />
<h3>Download</h3>
<p></a></p>
<ul>
<li><a href="http://www.dagondesign.com/files/dd-formmailer.zip">Latest Release</a> </li>
</ul>
<p>

	<div style="margin: 10px 0 20px 0; padding: 6px; border: 1px solid #D5D5D5; background: #F3F3F3; color: #777777; font-weight: bold;">

	<a href="http://www.dagondesign.com/donate/"><img src="http://www.dagondesign.com/wp-content/themes/dagondesign3.11/images/donation-button-small.gif" style="vertical-align: middle; "></a>

	&nbsp; If you have found this page useful, please consider donating. Thanks!

	</div>

	</p>
<hr /><a name="changelog"><br />
<h3>Changelog</h3>
<p></a></p>
<p>Since both the WordPress and non-WordPress versions of this script are updated together, the changelog below reflects both versions.</p>
<div class="scrollbox">
<ul>
<li><strong>07-05-09 &#8211; v5.8</strong> Added Estonian language. Added code to check for duplicate field names. Can now use commas in checkbox descs. Fixed garbled auto-reply messages. Adjusted the displaying of uploaded file names in the email message. mb_encode_mimeheader error in WP fixed. Other adjustments to email headers. Added &#8216;id&#8217; declaration to select boxes. Fixed incorrect example code in the instructions. Other minor changes.</li>
<li><strong>02-22-09 &#8211; v5.7</strong> Fixed issues regarding the saving of attached files, data selection values not being recorded, and various minor fixes. Inline styles have been removed from the two field items that contained them.</li>
<li><strong>10-19-08 &#8211; v5.6</strong> Added javascript date chooser field. Added html code field. Adjustments for better character set support. Fixed bug with spaces in selrecip. Commas can now be used in check boxes, radio buttons, and select boxes (see field info below). Timestamp option added for saving to data file. New email validation code (from http://code.google.com/p/php-email-address-validation/). New language added: Vietnamese</li>
<li><strong>09-18-08 &#8211; v5.51</strong> Captcha now displays properly in Safari and Chrome. All of the auto-reply issues should now be resolved. Few changes to headers for compatibility.</li>
<li><strong>08-24-08 &#8211; v5.5</strong> Fixed various undefined index errors, code changes to improve xhtml validity, attachments can now be saved to the server (not just emailed), improved email header handling for language support, can now show url (of form) in message, fixed issue with required select boxes, added Belarussian, Czech, and Japanese languages, clickable labels for radio and checkbox items, and various other fixes.</li>
<li><strong>05-13-08 &#8211; v5.41</strong> Added support for saving form data to a delimited file. Fixed a few issues including the loading of recaptcha files, and attachment support.</li>
<li><strong>11-25-07 &#8211; v5.4</strong> Added support for ReCaptcha, manual form code entry, 5 new languages (Catalan, Danish, Polish, Romanian, and Turkisk), several html and css tweaks, and other misc. updates.</li>
<li><strong>07-27-07 v5.33</strong> &#8211; Few minor bugs fixed. Finnish language file added.</li>
<li><strong>07-08-07 v5.32</strong> &#8211; Error messages affecting form alignment issue resolved. Italian and Slovak language files added.</li>
<li><strong>06-18-07 v5.3</strong> &#8211; &#8216;undefined index&#8217; errors fixed, image verification adjustments, p tags removed from fieldsets, changes to help html validity, various other fixes.</li>
<li><strong>05-09-07 v5.25</strong> &#8211; &#8216;Thank you&#8217; message now allows for form field inputs as well.</li>
<li><strong>05-08-07 v5.24</strong> &#8211; Auto-reply message now allows for form field inputs. Language selection issue resolved. str_replace errors (on certain servers) fixed. Norwegian BokmÃ¥l language file added.</li>
<li><strong>05-01-07</strong> &#8211; Not a version update. Greek and Swedish language files added.</li>
<li><strong>04-18-07 v5.23</strong> &#8211; Renamed email verification function (to fix conflicts with other scripts). The GD check is now disabled if you are not using image verification. Added two new language files &#8211; Portuguese and Russian.</li>
<li><strong>04-18-07</strong> &#8211; Not a version update. Brazilian Portuguese language file has been added.</li>
<li><strong>04-03-07 v5.22</strong> &#8211; Email generation code has been modified to try to work with more servers. French language file has also been updated.</li>
<li><strong>03-28-07 v5.21</strong> &#8211; Highly recommended update &#8211; Fixed an issue with the verification code not being handled properly. Nothing else has been changed.</li>
<li><strong>03-25-07 v5.2</strong> &#8211; Email generation improved &#8211; should work better in more email clients. Many issues with message generation and field types have been fixed. Better support added for field requirement options. CSS for various fields updated. Issue with submit button fixed. Dutch and French language files added. Checkbox and drop-down issues resolved. Email verification method improved. Undefined index errors fixed, and much more. Be sure to read the updated instructions for the field types.</li>
<li><strong>03-13-07 v5.1</strong> &#8211; Lots of updates: Slash escaping has been improved, p tags are now added around form elements, each form instance can have its own language setting, the language selection issue has been fixed, improved foreign character support in messages, check box handling improved, and a new optional auto reply feature has been added.</li>
<li><strong>02-06-07 v5.0</strong> &#8211; This is a <strong>major</strong> update from version 4, and because of this, I have completely re-written this page, and removed the old changelog to save space.</li>
</ul>
</div>
<hr /><a name="installation"><br />
<h3>Installation</h3>
<p></a></p>
<ul>
<li><strong>1)</strong> Download and uncompress dd-formmailer.zip</li>
<li><strong>2)</strong> Upload the entire dd-formmailer directory to your server</li>
<li><strong>4)</strong> Configure your options (explained below)</li>
<li><strong>5)</strong> Add the form to your page (explained below)</li>
</ul>
<hr /><a name="required"><br />
<h3>Required Configuration</h3>
<p></a></p>
<p>While this script is highly configurable, some of you may just want to get up and running quickly with a simple (and secure) contact form. If so, these are the minimum options you need to configure within the file:</p>
<blockquote><h4>Standalone Option</h4>
<p><strong>$standalone</strong> &#8211; If you plan to use this script by itself (not included from another PHP file), set this option to TRUE, and it will generate a proper html header and footer. If you want to change the basic header and footer, they are found near the bottom of this script. </p>
<h4>Path to CSS</h4>
<p><strong>$path_to_css</strong> &#8211; If you are using the standalone option, enter the relative path to your CSS file so it can be declared properly in the header. For those of you including this script in another PHP file, be sure to manually add the CSS declaration in the header section of your page, like this:</p>
<p><code>&lt;link rel="stylesheet" href="(path to dd-formmailer.css)" type="text/css" media="screen" /&gt;</code></p>
<p>If you plan to use the javascript date field, you will also have to include the following line:</p>
<p><code>&lt;script type="text/javascript" src="(location of date_chooser.js)"&gt;&lt;/script&gt;</code></p>
<h4>Language Setting</h4>
<p><strong>$language</strong> &#8211; The relative path to the language file you want to use.</p>
<h4>Full URL to Script</h4>
<p><strong>$script_path</strong> &#8211; The full URL to dd-formmailer.php (or whatever you have renamed it to)</p>
<h4>Full URL to Contact Page</h4>
<p><strong>$path_contact_page</strong> &#8211; If you are running this script in standalone mode, leave this blank. Otherwise, enter the full URL to the page that is displaying the form</p>
<h4>Recipient Data</h4>
<p><strong>$recipients</strong> &#8211; If you are just sending email to a single address, enter it here. For more advanced usage such as multiple recipients, CC, BCC, etc.. more information is below</p></blockquote>
<p>The other settings are optional, and are explained below.</p>
<hr /><a name="otherconfig"><br />
<h3>Other Configuration Options</h3>
<p></a></p>
<p>This is a listing of the other configurable options in the script. These are optional, but allow for much greater customization</p>
<blockquote><p><strong>Form Structure</strong> &#8211; This is where you define the fields that will be used on this form. There are a lot of options available for this, and they will be explained further down as well</p>
<p><strong>Manual Form Code</strong> &#8211; This is a very advanced option that has its own section on this page.</p>
<p><strong>Wrap messages</strong> &#8211; This option wraps message lines to 70 characters to comply with RFC specifications</p>
<p><strong>Save attachments</strong> &#8211; If enabled, attached files will be saved to a directory on the server instead of attached to the email.</p>
<p><strong>Save attachment path</strong> &#8211; Where files will be saved, if attach_save is enabled. This is the full path on the server, with a trailing slash. Directory must have write permissions. Example: /home/user/public_html/uploads/</p>
<p><strong>Show required</strong> &#8211; If enabled, required fields will be marked with an asterisk</p>
<p><strong>Show URL</strong> &#8211; If enabled, the URL the script is running from will be added to the message</p>
<p><strong>Show IP and Hostname</strong> &#8211; If enabled, the visitor&#8217;s IP and hostname are added to the message</p>
<p><strong>Special Fields &#8211; Sender name, Sender email, and Email subject</strong> &#8211; These options help generate the email headers. If you enter a field name, it will be replaced by user input from that field. For example, if you have a form field called fm_name and you use that as the Sender name option, the visitor&#8217;s name will be used as the From field in the email. You can also combine them. If you have a field called fm_firstname and fm_lastname you could enter &#8216;fm_lastname, fm_firstname&#8217; &#8211; For the Sender email option, just use your email field</p>
<p><strong>Max upload size</strong> &#8211; This allows you to set the maximum file size (in bytes) for attachment uploads. This option only applies if the setting is lower than the value already set in your php.ini file</p>
<p><strong>Message Structure</strong> &#8211; This feature is optional. If left blank, the script will generate the email message itself, which will include all the data the visitor submits. If you choose to use this option, it will act as the message template. Simply enter your custom text, including your field names. When the message is generated, the field names will be replaced by the user input from those fields. Note: Since the script will just do a search and replace for field names, be sure they are unique enough. Example: A check for fm_message2 would also get triggered by fm_message when the script adds in the input.</p>
<p><strong>Success Message</strong> &#8211; This is the text that is shown after the email has been sent. You can also use field names in this, and the user input from those fields will be used to generate the message.</p>
<p><strong>Auto Reply</strong> &#8211; This is an optional feature that allows you to automatically send a pre-defined message back to those who contact you. More information on this is below</p>
<p><strong>Image Verification Method</strong> &#8211; There are three choices for image verification. It can be disabled, you can use the script&#8217;s built-in system (a simple captcha &#8211; requires GD support on the server), or you can use the ReCaptcha system (requires signing up for a free account at <a href="http://recaptcha.net">recaptcha.net</a>)</p>
<p><strong>Basic Method Options</strong> &#8211; If using the basic image verification method, you can choose the text and background color for the image (3 or 6 digit hex codes). By default, the script will try and choose the best file format for the verification image, but if it gives you any problems, you can manually specify the format to see what works best for your server.</p>
<p><strong>ReCaptcha Method Options</strong> &#8211; If using the ReCaptcha image verification method, you must enter the public and private keys given to you at the ReCaptcha website. These are used to generate the verification form, and the keys are specific to the website under your account (meaning if you use this script on multiple sites, you need a set of keys for each).</p>
<p><strong>Save Data to File</strong> &#8211; When enabled, the form input will be saved to a delimited file.</p>
<p><strong>Still Send Email</strong> &#8211; When using the delimited file feature, this option determines whether or not the script still sends the email.</p>
<p><strong>Data Path</strong> &#8211; The path to the file the data will be written to &#8211; relative to the script&#8217;s directory. Be sure to give this file write access.</p>
<p><strong>Delimiter</strong> &#8211; Fields will be separated by this character. If this character is found in the actual data, it will be removed for simplicity.</p>
<p><strong>Newlines</strong> &#8211; Newlines in input, such as text areas, will be replaced by this, to keep the data on a single line in the file.</p>
<p><strong>Timestamp</strong> &#8211; Adds the date/time to the beginning of each line in your data file. This uses the <a href="http://us.php.net/date">PHP date format</a>. Leave blank to disable.</p></blockquote>
<hr /><a name="customize"><br />
<h3>Other Customizations</h3>
<p></a></p>
<p>With the exception of the text defined in the options, all text visible to the visitor is contained within the language file.</p>
<p>Visual changes to the form can be made in the included CSS file. The class names used in the examples below already exist within the CSS.</p>
<hr /><a name="usage"><br />
<h3>Usage</h3>
<p></a></p>
<p>If you are using the standalone option, all you have to do is open the URL to the script file in your browser. </p>
<p>If you are not using the standalone option, you can include the script in your existing PHP file with the following code:</p>
<p><code>&lt;?php include('dd-formmailer.php'); ?&gt;</code></p>
<p>Be sure to use the relative path to the script file.</p>
<hr /><a name="advancedrecip"><br />
<h3>Advanced Recipient Options</h3>
<p></a></p>
<p>As mentioned above, if you want to send the messages to a single recipient, just enter the email address in the recipients option. To send to multiple recipients, separate the addresses with a <strong>|</strong> (pipe) character, and use one of the following prefixes for each: <strong>to= cc= bcc=</strong></p>
<p><strong>Examples:</strong></p>
<pre>to=user1@domain.com|to=user2@domain.com
to=user1@domain.com|cc=user2@domain.com
to=user1@domain.com|cc=user2@domain.com|bcc=user3@domain.com</pre>
<p>You can have as many of each type (to, cc, bcc) as you like, and they can be in any order, although the first one in the list is the always the primary recipient, and must use <strong>to=</strong></p>
<p>For those of you who want to let the vistor choose the recipient from a drop-down box, first you must enter <strong>selrecip</strong> in the recipients field. Then you must add a new line in the form structure box. Example:</p>
<pre>type=selrecip|class=fmselect|label=Recipient|data=(select),
User1,user1@domain.com,User2,user2@domain.com</pre>
<p>The type must be <strong>selrecip</strong>, but you can use whatever you like as the CSS class, and label. The first item in the data parameter is the default (unselected) option. After that are the names and email addresses. You can add in as many as you like &#8211; just keep them in the proper order (name,email,name,email,etc..). Only the names are visible within the HTML for privacy reasons. </p>
<p>The &#8216;(select)&#8217; item is the default selection, which the user must change to submit the form. You can change the &#8216;(select)&#8217; text if you choose.</p>
<hr /><a name="advancedform"><br />
<h3>Advanced Form Structure</h3>
<p></a></p>
<p>This script uses a dynamic form generation system, which means that by simply adding a new line to the form structure, you will have a new field in your form. You can have as many fields as you like, and in any order. The only field type that you must absolutely have is the <strong>verify</strong> field if you are using the image verification option. All of the fields are explained below, with examples. Separate each field type with a single newline in the form structure option. (Some of the examples below are bit long, so they are wrapped to the next line &#8211; be sure that the only newlines are after each field type when adding them to your form structure.)</p>
<p>These are the different parameters that apply to most of the field types (Special exceptions and parameters unique to a particular field are listed under each field type):</p>
<ul>
<li><strong>type</strong> &#8211; This tells the script what type of field you are adding.</li>
<li><strong>class</strong> &#8211; The CSS class used to style the field. The classes used in the examples below already exist in the CSS file.</li>
<li><strong>label</strong> &#8211; Text that is shown next to the field.</li>
<li><strong>fieldname</strong> &#8211; The name of the form field (must be unique).</li>
<li><strong>max</strong> &#8211; Maximum number of characters allowed.</li>
<li><strong>req</strong> &#8211; (OPTIONAL) If you want to require a field, set this to true. If not, do not add it.</li>
<li><strong>default</strong> &#8211; (OPTIONAL) This allows you to specify the default value of a field.</li>
</ul>
<hr />
<h4>TEXT</h4>
<p>This is a standard text input field.</p>
<pre>type=text|class=|label=|fieldname=|max=|[req=true]|[ver=]|[default=]</pre>
<p>The text field type has a special parameter &#8211; <strong>ver</strong> &#8211; which can be used to verify the input. You can choose <i>email</i> (which checks that the input is a proper email address) or <i>url</i> (which checks that the input is not only a proper URL, but that it actually exists). If you do not want to use either validation option, do not add this parameter.</p>
<p><strong>Examples</strong>:</p>
<pre>type=text|class=fmtext|label=Name|fieldname=fm_name|max=100|req=true 

type=text|class=fmtext|label=Age|fieldname=fm_age|max=100|
default=Enter your age! 

type=text|class=fmtext|label=Email|fieldname=fm_email|max=100|req=true|
ver=email 

type=text|class=fmtext|label=URL|fieldname=fm_url|max=100|ver=url</pre>
<hr />
<h4>DATE</h4>
<p>This is a javascript pop-up date chooser.</p>
<pre>type=date|class=|label=|fieldname=|[req=true]</pre>
<p>This field type generates a text box with a calendar icon next to it. The user can enter a date manually, or click on the icon to see a small calendar that they can choose a date from.</p>
<p>To change this image, just replace calendar.gif in the script directory. Either give your file the same name, or search and replace the name in the script file.</p>
<p><strong>Example</strong>:</p>
<pre>type=date|class=fmdate|label=Event Date|fieldname=fm_date|req=true </pre>
<hr />
<h4>HTML</h4>
<p>This field type lets you insert html, or other code, anywhere in your form.</p>
<pre>type=html|text=</pre>
<p><strong>Example</strong>:</p>
<pre>type=html|text=&lt;p&gt;Hello!&lt;/p&gt; </pre>
<hr />
<h4>PASSWORD</h4>
<p>This is a standard password field. It is exactly like a text field, except it shows asterisks when the user types.</p>
<pre>type=password|class=|label=|fieldname=|max=|[req=true]|[confirm=true]</pre>
<p>The password field type also has a special parameter &#8211; <strong>confirm</strong> &#8211; which if set to true, it duplicates the password field, so that the visitor has to confirm their input. If you do not want to use this, do not add the confirm parameter.</p>
<p><strong>Examples</strong>:</p>
<pre>type=password|class=fmtext|label=Password|fieldname=fm_pass|max=100|
req=true|confirm=true
&nbsp;
type=password|class=fmtext|label=Secret Word|fieldname=fm_secret|max=100</pre>
<hr />
<h4>TEXTAREA</h4>
<p>This is a standard text area, for multiple lines of text.</p>
<pre>type=textarea|class=|label=|fieldname=|max=|rows=|[req=true]|[default=]</pre>
<p>The textarea field type has a special parameter &#8211; <strong>rows</strong> which defines the number of rows in the field (required for valid html).</p>
<p><strong>Examples</strong>:</p>
<pre>type=textarea|class=fmtextarea|label=Message|fieldname=fm_message|
max=1000|rows=6
&nbsp;
type=textarea|class=fmtextarea|label=Message|fieldname=fm_message|max=1000|
rows=4|req=true
&nbsp;
type=textarea|class=fmtextarea|label=Message|fieldname=fm_message|max=1000|
rows=10|req=true|default=Type here!</pre>
<hr />
<h4>WIDETEXTAREA</h4>
<p>This is exactly the same as the standard textarea, except that it&#8217;s wider, and the label is above it instead of to the side.</p>
<pre>type=widetextarea|class=|label=|fieldname=|max=|rows=|[req=true]|[default=]</pre>
<p><strong>Example</strong>:</p>
<pre>type=widetextarea|class=fmtextwide|label=Message|fieldname=fm_message|
max=1000|rows=10|req=true</pre>
<p><strong>*</strong> Note that the normal textarea, and wide textarea fields use a different CSS class for formatting.</p>
<hr />
<h4>VERIFY</h4>
<p>This field is required if you are using the <strong>basic</strong> verification method. It does not apply if you are using the ReCaptcha method. It is used for placement of the verification image (and associated text box) in the form.</p>
<pre>type=verify|class=|label=</pre>
<p><strong>Example</strong>:</p>
<pre>type=verify|class=fmverify|label=Verify</pre>
<hr />
<h4>FULLBLOCK and HALFBLOCK</h4>
<p>These are not standard form fields, but simply a way you can add text to your form. The full block is as wide as a wide textarea, while the half block is aligned with other standard fields. You can use basic HTML in your text if you like.</p>
<pre>type=fullblock|class=|text=
type=halfblock|class=|text=</pre>
<p><strong>Examples</strong>:</p>
<pre>type=fullblock|class=fmfullblock|text=This could be some sort of 
introduction message.
&nbsp;
type=halfblock|class=fmhalfblock|text=This could be used to explain a field 
in greater depth.</pre>
<hr />
<h4>OPENFIELDSET and CLOSEFIELDSET</h4>
<p>These do just what the name implies &#8211; they open and close a fieldset in your form so you can help group fields together. It also allows you to specify a legend for the fieldset (required for valid HTML).</p>
<pre>type=openfieldset|legend=
type=closefieldset</pre>
<p><strong>Examples</strong>:</p>
<pre>type=openfieldset|legend=Your Information
&nbsp;
(other field would go between these)
&nbsp;
type=closefieldset</pre>
<hr />
<h4>CHECKBOX</h4>
<p>The checkbox field can be used to generate a single checkbox, or a group of them. The usage is a bit different than the other fields.</p>
<pre>type=checkbox|class=|label=|data=
(fieldname),(text),(checked),(REQUIRED),
(fieldname),(text),(CHECKED),(REQUIRED)&#46;..</pre>
<p>As you can see, the checkbox data is a comma separated list of four items per checkbox:</p>
<ul>
<li><strong>fieldname</strong> &#8211; A unique fieldname for each checkbox in the form.</li>
<li><strong>text</strong> &#8211; The text shown to the right of each checkbox.</li>
<li><strong>checked</strong> &#8211; <strong>true</strong> or <strong>false</strong>. This allows you to make checkboxes checked by default.</li>
<li><strong>required</strong> &#8211; <strong>true</strong> or <strong>false</strong>. If true, it means that the user must check the box to send the message. Mainly useful for &#8216;check here to agree&#8217; type situations.</li>
</ul>
<p><strong>*NOTE*</strong> Because this field type uses commas to separate data, if you would like a comma to be displayed in your data, simply use two. It will be replaced later in the code.</p>
<p><strong>Examples</strong></p>
<pre>type=checkbox|class=fmcheck|label=I Agree|data=fm_agree,I agree to the 
terms,false,true
&nbsp;
type=checkbox|class=fmcheck|label=Interests|data=fm_i1,Computers,false,
false,fm_i2,Art,false,false,fm_i3,Music,false,false</pre>
<hr />
<h4>RADIO</h4>
<p>This field generates a group of radio buttons. Radio buttons are similar to checkboxes, except that they are treated as a group, and only one option may be selected. </p>
<pre>type=radio|class=|label=|fieldname=|[req=true]|[default=]|data=(text),(text),
(text)&#46;..</pre>
<p>The <strong>req</strong> and <strong>default</strong> items are optional. <strong>req</strong>, if set to true, makes the field required. <strong>default</strong> can be set to the option number you want to be selected by default (starting at 1).</p>
<p><strong>*NOTE*</strong> Because this field type uses commas to separate data, if you would like a comma to be displayed in your data, simply use two. It will be replaced later in the code.</p>
<p><strong>Examples</strong>:</p>
<pre>type=radio|class=fmradio|label=Gender|fieldname=fm_gender|data=Male,Female
&nbsp;
type=radio|class=fmradio|label=Color|fieldname=fm_color|req=true|default=1|
data=Unspecified,Red,Green,Blue</pre>
<hr />
<h4>SELECT</h4>
<p>The select field generates either a standard drop-down box, or a multi-select box, depending on the <strong>multi</strong> option. Option groups are supported as well.</p>
<pre>type=select|class=|label=|fieldname=|[multi=true]|[req=true]|data=(#group),
(text),(text),(#group),(text)&#46;..</pre>
<p>The <strong>multi</strong> and <strong>req</strong> options are optional.</p>
<p>If the field is required, the first option you have in the data paramater will be the default, which tells the user they need to select one of the options. If they do not change the default option, and it is required, they will receive an error.</p>
<p>The data field is just a list of the options, separated by a comma. To define the start of an option group, just prefix the group name with a # as shown below.</p>
<p><strong>*NOTE*</strong> Because this field type uses commas to separate data, if you would like a comma to be displayed in your data, simply use two. It will be replaced later in the code.</p>
<p><strong>Examples</strong>:</p>
<pre>type=select|class=fmselect|label=Age|fieldname=fm_age|req=true|
data=(select),0-30,31-60,61-90,91-120
&nbsp;
type=select|class=fmselect|label=Colors|fieldname=fm_colors|
multi=true|req=true|data=Red,Green,Blue
&nbsp;
type=select|class=fmselect|label=Choose|fieldname=fm_choose|
data=#Category1,item1,item2,#Category2,item3,item4</pre>
<hr />
<h4>FILE</h4>
<p>The file field generates a file upload box. As with all other fields, you can add as many of these as you like, as this script supports not only attachments, but multiple attachments. The only thing to keep in mind is that you may need to find out the limit your server has set for file upload sizes.</p>
<pre>type=file|class=|label=|fieldname=|[req=true]|[allowed=1,2,3]</pre>
<p>The <strong>allowed</strong> field is optional, and lets you define a (comma separated) list of file extensions that are allowed to be uploaded. Otherwise, all file types will be allowed.</p>
<p><strong>Examples</strong>:</p>
<pre>type=file|class=fmfile|label=Upload|fieldname=fm_upload
&nbsp;
type=file|class=fmfile|label=Upload|fieldname=fm_upload|req=true|
allowed=jpg,jpeg,gif,png</pre>
<hr /><a name="manualcode"><br />
<h3>Manual Form Code</h3>
<p></a></p>
<p>This feature allows you to manually specify the code used to generate your form. By default, this script uses the form structure information to dynamically generate the form. While this makes it easier for most people, since they do not have to write any code, it can limit those who need a bit more flexibility in their form structure.</p>
<p><strong>Important Notice</strong>: Because this method means you will be writing the form code yourself, and it will not be generated by the script, there is no way for it to automatically insert the PHP code needed to put the user&#8217;s input back into the form when there is a validation error. It is just not possible for this to be done automatically due to the nature of the option. The only way this can be accomplished is if you know enough about PHP to insert the code manually yourself. In other words, this is a very advanced option &#8211; only for those who are very familiar with HTML forms and PHP.</p>
<ul>
<li><strong>1)</strong> Customize your form using the &#8216;Form Structure&#8217; option as you would normally &#8211; this is required even when using the manual code entry, as it allows for processing of the form.</li>
<li><strong>2)</strong> Be sure you have all your options exactly as you want them, and view your newly created form page.</li>
<li><strong>3)</strong> View the source of the page, so you can copy the generated html. The code you need is between the following lines:
<pre>&lt;!&#45;- START of Dagon Design Formmailer output &#45;-&gt;
&lt;!&#45;- END of Dagon Design Formmailer output &#45;-&gt;</pre>
</li>
<li><strong>4)</strong> You can now customize this form code however you like, as long as the core elements of the form and fields are still in place.</li>
<li><strong>5)</strong> Enter your new code into the &#8216;Manual Form Code&#8217; option. (<strong>PHP VERSION NOTICE:</strong> Depending on your form code, you may have to &#8216;escape&#8217; single or double quotes, as you are assigning this code as a string value to the $manual_form_code option!)</li>
<li><strong>6)</strong> If everything worked properly, your page will now use the custom form code. Once again, the standard form structure option is still required, as it is still for processing of the form.</li>
</ul>
<p>You can also adjust the included CSS file to better fit your needs, or completely clear it out and manually create an entire new CSS structure for your task. Keep in mind that if you change any field items (or any options which affect the form code generation), you will have to repeat this process.</p>
<p>To disable the manual form code feature, just clear out the option for it.</p>
<hr /><a name="autoreply"><br />
<h3>Auto Reply Feature</h3>
<p></a></p>
<p>The options page for each instance includes fields to define an auto reply message. This is a pre-defined message that is sent back to the visitor. </p>
<p>To use this option, simply enter the name, email address, subject line, and message for your auto response. To disable this feature, just leave the message field blank.</p>
<p>You can also use field names in the auto reply message, and the user input from those fields will be used to generate the message.</p>
<hr /><a name="csv"><br />
<h3>Saving Data to a File</h3>
<p></a></p>
<p>This option allows you to save the form input in a delimited file. Please see above for a full explanation of the options.</p>
<p>With the PHP version of this script, the path to the data file is relative to the location of the script. Be sure to give this file write access.</p>
<hr /><a name="othermods"><br />
<h3>Other modifications</h3>
<p></a></p>
<h4>Redirect after form submission &#8211; Method 1</h4>
<p>It is possible to use Javascript to redirect the user after the form has been filled out. While this method is not 100% valid (Javascript redirection should go in the HEAD section of the page), it works. To add this feature, first find the following line in the script:</p>
<pre>$o .= $sent_message;</pre>
<p>And replace it with this:</p>
<pre>$o .= &#039;&lt;script&gt;&lt;!&#45;- 
window.location= &quot;http://www.mysite.com/&quot; 
//&#45;-&gt;&lt;/script&gt;&#039;;</pre>
<p>(where mysite.com is the URL you want to redirect to)</p>
<h4>Redirect after form submission &#8211; Method 2</h4>
<p>This is another method you can use to redirect the user after the form has been submitted. First, find this line:</p>
<p><code>$o .= $sent_message;</code></p>
<p>And after it, add this:</p>
<p><code>$o .= '&lt;META HTTP-EQUIV="REFRESH" CONTENT="4;URL=http://www.mysite.com/"&gt;';</code></p>
<p>Where &#8216;4&#8242; is the number of seconds to wait before refresh, and the &#8216;http://www.mysite.com/&#8217; is the URL you want to redirect to.</p>
<h4>Passing values to the form</h4>
<blockquote><p>To allow values to be passed directly to the form, all you have to do is change all references of $_POST to $_REQUEST (The REQUEST superglobal contains the values of both POST and GET items)</p></blockquote>
<h4>Prevent form data from being resubmitted upon refresh</h4>
<p>This feature is included in the WordPress plugin version, but not in the PHP version, because of how it has to be used. To enable the feature when using the script in standalone mode, add the following code after the PHP declaration at the top of the script:</p>
<pre>if (count($_POST) &gt; 0) {
&nbsp;&nbsp;$lastpost = isset($_COOKIE[&#039;lastpost&#039;]) ? $_COOKIE[&#039;lastpost&#039;] : &#039;&#039;;
&nbsp;&nbsp;if ($lastpost != md5(serialize($_POST))) {
&nbsp;&nbsp;&nbsp;&nbsp;setcookie(&#039;lastpost&#039;, md5(serialize($_POST)));
&nbsp;&nbsp;&nbsp;&nbsp;$_POST[&#039;_REPEATED&#039;] = 0;
&nbsp;&nbsp;} else {
&nbsp;&nbsp;&nbsp;&nbsp;$_POST[&#039;_REPEATED&#039;] = 1;
&nbsp;&nbsp;}
}</pre>
<p>If you are <strong>not</strong> using the standalone option, you must add that code at the very top of the PHP file you are calling the script from. Add PHP tags around it if needed. Just make sure there is no extra whitespace around the PHP tags.</p>
<h4>Modifying the script to use HII for image verification</h4>
<p>Miro has posted instructions for users wanting to use HII: <a href="http://www.dagondesign.com/articles/secure-php-form-mailer-script/#comment-67245">Read the comment</a>. <strong>Notice</strong>: Modifications listed in the comments may not apply for new versions of the script.</p>
<h4>Using SELRECIP and BCC together</h4>
<p>The easiest way to do this, is to find the following line in the script:</p>
<p><code>$send_status = mail($send_to, $email_subject, $msg, $headers);</code></p>
<p>If you are using SELRECIP, the message will be sent to whoever the visitor chooses. If you would also like the message to go to someone else, no matter who is chosen, just duplicate that line like so, adding in the address of the secondary recipient:</p>
<p><code>$send_status = mail("user2@domain.com", $email_subject, $msg, $headers);</code></p>
<hr /><a name="troubleshooting"><br />
<h3>Troubleshooting</h3>
<p></a></p>
<h4>Fields not working properly/Form is not displaying properly</h4>
<p>As stated above, each field item needs to be on a single line in your form structure. Many of the examples above are long, so they do not show up on a single line. Be sure to remove any linebreaks when adding them to your form. <strong>One form field statement per line</strong>.</p>
<h4>Verification image not showing up</h3>
<p>The first thing to do is check to make sure your paths are set correctly in the options.</p>
<p>This script automatically chooses the best file type to generate the verification image. If your verification image is not displaying, the problem could be that your server will not properly generate that type of file. You can manually set this using the &#8216;Force image type&#8217; option in the script. It allows you to manually specify <strong>jpeg</strong>, <strong>gif</strong>, or <strong>png</strong>.</p>
<p>Try all the options to see which works best for you.</p>
<h4>Problems sending email</h4>
<p>The most common question I receive is &#8216;Why am I not receiving email from the script?&#8217;</p>
<p>There are many reasons this can happen. The first thing to do is make sure you have access to the PHP mail function on your web server, and that there are no restrictions in place that might prevent certain features of this script from working. If you are not sure, please ask your host for information. Unfortunately, I am not able to spend the time troubleshooting general server issues for everyone.</p>
<p>Also try having the script send the messages to another email address (on another domain), just to be sure the problem is not with your email account.</p>
<p>If you believe you can use the PHP mail function and have already tried a different email address, create a small PHP file with the following contents (be sure to use your own email address):</p>
<p><code>&lt;?php mail('you@domain.com', 'test subject', 'test message'); ?&gt;</code></p>
<p>Open the file in your browser and then check your mail. If you did not receive the message, something is not set properly on your server, and the trouble is not with this script. Even if other mail scripts work for you, that does not mean this one will, as there are several methods to send mail in PHP.</p>
<p>If you <strong>do</strong> receive the message, it most likely means that your server is configured to not allow the use of the fourth parameter (extra headers) in the mail() function. To work around this,  replace this line:</p>
<p><code>$send_status = mail($send_to, $email_subject, $msg, $headers);</code></p>
<p>With this:</p>
<p><code>$send_status = mail($send_to, $email_subject, $msg);</code></p>
<p>The only downside is that certain features (such as some header information, and the ability to send to multiple recipients) will be disabled. You may be able to contact your host and have them change this though. Many hosts add in this restriction for security reasons, to protect against unsafe scripts.</p>
<p>Lastly, some servers require an extra parameter for the mail function that specifies who the message is from. In many cases, this must be an email address on the server itself. Example:</p>
<p><code>$send_status = mail($send_to, $email_subject, $msg, $headers, 
'-f user@domain.com');</code></p>
<h4>&#8216;Headers already sent&#8217; error</h4>
<p>Another common question is the &#8216;headers already sent&#8217; error message. Without getting into the details, this generally happens when something is output to the browser before a call to set_cookie, header, or a number of other PHP functions. Be sure there is no extra whitespace at the top of your file.</p>
<h4>Mail headers showing up in message body / attachments not working</h4>
<p>This issue can be caused if your server does not like the return/newline character set being used to end lines of the email headers. If you are experiencing this problem, try changing this line: </p>
<p><code>if (!defined('PHP_EOL')) 
define ('PHP_EOL', strtoupper(substr(PHP_OS,0,3) == 'WIN') ? "\r\n" : "\n");</code></p>
<p>To this:</p>
<p><code>if (!defined('PHP_EOL')) 
define ('PHP_EOL', strtoupper(substr(PHP_OS,0,3) == 'WIN') ? "\n" : "\n");</code></p>
<h4>If you require special SMTP settings for mail to be sent</h4>
<p>If you have to manually specify the SMTP settings, you can do so with the following code. This is only recommended for advanced users.</p>
<pre>ini_set(&quot;SMTP&quot;,&quot;mail.MYDOMAIN.com&quot;);
ini_set(&quot;smtp_port&quot;,&quot;587&quot;);
ini_set(&quot;username&quot;,&quot;MYUSERNAME@MYDOMAIN.com&quot;);
ini_set(&quot;password&quot;,&quot;MYPASSWORD&quot;); 
ini_set(&#039;sendmail_from&#039;, $sender_email);
$send_status = mail($send_to, $email_subject, $msg, $headers);
ini_restore(&#039;sendmail_from&#039;);</pre>
<p>(Just search for the reference to the mail() function to see where to add it)</p>
<h3>Conclusion</h3>
<p>Please be sure to read the entire article before asking a question. I spend a lot of time on the scripts and plugins available on this site, and it can be hard to keep up with all the requests. If you need modifications or a custom version, please <a href="/contact/">contact me</a>. Thanks for reading!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dagondesign.com/articles/secure-php-form-mailer-script/feed/</wfw:commentRss>
		<slash:comments>1960</slash:comments>
		</item>
		<item>
		<title>Secure Guestbook Script with Image Verification</title>
		<link>http://www.dagondesign.com/articles/secure-guestbook-script-with-image-verification/</link>
		<comments>http://www.dagondesign.com/articles/secure-guestbook-script-with-image-verification/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 00:11:08 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[PHP Scripts]]></category>

		<guid isPermaLink="false">http://www.dagondesign.com/articles/secure-guestbook-script-with-image-verification/</guid>
		<description><![CDATA[This is the latest version of my secure PHP guestbook script. A lot of new features have been added since the last release including support for entry moderation, separate configuration and language files, improved code and session handling, and much more. The purpose of this script is to provide an easy to use, yet secure [...]]]></description>
			<content:encoded><![CDATA[<p>This is the latest version of my secure PHP guestbook script. A lot of new features have been added since the last release including support for entry moderation, separate configuration and language files, improved code and session handling, and much more. The purpose of this script is to provide an easy to use, yet secure guestbook which features image verification to keep out spam bots as well as other security measures. It uses a flat-file storage method so that it will work for users without database access and contains many other features not found in most standard guestbook scripts. <span id="more-53"></span></p>
<h3>Download</h3>
<ul>
<li><a href="http://www.dagondesign.com/files/ddgb.zip">ddgb.zip</a></li>
</ul>
<p>

	<div style="margin: 10px 0 20px 0; padding: 6px; border: 1px solid #D5D5D5; background: #F3F3F3; color: #777777; font-weight: bold;">

	<a href="http://www.dagondesign.com/donate/"><img src="http://www.dagondesign.com/wp-content/themes/dagondesign3.11/images/donation-button-small.gif" style="vertical-align: middle; "></a>

	&nbsp; If you have found this page useful, please consider donating. Thanks!

	</div>

	</p>
<h3>Included Languages</h3>
<p>The script current includes files for the following languages: English, Dutch, Formal German, French, Italian, Norwegian, Portuguese, Romanian, Spanish, Swedish, Turkish</p>
<h3>See it in action</h3>
<p>I have a demo guestbook here: <a href="http://www.dagondesign.com/demo/ddgb/ddgb.php">Demo guestbook</a></p>
<h3>Installation</h3>
<ul>
<li>Download <strong>ddgb.zip</strong> and uncompress</li>
<li>Upload all files into a directory of your choosing</li>
<li>Give write-access to <b>/dat/.entries</b> and <b>/dat/.banlist</b> (chmod 666 or 777)</li>
<li>Configure the options in <b>config.php</b></li>
<li>Run the script by calling <strong>ddgb.php</strong></li>
</ul>
<h3>Changelog</h3>
<div class="scrollbox">
<ul>
<li><strong>07-01-09 </strong> &#8211; Not a version update, but the spanish language file has been updated, and the missing header.php file (when used in stand-alone mode) has been restored.</li>
<li><strong>02-22-09 v2.45</strong> &#8211; Several new features from contributor Hans Nordhaug, including: alt attributes added for valid xhtml, increased spam protection (honeypot field), made page navigation translateable, various visual changes.</li>
<li><strong>07-27-07 Vv2.44</strong> &#8211; PHP short-tag bug fixed. Italian language file added.</li>
<li><strong>06-20-07 v2.43</strong> &#8211; File locking feature is now an option (disabled by default), instead of automatically enabled</li>
<li><strong>06-13-07 v2.42</strong> &#8211; Security update</li>
<li><strong>04-04-07</strong> &#8211; Spanish language file has been added</li>
<li><strong>03-24-07</strong> &#8211; Romanian language file has been added</li>
<li><strong>01-14-07 v2.41</strong> &#8211; Fixed bug related to display of entries</li>
<li><strong>11-01-06 v2.4</strong> &#8211; Moderation/display issues 100% resolved &#8211; Smilies are now clickable &#8211; Various bug fixes</li>
<li><strong>10-22-06 v2.31</strong> &#8211; Further improvements to the session code &#8211; Should work better on Windows servers now</li>
<li><strong>10-21-06 v2.3</strong> &#8211; Fixed bug with display of entries when moderating &#8211;  Improved session code &#8211; Dutch language file has been added</li>
<li><strong>10-17-06</strong> &#8211; Not a version update &#8211; Swedish and Portuguese language files have been added</li>
<li><strong>09-07-06 v2.2</strong> &#8211; Bug fixed (verification problems in non-standalone mode)</li>
<li><strong>09-01-06 v2.1</strong> &#8211; Various minor fixes &#8211; Added Norwegian language file</li>
<li><strong>08-24-06 v2.0</strong> &#8211; This is a very big update. Because of this, almost all of this page has been rewritten. Unfortunately, previous data files will not work with this release because of the new data structure. The advantage is that new fields can be added in the future without loosing the old data! The new data file is also simple enough that you should be able to manually add your old entries into it. New features include:<br />
- Separate config and language files<br />
- Option to require manual approval/moderation of entries<br />
- Improved session handling (no more separate verification file!)<br />
- Option to run as stand-alone script, or through another page<br />
- Secure data file storage method already implemented<br />
- Now supports basic smilies<br />
- Can disable image verification if not supported<br />
- New option to protect email addresses<br />
- And more &#8211; read below</li>
<li><strong>05-17-06</strong> &#8211; Not a version update, but I added instructions on making the guestbook even more secure.</li>
<li><strong>05-03-06 v1.31</strong> &#8211; Fixed a bug when editing entries &#8211; Name, website, and email fields can now be modified on existing entries.</li>
<li><strong>03-16-06 v1.3</strong> &#8211; Revised layout a tiny bit &#8211; Now checks for GD support and gives error if missing &#8211; Adds http:// prefix if not entered in web address &#8211; IP addresses of posters shown in admin box &#8211; Can now ban posters by IP (removes all of their posts too) &#8211; Added confirmation before deleting and banning</li>
<li><strong>02-16-06 v1.2</strong> &#8211; Added option to allow or disallow html in posts &#8211; Fixed a magic quotes bug</li>
<li><strong>02-06-06 v1.1</strong> &#8211; Added option to prevent search engine robots from following links posted by visitors (using the nofollow tag)</li>
<li><strong>02-02-06 v1.0</strong> &#8211; First public release!</li>
</ul>
</div>
<h3>Some of the features</h3>
<ul>
<li>Flat-file storage with precautions in place to prevent data files from being viewed.</li>
<li>Various security measures to prevent abuse.</li>
<li>Separate config and language files.</li>
<li>Image verification support (can be disabled if your server does not support the GD library).</li>
<li>Administrative interface to edit and delete entries, ban IPs (and automatically remove entries from that IP), and an option to enable manual approval of entries.</li>
<li>Implements &#8216;nofol&#8217; tag to prevent search engine spiders from following links in entries (discourages some spammers).</li>
<li>HTML in posts disabled by default &#8211; you can enable this if you like, but it is a big risk.</li>
<li>Option to run as stand-alone script or included through another page.</li>
<li>Smilies are supported (either enter in the code, or click to add!)</li>
</ul>
<h3>Notes</h3>
<p>If you want to include this script inside another page, be sure to set the proper &#8217;stand alone&#8217; setting in the config file. You may also need to include the session_start function at the very top of the PHP file you are including the script from:</p>
<p><code>&lt;?php session_start(); ?&gt;</code></p>
<p>Then just include the script in your file like this:</p>
<p><code>&lt;?php include 'ddgb.php'; ?&gt;</code></p>
<h3>Overview of the options</h3>
<p>These options can be set in <b>config.php</b> file</p>
<p><strong>Path to ddgb.php</strong></p>
<blockquote><p>This needs to be set to the <b>full url</b> of the ddgb.php file on your server. Example: http://www.yoursite.com/ddgb/ddgb.php</p></blockquote>
<p><strong>Path to ddgb-verify.php</strong></p>
<blockquote><p>This needs to be set to the <b>full url</b> of the ddgb-verify.php file on your server. Example: http://www.yoursite.com/ddgb/ddgb-verify.php</p></blockquote>
<p><strong>Locale Setting</strong></p>
<blockquote><p>This allows you to choose the language file the script will use. The current version includes English and Formal German. You can also create your own by using one of the existing files as a template. Just set this option to the name of the file (without the .php) that you want to use.</p></blockquote>
<p><strong>Administrator Password</strong></p>
<blockquote><p>This is the password used to perform the administrative functions &#8211; editing, deleting, banning, and moderating. Be sure to change the default password.</p></blockquote>
<p><strong>Administrator Email</strong></p>
<blockquote><p>Used for new entry notification, if the feature is enabled.</p></blockquote>
<p><strong>Send Notifications of New Entries</strong></p>
<blockquote><p>If enabled, admin will receive email for all new entries.</p></blockquote>
<p><strong>Run as Stand-Alone Script</strong></p>
<blockquote><p>If you plan to run this script by itself, leave this option set to TRUE. If you want to include it in another page, set it to FALSE, and take a look at the information above under the &#8216;Notes&#8217; section.</p></blockquote>
<p><strong>Title Tag</strong></p>
<blockquote><p>This is the title of the page when the script is used in stand-alone mode.</p></blockquote>
<p><strong>Path to Data File</strong></p>
<blockquote><p>This is the location of the data file used to store entries. Be sure to give it write-access (chmod 666 or 777).</p></blockquote>
<p><strong>Path to Ban File</strong></p>
<blockquote><p>This is the location of the data file used to store banned IPs. Be sure to give it write-access (chmod 666 or 777).</p></blockquote>
<p><strong>Requre Manually Entry Approval</strong></p>
<blockquote><p>If enabled, this will require that the admin manually approve posts. To do this, simply log in using the admin link and you will see all of the posts (including the ones not yet approved). Just click the appropriate link to approve them, or delete them instead if you wish.</p></blockquote>
<p><strong>Enable Smiles</strong></p>
<blockquote><p>If enabled, this option will convert text-smilies into images. It will also show the available smilies on the &#8216;new entry&#8217; page.</p></blockquote>
<p><strong>Show Introduction Text</strong></p>
<blockquote><p>This is an optional intro which can be shown above the guestbook. The text it uses can be found in the language file you are using. This is disabled by default.</p></blockquote>
<p><strong>Disable Image Verification</strong></p>
<blockquote><p>If this script tells you that your server does not support image verification because you do not have access to the GD library, or you simply wish to disable image verification, set this to TRUE.</p></blockquote>
<p><strong>Image Verification Colors</strong></p>
<blockquote><p>This allows you to easily change the colors of the verification image. You can enter either 3 or 6 character hex color codes.</p></blockquote>
<p><strong>Path to CSS File</strong></p>
<blockquote><p>This is the location of the script&#8217;s CSS file, which controls the look of the guestbook.</p></blockquote>
<p><strong>Entries Per Page</strong></p>
<blockquote><p>Determines how many entries will be shown on each page. If there are more entries than this number, the guestbook will be split up into multiple pages.</p></blockquote>
<p><strong>Allow HTML in Messages</strong></p>
<blockquote><p>This option is dangerous because it allows visitors to enter HTML, which is a big security risk. It is disabled by default.</p></blockquote>
<p><strong>Protect Email Addresses</strong></p>
<blockquote><p>With this option enabled, email addresses will be shown in the following format instead of as traditional links: someone [at] somewhere [dot] net.</p></blockquote>
<p><strong>Enable File Locking</strong></p>
<blockquote><p>File locking is not supported by all servers. If you would like to use this feature, set this to TRUE.</p></blockquote>
<h3>Email Notification of Posts</h3>
<p>For those of you who would like to receive email notification anytime someone adds a new entry, here is a simple mod. First, find this line in the main script file (ddgb.php):</p>
<p><code>echo '&lt;p&gt;' . _ADDED_THX . '&lt;/p&gt;';</code></p>
<p>Right after it, add the following:</p>
<p><code>mail('user@domain.com', 'New Guestbook Entry', 'A New Guestbook Entry was added!');</code></p>
<p>Be sure to set your email address. The second parameter is the subject, and the third parameter is the message.</p>
<p>You can also use the following variables for your email&#8217;s subject or message: $fm_name $fm_website $fm_email $fm_location $fm_message. For example:</p>
<p><code>mail('user@domain.com', 'New Guestbook Entry', 'A New Guestbook Entry was added by' . $fm_name);</code></p>
<p>If this method does not work for you, it may have to do with the way your server is configured. Some hosts require that you manually configure the sendmail parameters for the PHP mail function to work properly. If you think this might be the case, you can try the following code instead:</p>
<pre>$to = &quot;user@domain.com&quot;;
$from = &quot;user@domain.com&quot;;
$subject = &quot;New Guestbook Entry&quot;;
$body = &quot;A new guestbook entry has been added to your site.&quot;;
ini_set(&quot;SMTP&quot;,&quot;localhost&quot;);
ini_set(&quot;sendmail_from&quot;,$from);
$result = mail($to, $subject, $body, &quot;From: $from&quot;);</pre>
<h3>Changing the timezone</h3>
<p>If you would like to change the timezone setting for the script, edit <strong>config.php</strong> and find the following line:</p>
<p><code>// *** START OF OPTIONS ***</code></p>
<p>After it, add the following:</p>
<p><code>date_default_timezone_set('TIMEZONE');</code></p>
<p>Where <strong>TIMEZONE</strong> is a <a href="http://www.php.net/manual/en/timezones.php">valid timezone identifier.</a></p>
<h3>Troubleshooting</h3>
<p>If you are having trouble getting the verification code to display, one thing to try is setting the $verify_path option to the filename of the verfication file, instead of the full URL to it. Example:</p>
<pre>$verify_path = &quot;ddgb-verify.php&quot;;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dagondesign.com/articles/secure-guestbook-script-with-image-verification/feed/</wfw:commentRss>
		<slash:comments>636</slash:comments>
		</item>
		<item>
		<title>Automatic MySql Backup Script</title>
		<link>http://www.dagondesign.com/articles/automatic-mysql-backup-script/</link>
		<comments>http://www.dagondesign.com/articles/automatic-mysql-backup-script/#comments</comments>
		<pubDate>Thu, 03 May 2007 13:08:50 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[PHP Scripts]]></category>

		<guid isPermaLink="false">http://www.dagondesign.com/articles/automatic-mysql-backup-script/</guid>
		<description><![CDATA[This script finds all of the MySQL databases on your server, individually backs them up (for easy recovery of specific data), compresses them, and stores the file in a specified directory and/or emails it to you.]]></description>
			<content:encoded><![CDATA[<p>This script finds all of the MySQL databases on your server, individually backs them up (for easy recovery of specific data), compresses them, and stores the file in a specified directory and/or emails it to you. It has been updated since the initial public release and includes several new features.<span id="more-23"></span></p>
<p>I would like to thank <a href="mailto:oliver@teqneers.de">Oliver Mueller</a> for his many contributions to this release, including additional features, fixes, and testing. Thanks Oliver!</p>
<h3>Download v2.1</h3>
<ul>
<li><a href="http://www.dagondesign.com/files/backup_dbs.txt">backup_dbs.txt </a></li>
<li><a href="http://www.dagondesign.com/files/backup_dbs_config.txt">backup_dbs_config.txt</a></li>
</ul>
<p>

	<div style="margin: 10px 0 20px 0; padding: 6px; border: 1px solid #D5D5D5; background: #F3F3F3; color: #777777; font-weight: bold;">

	<a href="http://www.dagondesign.com/donate/"><img src="http://www.dagondesign.com/wp-content/themes/dagondesign3.11/images/donation-button-small.gif" style="vertical-align: middle; "></a>

	&nbsp; If you have found this page useful, please consider donating. Thanks!

	</div>

	</p>
<h3>Other versions</h3>
<ul>
<li><a href="http://www.dagondesign.com/files/backup_dbs_austin.txt">backup_dbs_austin.txt</a> &#8211; a custom version of this script by <a href="http://www.3rror.com/">Austin</a>, which was modified to email each database separately.</li>
</ul>
<h3>Page Contents</h3>
<ul>
<li><a href="#changelog">Change log</a></li>
<li><a href="#requirements">Requirements</a></li>
<li><a href="#installation">Installation</a></li>
<li><a href="#configuration">Configuration</a></li>
<li><a href="#logging">The logging / error system</a></li>
<li><a href="#manually">Manually running the script</a></li>
<li><a href="#cron">Setting up a cron job</a></li>
<li><a href="#final">Final notes</a></li>
</ul>
<h3><a name="changelog"></a>Change log</h3>
<ul>
<li><b>v2.1 (May 3, 2007)</b><br />
<blockquote><p>New option added to allow comma separated list of databases to exclude</p></blockquote>
</li>
<li><b>v2.0 (September 27, 2005)</b><br />
<blockquote><p>Completely rewritten in PHP<br />
Config is now in separate file<br />
New logging and error system<br />
Log files are time-stamped<br />
Log files can be sent with backup email<br />
Error log can be emailed to alternate address<br />
Windows support (more info below)<br />
Can set max execution time for script<br />
Option to flush and optimize databases<br />
Can be executed from browser, cron job, etc..</p></blockquote>
</li>
<li><b>v1.2 (March 30, 2005 &#8211; First public release)</b><br />
<blockquote><p>Written in Perl for Unix-based systems<br />
Automatically finds all of your MySQL databases<br />
Databases are backed up individually<br />
The backup files are compressed into a single file<br />
Backups can be stored on the server and/or emailed</p></blockquote>
</li>
</ul>
<h3><a name="requirements"></a>Requirements</h3>
<p>There are very few requirements for this script to function. You must of course have PHP. You will also need to supply the script with a username and password for MySQL so that it can extract the databases. It is best to use the root MySQL account so it will be able to perform a complete backup. </p>
<p>This script was originally written for Unix-based systems, but this new version will work on Windows platforms, provided that you make the required configuration changes, and have an acceptable zip and tar replacement (that can properly handle the command line parameters).</p>
<h3><a name="installation"></a>Installation</h3>
<p>To install the script, just download the two files above, renaming them from <strong>.txt</strong> to <strong>.php</strong>. You can put them anywhere on your server, as long as they are together. Since the script is now in PHP you can even run it directly from your browser, although if you do, a password-protected directory is recommended.</p>
<h3><a name="configuration"></a>Configuration</h3>
<p>Before running this script, open up the configuration file &#8211; <strong>backup_dbs_config.php</strong> &#8211; and make the required changes. Most of the options do not have to be changed, but some are required for the script to function properly (such as the MySQL connection info).</p>
<h3><a name="logging"></a>The logging / error system</h3>
<p>Two log files are created every time the script runs. The standard log and error log. What happens to them depends on your configuration.</p>
<p>When you are performing an email backup, the standard log will be placed inside the body of the message. The backup file will of course be attached to this message. You can also choose if the backup file and standard log are left on the server after emailing.</p>
<p>Error messages are still shown in the standard log, but the separate error log allows you to receive notification (to a separate email address) in case of error. This can be useful if you want errors sent to your primary account, while backups are sent to an alternate (that you do not check every day). That way you can always be aware of problems.</p>
<h3><a name="manually"></a>Manually running the script</h3>
<p>Depending on your configuration and user permissions, you may have to run this script as root.</p>
<p>From the command line, you can type: <strong>php /path_to_script/backup_dbs.php</strong></p>
<p>You can also run it directly from your web browser: <strong>http://www.domain.com/path/backup_dbs.php</strong></p>
<h3><a name="cron"></a>Setting up a cron job</h3>
<p>Once again, depending on your configuration and user permissions, you may have to be logged in as root to create a cron job.</p>
<p>type <strong>crontab -e</strong> and add a new line. Here is an example: </p>
<blockquote><p>30 0 * * * php /root/scripts/backup_dbs.php</p></blockquote>
<p>That will configure cron to run the script every day at 12:30 am. To learn more about cron jobs, you can visit this <a href="http://www.linuxhelp.net/guides/cron/">cron guide</a>.</p>
<p>After adding the new line, save the file and exit. Cron may have to be restarted before it will recognize the new job. To do this, simply type:</p>
<blockquote><p>/etc/init.d/crond restart</p></blockquote>
<p>On certain servers, emails are sent out containing the output of cron jobs. If you would like to prevent this, you can add the following code to the end of your new cron job line:</p>
<blockquote><p>> /dev/null 2>&#038;1 </p></blockquote>
<p>If you add this code, do not forget to restart cron again before testing. That line only prevents email notifications after cron jobs execute. This will not effect the script&#8217;s log file options.</p>
<h3><a name="final"></a>Final notes</h3>
<p>This script has been tested extensively, but I take no responsibility for any damages caused by misuse, improper configuration, or differences in server configurations. If you have any questions or comments, feel free to post them below!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dagondesign.com/articles/automatic-mysql-backup-script/feed/</wfw:commentRss>
		<slash:comments>213</slash:comments>
		</item>
		<item>
		<title>Checking for GD support on your server</title>
		<link>http://www.dagondesign.com/articles/checking-for-gd-support-on-your-server/</link>
		<comments>http://www.dagondesign.com/articles/checking-for-gd-support-on-your-server/#comments</comments>
		<pubDate>Sun, 23 Apr 2006 22:31:01 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[PHP Scripts]]></category>

		<guid isPermaLink="false">http://www.dagondesign.com/articles/checking-for-gd-support-on-your-server/</guid>
		<description><![CDATA[Several of the scripts and plugins on this site use the GD library to generate verification images. If you are having problems getting a generated image to display, the first step is to make sure your server has support for the GD library in PHP. This small script will tell you if your server supports [...]]]></description>
			<content:encoded><![CDATA[<p>Several of the scripts and plugins on this site use the GD library to generate verification images. If you are having problems getting a generated image to display, the first step is to make sure your server has support for the GD library in PHP. This small script will tell you if your server supports GD, and if it does, it will list the specific components. For example, some versions of PHP/GD have problems generating PNG files. You can use this script to know if you need to change the script to generate a GIF instead, or if you just do not have support at all for GD. <span id="more-72"></span></p>
<h3>Live Demo</h3>
<ul>
<li><a href="http://www.dagondesign.com/demo/gd-test.php">http://www.dagondesign.com/demo/gd-test.php</a></li>
</ul>
<h3>Download</h3>
<ul>
<li><a href="http://www.dagondesign.com/files/gd-test.txt">gd-test.txt</a></li>
</ul>
<p>

	<div style="margin: 10px 0 20px 0; padding: 6px; border: 1px solid #D5D5D5; background: #F3F3F3; color: #777777; font-weight: bold;">

	<a href="http://www.dagondesign.com/donate/"><img src="http://www.dagondesign.com/wp-content/themes/dagondesign3.11/images/donation-button-small.gif" style="vertical-align: middle; "></a>

	&nbsp; If you have found this page useful, please consider donating. Thanks!

	</div>

	</p>
<h3>Instructions</h3>
<p>Download the above file, rename it from <strong>.txt</strong> to <strong>.php</strong>, upload it to your server, and open it in your browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dagondesign.com/articles/checking-for-gd-support-on-your-server/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
	</channel>
</rss>
