PDA

View Full Version : Add current post counter to each post!


Tommy Boy
12-07-2001, 10:00 PM
This hack adds a static counter to each post, in addition to the dynamic (total user posts) counter, which is currently used. It will show "Posts: 55/73" under the poster name, which indicated that this is the 55th post by this user, who has posted until now 73 posts in total.

This hack does NOT add any load to your board (except for deleting threads/posts, but this is optional). It is easy to install, just download the attached text file, and read the instructions.

What's new in version 1.1?
- Old posts counters are updated correctly (requested by bira)
- Correctly dealing with forums where posts should not count
- Fixed displayed counters for guests and imported posts

What's new in version 1.2?
- Static post counter is updated when deleting posts/threads (requested by bira)

What's new in version 1.3?
- Added support for single users update (useful in several situations)

What's new in version 2.0? (major release)
- Installer and updater integrated in the Admin control panel
- Option to update total users' post counts at the same time

What's new in version 2.1?
- Fixed bug in v2.0 installation (upgrade was still smooth)


Links:
- DOWNLOAD the hack (https://vborg.vbsupport.ru/attachment.php?postid=205841&v21)
- Live Demo (http://www.utopiatemple.com/forum/showthread.php?threadid=4938)
- Admin control panel screenshot (https://vborg.vbsupport.ru/attachment.php?postid=207591&fullpage=1)

Good luck! :D

exodus
12-08-2001, 10:44 PM
is this the accumlative post number? or like they have here on vB.org where every post in a specific thread gets numbered? post #1, post #2, etc...

?

bira
12-08-2001, 11:17 PM
this is a very nice idea.

If I understand correctly, this is the number of post per USER, not per thread.

Meaning, when you read this post now, this is my 115th post out of 115 total posts I made on this Bulletin Board.

But the next time I post (here or in a different thread), this will show it to be my 115th post out of a total of 116th, etc.

So it will allow users to easily see at what point in your posting history this post was made. Was it your very first post? Was it your very last? etc.

I'll try this hack - the idea is nice.

pipi
12-09-2001, 02:23 AM
Any demo? thanks for your hard work :D

bira
12-09-2001, 02:50 AM
Ok, I am trying this hack on my development server which has NO traffic at all, and I can already tell you of one big pitfall in this hack:

The update-post-counters.php runs an UPDATE post SET ... query on ALL YOUR POSTS. With over half a million posts in my database, and for other websites with a lot of posts, this process will take A LONG TIME, and will eventually exceed the execution timeout limit in php.ini (if not crash your MySQL!)

You MUST change your hack installer to run at X number of posts at a time (like the "update counters" does). You cannot just release this installer without making this modification, because it will not be fully installed, and most posts will show 0/xxx.

I myself can't even get the hack installed yet because I have so many posts in the db. So I don't even know what it looks like or how it works :(

bira
12-09-2001, 03:43 AM
After editing your update-post-counters.php to use limit and startat points, I've managed to install this hack.

Here is why the hack is at the moment worthless for existing bulletin boards:

Pitfall 1:

Users will now show in all of their existing posts totalposts/totalposts.

Eg, if I had 3000 posts so far, all my posts up to now will show 3000/3000 -- not very informative.

Pitfall 2:

If I delete a post, or an admin deletes a post, the currentpost will be bigger than the total posts.

Eg, if to use the same example as above, all my posts up to now will show:

3000/2999

....

Sorry, but only a new Bulletin Board owner should use this hack. It's worthless for boards that have been operating as long as I have :(

If you want to make it valuable, you need to change it to:

ORDER BY dateline ASC

and add $postcount = 1 before the loop, and $postcount++ after the loop. That will at least solve pitfall #1. It won't solve pitfal #2. Nothing normal will.

Either way, a word of warning: installing this hack takes, on moderate to big boards, close to one hour. And it takes a LOT or resources.

Tommy Boy
12-09-2001, 05:54 AM
Hehe, it's amazing, I was just thinking about these things when I went to sleep last night! If you want to wait, I'll provide a fix when I come back from work.

This hack IS possible, and has a lot of potential. Please give me a chance to prove it.

Tommy Boy
12-09-2001, 09:48 AM
Ok, I couldn't wait, so I released the fix already (first post updated) :p

Bira, please try it on your huge database, it should work fine, but let me know if it doesn't, for any reason... It takes less than 5 seconds to run on my database, and I have over 60k posts.

So anyway, this fixes your pitfall #1. Now let's talk about your pitfall #2. First of all, many people will not consider it a problem, but a "feature", since even though some of this user's posts were deleted, this still remains his Xth post, and there is no reason to modify this. This is a "logical" issue, if you will. In any case, I have decided to make it part of the hack after all.

Anything else I can do for you, sir? :D

bira
12-09-2001, 10:08 AM
Tommy I'm a girl! :D

I want to send you something by e-mail. I can't attach files to an e-mail via the BB, so can you please e-mail me at goren@atlasf1.com your addy, so I can send it to you?

I think you'll like it :)

bira
12-09-2001, 10:13 AM
Tommy did you upload a new zip file? The one I just downloaded has exactly the same php file :confused:

Tommy Boy
12-09-2001, 10:14 AM
Oops, sorry about that, m'lady! :eek:

Email sent. ;)

Tommy Boy
12-09-2001, 10:20 AM
[QUOTE]Originally posted by bira
Tommy did you upload a new zip file? The one I just downloaded has exactly the same php file :confused:

bira
12-09-2001, 10:29 AM
Tommy this is so weird. When I click on the link to the zip file, even though it's named ***v12, it downloads static-post-counter.zip -- the old zip.

I cleared my cache and it still does that :(

Can you e-mail it to me please?

Tommy Boy
12-09-2001, 10:36 AM
Sure, there you go girl! :D

Tommy Boy
12-09-2001, 08:05 PM
I removed the attachment from the first post by mistake, and now I can't add it back :(

So download the hack from here please. Thank you!

Gamingforce
12-10-2001, 06:02 AM
Hi, I installed this hack on my board and even when I have updated the counters, all old posts show 0/number. Only new posts have number/number.

Is this supposed to happen?

squawell
12-10-2001, 06:30 AM
i have same problem~~~

my all old posts show 0/number,but when i reply or post new

thread than show number/number ??

Tommy Boy
12-10-2001, 10:16 AM
Bah... I'm terribly sorry for this... This is what happens when you work on a hack late at night...

In uptate-post-counters.php, change:$update_these_users_only = "4"; // Use to update specific users only, separate with commas (example: "1, 540, 23500", default: "")Into:$update_these_users_only = ""; // Use to update specific users only, separate with commas (example: "1, 540, 23500", default: "")I have updated the attached file. Again, terribly sorry for that! :(

TheComputerGuy
12-14-2001, 08:57 PM
Tommy Boy...man this is a sweet hack, I saw it when you first had it out and saw the download and I downloaded and now just come to find there was an update...This is sweet...I like this hack and I will say when the New Web+++++Forums.com comes out I am proud to say I have your hack installed to create it into what I feel makes it to be....

I am going to use it as this

33/650th kill

On the Postbit I have now...sweet

FWC
12-16-2001, 04:52 PM
Tommy, I installed this last night. I had to make some changes because $post[postcount] was already used by Bira's hack for post count in a thread. It's working great. I do have one user who's static count is 2 higher than his total. I haven't figured that one out yet. :)

Tommy Boy
12-16-2001, 05:42 PM
You should update the users' post counts in the admin control panel.

FWC
12-16-2001, 05:48 PM
[QUOTE]Originally posted by Tommy Boy
You should update the users' post counts in the admin control panel.

Tommy Boy
12-16-2001, 06:06 PM
My pleasure! :D

Tommy Boy
12-17-2001, 09:46 PM
Screenshot of version 2.0's integration in the Admin control panel...

FWC
12-17-2001, 10:18 PM
The download link in the first message is no good. It's a link to the first message again. :)

Tommy Boy
12-17-2001, 10:26 PM
Actually, it links to post #15 in this thread, but sometimes browsers don't like to "jump" to an internal anchor for some reason... So just go there yourself, and download it. :p

To upgrade from an early version, just apply the changes to the admin/misc.php file.

Let me know how you like it, considering you're 33% of my users of this hack! ;)

FWC
12-17-2001, 10:33 PM
[QUOTE]Originally posted by Tommy Boy
Let me know how you like it, considering you're 33% of my users of this hack! ;)

FWC
12-18-2001, 01:19 AM
Tommy, I installed the upgrade on both my public and test boards. I just tried it out on the test board. Very nice! Good job. :D

Sadie Frost
12-18-2001, 12:19 PM
Okay, yet another really stupid question from me - was there supposed to be an update-post-counters.php file in the download? Cause I can't find it in my files anywhere and I only received a text file in the download.

I'm asking cause when I was installing and went to update my post counters, I got this database error:

Database error in vBulletin Control Panel 2.2.1:

Invalid SQL: SELECT postcount FROM post LIMIT 1
mysql error: Unknown column 'postcount' in 'field list'

mysql error number: 1054

If I try to go into update counters again, I get a parse error in my misc.php file at line 433 which is part of the following:

$deletethreads=$DB_site->query("SELECT threadid FROM thread WHERE title='".addslashes($thread[title])."' AND forumid=$thread[forumid] AND postusername='".addslashes($thread[postusername])."' AND dateline=$thread[dateline] AND threadid>$thread[threadid]");

Can anyone help? Thanks :)

pipi
12-18-2001, 03:02 PM
got same error...do we need update-post-counters.php file ?? where to download it??

FWC
12-18-2001, 04:38 PM
[QUOTE]Originally posted by Sadie Frost
I'm asking cause when I was installing and went to update my post counters, I got this database error:

Database error in vBulletin Control Panel 2.2.1:

Invalid SQL: SELECT postcount FROM post LIMIT 1
mysql error: Unknown column 'postcount' in 'field list'

Tommy Boy
12-18-2001, 05:13 PM
I'm sorry for that. It's my fault, since I took a code from another hack, without testing it first... Anyway, the attachment was updated (v2.1), and if you already installed v2.0, just make this small modification:

Open admin/misc.php, and look for:
// Add post counter column to post table, if needed
$DB_site->query ("SELECT postcount FROM post LIMIT 1");
if ($DB_site->errno)
$DB_site->query ("ALTER TABLE post ADD postcount int unsigned not null AFTER userid");Change it to: // Add post counter column to post table, if needed
$col_exists = $DB_site->query_first ("SHOW columns FROM post LIKE 'postcount'");
if (!$col_exists)
$DB_site->query ("ALTER TABLE post ADD postcount int unsigned not null AFTER userid");As for your question, update-post-counters.php is no longer needed, as long as the above change is applied.

Sadie Frost
12-18-2001, 06:05 PM
Thanks for helping me with that :)

No to be a pain but I'm still getting a parse error when I try to go to update counters - think that's an unrelated problem?

Tommy Boy
12-18-2001, 06:10 PM
I think so too. Send me your misc.php file, and I'll tell you what's wrong with it. I sent you an email, so you will know mine.

Sadie Frost
12-18-2001, 11:08 PM
It's working great now! :) I always thought posts should say the order in which they were posted - it's terrific. Thanks! :)

kidney
03-17-2002, 10:57 PM
Ok, got a question,

Why does my total post counter increase, but not the other.
Here is what I mean, I get 1/16 or 1/17.
When ever I post the last two digit increase, but I alway get 1/?? anywhere No mather which post I look I get 1/##, it always remains at 1/##, any clue!!

kidney
03-17-2002, 11:02 PM
Ok, it only increments whitin the same thread, Isn't suppose to work accross the forum?

Tommy Boy
03-18-2002, 10:32 AM
Yes it is. It might be conflicting with another hack you have installed. Try reapplying it, but use another name instead of "postcount".

kidney
03-18-2002, 12:15 PM
Yup it's conflicting with Biras' "Post Counter & Direct Link"

I know that you can fix it, but I figured that I have already done it, so I will pm the new file...

julius
05-18-2003, 07:29 AM
Mysql error when you delete a thread. (vb 2.3.0.)