Welcome to Dagon Design. In addition to free scripts, WordPress plugins, and articles, we offer a variety of services including custom theme design, plugin creation, and PHP scripting. Contact me for more information.

Version 2.45   Updated Wednesday, July 1st, 2009 at 7:19pm

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";

Pages: « 4426 25 24 23 22 [21] 20 19 18 17 161 » Show All

  1. 315
    Beno

    Hi,

    I really like this guestbook and I have looked at many. It’s good to know that the guestbook is still being worked on and improved.

    I have configured the script properly but the image varification isn’t working, I’m not sure why. I see the box but the text is missing. My test server is setup properly and GD is installed and enabled.

    Any ideas what might be causing this propblem?

    I also have a suggestion that in my opinion would make the guestbook perfect. It would be nice if the Admin could post comments / reply to entries.

    Regards,
    Beno

    P.S. If its of any help phpinfo() returns the following:
    GD Support – enabled
    GD Version – bundled (2.0.28 compatible)
    FreeType Support – enabled
    FreeType Linkage – with freetype
    FreeType Version – 2.1.9
    T1Lib Support – enabled
    GIF Read Support – enabled
    GIF Create Support – enabled
    JPG Support – enabled
    PNG Support – enabled
    WBMP Support – enabled
    XBM Support – enabled

  2. Chrisathome: If you would like to use the contact form to email me a link, it may help. It will be confidential of course.

    One thing though – I recommend trying with and without the www prefix to see if the code shows up.

  3. Admin

    just to add to my last post, have checked the host server versions and it is running apache 1.3.33 with php 4.4.1 on a linux server with the same gd version.

    Christopher

  4. Admin

    The hosting company’s server is behaving ok with the guestbook(I’m still testing so there is a redirection on it) and I can’t give a link to my local server as it isn’t visible outside my network. I can email you the link to the hosted site if you think that would help.

    The code is identical on both, the “live” web server shows the verify text the local one doesn’t. I can disable verification locally just so I can develop the css & html to integrate it in to my site but it’s inconvenient, and I’d like to know why (as this is all new to me…)

    Christopher

  5. Dave: If your entries are showing up properly already, you do not really have to worry about it. If you do want to change it, just look for a section of code near where the entries are displayed. The code block starts and ends with a double forward slash. They were supposed to be start and end comment tags ;) Which is why the bug happened. That code was supposed to be commented out.

    Chrisathome: Can I see a link?

  6. sorry about this…

    My knowledge of apache/php config is very limited (less than1 day!) so I would appreciate guidance as to why this might be occurring. I have been through php.ini & httpd.conf but cannot see what to do.

    The GD library – a bundled (2.0.28 compatible) version is active and a var dump of gd_info() shows true for gif jpg & png

    Now I’m lost!

    Christopher

  7. Rest of my post, this got lost!…

    My knowledge of apache/php config is very limited (

  8. Hi I have a question re the verify code.

    I am testing the very nice guestbook v2.40 on my host server and locally on my xp pro pc using apache2.2 & php5.2.0

    The host server displays everything correctly and works fine.

    My local server does not show the text in the verify box although everything else seems ok. Annoying, as I want to integrate the gb into my site design and it’s easier to work locally.

    My knowledge of apache/php config is very limited (

  9. -> Admin
    Sometimes i’m surprised that there are still people who don’t give them selfs the time to explore the script. Sure there are people who really doesn’t have php knowledge. For example, the ‘website’ link in the entry. Just add target=”_blank” into the url ine in the script and your ready to go.
    That is no hard deal. Well, i guess it’s probably not my day. ;)

    By the way, do you know what the update was in the latest version? I customized my ddgb file that the new version probably mess up my guestbook(s). Otherwise i leave it this way and stick to the old version.

  10. Bill: Most FTP clients use the ‘ls’ command to get a list of files on the remote server. Often times they will let you add extra parameters, such as ‘-a’ to show the hidden files. As far as your scroll bar stuff, if I remember correctly, custom scroll bars are not supported by all browsers – you might try checking in another.

    Joe: Glad to hear :)

  11. Thank you for your help admin,
    it turned out that due to the include function the filepath to the “entries” file was messed up. It now works fine, thx again.

  12. 304
    Bill

    Hello, an other question.
    Tried to add, in ddgb.css:
    BODY {
    scrollbar-face-color:#FFFFFF;
    scrollbar-highlight-color:#000000;
    scrollbar-3dlight-color:#FFFFFF;
    scrollbar-darkshadow-color:#FFFFFF;
    scrollbar-shadow-color:#000000;
    scrollbar-arrow-color:#FF0000;
    scrollbar-track-color:#FFFFFF;
    background-repeat: no-repeat;
    background-image: url(../pics/assen-achter-3-20p.jpg);
    }
    Doesn’t work.
    Have entered it in header.php
    Background is shown, but not fixed, fixed it with:

    But cant get the scrollbar, it still shows the standard windows scrollbar.

    Thanks.

  13. 303
    Bill

    1. Hello, didn’t see the option !!
    Changed it and works perfect.
    2. In options I did set Show hidden/system files but it is not shown, will ask Total Commander
    3. Maybe in config.php ?
    Thanks for you quick reply.

  14. Bill: I am not sure what you are asking with #1, but there is an option in the config that sets whether or not email addresses are displayed like that. As for #2 that is normal, because on most servers, files starting with a period are hidden. Most FTP clients allow you to set them to show hidden files. For #3, I may add an option in to allow that soon.

  15. 301
    Bill

    Hello, have 3 questions.
    First script is now working regarding first message, as I also had that problem testing it last week.
    Like your script so far.

    1. in the message, the email link is printed with [at] and [dot] in the address, whith spaces, so
    2. when I copy the dat files with a dot in front of it, so .banlist .entires and .htaccess, Total commander doesn’t show the files, the directory then is blank.
    So I couldn’t change it to 666
    Solved it to copy it without the dot, then change it to 666 and then change the name with a dot in front.
    Immediately the files dissapeared.
    Cant find anywhere to see the files.
    Or is this the way it should be?

    3. the website link has no target, can that be added somwhere, like target=_blank ?

    Thanks,

    Bill.

Pages: « 4426 25 24 23 22 [21] 20 19 18 17 161 » Show All

Leave a Comment

Before you comment: If you are having an issue with a script, please make sure you have read the entire article. Also, please read through the comments because most common issues have already been discussed many times. Thanks.


Be sure to wrap all code in <code></code> tags.