You can download version 1.1 here:
fortune11.zip.
You use it by including the file fortune.php in your own script. Make an instance of the object
Fortune.
$f = new Fortune;
After this call either
$f->quoteFromDir($dir)
with the location of a directory containing fortune-files or
$f->getRandomQuote($file)
with the location of a specific .dat-file.
Both of these functions return a string, which it's up to you
to print and format in HTML.
A complete working example is:
<?php
require("fortune.php");
$f = new Fortune;
echo $f->quoteFromDir("dat/");
?>
Where "dat/" is the directory in which the fortune-files are kept.
Making new fortune-files
To make your own fortune-files for use with this script, use the function
$f->createIndexFile($file, [$verbose])
This takes the name of a text-file with quotes as an input. The second argument determines whether the
function will print a bit of information about the analysis of the file. The argument is a boolean. Use
true to see detailed information after the creation of the file.
The input file must be a text-file with all the quotes, seperated by % on a line by itself. Take a short
look at a standard fortune-file to see the format.
This function was added because I realized that it's not certain that people have access to the
original strfile-utility for making the fortune-files. createIndexFile will probably not be part of any standard-page
you'll make with the script. Make sure that the user running the webserver will have write-access to the directory in
which the script executes.
This script was written by Henrik Aasted Sorensen, haas@itu.dk.
Feel free to mail comments and/or suggestions. I would also like to hear from you if
you actually start using this script on your page. :)