The problem should be in the first one because the control panel hacking shouldn't cause troubles into the topics and the public topic page is just a matter of adding an extra line.
As soon as I add the modified ubb_lib_posting and clear cache, most of my topics stop working. And then I am required to upload a clean ubb lib posting from the UBB zip to get everything to work again.
I know it is a quite weird problem but I am pretty sure that you are right about the infinite loop because when you click in any topic, it just stays like if it were loading and after a long time, it returns a server error.
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.