If it's flowing over the sides of the portafilter you may just need to replace the grouphead gasket; it provides the seal between the machine and the filter basket, and as they get old and hard they stop sealing as well. If your grouphead gasket is still soft, and not damaged in any way, then the problem may lie in the grouphead ramps; they force the portafitler up against the gasket, and without them turning the handle won't actually create a seal.