Replace system command wget and chmod with PHP builtin function