updated to use new php stream wrappers