Converted to Object-Oriented PHP, fixed syntax errors.