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 |
---|---|
|
The |
|
A header to add to the shoutbox |
|
A footer to add to the shoutbox |
|
The Lua magnet script to add a message |
|
The directory in which to store the messages |
|
A sample message named by 999999999—timestamp |
To get a feeling of what...