Modified the directory creation function due to inconsistencies in PHP versions