BTW, this (after you've applied the mod)
Code:
$postscount=$DB_site->query_first("SELECT replycount AS posts FROM thread WHERE threadid='$threadid'");
$postscount[posts]++;
$totalposts=$postscount[posts];
can be replaced, to save yet another query, with this:
Code:
$totalposts = $thread['replycount'] + 1;
since the thread info is already fetched earlier in the file.