Hard diffraction and central diffraction in hadron-hadron and photon-hadron collisions