php forum
php mysql forum
php mysql smarty
 
Topic Options
#316796 - 03/09/08 01:11 PM [7.2.2] Clearcache also resets NEW PM counters
blaaskaak Offline
Member

Registered: 02/25/07
Posts: 227
Loc: The Netherlands
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.


Edited by blaaskaak (03/10/08 08:07 AM)
Edit Reason: new version
_________________________

Top
#316797 - 03/10/08 08:09 AM Re: [7.2.2] Clearcache also resets NEW PM counters [Re: blaaskaak]
blaaskaak Offline
Member

Registered: 02/25/07
Posts: 227
Loc: The Netherlands
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.
_________________________

Top
#316798 - 03/13/08 11:11 PM Re: [7.2.2] Clearcache also resets NEW PM counters [Re: blaaskaak]
AllenAyres Administrator Offline
I type Like navaho

Registered: 03/10/00
Posts: 25241
Loc: Texas
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?
_________________________
- Allen wavey
- What Drives You?

Top
#316799 - 03/14/08 07:31 AM Re: [7.2.2] Clearcache also resets NEW PM counters [Re: AllenAyres]
blaaskaak Offline
Member

Registered: 02/25/07
Posts: 227
Loc: The Netherlands
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.
_________________________

Top
#316801 - 03/15/08 03:59 PM Re: [7.2.2] Clearcache also resets NEW PM counters [Re: blaaskaak]
AllenAyres Administrator Offline
I type Like navaho

Registered: 03/10/00
Posts: 25241
Loc: Texas
very helpful, thank you thumbsup
_________________________
- Allen wavey
- What Drives You?

Top


Moderator:  sirdude 
Who's Online
0 Registered (), 34 Guests and 49 Spiders online.
Key: Admin, Global Mod, Mod
Shout Box

Latest Posts
Custom island happy birthday
by Ian_W
46 minutes 59 seconds ago
[7.x] [Final] pJIRC Addon v0.4
by Gizmo
Yesterday at 06:57 PM
[7.2.1] - Naked shoutbox
by Jaymo
Yesterday at 06:48 PM
Multiple Identity Detector
by Thelockman
Yesterday at 08:13 AM
Faster! Faster!
by Gizmo
05/06/08 04:25 PM
Rounded corners on boxes 7.2.2
by arentzen
05/04/08 02:13 PM
Noticed on UBBcentral custom titles
by Dunny
05/03/08 05:28 PM
New Mods
Rounded corners on boxes 7.2.2
by arentzen
05/04/08 02:13 PM
Blended Sponsor Bar
by Gizmo
04/29/08 07:29 AM
Custom island that shows an rss feed
by blaaskaak
02/28/08 02:29 PM
Custom island happy birthday
by blaaskaak
09/07/07 05:34 PM
[7.2.1] - Naked shoutbox
by sirdude
08/17/07 10:36 PM
Newest Members
russell_bynum, Bettypeng, DougMM, cb163605, Jaymo
13281 Registered Users

 

 

 
fusionbb message board php hacks