Moved php functions to a seperate file

Anything that should be in more than one file should go here.