Flash photoionization of gamma-ray burst environments