On the interaction between ultra-high energy cosmic rays and photons in the universe