UBB.Dev
Posted By: ehm Recounting number of posts and update users - 08/25/2004 10:14 PM
I try the search first, since I guess it would be a comom issue, but find notthing, so there it is:
I deleted posts from members time to time, and I would like to recound the number of post for all members on a UBB Trhead 6.3.
Is that possible? I was thinking in some kind of command line at the SQL windown under ADMIN who could do it.

What happens is I had a police that post like "me too", "thank you", "see you", and other similars should not count to the post numbers, so what I do is delete those (it's a pain, but worth).
Then I just finished deleting all those 'No practical content' posts and now I would like to reclassify all my users.
This is why I would like to have a SQL query to change the post counts on all members.

Thank you for any input.
Elton
Posted By: isaac Re: Recounting number of posts and update users - 08/26/2004 9:10 AM
[6.2-6.3-6.4] Check Post Count Utility
https://www.ubbdev.com/forum/showflat.php?Cat=0&Board=modifications&Number=106511
Posted By: Anno Re: Recounting number of posts and update users - 08/26/2004 11:43 AM
This is for the total number of posts for each forum though. What he wants is the total number of posts for each user.

This wouldn't be too hard to write though.
Posted By: isaac Re: Recounting number of posts and update users - 08/26/2004 9:53 PM
what happens when you purge older posts? then a user post count would drop also ???

so basically would would be Changing UBB's "POST COUNT HISTORY" to "CURRENTLY ACTIVE POSTS"
Posted By: Anno Re: Recounting number of posts and update users - 08/26/2004 10:19 PM
Yes, currently exisiting posts in the database.
Posted By: JoshPet Re: Recounting number of posts and update users - 08/30/2004 10:16 AM
I had to do this quite a while back - used a simple little script like this:

Code
<br /><?<br />// Written by Joshua Pettit<br />// ©2003 - JoshuaPettit.com<br />// www.joshuapettit.com<br />// Used on conceivingconcepts.com<br /><br /><br />// Require the Library<br />	require ("main.inc.php");<br />	<br />echo "Begining the Script to fix the post counts.<br /><br />";<br />$count = 0;<br /><br />$query = "<br />	SELECT U_Username<br />	FROM {$config['tbprefix']}Users<br />	";<br />   $sth = $dbh -> do_query($query);<br /><br />while (list($Username) = $dbh -> fetch_array($sth)) {<br />	$Username_q = addslashes($Username);<br />	$query = "<br />		SELECT COUNT(*)<br />		FROM {$config['tbprefix']}Posts<br />		WHERE B_Username = '$Username_q'<br />	";	<br />   $sti = $dbh -> do_query($query);<br />   $postcount = $dbh -> fetch_array($sti);<br /><br /><br /><br />	$query = "<br />		UPDATE {$config['tbprefix']}Users<br />		SET U_Totalposts = '$postcount[0]'<br />		WHERE U_Username = '$Username_q'<br />	";	<br />   $stj = $dbh -> do_query($query);<br /><br /><br />	echo "$Username updated with $postcount[0] posts.<br />";<br /><br />	$count++;<br />}<br /><br />echo "Done! Updated $count Users!<br />";<br /><br />?>		


Drop that in the threads directory - run it, it'll fix all the post counts. Be sure to remove it when you're done - it's high load to recalculate all the post counts.
Posted By: JoshPet Re: Recounting number of posts and update users - 08/30/2004 10:19 AM
Whoops strike that that was an old wwwthreads board - before the advent of U_Number - this will be more efficient on modern boards.

Code
<br /><?<br />// Written by Joshua Pettit<br />// ©2003 - JoshuaPettit.com<br />// www.joshuapettit.com<br /><br /><br />// Require the Library<br />	require ("main.inc.php");<br />	<br />echo "Begining the Script to fix the post counts.<br /><br />";<br />$count = 0;<br /><br />$query = "<br />	SELECT U_Number,U_Username,U_Totalposts<br />	FROM {$config['tbprefix']}Users<br />	";<br />   $sth = $dbh -> do_query($query);<br /><br />while (list($Usernumber,$Username,$oldcount) = $dbh -> fetch_array($sth)) {<br />	$Usernumber_q = addslashes($Usernumber);<br />	$query = "<br />		SELECT COUNT(*)<br />		FROM {$config['tbprefix']}Posts<br />		WHERE B_PosterId = '$Usernumber_q'<br />	";	<br />   $sti = $dbh -> do_query($query);<br />   $postcount = $dbh -> fetch_array($sti);<br /><br /><br /><br />	$query = "<br />		UPDATE {$config['tbprefix']}Users<br />		SET U_Totalposts = '$postcount[0]'<br />		WHERE U_Number = '$Usernumber_q'<br />	";	<br />   $stj = $dbh -> do_query($query);<br /><br /><br />	echo "$Username had $oldcount updated to $postcount[0] posts.<br />";<br /><br />	$count++;<br />}<br /><br />echo "Done! Updated $count Users!<br />";<br /><br />?>		
Posted By: isaac Re: Recounting number of posts and update users - 12/08/2004 2:00 AM
thanks for the script - worked like a Charm!

I had been looking through the modifications forum for this script for a few days now - I only just now found this in the "how do I" forum. Any possibility of creating this into a file and moving it to the completed mods forum as a USE AT YOUR OWN RISK (as usual) script?

Again - thank you very much for providing exactly what what needed to help many other people (and myself) again
Hey Josh, would that code work for Infopop Threads 6.03?

Where do I do it in my control panel, the update.config settings or MySQL?

Let's say I have a person named Romy constantly screaming at me about his post count wasnt trasnferred.

Username: Romy
Current Postcount: 174 posts
Postcount should be: 17,850 posts.

How would your code look with those settings?

Any help would be appreciated because I got a few posters I need to fix..

1st post in these forums but it won't be the last.
© UBB.Developers