Issue stats

This pull requests refactors all the API module, making it more simple and easy to use and extend.

Additionally, it adds a new endpoint for globalstats: http://server/api/globalstats returns in JSON the global stats of the site.