two command block commands you will need are:
/gamemode 2 @a[m=0,r=20] (r=20 will set the area radius to 20 blocks)
/gamemode 0 @a[m=2,rm=20] (rm=20 will set the mode for anyone that is more than 20 blocks away.
Hook this up to an eternal redstone clock or set the appropriate settings on the command blocks if your version of Minecraft is 1.10 or higher.
Within the 20 block radius only ops will be able to edit or destroy things.