Book Image

Lighttpd

By : Andre Bogus
Book Image

Lighttpd

By: Andre Bogus

Overview of this book

Table of Contents (20 chapters)
Lighttpd
Credits
About the Author
About the Reviewer
Preface
HTTP Status Codes

Example: A Shoutbox


In the following example, we will exercise both the Lua Magnet and mod_magnet to create a shoutbox, a list of messages into which users can enter plain text. Only the ten newest messages are shown.

The basic idea is that reading is done more often than shouting, is probably a fast operation and can be cached, so we will use mod_magnet to assemble the shoutbox. Shouting, on the other hand, involves validating a message against Cross-site scripting attacks, writing it to a file, and possibly removing old messages. This will be done using the Lua magnet.

The basic layout will be as follows:

Page name

Description

/index.lua

The mod_magnet script to assemble the shoutbox

/.header.html.inc

A header to add to the shoutbox

/.footer.html.inc

A footer to add to the shoutbox

/shout.lua

The Lua magnet script to add a message

/messages/

The directory in which to store the messages

/messages/8783608325

A sample message named by 999999999—timestamp

To get a feeling of what...