The first set of new online safety rules legally requiring social media and other sites to take action against illegal content have been published by Ofcom.