php: Convert UID from 64bit to 32bit form
python: Refactor UID conversion into a function

Make it reusable in brickv.