Change downloadLayout script to PHP