Use a heavy glove and a hacksaw blade to cut the bad plastic flange into quarters. Try not to cut into the pipe.
Chip the quarters out with a hammer and chisel. Cut the pipe off level with the floor. Sand and clean up the pipe, and glue a new flange into it.
The flange should sit flush on top of the finished floor level with only the thickness of the flange above floor level. Bolt the flange to the floor.
If the toilet does not sit level (put a level across the bowl), shim it level under the base with beveled plastic shims made for the purpose.