Create lib.php

Some basic library routines