Magnetic connection from the Earth to the solar corona, flare positions, and solar energetic particle observations