PHP implementation

All files converted to .php
All repeatedly used lines of code put into individual includes
Can't test if this works yet without the server, but this should be
about what it will look like.