Refactor authentication code and drop support for old scheme

This drops support for the pre-challenge-response authentication scheme
(i.e. the scheme in use before Zarel/Pokemon-Showdown@7dbd8cfec5a on
February 8, 2013), and, by doing so, simplifies quite a bit of the
authentication code.

In particular, it is no longer necessary to make any database queries in
index.php, which reduces our database use significantly and also moves us
closer to the goal of the index page being static HTML.