Dagon Design WordPress Plugins, PHP Scripts, Tools, and Tutorials Thu, 23 Mar 2017 21:39:14 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.4 Free Text Host /articles/free-text-host/ /articles/free-text-host/#comments Sat, 16 Apr 2011 17:44:43 +0000 /articles/free-text-host/ The Free Text Host website is a new project by Dagon Design. The site allows visitors to host text without having to sign up or give any personal information. One possible usage for this is to host code snippets, but it can be used for just about anything really. Options include the ability to enter a password to allow you to edit or delete your text, and the choice to use preformatted text and make links clickable.

Try it out

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

Changelog

  • 04-16-11 – Added 2 new features. You can now chose to have pages automatically delete after a set number of days, or after being viewed a specified number of times.
  • 02-23-10 – Fixed several bugs with BBCode such as font size, color, quotes, and more (make sure you enable the BBCode option).
  • 10-07-09 – Added a view count to the bottom of the pages.
  • 06-24-09 – Support for BBCode has been added. Just click the option to enable it for your page. A listing of the supported tags is given.
  • 08-12-08 – Added a ‘Viewing password’ option. If you set one, it is required for your text to be viewed.
  • 10-22-07 – Option added to make links clickable, and to enable/disable preformatted output. You can also now edit the text with the edit/delete password.
  • 10-20-07 – First public release

Usage

Just enter your text and the verification code (to help prevent spam) and you will be given a randomly generated URL that only you will know.

There is currently a 50000 character limit. I will see how this works before I raise it higher.

Options

If you choose to use this option, you can enter an admin password when submitting your text. This password will allow you to make changes or delete your page. If you do not include an admin password, the page cannot be modified.

A viewing password can also be set, which if used, will require visitors to know the password to view your text.

The view limit is the number of times the page can be viewed before it automatically deletes. Leave blank to disable automatic deletion.

The day limit is the number of days that the page will remain active before it automatically deletes. Leave blank to disable automatic deletion.

Preformatted text can be selected, which means extra whitespace and linebreaks will appear exactly as you type them, and a fixed width font will be used.

Links in your text can be made clickable (turned into actual html links). These links will contain the nofollow attribute.

BBCode is also now supported (if the option is selected). A list of currently supported BBCode tags can be found here: #

Questions/Answers

Privacy Information

Only one cookie is used on the site, and it is for the verification code. The only information it contains is the code itself, and it is used to help prevent spam.

This site does not use any Javascript or Flash, and it has no tracking or logging features.

Is my hosted text visible by others?

Only if you give them the URL, or they guess it. The URL contains a 10 digit random alphanumeric ID, which allows for up to 3656158440062976 unique IDs, so it would be hard to guess.

Can I print my text?

Yes. If you print your page, it will only print the text itself. Everything else will be removed from the page.

Can I edit/delete my text?

Yes. When you enter your text, you have an option for a password. If you enter one, you can use it to edit or delete your page later.

What if I lose my URL?

Then it is lost. This is by design.

Disclaimer

While the generated pages are relatively private unless you give out the URL, Dagon Design cannot guarantee that no one will see your text by guessing the URL, etc.

]]>
/articles/free-text-host/feed/ 953
CSS Color Replacement Tool /articles/css-color-replacement-tool/ /articles/css-color-replacement-tool/#comments Tue, 23 Feb 2010 19:45:10 +0000 /?p=174 This tool allows you to extract the hex color codes from a remote CSS file, displaying both the hex codes and the colors themselves. You can then enter the new color codes you would like to replace them with. The script will then perform a global search and replace on the contents of the file, replacing each color with the code you specified, and displaying the updated CSS. The jscolor JavaScript Color Picker script has now been implemented to make choosing colors easier.

Why?

The primary purpose of this tool is to give you a quick way to change the entire color scheme of your site. While this can be done manually, the display of each color saves a lot of steps.

Try it out

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

Changelog

  • 02-23-10 Now features the jscolor script to choose new colors easier
  • 08-27-08 First version

Instructions

First, enter the URL to your CSS file and click Load data.

The script will extract all of the hex color codes from the CSS file, and display them in a list. Each line contains the color code, a box filled with the specified color, and an entry for the new color. Only unique colors are displayed.

With the help of the jscolor JavaScript Color Picker script, choosing new colors is even easier. Either click the box to choose your color, or manually type in the code.

When you are finished, just click Generate new CSS. The script will generate the full CSS file, with the replaced colors.

]]>
/articles/css-color-replacement-tool/feed/ 401
Clean Up Users Plugin for WordPress /articles/clean-up-users-plugin-for-wordpress/ /articles/clean-up-users-plugin-for-wordpress/#comments Sun, 26 Jul 2009 01:15:55 +0000 /?p=439 This WordPress plugin removes registered subscribers that have had no comments or posts. It can be useful for clearing out spam user accounts that were registered by bots and have no posts or comments associated with them. Other options may be added in the future.

Download

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

Installing

  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory.
  • Enable the plugin.
  • Use the plugin by visiting Settings > DDCleanUpUsers.

Usage

The usage of this plugin is very simple. Just view the options page for the plugin (under Settings > DDCleanUpUsers) and you will see one checkbox: Delete users with no comments or posts. Just check the box and click Submit. Registered subscribers who have no posts or comments will be removed.

Change Log

  • 07-25-09 Version 1.0 – First release.

Customizing

By default, the plugin will only check for subscribers with no comments and posts, but if for some reason you need to have it also check the editors, contributors, etc. you will find a way to change this in the code. Just search for // user roles and change the variables below.

]]>
/articles/clean-up-users-plugin-for-wordpress/feed/ 278
Scheduled Post Shift Plugin for WordPress /articles/scheduled-post-shift-plugin-for-wordpress/ /articles/scheduled-post-shift-plugin-for-wordpress/#comments Tue, 07 Jul 2009 23:20:11 +0000 /articles/scheduled-post-shift-plugin-for-wordpress/ This plugin automatically takes your oldest post, and updates its timestamp so that it appears as the latest post on your WordPress site. It does this by utilizing the cron feature built into WordPress 2.1 (and newer). It can rotate all the posts on your site, or just ones in specific categories. You can currently schedule it by setting the number of hours between shifts. For example, set it to 24 hours and it will shift the oldest post every day, at the time that you enabled it. You can also choose to only shift a post if it has been more than a set number of hours since the last post.

Download

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

Instructions

  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory
  • Enable the plugin
  • Configure the plugin options (under DDPostShift)
  • Click the ‘Enable Post Shift’ button to start

Disabling the Schedule

To stop the schedule, simply click the ‘Disable Post Shift’ button on the options page.

Change Log

  • 07-07-09 Version 1.31 – Added option to only shift a post if it has been a set number of hours since the last post was added.
  • 02-22-09 Version 1.3 – Updated to work better in recent WordPress versions. Log file support added, and several other updates. Can also shift posts when no drafts are available.
  • 08-28-08 Version 1.22 – A few bugs fixed. Now supports multiple category rotation.
  • 04-27-08 Version 1.21 – Updated for WordPress 2.5 and to be compatible with WP Security Scan plugin
  • 09-29-07 Version 1.2 – Updated for WordPress 2.3
  • 05-16-07 Version 1.1 – Updated for WordPress 2.2
  • 04-09-07 Version 1.0 – First release

Options

Here are the options available in this plugin’s options page in the WordPress admin panel.

Shift Delay

This is the number of hours between post shifts. The schedule will start as soon as you click the ‘Enable Post Shift’ button.

Only Shift after X Hours

If used, a post will only be shifted automatically if it has been more than this many hours since the last post was added.

Category IDs

If left blank, the plugin will operate on all of your posts. If you enter a comma-separated list of category ID’s, it will only update posts in those categories.

Log File

Full path on your server where you would like the log saved. You can leave this specific to this blog, or set up a global log for multiple blogs. Leave blank to disable this feature. Be sure to give this file write-access

]]>
/articles/scheduled-post-shift-plugin-for-wordpress/feed/ 1517
Latest Post from each Category plugin for WordPress /articles/latest-post-from-each-category-plugin-for-wordpress/ /articles/latest-post-from-each-category-plugin-for-wordpress/#comments Tue, 07 Jul 2009 23:09:47 +0000 /articles/latest-post-from-each-category-plugin-for-wordpress/ This plugin displays a list of the latest post from each category of your WordPress installation. It can be added to a post or page, or used directly in a template file. In the plugin’s options page you can choose the sort order, show or hide the dates, select the date formatting, show the first X characters of the content, display a link to the comments, and show comment counts, as well as other options.

Download

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

Installing

  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory.
  • Enable the plugin.
  • Configure the plugin options (under DDLatestFromEach).

Using

There are two ways you can use this plugin.

1) In a post or page, insert the following line:

<!-- ddlastfromeach -->

2) In a template file, insert the following code:

<?php echo dd_last_from_each(); ?>

Change Log

  • 07-07-09 Version 1.92 – Slight change to the way the list is displayed.
  • 07-06-09 Version 1.91 – You can now choose how many posts per category to display.
  • 02-19-09 Version 1.9 – Added option to use only selected categories.
  • 08-14-08 Version 1.8 – Tested with WordPress 2.6. Now uses WordPress function for determining date/time to show up to date posts. Added option to exclude categories.
  • 09-27-07 Version 1.7 – Updated to support WordPress 2.3. Added ‘Load Default Options’ button.
  • 05-31-07 Version 1.6 – Better support for international date formatting
  • 05-16-07 Version 1.5 – Updated for WordPress 2.2
  • 02-20-07 Version 1.4 – Updated for WordPress 2.1 (new pages were showing up in the default category)
  • 08-09-06 Version 1.3 – Added options to show comment links and counts. Also added an optional limit to the number of links shown, and a few other fixes.
  • 06-03-06 Version 1.2 – Added an option to turn category names into links. A bug was also fixed where extra slashes were being shown in the header text.
  • 05-31-06 Version 1.1 – You can now choose the sort order of the output, hide password-protected posts, and show the first X characters of the content after each post. A few other fixes have been made as well.
  • 05-30-06 Version 1.0 – First release.

Demo

Here you can see the plugin in action:

Latest Post From Each Category

Options

Here are the options available in this plugin’s options page in the WordPress admin panel.

Header text

This is shown above the list of posts.

Sort order

You can choose to have the data sorted by category or date. You also have the option of ascending or descending on both.

Show link to comments

When enabled, this will add a link to the comments for each post listed.

Include number of comments

This option only applies if Show link to comments is enabled. It adds the number of comments to the comment link.

Include link for posts with no comments

This option only applies if Show link to comments is enabled. It allows you to include or hide the comment link for posts with no comments.

Turn category names into links

Enabling this option will turn category names into links to the categories.

Hide password-protected posts

This prevents password-protected posts from showing up.

Show date after listed posts

This will show the post date after each post in the list.

Date format

If you are showing the date after posts, this will allow you to configure the date format (using the standard PHP date() format)

Show first X characters of posts

This allows you to show a preview of the content under each post in the list.

Number of characters to show

This lets you specify how many characters of the content will be shown, assuming you have the previous option enabled.

Limit list to X categories

This allows you to set a limit on the number of categories that will be shown in the list. Set to 0 for no limit.

Excluded category IDs

This is a comma-separated list of category ID’s you want excluded from the list.

Included category IDs

This is a comma-separated list of category ID’s you want to use in the list. This option only applies if you are not using the excluded category IDs option.

Max posts per category

If you would like to show more than one post per category, you can change the number here. To display all posts, use 0.

]]>
/articles/latest-post-from-each-category-plugin-for-wordpress/feed/ 567
Sitemap Generator Plugin for WordPress /articles/sitemap-generator-plugin-for-wordpress/ /articles/sitemap-generator-plugin-for-wordpress/#comments Tue, 07 Jul 2009 02:15:05 +0000 /articles/sitemap-generator-for-wordpress-v20/ This plugin creates a sitemap for your WordPress powered site. This is not just another XML sitemap plugin, but rather a true sitemap generator which is highly customizable from its own options page in the WordPress admin panel. Some of its features include: support for multi-level categories and pages, category/page exclusion, multiple-page generation with navigation, permalink support, choose what to display, what order to list items in, show comment counts and/or post dates, and much more. To see this plugin in action, visit my sitemap page.

Download

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

Languages

The latest version of this plugin includes complete support for language files. If you would like to submit a translation, please contact me. You can choose the language from the options page.

Current languages: English, Albanian, Arabic, Brazilian-Portuguese, Bulgarian, Catalan, Czech, Danish, Dutch, Estonian, Finnish, French, German, Italian, Japanese, Lithuanian, Norwegian, Polish, Romanian, Russian, Simplified Chinese, Serbian, SerbianLatin, Slovene, Spanish, Swedish, Turkish, Ukrainian

The language file contains not only the text shown on the sitemap page, but all of the text in the options page as well.

Changelog

  • 07-06-09 Version 3.17 – Fixed some translation issues. New string added to language files: DDSG_CONTINUED (used the English word for all existing translations). Added Finnish and Estonian languages. Updated Danish language. Various other fixes. Tested in WP 2.8
  • 02-22-09 Version 3.16 – I have switched back to hosting this plugin on this site, instead of the WP plugin repository. This should cause less confusion. New language files have been added: Arabic, Catalan, Danish, Norwegian, Serbian, and SerbianLatin. An issue has been fixed with the Czech lang file. An issue with the previous/next links not being translated has been fixed as well. Tested in WP 2.7.1
  • 09-17-08 Version 3.15 – This is a minor update that fixes the issue some users were having with permalinks when using multiple sitemap pages.
  • 05-12-08 Version 3.14 – Fixed an issue for xhtml compliance. Removed trailing whitespace in plugin file (was cause of ‘headers already sent’ error for some). Adjusted code to handle permalinks better.
  • 04-26-08 Version 3.13 – The plugin has been tested and works in WP 2.5. Added language files: Lithuanian, Romanian, Italian, Ukranian, and updated Spanish. Updated for compatibility with the WP Security Scan Plugin (thanks Michael). Undefined offset errors should be gone now. Updated the code that displays post/page titles. Fixed issue where comment counts showed on new lines.
  • 09-26-07 Version 3.12 – Instead of having separate plugin versions for pre and post WP2.3, this version handles everything from WP 2.1 to 2.3. There is a separate download for those using WP 2.0. A bug was also fixed that caused posts to be duplicated in 2.3.
  • 09-22-07 Version 3.11 – Bug fixed – categories were not showing up if they had a parent category with no posts.
  • 09-20-07 Version 3.1 – Now supports WordPress 2.3. Added Czech, Russian, and (updated) French language files.
  • 07-27-07 – Not a version update – added Albanian, Bulgarian, Swedish, and Turkish language files.
  • 07-08-07 Version 3.07 – Post titles with html formatting should now show up properly in the sitemap. Slovene language file added.
  • 06-22-07 Version 3.06 – Updated to display sub-categories (with posts), even when parent category has no posts.
  • 06-20-07 Version 3.05 – Ampersands (in titles) issue fixed.
  • 06-18-07 – Not a version update – added French and Brazilian-Portuguese language files.
  • 05-31-07 Version 3.04 – Better support for international date formatting added (using the date_i18n function). Option to limit multi-cat posts to one cat removed for now due to incompatibility issues. Spanish and Polish language files added.
  • 05-17-07 Version 3.03 – Parse error bug fixed. Non-published (draft) pages now hidden.
  • 05-16-07 Version 3.02 – Updated to work with WordPress 2.2. Drafts no longer appear in the sitemap. Added new languages: Simplified Chinese, Dutch, and Japanese.
  • 05-09-07 Version 3.01 – Bug fixed with future post check. German language file added.
  • 05-03-07 Version 3.0 – This is a very big update. Most of the plugin has been rewritten from the ground up. Many things have been fixed, several new features have been added, and it runs much faster than before. Be sure to read the updated information below.
  • 03-24-07 Version 2.73 – Sitemap page navigation will no longer show ‘/1/’ in the URL for the first page. The same method has also been applied for those not using permalinks.
  • 02-09-07 Version 2.72 – Fixed a compatibility issue with this plugin and some of my others.
  • 01-25-07 Version 2.71 – Fixed bug when used with WordPress 2.1
  • 09-17-06 Version 2.7 – You can choose to show excerpts even when a post or page title exists. They settings are now independent.
  • 04-02-06 Version 2.6 – The page and category exclusion lists are no longer case-sensitive. An issue has also been fixed for excluded categories that have non-excluded sub-categories. They now show up properly. Lastly, an issue was fixed where sites with more than 10,000 posts were having problems generating the sitemap.
  • 03-23-06 Version 2.5 – Lots of optimizations, runs much faster. Can now exclude pages (and subpages). Options page completely redone. All visible text is an option (under Language Settings). Comment count only counts approved comments.
  • 03-21-06 Version 2.4.2 – Some minor code adjustments. Works properly when the Google Analytics plugin by boakes.org is enabled.
  • 03-18-06 Version 2.4.1 – Several minor issues fixed. Rewrite code greatly improved. Added option to change ‘continued text’. Can now generate sitemap on error pages.
  • 03-14-06 Version 2.4 – Several requested features added: Choose to show everything, or just posts or pages. Can show publish date for posts (and configure the date/time format). Added ability to exclude categories. Option to open links in new windows
  • 02-16-06 Version 2.3.1 – Fixed uploads/attachments showing up in sitemap.Fixed small bug when sorting pages by title.
  • 01-23-06 Version 2.3 – Permalink support for navigation added! (read permalink section below for more info)
  • 01-22-06 Version 2.2.1 – Option to hide password-protected items. Fixed navigation bug (when WordPress was in sub-folder).
  • 01-21-06 Version 2.2 – Rewritten again! – Handles multi-level categories and pages. Continuation of previous posts/pages shown. Customizable text for category pages. Separate sort orders for posts and pages. CSS added for easy customization. Always hides drafts and future-dated posts now (there’s no reason not to). Multi-category posts handled much better. ‘Breadcrumb trail’ for sub-categories. For posts without titles – display ‘(no title)’, first X characters, or first X words. And many other fixes/updates.
  • 01-14-06 Version 2.0 – Rewritten completely, and turned into a plugin
  • 01-15-06 Version 2.1 – New features and various fixes: –
    Handles custom table prefixes. Fade effect upon submitting options (for WP 2.0 users). Option to display posts or pages first. For posts without titles, choose to ignore, use “(no title)”, or first few words of text. Place sitemap navigation at the top, bottom, or both.
  • 01-14-06 Version 2.0 – Rewritten completely, and turned into a plugin
  • 12-08-05 – Original (non-plugin) version 1.0

Installation

Upgrading?

To upgrade, disable and then delete the existing plugin. Then install the new version as explained above.

Be sure to use the new language files, as new text may have been added.

After you install, be sure to click the ‘Load Default Options’ button, as some of the settings have changed.

Version 3.0 of this plugin is a big jump from the previous versions. Most of the code has been rewritten from scratch, and a few things are different. One of the best improvements is the speed and stability. The sitemap generation is much faster now, which should especially help people with larger sites. Be sure to read the updated information below.

Want to run the plugin from a template file?

To use the sitemap generator function directly from a template file, just insert the following line where you would like the sitemap to be generated:

Permalinks for sitemap navigation

Depending on your settings, the sitemap may be spread across multiple pages. If you are using permalinks, be sure to enter the page slug of your sitemap page in the plugin options. That way it will use permalinks for the sitemap navigation as well. If you are not using permalinks, simply leave this option blank. Notice: After changing the sitemap page slug setting, be sure to update your permalink structure.

CSS declarations

This plugin has a couple of CSS classes built in to easily change the look of your sitemap. Just add the new declarations to your themes CSS file, and customize it however you like.

  • .ddsg-wrapper – Div around the entire sitemap.
  • .ddsg-pagenav – Div around the page navigation.

Available Options

These options can be configured from the options page in the WordPress admin panel. Most of these are fairly self-explanatory.

General Options

  • Language – Language files are located in /wp-content/plugins/sitemap-generator/lang/
  • Items per page – Set to 0 for unlimited
  • Sitemap page slug – If using permalinks, enter the slug of your sitemap page. Notice: After changing the sitemap page slug setting, be sure to update your permalink structure

Sitemap Generation

  • What to show – Show posts, pages, or both
  • If showing both, which first – Show posts or pages first
  • Post sort order – Sort by title or date (oldest or newest first)
  • Page sort order – Sort by title or date (oldest or newest first) or menu order (ascending or descending)
  • Show comment count after posts
  • Show comment count after pages
  • If showing comment counts, display when zero
  • Show dates after posts
  • Show dates after pages
  • Date format (if showing dates) – Use PHP date() formatting

Exclusions

  • Excluded categories – Category IDs, separated by commas. Sub-categories will also be excluded, as well as all posts contained in excluded categories
  • Excluded pages – Page IDs, separated by commas. Sub-pages will also be excluded
  • Hide future-dated posts
  • Hide password-protected items

Navigation

  • Sitemap navigation method – Two types to choose from
  • Show sitemap navigation – Where to show the navigation

Miscellaneous

  • Full path to XML sitemap – If you are also using an XML sitemap plugin, you can enter the path to the XML file here, and a link to it will be added to your sitemap page
  • Where to show XML sitemap link – At the end of the last page, or at the end of every page

Troubleshooting

If you are using the permalinks for multiple sitemap pages, be sure that you have updated your permalink structure after changing the page slug option so that it will recognize the new permalinks generated by the plugin.

]]>
/articles/sitemap-generator-plugin-for-wordpress/feed/ 3715
Hide Admin Panel from Subscribers Plugin for WordPress /articles/hide-admin-panel-from-subscribers-plugin-for-wordpress/ /articles/hide-admin-panel-from-subscribers-plugin-for-wordpress/#comments Tue, 07 Jul 2009 00:15:40 +0000 /?p=131 This plugin prevents subscribers from viewing the WordPress admin panel located at /wp-admin/. They are instead shown a custom message that you specify, as well as an optional logout link. You can use HTML tags and CSS in your message to style it any way you choose. Logged in users who have more access than subscribers are shown the standard admin panel.

Download

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

Change Log

  • 07-09-09 Version 1.1 – Fixed issue with logging out on newer WP versions. Fixed output of custom messages with the stripslashes function.
  • 08-20-08 Version 1.0 – First release.

Installing

  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory.
  • Enable the plugin.
  • View the plugin’s options page (under Settings -> DDHideAdmin) to configure your message.

Notes

If you would like to provide a logout link on the page, simply place the word LOGOUT where you would like it to appear (this keyword is case-sensitive) and the link will be generated.

]]>
/articles/hide-admin-panel-from-subscribers-plugin-for-wordpress/feed/ 357
Drop-Down Post List Plugin for WordPress /articles/drop-down-post-list-plugin-for-wordpress/ /articles/drop-down-post-list-plugin-for-wordpress/#comments Mon, 06 Jul 2009 23:27:51 +0000 /articles/drop-down-post-list-plugin-for-wordpress/ This plugin allows you to easily display drop-down boxes containing the posts for specified categories (or all categories). You can use this plugin by entering the trigger text in a post or page, or by adding the function call directly to your theme files. You can display as many drop-down boxes as you like, and you have a choice between a standard select box (with button), or a ‘jump menu’ (as the visitor clicks on a post, they will immediately be taken to that page without having to click a button). Other options are also available.

Download

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

Demo

This is a generated drop-down post list, listing the posts of a particular category:

Topic: WordPress Plugins and Mods


Installation

  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory
  • Enable the plugin
  • Configure the plugin under the DDPostList options page

Usage

There are two ways you can use this plugin.

Note: In both examples below, replace # with the category ID you want to list posts from, or use the word all to display posts from all categories.

1) In a post or page:

Topic: WordPress Plugins and Mods


Topic: WordPress Plugins and Mods


2) In a template file::


Change Log

  • 07-09-09 Version 1.33 – Added method to display posts from all categories. Changed the way the WP version was being detected for calls to the database.
  • 02-17-09 Version 1.32 – Small change to produce valid xhtml when using more than one drop-down on a page
  • 08-12-08 Version 1.31 – Small change to produce valid xhtml
  • 09-27-07 Version 1.3 – Updated to work with WordPress 2.3. Added ‘Load Default Options’ button
  • 08-01-07 Version 1.2 – Option added to specify default option in list
  • 07-29-07 Version 1.1 – More options added
  • 07-28-07 Version 1.0 – First release

Modifications

The code this plugin generates is fairly plain (no special formatting), but to make customization easy, the form has been assigned a CSS class: ddpl-form

For example, if you would like to set the width of the select field, add this code to your theme’s style sheet:

form.ddpl-form select { width: 200px; }

Options

Here are the current options available (found under the DDPostList options page)

Form Type – You can choose to have the plugin generate a ‘jump menu’, or a traditional list with a submit button

Default Option – If entered, this is the first option that will show up in the list (does not link to anything)

Button Text – If using a traditional list, this is the button text

Sorting Method – You can choose to sort by post date (ascending or descending), or post title

Post Limit – This allows you to define a limit for the number of posts in the list (0 for no limit)

Add Before Form – Code added here will be displayed before the generated form

Add After Form – Code added here will be displayed after the generated form

Add Before List – Code added here will be displayed before the list

Add After List – Code added here will be displayed after the list

]]>
/articles/drop-down-post-list-plugin-for-wordpress/feed/ 357
Secure PHP Form Mailer Script /articles/secure-php-form-mailer-script/ /articles/secure-php-form-mailer-script/#comments Mon, 06 Jul 2009 01:55:00 +0000 /?p=35 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 – 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.

You can see a very basic implementation of the WordPress plugin version of this script on this site’s contact page.

Notice: WordPress Users

Information on the WordPress plugin version of this script

Languages

As of the latest release, this script contains language files for:

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

If you would like to submit a language file please contact me.

WordPress vs PHP Versions

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.

Table of Contents

Due to the size of this page, I have split everything up into sections:


Download

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


Changelog

Since both the WordPress and non-WordPress versions of this script are updated together, the changelog below reflects both versions.

  • 07-05-09 – v5.8 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 ‘id’ declaration to select boxes. Fixed incorrect example code in the instructions. Other minor changes.
  • 02-22-09 – v5.7 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.
  • 10-19-08 – v5.6 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
  • 09-18-08 – v5.51 Captcha now displays properly in Safari and Chrome. All of the auto-reply issues should now be resolved. Few changes to headers for compatibility.
  • 08-24-08 – v5.5 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.
  • 05-13-08 – v5.41 Added support for saving form data to a delimited file. Fixed a few issues including the loading of recaptcha files, and attachment support.
  • 11-25-07 – v5.4 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.
  • 07-27-07 v5.33 – Few minor bugs fixed. Finnish language file added.
  • 07-08-07 v5.32 – Error messages affecting form alignment issue resolved. Italian and Slovak language files added.
  • 06-18-07 v5.3 – ‘undefined index’ errors fixed, image verification adjustments, p tags removed from fieldsets, changes to help html validity, various other fixes.
  • 05-09-07 v5.25 – ‘Thank you’ message now allows for form field inputs as well.
  • 05-08-07 v5.24 – 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.
  • 05-01-07 – Not a version update. Greek and Swedish language files added.
  • 04-18-07 v5.23 – 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 – Portuguese and Russian.
  • 04-18-07 – Not a version update. Brazilian Portuguese language file has been added.
  • 04-03-07 v5.22 – Email generation code has been modified to try to work with more servers. French language file has also been updated.
  • 03-28-07 v5.21 – Highly recommended update – Fixed an issue with the verification code not being handled properly. Nothing else has been changed.
  • 03-25-07 v5.2 – Email generation improved – 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.
  • 03-13-07 v5.1 – 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.
  • 02-06-07 v5.0 – This is a major update from version 4, and because of this, I have completely re-written this page, and removed the old changelog to save space.

Installation

  • 1) Download and uncompress dd-formmailer.zip
  • 2) Upload the entire dd-formmailer directory to your server
  • 4) Configure your options (explained below)
  • 5) Add the form to your page (explained below)

Required Configuration

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:

Standalone Option

$standalone – 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.

Path to CSS

$path_to_css – 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:

<link rel="stylesheet" href="(path to dd-formmailer.css)" type="text/css" media="screen" />

If you plan to use the javascript date field, you will also have to include the following line:

<script type="text/javascript" src="(location of date_chooser.js)"></script>

Language Setting

$language – The relative path to the language file you want to use.

Full URL to Script

$script_path – The full URL to dd-formmailer.php (or whatever you have renamed it to)

Full URL to Contact Page

$path_contact_page – 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

Recipient Data

$recipients – 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

The other settings are optional, and are explained below.


Other Configuration Options

This is a listing of the other configurable options in the script. These are optional, but allow for much greater customization

Form Structure – 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

Manual Form Code – This is a very advanced option that has its own section on this page.

Wrap messages – This option wraps message lines to 70 characters to comply with RFC specifications

Save attachments – If enabled, attached files will be saved to a directory on the server instead of attached to the email.

Save attachment path – 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/

Show required – If enabled, required fields will be marked with an asterisk

Show URL – If enabled, the URL the script is running from will be added to the message

Show IP and Hostname – If enabled, the visitor’s IP and hostname are added to the message

Special Fields – Sender name, Sender email, and Email subject – 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’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 ‘fm_lastname, fm_firstname’ – For the Sender email option, just use your email field

Max upload size – 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

Message Structure – 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.

Success Message – 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.

Auto Reply – 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

Image Verification Method – There are three choices for image verification. It can be disabled, you can use the script’s built-in system (a simple captcha – requires GD support on the server), or you can use the ReCaptcha system (requires signing up for a free account at recaptcha.net)

Basic Method Options – 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.

ReCaptcha Method Options – 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).

Save Data to File – When enabled, the form input will be saved to a delimited file.

Still Send Email – When using the delimited file feature, this option determines whether or not the script still sends the email.

Data Path – The path to the file the data will be written to – relative to the script’s directory. Be sure to give this file write access.

Delimiter – Fields will be separated by this character. If this character is found in the actual data, it will be removed for simplicity.

Newlines – Newlines in input, such as text areas, will be replaced by this, to keep the data on a single line in the file.

Timestamp – Adds the date/time to the beginning of each line in your data file. This uses the PHP date format. Leave blank to disable.


Other Customizations

With the exception of the text defined in the options, all text visible to the visitor is contained within the language file.

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.


Usage

If you are using the standalone option, all you have to do is open the URL to the script file in your browser.

If you are not using the standalone option, you can include the script in your existing PHP file with the following code:

<?php include('dd-formmailer.php'); ?>

Be sure to use the relative path to the script file.


Advanced Recipient Options

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 | (pipe) character, and use one of the following prefixes for each: to= cc= bcc=

Examples:

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

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 to=

For those of you who want to let the vistor choose the recipient from a drop-down box, first you must enter selrecip in the recipients field. Then you must add a new line in the form structure box. Example:

type=selrecip|class=fmselect|label=Recipient|data=(select),
User1,user1@domain.com,User2,user2@domain.com

The type must be selrecip, 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 – just keep them in the proper order (name,email,name,email,etc..). Only the names are visible within the HTML for privacy reasons.

The ‘(select)’ item is the default selection, which the user must change to submit the form. You can change the ‘(select)’ text if you choose.


Advanced Form Structure

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 verify 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 – be sure that the only newlines are after each field type when adding them to your form structure.)

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):

  • type – This tells the script what type of field you are adding.
  • class – The CSS class used to style the field. The classes used in the examples below already exist in the CSS file.
  • label – Text that is shown next to the field.
  • fieldname – The name of the form field (must be unique).
  • max – Maximum number of characters allowed.
  • req – (OPTIONAL) If you want to require a field, set this to true. If not, do not add it.
  • default – (OPTIONAL) This allows you to specify the default value of a field.

TEXT

This is a standard text input field.

type=text|class=|label=|fieldname=|max=|[req=true]|[ver=]|[default=]

The text field type has a special parameter – ver – which can be used to verify the input. You can choose email (which checks that the input is a proper email address) or url (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.

Examples:

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

DATE

This is a javascript pop-up date chooser.

type=date|class=|label=|fieldname=|[req=true]

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.

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.

Example:

type=date|class=fmdate|label=Event Date|fieldname=fm_date|req=true 

HTML

This field type lets you insert html, or other code, anywhere in your form.

type=html|text=

Example:

type=html|text=

Hello!


PASSWORD

This is a standard password field. It is exactly like a text field, except it shows asterisks when the user types.

type=password|class=|label=|fieldname=|max=|[req=true]|[confirm=true]

The password field type also has a special parameter – confirm – 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.

Examples:

type=password|class=fmtext|label=Password|fieldname=fm_pass|max=100|
req=true|confirm=true

type=password|class=fmtext|label=Secret Word|fieldname=fm_secret|max=100

TEXTAREA

This is a standard text area, for multiple lines of text.

type=textarea|class=|label=|fieldname=|max=|rows=|[req=true]|[default=]

The textarea field type has a special parameter – rows which defines the number of rows in the field (required for valid html).

Examples:

type=textarea|class=fmtextarea|label=Message|fieldname=fm_message|
max=1000|rows=6

type=textarea|class=fmtextarea|label=Message|fieldname=fm_message|max=1000|
rows=4|req=true

type=textarea|class=fmtextarea|label=Message|fieldname=fm_message|max=1000|
rows=10|req=true|default=Type here!

WIDETEXTAREA

This is exactly the same as the standard textarea, except that it’s wider, and the label is above it instead of to the side.

type=widetextarea|class=|label=|fieldname=|max=|rows=|[req=true]|[default=]

Example:

type=widetextarea|class=fmtextwide|label=Message|fieldname=fm_message|
max=1000|rows=10|req=true

* Note that the normal textarea, and wide textarea fields use a different CSS class for formatting.


VERIFY

This field is required if you are using the basic 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.

type=verify|class=|label=

Example:

type=verify|class=fmverify|label=Verify

FULLBLOCK and HALFBLOCK

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.

type=fullblock|class=|text=
type=halfblock|class=|text=

Examples:

type=fullblock|class=fmfullblock|text=This could be some sort of 
introduction message.

type=halfblock|class=fmhalfblock|text=This could be used to explain a field 
in greater depth.

OPENFIELDSET and CLOSEFIELDSET

These do just what the name implies – 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).

type=openfieldset|legend=
type=closefieldset

Examples:

type=openfieldset|legend=Your Information

(other field would go between these)

type=closefieldset

CHECKBOX

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.

type=checkbox|class=|label=|data=
(fieldname),(text),(checked),(REQUIRED),
(fieldname),(text),(CHECKED),(REQUIRED)...

As you can see, the checkbox data is a comma separated list of four items per checkbox:

  • fieldname – A unique fieldname for each checkbox in the form.
  • text – The text shown to the right of each checkbox.
  • checkedtrue or false. This allows you to make checkboxes checked by default.
  • requiredtrue or false. If true, it means that the user must check the box to send the message. Mainly useful for ‘check here to agree’ type situations.

*NOTE* 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.

Examples

type=checkbox|class=fmcheck|label=I Agree|data=fm_agree,I agree to the 
terms,false,true

type=checkbox|class=fmcheck|label=Interests|data=fm_i1,Computers,false,
false,fm_i2,Art,false,false,fm_i3,Music,false,false

RADIO

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.

type=radio|class=|label=|fieldname=|[req=true]|[default=]|data=(text),(text),
(text)...

The req and default items are optional. req, if set to true, makes the field required. default can be set to the option number you want to be selected by default (starting at 1).

*NOTE* 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.

Examples:

type=radio|class=fmradio|label=Gender|fieldname=fm_gender|data=Male,Female

type=radio|class=fmradio|label=Color|fieldname=fm_color|req=true|default=1|
data=Unspecified,Red,Green,Blue

SELECT

The select field generates either a standard drop-down box, or a multi-select box, depending on the multi option. Option groups are supported as well.

type=select|class=|label=|fieldname=|[multi=true]|[req=true]|data=(#group),
(text),(text),(#group),(text)...

The multi and req options are optional.

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.

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.

*NOTE* 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.

Examples:

type=select|class=fmselect|label=Age|fieldname=fm_age|req=true|
data=(select),0-30,31-60,61-90,91-120

type=select|class=fmselect|label=Colors|fieldname=fm_colors|
multi=true|req=true|data=Red,Green,Blue

type=select|class=fmselect|label=Choose|fieldname=fm_choose|
data=#Category1,item1,item2,#Category2,item3,item4

FILE

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.

type=file|class=|label=|fieldname=|[req=true]|[allowed=1,2,3]

The allowed 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.

Examples:

type=file|class=fmfile|label=Upload|fieldname=fm_upload

type=file|class=fmfile|label=Upload|fieldname=fm_upload|req=true|
allowed=jpg,jpeg,gif,png

Manual Form Code

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.

Important Notice: 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’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 – only for those who are very familiar with HTML forms and PHP.

  • 1) Customize your form using the ‘Form Structure’ option as you would normally – this is required even when using the manual code entry, as it allows for processing of the form.
  • 2) Be sure you have all your options exactly as you want them, and view your newly created form page.
  • 3) View the source of the page, so you can copy the generated html. The code you need is between the following lines:
    
    
  • 4) 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.
  • 5) Enter your new code into the ‘Manual Form Code’ option. (PHP VERSION NOTICE: Depending on your form code, you may have to ‘escape’ single or double quotes, as you are assigning this code as a string value to the $manual_form_code option!)
  • 6) 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.

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.

To disable the manual form code feature, just clear out the option for it.


Auto Reply Feature

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.

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.

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.


Saving Data to a File

This option allows you to save the form input in a delimited file. Please see above for a full explanation of the options.

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.


Other modifications

Redirect after form submission – Method 1

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:

$o .= $sent_message;

And replace it with this:

$o .= '';

(where mysite.com is the URL you want to redirect to)

Redirect after form submission – Method 2

This is another method you can use to redirect the user after the form has been submitted. First, find this line:

$o .= $sent_message;

And after it, add this:

$o .= '<META HTTP-EQUIV="REFRESH" CONTENT="4;URL=http://www.mysite.com/">';

Where ‘4’ is the number of seconds to wait before refresh, and the ‘http://www.mysite.com/’ is the URL you want to redirect to.

Passing values to the form

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)

Prevent form data from being resubmitted upon refresh

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:

if (count($_POST) > 0) {
	$lastpost = isset($_COOKIE['lastpost']) ? $_COOKIE['lastpost'] : '';
	if ($lastpost != md5(serialize($_POST))) {
		setcookie('lastpost', md5(serialize($_POST)));
		$_POST['_REPEATED'] = 0;
	} else {
		$_POST['_REPEATED'] = 1;
	}
}

If you are not 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.

Modifying the script to use HII for image verification

Miro has posted instructions for users wanting to use HII: Read the comment. Notice: Modifications listed in the comments may not apply for new versions of the script.

Using SELRECIP and BCC together

The easiest way to do this, is to find the following line in the script:

$send_status = mail($send_to, $email_subject, $msg, $headers);

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:

$send_status = mail("user2@domain.com", $email_subject, $msg, $headers);


Troubleshooting

Fields not working properly/Form is not displaying properly

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. One form field statement per line.

Verification image not showing up

The first thing to do is check to make sure your paths are set correctly in the options.

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 ‘Force image type’ option in the script. It allows you to manually specify jpeg, gif, or png.

Try all the options to see which works best for you.

Problems sending email

The most common question I receive is ‘Why am I not receiving email from the script?’

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.

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.

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):

<?php mail('you@domain.com', 'test subject', 'test message'); ?>

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.

If you do 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:

$send_status = mail($send_to, $email_subject, $msg, $headers);

With this:

$send_status = mail($send_to, $email_subject, $msg);

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.

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:

$send_status = mail($send_to, $email_subject, $msg, $headers, '-f user@domain.com');

‘Headers already sent’ error

Another common question is the ‘headers already sent’ 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.

Mail headers showing up in message body / attachments not working

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:

if (!defined('PHP_EOL')) define ('PHP_EOL', strtoupper(substr(PHP_OS,0,3) == 'WIN') ? "\r\n" : "\n");

To this:

if (!defined('PHP_EOL')) define ('PHP_EOL', strtoupper(substr(PHP_OS,0,3) == 'WIN') ? "\n" : "\n");

If you require special SMTP settings for mail to be sent

If you have to manually specify the SMTP settings, you can do so with the following code. This is only recommended for advanced users.

ini_set("SMTP","mail.MYDOMAIN.com");
ini_set("smtp_port","587");
ini_set("username","MYUSERNAME@MYDOMAIN.com");
ini_set("password","MYPASSWORD"); 
ini_set('sendmail_from', $sender_email);
$send_status = mail($send_to, $email_subject, $msg, $headers);
ini_restore('sendmail_from');

(Just search for the reference to the mail() function to see where to add it)

Conclusion

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 contact me. Thanks for reading!

]]>
/articles/secure-php-form-mailer-script/feed/ 2672
Secure Form Mailer Plugin For WordPress /articles/secure-form-mailer-plugin-for-wordpress/ /articles/secure-form-mailer-plugin-for-wordpress/#comments Mon, 06 Jul 2009 01:50:42 +0000 /articles/secure-form-mailer-plugin-for-wordpress/ This is the WordPress plugin version of my secure PHP form mailer script. This plugin has a wide range of features including: Support for multiple instances, 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 plugin 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 the plugin to fit your needs – whether it is 5 fields or 500. A non-WordPress version is also available. ReCaptcha support has also been added, as well as support for storing the data in a delimited file.

You can see a very basic implementation of the WordPress plugin version of this script on this site’s contact page.

Notice: non-WordPress Users

Information on the PHP version of this script

Languages

As of the latest release, this script contains language files for:

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

If you would like to submit a language file please contact me.

WordPress vs PHP Versions

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.

Table of Contents

Due to the size of this page, I have split everything up into sections:


Download

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


Changelog

Since both the WordPress and non-WordPress versions of this script are updated together, the changelog below reflects both versions.

  • 07-05-09 – v5.8 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 ‘id’ declaration to select boxes. Fixed incorrect example code in the instructions. Other minor changes.
  • 02-22-09 – v5.7 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. Tested and works in WordPress 2.7.1
  • 10-19-08 – v5.6 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/). WP Specific updates: Instances listed on main settings page – with descriptions of each instance (more info below). Updated display of options pages. Better support for multiple forms on one page. New language added: Vietnamese
  • 09-18-08 – v5.51 Captcha now displays properly in Safari and Chrome. All of the auto-reply issues should now be resolved. Few changes to headers for compatibility. The path for language files should now be auto-detected properly in all cases
  • 08-24-08 – v5.5 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.
  • 05-13-08 – v5.41 Added support for saving form data to a delimited file. Fixed a few issues including the loading of recaptcha files, and attachment support.
  • 11-25-07 – v5.4 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.
  • 07-27-07 – v5.33 Few minor bugs fixed. Finnish language file added.
  • 07-08-07 – v5.32 Error messages affecting form alignment issue resolved. Italian and Slovak language files added.
  • 06-18-07 – v5.3 ‘undefined index’ errors fixed, image verification adjustments, p tags removed from fieldsets, changes to help html validity, various other fixes.
  • 05-09-07 – v5.25 ‘Thank you’ message now allows for form field inputs as well.
  • 05-08-07 – v5.24 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.
  • 05-01-07 Not a version update. Greek and Swedish language files added.
  • 04-18-07 – v5.23 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 – Portuguese and Russian.
  • 04-18-07 Not a version update. Brazilian Portuguese language file has been added.
  • 04-03-07 – v5.22 Email generation code has been modified to try to work with more servers. French language file has also been updated.
  • 03-28-07 – v5.21 Highly recommended update – Fixed an issue with the verification code not being handled properly. Nothing else has been changed.
  • 03-25-07 – v5.2 Email generation improved – 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.
  • 03-13-07 – v5.1 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.
  • 02-06-07 – v5.0 This is a major update from version 4, and because of this, I have completely re-written this page, and removed the old changelog to save space.

Installation

  • 1) Download and uncompress dd-formmailer-wp.zip
  • 2) Upload the entire dd-formmailer directory to your WordPress plugins directory
  • 3) Activate the plugin
  • 4) Configure your options (explained below)
  • 5) Add the form to your page (explained below)

Quick and Basic Configuration

While this plugin 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 configuration changes you must make:

Create a new WordPress page, and type in the trigger text:

<!-- ddfm1 -->

Important: Make sure you add this using the html/code editor in WordPress, not the visual editor. In new versions of WordPress, just click the ‘html’ button above the edit box. If you use the visual editor it will not work, as the actual code you entered will be seen on the page, instead of being processed by the script.

Under Options -> DDFM1, fill in the following options:

Instance Description – This is a brief description of what you are using the instance for. All instances, and their descriptions, are listed on the main (DDFM-Main) options page, so you can easily keep track of them.

Contact page – Enter the full URL of your newly created contact page.

Recipients – Enter your email address.

Click Update options and you are finished! If you would like to learn more about the other features of this plugin, please continue reading.


Initial Configuration

After activating the plugin, you will have a new options page in the admin panel – DDFM-Main. These are the settings that apply to all instances of the plugin:

Instances – The number of contact forms this plugin will generate. If you just need a single contact form, leave this set to 1.

Current Instances – This is a list of the instances you currently have activated. It also displays the description for each instance. You can easily navigate to a particular instance from this page.

Image Verification Method – There are three choices for image verification. It can be disabled, you can use the script’s built-in system (a simple captcha – requires GD support on the server), or you can use the ReCaptcha system (requires signing up for a free account at recaptcha.net)

Basic Method Options – 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.

ReCaptcha Method Options – 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).

A ‘Load Default Options’ button is available if you wish to reset the settings on this page.

Each instance you create will have its own options page – DDFM1, DDFM2, etc. This is where you configure the settings for each individual form. These settings are listed below.


Form Configuration

These are the settings found on the options page for each instance:

Language – The language you want to use. To create a new language, simply duplicate the existing English.php file (in the plugins lang subdirectory), give it a new name, and edit it for your language. It will then automatically appear in this list (after reloading the page).

Contact page – This is the full URL of the page the form is actually going to be displayed on.

Recipients – If sending to a single recipient, all you have to do is enter the email address. This plugin supports multiple recipients, including CC and BCC, and even a drop-down box for recipient selection. Information on these configurations can be found further down on this page.

Form Structure – 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.

Manual Form Code – This is a very advanced option that has its own section on this page.

Sender name, Sender email, and Email subject – 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’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 ‘fm_lastname, fm_firstname’ – For the Sender email option, just use your email field.

The Email subject option works the same way. For example, you could enter ‘Contact: fm_subject’ and it will use the subject that the visitor entered, with the ‘Contact:’ prefix.

Message Structure – 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.

Auto Reply – 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.

Success Message – 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.

Save attachments – If enabled, attached files will be saved to a directory on the server instead of attached to the email.

Save attachment path – Where files will be saved, if ‘save attachments’ 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/

Show required – If enabled, required fields will be marked with an asterisk.

Show URL – If enabled, the URL the script is running from will be added to the message

Show IP and Hostname – If enabled, the visitor’s IP and hostname are added to the message.

Wrap messages – This option wraps message lines to 70 characters to comply with RFC specifications.

Max upload size – 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.

Save Data to File – When enabled, the form input will be saved to a delimited file.

Still Send Email – When using the delimited file feature, this option determines whether or not the script still sends the email.

Data Path – The path to the file the data will be written to – relative to the script’s directory. Be sure to give this file write access.

Delimiter – Fields will be separated by this character. If this character is found in the actual data, it will be removed for simplicity.

Newlines – Newlines in input, such as text areas, will be replaced by this, to keep the data on a single line in the file.

Timestamp – Adds the date/time to the beginning of each line in your data file. This uses the PHP date format. Leave blank to disable.

The option page for each inststance also has a ‘Load Default Options’ button.


Other Configuration Options

With the exception of the text defined in the options pages, all text visible to the visitor is contained within the language file.

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.


Usage

To show the form on your page, simply add the trigger text (followed by the instance number) to your page, just like you would any text:





Script by Dagon Design

For those of you who want to display the form directly from a template file, you can use the following code:

generate_data(); ?>

(where ‘1’ is the instance number)


Advanced Recipient Options

As mentioned above, if you want to send the messages to a single recipient, just enter the email address in the recipients field. To send to multiple recipients, separate the addresses with a | (pipe) character, and use one of the following prefixes for each: to= cc= bcc=

Examples:

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

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 to=

For those of you who want to let the vistor choose the recipient from a drop-down box, first you must enter selrecip in the recipients field. Then you must add a new line in the form structure box. Example:

type=selrecip|class=fmselect|label=Recipient|data=(select),User1,
user1@domain.com,User2,user2@domain.com

The type must be selrecip, 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 – just keep them in the proper order (name,email,name,email,etc..). Only the names are visible within the HTML for privacy reasons.

The ‘(select)’ item is the default selection, which the user must change to submit the form. You can change the ‘(select)’ text if you choose.


Advanced Form Structure


This plugin 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 verify 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 – be sure that the only newlines are after each field type when adding them to your form structure.)

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):

  • type – This tells the plugin what type of field you are adding.
  • class – The CSS class used to style the field. The classes used in the examples below already exist in the CSS file.
  • label – Text that is shown next to the field.
  • fieldname – The name of the form field (must be unique).
  • max – Maximum number of characters allowed.
  • req – (OPTIONAL) If you want to require a field, set this to true. If not, do not add it.
  • default – (OPTIONAL) This allows you to specify the default value of a field.

TEXT

This is a standard text input field.

type=text|class=|label=|fieldname=|max=|[req=true]|[ver=]|[default=]

The text field type has a special parameter – ver – which can be used to verify the input. You can choose email (which checks that the input is a proper email address) or url (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.

Examples:

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

DATE

This is a javascript pop-up date chooser.

type=date|class=|label=|fieldname=|[req=true]

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.

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.

Example:

type=date|class=fmdate|label=Event Date|fieldname=fm_date|req=true 

HTML

This field type lets you insert html, or other code, anywhere in your form.

type=html|text=

Example:

type=html|text=

Hello!


PASSWORD

This is a standard password field. It is exactly like a text field, except it shows asterisks when the user types.

type=password|class=|label=|fieldname=|max=|[req=true]|[confirm=true]

The password field type also has a special parameter – confirm – 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.

Examples:

type=password|class=fmtext|label=Password|fieldname=fm_pass|max=100|
req=true|confirm=true

type=password|class=fmtext|label=Secret Word|fieldname=fm_secret|max=100

TEXTAREA

This is a standard text area, for multiple lines of text.

type=textarea|class=|label=|fieldname=|max=|rows=|[req=true]|[default=]

The textarea field type has a special parameter – rows which defines the number of rows in the field (required for valid html).

Examples:

type=textarea|class=fmtextarea|label=Message|fieldname=fm_message|
max=1000|rows=6

type=textarea|class=fmtextarea|label=Message|fieldname=fm_message|max=1000|
rows=4|req=true

type=textarea|class=fmtextarea|label=Message|fieldname=fm_message|max=1000|
rows=10|req=true|default=Type here!

WIDETEXTAREA

This is exactly the same as the standard textarea, except that it’s wider, and the label is above it instead of to the side.

type=widetextarea|class=|label=|fieldname=|max=|rows=|[req=true]|[default=]

Example:

type=widetextarea|class=fmtextwide|label=Message|fieldname=fm_message|
max=1000|rows=10|req=true

* Note that the normal textarea, and wide textarea fields use a different CSS class for formatting.


VERIFY

This field is required if you are using the basic 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.

type=verify|class=|label=

Example:

type=verify|class=fmverify|label=Verify

FULLBLOCK and HALFBLOCK

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.

type=fullblock|class=|text=
type=halfblock|class=|text=

Examples:

type=fullblock|class=fmfullblock|text=This could be some sort of 
introduction message.

type=halfblock|class=fmhalfblock|text=This could be used to explain a field 
in greater depth.

OPENFIELDSET and CLOSEFIELDSET

These do just what the name implies – 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).

type=openfieldset|legend=
type=closefieldset

Examples:

type=openfieldset|legend=Your Information

(other field would go between these)

type=closefieldset

CHECKBOX

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.

type=checkbox|class=|label=|data=
(fieldname),(text),(checked),(REQUIRED),
(fieldname),(text),(CHECKED),(REQUIRED)...

As you can see, the checkbox data is a comma separated list of four items per checkbox:

  • fieldname – A unique fieldname for each checkbox in the form.
  • text – The text shown to the right of each checkbox.
  • checkedtrue or false. This allows you to make checkboxes checked by default.
  • requiredtrue or false. If true, it means that the user must check the box to send the message. Mainly useful for ‘check here to agree’ type situations.

*NOTE* 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.

Examples

type=checkbox|class=fmcheck|label=I Agree|data=fm_agree,I agree to the 
terms,false,true

type=checkbox|class=fmcheck|label=Interests|data=fm_i1,Computers,false,
false,fm_i2,Art,false,false,fm_i3,Music,false,false

RADIO

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.

type=radio|class=|label=|fieldname=|[req=true]|[default=]|data=(text),(text),
(text)...

The req and default items are optional. req, if set to true, makes the field required. default can be set to the option number you want to be selected by default (starting at 1).

*NOTE* 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.

Examples:

type=radio|class=fmradio|label=Gender|fieldname=fm_gender|data=Male,Female

type=radio|class=fmradio|label=Color|fieldname=fm_color|req=true|default=1|
data=Unspecified,Red,Green,Blue

SELECT

The select field generates either a standard drop-down box, or a multi-select box, depending on the multi option. Option groups are supported as well.

type=select|class=|label=|fieldname=|[multi=true]|[req=true]|data=(#group),
(text),(text),(#group),(text)...

The multi and req options are optional.

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.

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.

*NOTE* 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.

Examples:

type=select|class=fmselect|label=Age|fieldname=fm_age|req=true|
data=(select),0-30,31-60,61-90,91-120
 
type=select|class=fmselect|label=Colors|fieldname=fm_colors|
multi=true|req=true|data=Red,Green,Blue
 
type=select|class=fmselect|label=Choose|fieldname=fm_choose|
data=#Category1,item1,item2,#Category2,item3,item4

FILE

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.

type=file|class=|label=|fieldname=|[req=true]|[allowed=1,2,3]

The allowed 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.

Examples:

type=file|class=fmfile|label=Upload|fieldname=fm_upload

type=file|class=fmfile|label=Upload|fieldname=fm_upload|req=true|
allowed=jpg,jpeg,gif,png

Manual Form Code

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.

Important Notice: 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’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 – only for those who are very familiar with HTML forms and PHP.

  • 1) Customize your form using the ‘Form Structure’ option as you would normally – this is required even when using the manual code entry, as it allows for processing of the form.
  • 2) Be sure you have all your options exactly as you want them, and view your newly created form page.
  • 3) View the source of the page, so you can copy the generated html. The code you need is between the following lines:
    
    
  • 4) 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.
  • 5) Enter your new code into the ‘Manual Form Code’ field in the options and save.
  • 6) 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.

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.

To disable the manual form code feature, just clear out the option for it.


Auto Reply Feature


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.

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.

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.


Saving Data to a File

This option allows you to save the form input in a delimited file. Please see above for a full explanation of the options.

With the WordPress version of this script, the path to the data file is relative to the root directory of your WordPress installation. Be sure to give this file write access.


Other modifications

Redirect after form submission – Method 1

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:

$o .= $sent_message;

And replace it with this:

$o .= '';

(where mysite.com is the URL you want to redirect to)

Redirect after form submission – Method 2

This is another method you can use to redirect the user after the form has been submitted. First, find this line:

$o .= $sent_message;

And after it, add this:

$o .= '<META HTTP-EQUIV="REFRESH" CONTENT="4;URL=http://www.yoursite.com">';

Where ‘4’ is the number of seconds to wait before refresh, and the ‘http://www.yoursite.com’ is the URL you want to redirect to.

Passing values to the form

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)

Modifying the script to use HII for image verification

Miro has posted instructions for users wanting to use HII: Read the comment. Notice: Modifications listed in the comments may not apply for new versions of the script.

Using SELRECIP and BCC together

The easiest way to do this, is to find the following line in the script:

$send_status = mail($send_to, $email_subject, $msg, $headers);

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:

$send_status = mail("user2@domain.com", $email_subject, $msg, $headers);


Troubleshooting

Fields not working properly/Form is not displaying properly

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. One form field statement per line.

Verification image not showing up

The first thing to do is check to make sure your paths are set correctly in the options.

This plugin 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 ‘Force image type’ option under the DDFM-Main options page. It allows you to manually specify jpeg, gif, or png.

Try all the options to see which works best for you.

Problems sending email

The most common question I receive is ‘Why am I not receiving email from the script?’

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.

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.

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):

<?php mail('you@domain.com', 'test subject', 'test message'); ?>

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.

If you do 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:

$send_status = mail($send_to, $email_subject, $msg, $headers);

With this:

$send_status = mail($send_to, $email_subject, $msg);

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.

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:

$send_status = mail($send_to, $email_subject, $msg, $headers, '-f user@domain.com');

‘Headers already sent’ error

Another common question is the ‘headers already sent’ 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.

For WordPress users, it is also always a good idea to disable your other plugins temporarily to make sure that nothing is conflicting.

Mail headers showing up in message body / attachments not working

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:

if (!defined('PHP_EOL')) define ('PHP_EOL', strtoupper(substr(PHP_OS,0,3) == 'WIN') ? "\r\n" : "\n");

To this:

if (!defined('PHP_EOL')) define ('PHP_EOL', strtoupper(substr(PHP_OS,0,3) == 'WIN') ? "\n" : "\n");

If you require special SMTP settings for mail to be sent

If you have to manually specify the SMTP settings, you can do so with the following code. This is only recommended for advanced users.

ini_set("SMTP","mail.MYDOMAIN.com");
ini_set("smtp_port","587");
ini_set("username","MYUSERNAME@MYDOMAIN.com");
ini_set("password","MYPASSWORD"); 
ini_set('sendmail_from', $sender_email);
$send_status = mail($send_to, $email_subject, $msg, $headers);
ini_restore('sendmail_from');

(Just search for the reference to the mail() function to see where to add it)

Conclusion

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 contact me. Thanks for reading!

]]>
/articles/secure-form-mailer-plugin-for-wordpress/feed/ 2469
Draft Notification Plugin for WordPress /articles/draft-notification-plugin-for-wordpress/ /articles/draft-notification-plugin-for-wordpress/#comments Thu, 02 Jul 2009 01:34:56 +0000 /articles/draft-notification-plugin-for-wordpress/ This WordPress plugin automatically emails the admin when a new draft is saved. The email contains the post’s title, the author, and a link. There is no options page currently, because there is really nothing to configure. The plugin now supports the new ‘pending’ status.

Download

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

Instructions

  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory.
  • Enable the plugin.

Change Log

  • 07-01-09 Version 1.22 – You can now choose to send the emails to all users on or above a certain level (eg: editors).
  • 04-27-08 Version 1.21 – Updated to work with WordPress 2.5 and the ‘pending’ status.
  • 05-16-07 Version 1.2 – Updated to work with WordPress 2.2.
  • 10-20-06 Version 1.1 – The emails now contain the author’s name, instead of ID.
  • 04-22-06 Version 1.0 – First release.

Notes

Because of the way this plugin works, it also sends out an email when an existing draft has been saved again – This includes auto-saves. A solution to this is being researched.

By default, the author’s display_name is shown in the email. If you would prefer to see the login_name, or nice_name field, just look for the line in the script that says “Choose one of the following options to show the author’s name” and uncomment the option you would like to use.

Changing the user level for notifications

In the script, look for this line:

$email_user_level = 7;

This tells the script to send notification emails to anyone on, or above, that user level. Just change this for your particular needs.

]]>
/articles/draft-notification-plugin-for-wordpress/feed/ 253
Add Signature Plugin for WordPress /articles/add-signature-plugin-for-wordpress/ /articles/add-signature-plugin-for-wordpress/#comments Thu, 02 Jul 2009 01:04:31 +0000 /articles/add-signature-plugin-for-wordpress/ This plugin lets you display a custom signature at the bottom of your posts. Simply type the text you want in the options page and configure it to display on every post, or manually display it by adding the trigger text wherever you like. You can also add in author information using the included variables – login name, first name, last name, nickname, email address, website, and description/bio. It get this information from the author’s account settings. It currently supports up to three different signature templates.

Download

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

Instructions

  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory.
  • Enable the plugin.
  • Configure the plugin options (under DDAddSig).
  • Test it out by viewing a post.

Change Log

  • 07-01-09 Version 1.32 – Fixed bug when using more than 3 sigs. Sigs are now wrapped in a div with the class ddsig_wrap.
  • 02-17-09 Version 1.31 – Added five extra signature fields (7 total now), updated display of options.
  • 09-22-07 Version 1.3 – Added two extra signature fields. Added ‘Load Default Options’ button. Added option to display signature on search pages.
  • 11-27-06 Version 1.2 – Added option to show the signature on date/category archive pages.
  • 07-26-06 Version 1.1 – You can now choose to show the signature on the index, posts, and/or pages.
  • 07-23-06 Version 1.0 – First release.

Signatures

You can use HTML and CSS in your signatures. The following variables can also be used to display author information (they are case-sensitive):

  • %LOGIN% – Login name
  • %FIRST% – First name
  • %LAST% – Last name
  • %NICK% – Nickname
  • %EMAIL% – Email address
  • %URL% – Website
  • %DESC% – Description/Bio

Standard Usage

To show the signature on a post or page, simply type in the proper trigger text.

Primary signature:
<!-- ddsig -->

Signature 2:
<!-- ddsig2 -->

Signature 3:
<!-- ddsig3 -->

Etc..

Note: Be sure you enter the trigger text using the ‘Code View’ in WordPress – not the new visual text editor.

Automatic Usage

If you prefer, you can have the plugin automatically display the signature on the pages you specify with the options below. Note: These options only apply to the primary signature.

Display on index page
When enabled, this option will show the signature after each post on your index page.

Display on posts
When enabled, this option will show the signature on each single post page.

Display on static pages
When enabled, this option will show the signature on each static page.

Display on archive pages
When enabled, this option will show the signature on each archive page. This includes both date and category archives.

Display on search pages
When enabled, this option will show the signature on each search results page.

Other Uses

What if you want to show an image of the author at the bottom of the posts? Standard WordPress profiles do not include an option for an author image, but it is easy to do with this plugin.

Just add something like this to your signature field:

<img src="/authors/%NICK%.jpg" />

Then all you have to do is create an ‘authors’ directory on your server, containing an image for each author (with their nickname for the filename).

Modifications

Disable automatic line breaks in signatures
Find this code in the script:
$ddsig_data = get_option('ddsig_data');After it, add the following:
$ddsig_data = str_replace(array("\n","\r"), array("", ""), $ddsig_data);That will strip out the newline/return characters from the signature. To do the same to the other signature fields, just duplicate that line with the other variable names (ddsig_data2, etc..)

]]>
/articles/add-signature-plugin-for-wordpress/feed/ 489
Secure Guestbook Script with Image Verification /articles/secure-guestbook-script-with-image-verification/ /articles/secure-guestbook-script-with-image-verification/#comments Thu, 02 Jul 2009 00:11:08 +0000 /articles/secure-guestbook-script-with-image-verification/ 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.

Download

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

Included Languages

The script current includes files for the following languages: English, Dutch, Formal German, French, Italian, Norwegian, Portuguese, Romanian, Spanish, Swedish, Turkish

See it in action

I have a demo guestbook here: Demo guestbook

Installation

  • Download ddgb.zip and uncompress
  • Upload all files into a directory of your choosing
  • Give write-access to /dat/.entries and /dat/.banlist (chmod 666 or 777)
  • Configure the options in config.php
  • Run the script by calling ddgb.php

Changelog

  • 07-01-09 – 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.
  • 02-22-09 v2.45 – 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.
  • 07-27-07 Vv2.44 – PHP short-tag bug fixed. Italian language file added.
  • 06-20-07 v2.43 – File locking feature is now an option (disabled by default), instead of automatically enabled
  • 06-13-07 v2.42 – Security update
  • 04-04-07 – Spanish language file has been added
  • 03-24-07 – Romanian language file has been added
  • 01-14-07 v2.41 – Fixed bug related to display of entries
  • 11-01-06 v2.4 – Moderation/display issues 100% resolved – Smilies are now clickable – Various bug fixes
  • 10-22-06 v2.31 – Further improvements to the session code – Should work better on Windows servers now
  • 10-21-06 v2.3 – Fixed bug with display of entries when moderating – Improved session code – Dutch language file has been added
  • 10-17-06 – Not a version update – Swedish and Portuguese language files have been added
  • 09-07-06 v2.2 – Bug fixed (verification problems in non-standalone mode)
  • 09-01-06 v2.1 – Various minor fixes – Added Norwegian language file
  • 08-24-06 v2.0 – 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:
    – Separate config and language files
    – Option to require manual approval/moderation of entries
    – Improved session handling (no more separate verification file!)
    – Option to run as stand-alone script, or through another page
    – Secure data file storage method already implemented
    – Now supports basic smilies
    – Can disable image verification if not supported
    – New option to protect email addresses
    – And more – read below
  • 05-17-06 – Not a version update, but I added instructions on making the guestbook even more secure.
  • 05-03-06 v1.31 – Fixed a bug when editing entries – Name, website, and email fields can now be modified on existing entries.
  • 03-16-06 v1.3 – Revised layout a tiny bit – Now checks for GD support and gives error if missing – Adds http:// prefix if not entered in web address – IP addresses of posters shown in admin box – Can now ban posters by IP (removes all of their posts too) – Added confirmation before deleting and banning
  • 02-16-06 v1.2 – Added option to allow or disallow html in posts – Fixed a magic quotes bug
  • 02-06-06 v1.1 – Added option to prevent search engine robots from following links posted by visitors (using the nofollow tag)
  • 02-02-06 v1.0 – First public release!

Some of the features

  • Flat-file storage with precautions in place to prevent data files from being viewed.
  • Various security measures to prevent abuse.
  • Separate config and language files.
  • Image verification support (can be disabled if your server does not support the GD library).
  • 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.
  • Implements ‘nofol’ tag to prevent search engine spiders from following links in entries (discourages some spammers).
  • HTML in posts disabled by default – you can enable this if you like, but it is a big risk.
  • Option to run as stand-alone script or included through another page.
  • Smilies are supported (either enter in the code, or click to add!)

Notes

If you want to include this script inside another page, be sure to set the proper ‘stand alone’ 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:

<?php session_start(); ?>

Then just include the script in your file like this:

<?php include 'ddgb.php'; ?>

Overview of the options

These options can be set in config.php file

Path to ddgb.php

This needs to be set to the full url of the ddgb.php file on your server. Example: http://www.yoursite.com/ddgb/ddgb.php

Path to ddgb-verify.php

This needs to be set to the full url of the ddgb-verify.php file on your server. Example: http://www.yoursite.com/ddgb/ddgb-verify.php

Locale Setting

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.

Administrator Password

This is the password used to perform the administrative functions – editing, deleting, banning, and moderating. Be sure to change the default password.

Administrator Email

Used for new entry notification, if the feature is enabled.

Send Notifications of New Entries

If enabled, admin will receive email for all new entries.

Run as Stand-Alone Script

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 ‘Notes’ section.

Title Tag

This is the title of the page when the script is used in stand-alone mode.

Path to Data File

This is the location of the data file used to store entries. Be sure to give it write-access (chmod 666 or 777).

Path to Ban File

This is the location of the data file used to store banned IPs. Be sure to give it write-access (chmod 666 or 777).

Requre Manually Entry Approval

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.

Enable Smiles

If enabled, this option will convert text-smilies into images. It will also show the available smilies on the ‘new entry’ page.

Show Introduction Text

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.

Disable Image Verification

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.

Image Verification Colors

This allows you to easily change the colors of the verification image. You can enter either 3 or 6 character hex color codes.

Path to CSS File

This is the location of the script’s CSS file, which controls the look of the guestbook.

Entries Per Page

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.

Allow HTML in Messages

This option is dangerous because it allows visitors to enter HTML, which is a big security risk. It is disabled by default.

Protect Email Addresses

With this option enabled, email addresses will be shown in the following format instead of as traditional links: someone [at] somewhere [dot] net.

Enable File Locking

File locking is not supported by all servers. If you would like to use this feature, set this to TRUE.

Email Notification of Posts

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):

echo '<p>' . _ADDED_THX . '</p>';

Right after it, add the following:

mail('user@domain.com', 'New Guestbook Entry', 'A New Guestbook Entry was added!');

Be sure to set your email address. The second parameter is the subject, and the third parameter is the message.

You can also use the following variables for your email’s subject or message: $fm_name $fm_website $fm_email $fm_location $fm_message. For example:

mail('user@domain.com', 'New Guestbook Entry', 'A New Guestbook Entry was added by' . $fm_name);

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:

$to = "user@domain.com";
$from = "user@domain.com";
$subject = "New Guestbook Entry";
$body = "A new guestbook entry has been added to your site.";
ini_set("SMTP","localhost");
ini_set("sendmail_from",$from);
$result = mail($to, $subject, $body, "From: $from");

Changing the timezone

If you would like to change the timezone setting for the script, edit config.php and find the following line:

// *** START OF OPTIONS ***

After it, add the following:

date_default_timezone_set('TIMEZONE');

Where TIMEZONE is a valid timezone identifier.

Troubleshooting

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:

$verify_path = "ddgb-verify.php";
]]>
/articles/secure-guestbook-script-with-image-verification/feed/ 1173
Scheduled Draft Publish Plugin for WordPress /articles/scheduled-draft-publish-plugin-for-wordpress/ /articles/scheduled-draft-publish-plugin-for-wordpress/#comments Sun, 07 Jun 2009 23:25:40 +0000 /?p=186 This plugin uses the built-in scheduling feature of WordPress to periodically take a draft post and publish it. You can define the time between occurrences, and choose to have it publish the oldest draft each time, or a random draft. By default, it publishes drafts in any category, but you can define one, or multiple, categories for it to take the drafts from. You can also choose to only publish a draft if it has been more than a set number of hours since the last post

Download

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

Instructions

  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory
  • Enable the plugin
  • Configure the plugin options (under DDSchedDraft)
  • Click the ‘Enable Draft Publish’ button to start

Disabling the Schedule

To stop the schedule, simply click the ‘Disable Draft Publish’ button on the options page.

Change Log

  • 07-07-09 Version 1.31 – Added option to only publish a draft if it has been a set number of hours since the last post was added.
  • 02-22-09 Version 1.3 – Updated to work better in recent WordPress versions. Log file support added, and several other updates. Can also shift posts when no drafts are available. (version number skip is intentional)
  • 08-28-08 Version 1.0 – First release.

Options

Here are the options available in this plugin’s options page in the WordPress admin panel.

Draft Publish Delay

This is the number of hours between the publishing of drafts. The schedule will start as soon as you click the ‘Enable Draft Publish’ button.

Only Publish after X Hours

If used, a draft will only be published automatically if it has been more than this many hours since the last post was added.

Category IDs

If left blank, the plugin will operate on all of your posts. If you enter a comma-separated list of category ID’s, it will only publish drafts in those categories.

Random

If enabled, the plugin will publish a random draft each time the schedule runs. If disabled, it will publish the oldest draft each time.

Shift Posts

If checked, the oldest published post will be re-published as a new post,
ONLY if there are no drafts left to publish.

Log File

Full path on your server where you would like the log saved. You can leave this specific to this blog, or set up a global log for multiple blogs. Leave blank to disable this feature. Be sure to give this file write-access

]]>
/articles/scheduled-draft-publish-plugin-for-wordpress/feed/ 156
Stock Quotes Plugin for WordPress /articles/stock-quotes-plugin-for-wordpress/ /articles/stock-quotes-plugin-for-wordpress/#comments Mon, 23 Mar 2009 01:01:52 +0000 /?p=371 This WordPress plugin allows you to easily display stock quotes on your website. The output of the plugin is designed to be minimal – the stock symbol, last price, and change amount are shown. You can configure the output in the options page for the plugin. The data is retrieved from Yahoo finance.

Download

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

Instructions

  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory
  • Enable the plugin
  • Configure the plugin options (under DDStockQuotes)

Demo

Error opening: http://finance.yahoo.com/d/quotes.csv?s=MSFT&f=sl1c1
Error opening: http://finance.yahoo.com/d/quotes.csv?s=GOOG&f=sl1c1

Change Log

  • 03-22-09 Version 1.0 – First release

Usage

There are two ways this plugin can be used:

In a post or page:
[stock SYMBOL]

From a template file:
<?php echo ddsq_get_quote('SYMBOL'); ?>

* where SYMBOL is the stock symbol you want to use

Important note regarding symbols

For most stocks, you can simply use the standard symbol, but for some cases (such as indexes) you will have to use the proper tags from Yahoo Finance. First, use this URL to search for your stock/index/etc..

http://finance.yahoo.com/

Then when the results are shown, look at the URL. For example, searching for the Dow Jones Industrial Average. From the ‘s’ parameter in the URL, and the symbol shown next to the name, you will see that it uses ^DJI. For the S&P 500, the tag is ^GSPC.

Options

Here are the options available in this plugin’s options page in the WordPress admin panel.

Output Format

This is the format of the plugin output. You can use any HTML you want, using the placeholders for the values: %NAME% %LAST% %CHANGE%

Example: <strong>%NAME%</strong> %LAST% [<strong>%CHANGE%</strong>]

Up Color

Color to use for price change when up (leave blank to disable)

Down Color

Color to use for price change when down (leave blank to disable)

Non-WordPress usage of the code

If you would like to use this script in your own PHP code, outside of WordPress, it is easy to do. All you need is the ddsq_get_quote function from the plugin, replacing the three lines at the start of the function (which pull the option settings from WordPress), with the actual option strings. Example:

$quote_format = '%NAME% %LAST% [%CHANGE%]';
$up_color = '00BB00';
$down_color = 'FF0000';
]]>
/articles/stock-quotes-plugin-for-wordpress/feed/ 137
User Bio Popup plugin for WordPress /articles/user-bio-popup-plugin-for-wordpress/ /articles/user-bio-popup-plugin-for-wordpress/#comments Mon, 23 Feb 2009 01:49:30 +0000 /articles/user-bio-popup-plugin-for-wordpress/ This WordPress plugin searches posts and pages for the nicknames of authors. When it finds one, it turns it into a link which brings up a popup window with the author’s bio and image. It uses the contents of the ‘About Yourself’ field in the user’s profile for the actual bio, and the image used depends on which of the two methods you select. The options page for this plugin allows you to configure the popup’s heading, width, height, and more. It also is fully customizable with the built-in CSS in the popup template file.

Download

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

Instructions

  • Download dd-user-bio-popup.zip and uncompress
  • Upload dd-user-bio-popup.php to your plugin directory
  • Upload ddub-template.php to your theme directory
  • Enable the plugin
  • Configure the plugin options (under DDUserBioPopup). More information on that is below

Upgrading

Be sure to download both files when you upgrade, and check the options and the information on this page to make sure something has not been changed.

Change Log

  • 09-29-07 Version 2.4 – ‘Load Default Options’ button added. Tested with WP 2.3
  • 05-16-07 Version 2.3 – Updated for WordPress 2.2.
  • 04-06-06 Version 2.2 – Now in the options, you enter the FULL URL to the images directory. It should help make things a bit more standard. Everything validates now as well.
  • 04-05-06 Version 2.1 – Image detection code improved, gravatar code improved, and a few other little things.
  • 04-04-06 Version 2.0 – Popup code completely redone. Now popup window has it’s own template file. Images are now supported (Uploaded and Gravatars), as well as many other fixes and updates.
  • 04-02-06 Version 1.0 – First release.

Using images

The image used depends on your settings. This plugin allows you to create a directory, and upload images to it. You must simply specify the full URL to this directory in the options.

If you like, you could use a directory that your other author’s have access to, so they can upload their images themselves.

For image file names, simply use the author’s nickname – lower case, with spaces removed. The plugin will search for matching files that are either jpg, gif, or png.

Example

Let’s say your wordpress installation is at http://www.somesite.com/wp/ and you create a subdirectory called authors for the images. In your options page you would enter http://www.somesite.com/wp/authors/ for the directory.

Let’s also say that you have a user called Some User. You would want to call the image someuser.jpg (or gif or png). That’s it!

Now if the plugin cannot find a matching image, and Gravatars are enabled, it will try to find one by using the author’s email address (in their profile).

This plugin uses its own code for Gravatars, so you do not have to install anything else. If you are already using a Gravatar plugin, that is fine. They will not conflict.

Configuring

The CSS code for the popup window is contained in the template file (ddub-template.php). Feel free to change this to fit your site.

Options

Here are the settings available in this plugin’s options page in the WordPress admin panel.

Author images directory

This is the full url to your author image directory. This is where you can choose to store images for each author.

Use Gravatars?

If enabled, and an author image cannot be found in the specified directory, the author’s gravatar will be used. If you want to always use gravatars, just leave the ‘author images directory’ option blank.

Heading for the popup

This will be shown at the top of the popup window. If you want to include the user’s name, use %U.

Hover text for link

This will be shown when the visitor’s mouse is hovered over the link. If you want to include the user’s name, use %U.

Popup window width

Self-explanatory.

Popup window height

Self-explanatory.

CSS for popup window

This allows you to completely customize the popup window. The #wrapper div is around the content.

Other Modifications

If you would like the popup window to have a scroll bar, just search for the following code in the main script file:

scrollbars=0

And change it to this:

scrollbars=1
]]>
/articles/user-bio-popup-plugin-for-wordpress/feed/ 195
This Day Plugin for WordPress /articles/wordpress-plugin-this-day/ /articles/wordpress-plugin-this-day/#comments Mon, 23 Feb 2009 01:48:54 +0000 /articles/wordpress-plugin-this-day/ After every post, this plugin will list other posts on the same day from other years. Options include adjusting the number of posts to show, changing the sort order, the header text, hiding password protected posts, and more.

Download

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

Instructions

  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory
  • Enable the plugin
  • Configure the plugin options (under DDThisDay)
  • Test it out by viewing a post. Of course for it to display anything, there must be at least one other post with the same month and day as the one you are looking at

Change Log

  • 09-22-07 Version 1.4 – Option added to hide password protected posts (they were hidden by default before). Non-published posts no longer show up in the list. Added ‘Load Default Options’ button.
  • 05-16-07 Version 1.3 – Updated for WordPress 2.2
  • 04-07-07 Version 1.2 – Updated for WordPress 2.1
  • 01-02-07 Version 1.1 – Modified to only list posts
  • 04-04-06 Version 1.0 – First release

Notes

This plugin will not display anything (not even the specified header text) if there are no matching posts. So if it does not seem to be working, make sure you are viewing at a post that has other posts on the same day.

Options

Here are the options available in this plugin’s options page in the WordPress admin panel.

Max posts to show

This allows you to set a limit on the number of posts that will be displayed. Set this to 0 for no limit.

Sorting

You can choose to list newest or oldest posts first.

Header text

This will be shown before the list of posts.

Show other posts from today

Enabling this will show other posts from the exact same date as the post being viewed (otherwise it will only check other years).

Show the year

If enabled, this will show the post year after each post in the list.

Hide password protected posts

If enabled, password protected posts will not show up in the list.

]]>
/articles/wordpress-plugin-this-day/feed/ 130
Show the Intro to Password Protected Posts in WordPress /articles/show-the-intro-to-password-protected-posts-in-wordpress/ /articles/show-the-intro-to-password-protected-posts-in-wordpress/#comments Mon, 23 Feb 2009 01:11:06 +0000 /articles/show-the-intro-to-password-protected-posts-in-wordpress/ This is a small hack for WordPress that allows you to show the first part of password protected posts. It will display the content you have before the ‘more’ tag, followed by the standard password box. I wrote this up for a member of the WordPress forum, and I thought I would share it here. Update: Instructions are now provided for WordPress 2.2

Before you begin

The instructions below have been verified in WordPress versions 2.0 through 2.8. The only difference between these versions is the file you have to edit.

Instructions

For WordPress 2.0 or 2.1, open /wp-includes/template-functions-post.php

For WordPress 2.2 through 2.8+, open /wp-includes/post-template.php

Find the following text:

$output = get_the_password_form();
return $output;

Replace it with this:

$content = $pages[$page-1];
$content = explode('', $content, 2);
$output = "";
$output .= $content[0];
$output .= get_the_password_form();
return $output;

This next step is optional, but I think it makes it nicer.

In the get_the_password_form function, find the following text (may vary between versions):

This post is password protected.

And replace it with this:

The rest of this post is password protected.

Or whatever text you would like it to show.

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

]]>
/articles/show-the-intro-to-password-protected-posts-in-wordpress/feed/ 181
Change Default Thumbnail Size in WordPress /articles/change-default-thumbnail-size-in-wordpress/ /articles/change-default-thumbnail-size-in-wordpress/#comments Mon, 23 Feb 2009 01:08:56 +0000 /articles/change-default-thumbnail-size-in-wordpress/ WordPress 2.5 and later include a built-in option to change the size of thumbnails, but for those of you out there using an older version, it is quiet easy to change. It just requires modification of one WordPress file. When WordPress 2.1 was released, it changed the way this was done, and once again with the release of WordPress 2.3, so I have included instructions below for multiple versions.

Instructions for:

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


WordPress 2.0

Open /wp-admin/inline-uploading.php and look for the following code:

if ( $imagedata['width'] > 128 && 
$imagedata['width'] >= $imagedata['height'] * 4 / 3 )
			$thumb = wp_create_thumbnail($file, 128);
		elseif ( $imagedata['height'] > 96 )
			$thumb = wp_create_thumbnail($file, 96);

The default max size is 128 x 96. You can change these numbers to whatever you like, although you must keep the proper aspect ratio (4 / 3).

For example, to double the size of the thumbnails, replace 128 with 256, and 96 with 192. Be sure to change both sets of numbers – they are each listed in the code twice.


WordPress 2.1 – 2.2

Open /wp-admin/admin-functions.php and look for the following code:

$max_side = apply_filters( 'wp_thumbnail_max_side_length', 
128, $attachment_id, $file );

The number specified here (128 by default) is the maximum size of either dimension. Just change this to whatever you like.


WordPress 2.3

Open /wp-admin/includes/image.php and look for the following code:

$max_side = apply_filters( 'wp_thumbnail_max_side_length', 
128, $attachment_id, $file );

The number specified here (128 by default) is the maximum size of either dimension. Just change this to whatever you like.

WordPress 2.5 and later

Version 2.5 and later have built-in support for the thumbnail size in the options.

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

]]>
/articles/change-default-thumbnail-size-in-wordpress/feed/ 182
Retrieve Data Plugin for WordPress /articles/retrieve-data-plugin-for-wordpress/ /articles/retrieve-data-plugin-for-wordpress/#comments Sun, 22 Feb 2009 22:45:51 +0000 /?p=302 This plugin provides a simple way to include the contents of data files into your posts or pages. The data files can be local to your server, or on remote servers (if your PHP configuration allows it). In the options page for the plugin, just define the trigger text and the file the data will be retrieved from. When that trigger text appears in a post or page, the contents of the specified data file will be shown.

Download

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

Installation

  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory
  • Enable the plugin
  • Configure the plugin under the DDRetrieveData options page

Requirements

This plugin uses the file_get_contents function in PHP. While this function supports the reading of files on remote servers, the allow_url_fopen option must be enabled in PHP. Additionally, firewall software on the server may block remote access.

Change Log

  • 12-27-08 Version 1.0 – First release.

Usage Notes

From the plugin’s options page (DDRetrieveData), simply enter the trigger text and the path to the data file for each set of data you would like to use. If you need more fields, just click ‘Update Options’ to save your changes, and more fields will appear. There is no limit to how many fields you can have.

If using a local file, the path is relative to the WordPress installation directory. Examples:

file.txt
path/to/data/file.txt

If using a remote file, be sure to include the full path. Examples:

http://example.com/file.txt
ftp://example.com/file.txt
ftp://user:pass@example.com/file.txt

The default options show an example of each type. Just clear them out to use your own.

The trigger text can be anything you like. The default options show the trigger text being wrapped inside html comment tags. This is optional, but it prevents the trigger text from being shown if the plugin is disabled (as it will just be treated as a comment).

Note: Make sure you add this to your posts/pages using the html/code editor in WordPress, not the visual editor. In new versions of WordPress, just click the ‘html’ button above the edit box. If you use the visual editor it will not work, as the actual code you entered will be seen on the page, instead of being processed by the script.

Data Output

Currently the output of the data is rather simple. It can be seen in this function:

function ddrd_fetch_data($url) {
	return htmlspecialchars(file_get_contents($url));
}

As you can see, the htmlspecialchars function is used to force the data to show up exactly like it does in the file. If you would rather have html processed, remove that function. If you want to modify the way that the script retrives data (to use CURL for example), this is the function you need to change. The function is given the $url parameter, and returns the contents of the file.

Possible Future Updates

Currently there is no local caching of remote files. This may be added in the future. Other options may be added as well.

]]>
/articles/retrieve-data-plugin-for-wordpress/feed/ 100