Upper staining could have been due to oil cap not being secured but the lower staining will be the cam cover gasket thats gone hard and brittle with age, check to see if you have oil appearing down the spark plug wells as the centre gaskets will also be hard and brittle the same as the main outer gasket. Suggest you set about cleaning it all off before taking it apart to put new gaskets in. A good spreay of engine cleaner and agitate it with a paint brush followed by a good rinse down with a hosepipe should clean it up well. You could try a pressure washer on it if you have one to do the rinsing, if you do have the engine running when you use it and keep it away from the alternator so you don't get that soaked. When selecting the replacement gaskets go for a known brand and see if they come with the rubber seals that sit under the cover retaining bolts, they will need replacing as well if they are fitted to your engine. Not sure if your 15 retaining bolts are single use only so if they are you will need a set of new bolts as well. Probably best to check realoem site for part numbers and get a price from Sophers of Lincoln with forum discount for the bolts and their seals. Main and centre gasket sets usually cheaper from the likes of Carparts4less on the Web they sell Elring brand. Also worth checking Autodoc, they do a vast range of brands at various pricing but delivery can be slow as they come from Berlin. Just checked Realoem for a 2007 2.5si and can't see the round rubber seals for the retaining bolts listed so maybe not required on your engine if it is an (N52). Probably best to check Realoem using the last seven letters and figures of your Vin number to make sure you get the correct part numbers. If you think the filler cap gasket is suss then change that as well.
https://www.realoem.com/bmw/enUS/showparts?id=BU32-EUR-06-2007-E85-BMW-Z4_25si&diagId=11_3737.
Whilst you are in there whip the spark plugs out and check their condition. if in doubt how long they have been in and mileage they have done then put a new set in, best price usually from Carparts4less for these. Once you have buttoned up these leaks you may well enjoy the car much more.