Intergalactic Photon Spectra from the Far-IR to the UV Lyman Limit for 0 < z < 6 and the Optical Depth of the Universe to High-Energy Gamma Rays