How can I fix this toilet flange?
Your pictures are showing that it will be necessary to remove the existing drain lines up to the place where there is free pipe to cut into thus allow gluing in a new coupling. It will unlikely for there to be a decent way to fix this by any other means. Any type of cobbled together "fix" is always going to be a potential weak spot in the system ripe for failure.

It is possible to buy special reamers that can be used to remove pipe inside of a coupling joint so that a new pipe or fitting can be glued into there. However I am not sure such tools are available for your size of drain line. These tools also require good "straight in" access to be able to be used. It might be an option for you to investigate but will likely be more expensive than just replacing some of the existing drain lines. 

For you the expression "think before you cut" should have new meaning. 

Edit -- I did a bit of looking and did find that there are reamers available that will work for 3" size plastic pipe. Here are some pictures of what they look like:

  

With one of these and a suitably sized right angle drive electric drill you may be able to fix your problem by reaming the nearest accessible coupling. Use does require that you be able to securely clamp the fitting being drilled into place. Also make sure that you would have a really good hold on the drill while reaming.

Rather than trying to point you to a specific web site I would suggest that you do the Google search for "PVC Pipe Reamer".