Periodic orbits on Riemannian manifolds under the action of an at most quadratic potential