Rusted and corroded is typical of a cast iron flange that has been in place for a few years and is not in any way a problem. Cracked may or may not be a problem, depending upon where the crack is located and the extent of the crack. If the crack is on the outer ring of the flange in the vicinity of the bolt slots this too is typical of aging flanges, in fact, in many instances we find portions of the outer ring completely missing, however this flange can still be rendered servicable with the addition of a repair flange. If the crack is in the throat or waterway were it creates a leak, then it becomes necessary to replace the flange.
In a worst case scenario replacing the flange involves accessing the soil pipe and cutting out the existing closet bend and flange, then replacing it with a new cast iron or PVC closet bend and flange which can be connected to the existing cast iron pipe by means of a Mission Band or a Fernco Coupling.
When positioning a closet flange the underside of the flange is to be flush with the finished floor, which leaves the top surface about 1/4" to 3/8" above the finished floor. The code prohibits the top surface of the flange from being flush with or recessed below the finished floor.
The illustration below shows how to install a repair flange.
If you will hit the link below you will see an illustration I prepared for the proper positioning of a closet flange.
http://www.homerepairforum.com/image...g_089_w550.jpg