flatPHPbook by Thomas Hettenhausen

Readme for version 1.01


Features

This guestbook stores all of its data in a flat text file, so no database is needed. This makes it easy to use for people who want their own guestbook and have webspace with PHP support, but no access to a MySQL database, which often costs more and is not needed for smaller web projects. That does not mean that you have to live with less comfort - this script offers some features known from other guestbook and bulletin board / forum scripts, among them


Requirements

This guestbook script does not need much; it basically comes down to this:

I created this script on 3 machines (my home machine, my office machine, my notebook) with Windows XP on all of them, Apache 1.3.26 through 1.3.29 as web server, and different PHP 4 versions. I also tested it on my own webspace for hettenhausen.net (don't ask me which operating system of web server they use), on my Linux box running Debian (sid), and on SourceForge.net for the demo. You probably saw it running before you downloaded it. I guess that means it it is very likely it will run on your webspace out-of-the-box, but for sure with a little tweaking. Contact me if you need help or post in the official flatPHPbook forums at the SourceForge project page.


Installation / Upgrade

The flatPHPbook archive contains the following files (in alphabetical order):

  1. Changelog.txt → a text file listing the changes between the versions
  2. email.png → the little email icon
  3. english.lang → the default english language pack
  4. guestbook.css → the style sheet for the guestbook
  5. guestbook.db → an empty file which will later hold the guestbook data
  6. guestbook.ini → the configuration file for the guestbook script
  7. guestbook.js → the JavaScript functions used with the BBcode buttons
  8. guestbook.php → the guestbook script itself
  9. homepage.png → the little homepage icon
  10. LICENSE → the GNU GPL, the license under which this script is released
  11. README.html → this file
  12. welcomeMessage.inc.html → file containing the text displayed above the input fields

Just copy all these files into the same directory on your web space.

After that, you must make your guestbook.db and guestbook.ini files writable for the web server process (guestbook.ini only needs to be writable if you plan to use the web interface for configuration, if you edit the file manually, it is not necessary). With most webhosters that means setting the writable flag for other (since the web server process which will be writing to it is neither run by your account nor by anyone of your group). This would correspond to the number 666, making the file readable and writable for all. You can also try if writable for group is enough (664), for me it is.

With some webhosters you might have to explicitly flag the script as executable. You will see this is necessary if you know for sure that PHP is enabled for you but you only get to see the code instead of a nice looking guestbook.

To do either, load your favorite FTP program (I use FileZilla on Windows and gFTP on Linux, but every ftp program should be fine), and open the directory where you put these files. Now this is where it is probably different with each FTP program, but usually you right-click on the file guestbook.php and select "Properties / CHMOD" or something similar from the context menu. At the bottom of the new window, you can set so-called flags (read, write, execute) for either user, group and other, and sometimes also a field with a 3-digit number. Experiment until it works, usually you have to set executable for either group or other.

If you are upgrading beware:
Do not overwrite your old guestbook.db file or all your posts will be deleted and gone forever (unless your server contains some undelete feature and you have access to it).
You might also want to make sure to check if you made any update to the guestbook.php file (the "welcome message") and/or the stylesheet (guestbook.css) instead of creating your own/using a modified copy. From version 0.93 on, welcome messages now go into a separate file called welcomeMessage.inc.html.

If you are upgrading form a version prior to 1.0 beware:
With version 1.0, I changed the database format. To use your old guestbook.db file, you have to convert it first, else it will display wrong fields (IP address instead of time, weird date, no message itself). On the flatphpbook homepage at SourceForge is a link to a PHP script for both online use and download which takes care of this. To be on the safe side, you should always make a backup of this file first or upload a copy of this file (or save the converted file with a new name).


Configuration

The file guestbook.php is the PHP script itself, but you can of course open it with any text editor you have at hand and take a look at it.

Pretty much at the top, you can see a line reading

$INIfileName = "guestbook.ini";

This points to the configuration file called guestbook.ini. In there I defined the variables that control the behaviour of the scipt. You may of course edit that file with a text editor and change these settings, but if you log in as admin you will be presented with a link to edit the configuration via a web interface. The options you will be able to edit are the following:

General
version this is the flatPHPbook script release version number
gbName the guestbook name, this is displayed as the title and headline of the page
delimiter the special character used to tokenize the parts of a post in the database file - no need to edit this
useCookies if set to "1", the script will use cookies to log the admin in instead of PHP sessions (set to "0" for this) which do not work on all web hosters
CharSetyou can set the character encoding for the HTML code of the guestbook. Just leave at the default of "ISO-8859-1" if you use regular western (English, German, French, ...) letters. I you experience problems e.g. with the Russian file (cyrillic alphabet), set to "windows-1251". The official list can be found at the IANA homepage.
disableMSSmartTagsif set to "1", prevents Microsoft products like MS Office and the Internet Explorer from creating so called "Smart Tags" (hyperlinks) out of company names mentioned on the page. These get created only for comapnies Microsoft has on their list for this feature. Current versions of Internet Explorer do not use this technique yet, but this might change. Set to "0" to allow Smart Tags.
Files
guestbookFile filename of the guestbook database file where the posts are stored
stylesheetFile filename of the CSS stylesheet
javascriptFile file containing the JavaScript functions that make the buttons work
emailIcon the icon/image representing the email address
homepageIcon the icon/image representing the homepage
languageFile the language file from which the output texts are read
welcomeMessagefile containing the text displayed above the input fields
customHeaderfile containing any kind of HTML code that is placed right after the opening body tag
customFooterfile containing any kind of HTML code that is placed right before the closing body tag
Behaviour
displayNewestFirst sorting order for display of entries, "1" for newest first, "0" for oldest first (in both cases, the oldest is labelled 1)
refreshWaitingTime time to wait in seconds before a refresh on the Thanks-for-posting page
showTotalNumber toggles display of total number of posts above the list of entries ("0" or "1")
entriesPerPage set to "0" for all entries on a single page, or else to how many you want on one page
separateViewFromSign if set to "1", the form for signing is displayed on another page and not together with the old entries
trackUserIP set to "0" if you do not want to (or it is illegal in your country) log user IP addresses, will log "0.0.0.0" then, else it logs the posters IP address to the database file
timeNotation determines the format in which the post date and time is displayed:
"ISO" → "YYYY-MM-DD, H:mm:ss"
"american" → "MM-DD-YYYY, h:mm:ss am/pm"
"german" → "DD.MM.YYYY, H:mm:ss"
tableLayoutdetermines what table layout to use for the guestbook display: "classic" uses the 4-cells layout (2 rows, 2 columns per post) that is the default since release of the first version, "simple" uses only 2 cells.
customFieldsthe number of custom fields (additional to the standard nickname, email, homepage and comment
customFieldNamesa comma separated list of the names for the custom fields (so it reads something like "City,Country" without the quotation marks)
moderatedPostsif set to 1 instead of 0, posts do not automatically appear in the guestbook, but have to be approved by the site administrator first
Email
sendEmailset to "1" if you want to be notified via email every time a new post is made to your guestbook
fromAddressthe email address the notification is sent from (some mail servers do not accept mails without a valid From: address)
toAddressthe email address the notification is sent to (like the From: address you should probably use your address for this)
SMTPthe SMTP server for sending messages - check with your ISP for this (or open your email programm like Outlook or Mozilla Mail and search for an entry called "SMTP Server" or something like this)
overrideLocalhostonly useful on Unix/Linux web servers - set to 1 if you do not want to use the email service on your web server (usually has some MTA like sendmail, exim or postfix installed), but your regular email account instead. Has no effect on Windows machines, as you need to use your regular account there anyways.
BBcode
displayButtonsif set to "1", the buttons for BBcode are displayed; if set to "0" they are not displayed.Does not disable the interpretation of BBcode in messages posted earlier. If enabled, only those buttons explicitly set to "1" below are being displayed
displayWebButtonssets whether the "www" and the "@" buttons for hyperlinks and mailto-links are displayed
displayFormatButtonssets whether the buttons for bold, italic and underlined are displayed
displayColorButtonsets whether the color selector dropdown field is displayed
displaySizeButtonsets whether the size selector dropdown field is displayed
displayImageButtonsets whether the button for linking to an image on the web is displayed
displayCodeButtonsets whether the button for entering preformatted (verbatim) text is displayed

Just edit these values to your liking, but be warned: I do not have any checks in there to catch problems if you set e.g. the number of posts per page to below zero - this is not something someone from outside is going to hack, and I think you will be wise enough to fill in valid numbers. After all, you want this to work...

Just above the line mentioned above in the file guestbook.php, you will find the two lines setting the admin username and password,

$adminusername = "admin"; // the administrator username who can delete posts - YOU REALLY SHOULD CHANGE THIS
$adminpassword = "adminpw" ; // the corresponding passwort - YOU REALLY SHOULD CHANGE THIS

and, as noted in the code as well, you really should change $adminusername and $adminpassword to something else.

The file guestbook.css is a CSS file for the guestbook. If you know how to write HTML and used CSS yourself, go ahead and play with it. This is just regular CSS, no magic involved. Make the guestbook fit your own webpage with this. If you do not know what CSS is, either be daring and play around, or go learn something about it first. There are some pretty good online tutorials for CSS and HTML.

The file guestbook.js contains the JavaScript functions for the buttons: the ones insert the BBcode into the message and those that make the help appear when hovering over the buttons. The same caveat as with the CSS applies: if you don't know this, you might break something while playing around with it.


Misc

This guestbook is brought to you by Thomas Hettenhausen and released under the GPL. I wrote this little script because I intended to move my web presence from a HTML-only host to one allowing PHP, but not MySQL (a matter of money), and I did not find any suitable PHP-based guestbook. Right now I do have MySQL (found a cheaper host), but hey - that does not mean I cannot finish a project I start! On the other hand, free guestbook services might have been ok, too, but they usually display advertisements, are often slow in response time (after all, they are free, and their companies do not want to spent lots of money for their free services), and they often are not exactly easy to modify in their appearance, so they never quite fit your web page design.

And since I am a student of computer science (at the University of Bielefeld, Germany), I might as well just write my own if I need it.

The editor I used writing this script is SciTE, an editor around the Scintilla cross-platform editing component. It's Open Source software, available for Win32 and GTK+ and really feature-rich (while not as hard to learn as Emacs...). Give it a try!

If you like this guestbook, drop me a line and tell me! I would love to hear from installations, and I can also put up links to some of the sites that use it.

Thomas Hettenhausen, July/August 2003 (plus later additions/corrections)
http://www.hettenhausen.net
flatPHPbook @ SourceForge


Appendix A: Interna

Here I will document e.g. the structure of the database file (guestbook.db) for all those who want to edit it manually.

Each line in this file represents a post, new ones being appended at the end of the file. The line consists of the entries in the post, separated by the delimiter stored in the variable $delimiter. The order of the fields is:

  1. nickname
  2. email address
  3. homepage
  4. date and time in Unix timestamp format
  5. IP address of the poster (you might later need it for legal reasons)
  6. the message itself

followed by some possible custom fields, each with the delimiter before it.

A typical line might look like this:

El Gringo::elgringo@provider.com::www.provider.com/elgringo/::1076874034::129.70.102.13::That is a nice guestbook you have! See my homepage [url=www.myhomepage.com]here[/url].

This would show up in the guestbook as follows:

El Gringo 20:40:34, 2004-02-15
  That is a nice guestbook you have! See my homepage here.

Appendix B: Localization

Since version 0.9.5 it is possible to use a localized version of the script. English is already included, and Spanish, French and German can be downloaded from SourceForge. If you want to do another language, check out the file english.lang. Technically, this is an INI-file containing just one section (ATM) called "General", and then some lines with a variable name and then the appropriate string with which this variable is to be substituted in this language.

Just copy the file, name it to your language (e.g. french.lang), and then translate the strings. Keep in mind that the strings has to be enclosed in quotes, and may not contain "too" special characters (just try it out...). Also pay attention to where the string is used: the "New post! and " just added a new post to your guestbook!" strings are used in emails and therefore should not contain HTML entities, e.g. like "ä" for ä" - use the real character or like in this case "ae" as workaround.

For your own use it is of course sufficient to only translate those phrases that regular users will see, but if you did a complete translation please send it in and I can make it available for download for everybody! For credit, just include your name as a comment in the language file (that means on a line starting with a semicolon).