ported server to php

also fixed a whole bunch of broken auth stuff