Ponderomotive ion acceleration in underdense and overdense plasmas