Be aware there are no mods in phpBB 3.1 or 3.2 they both use extensions and isn’t recommended to modify core code. Have a search real quick in the extensions forums I know there is at least one advertisisement extension. In fact if you search “Adsense” you will get a hit.
"The more connected we get the more alone we become" - Kyle Broflovski
There are no ‘threads’ in phpBB, they are topics.