flatPHPbook by Thomas Hettenhausen

Readme for version 0.9.5

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

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

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.html.

I will not explain FTP here, I guess you know how to work with this if you want to install this script. Of course, if you are really low on space: the license and this readme file are not necesary. But then, if you are that low on space, you should not run a guestbook...

You must make your guestbook.db file writable for the web server. With most webhosters that means setting writable 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, for me it is.

With some webhosters you might have to explicitly label 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 SmartFTP 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 - with SmartFTP you right-click on the file guestbook.php and select "Properties / CHMOD" 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 also a field with a 3-digit number. Experiment until it works, usually you have to set executable for either group (my own web hoster, easy-hosten.de) or other.

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

// global variables such as filenames and settings

and following that, some lines which configure some parts of the script. Some of these do not change anything visible (name of the guestbook database file), but others do change the behaviour (how many posts per page, sort order for posts, etc.). You really should change $adminusername and $adminpassword to something else. You can change everything else in there, it should be pretty much self explanatory with the variable names and the comments directly behind them.

If you leave $trackUserIP set to 1, the script will add the IP of the poster as determined by PHP to the script. If that is illegal for you or you do not want this, set it to 0. Then (for compatability reason) the IP address is logged as "0.0.0.0".

If you want to use the German language pack, just exchange the variable $language to "german.lang" instead of "english.lang" after you downloaded the file from the project page and put it into the guestbook directory. With other languages it will be the same, but as of now, only German is available

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

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, 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
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
  5. time
  6. IP address of the poster (you might later need it for legal reasons)
  7. the message itself

A typical line might look like this:

El Gringo::elgringo@provider.com::www.provider.com/elgringo/::2003-08-12::19:23:01::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 2003-08-12, 19:23:01
That is a nice guestbook you have! See my homepage here.

Should I ever include more fields to the script, it will be at the end of the line, and ignoring empty fields and displaying them as blank.

Appendix B: Localization

Since version 0.9.5 it is possible to use a localized version of the script. German and English is already included. If you want to do another language, check out the files english.lang and german.lang. Technically, these are INI-Files containing one section called "General", and then one line 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 change the translate the strings. Keep in mind that the strings has to be enclosed in quotes, and may not contain any special characters.

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 you could send it in and I will 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).