Sample: wwwnews

Let’s suppose we have a WWW page with „news“, i.e. the index page contains list of references to individual pages with messages in the same directory. The directory content is managed by email. Write a script implementing this work. The script reads mails coming to a special address, checks sender address (the "From:" header value) against a list of valid senders written in the FROM shell variable (space separated list of addresses) and according to the mails, it modifies content of the directory.

The index.html page has following format:

<HTML>
... lines not containing <OL>
<OL>
<LI><A HREF=3D"message-file-name">page title</A> (dd. mm. yyyy)
...
</OL>
... rest of the page

The mail must contain:

a) Subject: DEL date [n]
then the n-th item from given day (including the message page itself) is removed from the list in the index file; if the number is omitted, all news from given day are removed.
b) Subject: page title
then the mail body contains new message page, it should be saved under a unique name and added to the index; the page title must be also checked for uniqueness

Operation result (log) is sent to the original sender. Every incoming mail data (date, time, sender, subject) is logged to the access.log file. The files must be locked during modifying as a prevention against a parallel processing of two incoming mails.