Database connection refactoring

 - Introduce template for database error
 - Hide E_WARNING & E_NOTICE from <production>
Topic creation refactoring

 - add caching for title and post-text when insert fails
 - introduce simple custom document.cookies interface for smart work with
   application's cookies