PDA

View Full Version : User's Percent of Total Posts


apfeifer
11-02-2001, 10:00 PM
Hack: User's Percent of Total Posts
Version of vB: 2.2.0, although may work on earlier versions but not tested
Current Version: 1.0.0
Description: This gives you a user's percent of the total posts on your forum.

Once again, this is a small hack but show's something interesting. Enjoy!

:cool:

apfeifer
11-03-2001, 01:30 AM
Er, duh, helps if I attach the file...

03.11.01: Fixed issue with percent's on users with post count of over 1000, thanks FireFly!

LanciaStratos
11-03-2001, 02:15 AM
Very nice hack! But, when I tried it out, it said that one of my users had 5988.52% of total posts. :?: :)

JJR512
11-03-2001, 03:09 AM
Yeah, it looks like the results are 1000 times higher than what they should be.

For example, I have 9771 posts on a 116,395-post board. I have 8.39469% of the total posts. Yet it says I have 8423.28%. (It also looks like the rounding is off.)

MrLister
11-03-2001, 03:47 AM
hmm well on popular boards the percent would be .02 % and so forth.... also it's a good idea to restrict the number of decimals.

apfeifer
11-03-2001, 11:40 AM
Eek, sorry about that, I'll fix it as soon as I get home from tryouts.

:cool:

apfeifer
11-03-2001, 12:20 PM
Originally posted by JJR512
Yeah, it looks like the results are 1000 times higher than what they should be.

For example, I have 9771 posts on a 116,395-post board. I have 8.39469% of the total posts. Yet it says I have 8423.28%. (It also looks like the rounding is off.)

Hmm, I just plugged the numbers for your posts / your boards posts in and it worked fine:

$percentoftotalposts = round((9774 / 116429) * 100,2);

echo $percentoftotalposts;

That echo's: 8.39

So I'm not totally sure. Paste the exact code that you have in member.php (just those couple lines, of course:p), and I'll look them over. I don't really see anything to fix because it's working for me.

:cool:

Admin
11-03-2001, 12:23 PM
$totalposts=number_format($countposts['posts']);
should be
$totalposts=$countposts['posts'];
because number_format() adds commas to the number (i.e 1000 => 1,000).

apfeifer
11-03-2001, 03:07 PM
Thank's FireFly! I have uploaded the fixed version of it.

:cool:

toLTcaboLT
11-03-2001, 03:21 PM
Hmzz I know it's little stupid .. but when I install where I can see that info ? :)

Can someone post screenshot .. I wanna too see that Hack .. Please? Tnx

apfeifer
11-03-2001, 03:27 PM
Here ya go:

https://vborg.vbsupport.ru/attachment.php?s=&postid=197862&fullpage=1

toLTcaboLT
11-03-2001, 03:34 PM
Cool .. Tnx man :)

LanciaStratos
11-03-2001, 03:36 PM
Working great now. Thanks apfeifer and FireFly! :)

JJR512
11-03-2001, 03:42 PM
First, thanks to FireFly; that fixed my problem.

Next, I'd like to show how I took the basic idea of this hack and extended it to work with tubedogg's 'user has started xx threads' hack (which was my idea ;)). This hack adds a new line to a person's profile, below the person's post count (and now the post percentage count, with this hack), and shows how many threads a person has started. What I've done is taken the idea of this hack, interfaced it with tubedogg's hack, to display the percentage of total threads that a person has started.

1. Install this hack
2. Install tubedogg's hack from here (https://vborg.vbsupport.ru/showthread.php?s=&threadid=12104), only instead of adding the contents of his memberadd.txt file where he tells you to in his step #2, insert the contents of that file just above the bit you added from this hack.
3. Below the bit you added to member.php from this hack, add this:
// Find percentage of threads started
$counttotalthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
$totalthreads=$counttotalthreads['threads'];
$percentageoftotalthreads = round(($starts / $totalthreads) * 100,2);
4. In the getinfo template, assuming you have already added the contents of getinfoadd.txt from tubedogg's hack, find $starts and change it to $starts ($percentageoftotalthreads% of total threads).

I would like to get permission from apfeifer and tubedogg to re-release their individual hacks along with my modifications as one unified hack (with full crediting, of course).

apfeifer
11-03-2001, 03:44 PM
Me likes!

:cool:

Admin
11-03-2001, 03:45 PM
No problems. :)
I installed this here, it's cool to have. :pleased:

GeorgeofCS
11-03-2001, 03:57 PM
I got it to work, but I did have a problem in this line

$percentoftotalposts = round(($userinfo[posts] / $totalposts) * 100,2);

it wouldn't work so I had to change it to

$percentoftotalposts = round(($userinfo[posts] / $totalposts) * 100);

but for me it doesn't give decimals.

Admin
11-03-2001, 04:04 PM
What version of PHP are you using George?

Admin
11-03-2001, 04:16 PM
http://www.vbulletin.com/forum/showthread.php?s=&threadid=32024

Try to use this:
$percentoftotalposts=sprintf('%.2f', (($userinfo[posts] / $totalposts) * 100);

GeorgeofCS
11-03-2001, 04:33 PM
Unfortunately I'm on php 3.16 I think. I'd have to check on the actual version number.

That replacement string didn't work :(

Admin
11-03-2001, 04:39 PM
Ooops, sorry. Did a typo. :o
Try again. :)

GeorgeofCS
11-03-2001, 05:02 PM
well that didn't work at first, but I found another typo and it works now with

$percentoftotalposts = sprintf('%.2f', (($userinfo[posts] / $totalposts) * 100));

Thank you :)

apfeifer
11-04-2001, 09:08 PM
Glad to see you got it working!

Should I change the documentation so it is compatible with older versions of PHP?

:cool:

eva2000
11-04-2001, 10:02 PM
:cool:

KuraFire
11-05-2001, 10:57 PM
I've got this installed, thanks man, nice hack! ^_^

over
11-09-2001, 08:37 PM
nice hack :) thnx
couple of days ago i spent ages gettin some stats sorted for the top 10 posters :) gonna slightly modify it if thats ok with u to show % on the topposters script.

Sweet Evil
11-14-2001, 05:00 AM
Yet another nice little feature by apfeifer, Thanks! ;)

punkbull
11-17-2001, 12:54 PM
I'm getting this error at the top of my forum's profile page:

Warning: Division by zero in /home/punkbull/public_html/member.php on line 1151

The user has no posts... I noticed that this is not happening with the vBulletin.org forums... I'm using the code straight from that text file. Any ideas?

Sweet Evil
11-17-2001, 02:22 PM
What is you line 1151?

Mine has nothing to do with this edit.. but talks about Moderators..

Did you install another hack at the same time as this one?

If I ever have a problem, I like to take Araxis Merge 2001 Professional and open my file thats having problems and a orig.. from the zip file.... to see what could be wrong..

punkbull
11-17-2001, 11:08 PM
Ahh, it was because there were no threads on the entire board ;)

Thank you!

Sadie Frost
01-11-2002, 11:51 AM
Great hack!

Could someone help me figure out how to put this in my forumhome? I tried just inserting the "$percentoftotalposts% of total posts" but when I do that all I get is "% of total posts". Am I doing something wrong?

Thanks for your help! :)

69-FLy-gUy
01-22-2002, 06:10 AM
You mean the postbit template when you make a post?

If so.. I am wondering how to also..

I palced the contents in showthread.php, but when i did, it made the pages 427 pages long for some reason...

Any help??
Ciao

inetd
05-05-2002, 06:04 AM
* inetd installed this hack
Good hack! :)

inetd
05-05-2002, 06:07 AM
Originally posted by Sadie Frost
Great hack!

Could someone help me figure out how to put this in my forumhome? I tried just inserting the "$percentoftotalposts% of total posts" but when I do that all I get is "% of total posts". Am I doing something wrong?

Thanks for your help! :) Sadie, you must add this code $countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=$countposts['posts'];

$percentoftotalposts = round(($userinfo[posts] / $totalposts) * 100,2); in index.php
after this$numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
$numbermembers=number_format($numbersmembers['users']);

And add $percentoftotalposts% of total posts in forumhome template :)

GL!

Eniyi
05-16-2002, 01:28 PM
Which file am I supposed to edit to put the percentage in the postbit?

Broekie
05-16-2002, 02:38 PM
to also get the threads per day (assuming you've installed this hack and tubedog's hack according to this info: https://vborg.vbsupport.ru/showthread.php?postid=198068#post198068)

in member.php

FIND
$jointime = (time() - $userinfo[joindate]) / 86400; // Days Joined
if ($jointime < 1) { // User has been a member for less than one day.
$postsperday = "$userinfo[posts]";

ADD DIRECTLY UNDER THAT

$threadsperday = "$starts";

FIND
$postsperday = sprintf("%.2f",($userinfo[posts] / $jointime));

ADD DIRECTLY UNDER THAT

$threadsperday = sprintf("%.2f",($starts / $jointime));

save and upload

than, in the getinfo template
REPLACE

$starts ($percentageoftotalthreads% of total threads)

WITH

$starts ($threadsperday threads per day / $percentageoftotalthreads% of total threads)

and it should work fine :)

PS: see the screenie to see what I mean ;)

FleaBag
05-16-2002, 11:20 PM
Installed on 2.2.5. Thanks for this hack!

Velocd
05-19-2002, 02:55 PM
For the users with low posts, their percentage seems to be accurate, but for some reason I and others with high posts are getting a percentage over 100, see attachment:

Broekie
05-20-2002, 06:32 AM
Originally posted by Velocd
For the users with low posts, their percentage seems to be accurate, but for some reason I and others with high posts are getting a percentage over 100, see attachment:

Looks like you've got an old version of this hack (that old version had this problem)

just read the first few posts, and see if that can help you...

Eniyi
05-22-2002, 02:06 PM
I guess my question was missed.

How can I display this percentage in the postbit?

FleaBag
06-20-2002, 09:29 AM
Working on 2.2.6, thanks! :D

mrdave
07-01-2002, 02:41 PM
A combination of a couple of hacks and a fix for the error when there are no posts on the entire board: by kreft
Total Threads And Percentage Of Total Posts & Threads In Users Profile
A combination of User's Percent of Total Posts by apfeifer &
User Has Started X Threads by tubedogg

member.php
FIND:

if ($userinfo[customtitle]==2)
$userinfo[usertitle] = htmlspecialchars($userinfo[usertitle]);
$userinfo[datejoined]=vbdate($dateformat,$userinfo[joindate]);

ADD this after:


$startcount = $DB_site->query_first("SELECT COUNT(title) AS starts FROM thread WHERE postusername='$userinfo[username]' AND open!='10'");
$starts = $startcount[starts];
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=$countposts['posts'];
if ($totalposts == 0) { $totalposts=$totalposts + 1; }
$percentoftotalposts = round(($userinfo[posts] / $totalposts) * 100,2);
$counttotalthreads=$DB_site->query_first('SELECT count(*) AS threads FROM thread');
$totalthreads=$counttotalthreads['threads'];
if ($totalthreads == 0) { $totalthreads=$totalthreads + 1; }
$percentageoftotalthreads = round(($starts / $totalthreads) * 100,2);

getinfo template
FIND:

<tr>
<td bgcolor=""><normalfont><b>Total Posts:</b></normalfont></td>
<td bgcolor=""><normalfont>$userinfo[posts]($postsperday posts per day)</normalfont></td>
</tr>

ADD this after:
<tr>
<td bgcolor=""><normalfont><b>Total Threads:</b></normalfont></td>
<td bgcolor=""><normalfont>$starts</normalfont></td>
</tr>
<tr>
<td bgcolor=""><normalfont><b>Percent of Total Posts & Threads:</b></normalfont></td>
<td bgcolor=""><normalfont>$percentoftotalposts% of total posts | $percentageoftotalthreads% of total threads</normalfont></td>
</tr>

The Ghost
07-21-2002, 04:40 PM
hi,

work's great on 2.2.6, thx for this great hack!

FleaBag
09-03-2002, 03:44 PM
Work well on 2.2.7. :D

khaleejy
09-23-2002, 06:08 PM
hi

this is my first hack but it goes alright. this hack shows the member posts percent of the total board posts in the member profile page.

just take a look at:
https://vborg.vbsupport.ru/member.php?s=&action=getinfo&userid=17654

Total Posts: 29 (0.48 posts per day | 0.02% of total posts on board)

that what the hack will do to you

sorry for my bad english,
humood :)

Velocd
09-23-2002, 06:19 PM
This has been done before :p
https://vborg.vbsupport.ru/showthread.php?s=&threadid=32050

Just to let you know ;)

khaleejy
09-23-2002, 06:44 PM
well i didnt know :|

neocorteqz
09-24-2002, 10:03 AM
well maybe someone can help me. I'm using version 2.2.7.


Whats happening is it's showing the % of post, but not the PPD (post per day). I'm using the original of this hack. All i want is the PPD to show up again. how would i go about fixing this?
Thanks.

http://nemesis.thecoldshop.com/member.php?s=&action=getinfo&userid=1


a snipet of my getinfo template


<tr>

<td bgcolor="#1C5780"><normalfont><b>Total Posts:</b></normalfont></td>
<td bgcolor="#1C5780"><normalfont>$userinfo[posts] ($postsperday posts per day / $percentoftotalposts% of total posts)</normalfont></td>
</tr>


and what I did to member.php

// grab the total number of posts to compare to this users
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=$countposts['posts'];

$percentoftotalposts = round(($userinfo[posts] / $totalposts) * 100,2);



Thanks for the help.

FleaBag
10-29-2002, 08:44 PM
Works with 2.2.8. :)

BaldNut
02-02-2003, 10:45 PM
working excellent in profile view, but how would i get it to work in my phpportals top ten page, i tried just adding "/ $percentoftotalposts% of total posts"

but that just gave blank results, any ideas ?

Alien
05-28-2003, 03:48 AM
Just to be clear, this adds +1 query to the member's profile pages?