John,
A few comments from only reading the code.
* The implementation should never return an error message instead of a link. If I post a link and you find that I do not have access or you could not find the post, the code should fall through to behave as it would without this mod -- i.e., just leave the link alone.
* Are you replacing all instances of "forumid", "threadid", and "postid" with "f", "t", and "p"?
This would mangle a mod with those strings anywhere else in the URL, like "/my_mod_forumid.php?p=1234".
* Access to a thread/post should be CANVIEWOTHERS if one is not the author.
* You seem to be checking a URL for "p=" first and then overwriting the results if "t=" is found in the same URL. Perhaps you are missing an 'else'.
* You could think about using the post title (p=1234 case) when it is set (i.e., not the thread title).
* "showpost.php" case would be useful and is very similar to "showthread.php" case.
Also, this may give you some other ideas:
https://vborg.vbsupport.ru/showthread.php?t=68398
Cheers