Block All Bots But Only Allow Mediapartners-Google (Adsense Bot)

I recently wanted to block all bots visiting http://example.com/view/1.php, http://example.com/view/2.php but only allow Google Adsense bot.

I recently wanted to block all bots visiting http://example.com/view/1.php, http://example.com/view/2.php but only allow Google Adsense bot. You need to edit robots.txt (a text file prevent cooperating web spiders and other web robots from accessing all or part of a website) as follows