Protection against CSRF attacks on the PZH Web Server

This pull request (documented in the commits) adds support to protect the PZH
against a number of online threats.

Most significantly, the PZH was vulnerable to CSRF attacks.  Now it should be a bit better.

This involved an enormous amount of fiddling and refactoring.  There is also a complimentary PR on the webinos-pzh project - https://github.com/webinos/webinos-pzh/pull/5 - that must be committed at the same time as this one.

http://jira.webinos.org/browse/WP-731
Jira issue: WP-731