`// Locate bbcode.html file in styles tree`

There should probably be a check after the loop to make sure a bbcode.html file was eventually found, and if not, error. Otherwise, the file_get_contents() below will cause problems.