UBB.Dev
If you happen to have a spammer, and you need to clean up the mess, this script adds functionality to the clearcache script that will cleanup the NEW PM counters. If will reset them to the actual new count.

open /admin/doclearcache.php

find
Code
build_forum_cache();

add below:
Code
// Update all new PM counters

// set them all to zero.

$query = "
update {$config['TABLE_PREFIX']}USER_PROFILE
set USER_TOTAL_PM = 0
";
$sth = $dbh->do_query($query,__LINE__,__FILE__);

// cycle through all user ID's that have New PM's.

$query = "
SELECT count(*) AS count, t1.USER_ID
FROM {$config['TABLE_PREFIX']}PRIVATE_MESSAGE_USERS AS t1,
{$config['TABLE_PREFIX']}PRIVATE_MESSAGE_TOPICS AS t2
WHERE t1.TOPIC_ID = t2.TOPIC_ID
AND t2.TOPIC_LAST_REPLY_TIME > t1.MESSAGE_LAST_READ
GROUP BY t1.USER_ID
";

$sti = $dbh->do_query($query,__LINE__,__FILE__);
while (list($total_unread,$PM_UserId) = $dbh -> fetch_array($sti)) {
$query = "
update {$config['TABLE_PREFIX']}USER_PROFILE
set USER_TOTAL_PM = ?
where USER_ID = ?
";
$dbh->do_placeholder_query($query,array($total_unread,$PM_UserId),__LINE__,__FILE__);
}

I have no idea about executing times if you have an enormous userbase. But works fine on our >5600 users / >37000 private topics.
If anyone picked this up yesterday, I just replaced it with a version that's a lot more efficient and runs with a lot less queries.
Nice, this re-counts pm's? It looks like it resets all pm's to 0, then counts new pm's. Our counts of total pm's get back?
Yep, that is exactly what it does.

Basicly you only need to run this if you start altering PM database tables yourself for spammer cleanup or whatever.
very helpful, thank you thumbsup
© UBB.Developers